@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,6 +1,30 @@
1
- import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {CommonType}from'@common-stack/core';import {ServiceBroker}from'moleculer';import'@cdm-logger/core';import {MoleculerTopics,MessengerNotificationServiceCommands}from'common';let MessengerNotificationMicroservice = class MessengerNotificationMicroservice {
1
+ import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {CommonType}from'@common-stack/core';import {ServiceBroker}from'moleculer';import'@cdm-logger/core';import {DisposableCollection}from'@adminide-stack/core';import {MoleculerTopics,MessengerNotificationServiceCommands}from'common/server';/**
2
+ * Messenger Notification Microservice Implementation
3
+ *
4
+ * This microservice handles comprehensive notification management within the messenger platform,
5
+ * providing operations for sending various types of notifications including email, SMS,
6
+ * push notifications, and Expo notifications across different messaging contexts through
7
+ * service broker delegation.
8
+ *
9
+ * Key capabilities:
10
+ * - Multi-channel notification delivery (email, SMS, push, Expo)
11
+ * - Unread message notification scheduling and management
12
+ * - User preference-based notification filtering
13
+ * - Support service notification handling
14
+ * - Alert message notification broadcasting
15
+ * - Thread-based notification management
16
+ * - Real-time push notification integration
17
+ * - Template-based notification customization
18
+ * - Channel and post-based notification routing
19
+ * - User aggregation and preference management
20
+ *
21
+ * The microservice integrates with multiple external services through Moleculer broker
22
+ * and provides comprehensive error handling and logging for notification workflows.
23
+ */
24
+ let MessengerNotificationMicroservice = class MessengerNotificationMicroservice {
2
25
  broker;
3
26
  logger;
27
+ toDispose = new DisposableCollection();
4
28
  topic = MoleculerTopics.MessengerNotificationService;
5
29
  constructor(broker, logger) {
6
30
  this.broker = broker;
@@ -9,42 +33,313 @@ import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from
9
33
  className: 'MessengerNotificationMicroservice'
10
34
  });
11
35
  }
36
+ /**
37
+ * Disposes of resources used by the service
38
+ */
39
+ dispose() {
40
+ this.toDispose.dispose();
41
+ }
42
+ /**
43
+ * Calls a microservice action with proper error handling
44
+ *
45
+ * @description Protected method to handle microservice communication
46
+ *
47
+ * @param {string} command - The command to execute
48
+ * @param {P} params - Parameters for the command
49
+ * @returns {Promise<T>} - Result from microservice
50
+ */
12
51
  async callAction(command, params) {
13
52
  return this.broker.call(`${this.topic}.${command}`, params);
14
53
  }
15
- sendNotificationOfUnreadMessages(unit, value) {
16
- return this.callAction(MessengerNotificationServiceCommands.SendNotificationOfUnreadMessages, {
17
- unit,
18
- value
19
- });
54
+ /**
55
+ * Sends notification for unread messages within a specified time frame
56
+ *
57
+ * @description Aggregates unread messages across channels and sends notifications
58
+ * to users based on their preferences within the specified duration
59
+ *
60
+ * @param {NotificationDurationUnitEnum} unit - Time unit for the duration
61
+ * @param {number} value - Number of time units to look back
62
+ * @returns {Promise<boolean | Error>} - Success status or error
63
+ */
64
+ // @ts-ignore - Enhanced error handling pattern with Error union type
65
+ async sendNotificationOfUnreadMessages(unit, value) {
66
+ try {
67
+ this.logger.debug('Sending notification of unread messages via microservice', {
68
+ unit,
69
+ value
70
+ });
71
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendNotificationOfUnreadMessages, {
72
+ unit,
73
+ value
74
+ });
75
+ if (typeof result !== 'boolean') {
76
+ return new Error('Invalid result from microservice');
77
+ }
78
+ this.logger.debug('Notification of unread messages sent successfully via microservice', {
79
+ unit,
80
+ value,
81
+ success: result
82
+ });
83
+ return result;
84
+ } catch (error) {
85
+ this.logger.error('Error sending notification of unread messages via microservice: %o', error);
86
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending unread message notifications');
87
+ }
20
88
  }
21
- sendNotificationOnPost(post) {
22
- return this.callAction(MessengerNotificationServiceCommands.SendNotificationOnPost, {
23
- post
24
- });
89
+ /**
90
+ * Sends general notifications for a post
91
+ *
92
+ * @description Handles email and SMS notifications for posts with template support
93
+ *
94
+ * @param {IPost} post - The post that triggered the notification
95
+ * @returns {Promise<boolean | Error>} - Success status or error
96
+ */
97
+ // @ts-ignore - Enhanced error handling pattern with Error union type
98
+ async sendNotificationOnPost(post) {
99
+ try {
100
+ this.logger.debug('Sending notification on post via microservice', {
101
+ postId: post.id
102
+ });
103
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendNotificationOnPost, {
104
+ post
105
+ });
106
+ if (typeof result !== 'boolean') {
107
+ return new Error('Invalid result from microservice');
108
+ }
109
+ this.logger.debug('Notification on post sent successfully via microservice', {
110
+ postId: post.id,
111
+ success: result
112
+ });
113
+ return result;
114
+ } catch (error) {
115
+ this.logger.error('Error sending notification on post via microservice: %o', error);
116
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending post notification');
117
+ }
25
118
  }
26
- sendNotificationOfAlertMessages(unit, value) {
27
- return this.callAction(MessengerNotificationServiceCommands.SendNotificationOfAlertMessages, {
28
- unit,
29
- value
30
- });
119
+ /**
120
+ * Sends notifications for alert messages within a time frame
121
+ *
122
+ * @description Processes and sends notifications for alert-type messages
123
+ *
124
+ * @param {NotificationDurationUnitEnum} unit - Time unit for the duration
125
+ * @param {number} value - Number of time units to look back
126
+ * @returns {Promise<boolean | Error>} - Success status or error
127
+ */
128
+ // @ts-ignore - Enhanced error handling pattern with Error union type
129
+ async sendNotificationOfAlertMessages(unit, value) {
130
+ try {
131
+ this.logger.debug('Sending notification of alert messages via microservice', {
132
+ unit,
133
+ value
134
+ });
135
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendNotificationOfAlertMessages, {
136
+ unit,
137
+ value
138
+ });
139
+ if (typeof result !== 'boolean') {
140
+ return new Error('Invalid result from microservice');
141
+ }
142
+ this.logger.debug('Notification of alert messages sent successfully via microservice', {
143
+ unit,
144
+ value,
145
+ success: result
146
+ });
147
+ return result;
148
+ } catch (error) {
149
+ this.logger.error('Error sending notification of alert messages via microservice: %o', error);
150
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending alert notifications');
151
+ }
31
152
  }
32
- sendPushNotificationsExpo(data) {
33
- return this.callAction(MessengerNotificationServiceCommands.SendPushNotificationsExpo, {
34
- data
35
- });
153
+ /**
154
+ * Sends Expo push notifications
155
+ *
156
+ * @description Sends push notifications through the Expo notification service
157
+ *
158
+ * @param {IExpoNotificationData} data - Notification data
159
+ * @returns {Promise<IExpoNotification | Error>} - Notification result or error
160
+ */
161
+ async sendPushNotificationsExpo(data) {
162
+ try {
163
+ this.logger.debug('Sending Expo push notifications via microservice', {
164
+ recipients: Array.isArray(data.to) ? data.to.length : 1,
165
+ hasTitle: !!data.title,
166
+ hasBody: !!data.body
167
+ });
168
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendPushNotificationsExpo, {
169
+ data
170
+ });
171
+ if (!result) {
172
+ return new Error('Failed to send Expo notification');
173
+ }
174
+ this.logger.debug('Expo push notifications sent successfully via microservice', {
175
+ status: result.status,
176
+ id: result.id
177
+ });
178
+ return result;
179
+ } catch (error) {
180
+ this.logger.error('Error sending Expo push notifications via microservice: %o', error);
181
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending Expo notification');
182
+ }
36
183
  }
37
- sendExpoNotificationOnPost(post, notificationData) {
38
- return this.callAction(MessengerNotificationServiceCommands.SendExpoNotificationOnPost, {
39
- post,
40
- notificationData
41
- });
184
+ /**
185
+ * Sends Expo notification when a post is created
186
+ *
187
+ * @description Handles push notification logic for new posts with thread and channel support
188
+ *
189
+ * @param {IPost} post - The post that triggered the notification
190
+ * @param {IExpoNotificationBodyData} notificationData - Optional notification data override
191
+ * @returns {Promise<boolean | Error>} - Success status or error
192
+ */
193
+ // @ts-ignore - Enhanced error handling pattern with Error union type
194
+ async sendExpoNotificationOnPost(post, notificationData) {
195
+ try {
196
+ this.logger.debug('Sending Expo notification on post via microservice', {
197
+ postId: post.id,
198
+ channelId: post.channel,
199
+ hasNotificationData: !!notificationData
200
+ });
201
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendExpoNotificationOnPost, {
202
+ post,
203
+ notificationData
204
+ });
205
+ if (typeof result !== 'boolean') {
206
+ return new Error('Invalid result from microservice');
207
+ }
208
+ this.logger.debug('Expo notification on post sent successfully via microservice', {
209
+ postId: post.id,
210
+ success: result
211
+ });
212
+ return result;
213
+ } catch (error) {
214
+ this.logger.error('Error sending Expo notification on post via microservice: %o', error);
215
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending post notification');
216
+ }
42
217
  }
43
- sendNotificationOfUnreadServiceMessages(unit, value) {
44
- return this.callAction(MessengerNotificationServiceCommands.SendNotificationOfUnreadServiceMessages, {
45
- unit,
46
- value
47
- });
218
+ /**
219
+ * Sends notifications for unread service messages
220
+ *
221
+ * @description Handles notifications for support service channels
222
+ *
223
+ * @param {NotificationDurationUnitEnum} unit - Time unit for the duration
224
+ * @param {number} value - Number of time units to look back
225
+ * @returns {Promise<boolean | Error>} - Success status or error
226
+ */
227
+ // @ts-ignore - Enhanced error handling pattern with Error union type
228
+ async sendNotificationOfUnreadServiceMessages(unit, value) {
229
+ try {
230
+ this.logger.debug('Sending notification of unread service messages via microservice', {
231
+ unit,
232
+ value
233
+ });
234
+ const result = await this.callAction(MessengerNotificationServiceCommands.SendNotificationOfUnreadServiceMessages, {
235
+ unit,
236
+ value
237
+ });
238
+ if (typeof result !== 'boolean') {
239
+ return new Error('Invalid result from microservice');
240
+ }
241
+ this.logger.debug('Notification of unread service messages sent successfully via microservice', {
242
+ unit,
243
+ value,
244
+ success: result
245
+ });
246
+ return result;
247
+ } catch (error) {
248
+ this.logger.error('Error sending notification of unread service messages via microservice: %o', error);
249
+ return error instanceof Error ? error : new Error('Unknown error occurred while sending service notifications');
250
+ }
251
+ }
252
+ /**
253
+ * Sets the support service configuration
254
+ *
255
+ * @description Updates the support service notification configuration for customized notifications
256
+ *
257
+ * @param {ISupportServiceConfig} config - Support service configuration
258
+ * @returns {Promise<void | Error>} - Void promise or error
259
+ */
260
+ // @ts-ignore - Enhanced error handling pattern with Error union type
261
+ async setSupportServiceConfig(config) {
262
+ try {
263
+ this.logger.debug('Setting support service config via microservice', {
264
+ hasEmail: !!config?.email,
265
+ hasTemplateId: !!config?.templateId,
266
+ hasVariables: !!config?.variables
267
+ });
268
+ await this.callAction(MessengerNotificationServiceCommands.SetSupportServiceConfig, {
269
+ config
270
+ });
271
+ this.logger.debug('Support service config set successfully via microservice');
272
+ } catch (error) {
273
+ this.logger.error('Error setting support service config via microservice: %o', error);
274
+ return error instanceof Error ? error : new Error('Unknown error occurred while setting support service config');
275
+ }
276
+ }
277
+ /**
278
+ * Validates notification data
279
+ *
280
+ * @description Helper method to validate notification data before processing
281
+ *
282
+ * @param {any} data - Data to validate
283
+ * @returns {Promise<boolean | Error>} - Validation result or error
284
+ */
285
+ async validateNotificationData(data) {
286
+ try {
287
+ if (!data) {
288
+ return new Error('Notification data is required');
289
+ }
290
+ // Basic validation logic
291
+ if (data.type === 'email' && !data.email) {
292
+ return new Error('Email is required for email notifications');
293
+ }
294
+ if (data.type === 'sms' && !data.phoneNumber) {
295
+ return new Error('Phone number is required for SMS notifications');
296
+ }
297
+ if (data.type === 'expo' && !data.to) {
298
+ return new Error('Recipients are required for Expo notifications');
299
+ }
300
+ this.logger.debug('Notification data validation passed', {
301
+ type: data.type
302
+ });
303
+ return true;
304
+ } catch (error) {
305
+ this.logger.error('Error validating notification data: %o', error);
306
+ return error instanceof Error ? error : new Error('Unknown error occurred while validating notification data');
307
+ }
308
+ }
309
+ /**
310
+ * Gets notification statistics
311
+ *
312
+ * @description Convenience method to get notification delivery statistics
313
+ *
314
+ * @param {string} userId - The user identifier (optional)
315
+ * @param {Date} startDate - Start date for statistics
316
+ * @param {Date} endDate - End date for statistics
317
+ * @returns {Promise<any | Error>} - Notification statistics or error
318
+ */
319
+ async getNotificationStatistics(userId, startDate, endDate) {
320
+ try {
321
+ this.logger.debug('Getting notification statistics via microservice', {
322
+ userId,
323
+ startDate: startDate?.toISOString(),
324
+ endDate: endDate?.toISOString()
325
+ });
326
+ const result = await this.broker.call(`${this.topic}.getNotificationStatistics`, {
327
+ userId,
328
+ startDate,
329
+ endDate
330
+ });
331
+ if (!result) {
332
+ return new Error('Failed to get notification statistics');
333
+ }
334
+ this.logger.debug('Notification statistics retrieved successfully via microservice', {
335
+ userId,
336
+ hasStats: !!result
337
+ });
338
+ return result;
339
+ } catch (error) {
340
+ this.logger.error('Error getting notification statistics via microservice: %o', error);
341
+ return error instanceof Error ? error : new Error('Unknown error occurred while getting notification statistics');
342
+ }
48
343
  }
49
344
  };
50
345
  MessengerNotificationMicroservice = __decorate([injectable(), __param(0, inject(CommonType.MOLECULER_BROKER)), __param(1, inject('Logger')), __metadata("design:paramtypes", [ServiceBroker, Object])], MessengerNotificationMicroservice);export{MessengerNotificationMicroservice};//# sourceMappingURL=messenger-notification-microservice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messenger-notification-microservice.js","sources":["../../../src/services/proxy-services/messenger-notification-microservice.ts"],"sourcesContent":[null],"names":[],"mappings":"iRAgBa,IAAA,iCAAiC,GAAvC,MAAM,iCAAiC,CAAA;AAKrB,EAAA,MAAA;AAEA,EAAA,MAAA;AANrB,EAAA,KAAA,GAAQ,eAAA,CAAA,4BAAgB;aAIH,CAAA,MAAA,EAAqB,MAEI,EAAA;QAFzB,CAAM,MAAA,GAAA;QAEN,CAAM,MAAA,GAAA;AAEvB,IAAA,IAAA,CAAA,MAAK,GAAA,MAAS,CAAA,KAAO,CAAA;MACxB,SAAA,EAAA;AAES,KAAA,CAAA;AACN;QACH,UAAA,CAAA,OAAA,EAAA,MAAA,EAAA;IAED,OAAgC,IAAA,CAAA,MAAA,CAAA,IAAA,CAAA,CAAA,EAAA,IAAA,CAAA,KAAmC,CAAA,CAAE,EAAa,OAAA,CAAA,CAAA,EAAA,MAAA,CAAA;AAC9E;kCACQ,CAAA,IAAA,EAAA,KAAA,EAAA;eACC,CAAA,UAAA,CAAA,oCAAA,CAAA,gCAAA,EAAA;AACR,MAAA,IAAC;MACL;AAED,KAAA,CAAA;AACI;wBACQ,CAAA,IAAA,EAAA;AACP,IAAA,OAAE,IAAA,CAAA,UAAA,CAAA,oCAAA,CAAA,sBAAA,EAAA;MACN;KAE8B,CAAA;AAC3B;iCACQ,CAAA,IAAA,EAAA,KAAA,EAAA;eACC,CAAA,UAAA,CAAA,oCAAA,CAAA,+BAAA,EAAA;AACR,MAAA,IAAC;MACL;AAED,KAAA,CAAA;AACI;2BACQ,CAAA,IAAA,EAAA;AACP,IAAA,OAAE,IAAA,CAAA,UAAA,CAAA,oCAAA,CAAA,yBAAA,EAAA;MACN;KAEyB,CAAA;AACtB;4BACQ,CAAA,IAAA,EAAA,gBAAA,EAAA;eACY,CAAA,UAAA,CAAA,oCAAA,CAAA,0BAAA,EAAA;AACnB,MAAA,IAAC;MACL;KAEsC,CAAA;AACnC;yCACQ,CAAA,IAAA,EAAA,KAAA,EAAA;eACC,CAAA,UAAA,CAAA,oCAAA,CAAA,uCAAA,EAAA;AACR,MAAA,IAAC;MACL;KACJ,CAAA;AAvDY;AADZ;AAKQ,iCAAkB,GAAA,UAAA,CAAA,CAAA,UAAiB,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,iCAAA,CAAA"}
1
+ {"version":3,"file":"messenger-notification-microservice.js","sources":["../../../src/services/proxy-services/messenger-notification-microservice.ts"],"sourcesContent":[null],"names":[],"mappings":"gVAiBA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AAEU,IAAA,iCAAiC,GAAvC,MAAM,iCAAiC,CAAA;AAMrB,EAAA,MAAA;AAEA,EAAA,MAAA;AAPF,EAAA,SAAA,GAAY,IAAA,oBAAwB,EAAA;AACvD,EAAA,KAAA,GAAQ,eAAA,CAAA,4BAAgB;aAIH,CAAA,MAAA,EAAqB,MAEI,EAAA;QAFzB,CAAM,MAAA,GAAA;QAEN,CAAM,MAAA,GAAA;AAEvB,IAAA,IAAA,CAAA,MAAK,GAAA,MAAS,CAAA,KAAO,CAAA;MACxB,SAAA,EAAA;AAED,KAAA,CAAA;;AAEG;;AAEC;SACH,GAAA;AAED,IAAA,IAAA,CAAA,SAAA,CAAA,OAAA,EAAA;;;;;;;;AAQG;AACO;AACN;QACH,UAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AAED,IAAA,OAAA,IAAA,CAAA,MAAA,CAAA,IAAA,CAAA,CAAA,EAAA,IAAA,CAAA,KAAA,CAAA,CAAA,EAAA,OAAA,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;;;AAGT;AACA,iCAAY,GAAA,UAAA,CAAA,CAAA,UAAA,EAAA,EAAA,OAAA,CAAA,CAAA,EAAA,MAAA,CAAA,UAA8D,CAAC,gBAAC,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,iCAAA,CAAA"}
@@ -1,21 +1,216 @@
1
1
  import { ServiceBroker } from 'moleculer';
2
- import { IFileInfo, IMessageIdentifier, MoleculerTopics as MoleculerTopics, IPost, IPostThread, IUploadedFileInput, IPostService, IPostServiceInput, CreatePostThreadOptions } from 'common';
2
+ import { IFileInfo, IMessageIdentifier, MoleculerTopics as MoleculerTopics, IPostModel, IPostThread, IUploadedFileInput, IPostService, IPostServiceInput, CreatePostThreadOptions, AsDomainType, ICodeAgentRequest, IFileUpdateResponse } from 'common/server';
3
3
  import { BaseProxyService } from '@common-stack/store-mongo';
4
4
  import { CdmLogger } from '@cdm-logger/core';
5
- export declare class PostProxyService extends BaseProxyService<IPost, IPostServiceInput, Partial<IPost>> implements IPostService {
5
+ import { Disposable, DisposableCollection } from '@adminide-stack/core';
6
+ /**
7
+ * Post Microservice Implementation
8
+ *
9
+ * This microservice handles comprehensive post management within the messenger platform,
10
+ * providing operations for creating, updating, managing posts and their associated
11
+ * content including file attachments, notifications, threading, and real-time
12
+ * message delivery across channels and organizations through service broker delegation.
13
+ *
14
+ * Key capabilities:
15
+ * - Post lifecycle management (creation, updates, deletion)
16
+ * - File attachment handling and upload management
17
+ * - Real-time message delivery and notifications
18
+ * - Post threading and conversation management
19
+ * - Message status tracking (read, delivered)
20
+ * - Channel integration and message counting
21
+ * - Expo push notification integration
22
+ * - File upload link generation and management
23
+ */
24
+ export declare class PostProxyService extends BaseProxyService<IPostModel, IPostServiceInput, Partial<IPostModel>> implements IPostService, Disposable {
6
25
  protected readonly logger: CdmLogger.ILogger;
26
+ protected readonly toDispose: DisposableCollection;
7
27
  topic: MoleculerTopics;
8
28
  constructor(broker: ServiceBroker, logger: CdmLogger.ILogger);
9
- attachUploadedFile(postId: string, file: IUploadedFileInput, createdBy: string): Promise<IFileInfo>;
10
- createFileUploadLink(postId: string, filename: string, userId: string): Promise<string>;
11
- attachUploadedFiles(postId: string, files: IUploadedFileInput[], createdBy: string): Promise<IFileInfo[]>;
12
- createFilesUploadLink(postId: string, filenames: string[], userId: string): Promise<string[]>;
13
- deleteFile(url: string): Promise<boolean>;
14
- readMessage(messageId: IMessageIdentifier, user: string): Promise<boolean>;
15
- deliverMessage(messageId: IMessageIdentifier, user: string): Promise<boolean>;
16
- createWithoutSubscription(data: IPostServiceInput): Promise<IPost>;
29
+ /**
30
+ * Disposes of resources used by the service
31
+ */
32
+ dispose(): void;
33
+ /**
34
+ * Creates a file upload link for a post
35
+ *
36
+ * @description Generates a secure upload URL for attaching files to posts
37
+ *
38
+ * @param {string} postId - The post identifier
39
+ * @param {string} filename - The name of the file to upload
40
+ * @param {string} userId - The user performing the upload
41
+ * @returns {Promise<string | Error>} - Upload URL or error
42
+ */
43
+ createFileUploadLink(postId: string, filename: string, userId: string): Promise<string | Error>;
44
+ /**
45
+ * Attaches an uploaded file to a post
46
+ *
47
+ * @description Processes and attaches a completed file upload to a post
48
+ *
49
+ * @param {string} postId - The post identifier
50
+ * @param {IUploadedFileInput} file - The uploaded file information
51
+ * @param {string} createdBy - The user who uploaded the file
52
+ * @returns {Promise<IFileInfo | Error>} - File information or error
53
+ */
54
+ attachUploadedFile(postId: string, file: IUploadedFileInput, createdBy: string): Promise<IFileInfo | Error>;
55
+ /**
56
+ * Creates upload links for multiple files
57
+ *
58
+ * @description Generates secure upload URLs for multiple files to be attached to a post
59
+ *
60
+ * @param {string} postId - The post identifier
61
+ * @param {string[]} filenames - Array of file names
62
+ * @param {string} userId - The user performing the uploads
63
+ * @returns {Promise<string[] | Error>} - Array of upload URLs or error
64
+ */
65
+ createFilesUploadLink(postId: string, filenames: string[], userId: string): Promise<string[] | Error>;
66
+ /**
67
+ * Attaches multiple uploaded files to a post
68
+ *
69
+ * @description Processes and attaches multiple completed file uploads to a post
70
+ *
71
+ * @param {string} postId - The post identifier
72
+ * @param {IUploadedFileInput[]} files - Array of uploaded file information
73
+ * @param {string} createdBy - The user who uploaded the files
74
+ * @returns {Promise<IFileInfo[] | Error>} - Array of file information or error
75
+ */
76
+ attachUploadedFiles(postId: string, files: IUploadedFileInput[], createdBy: string): Promise<IFileInfo[] | Error>;
77
+ /**
78
+ * Creates a new post with full integration
79
+ *
80
+ * @description Creates a post with channel updates, notifications, and real-time publishing
81
+ *
82
+ * @param {IPostServiceInput} data - Post creation data
83
+ * @returns {Promise<AsDomainType<IPostModel> | Error>} - Created post or error
84
+ */
85
+ create(data: IPostServiceInput): Promise<AsDomainType<IPostModel> | Error>;
86
+ /**
87
+ * Creates a post without real-time subscription
88
+ *
89
+ * @description Creates a post with channel updates but without real-time publishing
90
+ *
91
+ * @param {IPostServiceInput} data - Post creation data
92
+ * @returns {Promise<AsDomainType<IPostModel> | Error>} - Created post or error
93
+ */
94
+ createWithoutSubscription(data: IPostServiceInput): Promise<AsDomainType<IPostModel> | Error>;
95
+ /**
96
+ * Deletes a file by URL
97
+ *
98
+ * @description Removes a file from storage using its URL
99
+ *
100
+ * @param {string} url - The file URL to delete
101
+ * @returns {Promise<boolean | Error>} - Success status or error
102
+ */
103
+ deleteFile(url: string): Promise<boolean | Error>;
104
+ /**
105
+ * Marks a message as read by a user
106
+ *
107
+ * @description Updates message status to indicate it has been read by a specific user
108
+ *
109
+ * @param {IMessageIdentifier} messageId - Message identifier
110
+ * @param {string} user - User ID who read the message
111
+ * @returns {Promise<boolean | Error>} - Success status or error
112
+ */
113
+ readMessage(messageId: IMessageIdentifier, user: string): Promise<boolean | Error>;
114
+ /**
115
+ * Marks a message as delivered to a user
116
+ *
117
+ * @description Updates message status to indicate it has been delivered to a specific user
118
+ *
119
+ * @param {IMessageIdentifier} messageId - Message identifier
120
+ * @param {string} user - User ID who received the message
121
+ * @returns {Promise<boolean | Error>} - Success status or error
122
+ */
123
+ deliverMessage(messageId: IMessageIdentifier, user: string): Promise<boolean | Error>;
124
+ /**
125
+ * Creates a post with associated post thread
126
+ *
127
+ * @description Creates both a post and its associated thread for threaded conversations
128
+ *
129
+ * @param {CreatePostThreadOptions} data - Post and thread creation options
130
+ * @returns {Promise<{post: AsDomainType<IPostModel>; postThread: IPostThread} | Error>} - Created post and thread or error
131
+ */
17
132
  createPostWithPostThread(data: CreatePostThreadOptions): Promise<{
18
- post: IPost;
133
+ post: AsDomainType<IPostModel>;
19
134
  postThread: IPostThread;
20
- }>;
135
+ } | Error>;
136
+ /**
137
+ * Retrieves the last message in a channel
138
+ *
139
+ * @description Gets the most recent post/message from a specific channel
140
+ *
141
+ * @param {string} channelId - The channel identifier
142
+ * @returns {Promise<AsDomainType<IPostModel> | Error>} - Last message or error
143
+ */
144
+ getLastMessage(channelId: string): Promise<AsDomainType<IPostModel> | Error>;
145
+ /**
146
+ * Gets posts by channel with pagination
147
+ *
148
+ * @description Retrieves posts from a channel with pagination support
149
+ *
150
+ * @param {string} channelId - The channel identifier
151
+ * @param {number} limit - Maximum number of posts to return
152
+ * @param {number} offset - Number of posts to skip
153
+ * @returns {Promise<Array<AsDomainType<IPostModel>> | Error>} - Array of posts or error
154
+ */
155
+ getPostsByChannel(channelId: string, limit?: number, offset?: number): Promise<Array<AsDomainType<IPostModel>> | Error>;
156
+ /**
157
+ * Updates a post
158
+ *
159
+ * @description Updates post content and metadata
160
+ *
161
+ * @param {string} postId - The post identifier
162
+ * @param {Partial<IPostServiceInput>} updates - Update data
163
+ * @returns {Promise<AsDomainType<IPostModel> | Error>} - Updated post or error
164
+ */
165
+ updatePost(postId: string, updates: Partial<IPostServiceInput>): Promise<AsDomainType<IPostModel> | Error>;
166
+ /**
167
+ * Deletes a post
168
+ *
169
+ * @description Soft deletes a post and its associated data
170
+ *
171
+ * @param {string} postId - The post identifier
172
+ * @returns {Promise<boolean | Error>} - Success status or error
173
+ */
174
+ deletePost(postId: string): Promise<boolean | Error>;
175
+ /**
176
+ * Validates post data for creation or updates
177
+ *
178
+ * @description Helper method to validate post data before processing
179
+ *
180
+ * @param {IPostServiceInput} data - Data to validate
181
+ * @returns {Promise<boolean | Error>} - Validation result or error
182
+ */
183
+ validatePostData(data: IPostServiceInput): Promise<boolean | Error>;
184
+ /**
185
+ * Gets posts by author with pagination
186
+ *
187
+ * @description Convenience method to get posts created by a specific author
188
+ *
189
+ * @param {string} authorId - The author identifier
190
+ * @param {number} limit - Maximum number of posts to return
191
+ * @param {number} offset - Number of posts to skip
192
+ * @returns {Promise<Array<AsDomainType<IPostModel>> | Error>} - Array of posts or error
193
+ */
194
+ getPostsByAuthor(authorId: string, limit?: number, offset?: number): Promise<Array<AsDomainType<IPostModel>> | Error>;
195
+ /**
196
+ * Retrieves previous messages for a specific project
197
+ *
198
+ * @description Fetches the most recent messages from a project, formatted for AI agent context.
199
+ *
200
+ * @param {string} projectId - The unique identifier of the project
201
+ * @param {number} limit - Maximum number of messages to retrieve (default: 5)
202
+ * @returns {Promise<Array<IPostModel> | Error>} - Array of formatted messages or error
203
+ */
204
+ getPreviousMessagesByProjectId(projectId: string, limit?: number): Promise<Array<IPostModel> | Error>;
205
+ /**
206
+ * Saves code agent result with comprehensive data
207
+ *
208
+ * @description Saves the result from a code agent operation including message creation,
209
+ * fragment generation, and project update publishing. Handles both success and error cases
210
+ * with proper message creation and fragment management.
211
+ */
212
+ saveCodeAgentResult(request: ICodeAgentRequest, sandboxUrl: string, fragmentTitle: string, responseContent: string, files: {
213
+ [path: string]: string;
214
+ }, summary: string, isError: boolean, canvasLayers?: any[]): Promise<any>;
215
+ updateSandboxFile(projectId: string, messageId: string, filePath: string, content: string): Promise<IFileUpdateResponse>;
21
216
  }