@vibexnpm/talkx 8.10.0 → 8.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +57 -0
- package/dist/talkflow-sdk.esm.js +1 -1
- package/dist/talkflow-sdk.esm.js.map +1 -1
- package/dist/talkflow-sdk.standalone.js +1 -1
- package/dist/talkflow-sdk.standalone.js.map +1 -1
- package/dist/talkflow-sdk.umd.js +1 -1
- package/dist/talkflow-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/chat/ChatClient.js +20 -0
- package/src/talkflow/delegates.js +2 -0
- package/types/__typetests__/files.types.ts +53 -0
- package/types/index.d.ts +57 -0
package/package.json
CHANGED
package/src/chat/ChatClient.js
CHANGED
|
@@ -1429,6 +1429,26 @@ class ChatClient extends EventEmitter {
|
|
|
1429
1429
|
return this.apiClient.get('/api/v1/rooms/groups/all', { size, lastId, lastSortValue });
|
|
1430
1430
|
}
|
|
1431
1431
|
|
|
1432
|
+
/**
|
|
1433
|
+
* 파일함 — 내가 지금 참여 중인 방들에 올라온 파일(미디어 포함) 목록, 최신순 커서 페이지.
|
|
1434
|
+
*
|
|
1435
|
+
* <p>한 줄이 파일 하나다(메시지 하나에 파일이 여러 개면 여러 줄). 보이는 범위는 채팅 화면과 같다 — 참여 중인 방만,
|
|
1436
|
+
* 재입장 이전·보관 기간 밖·삭제된 메시지의 파일은 오지 않는다. PM 이 만든 파일도 온다.</p>
|
|
1437
|
+
*
|
|
1438
|
+
* <p>다른 목록 조회({@link ChatClient#getMessages})처럼 서버 응답 래퍼째 돌려준다 — 페이지는 {@code result.data}.</p>
|
|
1439
|
+
*
|
|
1440
|
+
* @param {Object} [params]
|
|
1441
|
+
* @param {string} [params.roomId] - 방 하나로 거르기. 생략하면 참여 중인 방 전부. 참여하지 않은 방이면 403
|
|
1442
|
+
* @param {number} [params.size=50] - 페이지 크기 (1-100, 파일 수)
|
|
1443
|
+
* @param {string} [params.lastId] - 직전 응답의 lastId 를 그대로 — 불투명 값이라 만들어 쓰지 않는다
|
|
1444
|
+
* @param {number} [params.lastSortValue] - 직전 응답의 lastSortValue 를 그대로
|
|
1445
|
+
* @returns {Promise<Object>}
|
|
1446
|
+
*/
|
|
1447
|
+
async getFiles(params = {}) {
|
|
1448
|
+
const { roomId, size = 50, lastId, lastSortValue } = params;
|
|
1449
|
+
return this.apiClient.get('/api/v1/files', { roomId, size, lastId, lastSortValue });
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1432
1452
|
/**
|
|
1433
1453
|
* 메시지 목록 조회
|
|
1434
1454
|
* @param {string} roomId - 채팅방 ID
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 파일함 타입 — docs/chat.md «파일함» 예제가 <b>실제로 컴파일되는지</b>.
|
|
3
|
+
*
|
|
4
|
+
* <p>jest 는 `.d.ts` 를 보지 않는다. 문서가 약속한 모양(반환은 envelope 째 · 한 줄 = 파일 하나 · 커서 두 칸은 직전 응답
|
|
5
|
+
* 그대로 · 이름·방 이름은 비어 있을 수 있음 · 종류는 다섯 값)이 선언과 맞는지 여기서 tsc 로 고정한다.</p>
|
|
6
|
+
*
|
|
7
|
+
* <p>실행: {@code npm run typecheck}</p>
|
|
8
|
+
*/
|
|
9
|
+
import TalkFlowClient from '../index';
|
|
10
|
+
import type { ChatFile, ChatFileListParams } from '../index';
|
|
11
|
+
|
|
12
|
+
declare const talkflow: TalkFlowClient;
|
|
13
|
+
declare const roomId: string;
|
|
14
|
+
|
|
15
|
+
// 1) 처음부터 끝까지 — 다음 페이지는 응답의 커서 두 칸을 그대로 넘긴다.
|
|
16
|
+
async function loadAll(filterRoomId?: string): Promise<ChatFile[]> {
|
|
17
|
+
const rows: ChatFile[] = [];
|
|
18
|
+
let params: ChatFileListParams = { roomId: filterRoomId, size: 50 };
|
|
19
|
+
for (;;) {
|
|
20
|
+
const result = await talkflow.getFiles(params);
|
|
21
|
+
rows.push(...result.data.content);
|
|
22
|
+
if (!result.data.hasNext) {
|
|
23
|
+
return rows;
|
|
24
|
+
}
|
|
25
|
+
params = {
|
|
26
|
+
...params,
|
|
27
|
+
lastId: result.data.lastId ?? undefined,
|
|
28
|
+
lastSortValue: result.data.lastSortValue ?? undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 2) 한 줄 그리기 — 누가·언제·어느 방·파일명·다운로드 링크·종류.
|
|
34
|
+
function describe(row: ChatFile): string {
|
|
35
|
+
const who: string = row.uploaderName ?? '알 수 없음';
|
|
36
|
+
const madeByPm: boolean = row.uploaderType === 'ASSISTANT';
|
|
37
|
+
const room: string = row.roomName ?? '';
|
|
38
|
+
const uploadedAt: number = row.uploadedAt;
|
|
39
|
+
const kind: 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'FILE' = row.category;
|
|
40
|
+
const link: string = row.file.fileUrl;
|
|
41
|
+
const mime: string | undefined = row.file.fileType;
|
|
42
|
+
void [madeByPm, uploadedAt, kind, mime];
|
|
43
|
+
return `${who} · ${room} · ${row.file.fileName ?? link}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 3) 방 목록 필터는 파일함에 없다 — 방 하나는 roomId 로 고른다.
|
|
47
|
+
async function wrongFilter(): Promise<void> {
|
|
48
|
+
// @ts-expect-error — type 은 방 목록(getRooms) 파라미터다.
|
|
49
|
+
await talkflow.getFiles({ type: 'GROUP' });
|
|
50
|
+
await talkflow.getFiles({ roomId });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void [loadAll, describe, wrongFilter];
|
package/types/index.d.ts
CHANGED
|
@@ -631,6 +631,8 @@ export interface FileMetaData {
|
|
|
631
631
|
*/
|
|
632
632
|
fileId?: string;
|
|
633
633
|
fileUrl: string;
|
|
634
|
+
/** MIME 타입(예: {@code 'image/png'}) — 서버가 업로드·메시지·파일함 응답에 싣는 값. */
|
|
635
|
+
fileType?: string;
|
|
634
636
|
fileName?: string;
|
|
635
637
|
fileSize?: number;
|
|
636
638
|
contentType?: string;
|
|
@@ -1288,6 +1290,47 @@ export interface ApiEnvelope<T> {
|
|
|
1288
1290
|
message?: string;
|
|
1289
1291
|
}
|
|
1290
1292
|
|
|
1293
|
+
/** {@link ChatClient.getFiles} 파라미터 — 파일함 한 페이지. */
|
|
1294
|
+
export interface ChatFileListParams {
|
|
1295
|
+
/** 방 하나로 거르기. 생략하면 내가 지금 참여 중인 방 전부. 참여하지 않은 방이면 403. */
|
|
1296
|
+
roomId?: string;
|
|
1297
|
+
/** 페이지 크기(파일 수). 기본 50, max 100. */
|
|
1298
|
+
size?: number;
|
|
1299
|
+
/** 직전 응답의 {@code lastId} 그대로 — 불투명 값이라 만들어 쓰지 않는다. */
|
|
1300
|
+
lastId?: string;
|
|
1301
|
+
/** 직전 응답의 {@code lastSortValue} 그대로(epoch millis) — {@link CursorPageParams} 와 같은 형. */
|
|
1302
|
+
lastSortValue?: number | string;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* 파일함 한 줄 — 파일 하나(메시지 하나에 파일이 여러 개면 여러 줄).
|
|
1307
|
+
*
|
|
1308
|
+
* <p>보이는 범위는 채팅 화면과 같다 — 참여 중인 방만, 재입장 이전·보관 기간 밖·삭제된 메시지의 파일은 오지 않는다.</p>
|
|
1309
|
+
*/
|
|
1310
|
+
export interface ChatFile {
|
|
1311
|
+
/** 이 줄의 id — 목록 key 로 쓴다. 페이지 커서 {@code lastId} 와 같은 모양. */
|
|
1312
|
+
id: string;
|
|
1313
|
+
roomId: string;
|
|
1314
|
+
/** 방 이름 — 1:1 은 상대 이름. 상대를 찾지 못하면 null. */
|
|
1315
|
+
roomName: string | null;
|
|
1316
|
+
roomType: ChatRoomTypeValue | null;
|
|
1317
|
+
/** 이 파일이 실린 메시지 — {@link ChatMessage.messageId} 와 같은 값. */
|
|
1318
|
+
messageId: string;
|
|
1319
|
+
/** 올린 쪽 id — 사람은 사용자 id, PM 이 만든 파일은 페르소나 id. */
|
|
1320
|
+
uploaderId: string;
|
|
1321
|
+
uploaderType: SenderTypeValue;
|
|
1322
|
+
/** 사람은 닉네임, PM 은 페르소나 이름. 찾지 못하면(탈퇴·삭제) null. */
|
|
1323
|
+
uploaderName: string | null;
|
|
1324
|
+
/** 사람만. PM 은 null. */
|
|
1325
|
+
uploaderProfileUrl: string | null;
|
|
1326
|
+
/** 올린 시각(epoch millis). */
|
|
1327
|
+
uploadedAt: number;
|
|
1328
|
+
/** 종류 — 파일 MIME 기준, 채팅 첨부 분류와 같다. */
|
|
1329
|
+
category: 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'FILE';
|
|
1330
|
+
/** 파일명({@code fileName})·다운로드 링크({@code fileUrl})·MIME({@code fileType})·크기·썸네일 — 채팅 메시지 첨부와 같은 모양. */
|
|
1331
|
+
file: FileMetaData;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1291
1334
|
// ============================================================================
|
|
1292
1335
|
// Event payloads
|
|
1293
1336
|
// ============================================================================
|
|
@@ -2397,6 +2440,13 @@ export class ChatClient implements SdkEventEmitter<ChatClientEvents> {
|
|
|
2397
2440
|
* WebSocket 이벤트와 동일 형 (REST 원시 응답은 ISO 문자열).</p>
|
|
2398
2441
|
*/
|
|
2399
2442
|
getMessages(roomId: string, params?: CursorPageParams): Promise<ApiEnvelope<CursorPageResponse<ChatMessage>>>;
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* 파일함 — 내가 지금 참여 중인 방들에 올라온 파일(미디어 포함), 최신순 커서 페이징. 반환은 envelope 째
|
|
2446
|
+
* ({@code result.data.content}). 한 줄이 파일 하나다. {@code roomId} 를 주면 그 방만(참여하지 않은 방이면 403).
|
|
2447
|
+
* 다음 페이지는 응답의 {@code lastId}·{@code lastSortValue} 를 그대로 넘긴다.
|
|
2448
|
+
*/
|
|
2449
|
+
getFiles(params?: ChatFileListParams): Promise<ApiEnvelope<CursorPageResponse<ChatFile>>>;
|
|
2400
2450
|
fetchLinkPreview(url: string): Promise<FetchLinkPreviewResponse | null>;
|
|
2401
2451
|
sendMessage(roomId: string, data: SendMessageData): Promise<SendMessageResult>;
|
|
2402
2452
|
/** Optimistic UI 버전 — 응답 전 base/예측 messageIds 동기 반환. */
|
|
@@ -2883,6 +2933,13 @@ export default class TalkFlowClient implements SdkEventEmitter<TalkFlowClientEve
|
|
|
2883
2933
|
* WebSocket 이벤트와 동일 형 (REST 원시 응답은 ISO 문자열).</p>
|
|
2884
2934
|
*/
|
|
2885
2935
|
getMessages(roomId: string, params?: CursorPageParams): Promise<ApiEnvelope<CursorPageResponse<ChatMessage>>>;
|
|
2936
|
+
|
|
2937
|
+
/**
|
|
2938
|
+
* 파일함 — 내가 지금 참여 중인 방들에 올라온 파일(미디어 포함), 최신순 커서 페이징. 반환은 envelope 째
|
|
2939
|
+
* ({@code result.data.content}). 한 줄이 파일 하나다. {@code roomId} 를 주면 그 방만(참여하지 않은 방이면 403).
|
|
2940
|
+
* 다음 페이지는 응답의 {@code lastId}·{@code lastSortValue} 를 그대로 넘긴다.
|
|
2941
|
+
*/
|
|
2942
|
+
getFiles(params?: ChatFileListParams): Promise<ApiEnvelope<CursorPageResponse<ChatFile>>>;
|
|
2886
2943
|
fetchLinkPreview(url: string): Promise<FetchLinkPreviewResponse | null>;
|
|
2887
2944
|
sendMessage(roomId: string, data: SendMessageData): Promise<SendMessageResult>;
|
|
2888
2945
|
/** Optimistic UI 버전 — 응답 전 base/예측 messageIds 동기 반환. */
|