import type { CancelTokenSource } from 'axios'; import { C11nEnv } from '../interpreter/c11n-env'; type CustomMessageRequest = { context: string; content: object; pageInstructions?: object[]; }; type Recipient = { pyUserName: string; pxObjClass?: string; pyUserIdentifier: string; pyPosition?: string; }; type FeedFilter = { id: string; label: string; on: boolean; disabled: boolean; }; type Message = { ID: string; pzInsKey?: string; mentions?: MentionItem[]; pxResults?: Message[]; [key: string]: any; }; type MentionItem = { mentionsID: string; mentionsType: string; [key: string]: any; }; /** * @description Use the APIs in the FeedUtils class to handle the feeds of a case. */ declare class FeedUtils { mentionsTagsCancelTokenSource: CancelTokenSource[]; mentions: MentionItem[]; constructor(); /** * Obtains the feeds for a given context. * @function * @static * @example In this example, the API obtains the feed of a context whose feedID is pyDashboardFeed. * PCore.getFeedUtils().getFeeds('DATA-PORTAL $EngPMF', 'pyDashboardFeed','class',[{id: 'All', label: 'All', on: false, disabled: false}],[], getPConnect(), true) * .then(feedResponse => { * // feedResponse array * }).catch(err => { * // errors * }); * @example In this example, the API obtains the feed of a context whose feedID is pyCaseFeed. * PCore.getFeedUtils().getFeeds('PEGAPROJMGMT-WORK TASK-100', 'pyCaseFeed','class',[{id: 'All', label: 'All', on: false, disabled: false}],[], getPConnect(), true) * .then(feedResponse => { * // feedResponse array * }).catch(err => { * // errors * }); * * @param pulseContext The name of the application context or case context for which the feed must be fetched. * @param feedID The ID of the feed that must be fetched. * FeedID of the Pulse widget, when configured on the Home page, is known as "pyDashboardFeed" * and when used within a case view, it is known as "pyCaseFeed." * @param feedClass The class associated with the feed to be fetched. * @param feedFilters The list of conditions through which the feed to be fetched is filtered. * It is an array comprising objects, with each object containing four distinct properties. * id and label values for the filter options are available in pyDashboardFeed and pyCaseFeed rules. * Extra filter options if needed can be configured in the same rules. * @param {string} feedFilters.id The unique identifier for the feed source * @param {string} feedFilters.label The title of the feed source * @param {boolean} feedFilters.disabled This can be used to deactivate the filter (with a default value of false) * @param {boolean} feedFilters.on This provides information regarding whether the filter is currently selected.(with a default value of false i.e., not selected) * @param fetchFeedsCancelTokenSource The list of API requests for fetching the feed. * @param pConnectObj The PConnect object of the component from where the API is being called. * @param isLoadMore The flag that determines if the next set of feeds should be loaded. * The default value is false. Set isLoadMore to true if you want to load the next set of feeds. * @returns A Promise that resolves to an object. */ getFeeds: (pulseContext: string, feedID: string, feedClass: string, feedFilters: FeedFilter[], fetchFeedsCancelTokenSource: CancelTokenSource[], pConnectObj: C11nEnv, isLoadMore: boolean) => Promise; /** * Posts a message to the given context. * @function * @static * @example In this example, the API posts a message along with attachment to the given context. * PCore.getFeedUtils().postMessage('DATA-PORTAL $appName','test message', getPConnect(), [{"type":"File","category":"File","fileName":"attachment.png","ID":"459c"}], false, []) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @example In this example, the API replies to a message along with attachment to the given context. * PCore.getFeedUtils().postMessage('PEGASOCIAL M-214007','test reply message',getPConnect(),[{"type":"File","category":"File","fileName":"attachment.png","ID":"459c"}], true,[]) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @example In this example, the API posts a message along with attachment to the given context that is visible only to the users listed in the recipients property. * PCore.getFeedUtils().postMessage('DATA-PORTAL $appName','test private message', getPConnect(),[], false, [{pyUserName:"venkat", pyUserIdentifier:"vel", pyPosition: "SWE"}]) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @param pulseContext The name of the application context or case context for which the message must be posted. * @param message The message that needs to be posted. * @param pConnectObj The PConnect object of the component from where the API is being called. * @param attachmentIDs The metadata of the attachments that need to be posted along with the message. * @param isReply The flag that determines if you want to post a message or a reply to a message.The default value is false. Set isReply to true if you want to post a reply to a message. Set isReply to false if you want to post a message. * @param recipients The list of users who can view the posted message. * Note: * 1. The default value is []. * 2. If you want to post a private message, set recipients to an array of objects, where each object contains the pyUserName, pyUserIdentifier and pyPosition properties. * 3. If you want to post a public message, set recipients to an empty array. * @param recipients.pyUserName Name of the user who can view the message. * @param recipients.pyUserIdentifier Unique identifier of the user who can view the message. * @param recipients.pyPosition Position of the user who can view the message. Note: Send null if you don't have the position of the user. * @returns A Promise that resolves to an object. */ postMessage: (pulseContext: string, message: string, pConnectObj: C11nEnv, attachmentIDs?: any[], isReply?: boolean, recipients?: Recipient[]) => Promise; /** * Posts a specific type of message to the given context. * * @function * @static * @example In this example, the API posts a message whose type is associated with the PegaSocial-Post-Task classID. * * const payload = { * "context": "DATA-PORTAL $TestABC", * "content": { * "label": "Sample label", * "description": "Sample description" * } * }; * * PCore.getFeedUtils().postCustomMessage('PegaSocial-Post-Task', payload, getPConnect()) * .then(response => { * // Handle the response * }).catch(err => { * // Handle errors * }); * * @param {string} postTypeClassID The unique identifier of the class associated with the type of the message to be posted. * @param {object} payload The object containing the details of the message to be posted. * @param {string} payload.context The name of the application context or case context for which the message must be posted. * @param {object} payload.content A dynamically formed object based on the fields configured in the view of a post type. * @param {object} pConnectObj The pConnect object of the component from where the API is being called. * @returns {Promise} A Promise that resolves to an object. */ postCustomMessage: (postTypeClassID: string, payload: CustomMessageRequest, pConnectObj: C11nEnv) => Promise; /** * Modifies a message associated with the given context. * @function * @static * @example In this example, the API edits the message whose messageID is PEGASOCIAL M-100. * const payload = { * messageID: 'PEGASOCIAL M-100', * parentMessageID: 'PEGASOCIAL M-100', * message: 'test message', * isReply: false, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().editMessage(payload) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @example In this example, the API edits the reply to the message whose messageID is PEGASOCIAL M-101 and parentmessageID is PEGASOCIAL M-100. * const payload = { * messageID: 'PEGASOCIAL M-101', * parentMessageID: 'PEGASOCIAL M-100', * message: 'test reply message', * isReply: true, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().editMessage(payload) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @example In this example, the API edits the message that is visible only to the users listed in the recipients property. * const payload = { * messageID: 'PEGASOCIAL M-100', * parentMessageID: 'PEGASOCIAL M-100', * message:'test message edited', * isReply:true, * pConnectObj: getPConnect(), * recipients: [{pyUserName:"venkat", pyUserIdentifier:"vel", pyPosition: "SWE"}] * } * PCore.getFeedUtils().editMessage(payload) * .then(() => { * // success * }).catch(err => { * // Error handling * }); * @param param The object that contains the required data to edit a message. * @param param.messageID The unique identifier(pzInsKey) of the message that needs to be edited. * @param param.parentMessageID The unique identifier(pzInsKey) of the parent message that needs to be edited. * @param param.message The new message that replaces the existing message. * @param param.pConnectObj The pConnect object of the component from where the API is being called. * @param param.isReply The flag that determines if you want to post a message or a reply to a message. * The default value is false. Set isReply to true if you want to edit a reply for a message. * Set isReply to false if you want to edit a message. * @param param.recipients The list of users who can view the edited message. * Note: * 1. The default value is []. * 2. If you want to edit a private message, set recipients to an array of objects, where each object contains the pyUserName, pyUserIdentifier and pyPosition properties. * 3. If you want to edit a public message, set recipients to an empty array. * @param param.recipients.pyUserName Name of the user who can view the message. * @param param.recipients.pyUserIdentifier Unique identifier of the user who can view the message. * @param param.recipients.pyPosition Position of the user who can view the message. Note: Send null if you don't have the position of the user. * @returns A Promise that resolves to an object. */ editMessage: ({ messageID, parentMessageID, message, pConnectObj, isReply, recipients }: { messageID: string; parentMessageID: string; message: string; pConnectObj: C11nEnv; isReply: boolean; recipients: Recipient[]; }) => Promise; /** * @private * @param messageData The object that contains the newly added/edited message details. * @param isReply The flag that determines if you want to post/edit a message or a reply to a message. * @param pConnectObj The PConnect object of the component from where the API is being called. * @param hasAttachment The flag that determines if you have an attachment for a message. * @returns MessageObject The messageObject */ buildMessageObject: (messageData: Message, isReply: boolean, pConnectObj: C11nEnv, hasAttachment?: boolean) => any; /** * @private * @param array This param carries the list of mention objects * @returns The list of mention objects excluding the user mentions and duplicates */ getCaseMentions: (array: Message[]) => MentionItem[]; /** * Likes or unlike a message. * @function * @static * @example In this example, the API likes the message whose messageID is PEGASOCIAL M-100. * const payload = { * pulseContext:'PEGAPROJMGMT-WORK TASK-100', * likedBy: false, * messageID:'PEGASOCIAL M-100', * isReply: false, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().likeMessage(payload) * .then(() => { * // success * }).catch(err => { * // errors * }); * @example In this example, the API dislikes the message whose messageID is PEGASOCIAL M-100. * const payload = { * pulseContext:'PEGAPROJMGMT-WORK TASK-100', * likedBy: true, * messageID:'PEGASOCIAL M-100', * isReply: false, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().likeMessage(payload) * .then(() => { * // success * }).catch(err => { * // errors * }); * @example In this example, the API likes the reply whose messageID is PEGASOCIAL M-100. * const payload = { * pulseContext:'PEGAPROJMGMT-WORK TASK-100', * likedBy: false, * messageID:'PEGASOCIAL M-100', * isReply: true, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().likeMessage(payload) * .then(() => { * // success * }).catch(err => { * // errors * }); * @example In this example, the API dislikes the reply whose messageID is PEGASOCIAL M-100. * const payload = { * pulseContext:'PEGAPROJMGMT-WORK TASK-100', * likedBy: true, * messageID:'PEGASOCIAL M-100', * isReply: true, * pConnectObj: getPConnect() * } * PCore.getFeedUtils().likeMessage(payload) * .then(() => { * // success * }).catch(err => { * // errors * }); * @param param The object that contains all the required data to like or unlike a specific message. * @param param.pulseContext The name of the application context or case context for which the feed must be fetched. * @param param.likedBy The value that determines whether to like or unlike the message. * @param param.messageID The ID(pzInsKey) of the message that needs to be liked or unlike. * @param param.isReply The flag that determines whether the number of likes must be obtained for a message or a reply to a message. * @param param.pConnectObj The PConnect object of the component from where the API is being called. */ likeMessage: ({ pulseContext, likedBy: unLiked, messageID, isReply, pConnectObj }: { pulseContext: string; likedBy: boolean; messageID: string; isReply: boolean; pConnectObj: C11nEnv; }) => void; /** * Deletes a message from a given context. * @function * @static * @example In this example, the API removes the reply whose ID is PEGASOCIAL M-101 from a message whose ID is PEGASOCIAL M-100. * PCore.getFeedUtils().deleteMessage('PEGASOCIAL M-100', true, 'PEGASOCIAL M-101', getPConnect()) * .then(() => { * // success * }).catch(err => { * // errors * }); * @example In this example, the API removes the message whose ID is PEGASOCIAL M-100 * PCore.getFeedUtils().deleteMessage('PEGASOCIAL M-100', false, '', getPConnect()) * .then(() => { * // success * }).catch(err => { * // errors * }); * @param messageID The ID of the message that needs to be deleted. Note: Ensure that you provide the pzInsKey value of the messageID. * @param isReply The flag that determines if you want to delete a message or a reply to a message. * Note: The default value is false. * Set isReply to true if you want to delete a reply to a message. * Set isReply to false if you want to delete a message. * @param replyID The ID of the reply that needs to be deleted. * Note:This parameter is required if isReply is set to true. * If isReply is set to false, pass an empty string as the replyID. * @param pConnectObj The PConnect object of the component from where the API is being called. */ deleteMessage: (messageID: string, isReply: boolean, replyID: string, pConnectObj: C11nEnv) => void; /** * Obtains the list of users who liked the message. * @function * @static * @example In this example, the API obtains the list of users who liked the message with messageID PEGASOCIAL M-100 * PCore.getFeedUtils().getLikedUsers(PEGASOCIAL M-100, getPConnect()) * .then(response => { * // response array * }).catch(err => { * // errors * }); * * @param messageID The ID of the message that is liked by the users. Note: Ensure that you provide the pzInsKey value of the messageID. * @param pConnectObj The PConnect object of the component from where the API is being called. * @returns A Promise that resolves to an object. */ getLikedUsers: (messageID: string, pConnectObj: C11nEnv) => Promise; /** * Obtains the list of options for the selected object that can be mentioned in a Pulse post. * @function * @static * @example In this example, the API obtains the list of cases that can be mentioned in a Pulse post. * PCore.getFeedUtils().getMentionSuggestions({searchFor:"case", mentionsType = 'Cases', listSize:5}, getPConnect()) * .then(mentionsResponse => { * // mentionsResponse array * }).catch(err => { * // errors * }); * @param mentionProps The object that contains the search parameters for obtaining the list of options for the selected object. * @param pConnectObj The PConnect object of the component from where the API is being called. * @returns A Promise that resolves to an object. */ getMentionSuggestions: (mentionProps: { pulseContext?: string; searchFor: string; mentionsType: string; listSize?: number; }, pConnectObj: C11nEnv) => Promise; /** * Obtains the list of available types of objects that can be mentioned in a Pulse post. * @function * @static * @example In this example, the API obtains the list of available types of objects that can be mentioned in a Pulse post. * PCore.getFeedUtils().getMentionTypes(getPConnect()) * .then(response => { * // response array * }).catch(err => { * // errors * }); * @param pConnectObj The PConnect object of the component from where the API is being called. * @returns A Promise that resolves to an object. */ getMentionTypes: (pConnectObj: C11nEnv) => Promise; /** * Retrieves the view for a specified post type. * @function * @static * @example In this example, the API retrieves the view whose type is associated with the PegaSocial-Post-Task classID. * PCore.getFeedUtils().getPostTypeView('PegaSocial-Post-Task', getPConnect()) * .then(view => { * // Handle the view * }).catch(err => { * // Handle errors * }); * @param postTypeClassID The unique identifier of the class associated with the type of the message to be posted. * @param pConnectObj The pConnect object of the component from where the API is being called. * @returns A Promise that resolves to an object. */ getPostTypeView: (postTypeClassID: string, pConnectObj: C11nEnv) => Promise; /** * Obtains the options suggested for selecting a tag for a given context. * @function * @static * @example In this example, the API obtains the options suggested for selecting a tag for the given context. * PCore.getFeedUtils().getTagSuggestions({searchFor:"test", listSize:5}, getPConnect()) * .then(tagsResponse => { * // tagsResponse array * }).catch(err => { * // errors * }); * @param tagProps The object that contains the search parameters for obtaining the list of tags. * @param pConnectObj The PConnect object of the component from where the API is being called. * @returns A Promise that resolves to an object. */ getTagSuggestions: (tagProps: { searchFor: string; listSize?: number; }, pConnectObj: C11nEnv) => Promise; } declare const _default: FeedUtils; export default _default;