@droppii-org/chat-sdk 0.1.70 → 0.1.72

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 (80) hide show
  1. package/dist/components/conversation-detail/ConversationDetailInput.d.ts +3 -1
  2. package/dist/components/conversation-detail/ConversationDetailInput.d.ts.map +1 -1
  3. package/dist/components/conversation-detail/ConversationDetailInput.js +2 -2
  4. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts +2 -1
  5. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts.map +1 -1
  6. package/dist/components/conversation-detail/ConversationMoreOptionPanel.js +9 -5
  7. package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts.map +1 -1
  8. package/dist/components/conversation-detail/bot/BotButtonMessage.js +6 -4
  9. package/dist/components/media-collection/FileCollection.d.ts.map +1 -1
  10. package/dist/components/media-collection/FileCollection.js +1 -2
  11. package/dist/components/message/footer/FilePreview.d.ts +0 -6
  12. package/dist/components/message/footer/FilePreview.d.ts.map +1 -1
  13. package/dist/components/message/footer/FilePreview.js +1 -17
  14. package/dist/components/message/item/FileMessage.d.ts.map +1 -1
  15. package/dist/components/message/item/FileMessage.js +1 -2
  16. package/dist/components/message/item/TextMessage.d.ts.map +1 -1
  17. package/dist/components/message/item/TextMessage.js +0 -6
  18. package/dist/components/message/item/index.d.ts.map +1 -1
  19. package/dist/components/message/item/index.js +2 -8
  20. package/dist/components/message/item/renderMessageContent.d.ts.map +1 -1
  21. package/dist/components/message/item/renderMessageContent.js +3 -0
  22. package/dist/components/message/reply/ReplyQuoteContent.d.ts.map +1 -1
  23. package/dist/components/message/reply/ReplyQuoteContent.js +1 -1
  24. package/dist/constants/botFlow.d.ts +2 -0
  25. package/dist/constants/botFlow.d.ts.map +1 -1
  26. package/dist/constants/botFlow.js +2 -0
  27. package/dist/constants/moreOption.d.ts +11 -0
  28. package/dist/constants/moreOption.d.ts.map +1 -1
  29. package/dist/constants/moreOption.js +14 -0
  30. package/dist/context/ChatContext.d.ts +1 -1
  31. package/dist/context/ChatContext.d.ts.map +1 -1
  32. package/dist/context/ChatContext.js +2 -1
  33. package/dist/hooks/conversation/useBotConversationDetail.d.ts +1 -0
  34. package/dist/hooks/conversation/useBotConversationDetail.d.ts.map +1 -1
  35. package/dist/hooks/conversation/useBotConversationDetail.js +5 -4
  36. package/dist/hooks/conversation/useBotMainMenu.d.ts +4 -0
  37. package/dist/hooks/conversation/useBotMainMenu.d.ts.map +1 -0
  38. package/dist/hooks/conversation/useBotMainMenu.js +16 -0
  39. package/dist/hooks/conversation/useResolveConversation.d.ts +11 -0
  40. package/dist/hooks/conversation/useResolveConversation.d.ts.map +1 -0
  41. package/dist/hooks/conversation/useResolveConversation.js +90 -0
  42. package/dist/hooks/conversation/useSwitchToCsTeam.d.ts +6 -0
  43. package/dist/hooks/conversation/useSwitchToCsTeam.d.ts.map +1 -0
  44. package/dist/hooks/conversation/useSwitchToCsTeam.js +41 -0
  45. package/dist/hooks/message/useMessage.d.ts +1 -0
  46. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  47. package/dist/hooks/message/useMessage.js +12 -0
  48. package/dist/hooks/message/useSendMessage.d.ts +9 -2
  49. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  50. package/dist/hooks/message/useSendMessage.js +50 -4
  51. package/dist/index.d.ts +14 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +11 -0
  54. package/dist/locales/vi/common.json +2 -0
  55. package/dist/locales/vi/conversation-inbox.json +1 -0
  56. package/dist/screens/conversation-detail/index.d.ts +3 -2
  57. package/dist/screens/conversation-detail/index.d.ts.map +1 -1
  58. package/dist/screens/conversation-detail/index.js +15 -1
  59. package/dist/screens/conversation-inbox/index.d.ts +3 -1
  60. package/dist/screens/conversation-inbox/index.d.ts.map +1 -1
  61. package/dist/screens/conversation-inbox/index.js +2 -2
  62. package/dist/services/query.d.ts +2 -0
  63. package/dist/services/query.d.ts.map +1 -1
  64. package/dist/services/query.js +2 -0
  65. package/dist/services/routes.d.ts +2 -0
  66. package/dist/services/routes.d.ts.map +1 -1
  67. package/dist/services/routes.js +2 -0
  68. package/dist/tsconfig.tsbuildinfo +1 -1
  69. package/dist/types/chat.d.ts +5 -2
  70. package/dist/types/chat.d.ts.map +1 -1
  71. package/dist/types/chat.js +4 -4
  72. package/dist/types/conversation.d.ts +4 -0
  73. package/dist/types/conversation.d.ts.map +1 -1
  74. package/dist/utils/botFlow.d.ts +7 -0
  75. package/dist/utils/botFlow.d.ts.map +1 -0
  76. package/dist/utils/botFlow.js +9 -0
  77. package/dist/utils/common.d.ts +9 -0
  78. package/dist/utils/common.d.ts.map +1 -1
  79. package/dist/utils/common.js +34 -3
  80. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { SessionType } from "@openim/wasm-client-sdk";
4
+ import { DChatSDK } from "../../constants/sdk";
5
+ import { apiInstance } from "../../services/api";
6
+ import { ENDPOINTS } from "../../services/routes";
7
+ import useConversationStore from "../../store/conversation";
8
+ import { resolveConversationBotId } from "../../utils/conversation";
9
+ export const useResolveConversation = ({ conversationId, userId, groupId, botId, }) => {
10
+ const [isResolving, setIsResolving] = useState(false);
11
+ const [error, setError] = useState(null);
12
+ const conversationData = useConversationStore((state) => state.conversationData);
13
+ const setConversationData = useConversationStore((state) => state.setConversationData);
14
+ const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
15
+ const hasTarget = !!(conversationId || userId || groupId || botId);
16
+ const matchesConversationId = !!conversationId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.conversationID) === conversationId;
17
+ const matchesUserId = !!userId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.userID) === userId;
18
+ const matchesGroupId = !!groupId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.groupID) === groupId;
19
+ const matchesBotId = !!botId &&
20
+ !!conversationData &&
21
+ resolveConversationBotId(conversationData) === botId;
22
+ const isAlreadyResolved = matchesConversationId || matchesUserId || matchesGroupId || matchesBotId;
23
+ useEffect(() => {
24
+ if (!hasTarget || isAlreadyResolved)
25
+ return;
26
+ let cancelled = false;
27
+ setIsResolving(true);
28
+ setError(null);
29
+ const resolve = async () => {
30
+ var _a, _b;
31
+ try {
32
+ let resolved = null;
33
+ if (conversationId) {
34
+ const { data } = await DChatSDK.getMultipleConversation([conversationId]);
35
+ resolved = (_a = data === null || data === void 0 ? void 0 : data[0]) !== null && _a !== void 0 ? _a : null;
36
+ }
37
+ else if (userId || groupId) {
38
+ const { data } = await DChatSDK.getOneConversation({
39
+ sourceID: (userId || groupId),
40
+ sessionType: userId ? SessionType.Single : SessionType.Group,
41
+ });
42
+ resolved = data;
43
+ }
44
+ else if (botId) {
45
+ const { data: botConversationResponse } = await apiInstance.get(ENDPOINTS.chatService.getConversationByBotId(botId));
46
+ const resolvedGroupId = (_b = botConversationResponse.data) === null || _b === void 0 ? void 0 : _b.groupId;
47
+ if (!resolvedGroupId) {
48
+ throw new Error("Missing groupId from get-or-create bot conversation response");
49
+ }
50
+ const { data: conversation } = await DChatSDK.getOneConversation({
51
+ sourceID: resolvedGroupId,
52
+ sessionType: SessionType.Group,
53
+ });
54
+ resolved = conversation;
55
+ }
56
+ if (cancelled)
57
+ return;
58
+ if (!resolved) {
59
+ throw new Error("Conversation not found");
60
+ }
61
+ setConversationData(resolved);
62
+ setSelectedConversationId(resolved.conversationID);
63
+ }
64
+ catch (err) {
65
+ if (cancelled)
66
+ return;
67
+ console.error("useResolveConversation", err);
68
+ setError(err instanceof Error ? err : new Error("Failed to resolve conversation"));
69
+ }
70
+ finally {
71
+ if (!cancelled)
72
+ setIsResolving(false);
73
+ }
74
+ };
75
+ void resolve();
76
+ return () => {
77
+ cancelled = true;
78
+ };
79
+ }, [
80
+ conversationId,
81
+ userId,
82
+ groupId,
83
+ botId,
84
+ hasTarget,
85
+ isAlreadyResolved,
86
+ setConversationData,
87
+ setSelectedConversationId,
88
+ ]);
89
+ return { isResolving, error };
90
+ };
@@ -0,0 +1,6 @@
1
+ export type SwitchToCsTeamResult = "already_in_cs" | "switched" | "failed";
2
+ export declare const useSwitchToCsTeam: () => {
3
+ switchToCsTeam: (conversationId: string) => Promise<SwitchToCsTeamResult>;
4
+ isPending: boolean;
5
+ };
6
+ //# sourceMappingURL=useSwitchToCsTeam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwitchToCsTeam.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useSwitchToCsTeam.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3E,eAAO,MAAM,iBAAiB;qCAKH,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC;;CAuChE,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useCallback } from "react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { QUERY_KEYS } from "../../services/query";
5
+ import { BOT_COMMAND_CHAT_WITH_CS } from "../../constants/botFlow";
6
+ import { isInCsSession, findMainMenuAction } from "../../utils/botFlow";
7
+ import { fetchBotConversationDetail } from "./useBotConversationDetail";
8
+ import { fetchBotMainMenu } from "./useBotMainMenu";
9
+ import { useRunBotFlow } from "./useRunBotFlow";
10
+ export const useSwitchToCsTeam = () => {
11
+ const queryClient = useQueryClient();
12
+ const { mutateAsync: runBotFlow, isPending } = useRunBotFlow();
13
+ const switchToCsTeam = useCallback(async (conversationId) => {
14
+ try {
15
+ const detail = await fetchBotConversationDetail(conversationId);
16
+ if (isInCsSession(detail)) {
17
+ return "already_in_cs";
18
+ }
19
+ const mainMenu = await fetchBotMainMenu(conversationId);
20
+ const chatWithCsAction = findMainMenuAction(mainMenu, BOT_COMMAND_CHAT_WITH_CS);
21
+ if (!chatWithCsAction) {
22
+ return "failed";
23
+ }
24
+ await runBotFlow({
25
+ conversationId,
26
+ groupId: "",
27
+ childId: "",
28
+ actionId: chatWithCsAction.id,
29
+ });
30
+ await queryClient.invalidateQueries({
31
+ queryKey: [QUERY_KEYS.GET_CONVERSATION_DETAIL, conversationId],
32
+ });
33
+ return "switched";
34
+ }
35
+ catch (error) {
36
+ console.error("switchToCsTeam", error);
37
+ return "failed";
38
+ }
39
+ }, [runBotFlow, queryClient]);
40
+ return { switchToCsTeam, isPending };
41
+ };
@@ -1,5 +1,6 @@
1
1
  import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
2
2
  export declare const visibleTypeMessage: MessageType[];
3
+ export declare const isMessageHiddenForViewer: (message: MessageItem, isCrm: boolean) => boolean;
3
4
  export declare const useMessage: (conversationId?: string, searchClientMsgID?: string, enabled?: boolean, useAppHistory?: boolean) => {
4
5
  loadState: {
5
6
  initLoading: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAUjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc,EACd,uBAAqB;;;;;qBAeA,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAiSnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
1
+ {"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAYjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,SAAS,WAAW,EACpB,OAAO,OAAO,KACb,OAWF,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc,EACd,uBAAqB;;;;;qBAeA,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAiSnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
@@ -8,6 +8,8 @@ import isEmpty from "lodash/isEmpty";
8
8
  import { useChatContext } from "../../context/ChatContext";
9
9
  import useAuthStore from "../../store/auth";
10
10
  import { ConnectStatus, SyncStatus } from "../../types/chat";
11
+ import { isSystemLogMessageType } from "../../utils/messageLog";
12
+ import { isRenderableCustomMessage } from "../../utils/customMessage";
11
13
  export const visibleTypeMessage = [
12
14
  MessageType.TextMessage,
13
15
  MessageType.PictureMessage,
@@ -25,6 +27,16 @@ export const visibleTypeMessage = [
25
27
  MessageType.RevokeMessage,
26
28
  MessageType.LogTextMessage,
27
29
  ];
30
+ export const isMessageHiddenForViewer = (message, isCrm) => {
31
+ if (!visibleTypeMessage.includes(message === null || message === void 0 ? void 0 : message.contentType))
32
+ return true;
33
+ if (isCrm)
34
+ return false;
35
+ const isCustomMessage = MessageType.CustomMessage === (message === null || message === void 0 ? void 0 : message.contentType);
36
+ return (Boolean(message === null || message === void 0 ? void 0 : message.isInternal) ||
37
+ isSystemLogMessageType(message === null || message === void 0 ? void 0 : message.contentType) ||
38
+ (isCustomMessage && !isRenderableCustomMessage(message)));
39
+ };
28
40
  export const useMessage = (conversationId, searchClientMsgID, enabled = true, useAppHistory = false) => {
29
41
  const { connectStatus, syncStatus } = useChatContext();
30
42
  const userID = useAuthStore((state) => state.userID);
@@ -1,4 +1,5 @@
1
- import { MergerMsgParams, MessageItem } from "@openim/wasm-client-sdk";
1
+ import { CustomMsgParams, MergerMsgParams, MessageItem } from "@openim/wasm-client-sdk";
2
+ import { type CustomMessagePayload } from "../../types/customMessage";
2
3
  import { BotFlowMeta, ExtendMessageInfo, FileMsgParamsByFile, ImageMsgParamsByFile, UrlMetadataInfo, VideoMsgParamsByFile } from "../../types/chat";
3
4
  import { UploadFile } from "antd";
4
5
  import { ISessionResponse } from "../../types/dto";
@@ -12,6 +13,8 @@ export declare const createMergerMessage: (mergerMsgParams: MergerMsgParams) =>
12
13
  export declare const createVideoMessageByFile: (file: VideoMsgParamsByFile) => Promise<MessageItem | null>;
13
14
  export declare const createFileMessageByFile: (file: FileMsgParamsByFile) => Promise<MessageItem | null>;
14
15
  export declare const createUrlTextMessage: (text: string, urls: string[]) => Promise<MessageItem | null>;
16
+ export declare const createCustomMessageByParams: (params: CustomMsgParams) => Promise<MessageItem | null>;
17
+ export declare const createCustomMessage: (payload: CustomMessagePayload) => Promise<MessageItem | null>;
15
18
  export declare const createQuoteMessage: (text: string, quotedMessage: MessageItem) => Promise<MessageItem | null>;
16
19
  export type SendMessageScrollEvent = "CHAT_LIST_SCROLL_TO_BOTTOM" | "CONVERSATION_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM";
17
20
  export interface OfflinePushMeta {
@@ -26,7 +29,7 @@ export interface UseSendMessageOptions {
26
29
  }) => OfflinePushMeta;
27
30
  }
28
31
  export declare const useSendMessage: (options?: UseSendMessageOptions) => {
29
- sendMergeMessage: ({ richText, plainText, files, currentSession, isInternal, urlMetadata, flow, }: {
32
+ sendMergeMessage: ({ richText, plainText, files, currentSession, isInternal, urlMetadata, flow, customMessage, }: {
30
33
  richText: string;
31
34
  plainText: string;
32
35
  files?: UploadFile[];
@@ -34,6 +37,10 @@ export declare const useSendMessage: (options?: UseSendMessageOptions) => {
34
37
  isInternal: boolean;
35
38
  urlMetadata?: UrlMetadataInfo;
36
39
  flow?: BotFlowMeta;
40
+ customMessage?: CustomMessagePayload;
41
+ }) => Promise<boolean>;
42
+ sendCustomMessage: (payload: CustomMessagePayload, sendOptions?: {
43
+ currentSession?: ISessionResponse;
37
44
  }) => Promise<boolean>;
38
45
  resendMessage: (failedMessage: MessageItem) => Promise<void>;
39
46
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF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AAC;IACrC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;sHA0RvD;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;QAClC,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;QACnB,aAAa,CAAC,EAAE,oBAAoB,CAAC;KACtC,KAAG,OAAO,CAAC,OAAO,CAAC;iCA3CT,oBAAoB,gBACf;QAAE,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAAE,KAClD,OAAO,CAAC,OAAO,CAAC;mCAnHG,WAAW;CAyVpC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,kDAKvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,sBA8BA,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { MessageStatus, MessageType, } from "@openim/wasm-client-sdk";
2
+ import { CustomMessageType, } from "../../types/customMessage";
2
3
  import { DChatSDK } from "../../constants/sdk";
3
4
  import { v4 as uuidv4 } from "uuid";
4
5
  import { useCallback } from "react";
@@ -89,6 +90,24 @@ export const createUrlTextMessage = async (text, urls) => {
89
90
  });
90
91
  return textMessage;
91
92
  };
93
+ export const createCustomMessageByParams = async (params) => {
94
+ let customMessage = await DChatSDK.createCustomMessage(params, new Date().getTime().toString())
95
+ .then(({ data }) => {
96
+ return data;
97
+ })
98
+ .catch(({ errCode, errMsg }) => {
99
+ console.error("createCustomMessage", errCode, errMsg);
100
+ return null;
101
+ });
102
+ return customMessage;
103
+ };
104
+ export const createCustomMessage = async (payload) => {
105
+ return createCustomMessageByParams({
106
+ data: JSON.stringify(payload.data),
107
+ extension: payload.type,
108
+ description: payload.type === CustomMessageType.Order ? payload.data.orderCode : "",
109
+ });
110
+ };
92
111
  export const createQuoteMessage = async (text, quotedMessage) => {
93
112
  let textMessage = await DChatSDK.createQuoteMessage({
94
113
  text,
@@ -140,10 +159,10 @@ export const useSendMessage = (options) => {
140
159
  }, [queryClient]);
141
160
  const dispatchMessage = useCallback(async (message, currentSession) => {
142
161
  var _a, _b, _c, _d, _e, _f;
143
- const desc = generateContentBasedOnMessageType(message.contentType, ((_a = message === null || message === void 0 ? void 0 : message.textElem) === null || _a === void 0 ? void 0 : _a.content) || "", undefined, {
162
+ const desc = generateContentBasedOnMessageType(message.contentType, ((_a = message === null || message === void 0 ? void 0 : message.textElem) === null || _a === void 0 ? void 0 : _a.content) || "", t, {
144
163
  duration: (_b = message.videoElem) === null || _b === void 0 ? void 0 : _b.duration,
145
164
  fileName: (_c = message.fileElem) === null || _c === void 0 ? void 0 : _c.fileName,
146
- }) || t("new_message");
165
+ }, message === null || message === void 0 ? void 0 : message.customElem) || t("new_message");
147
166
  const pushMeta = (_e = (_d = options === null || options === void 0 ? void 0 : options.resolveOfflinePushMeta) === null || _d === void 0 ? void 0 : _d.call(options, { desc })) !== null && _e !== void 0 ? _e : {
148
167
  title: (conversationData === null || conversationData === void 0 ? void 0 : conversationData.showName) || "Droppii Chat",
149
168
  icon: (conversationData === null || conversationData === void 0 ? void 0 : conversationData.faceURL) || "",
@@ -200,7 +219,16 @@ export const useSendMessage = (options) => {
200
219
  if (!storedFiles) {
201
220
  let newTextPayload = null;
202
221
  const textContent = ((_a = failedMessage.textElem) === null || _a === void 0 ? void 0 : _a.content) || failedMessage.content || "";
203
- if (failedMessage.contentType === MessageType.UrlTextMessage &&
222
+ if (failedMessage.contentType === MessageType.CustomMessage) {
223
+ newTextPayload = failedMessage.customElem
224
+ ? await createCustomMessageByParams({
225
+ data: failedMessage.customElem.data,
226
+ extension: failedMessage.customElem.extension,
227
+ description: failedMessage.customElem.description,
228
+ })
229
+ : null;
230
+ }
231
+ else if (failedMessage.contentType === MessageType.UrlTextMessage &&
204
232
  failedMessage.urlTextElem) {
205
233
  newTextPayload = await createUrlTextMessage(textContent, failedMessage.urlTextElem.urls);
206
234
  }
@@ -275,7 +303,18 @@ export const useSendMessage = (options) => {
275
303
  removeOneMessage(failedMessage.clientMsgID);
276
304
  await sendMessage(Object.assign(Object.assign({}, newPayload), { ex: failedMessage.ex }));
277
305
  }, [sendMessage]);
278
- const sendMergeMessage = useCallback(async ({ richText, plainText, files = [], currentSession, isInternal, urlMetadata, flow, }) => {
306
+ const sendCustomMessage = useCallback(async (payload, sendOptions) => {
307
+ if (!conversationData || (!recvID && !groupID))
308
+ return false;
309
+ const customMessage = await createCustomMessage(payload);
310
+ if (!customMessage)
311
+ return false;
312
+ const extendMessageInfo = generateExtendMessageInfo({
313
+ currentSession: sendOptions === null || sendOptions === void 0 ? void 0 : sendOptions.currentSession,
314
+ });
315
+ return sendMessage(Object.assign(Object.assign({}, customMessage), { ex: JSON.stringify(extendMessageInfo) || "{}", isInternal: false }), sendOptions === null || sendOptions === void 0 ? void 0 : sendOptions.currentSession);
316
+ }, [conversationData, recvID, groupID, sendMessage]);
317
+ const sendMergeMessage = useCallback(async ({ richText, plainText, files = [], currentSession, isInternal, urlMetadata, flow, customMessage, }) => {
279
318
  if (!conversationData || (!recvID && !groupID))
280
319
  return false;
281
320
  const messageList = [];
@@ -415,6 +454,12 @@ export const useSendMessage = (options) => {
415
454
  return false;
416
455
  messageList.push(textMessage);
417
456
  }
457
+ if (customMessage) {
458
+ const customMessageItem = await createCustomMessage(customMessage);
459
+ if (!customMessageItem)
460
+ return false;
461
+ messageList.push(customMessageItem);
462
+ }
418
463
  for (const message of messageList) {
419
464
  const isTextLikeMessage = (message === null || message === void 0 ? void 0 : message.contentType) === MessageType.TextMessage ||
420
465
  (message === null || message === void 0 ? void 0 : message.contentType) === MessageType.UrlTextMessage ||
@@ -441,6 +486,7 @@ export const useSendMessage = (options) => {
441
486
  ]);
442
487
  return {
443
488
  sendMergeMessage,
489
+ sendCustomMessage,
444
490
  resendMessage,
445
491
  };
446
492
  };
package/dist/index.d.ts CHANGED
@@ -19,9 +19,22 @@ export { default as DChatConversationDetail } from "./screens/conversation-detai
19
19
  export type { DChatConversationDetailProps } from "./screens/conversation-detail";
20
20
  export { ConversationDetailHeader, ConversationDetailInput, } from "./components/conversation-detail";
21
21
  export type { ConversationDetailHeaderProps, ConversationDetailInputProps, } from "./components/conversation-detail";
22
+ export { DEFAULT_MORE_OPTIONS, MORE_OPTIONS, MoreOptionKey, createMoreOptions, } from "./constants/moreOption";
23
+ export type { MoreOptionConfig } from "./constants/moreOption";
22
24
  export { ChatCategory, ChatType, PeerType, } from "./types/conversation";
23
- export type { ConversationListItem, CreateConversationData, ConversationMember, } from "./types/conversation";
25
+ export type { ConversationListItem, CreateConversationData, ConversationMember, BotConversationDetail, BotMainMenuItem, } from "./types/conversation";
26
+ export { isBotPeer, resolveConversationBotId } from "./utils/conversation";
27
+ export { isInCsSession } from "./utils/botFlow";
28
+ export { useBotConversationDetail, fetchBotConversationDetail, } from "./hooks/conversation/useBotConversationDetail";
29
+ export { useBotMainMenu } from "./hooks/conversation/useBotMainMenu";
30
+ export { useSwitchToCsTeam, } from "./hooks/conversation/useSwitchToCsTeam";
31
+ export type { SwitchToCsTeamResult } from "./hooks/conversation/useSwitchToCsTeam";
32
+ export { CustomMessageType } from "./types/customMessage";
33
+ export type { CustomElemOrderData, CustomMessagePayload, RenderCustomMessage, RenderCustomMessageArgs, } from "./types/customMessage";
34
+ export { parseCustomMessagePayload, isRenderableCustomMessage, } from "./utils/customMessage";
24
35
  export { useDChatAuth } from "./hooks/user/useAuth";
36
+ export { useSendMessage } from "./hooks/message/useSendMessage";
37
+ export type { UseSendMessageOptions } from "./hooks/message/useSendMessage";
25
38
  export { useUpdateFcmToken } from "./hooks/user/useUpdateFcmToken";
26
39
  export { useConversationList } from "./hooks/conversation/useConversationList";
27
40
  export { useCreateConversation } from "./hooks/conversation/useCreateConversation";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AACtD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,cAAc,CAAC;AAC7C,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAEzF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACjF,YAAY,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACnF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACx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 -18,9 +18,20 @@ export { default as RichTextEditor } from "./components/rich-text-editor/RichTex
18
18
  export { default as DChatConversationInbox } from "./screens/conversation-inbox";
19
19
  export { default as DChatConversationDetail } from "./screens/conversation-detail";
20
20
  export { ConversationDetailHeader, ConversationDetailInput, } from "./components/conversation-detail";
21
+ export { DEFAULT_MORE_OPTIONS, MORE_OPTIONS, MoreOptionKey, createMoreOptions, } from "./constants/moreOption";
21
22
  export { ChatCategory, ChatType, PeerType, } from "./types/conversation";
23
+ //Bot flow / CS session
24
+ export { isBotPeer, resolveConversationBotId } from "./utils/conversation";
25
+ export { isInCsSession } from "./utils/botFlow";
26
+ export { useBotConversationDetail, fetchBotConversationDetail, } from "./hooks/conversation/useBotConversationDetail";
27
+ export { useBotMainMenu } from "./hooks/conversation/useBotMainMenu";
28
+ export { useSwitchToCsTeam, } from "./hooks/conversation/useSwitchToCsTeam";
29
+ //Custom message
30
+ export { CustomMessageType } from "./types/customMessage";
31
+ export { parseCustomMessagePayload, isRenderableCustomMessage, } from "./utils/customMessage";
22
32
  //Hooks
23
33
  export { useDChatAuth } from "./hooks/user/useAuth";
34
+ export { useSendMessage } from "./hooks/message/useSendMessage";
24
35
  export { useUpdateFcmToken } from "./hooks/user/useUpdateFcmToken";
25
36
  export { useConversationList } from "./hooks/conversation/useConversationList";
26
37
  export { useCreateConversation } from "./hooks/conversation/useCreateConversation";
@@ -103,6 +103,8 @@
103
103
  "msg_type_file": "[File]",
104
104
  "msg_type_video": "[Video]",
105
105
  "msg_type_unsupported": "Tin nhắn không khả dụng",
106
+ "msg_type_order": "[Đơn hàng] {{orderCode}}",
107
+ "invalid_message": "Tin nhắn không hợp lệ",
106
108
  "session_started": "Phiên chat đã bắt đầu",
107
109
  "session_ended": "Phiên chat đã kết thúc",
108
110
  "new_message": "Bạn có tin nhắn mới",
@@ -17,6 +17,7 @@
17
17
  "thread_detail": {
18
18
  "profile_hint": "Nhấn để xem thông tin",
19
19
  "input_placeholder": "Nhập tin nhắn...",
20
+ "resolve_failed": "Không thể mở cuộc trò chuyện",
20
21
  "more_option": {
21
22
  "toggle": "Tùy chọn khác",
22
23
  "media": "Ảnh/Video",
@@ -1,9 +1,10 @@
1
1
  import type { ConversationDetailInputProps } from "../../components/conversation-detail";
2
- export interface DChatConversationDetailProps extends ConversationDetailInputProps {
2
+ import { type UseResolveConversationParams } from "../../hooks/conversation/useResolveConversation";
3
+ export interface DChatConversationDetailProps extends ConversationDetailInputProps, UseResolveConversationParams {
3
4
  className?: string;
4
5
  children?: React.ReactNode;
5
6
  onBack?: () => void;
6
7
  }
7
- declare const DChatConversationDetail: ({ className, children, onBack, ...inputProps }: DChatConversationDetailProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ declare const DChatConversationDetail: ({ className, children, onBack, conversationId, userId, groupId, botId, ...inputProps }: DChatConversationDetailProps) => import("react/jsx-runtime").JSX.Element | null;
8
9
  export default DChatConversationDetail;
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-detail/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAUrF,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,uBAAuB,GAAI,gDAK9B,4BAA4B,mDAoF9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-detail/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAQrF,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAGrD,MAAM,WAAW,4BACf,SAAQ,4BAA4B,EAClC,4BAA4B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,uBAAuB,GAAI,wFAS9B,4BAA4B,mDA2G9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -14,19 +14,27 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
14
14
  import { usePathname, useRouter, useSearchParams } from "next/navigation";
15
15
  import { useTranslation } from "react-i18next";
16
16
  import clsx from "clsx";
17
+ import { Empty, Spin } from "antd";
17
18
  import useConversationStore from "../../store/conversation";
18
19
  import { ConversationMessageList, ConversationDetailHeader, ConversationDetailInput, PinnedMessageBar, } from "../../components/conversation-detail";
19
20
  import { BotButtonMessage, BotInactiveNotice, BotStartButton, BotSuggest, } from "../../components/conversation-detail/bot";
20
21
  import { useBotFlow } from "../../hooks/conversation/useBotFlow";
22
+ import { useResolveConversation, } from "../../hooks/conversation/useResolveConversation";
21
23
  import { isBotPeer } from "../../utils/conversation";
22
24
  const DChatConversationDetail = (_a) => {
23
25
  var _b;
24
- var { className, children, onBack } = _a, inputProps = __rest(_a, ["className", "children", "onBack"]);
26
+ var { className, children, onBack, conversationId, userId, groupId, botId } = _a, inputProps = __rest(_a, ["className", "children", "onBack", "conversationId", "userId", "groupId", "botId"]);
25
27
  const { t } = useTranslation("conversation-inbox");
26
28
  const router = useRouter();
27
29
  const pathname = usePathname();
28
30
  const searchParams = useSearchParams();
29
31
  const conversation = useConversationStore((state) => state.conversationData);
32
+ const { isResolving, error } = useResolveConversation({
33
+ conversationId,
34
+ userId,
35
+ groupId,
36
+ botId,
37
+ });
30
38
  const isBotThread = conversation ? isBotPeer(conversation) : false;
31
39
  const botFlow = useBotFlow({
32
40
  conversationId: (_b = conversation === null || conversation === void 0 ? void 0 : conversation.conversationID) !== null && _b !== void 0 ? _b : "",
@@ -39,6 +47,12 @@ const DChatConversationDetail = (_a) => {
39
47
  router.replace(query ? `${pathname}?${query}` : pathname);
40
48
  onBack === null || onBack === void 0 ? void 0 : onBack();
41
49
  };
50
+ if (isResolving) {
51
+ return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-white", children: _jsx(Spin, {}) }));
52
+ }
53
+ if (error) {
54
+ return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-white", children: _jsx(Empty, { description: t("thread_detail.resolve_failed") }) }));
55
+ }
42
56
  if (!conversation) {
43
57
  return null;
44
58
  }
@@ -1,8 +1,10 @@
1
1
  import type { ConversationListItem } from "../../types/conversation";
2
+ import type { MoreOptionConfig } from "../../constants/moreOption";
2
3
  export interface DChatConversationInboxProps {
3
4
  onSelectThread?: (conversation: ConversationListItem) => void;
4
5
  className?: string;
6
+ moreOptions?: MoreOptionConfig[];
5
7
  }
6
- declare const DChatConversationInbox: ({ onSelectThread, className, }: DChatConversationInboxProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const DChatConversationInbox: ({ onSelectThread, className, moreOptions, }: DChatConversationInboxProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default DChatConversationInbox;
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-inbox/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,sBAAsB,GAAI,gCAG7B,2BAA2B,4CA+C7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-inbox/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED,QAAA,MAAM,sBAAsB,GAAI,6CAI7B,2BAA2B,4CAoD7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -12,7 +12,7 @@ import ConversationInboxList from "../../components/conversation-inbox/Conversat
12
12
  import DChatConversationDetail from "../../screens/conversation-detail";
13
13
  import { DChatApplicationType } from "../../types/chat";
14
14
  import { Icon } from "../../components/icon";
15
- const DChatConversationInbox = ({ onSelectThread, className, }) => {
15
+ const DChatConversationInbox = ({ onSelectThread, className, moreOptions, }) => {
16
16
  const { t } = useTranslation("conversation-inbox");
17
17
  const searchParams = useSearchParams();
18
18
  const threadId = searchParams.get("threadId");
@@ -23,7 +23,7 @@ const DChatConversationInbox = ({ onSelectThread, className, }) => {
23
23
  });
24
24
  useActiveConversation(conversationList.items);
25
25
  if (threadId) {
26
- return _jsx(DChatConversationDetail, { className: className });
26
+ return (_jsx(DChatConversationDetail, { className: className, moreOptions: moreOptions }));
27
27
  }
28
28
  return (_jsxs("div", { "data-testid": "conversation-inbox-root", className: clsx("flex h-full w-full flex-col bg-white", className), children: [_jsx(ConversationInboxHeader, {}), !isApplicationTypeValid ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 80, className: "text-gray-300" }), description: t("empty.no_conversations") }) })) : (_jsx(ConversationInboxList, { items: conversationList.items, isLoading: conversationList.isLoading, isFetchingNextPage: conversationList.isFetchingNextPage, hasNextPage: conversationList.hasNextPage, onLoadMore: conversationList.fetchNextPage, onSelectThread: onSelectThread }))] }));
29
29
  };
@@ -29,6 +29,8 @@ export declare const QUERY_KEYS: {
29
29
  RUN_BOT_FLOW: string;
30
30
  RESET_BOT_FLOW: string;
31
31
  GET_BOT_DETAIL: string;
32
+ GET_BOT_MAIN_MENU: string;
33
+ GET_CONVERSATION_BY_BOT_ID: string;
32
34
  LEAVE_CONVERSATION: string;
33
35
  IS_JOINED_GROUP: string;
34
36
  CREATE_SESSION: string;
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/services/query.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCtB,CAAC"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/services/query.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCtB,CAAC"}
@@ -29,6 +29,8 @@ export const QUERY_KEYS = {
29
29
  RUN_BOT_FLOW: "RUN_BOT_FLOW",
30
30
  RESET_BOT_FLOW: "RESET_BOT_FLOW",
31
31
  GET_BOT_DETAIL: "GET_BOT_DETAIL",
32
+ GET_BOT_MAIN_MENU: "GET_BOT_MAIN_MENU",
33
+ GET_CONVERSATION_BY_BOT_ID: "GET_CONVERSATION_BY_BOT_ID",
32
34
  LEAVE_CONVERSATION: "LEAVE_CONVERSATION",
33
35
  IS_JOINED_GROUP: "IS_JOINED_GROUP",
34
36
  CREATE_SESSION: "CREATE_SESSION",
@@ -31,7 +31,9 @@ export declare const ENDPOINTS: {
31
31
  getConversationDetail: (conversationId: string) => string;
32
32
  runBotFlow: (conversationId: string) => string;
33
33
  resetBotFlow: (conversationId: string) => string;
34
+ getBotMainMenu: (conversationId: string) => string;
34
35
  getBotDetail: (botId: string) => string;
36
+ getConversationByBotId: (botId: string) => string;
35
37
  getUrlMetadata: string;
36
38
  };
37
39
  identityService: {
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/services/routes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;mCAMS,MAAM;;0CAGC,MAAM,UAAU,MAAM;6BAEnC,MAAM;;oDAEiB,MAAM;uCAEnB,MAAM;kCAEX,MAAM;;oCAGJ,MAAM;mCAEP,MAAM;uCAEF,MAAM;;;;;;;;iCASZ,MAAM;4CAEK,MAAM;;;;gDAKF,MAAM;qCAEjB,MAAM;uCAEJ,MAAM;8BAEf,MAAM;;;;;;;;;CAS/B,CAAC"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/services/routes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;mCAMS,MAAM;;0CAGC,MAAM,UAAU,MAAM;6BAEnC,MAAM;;oDAEiB,MAAM;uCAEnB,MAAM;kCAEX,MAAM;;oCAGJ,MAAM;mCAEP,MAAM;uCAEF,MAAM;;;;;;;;iCASZ,MAAM;4CAEK,MAAM;;;;gDAKF,MAAM;qCAEjB,MAAM;uCAEJ,MAAM;yCAEJ,MAAM;8BAEjB,MAAM;wCACI,MAAM;;;;;;;;;CAUzC,CAAC"}
@@ -31,7 +31,9 @@ export const ENDPOINTS = {
31
31
  getConversationDetail: (conversationId) => `/chat-service/v1/app/conversations/${conversationId}`,
32
32
  runBotFlow: (conversationId) => `/chat-service/v1/app/conversations/${conversationId}/bot-flows/run`,
33
33
  resetBotFlow: (conversationId) => `/chat-service/v1/app/conversations/${conversationId}/bot-flows/reset`,
34
+ getBotMainMenu: (conversationId) => `/chat-service/v1/app/conversations/${conversationId}/bot-flows/main-menu`,
34
35
  getBotDetail: (botId) => `/chat-service/v1/app/bots/${botId}`,
36
+ getConversationByBotId: (botId) => `/chat-service/v1/app/bots/${botId}/conversation`,
35
37
  getUrlMetadata: "/chat-service/v1/utils/url-metadata",
36
38
  },
37
39
  identityService: {