connectbase-client 0.6.38 → 0.7.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/connect-base.umd.js +2 -2
- package/dist/index.d.mts +304 -2
- package/dist/index.d.ts +304 -2
- package/dist/index.js +167 -0
- package/dist/index.mjs +167 -0
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -3923,6 +3923,15 @@ var PaymentAPI = class {
|
|
|
3923
3923
|
* successUrl: prepareResult.success_url,
|
|
3924
3924
|
* failUrl: prepareResult.fail_url
|
|
3925
3925
|
* })
|
|
3926
|
+
*
|
|
3927
|
+
* // Stripe 결제 플로우:
|
|
3928
|
+
* // const result = await client.payment.prepare({ amount: 1000, order_name: 'Product' })
|
|
3929
|
+
* // if (result.payment_provider === 'stripe') {
|
|
3930
|
+
* // const stripe = await loadStripe(result.stripe_publishable_key)
|
|
3931
|
+
* // const elements = stripe.elements({ clientSecret: result.stripe_client_secret })
|
|
3932
|
+
* // // Mount PaymentElement, then:
|
|
3933
|
+
* // // stripe.confirmPayment({ elements, redirect: 'if_required' })
|
|
3934
|
+
* // }
|
|
3926
3935
|
* ```
|
|
3927
3936
|
*/
|
|
3928
3937
|
async prepare(data) {
|
|
@@ -6631,6 +6640,162 @@ var NativeAPI = class {
|
|
|
6631
6640
|
}
|
|
6632
6641
|
};
|
|
6633
6642
|
|
|
6643
|
+
// src/api/knowledge.ts
|
|
6644
|
+
var KnowledgeAPI = class {
|
|
6645
|
+
constructor(http) {
|
|
6646
|
+
this.http = http;
|
|
6647
|
+
}
|
|
6648
|
+
// ========== Document ==========
|
|
6649
|
+
/**
|
|
6650
|
+
* 문서 추가
|
|
6651
|
+
*
|
|
6652
|
+
* 지식 베이스에 새 문서를 추가합니다. 텍스트 소스인 경우 즉시 처리됩니다.
|
|
6653
|
+
*
|
|
6654
|
+
* @param kbID - 지식 베이스 ID
|
|
6655
|
+
* @param data - 문서 생성 요청
|
|
6656
|
+
* @returns 생성된 문서 정보
|
|
6657
|
+
*
|
|
6658
|
+
* @example
|
|
6659
|
+
* ```typescript
|
|
6660
|
+
* // 텍스트 문서
|
|
6661
|
+
* const doc = await cb.knowledge.addDocument('kb-id', {
|
|
6662
|
+
* name: 'FAQ',
|
|
6663
|
+
* source_type: 'text',
|
|
6664
|
+
* content: '자주 묻는 질문들...'
|
|
6665
|
+
* })
|
|
6666
|
+
*
|
|
6667
|
+
* // URL에서 가져오기
|
|
6668
|
+
* const doc2 = await cb.knowledge.addDocument('kb-id', {
|
|
6669
|
+
* name: '도움말',
|
|
6670
|
+
* source_type: 'url',
|
|
6671
|
+
* source_url: 'https://example.com/help.html'
|
|
6672
|
+
* })
|
|
6673
|
+
* ```
|
|
6674
|
+
*/
|
|
6675
|
+
async addDocument(kbID, data) {
|
|
6676
|
+
return this.http.post(
|
|
6677
|
+
`/v1/public/knowledge-bases/${kbID}/documents`,
|
|
6678
|
+
data
|
|
6679
|
+
);
|
|
6680
|
+
}
|
|
6681
|
+
/**
|
|
6682
|
+
* 문서 목록 조회
|
|
6683
|
+
*
|
|
6684
|
+
* @param kbID - 지식 베이스 ID
|
|
6685
|
+
* @returns 문서 목록
|
|
6686
|
+
*/
|
|
6687
|
+
async listDocuments(kbID) {
|
|
6688
|
+
return this.http.get(
|
|
6689
|
+
`/v1/public/knowledge-bases/${kbID}/documents`
|
|
6690
|
+
);
|
|
6691
|
+
}
|
|
6692
|
+
/**
|
|
6693
|
+
* 문서 삭제
|
|
6694
|
+
*
|
|
6695
|
+
* 문서와 관련된 모든 청크도 함께 삭제됩니다.
|
|
6696
|
+
*
|
|
6697
|
+
* @param kbID - 지식 베이스 ID
|
|
6698
|
+
* @param docID - 문서 ID
|
|
6699
|
+
*/
|
|
6700
|
+
async deleteDocument(kbID, docID) {
|
|
6701
|
+
await this.http.delete(`/v1/public/knowledge-bases/${kbID}/documents/${docID}`);
|
|
6702
|
+
}
|
|
6703
|
+
// ========== Search ==========
|
|
6704
|
+
/**
|
|
6705
|
+
* 문서 검색
|
|
6706
|
+
*
|
|
6707
|
+
* 키워드 기반으로 관련 문서 청크를 검색합니다.
|
|
6708
|
+
* 제목, 내용, 키워드 필드에서 매칭되며 점수 기반으로 정렬됩니다.
|
|
6709
|
+
*
|
|
6710
|
+
* @param kbID - 지식 베이스 ID
|
|
6711
|
+
* @param request - 검색 요청
|
|
6712
|
+
* @returns 검색 결과
|
|
6713
|
+
*
|
|
6714
|
+
* @example
|
|
6715
|
+
* ```typescript
|
|
6716
|
+
* const results = await cb.knowledge.search('kb-id', {
|
|
6717
|
+
* query: '환불 신청 방법',
|
|
6718
|
+
* top_k: 5 // 상위 5개 결과
|
|
6719
|
+
* })
|
|
6720
|
+
*
|
|
6721
|
+
* for (const result of results.results) {
|
|
6722
|
+
* console.log(`[${result.score}] ${result.title}`)
|
|
6723
|
+
* console.log(result.content)
|
|
6724
|
+
* }
|
|
6725
|
+
* ```
|
|
6726
|
+
*/
|
|
6727
|
+
async search(kbID, request) {
|
|
6728
|
+
return this.http.post(
|
|
6729
|
+
`/v1/public/knowledge-bases/${kbID}/search`,
|
|
6730
|
+
request
|
|
6731
|
+
);
|
|
6732
|
+
}
|
|
6733
|
+
/**
|
|
6734
|
+
* 문서 검색 (GET 방식)
|
|
6735
|
+
*
|
|
6736
|
+
* 쿼리 파라미터로 검색합니다.
|
|
6737
|
+
*
|
|
6738
|
+
* @param kbID - 지식 베이스 ID
|
|
6739
|
+
* @param query - 검색 쿼리
|
|
6740
|
+
* @param topK - 반환할 결과 수 (기본값: 지식 베이스 설정)
|
|
6741
|
+
*/
|
|
6742
|
+
async searchGet(kbID, query, topK) {
|
|
6743
|
+
const params = new URLSearchParams({ query });
|
|
6744
|
+
if (topK) params.append("top_k", String(topK));
|
|
6745
|
+
return this.http.get(
|
|
6746
|
+
`/v1/public/knowledge-bases/${kbID}/search?${params.toString()}`
|
|
6747
|
+
);
|
|
6748
|
+
}
|
|
6749
|
+
};
|
|
6750
|
+
|
|
6751
|
+
// src/api/queue.ts
|
|
6752
|
+
var QueueAPI = class {
|
|
6753
|
+
constructor(http) {
|
|
6754
|
+
this.http = http;
|
|
6755
|
+
}
|
|
6756
|
+
/**
|
|
6757
|
+
* 메시지 발행
|
|
6758
|
+
*/
|
|
6759
|
+
async publish(queueID, data) {
|
|
6760
|
+
return this.http.post(`/v1/public/queues/${queueID}/messages`, data);
|
|
6761
|
+
}
|
|
6762
|
+
/**
|
|
6763
|
+
* 배치 메시지 발행 (최대 100개)
|
|
6764
|
+
*/
|
|
6765
|
+
async publishBatch(queueID, data) {
|
|
6766
|
+
return this.http.post(`/v1/public/queues/${queueID}/messages/batch`, data);
|
|
6767
|
+
}
|
|
6768
|
+
/**
|
|
6769
|
+
* 메시지 소비 (Pull 방식)
|
|
6770
|
+
*/
|
|
6771
|
+
async consume(queueID, options) {
|
|
6772
|
+
const params = new URLSearchParams();
|
|
6773
|
+
if (options?.max_messages) params.set("max_messages", String(options.max_messages));
|
|
6774
|
+
if (options?.visibility_timeout) params.set("visibility_timeout", String(options.visibility_timeout));
|
|
6775
|
+
const query = params.toString();
|
|
6776
|
+
return this.http.get(`/v1/public/queues/${queueID}/messages${query ? `?${query}` : ""}`);
|
|
6777
|
+
}
|
|
6778
|
+
/**
|
|
6779
|
+
* 메시지 처리 완료 확인 (Ack)
|
|
6780
|
+
*/
|
|
6781
|
+
async ack(queueID, messageIds) {
|
|
6782
|
+
const data = { message_ids: messageIds };
|
|
6783
|
+
return this.http.post(`/v1/public/queues/${queueID}/messages/ack`, data);
|
|
6784
|
+
}
|
|
6785
|
+
/**
|
|
6786
|
+
* 메시지 재시도 요청 (Nack)
|
|
6787
|
+
*/
|
|
6788
|
+
async nack(queueID, messageId, options) {
|
|
6789
|
+
return this.http.post(`/v1/public/queues/${queueID}/messages/${messageId}/nack`, options || {});
|
|
6790
|
+
}
|
|
6791
|
+
/**
|
|
6792
|
+
* 큐 정보 조회
|
|
6793
|
+
*/
|
|
6794
|
+
async getInfo(queueID) {
|
|
6795
|
+
return this.http.get(`/v1/public/queues/${queueID}`);
|
|
6796
|
+
}
|
|
6797
|
+
};
|
|
6798
|
+
|
|
6634
6799
|
// src/api/game-transport.ts
|
|
6635
6800
|
var WebTransportTransport = class {
|
|
6636
6801
|
constructor(config, onMessage, onClose, onError) {
|
|
@@ -7306,6 +7471,8 @@ var ConnectBase = class {
|
|
|
7306
7471
|
this.game = new GameAPI(this.http, config.gameUrl || DEFAULT_GAME_URL, config.appId);
|
|
7307
7472
|
this.ads = new AdsAPI(this.http);
|
|
7308
7473
|
this.native = new NativeAPI();
|
|
7474
|
+
this.knowledge = new KnowledgeAPI(this.http);
|
|
7475
|
+
this.queue = new QueueAPI(this.http);
|
|
7309
7476
|
}
|
|
7310
7477
|
/**
|
|
7311
7478
|
* 수동으로 토큰 설정 (기존 토큰으로 세션 복원 시)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "connectbase-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"dev": "tsup --watch",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"release": "pnpm build && npm publish --access public"
|
|
37
|
+
},
|
|
32
38
|
"keywords": [
|
|
33
39
|
"connect-base",
|
|
34
40
|
"baas",
|
|
@@ -52,11 +58,5 @@
|
|
|
52
58
|
},
|
|
53
59
|
"engines": {
|
|
54
60
|
"node": ">=16"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "tsup",
|
|
58
|
-
"dev": "tsup --watch",
|
|
59
|
-
"typecheck": "tsc --noEmit",
|
|
60
|
-
"release": "pnpm build && npm publish --access public"
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|