@daeryun/dr_components 0.7.79 → 0.7.81

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 (134) hide show
  1. package/dist/asset/images/daeryuntalk/download.svg +5 -0
  2. package/dist/asset/images/daeryuntalk/firstGo.svg +5 -0
  3. package/dist/asset/images/daeryuntalk/objectBack.svg +4 -0
  4. package/dist/asset/images/daeryuntalk/viewer/close.svg +4 -0
  5. package/dist/asset/images/daeryuntalk/viewer/gray-download.svg +7 -0
  6. package/dist/asset/images/daeryuntalk/viewer/move-button.svg +4 -0
  7. package/dist/asset/images/daeryuntalk/viewer/rotate.svg +17 -0
  8. package/dist/asset/images/daeryuntalk/viewer/zoom-in.svg +5 -0
  9. package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +6 -0
  10. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  11. package/dist/components/Daeryuntalk/ChatButton.jsx +1 -0
  12. package/dist/components/Daeryuntalk/ChatButton.tsx +1 -0
  13. package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
  14. package/dist/components/Daeryuntalk/ChatConversation.jsx +19 -12
  15. package/dist/components/Daeryuntalk/ChatConversation.tsx +48 -11
  16. package/dist/components/Daeryuntalk/ChatHomeView.jsx +27 -6
  17. package/dist/components/Daeryuntalk/ChatHomeView.tsx +39 -8
  18. package/dist/components/Daeryuntalk/ChatInput.jsx +23 -3
  19. package/dist/components/Daeryuntalk/ChatInput.tsx +26 -10
  20. package/dist/components/Daeryuntalk/ChatItem/ChatFile.d.ts +10 -0
  21. package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +186 -0
  22. package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +252 -0
  23. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.d.ts +8 -0
  24. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.jsx +87 -0
  25. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.tsx +115 -0
  26. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.d.ts +8 -0
  27. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +13 -0
  28. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +25 -0
  29. package/dist/components/Daeryuntalk/ChatItem/RichText.d.ts +7 -0
  30. package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +25 -0
  31. package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +32 -0
  32. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.d.ts +8 -0
  33. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.jsx +19 -0
  34. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.tsx +31 -0
  35. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.d.ts +7 -0
  36. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +20 -0
  37. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +36 -0
  38. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +7 -0
  39. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +9 -0
  40. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +16 -0
  41. package/dist/components/Daeryuntalk/ChatMessage.d.ts +11 -1
  42. package/dist/components/Daeryuntalk/ChatMessage.jsx +116 -14
  43. package/dist/components/Daeryuntalk/ChatMessage.tsx +175 -20
  44. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.d.ts +7 -0
  45. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +16 -0
  46. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +28 -0
  47. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.d.ts +10 -0
  48. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +118 -0
  49. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +162 -0
  50. package/dist/components/Daeryuntalk/ChatWidget.jsx +7 -3
  51. package/dist/components/Daeryuntalk/ChatWidget.tsx +9 -5
  52. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +37 -5
  53. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +71 -157
  54. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +128 -189
  55. package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +17 -0
  56. package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +57 -0
  57. package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +82 -0
  58. package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +3 -0
  59. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +172 -0
  60. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +236 -0
  61. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +133 -0
  62. package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.js +251 -46
  63. package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.ts +353 -129
  64. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +115 -0
  65. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.js +1 -0
  66. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +135 -0
  67. package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +6 -0
  68. package/dist/components/Daeryuntalk/_enums/ask-status.js +11 -0
  69. package/dist/components/Daeryuntalk/_enums/ask-status.ts +11 -0
  70. package/dist/components/Daeryuntalk/_enums/message_type.d.ts +6 -0
  71. package/dist/components/Daeryuntalk/_enums/message_type.js +13 -0
  72. package/dist/components/Daeryuntalk/_enums/message_type.ts +13 -0
  73. package/dist/components/Daeryuntalk/_enums/sender_type.d.ts +8 -0
  74. package/dist/components/Daeryuntalk/_enums/sender_type.js +16 -0
  75. package/dist/components/Daeryuntalk/_enums/sender_type.ts +16 -0
  76. package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +22 -0
  77. package/dist/components/Daeryuntalk/_enums/socket_type.js +23 -0
  78. package/dist/components/Daeryuntalk/_enums/socket_type.ts +31 -0
  79. package/dist/components/Daeryuntalk/_enums/template.d.ts +32 -0
  80. package/dist/components/Daeryuntalk/_enums/template.js +49 -0
  81. package/dist/components/Daeryuntalk/_enums/template.ts +53 -0
  82. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.d.ts +34 -0
  83. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.js +66 -0
  84. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.ts +69 -0
  85. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +46 -0
  86. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +296 -0
  87. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +364 -0
  88. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.d.ts +1 -0
  89. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.js +1 -0
  90. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.ts +1 -0
  91. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -0
  92. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +22 -0
  93. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +30 -0
  94. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +21 -0
  95. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +205 -0
  96. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +240 -0
  97. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.d.ts +8 -0
  98. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.js +18 -0
  99. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.ts +23 -0
  100. package/dist/components/Daeryuntalk/_lib/index.d.ts +7 -0
  101. package/dist/components/Daeryuntalk/_lib/index.js +101 -0
  102. package/dist/components/Daeryuntalk/_lib/index.ts +137 -0
  103. package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
  104. package/dist/components/Daeryuntalk/_lib/utils.js +16 -0
  105. package/dist/components/Daeryuntalk/_lib/utils.ts +17 -0
  106. package/dist/components/Daeryuntalk/{types.d.ts → _types/message.d.ts} +33 -17
  107. package/dist/components/Daeryuntalk/_types/message.js +19 -0
  108. package/dist/components/Daeryuntalk/{types.ts → _types/message.ts} +64 -19
  109. package/dist/components/Daeryuntalk/_types/message_object.d.ts +16 -0
  110. package/dist/components/Daeryuntalk/_types/message_object.js +1 -0
  111. package/dist/components/Daeryuntalk/_types/message_object.ts +20 -0
  112. package/dist/components/Daeryuntalk/_types/socket/message.d.ts +0 -0
  113. package/dist/components/Daeryuntalk/_types/socket/message.js +1 -0
  114. package/dist/components/Daeryuntalk/_types/socket/message.ts +0 -0
  115. package/dist/components/Daeryuntalk/_types/socket/workflow.d.ts +15 -0
  116. package/dist/components/Daeryuntalk/_types/socket/workflow.js +1 -0
  117. package/dist/components/Daeryuntalk/_types/socket/workflow.ts +15 -0
  118. package/dist/components/Daeryuntalk/_ui/buttons/Button1.d.ts +10 -0
  119. package/dist/components/Daeryuntalk/_ui/buttons/Button1.jsx +11 -0
  120. package/dist/components/Daeryuntalk/_ui/buttons/Button1.tsx +28 -0
  121. package/dist/components/Daeryuntalk/_ui/inputs/Input1.d.ts +12 -0
  122. package/dist/components/Daeryuntalk/_ui/inputs/Input1.jsx +9 -0
  123. package/dist/components/Daeryuntalk/_ui/inputs/Input1.tsx +39 -0
  124. package/dist/components/Daeryuntalk/index.tsx +1 -0
  125. package/dist/lib/index.js +1 -1
  126. package/dist/lib/index.ts +1 -1
  127. package/dist/styles/globals.css +161 -8
  128. package/dist/tsconfig.tsbuildinfo +1 -1
  129. package/package.json +8 -2
  130. package/dist/components/Daeryuntalk/types.js +0 -8
  131. package/dist/lib/api/daeryuntalk/index.d.ts +0 -143
  132. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.d.ts +0 -0
  133. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.js +0 -0
  134. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.ts +0 -0
@@ -7,6 +7,17 @@
7
7
  * 3. 웹소켓 연결
8
8
  * 4. 채팅 문의 관리
9
9
  */
10
+ import {
11
+ IDaeryunTalkResponseWrapper,
12
+ IAuthConnectionDataResponse,
13
+ WebSocketInitDataResponse,
14
+ IChatInquiryMainDataResponse,
15
+ ChatInquiryCreateDataResponse,
16
+ ChatInquiryDetailDataResponse,
17
+ ChatMessage,
18
+ SendMessageResponse,
19
+ ChatInquiryMessageListDataResponse
20
+ } from './type/response';
10
21
 
11
22
  // API 기본 URL
12
23
  const API_BASE_URL = 'https://chat-client-api.lawmance.com';
@@ -16,68 +27,26 @@ const DEFAULT_API_VERSION = '1.0.0';
16
27
 
17
28
  // API 엔드포인트
18
29
  const ENDPOINTS = {
19
- AUTHENTICATE: '/chatctm/ctf/crtfica',
20
- WEBSOCKET_INIT: '/chatctm/cmp/ws-init',
21
- CHAT_INQUIRY_MAIN: '/chatctm/hom/chatinquirymainsearch',
22
- CHAT_INQUIRY_CREATE: '/chatctm/hom/chatinquirycreate',
30
+ /* 시작점 */
31
+ AUTHENTICATE: '/chatctm/ctf/crtfica', // 유저 인증
32
+ WEBSOCKET_INIT: '/chatctm/cmp/ws-init', // 웹 소켓 초기화
33
+ /* 채팅 */
34
+ CHAT_INQUIRY_MAIN: '/chatctm/hom/chatinquirymainsearch', // 채팅 문의 메인 조회
35
+ CHAT_INQUIRY_CREATE: '/chatctm/hom/chatinquirycreate', // XXX
23
36
  CHAT_INQUIRY_DETAIL: '/chatctm/hom/chatinquirydetailsearch',
24
- CHAT_INQUIRY_GENERATION: '/chatctm/chi/chatinquirygeneration',
25
- CHAT_INQUIRY_DETAIL_NEW: '/chatctm/chi/chatinquirydetail',
26
- CHAT_MESSAGE_SEND: '/chatctm/chi/chatinquirymessagesend'
37
+ CHAT_INQUIRY_GENERATION: '/chatctm/chi/chatinquirygeneration', // 채팅 문의 생성
38
+ CHAT_INQUIRY_DETAIL_NEW: '/chatctm/chi/chatinquirydetail', // 채팅 문의 상세 조회
39
+ CHAT_INQUIRY_MESSAGE_LIST: '/chatctm/chi/chatinquirymessagelist', // 채팅 문의 메시지 목록 조회
40
+ CHAT_MESSAGE_SEND: '/chatctm/chi/chatinquirymessagesend', // 채팅 문의 메시지 전송
41
+ CHAT_MESSAGE_FILE_URL_REQUEST: '/chatctm/chi/chatinquirymessagefiledownloadurlgeneration', //채팅 문의 메시지 파일 다운로드 URL 생성 요청
42
+ CHAT_MESSAGE_WORKFLOW_START: '/chatctm/chi/chatinquiryworkflowprogress', // 채팅 문의 워크플로우 진행
43
+ CHAT_MESSAGE_WORKFLOW_BACK: '/chatctm/chi/chatinquiryworkflowrollback', // 채팅 문의 워크플로우 되돌리기
44
+ /* 유저 */
45
+ USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate' //개인 정보 업데이트
27
46
  };
28
47
 
29
- // 타입 정의
30
- export interface WebSocketInitResponse {
31
- data: {
32
- cnnc_url: string;
33
- cnnc_token: string;
34
- };
35
- }
36
-
37
- export interface ChatInquiryMainData {
38
- channel_name: string;
39
- channel_logo_image_url: string;
40
- sleeve_image_url: string;
41
- salutation: string;
42
- answer_speed_message: string;
43
- progress_inquiry_number: string;
44
- }
45
-
46
- export interface ResultInfo {
47
- result_type_cd: string;
48
- result_cd: string;
49
- result_msg: string;
50
- }
51
-
52
- export interface ChatInquiryMainResponse {
53
- result_info: ResultInfo;
54
- data: ChatInquiryMainData;
55
- }
56
-
57
- export interface ChatInquiryCreateResponse {
58
- result_info: ResultInfo;
59
- data: {
60
- chat_inquiry_number: string;
61
- };
62
- }
63
-
64
- // 채팅 문의 상세 데이터 타입 정의
65
- export interface ChatInquiryDetailData {
66
- inquiry_number?: string;
67
- status?: string;
68
- created_at?: string;
69
- updated_at?: string;
70
- description?: string;
71
- messages?: ChatMessage[];
72
- }
73
-
74
- export interface ChatInquiryDetailResponse {
75
- result_info?: ResultInfo;
76
- data?: ChatInquiryDetailData; // data 속성 추가
77
- success?: boolean;
78
- error_code?: string;
79
- error_message?: string;
80
- }
48
+ // 메인
49
+ const TEST_CENTER_CODE: string = 'CT0000';
81
50
 
82
51
  // 채팅 메시지 유형 상수
83
52
  export const MESSAGE_TYPES = {
@@ -88,26 +57,6 @@ export const MESSAGE_TYPES = {
88
57
  MACRO: 'MSP00100005'
89
58
  };
90
59
 
91
- // 메시지 블록 타입 정의
92
- export interface MessageBlock {
93
- type: string;
94
- value: string;
95
- }
96
-
97
- // 채팅 메시지 타입 정의
98
- export interface ChatMessage {
99
- msg_no: string;
100
- msg_type: string;
101
- msg_status: string;
102
- user_key: string;
103
- inquiry_no: string;
104
- created_at: string;
105
- updated_at: string;
106
- language: string;
107
- plain_text: string;
108
- blocks: MessageBlock[];
109
- }
110
-
111
60
  /**
112
61
  * 쿠키 지원이 포함된 기본 fetch 함수
113
62
  */
@@ -123,12 +72,20 @@ async function fetchWithCookies<T>(
123
72
  headers.set('Content-Type', 'application/json');
124
73
  }
125
74
 
75
+ if (typeof window !== 'undefined') {
76
+ const AuthToken = localStorage.getItem('daeryunchatinquirytoken') || '';
77
+ // 로컬스토리지에 존재하면, 헤더에 추가
78
+ if (AuthToken) {
79
+ headers.set('a', AuthToken);
80
+ }
81
+ }
82
+
126
83
  // 버전 헤더 추가
127
84
  headers.set('v', version);
128
85
 
129
86
  const defaultOptions: RequestInit = {
130
87
  credentials: 'include', // 요청에 쿠키 포함
131
- headers
88
+ headers: headers as HeadersInit
132
89
  };
133
90
 
134
91
  const mergedOptions = {
@@ -215,13 +172,22 @@ async function fetchWithCookies<T>(
215
172
  * @param version API 버전 (기본값: 1.0.0)
216
173
  * @returns 인증 응답
217
174
  */
218
- export async function authenticateUser(version?: string): Promise<any> {
175
+
176
+ export async function authenticateUser(centerCode: string, version?: string): Promise<any> {
219
177
  console.log('[인증 시작] 사용자 인증 요청', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
220
178
  try {
179
+ const body = {
180
+ d: {
181
+ center_code: centerCode
182
+ }
183
+ };
221
184
  // 인증 API 호출
222
- const response = await fetchWithCookies<any>(
185
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<IAuthConnectionDataResponse>>(
223
186
  `${API_BASE_URL}${ENDPOINTS.AUTHENTICATE}`,
224
- { method: 'GET' },
187
+ {
188
+ method: 'POST',
189
+ body: JSON.stringify(body)
190
+ },
225
191
  version
226
192
  );
227
193
 
@@ -231,6 +197,10 @@ export async function authenticateUser(version?: string): Promise<any> {
231
197
  return { success: true, status: 'authenticated' };
232
198
  }
233
199
 
200
+ if (typeof window !== 'undefined' && response?.data?.token) {
201
+ localStorage.setItem('daeryunchatinquirytoken', response.data.token);
202
+ }
203
+
234
204
  console.log('[인증 성공] 사용자 인증 완료', response);
235
205
  return response;
236
206
  } catch (error) {
@@ -244,13 +214,15 @@ export async function authenticateUser(version?: string): Promise<any> {
244
214
  * @param version API 버전 (기본값: 1.0.0)
245
215
  * @returns 연결 URL과 토큰이 포함된 웹소켓 초기화 데이터
246
216
  */
247
- export async function initializeWebSocket(version?: string): Promise<WebSocketInitResponse> {
217
+ export async function initializeWebSocket(
218
+ version?: string
219
+ ): Promise<IDaeryunTalkResponseWrapper<WebSocketInitDataResponse>> {
248
220
  console.log(
249
221
  '[웹소켓 초기화 시작] 웹소켓 연결 초기화 요청',
250
222
  version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
251
223
  );
252
224
  try {
253
- const response = await fetchWithCookies<WebSocketInitResponse>(
225
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<WebSocketInitDataResponse>>(
254
226
  `${API_BASE_URL}${ENDPOINTS.WEBSOCKET_INIT}`,
255
227
  { method: 'POST' },
256
228
  version
@@ -293,12 +265,18 @@ export function connectWebSocket(
293
265
  if (onOpen) onOpen(event);
294
266
  };
295
267
 
296
- if (onMessage) {
297
- socket.onmessage = event => {
298
- console.log('[웹소켓 메시지 수신]', event.data);
299
- onMessage(event.data);
300
- };
301
- }
268
+ socket.onmessage = event => {
269
+ console.log('[웹소켓 메시지 수신]', event.data);
270
+
271
+ try {
272
+ const data = JSON.parse(event.data);
273
+ console.log('📩 New Message (parsed):', data);
274
+ } catch (err) {
275
+ console.error('[웹소켓] JSON 파싱 오류:', err);
276
+ }
277
+
278
+ if (onMessage) onMessage(event.data); // event 전체 넘기기 (event.data는 string)
279
+ };
302
280
 
303
281
  if (onClose) {
304
282
  socket.onclose = event => {
@@ -323,13 +301,17 @@ export function connectWebSocket(
323
301
 
324
302
  /**
325
303
  * 채팅 문의 메인 조회
304
+ * @param channelNumber 전달받은 채널
326
305
  * @param version API 버전 (기본값: 1.0.0)
327
306
  * @returns 채팅 문의 메인 데이터
328
307
  */
329
- export async function getChatInquiryMain(version?: string): Promise<ChatInquiryMainResponse> {
308
+ export async function getChatInquiryMain(
309
+ channelNumber: string,
310
+ version?: string
311
+ ): Promise<IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>> {
330
312
  const body = {
331
313
  d: {
332
- channel_number: 'CH123456789012345678' // 명시된 고정값
314
+ channel_number: channelNumber
333
315
  }
334
316
  };
335
317
 
@@ -339,7 +321,7 @@ export async function getChatInquiryMain(version?: string): Promise<ChatInquiryM
339
321
  version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
340
322
  );
341
323
  try {
342
- const response = await fetchWithCookies<ChatInquiryMainResponse>(
324
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>>(
343
325
  `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_MAIN}`,
344
326
  {
345
327
  method: 'POST',
@@ -360,17 +342,20 @@ export async function getChatInquiryMain(version?: string): Promise<ChatInquiryM
360
342
  * @param version API 버전 (기본값: 1.0.0)
361
343
  * @returns 문의 번호가 포함된 생성된 채팅 문의 데이터
362
344
  */
363
- export async function generateChatInquiry(version?: string): Promise<ChatInquiryCreateResponse> {
345
+ export async function generateChatInquiry(
346
+ channelNumber: string,
347
+ version?: string
348
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>> {
364
349
  console.log('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
365
350
 
366
351
  const body = {
367
352
  d: {
368
- channel_number: 'CH123456789012345678'
353
+ channel_number: channelNumber
369
354
  }
370
355
  };
371
356
 
372
357
  try {
373
- const response = await fetchWithCookies<ChatInquiryCreateResponse>(
358
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>(
374
359
  `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_GENERATION}`,
375
360
  {
376
361
  method: 'POST',
@@ -393,23 +378,23 @@ export async function generateChatInquiry(version?: string): Promise<ChatInquiry
393
378
  * @returns 채팅 문의 상세 정보
394
379
  */
395
380
  export async function getChatInquiryDetailNew(
396
- chatInquiryNumber: string,
381
+ chat_inquiry_number: string,
397
382
  version?: string
398
- ): Promise<ChatInquiryDetailResponse> {
383
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryDetailDataResponse>> {
399
384
  const body = {
400
385
  d: {
401
- channel_number: 'CH123456789012345678', // 고정값
402
- chat_inquiry_number: chatInquiryNumber
386
+ chat_inquiry_number: chat_inquiry_number, // 채팅문의 번호
387
+ size: 10
403
388
  }
404
389
  };
405
390
 
406
391
  console.log(
407
392
  '[채팅 문의 상세 조회 시작 (개선)] 문의 번호:',
408
- chatInquiryNumber,
393
+ chat_inquiry_number,
409
394
  version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
410
395
  );
411
396
  try {
412
- const response = await fetchWithCookies<ChatInquiryDetailResponse>(
397
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<ChatInquiryDetailDataResponse>>(
413
398
  `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_DETAIL_NEW}`,
414
399
  {
415
400
  method: 'POST',
@@ -425,6 +410,51 @@ export async function getChatInquiryDetailNew(
425
410
  }
426
411
  }
427
412
 
413
+ /**
414
+ * 채팅 메세지 목록 조회
415
+ * @param chatInquiryNumber 채팅 문의 번호
416
+ * @param standard_date_time 기준 일시
417
+ * @param size 사이즈
418
+ * @param version API 버전 (기본값: 1.0.0)
419
+ * @returns 채팅 메세지 리스트
420
+ */
421
+ export async function getChatInquiryMessageList(
422
+ chatInquiryNumber: string,
423
+ standardDateTime?: any,
424
+ size?: number,
425
+ version?: string
426
+ ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>> {
427
+ const body = {
428
+ d: {
429
+ chat_inquiry_number: chatInquiryNumber,
430
+ ...(standardDateTime && { standard_date_time: standardDateTime }),
431
+ // standard_date_time: standard_date_time ?? new Date().toISOString(),
432
+ size: size ?? 10
433
+ }
434
+ };
435
+
436
+ console.log(
437
+ '[채팅 메세지 리스트] 문의 번호:',
438
+ chatInquiryNumber,
439
+ version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
440
+ );
441
+ try {
442
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>>(
443
+ `${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_MESSAGE_LIST}`,
444
+ {
445
+ method: 'POST',
446
+ body: JSON.stringify(body)
447
+ },
448
+ version
449
+ );
450
+ console.log('[채팅 메세지 리스트]', response);
451
+ return response;
452
+ } catch (error) {
453
+ console.error('[채팅 메세지 리스트]', error);
454
+ throw error;
455
+ }
456
+ }
457
+
428
458
  /**
429
459
  * Daeryuntalk 초기화 완료 흐름
430
460
  * 이 함수는 인증부터 웹소켓 연결까지 완전한 흐름을 처리
@@ -438,7 +468,8 @@ export async function initializeDaeryuntalk(
438
468
  onWebSocketMessage?: (event: MessageEvent) => void,
439
469
  version?: string
440
470
  ): Promise<{
441
- inquiryData?: any;
471
+ inquiryData?: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
472
+ socket: WebSocket;
442
473
  }> {
443
474
  console.log(
444
475
  '[Daeryuntalk 초기화 시작] 전체 흐름 실행',
@@ -447,41 +478,47 @@ export async function initializeDaeryuntalk(
447
478
  try {
448
479
  // 1단계: 사용자 인증
449
480
  console.log('[Daeryuntalk 초기화] 1단계: 사용자 인증 시작');
450
- await authenticateUser(version);
481
+ const authResponse = await authenticateUser(TEST_CENTER_CODE, version);
451
482
  console.log('[Daeryuntalk 초기화] 1단계: 사용자 인증 완료');
452
483
 
453
484
  // 2단계: 웹소켓 초기화
454
485
  console.log('[Daeryuntalk 초기화] 2단계: 웹소켓 초기화 시작');
455
486
  const wsInitData = await initializeWebSocket(version);
456
487
  console.log('[Daeryuntalk 초기화] 2단계: 웹소켓 초기화 완료', {
457
- cnnc_url: wsInitData.data.cnnc_url,
458
- token_일부: wsInitData.data.cnnc_token ? `${wsInitData.data.cnnc_token.substring(0, 10)}...` : '없음'
488
+ cnnc_url: wsInitData.data.connection_url,
489
+ token_일부: wsInitData.data.connection_token
490
+ ? `${wsInitData.data.connection_token.substring(0, 10)}...`
491
+ : '없음'
459
492
  });
460
493
 
461
494
  // 3단계: 웹소켓 연결
462
495
  console.log('[Daeryuntalk 초기화] 3단계: 웹소켓 연결 시작');
463
- const socket = connectWebSocket(
464
- wsInitData.data.cnnc_url,
465
- wsInitData.data.cnnc_token,
496
+ const socket: WebSocket = connectWebSocket(
497
+ wsInitData.data.connection_url,
498
+ wsInitData.data.connection_token,
466
499
  onWebSocketMessage,
467
500
  onWebSocketConnected
468
501
  ? () => {
469
502
  console.log('[Daeryuntalk 초기화] 3단계: 웹소켓 연결 콜백 실행');
470
- onWebSocketConnected(socket);
503
+ if (onWebSocketConnected) {
504
+ onWebSocketConnected(socket);
505
+ }
471
506
  }
472
507
  : undefined
473
508
  );
509
+ // console.log('socket', socket);
474
510
  console.log('[Daeryuntalk 초기화] 3단계: 웹소켓 연결 객체 생성됨');
475
511
 
512
+ console.log('authResponse', authResponse);
476
513
  // 4단계: 채팅 문의 메인 조회
477
514
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 시작');
478
- const chatInquiryData = await getChatInquiryMain(version);
515
+ const chatInquiryData = await getChatInquiryMain(authResponse.data.channel_number, version);
479
516
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 완료', chatInquiryData);
480
-
481
- console.log('[Daeryuntalk 초기화 완료] 모든 단계 성공');
482
517
  return {
483
- inquiryData: chatInquiryData
518
+ inquiryData: chatInquiryData,
519
+ socket: socket
484
520
  };
521
+ console.log('[Daeryuntalk 초기화 완료] 모든 단계 성공');
485
522
  } catch (error) {
486
523
  console.error('[Daeryuntalk 초기화 실패] 오류 발생:', error);
487
524
  throw error;
@@ -489,36 +526,139 @@ export async function initializeDaeryuntalk(
489
526
  }
490
527
 
491
528
  /**
492
- * 채팅 메시지 전송
493
- * @param chatInquiryNumber 채팅 문의 번호
494
- * @param messageText 메시지 내용
529
+ * 채팅 워크플로우 진행 처리
530
+ *
531
+ * @param chatInquiryNumber 채팅 문의 번호 required
532
+ * @param messageNumber 메시지 번호 required
533
+ * @param workFlowNumber 워크플로우 번호 required
534
+ * @param objectNumber 오브젝트 번호 required
535
+ * @param version API 버전 (기본값: 1.0.0)
536
+ * @returns 전송된 메시지 데이터
537
+ */
538
+ export async function chatWorkFlow(
539
+ chatInquiryNumber: string,
540
+ messageNumber: string,
541
+ workFlowNumber: string,
542
+ objectNumber: string,
543
+ version?: string
544
+ ): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>> {
545
+ const body = {
546
+ d: {
547
+ chat_inquiry_number: chatInquiryNumber,
548
+ message_number: messageNumber,
549
+ work_flow_number: workFlowNumber,
550
+ object_number: objectNumber
551
+ }
552
+ };
553
+
554
+ console.log(
555
+ '[채팅 워크플로우 시작]',
556
+ '문의 번호:',
557
+ chatInquiryNumber,
558
+ '메시지 번호:',
559
+ messageNumber,
560
+ '워크플로우 번호:',
561
+ workFlowNumber,
562
+ '오브젝트 번호:',
563
+ objectNumber,
564
+ version ? `버전: ${version}` : '기본 버전: 1.0.0'
565
+ );
566
+ try {
567
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<any>>(
568
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_WORKFLOW_START}`,
569
+ {
570
+ method: 'POST',
571
+ body: JSON.stringify(body)
572
+ },
573
+ version
574
+ );
575
+ console.log('[채팅 워크플로우 시작 성공]', response);
576
+ return response;
577
+ } catch (error) {
578
+ console.error('[채팅 워크플로우 시작 실패]', error);
579
+ throw error;
580
+ }
581
+ }
582
+
583
+ /**
584
+ * 채팅 워크플로우 되돌리기
585
+ *
586
+ * @param chatInquiryNumber 채팅 문의 번호 required
587
+ * @param messageNumber 메시지 번호 required
588
+ * @param workFlowNavigationCode 워크플로우네비게이션코드 번호 required
495
589
  * @param version API 버전 (기본값: 1.0.0)
496
590
  * @returns 전송된 메시지 데이터
497
591
  */
498
- export interface SendMessageResponse {
499
- result_info: ResultInfo;
500
- data?: {
501
- message: ChatMessage;
592
+ export async function chatWorkFlowBack(
593
+ chatInquiryNumber: string,
594
+ messageNumber: string,
595
+ workFlowNavigationCode: string,
596
+ version?: string
597
+ ): Promise<IDaeryunTalkResponseWrapper<null>> {
598
+ const body = {
599
+ d: {
600
+ chat_inquiry_number: chatInquiryNumber,
601
+ message_number: messageNumber,
602
+ work_flow_navigation_code: workFlowNavigationCode
603
+ }
502
604
  };
605
+
606
+ console.log(
607
+ '[채팅 워크플로우 되돌리기 시작]',
608
+ '문의 번호:',
609
+ chatInquiryNumber,
610
+ '메시지 번호:',
611
+ messageNumber,
612
+ '워크플로우네비게이션코드 번호:',
613
+ workFlowNavigationCode,
614
+ version ? `버전: ${version}` : '기본 버전: 1.0.0'
615
+ );
616
+ try {
617
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<any>>(
618
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_WORKFLOW_BACK}`,
619
+ {
620
+ method: 'POST',
621
+ body: JSON.stringify(body)
622
+ },
623
+ version
624
+ );
625
+ console.log('[채팅 워크플로우 되돌리기 성공]', response);
626
+ return response;
627
+ } catch (error) {
628
+ console.error('[채팅 워크플로우 되돌리기 실패]', error);
629
+ throw error;
630
+ }
503
631
  }
504
632
 
633
+ /**
634
+ * 채팅 메시지 전송
635
+ * @param chatInquiryNumber 채팅 문의 번호
636
+ * @param messageText 메시지 내용
637
+ * @param version API 버전 (기본값: 1.0.0)
638
+ * @returns 전송된 메시지 데이터
639
+ */
505
640
  export async function sendChatMessage(
506
641
  chatInquiryNumber: string,
507
- messageText: string,
642
+ htmlContent: string,
643
+ jsonData: any,
508
644
  version?: string
509
- ): Promise<SendMessageResponse> {
645
+ ): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>> {
510
646
  if (!chatInquiryNumber) {
511
647
  throw new Error('채팅 메시지 전송 실패: 문의 번호가 없음');
512
648
  }
513
649
 
514
- if (!messageText.trim()) {
650
+ if (!htmlContent) {
515
651
  throw new Error('채팅 메시지 전송 실패: 메시지가 없음');
516
652
  }
653
+ if (!jsonData) {
654
+ throw new Error('채팅 메시지 전송 실패: json 데이터 없음');
655
+ }
517
656
 
518
657
  const body = {
519
658
  d: {
520
- inquiry_number: chatInquiryNumber,
521
- plain_text: messageText
659
+ chat_inquiry_number: chatInquiryNumber, // required
660
+ html_content: htmlContent, // required, tiptap html
661
+ json_data: jsonData // required, tiptab json
522
662
  }
523
663
  };
524
664
 
@@ -526,11 +666,11 @@ export async function sendChatMessage(
526
666
  '[채팅 메시지 전송 시작] 문의 번호:',
527
667
  chatInquiryNumber,
528
668
  '메시지:',
529
- messageText,
669
+ htmlContent,
530
670
  version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
531
671
  );
532
672
  try {
533
- const response = await fetchWithCookies<SendMessageResponse>(
673
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<SendMessageResponse>>(
534
674
  `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_SEND}`,
535
675
  {
536
676
  method: 'POST',
@@ -545,3 +685,87 @@ export async function sendChatMessage(
545
685
  throw error;
546
686
  }
547
687
  }
688
+
689
+ /**
690
+ * 채팅 개인 정보 업데이트
691
+ * @param chatInquiryNumber 채팅 문의 번호
692
+ * @param messageNumber 해당 채팅 번호
693
+ * @param name 이름
694
+ * @param cellPhoneNumber 전화번호
695
+ * @param version API 버전 (기본값: 1.0.0)
696
+ * @returns 전송된 메시지 데이터
697
+ */
698
+ export async function chatUserUpdate(
699
+ chatInquiryNumber: string,
700
+ messageNumber: string,
701
+ name: string,
702
+ cellPhoneNumber: string,
703
+ version?: string
704
+ ): Promise<IDaeryunTalkResponseWrapper<any>> {
705
+ const body = {
706
+ d: {
707
+ chat_inquiry_number: chatInquiryNumber, // required
708
+ message_number: messageNumber, // required
709
+ name: name, // required
710
+ cell_phone_number: cellPhoneNumber // required
711
+ }
712
+ };
713
+
714
+ console.log('[채팅 개인 정보 업데이트] 시작');
715
+ try {
716
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<any>>(
717
+ `${API_BASE_URL}${ENDPOINTS.USER_INFO_UPDATE}`,
718
+ {
719
+ method: 'POST',
720
+ body: JSON.stringify(body)
721
+ },
722
+ version
723
+ );
724
+ console.log('[채팅 메시지 전송 성공]', response);
725
+ return response;
726
+ } catch (error) {
727
+ console.error('[채팅 메시지 전송 실패]', error);
728
+ throw error;
729
+ }
730
+ }
731
+
732
+ /**
733
+ * 채팅문의 메시지 파일 다운로드 URL 생성
734
+ * @param chatInquiryNumber 채팅문의번호
735
+ * @param fileNumber 파일번호
736
+ * @param version
737
+ */
738
+ export const getMessageFileDownloadUrl = async ({
739
+ chatInquiryNumber,
740
+ fileNumber,
741
+ version = DEFAULT_API_VERSION
742
+ }: {
743
+ chatInquiryNumber: string; // required
744
+ fileNumber: string;
745
+ version?: string;
746
+ }) => {
747
+ const consoleName = '채팅문의 메시지 파일 다운로드 URL 생성';
748
+ try {
749
+ const body = {
750
+ d: {
751
+ chat_inquiry_number: chatInquiryNumber, // required
752
+ file_number: fileNumber // required
753
+ }
754
+ };
755
+ console.log(`[${consoleName} 진행]`);
756
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<{ url: string }>>(
757
+ `${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_FILE_URL_REQUEST}`,
758
+ {
759
+ method: 'POST',
760
+ body: JSON.stringify(body)
761
+ },
762
+ version
763
+ );
764
+
765
+ console.log(`[${consoleName} 완료]`, response);
766
+ return response;
767
+ } catch (error) {
768
+ console.error(`[${consoleName} 실패] 오류:`, error);
769
+ throw error;
770
+ }
771
+ };