@vibexnpm/talkx 3.2.0 → 3.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibexnpm/talkx",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "type": "module",
5
5
  "description": "TalkFlow SDK - Chat & WebRTC unified client",
6
6
  "main": "dist/talkflow-sdk.umd.js",
@@ -18,6 +18,14 @@ const MAX_FILES_PER_MESSAGE = 20;
18
18
  */
19
19
  const MAX_ROOM_PM_PROMPT_LENGTH = 20000;
20
20
 
21
+ /**
22
+ * 매직 시그니처가 없는 평문 문서 MIME (txt / md).
23
+ * 서버 도메인 상수(PlainTextDocumentType)의 미러 — 서버가 평문 타입을 늘리면 여기도 함께 늘려야 한다.
24
+ * 빠지면 이 MIME 들이 DOCUMENT 가 아닌 FILE 로 분류돼 그룹 수 예측이 서버와 어긋나고,
25
+ * 결과적으로 다중 파일 전송의 messageId prediction 이 틀어진다.
26
+ */
27
+ const PLAIN_TEXT_DOCUMENT_MIME_TYPES = new Set(['text/plain', 'text/markdown', 'text/x-markdown']);
28
+
21
29
  class ChatClient extends EventEmitter {
22
30
  /**
23
31
  * @param {Object} options
@@ -1787,6 +1795,21 @@ class ChatClient extends EventEmitter {
1787
1795
  return typeof message === 'string' && message.trim().length > 0;
1788
1796
  }
1789
1797
 
1798
+ /**
1799
+ * Content-Type 의 base MIME — {@code ;} 이후 파라미터(charset 등) 제거 + trim + 소문자.
1800
+ * <p>서버 {@code ChatFileCategory.baseMimeType} mirror. 'text/plain; charset=utf-8' → 'text/plain'.
1801
+ * 'text/plain-invalid' 같은 변형은 그대로 남아 정확 비교에서 걸러진다.</p>
1802
+ *
1803
+ * @private
1804
+ * @param {string} mimeType
1805
+ * @returns {string}
1806
+ */
1807
+ _baseMimeType(mimeType) {
1808
+ const raw = mimeType || '';
1809
+ const sep = raw.indexOf(';');
1810
+ return (sep >= 0 ? raw.slice(0, sep) : raw).trim().toLowerCase();
1811
+ }
1812
+
1790
1813
  /**
1791
1814
  * MIME 타입 → 서버 {@code ChatMessageType} 분류 (서버 {@code FileGroupingService.classifyFileType} mirror).
1792
1815
  * <p>서버 도메인 규칙과 동일해야 group count 예측이 일치한다. 서버 변경 시 본 메서드도 동기화 필요.</p>
@@ -1796,11 +1819,15 @@ class ChatClient extends EventEmitter {
1796
1819
  * @returns {string} 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'FILE'
1797
1820
  */
1798
1821
  _classifyFileType(mimeType) {
1799
- const mime = (mimeType || '').toLowerCase();
1822
+ const mime = this._baseMimeType(mimeType);
1800
1823
  if (mime.startsWith('image/')) return 'IMAGE';
1801
1824
  if (mime.startsWith('video/')) return 'VIDEO';
1802
1825
  if (mime.startsWith('audio/')) return 'AUDIO';
1803
- if (mime.includes('pdf') || mime.includes('document')) return 'DOCUMENT';
1826
+ // 평문(txt/md)도 DOCUMENT — 서버가 온디맨드 번역·PM 문서 인식 대상으로 삼는 기준과 동일해야 한다
1827
+ if (mime.includes('pdf') || mime.includes('document')
1828
+ || PLAIN_TEXT_DOCUMENT_MIME_TYPES.has(mime)) {
1829
+ return 'DOCUMENT';
1830
+ }
1804
1831
  return 'FILE';
1805
1832
  }
1806
1833