@daeryun/dr_components 1.2.18 → 1.2.20

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 (241) hide show
  1. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  2. package/dist/components/Daeryuntalk/ChatButton.jsx +1 -1
  3. package/dist/components/Daeryuntalk/ChatButton.tsx +1 -1
  4. package/dist/components/Daeryuntalk/ChatWidget.d.ts +1 -0
  5. package/dist/components/Daeryuntalk/ChatWidget.jsx +114 -31
  6. package/dist/components/Daeryuntalk/ChatWidget.tsx +120 -37
  7. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +0 -9
  8. package/dist/components/Daeryuntalk/index.jsx +17 -1
  9. package/dist/components/Daeryuntalk/index.tsx +26 -2
  10. package/dist/components/DaeryuntalkBackup/ChatButton.d.ts +11 -0
  11. package/dist/components/DaeryuntalkBackup/ChatButton.jsx +123 -0
  12. package/dist/components/DaeryuntalkBackup/ChatButton.tsx +157 -0
  13. package/dist/components/DaeryuntalkBackup/ChatConversation.d.ts +21 -0
  14. package/dist/components/DaeryuntalkBackup/ChatConversation.jsx +259 -0
  15. package/dist/components/DaeryuntalkBackup/ChatConversation.tsx +390 -0
  16. package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.d.ts +16 -0
  17. package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.jsx +50 -0
  18. package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.tsx +108 -0
  19. package/dist/components/DaeryuntalkBackup/ChatHomeView.d.ts +14 -0
  20. package/dist/components/DaeryuntalkBackup/ChatHomeView.jsx +147 -0
  21. package/dist/components/DaeryuntalkBackup/ChatHomeView.tsx +262 -0
  22. package/dist/components/DaeryuntalkBackup/ChatInput.d.ts +8 -0
  23. package/dist/components/DaeryuntalkBackup/ChatInput.jsx +64 -0
  24. package/dist/components/DaeryuntalkBackup/ChatInput.tsx +98 -0
  25. package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.d.ts +6 -0
  26. package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.jsx +19 -0
  27. package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.tsx +27 -0
  28. package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.d.ts +10 -0
  29. package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.jsx +165 -0
  30. package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.tsx +244 -0
  31. package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.d.ts +6 -0
  32. package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.jsx +12 -0
  33. package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.tsx +25 -0
  34. package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.d.ts +8 -0
  35. package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.jsx +100 -0
  36. package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.tsx +135 -0
  37. package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.d.ts +8 -0
  38. package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.jsx +14 -0
  39. package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.tsx +26 -0
  40. package/dist/components/DaeryuntalkBackup/ChatItem/RichText.d.ts +7 -0
  41. package/dist/components/DaeryuntalkBackup/ChatItem/RichText.jsx +37 -0
  42. package/dist/components/DaeryuntalkBackup/ChatItem/RichText.tsx +45 -0
  43. package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.d.ts +9 -0
  44. package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.jsx +10 -0
  45. package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.tsx +21 -0
  46. package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.d.ts +3 -0
  47. package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.jsx +34 -0
  48. package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.tsx +43 -0
  49. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.d.ts +8 -0
  50. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.jsx +20 -0
  51. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.tsx +32 -0
  52. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.d.ts +7 -0
  53. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.jsx +21 -0
  54. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.tsx +37 -0
  55. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.d.ts +9 -0
  56. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.jsx +178 -0
  57. package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.tsx +233 -0
  58. package/dist/components/DaeryuntalkBackup/ChatMessage.d.ts +20 -0
  59. package/dist/components/DaeryuntalkBackup/ChatMessage.jsx +198 -0
  60. package/dist/components/DaeryuntalkBackup/ChatMessage.tsx +295 -0
  61. package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.d.ts +9 -0
  62. package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.jsx +39 -0
  63. package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.tsx +75 -0
  64. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.d.ts +7 -0
  65. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.jsx +20 -0
  66. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.tsx +39 -0
  67. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.d.ts +10 -0
  68. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.jsx +138 -0
  69. package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.tsx +177 -0
  70. package/dist/components/DaeryuntalkBackup/ChatWidget.d.ts +13 -0
  71. package/dist/components/DaeryuntalkBackup/ChatWidget.jsx +154 -0
  72. package/dist/components/DaeryuntalkBackup/ChatWidget.tsx +221 -0
  73. package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.d.ts +103 -0
  74. package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.jsx +207 -0
  75. package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.tsx +350 -0
  76. package/dist/components/DaeryuntalkBackup/DateSeparator.d.ts +6 -0
  77. package/dist/components/DaeryuntalkBackup/DateSeparator.jsx +14 -0
  78. package/dist/components/DaeryuntalkBackup/DateSeparator.tsx +24 -0
  79. package/dist/components/DaeryuntalkBackup/FixedErrorBox.d.ts +7 -0
  80. package/dist/components/DaeryuntalkBackup/FixedErrorBox.jsx +34 -0
  81. package/dist/components/DaeryuntalkBackup/FixedErrorBox.tsx +73 -0
  82. package/dist/components/DaeryuntalkBackup/History/AuthForm.d.ts +10 -0
  83. package/dist/components/DaeryuntalkBackup/History/AuthForm.jsx +157 -0
  84. package/dist/components/DaeryuntalkBackup/History/AuthForm.tsx +206 -0
  85. package/dist/components/DaeryuntalkBackup/HistoryView.d.ts +19 -0
  86. package/dist/components/DaeryuntalkBackup/HistoryView.jsx +94 -0
  87. package/dist/components/DaeryuntalkBackup/HistoryView.tsx +182 -0
  88. package/dist/components/DaeryuntalkBackup/HomeView.d.ts +12 -0
  89. package/dist/components/DaeryuntalkBackup/HomeView.jsx +178 -0
  90. package/dist/components/DaeryuntalkBackup/HomeView.tsx +261 -0
  91. package/dist/components/DaeryuntalkBackup/NavigationFooter.d.ts +11 -0
  92. package/dist/components/DaeryuntalkBackup/NavigationFooter.jsx +44 -0
  93. package/dist/components/DaeryuntalkBackup/NavigationFooter.tsx +98 -0
  94. package/dist/components/DaeryuntalkBackup/NoticeMessage.d.ts +7 -0
  95. package/dist/components/DaeryuntalkBackup/NoticeMessage.jsx +40 -0
  96. package/dist/components/DaeryuntalkBackup/NoticeMessage.tsx +60 -0
  97. package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.d.ts +6 -0
  98. package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.jsx +17 -0
  99. package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.tsx +28 -0
  100. package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.d.ts +20 -0
  101. package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.jsx +130 -0
  102. package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.tsx +181 -0
  103. package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.d.ts +23 -0
  104. package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.jsx +40 -0
  105. package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.tsx +70 -0
  106. package/dist/components/DaeryuntalkBackup/Toast/Toast.d.ts +11 -0
  107. package/dist/components/DaeryuntalkBackup/Toast/Toast.jsx +64 -0
  108. package/dist/components/DaeryuntalkBackup/Toast/Toast.tsx +98 -0
  109. package/dist/components/DaeryuntalkBackup/Toast/ToastRender.d.ts +1 -0
  110. package/dist/components/DaeryuntalkBackup/Toast/ToastRender.jsx +22 -0
  111. package/dist/components/DaeryuntalkBackup/Toast/ToastRender.tsx +30 -0
  112. package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.d.ts +9 -0
  113. package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.jsx +98 -0
  114. package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.tsx +138 -0
  115. package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.d.ts +18 -0
  116. package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.jsx +104 -0
  117. package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.tsx +182 -0
  118. package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.d.ts +24 -0
  119. package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.jsx +141 -0
  120. package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.tsx +278 -0
  121. package/dist/components/DaeryuntalkBackup/ViewportHandler.d.ts +6 -0
  122. package/dist/components/DaeryuntalkBackup/ViewportHandler.jsx +25 -0
  123. package/dist/components/DaeryuntalkBackup/ViewportHandler.tsx +32 -0
  124. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.d.ts +177 -0
  125. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.js +801 -0
  126. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.ts +1097 -0
  127. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.d.ts +131 -0
  128. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.js +1 -0
  129. package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.ts +159 -0
  130. package/dist/components/DaeryuntalkBackup/_api/index.d.ts +6 -0
  131. package/dist/components/DaeryuntalkBackup/_api/index.js +6 -0
  132. package/dist/components/DaeryuntalkBackup/_api/index.ts +7 -0
  133. package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.d.ts +5 -0
  134. package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.js +9 -0
  135. package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.ts +9 -0
  136. package/dist/components/DaeryuntalkBackup/_enums/ask-status.d.ts +13 -0
  137. package/dist/components/DaeryuntalkBackup/_enums/ask-status.js +25 -0
  138. package/dist/components/DaeryuntalkBackup/_enums/ask-status.ts +26 -0
  139. package/dist/components/DaeryuntalkBackup/_enums/error.d.ts +109 -0
  140. package/dist/components/DaeryuntalkBackup/_enums/error.js +254 -0
  141. package/dist/components/DaeryuntalkBackup/_enums/error.ts +289 -0
  142. package/dist/components/DaeryuntalkBackup/_enums/message_type.d.ts +6 -0
  143. package/dist/components/DaeryuntalkBackup/_enums/message_type.js +13 -0
  144. package/dist/components/DaeryuntalkBackup/_enums/message_type.ts +13 -0
  145. package/dist/components/DaeryuntalkBackup/_enums/sender_type.d.ts +8 -0
  146. package/dist/components/DaeryuntalkBackup/_enums/sender_type.js +16 -0
  147. package/dist/components/DaeryuntalkBackup/_enums/sender_type.ts +16 -0
  148. package/dist/components/DaeryuntalkBackup/_enums/socket_type.d.ts +34 -0
  149. package/dist/components/DaeryuntalkBackup/_enums/socket_type.js +46 -0
  150. package/dist/components/DaeryuntalkBackup/_enums/socket_type.ts +56 -0
  151. package/dist/components/DaeryuntalkBackup/_enums/template.d.ts +32 -0
  152. package/dist/components/DaeryuntalkBackup/_enums/template.js +76 -0
  153. package/dist/components/DaeryuntalkBackup/_enums/template.ts +81 -0
  154. package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.d.ts +33 -0
  155. package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.js +66 -0
  156. package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.ts +71 -0
  157. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.d.ts +48 -0
  158. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.js +465 -0
  159. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.ts +595 -0
  160. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.d.ts +1 -0
  161. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.jsx +15 -0
  162. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.tsx +17 -0
  163. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
  164. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.js +112 -0
  165. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.ts +144 -0
  166. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.d.ts +44 -0
  167. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.js +534 -0
  168. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.ts +706 -0
  169. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.d.ts +8 -0
  170. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.js +18 -0
  171. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.ts +23 -0
  172. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.d.ts +9 -0
  173. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.js +109 -0
  174. package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.ts +121 -0
  175. package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.d.ts +12 -0
  176. package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.js +48 -0
  177. package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.ts +73 -0
  178. package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.d.ts +7 -0
  179. package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.js +42 -0
  180. package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.ts +52 -0
  181. package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.d.ts +6 -0
  182. package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.js +20 -0
  183. package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.ts +30 -0
  184. package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.d.ts +2 -0
  185. package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.js +26 -0
  186. package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.ts +43 -0
  187. package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.d.ts +27 -0
  188. package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.js +80 -0
  189. package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.ts +101 -0
  190. package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.d.ts +18 -0
  191. package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.js +66 -0
  192. package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.ts +75 -0
  193. package/dist/components/DaeryuntalkBackup/_lib/index.d.ts +7 -0
  194. package/dist/components/DaeryuntalkBackup/_lib/index.js +103 -0
  195. package/dist/components/DaeryuntalkBackup/_lib/index.ts +136 -0
  196. package/dist/components/DaeryuntalkBackup/_lib/utils.d.ts +17 -0
  197. package/dist/components/DaeryuntalkBackup/_lib/utils.js +94 -0
  198. package/dist/components/DaeryuntalkBackup/_lib/utils.ts +119 -0
  199. package/dist/components/DaeryuntalkBackup/_types/message.d.ts +92 -0
  200. package/dist/components/DaeryuntalkBackup/_types/message.js +25 -0
  201. package/dist/components/DaeryuntalkBackup/_types/message.ts +156 -0
  202. package/dist/components/DaeryuntalkBackup/_types/message_object.d.ts +17 -0
  203. package/dist/components/DaeryuntalkBackup/_types/message_object.js +1 -0
  204. package/dist/components/DaeryuntalkBackup/_types/message_object.ts +18 -0
  205. package/dist/components/DaeryuntalkBackup/_types/socket/workflow.d.ts +15 -0
  206. package/dist/components/DaeryuntalkBackup/_types/socket/workflow.js +1 -0
  207. package/dist/components/DaeryuntalkBackup/_types/socket/workflow.ts +15 -0
  208. package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.d.ts +6 -0
  209. package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.jsx +5 -0
  210. package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.tsx +15 -0
  211. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.d.ts +10 -0
  212. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.jsx +12 -0
  213. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.tsx +29 -0
  214. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.d.ts +10 -0
  215. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.jsx +12 -0
  216. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.tsx +29 -0
  217. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.d.ts +10 -0
  218. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.jsx +12 -0
  219. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.tsx +29 -0
  220. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.d.ts +10 -0
  221. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.jsx +12 -0
  222. package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.tsx +29 -0
  223. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.d.ts +8 -0
  224. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.jsx +15 -0
  225. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.tsx +38 -0
  226. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.d.ts +8 -0
  227. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.jsx +21 -0
  228. package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.tsx +50 -0
  229. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.d.ts +12 -0
  230. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.jsx +9 -0
  231. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.tsx +39 -0
  232. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.d.ts +13 -0
  233. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.jsx +10 -0
  234. package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.tsx +43 -0
  235. package/dist/components/DaeryuntalkBackup/index.d.ts +8 -0
  236. package/dist/components/DaeryuntalkBackup/index.jsx +190 -0
  237. package/dist/components/DaeryuntalkBackup/index.tsx +261 -0
  238. package/dist/components/common/integrate/index.d.ts +1 -1
  239. package/dist/styles/globals.css +415 -414
  240. package/dist/tsconfig.tsbuildinfo +1 -1
  241. package/package.json +5 -1
@@ -0,0 +1,1097 @@
1
+ /**
2
+ * Daeryuntalk API 클라이언트 모듈 2025-04-23
3
+ *
4
+ * 이 모듈은 Daeryuntalk 채팅 API와 상호작용하기 위한 함수를 제공
5
+ * 1. 고객 인증
6
+ * 2. 웹소켓 연결 초기화
7
+ * 3. 웹소켓 연결
8
+ * 4. 채팅 문의 관리
9
+ */
10
+ import {
11
+ IDaeryunTalkResponseWrapper,
12
+ IAuthConnectionDataResponse,
13
+ WebSocketInitDataResponse,
14
+ IChatInquiryMainDataResponse,
15
+ ChatInquiryCreateDataResponse,
16
+ ChatInquiryDetailDataResponse,
17
+ ChatMessage,
18
+ SendMessageResponse,
19
+ ChatInquiryMessageListDataResponse,
20
+ HistoryListResponse,
21
+ RequestConfirmNumberResponse
22
+ } from './type/response';
23
+ import { Dispatch, SetStateAction } from 'react';
24
+ import { ErrorEnum } from '../../_enums/error';
25
+ import { MessageSocketType } from '../../_enums/socket_type';
26
+ import { consoleFn } from '../../_lib/utils';
27
+ import { AgeCheckStatusEnums } from '../../_enums/ags_check_status';
28
+
29
+ // API 기본 URL
30
+ const API_BASE_URL = process.env.NEXT_PUBLIC_CHAT_CUSTOMER_API;
31
+ // 'https://chat-client-api.lawmance.com';
32
+
33
+ // API 기본 버전
34
+ export const DEFAULT_API_VERSION = '1.0.0';
35
+
36
+ // API 엔드포인트
37
+ const ENDPOINTS = {
38
+ /* 시작점 */
39
+ AUTHENTICATE: '/chatctm/ctf/crtfica', // 유저 인증
40
+ WEBSOCKET_INIT: '/chatctm/ctf/ws-init', // 웹 소켓 초기화
41
+ /* 채팅 */
42
+ CHAT_INQUIRY_MAIN: '/chatctm/hom/chatinquirymainsearch', // 채팅 문의 메인 조회
43
+ CHAT_INQUIRY_CREATE: '/chatctm/hom/chatinquirycreate', // XXX
44
+ CHAT_INQUIRY_DETAIL: '/chatctm/hom/chatinquirydetailsearch',
45
+ CHAT_INQUIRY_GENERATION: '/chatctm/chi/chatinquirygeneration', // 채팅 문의 생성
46
+ CHAT_INQUIRY_DETAIL_NEW: '/chatctm/chi/chatinquirydetail', // 채팅 문의 상세 조회
47
+ CHAT_INQUIRY_MESSAGE_LIST: '/chatctm/chi/chatinquirymessagelist', // 채팅 문의 메시지 목록 조회
48
+ CHAT_MESSAGE_SEND: '/chatctm/chi/chatinquirymessagesend', // 채팅 문의 메시지 전송
49
+ CHAT_MESSAGE_FILE_URL_REQUEST: '/chatctm/chi/chatinquirymessagefiledownloadurlgeneration', //채팅 문의 메시지 파일 다운로드 URL 생성 요청
50
+ CHAT_MESSAGE_WORKFLOW_START: '/chatctm/chi/chatinquiryworkflowprogress', // 채팅 문의 워크플로우 진행
51
+ CHAT_MESSAGE_WORKFLOW_BACK: '/chatctm/chi/chatinquiryworkflowrollback', // 채팅 문의 워크플로우 되돌리기
52
+ /* 유저 */
53
+ USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate', //개인 정보 업데이트
54
+ AGE_CHECK_UPDATE: '/chatctm/chi/ageconsentupdate', // 연령 동의 업데이트
55
+ /* 히스토리 */
56
+ HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
57
+ HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
58
+ HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch', // 히스토리 채팅 문의 목록 조회
59
+ ATTEND_CHAT_BY_HISTORY: '/chatctm/his/historychatinquiryparticipation', // 채팅문의 참여
60
+ /* 팔로업 알림 인증 */
61
+ FOLLOWUP_ATTENTD: '/chatctm/chi/chatinquiryalarmparticipation' // 채팅 문의 알림 참여
62
+ };
63
+
64
+ // 메인
65
+
66
+ // 채팅 메시지 유형 상수
67
+ export const MESSAGE_TYPES = {
68
+ SYSTEM: 'MSP00100001',
69
+ BOT: 'MSP00100002',
70
+ CUSTOMER: 'MSP00100003',
71
+ OPERATOR: 'MSP00100004',
72
+ MACRO: 'MSP00100005'
73
+ };
74
+
75
+ // 재시도
76
+ async function retryable<T>(fn: () => Promise<T>, maxAttempts = 3, delayMs = 350, label = ''): Promise<T> {
77
+ let attempt = 0;
78
+ while (attempt < maxAttempts) {
79
+ try {
80
+ return await fn();
81
+ } catch (error) {
82
+ attempt++;
83
+ console.warn(`[재시도] ${label} ${attempt}회 실패`, error);
84
+ if (attempt >= maxAttempts) throw new Error(`${label} 최대 재시도 초과`);
85
+ await new Promise(res => setTimeout(res, delayMs));
86
+ }
87
+ }
88
+ throw new Error(`${label} 실패`);
89
+ }
90
+
91
+ /**
92
+ * 쿠키 지원이 포함된 기본 fetch 함수
93
+ */
94
+
95
+ async function fetchWithCookies<T>(
96
+ url: string,
97
+ options: RequestInit = {},
98
+ version: string = DEFAULT_API_VERSION,
99
+ timeoutMs: number = 10000 // ⏰ 기본 타임아웃 10초
100
+ ): Promise<IDaeryunTalkResponseWrapper<T>> {
101
+ const headers = new Headers(options.headers || {});
102
+
103
+ if (!headers.has('Content-Type')) {
104
+ headers.set('Content-Type', 'application/json');
105
+ }
106
+
107
+ if (typeof window !== 'undefined') {
108
+ const AuthToken = localStorage.getItem('daeryunchatinquirytoken') || '';
109
+ if (AuthToken) {
110
+ headers.set('a', AuthToken);
111
+ }
112
+ }
113
+
114
+ headers.set('v', version);
115
+
116
+ const controller = new AbortController();
117
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
118
+
119
+ const mergedOptions: RequestInit = {
120
+ credentials: 'include',
121
+ ...options,
122
+ headers
123
+ };
124
+
125
+ const isAuthRequest = url.includes(ENDPOINTS.AUTHENTICATE);
126
+
127
+ try {
128
+ const response = await fetch(url, mergedOptions);
129
+
130
+ clearTimeout(timer); // ✅ 정상 응답이면 타이머 해제
131
+
132
+ const contentLength = response.headers.get('content-length');
133
+ const isEmpty = contentLength === '0';
134
+
135
+ let data: any = null;
136
+
137
+ try {
138
+ const text = await response.clone().text();
139
+ if (text && text.trim()) {
140
+ data = JSON.parse(text);
141
+ }
142
+ } catch (err) {
143
+ console.error(`[API 응답 파싱 실패] ${url}`, err);
144
+ }
145
+
146
+ if (!response.ok || (!isAuthRequest && data?.result_info?.result_type_cd !== 'OK')) {
147
+ // 실패 응답도 서버에서 온 데이터 그대로 반환
148
+ return {
149
+ result_info: data?.result_info ?? {
150
+ result_cd: String(response.status),
151
+ result_type_cd: 'ERROR',
152
+ result_msg: `${response.status} ${response.statusText}`
153
+ },
154
+ data: data?.data ?? (null as any)
155
+ };
156
+ }
157
+
158
+ // 성공 응답 처리 (서버 값 그대로)
159
+ return {
160
+ result_info: data?.result_info ?? {
161
+ result_cd: '200',
162
+ result_type_cd: 'OK',
163
+ result_msg: '성공'
164
+ },
165
+ data: data?.data ?? ({} as T)
166
+ };
167
+ } catch (error) {
168
+ console.error(`[API 호출 실패] ${url}`, error);
169
+ clearTimeout(timer); // 💡 에러 발생 시에도 타이머 정리
170
+
171
+ console.error(`[API 호출 실패] ${url}`, error);
172
+ return {
173
+ result_info: {
174
+ result_cd: 'FETCH_ERROR',
175
+ result_type_cd: 'ERROR',
176
+ result_msg:
177
+ error instanceof DOMException && error.name === 'AbortError'
178
+ ? '요청 시간이 초과되었습니다.'
179
+ : error instanceof Error
180
+ ? error.message
181
+ : '알 수 없는 오류'
182
+ },
183
+ data: null as any
184
+ };
185
+ }
186
+ }
187
+
188
+ /**
189
+ * 사용자 인증
190
+ * @param version API 버전 (기본값: 1.0.0)
191
+ * @returns 인증 응답
192
+ */
193
+
194
+ export async function authenticateUser(centerCode: string, version?: string, retry?: boolean): Promise<any> {
195
+ try {
196
+ const body = {
197
+ d: {
198
+ center_code: centerCode
199
+ }
200
+ };
201
+
202
+ // 인증 API 호출
203
+ const response = await fetchWithCookies<IAuthConnectionDataResponse>(
204
+ `${API_BASE_URL}${ENDPOINTS.AUTHENTICATE}`,
205
+ {
206
+ method: 'POST',
207
+ body: JSON.stringify(body)
208
+ },
209
+ version
210
+ );
211
+
212
+ // 빈 응답인 경우에도 성공으로 처리 -> 이거 지워야함
213
+ // if (Object.keys(response).length === 0) {
214
+ // consoleFn('[인증 성공] 사용자 인증 완료 - 빈 응답 (쿠키만 설정됨)');
215
+ // return { success: true, status: 'authenticated' };
216
+ // }
217
+
218
+ if (typeof window !== 'undefined' && response?.data?.token) {
219
+ localStorage.setItem('daeryunchatinquirytoken', response.data.token);
220
+ }
221
+
222
+ consoleFn('[인증 성공] 사용자 인증 완료', response);
223
+ return response;
224
+ } catch (error) {
225
+ console.error('[인증 실패] 사용자 인증 오류:', error);
226
+ throw error;
227
+ }
228
+ }
229
+
230
+ /**
231
+ * 웹소켓 연결 초기화
232
+ * @param version API 버전 (기본값: 1.0.0)
233
+ * @returns 연결 URL과 토큰이 포함된 웹소켓 초기화 데이터
234
+ */
235
+ export async function initializeWebSocket(
236
+ version?: string
237
+ ): Promise<IDaeryunTalkResponseWrapper<WebSocketInitDataResponse>> {
238
+ consoleFn(
239
+ '[웹소켓 초기화 시작] 웹소켓 연결 초기화 요청',
240
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
241
+ );
242
+ try {
243
+ const response = await fetchWithCookies<WebSocketInitDataResponse>(
244
+ `${API_BASE_URL}${ENDPOINTS.WEBSOCKET_INIT}`,
245
+ { method: 'POST' },
246
+ version
247
+ );
248
+ return response;
249
+ } catch (error) {
250
+ console.error('[웹소켓 초기화 실패] 웹소켓 연결 초기화 오류:', error);
251
+ throw error;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * 웹소켓 연결
257
+ * @param wsUrl 웹소켓 URL
258
+ * @param token 연결 토큰
259
+ * @param onMessage 메시지 핸들러
260
+ * @param onOpen 연결 열림 핸들러
261
+ * @param onClose 연결 닫힘 핸들러
262
+ * @param onError 오류 핸들러
263
+ * @returns 웹소켓 인스턴스
264
+ */
265
+
266
+
267
+ export function connectWebSocket(
268
+ wsUrl: string,
269
+ token: string,
270
+ isOpen: boolean,
271
+ setIsConnected: Dispatch<SetStateAction<boolean | null>>,
272
+ userExpiredRef: React.MutableRefObject<boolean>,
273
+ onMessage?: (event: MessageEvent) => void,
274
+ onOpen?: (event: Event) => void,
275
+ onClose?: (event: CloseEvent) => void,
276
+ onError?: (event: Event) => void,
277
+ ): WebSocket {
278
+ // URL에 토큰을 파라미터로 추가
279
+ const connectionUrl = `${wsUrl}?token=${token}`;
280
+ consoleFn('[웹소켓 연결 시작] 연결 URL:', connectionUrl);
281
+
282
+ try {
283
+ const socket = new WebSocket(connectionUrl);
284
+
285
+ const setupSocketHandlers = (socket: WebSocket) => {
286
+ socket.onopen = event => {
287
+ consoleFn('[웹소켓 연결 성공]');
288
+ if (onOpen) onOpen(event);
289
+ };
290
+
291
+ socket.onmessage = event => {
292
+ consoleFn('[웹소켓 메시지 수신]', event.data);
293
+
294
+ try {
295
+ const data = JSON.parse(event.data);
296
+ if (data?.type === 'user.expired' || event?.data?.type === MessageSocketType.USER_EXPIRED) {
297
+ userExpiredRef && (userExpiredRef.current = true);
298
+ }
299
+ consoleFn('📩 New Message (parsed):', data);
300
+ } catch (err) {
301
+ console.error('[웹소켓] JSON 파싱 오류:', err);
302
+ }
303
+
304
+ if (onMessage) onMessage(event.data);
305
+ };
306
+
307
+ socket.onclose = async event => {
308
+ console.warn('[웹소켓 종료]', event);
309
+
310
+ consoleFn('userExpiredRef.current', userExpiredRef.current);
311
+
312
+ if (userExpiredRef.current) {
313
+ consoleFn('[웹소켓 종료] 만기 유저는 소켓 연결 재시도 하지 않음');
314
+ return;
315
+ }
316
+
317
+ // 재연결 로직 추가
318
+ if (onClose) onClose(event);
319
+ };
320
+
321
+ socket.onerror = event => {
322
+ console.error('[웹소켓 오류]', event);
323
+ if (onError) onError(event);
324
+ };
325
+ };
326
+
327
+ setupSocketHandlers(socket);
328
+
329
+ return socket;
330
+ } catch (error) {
331
+ console.error('[웹소켓 연결 실패]', error);
332
+ throw error;
333
+ }
334
+ }
335
+
336
+ /**
337
+ * 채팅 문의 메인 조회
338
+ * @param channelNumber 전달받은 채널
339
+ * @param version API 버전 (기본값: 1.0.0)
340
+ * @returns 채팅 문의 메인 데이터
341
+ */
342
+ export async function getChatInquiryMain(
343
+ channelNumber: string,
344
+ version?: string
345
+ ): Promise<IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>> {
346
+ const body = {
347
+ d: {
348
+ channel_number: channelNumber
349
+ }
350
+ };
351
+ consoleFn('body', body);
352
+
353
+ consoleFn(
354
+ '[채팅 문의 메인 조회 시작] 채널 번호:',
355
+ body.d.channel_number,
356
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
357
+ );
358
+ try {
359
+ const response = await fetchWithCookies<IChatInquiryMainDataResponse>(
360
+ `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_MAIN}`,
361
+ {
362
+ method: 'POST',
363
+ body: JSON.stringify(body)
364
+ },
365
+ version
366
+ );
367
+ consoleFn('[채팅 문의 메인 조회 성공]', response);
368
+ return response;
369
+ } catch (error) {
370
+ console.error('[채팅 문의 메인 조회 실패]', error);
371
+ throw error;
372
+ }
373
+ }
374
+
375
+ /**
376
+ * 새 채팅 문의 생성 (개선된 API)
377
+ * @param channelNumber
378
+ * @param currentUrl
379
+ * @param version
380
+ */
381
+ export async function generateChatInquiry(
382
+ channelNumber: string,
383
+ currentUrl: string,
384
+ centerCode?: string,
385
+ version?: string
386
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>> {
387
+ consoleFn('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
388
+ let channelId = channelNumber;
389
+ if (!channelNumber) {
390
+ const authRes = await authenticateUser((centerCode || 'CT0000') ?? 'CT0000', version);
391
+ channelId = authRes.data.channel_number;
392
+ }
393
+
394
+ const body = {
395
+ d: {
396
+ channel_number: channelId,
397
+ current_url: currentUrl
398
+ }
399
+ };
400
+
401
+ try {
402
+ const response = await fetchWithCookies<ChatInquiryCreateDataResponse>(
403
+ `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_GENERATION}`,
404
+ {
405
+ method: 'POST',
406
+ body: JSON.stringify(body)
407
+ },
408
+ version
409
+ );
410
+ consoleFn('[새 채팅 문의 생성 성공 (개선)] 문의 번호:', response.data.chat_inquiry_number);
411
+ return response;
412
+ } catch (error) {
413
+ console.error('[새 채팅 문의 생성 실패 (개선)]', error);
414
+ throw error;
415
+ }
416
+ }
417
+
418
+ /**
419
+ * 채팅 문의 상세 조회 (개선된 API)
420
+ * @param chatInquiryNumber 채팅 문의 번호
421
+ * @param version API 버전 (기본값: 1.0.0)
422
+ * @returns 채팅 문의 상세 정보
423
+ */
424
+ export async function getChatInquiryDetailNew(
425
+ chat_inquiry_number: string,
426
+ version?: string
427
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryDetailDataResponse>> {
428
+ const body = {
429
+ d: {
430
+ chat_inquiry_number: chat_inquiry_number // 채팅문의 번호
431
+ }
432
+ };
433
+
434
+ consoleFn(
435
+ '[채팅 문의 상세 조회 시작 (개선)] 문의 번호:',
436
+ chat_inquiry_number,
437
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
438
+ );
439
+ try {
440
+ const response = await fetchWithCookies<ChatInquiryDetailDataResponse>(
441
+ `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_DETAIL_NEW}`,
442
+ {
443
+ method: 'POST',
444
+ body: JSON.stringify(body)
445
+ },
446
+ version
447
+ );
448
+ consoleFn('[채팅 문의 상세 조회 성공 (개선)]', response);
449
+ return response;
450
+ } catch (error) {
451
+ console.error('[채팅 문의 상세 조회 실패 (개선)]', error);
452
+ throw error;
453
+ }
454
+ }
455
+
456
+ /**
457
+ * 채팅 메세지 목록 조회
458
+ * @param chatInquiryNumber 채팅 문의 번호
459
+ * @param standard_date_time 기준 일시
460
+ * @param size 사이즈
461
+ * @param version API 버전 (기본값: 1.0.0)
462
+ * @returns 채팅 메세지 리스트
463
+ */
464
+ export async function getChatInquiryMessageList(
465
+ chatInquiryNumber: string,
466
+ standardTimestamp?: number,
467
+ size?: number,
468
+ version?: string
469
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>> {
470
+ const body = {
471
+ d: {
472
+ chat_inquiry_number: chatInquiryNumber,
473
+ ...(standardTimestamp && { standard_timestamp: standardTimestamp }),
474
+ size: size ?? 400
475
+ }
476
+ };
477
+
478
+ consoleFn(
479
+ '[채팅 메세지 리스트] 문의 번호:',
480
+ chatInquiryNumber,
481
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
482
+ );
483
+ try {
484
+ const response = await fetchWithCookies<ChatInquiryMessageListDataResponse>(
485
+ `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_MESSAGE_LIST}`,
486
+ {
487
+ method: 'POST',
488
+ body: JSON.stringify(body)
489
+ },
490
+ version
491
+ );
492
+ consoleFn('[채팅 메세지 리스트]', response);
493
+ return response;
494
+ } catch (error) {
495
+ console.error('[채팅 메세지 리스트]', error);
496
+ throw error;
497
+ }
498
+ }
499
+
500
+ /**
501
+ * Daeryuntalk 초기화 완료 흐름
502
+ * 이 함수는 인증부터 웹소켓 연결까지 완전한 흐름을 처리
503
+ * @param onWebSocketConnected 웹소켓 연결 시 콜백
504
+ * @param onWebSocketMessage 메시지 핸들러
505
+ * @param onWebSocketClose 웹소켓 종료 시 콜백
506
+ * @param onWebSocketError 웹소켓 오류 시 콜백
507
+ * @param version API 버전 (기본값: 1.0.0)
508
+ * @returns 웹소켓 인스턴스 및 문의 데이터
509
+ */
510
+ export async function initializeDaeryuntalk(
511
+ hashValue: string,
512
+ isOpen: boolean,
513
+ setIsConnected: Dispatch<SetStateAction<boolean | null>>,
514
+ isMobile: boolean,
515
+ centerCode: string,
516
+ userExpiredRef: React.MutableRefObject<boolean>,
517
+ onWebSocketConnected?: (socket: WebSocket) => void,
518
+ onWebSocketMessage?: (event: MessageEvent) => void,
519
+ onWebSocketClose?: (event: CloseEvent) => void,
520
+ onWebSocketError?: (event: Event) => void,
521
+ version?: string
522
+ ): Promise<{
523
+ inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null;
524
+ socket: WebSocket | null;
525
+ hashAuth: any;
526
+ errorCode: IDaeryunTalkResponseWrapper<any> | null;
527
+ }> {
528
+ // if (typeof window !== 'undefined' && hashValue) {
529
+ // localStorage.removeItem('daeryunchatinquirytoken');
530
+ // }
531
+ consoleFn(
532
+ '[Daeryuntalk 초기화 시작] 전체 흐름 실행',
533
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
534
+ );
535
+ try {
536
+ consoleFn('[Daeryuntalk 초기화] 전체 흐름 시작');
537
+ let errorData: IDaeryunTalkResponseWrapper<any> | null = null;
538
+
539
+ // 1단계: 사용자 인증
540
+ let authResponse = await retryable(() => authenticateUser(centerCode, version), 1, 350, '사용자 인증');
541
+
542
+ consoleFn('authResponse11', authResponse);
543
+ // 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
544
+ // 만약 만료된 토큰이라면?
545
+ // consoleFn('authResponse', authResponse);
546
+ // consoleFn('ErrorEnum.CE_TOKEN_EXPIRED', ErrorEnum.CE_TOKEN_EXPIRED);
547
+ // consoleFn('authResponse?.result_info?.result_cd', authResponse?.result_info?.result_cd);
548
+ if (authResponse?.result_info?.result_cd === 'OK' || authResponse?.result_info?.result_type_cd === 'OK') {
549
+ } else {
550
+ if (
551
+ authResponse?.result_info?.result_cd === ErrorEnum.CE_TOKEN_EXPIRED ||
552
+ authResponse?.result_info?.result_type_cd === ErrorEnum.CE_TOKEN_EXPIRED
553
+ ) {
554
+ // 재인증 시작
555
+ errorData = authResponse;
556
+ consoleFn('재인증 시작');
557
+ localStorage.removeItem('daeryunchatinquirytoken');
558
+ authResponse = await retryable(
559
+ () => authenticateUser(centerCode, version, true),
560
+ 3,
561
+ 350,
562
+ '사용자 인증'
563
+ );
564
+ } else {
565
+ errorData = authResponse;
566
+ return {
567
+ inquiryData: null,
568
+ socket: null,
569
+ hashAuth: '',
570
+ errorCode: errorData
571
+ };
572
+ }
573
+ }
574
+
575
+ // 2단계: 웹소켓 초기화
576
+ const wsInitData = await retryable(() => initializeWebSocket(version), 3, 350, '웹소켓 초기화');
577
+
578
+ if (!(authResponse?.result_info?.result_cd === 'OK' || authResponse?.result_info?.result_type_cd === 'OK')) {
579
+ errorData = wsInitData;
580
+ return {
581
+ inquiryData: null,
582
+ socket: null,
583
+ hashAuth: '',
584
+ errorCode: errorData
585
+ };
586
+ }
587
+
588
+ // 3단계: 웹소켓 연결
589
+ const socket = await retryable(
590
+ () =>
591
+ new Promise<WebSocket>((resolve, reject) => {
592
+ try {
593
+ const ws = connectWebSocket(
594
+ wsInitData.data.connection_url,
595
+ wsInitData.data.connection_token,
596
+ isOpen,
597
+ setIsConnected,
598
+ userExpiredRef,
599
+ onWebSocketMessage,
600
+ () => {
601
+ consoleFn('[웹소켓 연결 성공]');
602
+ onWebSocketConnected?.(ws);
603
+ resolve(ws);
604
+ },
605
+ (event: CloseEvent) => {
606
+ // onClose
607
+ onWebSocketClose?.(event);
608
+ },
609
+ (event: Event) => {
610
+ // onError
611
+ console.error('[웹소켓 연결 실패]', event);
612
+ onWebSocketError?.(event);
613
+ reject(new Error('웹소켓 연결 실패'));
614
+ }
615
+ );
616
+ } catch (err) {
617
+ reject(err);
618
+ }
619
+ }),
620
+ 3,
621
+ 2000,
622
+ '웹소켓 연결'
623
+ );
624
+
625
+ // 4단계: 해시 인증
626
+ let hashAuth = null;
627
+ if (hashValue) {
628
+ hashAuth = await retryable(() => followupAttend({ token: hashValue }), 2, 1000, '해시 인증');
629
+ }
630
+
631
+ // 5단계: 문의 조회
632
+ const chatInquiryData = await retryable(
633
+ () => getChatInquiryMain(authResponse.data.channel_number, version),
634
+ 2,
635
+ 350,
636
+ '채팅 문의 메인 조회'
637
+ );
638
+
639
+ consoleFn('[Daeryuntalk 초기화 완료]');
640
+ return {
641
+ inquiryData: chatInquiryData,
642
+ socket,
643
+ hashAuth,
644
+ errorCode: errorData
645
+ };
646
+ } catch (error) {
647
+ console.error('[Daeryuntalk 초기화 실패] 오류 발생:', error);
648
+ throw error;
649
+ }
650
+ }
651
+
652
+ /**
653
+ * 채팅 워크플로우 진행 처리
654
+ *
655
+ * @param chatInquiryNumber 채팅 문의 번호 required
656
+ * @param messageNumber 메시지 번호 required
657
+ * @param workFlowNumber 워크플로우 번호 required
658
+ * @param objectNumber 오브젝트 번호 required
659
+ * @param version API 버전 (기본값: 1.0.0)
660
+ * @returns 전송된 메시지 데이터
661
+ */
662
+ export async function chatWorkFlow(
663
+ chatInquiryNumber: string,
664
+ messageNumber: string,
665
+ workFlowNumber: string,
666
+ objectNumber: string,
667
+ version?: string
668
+ ): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>> {
669
+ const body = {
670
+ d: {
671
+ chat_inquiry_number: chatInquiryNumber,
672
+ message_number: messageNumber,
673
+ work_flow_number: workFlowNumber,
674
+ object_number: objectNumber
675
+ }
676
+ };
677
+
678
+ consoleFn(
679
+ '[채팅 워크플로우 시작]',
680
+ '문의 번호:',
681
+ chatInquiryNumber,
682
+ '메시지 번호:',
683
+ messageNumber,
684
+ '워크플로우 번호:',
685
+ workFlowNumber,
686
+ '오브젝트 번호:',
687
+ objectNumber,
688
+ version ? `버전: ${version}` : '기본 버전: 1.0.0'
689
+ );
690
+ try {
691
+ const response = await fetchWithCookies<any>(
692
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_WORKFLOW_START}`,
693
+ {
694
+ method: 'POST',
695
+ body: JSON.stringify(body)
696
+ },
697
+ version
698
+ );
699
+ consoleFn('[채팅 워크플로우 시작 성공]', response);
700
+ return response;
701
+ } catch (error) {
702
+ console.error('[채팅 워크플로우 시작 실패]', error);
703
+ throw error;
704
+ }
705
+ }
706
+
707
+ /**
708
+ * 채팅 워크플로우 되돌리기
709
+ *
710
+ * @param chatInquiryNumber 채팅 문의 번호 required
711
+ * @param messageNumber 메시지 번호 required
712
+ * @param workFlowNavigationCode 워크플로우네비게이션코드 번호 required
713
+ * @param version API 버전 (기본값: 1.0.0)
714
+ * @returns 전송된 메시지 데이터
715
+ */
716
+ export async function chatWorkFlowBack(
717
+ chatInquiryNumber: string,
718
+ messageNumber: string,
719
+ workFlowNavigationCode: string,
720
+ version?: string
721
+ ): Promise<IDaeryunTalkResponseWrapper<null>> {
722
+ const body = {
723
+ d: {
724
+ chat_inquiry_number: chatInquiryNumber,
725
+ message_number: messageNumber,
726
+ work_flow_navigation_code: workFlowNavigationCode
727
+ }
728
+ };
729
+
730
+ consoleFn(
731
+ '[채팅 워크플로우 되돌리기 시작]',
732
+ '문의 번호:',
733
+ chatInquiryNumber,
734
+ '메시지 번호:',
735
+ messageNumber,
736
+ '워크플로우네비게이션코드 번호:',
737
+ workFlowNavigationCode,
738
+ version ? `버전: ${version}` : '기본 버전: 1.0.0'
739
+ );
740
+ try {
741
+ const response = await fetchWithCookies<any>(
742
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_WORKFLOW_BACK}`,
743
+ {
744
+ method: 'POST',
745
+ body: JSON.stringify(body)
746
+ },
747
+ version
748
+ );
749
+ consoleFn('[채팅 워크플로우 되돌리기 성공]', response);
750
+ return response;
751
+ } catch (error) {
752
+ console.error('[채팅 워크플로우 되돌리기 실패]', error);
753
+ throw error;
754
+ }
755
+ }
756
+
757
+ /**
758
+ * 채팅 메시지 전송
759
+ * @param chatInquiryNumber 채팅 문의 번호
760
+ * @param messageText 메시지 내용
761
+ * @param version API 버전 (기본값: 1.0.0)
762
+ * @returns 전송된 메시지 데이터
763
+ */
764
+ export async function sendChatMessage(
765
+ chatInquiryNumber: string,
766
+ htmlContent: string,
767
+ jsonData: any,
768
+ version?: string
769
+ ): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>> {
770
+ if (!chatInquiryNumber) {
771
+ throw new Error('채팅 메시지 전송 실패: 문의 번호가 없음');
772
+ }
773
+
774
+ if (!htmlContent) {
775
+ throw new Error('채팅 메시지 전송 실패: 메시지가 없음');
776
+ }
777
+ if (!jsonData) {
778
+ throw new Error('채팅 메시지 전송 실패: json 데이터 없음');
779
+ }
780
+
781
+ const body = {
782
+ d: {
783
+ chat_inquiry_number: chatInquiryNumber, // required
784
+ html_content: htmlContent, // required, tiptap html
785
+ json_data: jsonData // required, tiptab json
786
+ }
787
+ };
788
+
789
+ consoleFn(
790
+ '[채팅 메시지 전송 시작] 문의 번호:',
791
+ chatInquiryNumber,
792
+ '메시지:',
793
+ htmlContent,
794
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
795
+ );
796
+ try {
797
+ const response = await fetchWithCookies<SendMessageResponse>(
798
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_SEND}`,
799
+ {
800
+ method: 'POST',
801
+ body: JSON.stringify(body)
802
+ },
803
+ version
804
+ );
805
+ consoleFn('[채팅 메시지 전송 성공]', response);
806
+ return response;
807
+ } catch (error) {
808
+ console.error('[채팅 메시지 전송 실패]', error);
809
+ throw error;
810
+ }
811
+ }
812
+
813
+ /**
814
+ * 채팅 개인 정보 업데이트
815
+ * @param chatInquiryNumber 채팅 문의 번호
816
+ * @param messageNumber 해당 채팅 번호
817
+ * @param name 이름
818
+ * @param cellPhoneNumber 전화번호
819
+ * @param version API 버전 (기본값: 1.0.0)
820
+ * @returns 전송된 메시지 데이터
821
+ */
822
+ export async function chatUserUpdate(
823
+ chatInquiryNumber: string,
824
+ messageNumber: string,
825
+ name: string,
826
+ cellPhoneNumber: string,
827
+ version?: string
828
+ ): Promise<IDaeryunTalkResponseWrapper<any>> {
829
+ const body = {
830
+ d: {
831
+ chat_inquiry_number: chatInquiryNumber, // required
832
+ message_number: messageNumber, // required
833
+ name: name, // required
834
+ cell_phone_number: cellPhoneNumber // required
835
+ }
836
+ };
837
+
838
+ consoleFn('[채팅 개인 정보 업데이트] 시작');
839
+ try {
840
+ const response = await fetchWithCookies<any>(
841
+ `${API_BASE_URL}${ENDPOINTS.USER_INFO_UPDATE}`,
842
+ {
843
+ method: 'POST',
844
+ body: JSON.stringify(body)
845
+ },
846
+ version
847
+ );
848
+ consoleFn('[채팅 메시지 전송 성공]', response);
849
+ return response;
850
+ } catch (error) {
851
+ console.error('[채팅 메시지 전송 실패]', error);
852
+ throw error;
853
+ }
854
+ }
855
+
856
+ export async function ageCheckUpdate(
857
+ chatInquiryNumber: string,
858
+ ageConsentStateCode: AgeCheckStatusEnums,
859
+ version?: string
860
+ ): Promise<IDaeryunTalkResponseWrapper<any>> {
861
+ const body = {
862
+ d: {
863
+ chat_inquiry_number: chatInquiryNumber,
864
+ age_consent_state_code: ageConsentStateCode // AGE00100001(미동의), AGE00100002(동의)
865
+ }
866
+ };
867
+
868
+ consoleFn('[채팅 연령 동의 업데이트] 시작');
869
+ try {
870
+ const response = await fetchWithCookies<{ result: string }>(
871
+ `${API_BASE_URL}${ENDPOINTS.AGE_CHECK_UPDATE}`,
872
+ {
873
+ method: 'POST',
874
+ body: JSON.stringify(body)
875
+ },
876
+ version
877
+ );
878
+ consoleFn('[채팅 연령 동의 업데이트 성공]', response);
879
+ return response;
880
+ } catch (error) {
881
+ console.error('[채팅 연령 동의 업데이트 실패]', error);
882
+ throw error;
883
+ }
884
+ }
885
+
886
+ /**
887
+ * 채팅문의 메시지 파일 다운로드 URL 생성
888
+ * @param chatInquiryNumber 채팅문의번호
889
+ * @param fileNumber 파일번호
890
+ * @param version
891
+ */
892
+ export const getMessageFileDownloadUrl = async ({
893
+ chatInquiryNumber,
894
+ fileNumber,
895
+ version = DEFAULT_API_VERSION
896
+ }: {
897
+ chatInquiryNumber: string; // required
898
+ fileNumber: string;
899
+ version?: string;
900
+ }) => {
901
+ const consoleName = '채팅문의 메시지 파일 다운로드 URL 생성';
902
+ try {
903
+ const body = {
904
+ d: {
905
+ chat_inquiry_number: chatInquiryNumber, // required
906
+ file_number: fileNumber // required
907
+ }
908
+ };
909
+ consoleFn(`[${consoleName} 진행]`);
910
+ const response = await fetchWithCookies<{ url: string }>(
911
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_FILE_URL_REQUEST}`,
912
+ {
913
+ method: 'POST',
914
+ body: JSON.stringify(body)
915
+ },
916
+ version
917
+ );
918
+
919
+ consoleFn(`[${consoleName} 완료]`, response);
920
+ return response;
921
+ } catch (error) {
922
+ console.error(`[${consoleName} 실패] 오류:`, error);
923
+ throw error;
924
+ }
925
+ };
926
+
927
+ // /* 히스토리 */
928
+ // HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
929
+ // HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
930
+ // HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch' // 히스토리 채팅 문의 목록 조회
931
+
932
+ /**
933
+ * 점유 인증 번호 요청
934
+ * @param name
935
+ * @param cellPhoneNumber
936
+ * @param version
937
+ */
938
+ export const requestPhone = async ({
939
+ name,
940
+ cellPhoneNumber,
941
+ version = DEFAULT_API_VERSION
942
+ }: {
943
+ name: string; // required
944
+ cellPhoneNumber: string;
945
+ version?: string;
946
+ }) => {
947
+ const consoleName = '점유 인증 번호 요청';
948
+ try {
949
+ const body = {
950
+ d: {
951
+ name: name, // required
952
+ cell_phone_number: cellPhoneNumber // required
953
+ }
954
+ };
955
+ consoleFn(`[${consoleName} 진행]`);
956
+ const response = await fetchWithCookies<RequestConfirmNumberResponse>(
957
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_REQUEST}`,
958
+ {
959
+ method: 'POST',
960
+ body: JSON.stringify(body)
961
+ },
962
+ version
963
+ );
964
+
965
+ consoleFn(`[${consoleName} 완료]`, response);
966
+ return response;
967
+ } catch (error) {
968
+ console.error(`[${consoleName} 실패] 오류:`, error);
969
+ throw error;
970
+ }
971
+ };
972
+
973
+ /**
974
+ * 점유 인증 번호 검증
975
+ * @param name
976
+ * @param cellPhoneNumber
977
+ * @param certificationNumber
978
+ * @param version
979
+ */
980
+ export const historyPhoneAuth = async ({
981
+ name,
982
+ cellPhoneNumber,
983
+ certificationNumber,
984
+ version = DEFAULT_API_VERSION
985
+ }: {
986
+ name: string; // required
987
+ cellPhoneNumber: string;
988
+ certificationNumber: string;
989
+ version?: string;
990
+ }) => {
991
+ const consoleName = '점유 인증 번호 검증';
992
+ try {
993
+ const body = {
994
+ d: {
995
+ name: name, // required
996
+ cell_phone_number: cellPhoneNumber, // required
997
+ certification_number: certificationNumber // required
998
+ }
999
+ };
1000
+ consoleFn(`[${consoleName} 진행]`);
1001
+ const response = await fetchWithCookies<unknown>(
1002
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_AUTHENTICATION}`,
1003
+ {
1004
+ method: 'POST',
1005
+ body: JSON.stringify(body)
1006
+ },
1007
+ version
1008
+ );
1009
+
1010
+ consoleFn(`[${consoleName} 완료]`, response);
1011
+ return response;
1012
+ } catch (error) {
1013
+ console.error(`[${consoleName} 실패] 오류:`, error);
1014
+ throw error;
1015
+ }
1016
+ };
1017
+
1018
+ export const getHistoryList = async ({ version = DEFAULT_API_VERSION }: { version?: string }) => {
1019
+ const consoleName = '히스토리 채팅 문의 목록 조회';
1020
+ try {
1021
+ consoleFn(`[${consoleName} 진행]`);
1022
+ const response = await fetchWithCookies<HistoryListResponse>(
1023
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_LIST}`,
1024
+ {
1025
+ method: 'POST'
1026
+ // body: JSON.stringify(body)
1027
+ },
1028
+ version
1029
+ );
1030
+
1031
+ consoleFn(`[${consoleName} 완료]`, response);
1032
+ return response;
1033
+ } catch (error) {
1034
+ console.error(`[${consoleName} 실패] 오류:`, error);
1035
+ throw error;
1036
+ }
1037
+ };
1038
+
1039
+ export const attendChatRoomByHistory = async ({
1040
+ chatInquiryNumber,
1041
+ version = DEFAULT_API_VERSION
1042
+ }: {
1043
+ chatInquiryNumber: string;
1044
+ version?: string;
1045
+ }) => {
1046
+ const consoleName = '히스토리 채팅 문의 참여';
1047
+ try {
1048
+ consoleFn(`[${consoleName} 진행]`);
1049
+
1050
+ const body = {
1051
+ d: {
1052
+ chat_inquiry_number: chatInquiryNumber // required
1053
+ }
1054
+ };
1055
+ const response = await fetchWithCookies<HistoryListResponse>(
1056
+ `${API_BASE_URL}${ENDPOINTS.ATTEND_CHAT_BY_HISTORY}`,
1057
+ {
1058
+ method: 'POST',
1059
+ body: JSON.stringify(body)
1060
+ },
1061
+ version
1062
+ );
1063
+
1064
+ consoleFn(`[${consoleName} 완료]`, response);
1065
+ return response;
1066
+ } catch (error) {
1067
+ console.error(`[${consoleName} 실패] 오류:`, error);
1068
+ throw error;
1069
+ }
1070
+ };
1071
+
1072
+ export const followupAttend = async ({ token, version = DEFAULT_API_VERSION }: { token: string; version?: string }) => {
1073
+ const consoleName = '히스토리 채팅 문의 참여';
1074
+ try {
1075
+ consoleFn(`[${consoleName} 진행]`);
1076
+
1077
+ const body = {
1078
+ d: {
1079
+ token: token // required
1080
+ }
1081
+ };
1082
+ const response = await fetchWithCookies<HistoryListResponse>(
1083
+ `${API_BASE_URL}${ENDPOINTS.FOLLOWUP_ATTENTD}`,
1084
+ {
1085
+ method: 'POST',
1086
+ body: JSON.stringify(body)
1087
+ },
1088
+ version
1089
+ );
1090
+
1091
+ consoleFn(`[${consoleName} 완료]`, response);
1092
+ return response;
1093
+ } catch (error) {
1094
+ console.error(`[${consoleName} 실패] 오류:`, error);
1095
+ throw error;
1096
+ }
1097
+ };