connectbase-client 3.16.3 → 3.17.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/dist/index.d.mts CHANGED
@@ -6938,6 +6938,20 @@ interface CreateDocumentRequest {
6938
6938
  source_type?: 'file' | 'text' | 'url';
6939
6939
  content?: string;
6940
6940
  source_url?: string;
6941
+ /**
6942
+ * source_type='file' 일 때 사용. 바이너리를 base64 로 인코딩해서 보낸다.
6943
+ * 서버가 PDF / DOCX / text 류를 자동으로 텍스트 추출 → 청킹·인덱싱 한다.
6944
+ * 파일 50MB 상한, 이미지 OCR / 스캔 PDF 는 미지원.
6945
+ * 일반적으로는 [`KnowledgeAPI.addDocumentFromFile`](../api/knowledge.ts) 헬퍼를 사용하면
6946
+ * Blob / File 로 직접 넘길 수 있다.
6947
+ */
6948
+ file_content?: string;
6949
+ /**
6950
+ * file_content 의 MIME (예: 'application/pdf',
6951
+ * 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/markdown').
6952
+ * 비어있으면 서버가 매직 바이트로 자동 추정 — 정확도를 위해 명시 권장.
6953
+ */
6954
+ mime_type?: string;
6941
6955
  metadata?: Record<string, unknown>;
6942
6956
  }
6943
6957
  interface DocumentResponse {
@@ -7006,6 +7020,18 @@ interface KnowledgeSearchResponse {
7006
7020
  total: number;
7007
7021
  }
7008
7022
 
7023
+ /**
7024
+ * `addDocumentFromFile` 입력 형식.
7025
+ *
7026
+ * - `File` (DOM) — 브라우저 `<input type="file">` 결과를 그대로 사용. name / type 이 자동 추출됨.
7027
+ * - `Blob` (DOM) — Blob.type 이 MIME 으로 사용됨 (없으면 서버 자동 추정).
7028
+ * - `{ data, mimeType?, name? }` — Node.js Buffer / Uint8Array. mimeType 명시 권장.
7029
+ */
7030
+ type KnowledgeFileInput = File | Blob | {
7031
+ data: Uint8Array | ArrayBuffer;
7032
+ mimeType?: string;
7033
+ name?: string;
7034
+ };
7009
7035
  /**
7010
7036
  * Knowledge Base API
7011
7037
  *
@@ -7073,6 +7099,50 @@ declare class KnowledgeAPI {
7073
7099
  * ```
7074
7100
  */
7075
7101
  addDocument(kbID: string, data: CreateDocumentRequest): Promise<DocumentResponse>;
7102
+ /**
7103
+ * 파일을 KB 에 추가 (PDF / DOCX / text 파일).
7104
+ *
7105
+ * 브라우저에서 `<input type="file">` 로 받은 `File` 또는 `Blob` 을 그대로 넘기면 SDK 가
7106
+ * base64 로 인코딩 + MIME 추정 후 서버에 보낸다. 서버는 PDF / DOCX / text 류를 자동
7107
+ * 텍스트 추출하여 기존 청킹·인덱싱 파이프라인을 태운다.
7108
+ *
7109
+ * 지원 MIME (2026-05 기준):
7110
+ * - `application/pdf` (텍스트 PDF — 스캔 이미지 PDF 는 미지원)
7111
+ * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX)
7112
+ * - `text/*` (plain / markdown / csv / html)
7113
+ * - `application/json`
7114
+ *
7115
+ * 비지원 MIME (이미지 OCR / 한글 HWP / XLSX 등) 은 향후 추가될 예정 — 현재는 명시적 에러.
7116
+ *
7117
+ * 파일 크기 상한: 50MB (원본 바이너리 기준).
7118
+ *
7119
+ * @param kbID - Knowledge Base ID
7120
+ * @param file - 업로드할 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
7121
+ * @param options - name 오버라이드 + metadata
7122
+ * @returns 생성된 문서 정보 (서버에서 status='processing' → 청킹 완료 후 'ready')
7123
+ *
7124
+ * @example
7125
+ * ```typescript
7126
+ * // 브라우저: <input type="file"> 로 받은 File
7127
+ * const file = event.target.files[0]
7128
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', file, {
7129
+ * metadata: { tag: 'manual' }
7130
+ * })
7131
+ *
7132
+ * // Node.js: fs.readFileSync 로 읽은 Buffer
7133
+ * import { readFileSync } from 'node:fs'
7134
+ * const data = readFileSync('./report.pdf')
7135
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', {
7136
+ * data,
7137
+ * mimeType: 'application/pdf',
7138
+ * name: 'report.pdf',
7139
+ * })
7140
+ * ```
7141
+ */
7142
+ addDocumentFromFile(kbID: string, file: KnowledgeFileInput, options?: {
7143
+ name?: string;
7144
+ metadata?: Record<string, unknown>;
7145
+ }): Promise<DocumentResponse>;
7076
7146
  /**
7077
7147
  * 문서 목록 조회
7078
7148
  *
package/dist/index.d.ts CHANGED
@@ -6938,6 +6938,20 @@ interface CreateDocumentRequest {
6938
6938
  source_type?: 'file' | 'text' | 'url';
6939
6939
  content?: string;
6940
6940
  source_url?: string;
6941
+ /**
6942
+ * source_type='file' 일 때 사용. 바이너리를 base64 로 인코딩해서 보낸다.
6943
+ * 서버가 PDF / DOCX / text 류를 자동으로 텍스트 추출 → 청킹·인덱싱 한다.
6944
+ * 파일 50MB 상한, 이미지 OCR / 스캔 PDF 는 미지원.
6945
+ * 일반적으로는 [`KnowledgeAPI.addDocumentFromFile`](../api/knowledge.ts) 헬퍼를 사용하면
6946
+ * Blob / File 로 직접 넘길 수 있다.
6947
+ */
6948
+ file_content?: string;
6949
+ /**
6950
+ * file_content 의 MIME (예: 'application/pdf',
6951
+ * 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/markdown').
6952
+ * 비어있으면 서버가 매직 바이트로 자동 추정 — 정확도를 위해 명시 권장.
6953
+ */
6954
+ mime_type?: string;
6941
6955
  metadata?: Record<string, unknown>;
6942
6956
  }
6943
6957
  interface DocumentResponse {
@@ -7006,6 +7020,18 @@ interface KnowledgeSearchResponse {
7006
7020
  total: number;
7007
7021
  }
7008
7022
 
7023
+ /**
7024
+ * `addDocumentFromFile` 입력 형식.
7025
+ *
7026
+ * - `File` (DOM) — 브라우저 `<input type="file">` 결과를 그대로 사용. name / type 이 자동 추출됨.
7027
+ * - `Blob` (DOM) — Blob.type 이 MIME 으로 사용됨 (없으면 서버 자동 추정).
7028
+ * - `{ data, mimeType?, name? }` — Node.js Buffer / Uint8Array. mimeType 명시 권장.
7029
+ */
7030
+ type KnowledgeFileInput = File | Blob | {
7031
+ data: Uint8Array | ArrayBuffer;
7032
+ mimeType?: string;
7033
+ name?: string;
7034
+ };
7009
7035
  /**
7010
7036
  * Knowledge Base API
7011
7037
  *
@@ -7073,6 +7099,50 @@ declare class KnowledgeAPI {
7073
7099
  * ```
7074
7100
  */
7075
7101
  addDocument(kbID: string, data: CreateDocumentRequest): Promise<DocumentResponse>;
7102
+ /**
7103
+ * 파일을 KB 에 추가 (PDF / DOCX / text 파일).
7104
+ *
7105
+ * 브라우저에서 `<input type="file">` 로 받은 `File` 또는 `Blob` 을 그대로 넘기면 SDK 가
7106
+ * base64 로 인코딩 + MIME 추정 후 서버에 보낸다. 서버는 PDF / DOCX / text 류를 자동
7107
+ * 텍스트 추출하여 기존 청킹·인덱싱 파이프라인을 태운다.
7108
+ *
7109
+ * 지원 MIME (2026-05 기준):
7110
+ * - `application/pdf` (텍스트 PDF — 스캔 이미지 PDF 는 미지원)
7111
+ * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX)
7112
+ * - `text/*` (plain / markdown / csv / html)
7113
+ * - `application/json`
7114
+ *
7115
+ * 비지원 MIME (이미지 OCR / 한글 HWP / XLSX 등) 은 향후 추가될 예정 — 현재는 명시적 에러.
7116
+ *
7117
+ * 파일 크기 상한: 50MB (원본 바이너리 기준).
7118
+ *
7119
+ * @param kbID - Knowledge Base ID
7120
+ * @param file - 업로드할 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
7121
+ * @param options - name 오버라이드 + metadata
7122
+ * @returns 생성된 문서 정보 (서버에서 status='processing' → 청킹 완료 후 'ready')
7123
+ *
7124
+ * @example
7125
+ * ```typescript
7126
+ * // 브라우저: <input type="file"> 로 받은 File
7127
+ * const file = event.target.files[0]
7128
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', file, {
7129
+ * metadata: { tag: 'manual' }
7130
+ * })
7131
+ *
7132
+ * // Node.js: fs.readFileSync 로 읽은 Buffer
7133
+ * import { readFileSync } from 'node:fs'
7134
+ * const data = readFileSync('./report.pdf')
7135
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', {
7136
+ * data,
7137
+ * mimeType: 'application/pdf',
7138
+ * name: 'report.pdf',
7139
+ * })
7140
+ * ```
7141
+ */
7142
+ addDocumentFromFile(kbID: string, file: KnowledgeFileInput, options?: {
7143
+ name?: string;
7144
+ metadata?: Record<string, unknown>;
7145
+ }): Promise<DocumentResponse>;
7076
7146
  /**
7077
7147
  * 문서 목록 조회
7078
7148
  *
package/dist/index.js CHANGED
@@ -7967,6 +7967,40 @@ var NativeAPI = class {
7967
7967
  };
7968
7968
 
7969
7969
  // src/api/knowledge.ts
7970
+ async function readFileInput(file) {
7971
+ if (typeof Blob !== "undefined" && file instanceof Blob) {
7972
+ const buffer = await file.arrayBuffer();
7973
+ const name = "name" in file ? file.name : void 0;
7974
+ return {
7975
+ data: bytesToBase64(new Uint8Array(buffer)),
7976
+ mimeType: file.type || "",
7977
+ defaultName: name
7978
+ };
7979
+ }
7980
+ const obj = file;
7981
+ if (!obj || obj.data === void 0) {
7982
+ throw new Error("addDocumentFromFile: file must be a Blob/File or { data, mimeType?, name? }");
7983
+ }
7984
+ const bytes = obj.data instanceof Uint8Array ? obj.data : new Uint8Array(obj.data);
7985
+ return {
7986
+ data: bytesToBase64(bytes),
7987
+ mimeType: obj.mimeType ?? "",
7988
+ defaultName: obj.name
7989
+ };
7990
+ }
7991
+ function bytesToBase64(bytes) {
7992
+ const g = globalThis;
7993
+ if (g.Buffer) {
7994
+ return g.Buffer.from(bytes).toString("base64");
7995
+ }
7996
+ const chunkSize = 8192;
7997
+ let binary = "";
7998
+ for (let i = 0; i < bytes.length; i += chunkSize) {
7999
+ const chunk = bytes.subarray(i, Math.min(i + chunkSize, bytes.length));
8000
+ binary += String.fromCharCode.apply(null, Array.from(chunk));
8001
+ }
8002
+ return btoa(binary);
8003
+ }
7970
8004
  var KnowledgeAPI = class {
7971
8005
  constructor(http) {
7972
8006
  this.http = http;
@@ -8004,6 +8038,57 @@ var KnowledgeAPI = class {
8004
8038
  data
8005
8039
  );
8006
8040
  }
8041
+ /**
8042
+ * 파일을 KB 에 추가 (PDF / DOCX / text 파일).
8043
+ *
8044
+ * 브라우저에서 `<input type="file">` 로 받은 `File` 또는 `Blob` 을 그대로 넘기면 SDK 가
8045
+ * base64 로 인코딩 + MIME 추정 후 서버에 보낸다. 서버는 PDF / DOCX / text 류를 자동
8046
+ * 텍스트 추출하여 기존 청킹·인덱싱 파이프라인을 태운다.
8047
+ *
8048
+ * 지원 MIME (2026-05 기준):
8049
+ * - `application/pdf` (텍스트 PDF — 스캔 이미지 PDF 는 미지원)
8050
+ * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX)
8051
+ * - `text/*` (plain / markdown / csv / html)
8052
+ * - `application/json`
8053
+ *
8054
+ * 비지원 MIME (이미지 OCR / 한글 HWP / XLSX 등) 은 향후 추가될 예정 — 현재는 명시적 에러.
8055
+ *
8056
+ * 파일 크기 상한: 50MB (원본 바이너리 기준).
8057
+ *
8058
+ * @param kbID - Knowledge Base ID
8059
+ * @param file - 업로드할 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
8060
+ * @param options - name 오버라이드 + metadata
8061
+ * @returns 생성된 문서 정보 (서버에서 status='processing' → 청킹 완료 후 'ready')
8062
+ *
8063
+ * @example
8064
+ * ```typescript
8065
+ * // 브라우저: <input type="file"> 로 받은 File
8066
+ * const file = event.target.files[0]
8067
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', file, {
8068
+ * metadata: { tag: 'manual' }
8069
+ * })
8070
+ *
8071
+ * // Node.js: fs.readFileSync 로 읽은 Buffer
8072
+ * import { readFileSync } from 'node:fs'
8073
+ * const data = readFileSync('./report.pdf')
8074
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', {
8075
+ * data,
8076
+ * mimeType: 'application/pdf',
8077
+ * name: 'report.pdf',
8078
+ * })
8079
+ * ```
8080
+ */
8081
+ async addDocumentFromFile(kbID, file, options) {
8082
+ const { data, mimeType, defaultName } = await readFileInput(file);
8083
+ const name = options?.name ?? defaultName ?? "document";
8084
+ return this.addDocument(kbID, {
8085
+ name,
8086
+ source_type: "file",
8087
+ file_content: data,
8088
+ mime_type: mimeType,
8089
+ metadata: options?.metadata
8090
+ });
8091
+ }
8007
8092
  /**
8008
8093
  * 문서 목록 조회
8009
8094
  *
package/dist/index.mjs CHANGED
@@ -7924,6 +7924,40 @@ var NativeAPI = class {
7924
7924
  };
7925
7925
 
7926
7926
  // src/api/knowledge.ts
7927
+ async function readFileInput(file) {
7928
+ if (typeof Blob !== "undefined" && file instanceof Blob) {
7929
+ const buffer = await file.arrayBuffer();
7930
+ const name = "name" in file ? file.name : void 0;
7931
+ return {
7932
+ data: bytesToBase64(new Uint8Array(buffer)),
7933
+ mimeType: file.type || "",
7934
+ defaultName: name
7935
+ };
7936
+ }
7937
+ const obj = file;
7938
+ if (!obj || obj.data === void 0) {
7939
+ throw new Error("addDocumentFromFile: file must be a Blob/File or { data, mimeType?, name? }");
7940
+ }
7941
+ const bytes = obj.data instanceof Uint8Array ? obj.data : new Uint8Array(obj.data);
7942
+ return {
7943
+ data: bytesToBase64(bytes),
7944
+ mimeType: obj.mimeType ?? "",
7945
+ defaultName: obj.name
7946
+ };
7947
+ }
7948
+ function bytesToBase64(bytes) {
7949
+ const g = globalThis;
7950
+ if (g.Buffer) {
7951
+ return g.Buffer.from(bytes).toString("base64");
7952
+ }
7953
+ const chunkSize = 8192;
7954
+ let binary = "";
7955
+ for (let i = 0; i < bytes.length; i += chunkSize) {
7956
+ const chunk = bytes.subarray(i, Math.min(i + chunkSize, bytes.length));
7957
+ binary += String.fromCharCode.apply(null, Array.from(chunk));
7958
+ }
7959
+ return btoa(binary);
7960
+ }
7927
7961
  var KnowledgeAPI = class {
7928
7962
  constructor(http) {
7929
7963
  this.http = http;
@@ -7961,6 +7995,57 @@ var KnowledgeAPI = class {
7961
7995
  data
7962
7996
  );
7963
7997
  }
7998
+ /**
7999
+ * 파일을 KB 에 추가 (PDF / DOCX / text 파일).
8000
+ *
8001
+ * 브라우저에서 `<input type="file">` 로 받은 `File` 또는 `Blob` 을 그대로 넘기면 SDK 가
8002
+ * base64 로 인코딩 + MIME 추정 후 서버에 보낸다. 서버는 PDF / DOCX / text 류를 자동
8003
+ * 텍스트 추출하여 기존 청킹·인덱싱 파이프라인을 태운다.
8004
+ *
8005
+ * 지원 MIME (2026-05 기준):
8006
+ * - `application/pdf` (텍스트 PDF — 스캔 이미지 PDF 는 미지원)
8007
+ * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX)
8008
+ * - `text/*` (plain / markdown / csv / html)
8009
+ * - `application/json`
8010
+ *
8011
+ * 비지원 MIME (이미지 OCR / 한글 HWP / XLSX 등) 은 향후 추가될 예정 — 현재는 명시적 에러.
8012
+ *
8013
+ * 파일 크기 상한: 50MB (원본 바이너리 기준).
8014
+ *
8015
+ * @param kbID - Knowledge Base ID
8016
+ * @param file - 업로드할 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
8017
+ * @param options - name 오버라이드 + metadata
8018
+ * @returns 생성된 문서 정보 (서버에서 status='processing' → 청킹 완료 후 'ready')
8019
+ *
8020
+ * @example
8021
+ * ```typescript
8022
+ * // 브라우저: <input type="file"> 로 받은 File
8023
+ * const file = event.target.files[0]
8024
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', file, {
8025
+ * metadata: { tag: 'manual' }
8026
+ * })
8027
+ *
8028
+ * // Node.js: fs.readFileSync 로 읽은 Buffer
8029
+ * import { readFileSync } from 'node:fs'
8030
+ * const data = readFileSync('./report.pdf')
8031
+ * const doc = await cb.knowledge.addDocumentFromFile('kb-id', {
8032
+ * data,
8033
+ * mimeType: 'application/pdf',
8034
+ * name: 'report.pdf',
8035
+ * })
8036
+ * ```
8037
+ */
8038
+ async addDocumentFromFile(kbID, file, options) {
8039
+ const { data, mimeType, defaultName } = await readFileInput(file);
8040
+ const name = options?.name ?? defaultName ?? "document";
8041
+ return this.addDocument(kbID, {
8042
+ name,
8043
+ source_type: "file",
8044
+ file_content: data,
8045
+ mime_type: mimeType,
8046
+ metadata: options?.metadata
8047
+ });
8048
+ }
7964
8049
  /**
7965
8050
  * 문서 목록 조회
7966
8051
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "3.16.3",
3
+ "version": "3.17.1",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",