@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.
- package/lib/containers/containers.js +3 -1
- package/lib/containers/containers.js.map +1 -1
- package/lib/containers/context-services-from-container.d.ts +2 -2
- package/lib/containers/context-services-from-container.js +2 -1
- package/lib/containers/context-services-from-container.js.map +1 -1
- package/lib/graphql/resolvers/channel-member.d.ts +3 -3
- package/lib/graphql/resolvers/channel-member.js +30 -5
- package/lib/graphql/resolvers/channel-member.js.map +1 -1
- package/lib/graphql/resolvers/channel.d.ts +3 -3
- package/lib/graphql/resolvers/channel.js +275 -53
- package/lib/graphql/resolvers/channel.js.map +1 -1
- package/lib/graphql/resolvers/extended-token-account.d.ts +3 -32
- package/lib/graphql/resolvers/extended-token-account.js +90 -23
- package/lib/graphql/resolvers/extended-token-account.js.map +1 -1
- package/lib/graphql/resolvers/index.d.ts +1 -31
- package/lib/graphql/resolvers/post-thread.d.ts +2 -3
- package/lib/graphql/resolvers/post-thread.js +294 -132
- package/lib/graphql/resolvers/post-thread.js.map +1 -1
- package/lib/graphql/resolvers/post.d.ts +2 -3
- package/lib/graphql/resolvers/post.js +697 -234
- package/lib/graphql/resolvers/post.js.map +1 -1
- package/lib/graphql/resolvers/reaction.d.ts +3 -3
- package/lib/graphql/resolvers/reaction.js +96 -14
- package/lib/graphql/resolvers/reaction.js.map +1 -1
- package/lib/graphql/schema/channel-member.graphql +110 -21
- package/lib/graphql/schema/channel-member.graphql.js +1 -1
- package/lib/graphql/schema/channel.graphql +331 -38
- package/lib/graphql/schema/channel.graphql.js +1 -1
- package/lib/graphql/schema/post-thread.graphql +166 -21
- package/lib/graphql/schema/post-thread.graphql.js +1 -1
- package/lib/graphql/schema/post.graphql +280 -40
- package/lib/graphql/schema/post.graphql.js +1 -1
- package/lib/graphql/schema/reaction.graphql +71 -13
- package/lib/graphql/schema/reaction.graphql.js +1 -1
- package/lib/graphql/schema/services.graphql +2 -0
- package/lib/graphql/schema/users.graphql +76 -13
- package/lib/graphql/schema/users.graphql.js +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/interfaces/services.d.ts +1 -2
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.d.ts +17 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +44 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/index.d.ts +1 -0
- package/lib/migrations/index.d.ts +1 -0
- package/lib/migrations/mail-template-migration.js +1 -1
- package/lib/migrations/message-notification-template-migration.d.ts +1 -1
- package/lib/migrations/message-notification-template-migration.js +1 -1
- package/lib/plugins/channel-moleculer-service.d.ts +21 -1
- package/lib/plugins/channel-moleculer-service.js +417 -115
- package/lib/plugins/channel-moleculer-service.js.map +1 -1
- package/lib/plugins/extended-token-account-moleculer-service.d.ts +25 -1
- package/lib/plugins/extended-token-account-moleculer-service.js +348 -22
- package/lib/plugins/extended-token-account-moleculer-service.js.map +1 -1
- package/lib/plugins/messenger-notification-moleculer-service.d.ts +27 -3
- package/lib/plugins/messenger-notification-moleculer-service.js +404 -58
- package/lib/plugins/messenger-notification-moleculer-service.js.map +1 -1
- package/lib/plugins/post-moleculer-service.d.ts +85 -21
- package/lib/plugins/post-moleculer-service.js +986 -256
- package/lib/plugins/post-moleculer-service.js.map +1 -1
- package/lib/plugins/post-thread-moleculer-service.d.ts +33 -1
- package/lib/plugins/post-thread-moleculer-service.js +326 -8
- package/lib/plugins/post-thread-moleculer-service.js.map +1 -1
- package/lib/plugins/reaction-moleculer-service.js +1 -1
- package/lib/plugins/reaction-moleculer-service.js.map +1 -1
- package/lib/preferences/settings/post-settings.d.ts +2 -0
- package/lib/preferences/settings/post-settings.js +47 -9
- package/lib/preferences/settings/post-settings.js.map +1 -1
- package/lib/services/channel-service.d.ts +178 -33
- package/lib/services/channel-service.js +735 -276
- package/lib/services/channel-service.js.map +1 -1
- package/lib/services/extended-token-account-service.d.ts +130 -14
- package/lib/services/extended-token-account-service.js +462 -52
- package/lib/services/extended-token-account-service.js.map +1 -1
- package/lib/services/messenger-notification-service.d.ts +106 -13
- package/lib/services/messenger-notification-service.js +824 -442
- package/lib/services/messenger-notification-service.js.map +1 -1
- package/lib/services/post-service.d.ts +172 -16
- package/lib/services/post-service.js +580 -113
- package/lib/services/post-service.js.map +1 -1
- package/lib/services/post-thread-service.d.ts +114 -5
- package/lib/services/post-thread-service.js +400 -13
- package/lib/services/post-thread-service.js.map +1 -1
- package/lib/services/proxy-services/channel-microservice.d.ts +5 -3
- package/lib/services/proxy-services/channel-microservice.js +19 -10
- package/lib/services/proxy-services/channel-microservice.js.map +1 -1
- package/lib/services/proxy-services/messenger-notification-microservice.d.ts +128 -8
- package/lib/services/proxy-services/messenger-notification-microservice.js +324 -29
- package/lib/services/proxy-services/messenger-notification-microservice.js.map +1 -1
- package/lib/services/proxy-services/post-microservice.d.ts +186 -12
- package/lib/services/proxy-services/post-microservice.js +543 -54
- package/lib/services/proxy-services/post-microservice.js.map +1 -1
- package/lib/services/proxy-services/post-thread-microservice.d.ts +134 -3
- package/lib/services/proxy-services/post-thread-microservice.js +388 -6
- package/lib/services/proxy-services/post-thread-microservice.js.map +1 -1
- package/lib/services/proxy-services/reaction-microservice.d.ts +161 -3
- package/lib/services/proxy-services/reaction-microservice.js +474 -2
- package/lib/services/proxy-services/reaction-microservice.js.map +1 -1
- package/lib/services/reaction-service.d.ts +124 -4
- package/lib/services/reaction-service.js +415 -3
- package/lib/services/reaction-service.js.map +1 -1
- package/lib/store/models/account-token-store.d.ts +1 -1
- package/lib/store/models/account-token-store.js.map +1 -1
- package/lib/store/models/channel.d.ts +2 -3
- package/lib/store/models/channel.js +180 -71
- package/lib/store/models/channel.js.map +1 -1
- package/lib/store/models/post-thread.d.ts +3 -3
- package/lib/store/models/post-thread.js +96 -14
- package/lib/store/models/post-thread.js.map +1 -1
- package/lib/store/models/post.d.ts +2 -3
- package/lib/store/models/post.js +143 -23
- package/lib/store/models/post.js.map +1 -1
- package/lib/store/models/reaction.d.ts +2 -3
- package/lib/store/models/reaction.js +67 -8
- package/lib/store/models/reaction.js.map +1 -1
- package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
- package/lib/store/repositories/channel-repository.d.ts +6 -6
- package/lib/store/repositories/channel-repository.js +5 -2
- package/lib/store/repositories/channel-repository.js.map +1 -1
- package/lib/store/repositories/post-repository.d.ts +6 -6
- package/lib/store/repositories/post-repository.js +5 -2
- package/lib/store/repositories/post-repository.js.map +1 -1
- package/lib/store/repositories/post-thread-repository.d.ts +6 -6
- package/lib/store/repositories/post-thread-repository.js +5 -2
- package/lib/store/repositories/post-thread-repository.js.map +1 -1
- package/lib/store/repositories/reaction-repository.d.ts +6 -6
- package/lib/store/repositories/reaction-repository.js +5 -2
- package/lib/store/repositories/reaction-repository.js.map +1 -1
- package/lib/templates/constants/SERVER_TYPES.ts.template +0 -3
- package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
- package/lib/templates/repositories/PostRepository.ts.template +3 -3
- package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
- package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
- package/lib/templates/services/ChannelService.ts.template +278 -39
- package/lib/templates/services/ExtendedTokenAccountService.ts.template +107 -3
- package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
- package/lib/templates/services/PostService.ts.template +184 -20
- package/lib/templates/services/PostThreadService.ts.template +151 -6
- package/lib/templates/services/ReactionService.ts.template +129 -3
- package/package.json +4 -4
- package/lib/interfaces/context.d.ts +0 -14
- package/lib/store/models/common-options.js +0 -20
- package/lib/store/models/common-options.js.map +0 -1
|
@@ -1,42 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Post Service Interface
|
|
3
|
+
* ----------------------
|
|
4
|
+
*
|
|
5
|
+
* This interface defines the business logic layer for post and message management
|
|
6
|
+
* within the messenger platform. It provides comprehensive operations for handling
|
|
7
|
+
* messages, file attachments, threading, and message state management across
|
|
8
|
+
* different channels and communication contexts.
|
|
9
|
+
*
|
|
10
|
+
* Key capabilities:
|
|
11
|
+
* - Post lifecycle management (creation, updates, deletion)
|
|
12
|
+
* - File upload and attachment handling (single and batch operations)
|
|
13
|
+
* - Message threading and conversation management
|
|
14
|
+
* - Message delivery and read status tracking
|
|
15
|
+
* - File management and cleanup operations
|
|
16
|
+
* - Cross-channel message coordination
|
|
17
|
+
* - Post-thread relationship management
|
|
18
|
+
* - Message state synchronization
|
|
19
|
+
*
|
|
20
|
+
* The service layer abstracts complex messaging operations and provides a
|
|
21
|
+
* cohesive API for post-related functionality throughout the messaging platform,
|
|
22
|
+
* handling file storage, threading logic, and message state consistency.
|
|
23
|
+
*/
|
|
3
24
|
|
|
4
|
-
|
|
25
|
+
import {
|
|
26
|
+
IFileInfo,
|
|
27
|
+
IMessageIdentifier,
|
|
28
|
+
IPost,
|
|
29
|
+
IPostModel,
|
|
30
|
+
IPostThread,
|
|
31
|
+
IThreadMessageInput,
|
|
32
|
+
IUploadedFileInput,
|
|
33
|
+
Disposable,
|
|
34
|
+
AsDomainType,
|
|
35
|
+
IBaseService
|
|
36
|
+
} from 'common/server';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Post Service Input Interface
|
|
40
|
+
*
|
|
41
|
+
* @description Input parameters for post creation operations,
|
|
42
|
+
* excluding auto-generated and system-managed fields.
|
|
43
|
+
*/
|
|
44
|
+
export interface IPostServiceInput extends Omit<IPostModel, 'id' | 'files' | 'isRead' | 'isDelivered' | '_id'> {
|
|
45
|
+
/** Array of file identifiers to attach to the post */
|
|
5
46
|
files: string[];
|
|
47
|
+
/** Optional MongoDB ObjectId for the post */
|
|
6
48
|
_id?: any;
|
|
7
49
|
}
|
|
8
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Post Thread Creation Options
|
|
53
|
+
*
|
|
54
|
+
* @description Configuration parameters for creating posts with associated threads.
|
|
55
|
+
*/
|
|
9
56
|
export type CreatePostThreadOptions = {
|
|
57
|
+
/** Thread message input data */
|
|
10
58
|
threadMessageInput: IThreadMessageInput;
|
|
59
|
+
/** Channel identifier where the post will be created */
|
|
11
60
|
channelId: string;
|
|
61
|
+
/** Optional responder user identifier */
|
|
12
62
|
responderId?: string;
|
|
63
|
+
/** Optional parent post identifier for threading */
|
|
13
64
|
postParentId?: string;
|
|
65
|
+
/** Optional existing post identifier */
|
|
14
66
|
postId?: string;
|
|
67
|
+
/** Account identifier of the post creator */
|
|
15
68
|
accountId: string;
|
|
69
|
+
/** Optional organization identifier */
|
|
16
70
|
orgId?: string;
|
|
71
|
+
/** Optional existing post thread identifier */
|
|
17
72
|
postThreadId?: string;
|
|
18
73
|
};
|
|
19
74
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Post Service Interface
|
|
77
|
+
*
|
|
78
|
+
* @description Provides comprehensive post and message management capabilities
|
|
79
|
+
* including file handling, threading, and message state management.
|
|
80
|
+
*/
|
|
81
|
+
export interface IPostService extends IBaseService<IPostModel, IPostServiceInput, Partial<IPostModel>>, Disposable {
|
|
82
|
+
/**
|
|
83
|
+
* Creates a file upload link for a specific post
|
|
84
|
+
*
|
|
85
|
+
* @description Generates a secure upload URL for attaching a single file
|
|
86
|
+
* to an existing post, handling authentication and storage permissions.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} postId - The unique identifier of the post
|
|
89
|
+
* @param {string} filename - The name of the file to upload
|
|
90
|
+
* @param {string} userId - The identifier of the user performing the upload
|
|
91
|
+
* @returns {Promise<string | Error>} - Upload URL or error
|
|
92
|
+
*/
|
|
93
|
+
createFileUploadLink(postId: string, filename: string, userId: string): Promise<string | Error>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Attaches an uploaded file to a post
|
|
97
|
+
*
|
|
98
|
+
* @description Associates a successfully uploaded file with a post,
|
|
99
|
+
* updating the post's file attachments and metadata.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} postId - The unique identifier of the post
|
|
102
|
+
* @param {IUploadedFileInput} file - The uploaded file information
|
|
103
|
+
* @param {string} createdBy - The identifier of the user who uploaded the file
|
|
104
|
+
* @returns {Promise<IFileInfo | Error>} - File information or error
|
|
105
|
+
*/
|
|
106
|
+
attachUploadedFile(postId: string, file: IUploadedFileInput, createdBy: string): Promise<IFileInfo | Error>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Creates multiple file upload links for a post
|
|
110
|
+
*
|
|
111
|
+
* @description Generates secure upload URLs for attaching multiple files
|
|
112
|
+
* to an existing post in a single operation.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} postId - The unique identifier of the post
|
|
115
|
+
* @param {string[]} filenames - Array of file names to upload
|
|
116
|
+
* @param {string} userId - The identifier of the user performing the upload
|
|
117
|
+
* @returns {Promise<string[] | Error>} - Array of upload URLs or error
|
|
118
|
+
*/
|
|
119
|
+
createFilesUploadLink(postId: string, filenames: string[], userId: string): Promise<string[] | Error>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Attaches multiple uploaded files to a post
|
|
123
|
+
*
|
|
124
|
+
* @description Associates multiple successfully uploaded files with a post
|
|
125
|
+
* in a single batch operation, optimizing performance and consistency.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} postId - The unique identifier of the post
|
|
128
|
+
* @param {IUploadedFileInput[]} files - Array of uploaded file information
|
|
129
|
+
* @param {string} createdBy - The identifier of the user who uploaded the files
|
|
130
|
+
* @returns {Promise<IFileInfo[] | Error>} - Array of file information or error
|
|
131
|
+
*/
|
|
132
|
+
attachUploadedFiles(postId: string, files: IUploadedFileInput[], createdBy: string): Promise<IFileInfo[] | Error>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Deletes a file from storage
|
|
136
|
+
*
|
|
137
|
+
* @description Permanently removes a file from the storage system,
|
|
138
|
+
* typically used for cleanup or when files are no longer needed.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} url - The URL or identifier of the file to delete
|
|
141
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
142
|
+
*/
|
|
143
|
+
deleteFile(url: string): Promise<boolean | Error>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Marks a message as read by a user
|
|
147
|
+
*
|
|
148
|
+
* @description Updates the read status of a message for a specific user,
|
|
149
|
+
* affecting unread counts and notification states.
|
|
150
|
+
*
|
|
151
|
+
* @param {IMessageIdentifier} messageId - The message identifier
|
|
152
|
+
* @param {string} user - The identifier of the user marking the message as read
|
|
153
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
154
|
+
*/
|
|
155
|
+
readMessage(messageId: IMessageIdentifier, user: string): Promise<boolean | Error>;
|
|
23
156
|
|
|
24
|
-
|
|
25
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Marks a message as delivered to a user
|
|
159
|
+
*
|
|
160
|
+
* @description Updates the delivery status of a message, indicating
|
|
161
|
+
* successful delivery to the target user's device or client.
|
|
162
|
+
*
|
|
163
|
+
* @param {IMessageIdentifier} messageId - The message identifier
|
|
164
|
+
* @param {string} user - The identifier of the user who received the message
|
|
165
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
166
|
+
*/
|
|
167
|
+
deliverMessage(messageId: IMessageIdentifier, user: string): Promise<boolean | Error>;
|
|
26
168
|
|
|
27
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Creates a post without triggering subscriptions
|
|
171
|
+
*
|
|
172
|
+
* @description Creates a new post while bypassing real-time subscription
|
|
173
|
+
* notifications, useful for bulk operations or system-generated content.
|
|
174
|
+
*
|
|
175
|
+
* @param {IPostServiceInput} data - The post creation data
|
|
176
|
+
* @returns {Promise<AsDomainType<IPostModel> | Error>} - Created post or error
|
|
177
|
+
*/
|
|
178
|
+
createWithoutSubscription(data: IPostServiceInput): Promise<AsDomainType<IPostModel> | Error>;
|
|
28
179
|
|
|
29
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Creates a post with an associated thread
|
|
182
|
+
*
|
|
183
|
+
* @description Creates both a post and its associated thread in a single
|
|
184
|
+
* transaction, ensuring data consistency and proper relationship setup.
|
|
185
|
+
*
|
|
186
|
+
* @param {CreatePostThreadOptions} options - The post and thread creation options
|
|
187
|
+
* @returns {Promise<{ post: AsDomainType<IPostModel>; postThread: IPostThread } | Error>} - Created post and thread or error
|
|
188
|
+
*/
|
|
189
|
+
createPostWithPostThread(options: CreatePostThreadOptions): Promise<{ post: AsDomainType<IPostModel>; postThread: IPostThread } | Error>;
|
|
30
190
|
|
|
31
|
-
|
|
32
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Retrieves the most recent message from a channel
|
|
193
|
+
*
|
|
194
|
+
* @description Fetches the latest post/message from a specific channel,
|
|
195
|
+
* useful for displaying channel previews and recent activity.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} channelId - The unique identifier of the channel
|
|
198
|
+
* @returns {Promise<AsDomainType<IPostModel> | Error>} - Latest message or error
|
|
199
|
+
*/
|
|
200
|
+
getLastMessage(channelId: string): Promise<AsDomainType<IPostModel> | Error>;
|
|
33
201
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
postParentId,
|
|
39
|
-
postId,
|
|
40
|
-
accountId,
|
|
41
|
-
}: CreatePostThreadOptions): Promise<{ post: IPost; postThread: IPostThread }>;
|
|
202
|
+
/**
|
|
203
|
+
* Disposes of resources used by the service
|
|
204
|
+
*/
|
|
205
|
+
dispose(): void;
|
|
42
206
|
}
|
|
@@ -1,10 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Post Thread Service Interface
|
|
3
|
+
* -----------------------------
|
|
4
|
+
*
|
|
5
|
+
* This interface defines the business logic layer for post thread management
|
|
6
|
+
* within the messenger platform. It provides comprehensive operations for handling
|
|
7
|
+
* threaded conversations, reply management, and discussion organization across
|
|
8
|
+
* different channels and messaging contexts.
|
|
9
|
+
*
|
|
10
|
+
* Key capabilities:
|
|
11
|
+
* - Thread lifecycle management (creation, updates, deletion)
|
|
12
|
+
* - Reply and response tracking within threads
|
|
13
|
+
* - Thread participant management and notifications
|
|
14
|
+
* - Thread statistics and metrics collection
|
|
15
|
+
* - Nested conversation organization
|
|
16
|
+
* - Thread visibility and access control
|
|
17
|
+
* - Cross-channel thread coordination
|
|
18
|
+
* - Thread state synchronization
|
|
19
|
+
*
|
|
20
|
+
* The service layer abstracts complex threading operations and provides a
|
|
21
|
+
* cohesive API for thread-related functionality throughout the messaging platform,
|
|
22
|
+
* handling conversation hierarchies, participant tracking, and thread state management.
|
|
23
|
+
*/
|
|
3
24
|
|
|
4
|
-
|
|
25
|
+
import { IPostThreadModel, Disposable, AsDomainType,IBaseService } from 'common/server';
|
|
5
26
|
|
|
6
|
-
// export type IPostThreadService = IBaseService<IPostThread>;
|
|
7
27
|
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Post Thread Service Input Interface
|
|
30
|
+
*
|
|
31
|
+
* @description Input parameters for post thread creation and update operations,
|
|
32
|
+
* excluding auto-generated fields like ID. Used for operations that modify
|
|
33
|
+
* thread data before it becomes a domain object.
|
|
34
|
+
*/
|
|
35
|
+
export interface IPostThreadServiceInput extends Omit<IPostThreadModel, 'id'> {
|
|
36
|
+
// Add any additional input-specific fields here if needed
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Post Thread Service Interface
|
|
41
|
+
*
|
|
42
|
+
* @description Provides comprehensive post thread management capabilities
|
|
43
|
+
* including thread creation, participant tracking, and conversation organization.
|
|
44
|
+
* All operations return domain objects wrapped with AsDomainType for consistency.
|
|
45
|
+
*/
|
|
46
|
+
export interface IPostThreadService extends IBaseService<IPostThreadModel>, Disposable {
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves a specific post thread with its metadata
|
|
49
|
+
*
|
|
50
|
+
* @description Fetches a complete post thread including all replies,
|
|
51
|
+
* participant information, and thread statistics for display and interaction.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} threadId - The ID of the thread to retrieve
|
|
54
|
+
* @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Post thread data or error
|
|
55
|
+
*/
|
|
56
|
+
getPostThread(threadId: string): Promise<AsDomainType<IPostThreadModel> | Error>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the total count of posts within a thread
|
|
60
|
+
*
|
|
61
|
+
* @description Calculates and returns the number of posts/replies
|
|
62
|
+
* within a specific thread for pagination and display purposes.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} threadId - The ID of the thread to count posts for
|
|
65
|
+
* @returns {Promise<number | Error>} - Thread post count or error
|
|
66
|
+
*/
|
|
67
|
+
getPostThreadCount(threadId: string): Promise<number | Error>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Updates a post thread
|
|
71
|
+
*
|
|
72
|
+
* @description Updates the specified thread with new data while maintaining
|
|
73
|
+
* thread integrity and participant notifications.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} threadId - The ID of the thread to update
|
|
76
|
+
* @param {Partial<IPostThreadServiceInput>} updates - The updates to apply
|
|
77
|
+
* @returns {Promise<AsDomainType<IPostThreadModel> | Error>} - Updated thread or error
|
|
78
|
+
*/
|
|
79
|
+
updateThread(threadId: string, updates: Partial<IPostThreadServiceInput>): Promise<AsDomainType<IPostThreadModel> | Error>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Deletes a post thread
|
|
83
|
+
*
|
|
84
|
+
* @description Soft deletes a thread while maintaining data integrity
|
|
85
|
+
* and notifying participants.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} threadId - The ID of the thread to delete
|
|
88
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
89
|
+
*/
|
|
90
|
+
deleteThread(threadId: string): Promise<boolean | Error>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Gets threads by post ID
|
|
94
|
+
*
|
|
95
|
+
* @description Retrieves all threads associated with a specific post,
|
|
96
|
+
* useful for viewing conversation context.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} postId - The ID of the post
|
|
99
|
+
* @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
|
|
100
|
+
*/
|
|
101
|
+
getThreadsByPost(postId: string): Promise<Array<AsDomainType<IPostThreadModel>> | Error>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Gets threads by channel with pagination
|
|
105
|
+
*
|
|
106
|
+
* @description Retrieves paginated threads for a specific channel,
|
|
107
|
+
* ordered by relevance or time.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} channelId - The ID of the channel
|
|
110
|
+
* @param {number} [limit] - Maximum number of threads to return
|
|
111
|
+
* @param {number} [offset] - Number of threads to skip
|
|
112
|
+
* @returns {Promise<Array<AsDomainType<IPostThreadModel>> | Error>} - Array of threads or error
|
|
113
|
+
*/
|
|
114
|
+
getThreadsByChannel(channelId: string, limit?: number, offset?: number): Promise<Array<AsDomainType<IPostThreadModel>> | Error>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Gets thread participants
|
|
118
|
+
*
|
|
119
|
+
* @description Retrieves all participants in a thread, including
|
|
120
|
+
* their participation status and roles.
|
|
121
|
+
*
|
|
122
|
+
* @param {string} threadId - The ID of the thread
|
|
123
|
+
* @returns {Promise<Array<string> | Error>} - Array of participant IDs or error
|
|
124
|
+
*/
|
|
125
|
+
getThreadParticipants(threadId: string): Promise<Array<string> | Error>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Adds a participant to a thread
|
|
129
|
+
*
|
|
130
|
+
* @description Adds a user as a participant to a thread,
|
|
131
|
+
* enabling notifications and access.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} threadId - The ID of the thread
|
|
134
|
+
* @param {string} userId - The ID of the user to add
|
|
135
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
136
|
+
*/
|
|
137
|
+
addParticipant(threadId: string, userId: string): Promise<boolean | Error>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Removes a participant from a thread
|
|
141
|
+
*
|
|
142
|
+
* @description Removes a user's participation from a thread,
|
|
143
|
+
* updating notifications and access accordingly.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} threadId - The ID of the thread
|
|
146
|
+
* @param {string} userId - The ID of the user to remove
|
|
147
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
148
|
+
*/
|
|
149
|
+
removeParticipant(threadId: string, userId: string): Promise<boolean | Error>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Disposes of resources used by the service
|
|
153
|
+
*/
|
|
154
|
+
dispose(): void;
|
|
10
155
|
}
|
|
@@ -1,7 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Reaction Service Interface
|
|
3
|
+
* --------------------------
|
|
4
|
+
*
|
|
5
|
+
* This interface defines the business logic layer for reaction management
|
|
6
|
+
* within the messenger platform. It provides comprehensive operations for handling
|
|
7
|
+
* emoji reactions, sentiment tracking, and user engagement features across
|
|
8
|
+
* posts, messages, and other interactive content.
|
|
9
|
+
*
|
|
10
|
+
* Key capabilities:
|
|
11
|
+
* - Reaction lifecycle management (addition, removal, updates)
|
|
12
|
+
* - Emoji and custom reaction support
|
|
13
|
+
* - User reaction tracking and analytics
|
|
14
|
+
* - Reaction aggregation and statistics
|
|
15
|
+
* - Cross-platform reaction synchronization
|
|
16
|
+
* - Reaction notification management
|
|
17
|
+
* - Bulk reaction operations
|
|
18
|
+
* - Reaction validation and moderation
|
|
19
|
+
*
|
|
20
|
+
* The service layer abstracts reaction operations and provides a cohesive API
|
|
21
|
+
* for engagement-related functionality throughout the messaging platform,
|
|
22
|
+
* handling user interactions, emotion tracking, and social engagement metrics.
|
|
23
|
+
*/
|
|
3
24
|
|
|
25
|
+
import { IBaseService, IReactionModel, IReactionInput, Disposable, AsDomainType } from 'common/server';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reaction Service Input Interface
|
|
29
|
+
*
|
|
30
|
+
* @description Input parameters for reaction creation and management operations,
|
|
31
|
+
* including user context and reaction metadata.
|
|
32
|
+
*/
|
|
4
33
|
export interface IReactionServiceInput extends IReactionInput {
|
|
34
|
+
/** User identifier who is creating or managing the reaction */
|
|
5
35
|
user: string;
|
|
6
36
|
}
|
|
7
|
-
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Reaction Service Interface
|
|
40
|
+
*
|
|
41
|
+
* @description Provides comprehensive reaction management capabilities
|
|
42
|
+
* including emoji reactions, user engagement tracking, and reaction analytics.
|
|
43
|
+
*/
|
|
44
|
+
export interface IReactionService extends IBaseService<IReactionModel, IReactionServiceInput, Partial<IReactionInput>>, Disposable {
|
|
45
|
+
/**
|
|
46
|
+
* Adds a reaction to a post or message
|
|
47
|
+
*
|
|
48
|
+
* @description Creates a new reaction entry for a specific content item,
|
|
49
|
+
* handling duplicate detection and user validation.
|
|
50
|
+
*
|
|
51
|
+
* @param {IReactionServiceInput} data - Reaction creation data including user and reaction type
|
|
52
|
+
* @returns {Promise<AsDomainType<IReactionModel> | Error>} - Created reaction or error
|
|
53
|
+
*/
|
|
54
|
+
addReaction(data: IReactionServiceInput): Promise<AsDomainType<IReactionModel> | Error>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Removes a reaction from a post or message
|
|
58
|
+
*
|
|
59
|
+
* @description Deletes an existing reaction entry, ensuring proper user
|
|
60
|
+
* authorization and content validation.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} reactionId - The unique identifier of the reaction to remove
|
|
63
|
+
* @param {string} userId - The identifier of the user removing the reaction
|
|
64
|
+
* @returns {Promise<boolean | Error>} - Success status or error
|
|
65
|
+
*/
|
|
66
|
+
removeReaction(reactionId: string, userId: string): Promise<boolean | Error>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves all reactions for a specific content item
|
|
70
|
+
*
|
|
71
|
+
* @description Fetches reaction data with aggregation and user information
|
|
72
|
+
* for display in the user interface.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} contentId - The identifier of the content (post, message, etc.)
|
|
75
|
+
* @param {string} contentType - The type of content being reacted to
|
|
76
|
+
* @returns {Promise<Array<AsDomainType<IReactionModel>> | Error>} - Array of reactions or error
|
|
77
|
+
*/
|
|
78
|
+
getReactionsByContent(contentId: string, contentType: string): Promise<Array<AsDomainType<IReactionModel>> | Error>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves reaction statistics for content
|
|
82
|
+
*
|
|
83
|
+
* @description Provides aggregated reaction counts and statistics
|
|
84
|
+
* for analytics and display purposes.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} contentId - The identifier of the content
|
|
87
|
+
* @param {string} contentType - The type of content
|
|
88
|
+
* @returns {Promise<Record<string, any> | Error>} - Reaction statistics or error
|
|
89
|
+
*/
|
|
90
|
+
getReactionStats(contentId: string, contentType: string): Promise<Record<string, any> | Error>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Checks if a user has reacted to specific content
|
|
94
|
+
*
|
|
95
|
+
* @description Determines whether a user has already reacted to
|
|
96
|
+
* a piece of content, useful for UI state management.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} contentId - The identifier of the content
|
|
99
|
+
* @param {string} userId - The identifier of the user
|
|
100
|
+
* @param {string} reactionType - The type of reaction to check
|
|
101
|
+
* @returns {Promise<boolean | Error>} - True if user has reacted, or error
|
|
102
|
+
*/
|
|
103
|
+
hasUserReacted(contentId: string, userId: string, reactionType: string): Promise<boolean | Error>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Updates an existing reaction
|
|
107
|
+
*
|
|
108
|
+
* @description Modifies an existing reaction, typically changing
|
|
109
|
+
* the reaction type while maintaining the same user and content association.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} reactionId - The unique identifier of the reaction
|
|
112
|
+
* @param {Partial<IReactionInput>} updates - The reaction updates to apply
|
|
113
|
+
* @returns {Promise<AsDomainType<IReactionModel> | Error>} - Updated reaction or error
|
|
114
|
+
*/
|
|
115
|
+
updateReaction(reactionId: string, updates: Partial<IReactionInput>): Promise<AsDomainType<IReactionModel> | Error>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Removes all reactions from specific content
|
|
119
|
+
*
|
|
120
|
+
* @description Bulk removes all reactions from a content item,
|
|
121
|
+
* typically used during content deletion or moderation.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} contentId - The identifier of the content
|
|
124
|
+
* @param {string} contentType - The type of content
|
|
125
|
+
* @returns {Promise<number | Error>} - Number of reactions removed or error
|
|
126
|
+
*/
|
|
127
|
+
removeAllReactionsByContent(contentId: string, contentType: string): Promise<number | Error>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Disposes of resources used by the service
|
|
131
|
+
*/
|
|
132
|
+
dispose(): void;
|
|
133
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-box/platform-server",
|
|
3
|
-
"version": "10.0.3-alpha.
|
|
3
|
+
"version": "10.0.3-alpha.62",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@container-stack/mailing-api": "5.4.1-alpha.
|
|
23
|
-
"@messenger-box/core": "10.0.3-alpha.
|
|
22
|
+
"@container-stack/mailing-api": "5.4.1-alpha.9",
|
|
23
|
+
"@messenger-box/core": "10.0.3-alpha.62",
|
|
24
24
|
"@skoropletov/moleculer-cron-tasks": "~0.0.8",
|
|
25
25
|
"date-fns": "^4.1.0"
|
|
26
26
|
},
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"typescript": {
|
|
70
70
|
"definition": "lib/index.d.ts"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "8b546a2c05aecf314c1c8e94245810a945e90899"
|
|
73
73
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ServerContext as AdminIdeServerContext, IConfigurationServerService } from '@adminide-stack/core';
|
|
2
|
-
import { IUserProfile, IBaseAccountService, IUserAccount, IConfigurationModel } from 'common';
|
|
3
|
-
import { IServices } from './services';
|
|
4
|
-
export interface IServerContext extends AdminIdeServerContext {
|
|
5
|
-
user: IUserProfile;
|
|
6
|
-
accountService?: {
|
|
7
|
-
findAccountById: (id: string) => IUserAccount | undefined;
|
|
8
|
-
findAccountByUser: (id: string) => IUserAccount | undefined;
|
|
9
|
-
} & IBaseAccountService;
|
|
10
|
-
configurationService: IConfigurationServerService & {
|
|
11
|
-
parser(resource: string, value: string): IConfigurationModel | Error;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export type IContext = IServerContext & IServices;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const commonModeSchemaOptions = {
|
|
2
|
-
timestamps: true,
|
|
3
|
-
toJSON: {
|
|
4
|
-
virtuals: true
|
|
5
|
-
},
|
|
6
|
-
toObject: {
|
|
7
|
-
virtuals: true,
|
|
8
|
-
getters: true,
|
|
9
|
-
transform(doc, ret) {
|
|
10
|
-
delete ret.__v;
|
|
11
|
-
delete ret._id;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const addIdVirtualFields = schema => {
|
|
16
|
-
schema.set('toJSON', {
|
|
17
|
-
virtuals: true
|
|
18
|
-
});
|
|
19
|
-
return schema;
|
|
20
|
-
};export{addIdVirtualFields,commonModeSchemaOptions};//# sourceMappingURL=common-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common-options.js","sources":["../../../src/store/models/common-options.ts"],"sourcesContent":[null],"names":[],"mappings":"AAGa,MAAA,uBAAuB,GAAG;AACnC,EAAA,UAAA,EAAU,IAAM;AAChB,EAAA,MAAA,EAAM;AACF,IAAA,QAAA,EAAA;AACH,GAAA;AACD,EAAA,QAAA,EAAQ;AACJ,IAAA,QAAA,EAAA,IAAU;AACV,IAAA,OAAA,EAAA,IAAS;aACA,CAAA,GAAA,EAAI,GAAA,EAAK;aACP,GAAA,CAAA,GAAA;aACA,GAAA,CAAA,GAAA;;AAEd;;AAGQ,MAAA,kBAAkB,GAAG,MAAC,IAAkB;AACjD,EAAA,MAAA,CAAA,GAAO,CAAA,QAAI,EAAQ;AACf,IAAA,QAAA,EAAA;AACH,GAAA,CAAA;AACD,EAAA,OAAA;AACJ"}
|