@chatbotkit/sdk 1.20.0 → 1.21.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/cjs/client.cjs +64 -51
- package/dist/cjs/client.d.ts +1 -13
- package/dist/cjs/contact/index.cjs +1 -1
- package/dist/cjs/contact/index.d.ts +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/param.cjs +1 -1
- package/dist/cjs/platform/content/doc/index.cjs +3 -0
- package/dist/cjs/platform/content/doc/index.d.ts +1 -0
- package/dist/cjs/platform/content/doc/v1.cjs +10 -0
- package/dist/cjs/platform/content/doc/v1.d.ts +5 -0
- package/dist/cjs/platform/content/manual/index.cjs +3 -0
- package/dist/cjs/platform/content/manual/index.d.ts +1 -0
- package/dist/cjs/platform/content/manual/v1.cjs +10 -0
- package/dist/cjs/platform/content/manual/v1.d.ts +5 -0
- package/dist/esm/client.d.ts +1 -13
- package/dist/esm/client.js +48 -32
- package/dist/esm/contact/index.d.ts +1 -1
- package/dist/esm/contact/index.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/platform/content/doc/index.d.ts +1 -0
- package/dist/esm/platform/content/doc/index.js +4 -1
- package/dist/esm/platform/content/doc/v1.d.ts +5 -0
- package/dist/esm/platform/content/doc/v1.js +9 -0
- package/dist/esm/platform/content/manual/index.d.ts +1 -0
- package/dist/esm/platform/content/manual/index.js +4 -1
- package/dist/esm/platform/content/manual/v1.d.ts +5 -0
- package/dist/esm/platform/content/manual/v1.js +9 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/cjs/client.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _ChatBotKitClient_secret, _ChatBotKitClient_url, _ChatBotKitClient_endpoints, _ChatBotKitClient_runAsUserId, _ChatBotKitClient_runAsChildUserEmail, _ChatBotKitClient_timezone, _ChatBotKitClient_headers, _ChatBotKitClient_timeout, _ChatBotKitClient_retries, _ChatBotKitClient_retryDelay, _ChatBotKitClient_retryTimeout, _ChatBotKitClient_fetchFn, _ChatBotKitClient_cacheMap;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.ChatBotKitClient = exports.ResponsePromise = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
4
6
|
const fetch_1 = require("@chatbotkit/fetch");
|
|
5
7
|
const fetchPlusPlus = (0, fetch_1.withRetry)((0, fetch_1.withTimeout)(fetch_1.fetch, { timeout: Infinity }), {
|
|
6
8
|
retries: 3,
|
|
@@ -30,25 +32,24 @@ class ResponsePromise {
|
|
|
30
32
|
return 'ResponsePromise';
|
|
31
33
|
}
|
|
32
34
|
async getRequest(params) {
|
|
33
|
-
var _a, _b, _c, _d;
|
|
34
35
|
let body;
|
|
35
36
|
const { method, headers, data, timeout, retries, retryDelay, retryTimeout, fetchFn, } = this.request;
|
|
36
37
|
if (data) {
|
|
37
|
-
body =
|
|
38
|
+
body = params?.data || data;
|
|
38
39
|
}
|
|
39
40
|
const url = this.url.toString();
|
|
40
|
-
const response = await (
|
|
41
|
-
method:
|
|
41
|
+
const response = await (params?.fetchFn || fetchFn || fetchPlusPlus)(url, {
|
|
42
|
+
method: params?.method || method,
|
|
42
43
|
headers: {
|
|
43
44
|
...headers,
|
|
44
|
-
...params
|
|
45
|
+
...params?.headers,
|
|
45
46
|
},
|
|
46
47
|
body,
|
|
47
48
|
...{
|
|
48
|
-
timeout:
|
|
49
|
-
retries:
|
|
50
|
-
retryDelay:
|
|
51
|
-
retryTimeout:
|
|
49
|
+
timeout: params?.timeout ?? timeout,
|
|
50
|
+
retries: params?.retries ?? retries,
|
|
51
|
+
retryDelay: params?.retryDelay ?? retryDelay,
|
|
52
|
+
retryTimeout: params?.retryTimeout ?? retryTimeout,
|
|
52
53
|
},
|
|
53
54
|
mode: 'cors',
|
|
54
55
|
cache: 'no-cache',
|
|
@@ -127,10 +128,9 @@ class ResponsePromise {
|
|
|
127
128
|
yield* (0, fetch_1.jsonl)(response.body);
|
|
128
129
|
}
|
|
129
130
|
async cache(key = 'default') {
|
|
130
|
-
var _a;
|
|
131
131
|
const cacheKey = JSON.stringify({
|
|
132
132
|
key,
|
|
133
|
-
method:
|
|
133
|
+
method: this.request?.method || 'GET',
|
|
134
134
|
url: this.url.toString(),
|
|
135
135
|
});
|
|
136
136
|
if (!this.cacheMap.has(cacheKey)) {
|
|
@@ -154,35 +154,47 @@ class ResponsePromise {
|
|
|
154
154
|
exports.ResponsePromise = ResponsePromise;
|
|
155
155
|
class ChatBotKitClient {
|
|
156
156
|
constructor(options) {
|
|
157
|
-
this
|
|
158
|
-
this
|
|
157
|
+
_ChatBotKitClient_secret.set(this, null);
|
|
158
|
+
_ChatBotKitClient_url.set(this, void 0);
|
|
159
|
+
_ChatBotKitClient_endpoints.set(this, void 0);
|
|
160
|
+
_ChatBotKitClient_runAsUserId.set(this, void 0);
|
|
161
|
+
_ChatBotKitClient_runAsChildUserEmail.set(this, void 0);
|
|
162
|
+
_ChatBotKitClient_timezone.set(this, void 0);
|
|
163
|
+
_ChatBotKitClient_headers.set(this, void 0);
|
|
164
|
+
_ChatBotKitClient_timeout.set(this, void 0);
|
|
165
|
+
_ChatBotKitClient_retries.set(this, void 0);
|
|
166
|
+
_ChatBotKitClient_retryDelay.set(this, void 0);
|
|
167
|
+
_ChatBotKitClient_retryTimeout.set(this, void 0);
|
|
168
|
+
_ChatBotKitClient_fetchFn.set(this, void 0);
|
|
169
|
+
_ChatBotKitClient_cacheMap.set(this, void 0);
|
|
170
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_secret, options.secret, "f");
|
|
171
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_url, new URL(`https://api.chatbotkit.com`), "f");
|
|
159
172
|
if (options.host) {
|
|
160
|
-
this.
|
|
173
|
+
tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_url, "f").host = options.host;
|
|
161
174
|
}
|
|
162
175
|
if (options.protocol) {
|
|
163
|
-
this.
|
|
164
|
-
}
|
|
165
|
-
this
|
|
166
|
-
this
|
|
167
|
-
this
|
|
168
|
-
this
|
|
169
|
-
this
|
|
170
|
-
this
|
|
171
|
-
this
|
|
172
|
-
this
|
|
173
|
-
this
|
|
174
|
-
this
|
|
175
|
-
this
|
|
176
|
+
tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_url, "f").protocol = options.protocol;
|
|
177
|
+
}
|
|
178
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_endpoints, options.endpoints || {}, "f");
|
|
179
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_runAsUserId, options.runAsUserId, "f");
|
|
180
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_runAsChildUserEmail, options.runAsChildUserEmail, "f");
|
|
181
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_timezone, options.timezone, "f");
|
|
182
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_headers, options.headers || {}, "f");
|
|
183
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_timeout, options.timeout, "f");
|
|
184
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_retries, options.retries, "f");
|
|
185
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_retryDelay, options.retryDelay, "f");
|
|
186
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_retryTimeout, options.retryTimeout, "f");
|
|
187
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_fetchFn, options.fetchFn || fetchPlusPlus, "f");
|
|
188
|
+
tslib_1.__classPrivateFieldSet(this, _ChatBotKitClient_cacheMap, new Map(), "f");
|
|
176
189
|
}
|
|
177
190
|
clientFetch(path, options) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const url = new URL(this.endpoints[(options === null || options === void 0 ? void 0 : options.endpoint) || path] || path, this.url);
|
|
191
|
+
let method = options?.method;
|
|
192
|
+
const url = new URL(tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_endpoints, "f")[options?.endpoint || path] || path, tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_url, "f"));
|
|
181
193
|
if (url.hostname === 'api.chatbotkit.com' &&
|
|
182
194
|
url.pathname.startsWith('/api/')) {
|
|
183
195
|
url.pathname = url.pathname.substring(4);
|
|
184
196
|
}
|
|
185
|
-
if (options
|
|
197
|
+
if (options?.query) {
|
|
186
198
|
for (const key in options.query) {
|
|
187
199
|
const value = options.query[key];
|
|
188
200
|
if (typeof value === 'object') {
|
|
@@ -201,34 +213,34 @@ class ChatBotKitClient {
|
|
|
201
213
|
}
|
|
202
214
|
}
|
|
203
215
|
const headers = {
|
|
204
|
-
...this
|
|
216
|
+
...tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f"),
|
|
205
217
|
};
|
|
206
|
-
if (!
|
|
207
|
-
if (this
|
|
208
|
-
headers['authorization'] = `Bearer ${this
|
|
218
|
+
if (!options?.external) {
|
|
219
|
+
if (tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")) {
|
|
220
|
+
headers['authorization'] = `Bearer ${tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")}`;
|
|
209
221
|
}
|
|
210
|
-
if (this
|
|
211
|
-
headers['x-runas-user-id'] = this
|
|
222
|
+
if (tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f")) {
|
|
223
|
+
headers['x-runas-user-id'] = tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f");
|
|
212
224
|
}
|
|
213
|
-
if (this
|
|
214
|
-
headers['x-runas-child-user-email'] = this
|
|
225
|
+
if (tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f")) {
|
|
226
|
+
headers['x-runas-child-user-email'] = tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f");
|
|
215
227
|
}
|
|
216
228
|
}
|
|
217
|
-
if (this
|
|
218
|
-
headers['x-timezone'] = this
|
|
229
|
+
if (tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f")) {
|
|
230
|
+
headers['x-timezone'] = tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f");
|
|
219
231
|
}
|
|
220
232
|
let data;
|
|
221
|
-
if (options
|
|
233
|
+
if (options?.record) {
|
|
222
234
|
method = method || 'POST';
|
|
223
235
|
data = JSON.stringify(options.record);
|
|
224
236
|
headers['content-type'] = 'application/json';
|
|
225
237
|
}
|
|
226
|
-
else if (options
|
|
238
|
+
else if (options?.buffer) {
|
|
227
239
|
method = method || 'POST';
|
|
228
240
|
data = options.buffer;
|
|
229
241
|
headers['content-type'] = 'application/octet-stream';
|
|
230
242
|
}
|
|
231
|
-
else if (options
|
|
243
|
+
else if (options?.file) {
|
|
232
244
|
method = method || 'POST';
|
|
233
245
|
data = new fetch_1.FormData();
|
|
234
246
|
data.append('file', new fetch_1.Blob([options.file.data], { type: options.file.type }), options.file.name);
|
|
@@ -236,20 +248,21 @@ class ChatBotKitClient {
|
|
|
236
248
|
else {
|
|
237
249
|
method = method || 'GET';
|
|
238
250
|
}
|
|
239
|
-
if (options
|
|
251
|
+
if (options?.headers) {
|
|
240
252
|
Object.assign(headers, options.headers);
|
|
241
253
|
}
|
|
242
254
|
const request = {
|
|
243
255
|
method,
|
|
244
256
|
headers,
|
|
245
257
|
data,
|
|
246
|
-
timeout:
|
|
247
|
-
retries:
|
|
248
|
-
retryDelay:
|
|
249
|
-
retryTimeout:
|
|
250
|
-
fetchFn:
|
|
258
|
+
timeout: options?.timeout ?? tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_timeout, "f"),
|
|
259
|
+
retries: options?.retries ?? tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_retries, "f"),
|
|
260
|
+
retryDelay: options?.retryDelay ?? tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_retryDelay, "f"),
|
|
261
|
+
retryTimeout: options?.retryTimeout ?? tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_retryTimeout, "f"),
|
|
262
|
+
fetchFn: options?.fetchFn || tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_fetchFn, "f"),
|
|
251
263
|
};
|
|
252
|
-
return new ResponsePromise(url, request, this
|
|
264
|
+
return new ResponsePromise(url, request, tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_cacheMap, "f"));
|
|
253
265
|
}
|
|
254
266
|
}
|
|
255
267
|
exports.ChatBotKitClient = ChatBotKitClient;
|
|
268
|
+
_ChatBotKitClient_secret = new WeakMap(), _ChatBotKitClient_url = new WeakMap(), _ChatBotKitClient_endpoints = new WeakMap(), _ChatBotKitClient_runAsUserId = new WeakMap(), _ChatBotKitClient_runAsChildUserEmail = new WeakMap(), _ChatBotKitClient_timezone = new WeakMap(), _ChatBotKitClient_headers = new WeakMap(), _ChatBotKitClient_timeout = new WeakMap(), _ChatBotKitClient_retries = new WeakMap(), _ChatBotKitClient_retryDelay = new WeakMap(), _ChatBotKitClient_retryTimeout = new WeakMap(), _ChatBotKitClient_fetchFn = new WeakMap(), _ChatBotKitClient_cacheMap = new WeakMap();
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -45,19 +45,6 @@ export class ResponsePromise<T, U> {
|
|
|
45
45
|
}
|
|
46
46
|
export class ChatBotKitClient {
|
|
47
47
|
constructor(options: ChatBotKitClientOptions);
|
|
48
|
-
secret: string;
|
|
49
|
-
url: URL;
|
|
50
|
-
endpoints: Record<string, string>;
|
|
51
|
-
runAsUserId: string;
|
|
52
|
-
runAsChildUserEmail: string;
|
|
53
|
-
timezone: string;
|
|
54
|
-
headers: Record<string, string>;
|
|
55
|
-
timeout: number;
|
|
56
|
-
retries: number;
|
|
57
|
-
retryDelay: number;
|
|
58
|
-
retryTimeout: boolean;
|
|
59
|
-
fetchFn: FetchFunction;
|
|
60
|
-
cacheMap: Map<any, any>;
|
|
61
48
|
clientFetch<T, U>(path: string, options?: {
|
|
62
49
|
method?: string;
|
|
63
50
|
headers?: Record<string, any>;
|
|
@@ -77,6 +64,7 @@ export class ChatBotKitClient {
|
|
|
77
64
|
retryTimeout?: boolean;
|
|
78
65
|
fetchFn?: FetchFunction;
|
|
79
66
|
}): ResponsePromise<T, U>;
|
|
67
|
+
#private;
|
|
80
68
|
}
|
|
81
69
|
export type FetchFunction = import("@chatbotkit/fetch").FetchFn<import("@chatbotkit/fetch").withRetryOptions & import("@chatbotkit/fetch").withTimeoutOptions>;
|
|
82
70
|
export type ChatBotKitClientOptions = {
|
|
@@ -13,7 +13,7 @@ class ContactClient extends client_js_1.ChatBotKitClient {
|
|
|
13
13
|
this.task = new index_js_4.TaskClient(options);
|
|
14
14
|
this.space = new index_js_3.SpaceClient(options);
|
|
15
15
|
this.conversation = new index_js_1.ConversationClient(options);
|
|
16
|
-
this.
|
|
16
|
+
this.secret = new index_js_2.SecretClient(options);
|
|
17
17
|
}
|
|
18
18
|
list(request) {
|
|
19
19
|
return (0, v1_js_1.listContacts)(this, request);
|
|
@@ -2,7 +2,7 @@ export class ContactClient extends ChatBotKitClient {
|
|
|
2
2
|
task: TaskClient;
|
|
3
3
|
space: SpaceClient;
|
|
4
4
|
conversation: ConversationClient;
|
|
5
|
-
|
|
5
|
+
secret: SecretClient;
|
|
6
6
|
list(request?: import("./v1.js").ContactListRequest): ResponsePromise<import("./v1.js").ContactListResponse, import("./v1.js").ContactListStreamType>;
|
|
7
7
|
fetch(contactId: string): ResponsePromise<import("./v1.js").ContactFetchResponse, never>;
|
|
8
8
|
create(request: import("./v1.js").ContactCreateRequest): Promise<import("./v1.js").ContactCreateResponse>;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ class ChatBotKit extends client_js_1.ChatBotKitClient {
|
|
|
50
50
|
this.bot = new index_js_2.BotClient(options);
|
|
51
51
|
this.channel = new index_js_3.ChannelClient(options);
|
|
52
52
|
this.file = new index_js_7.FileClient(options);
|
|
53
|
+
this.secret = new index_js_16.SecretClient(options);
|
|
53
54
|
this.magic = new index_js_10.MagicClient(options);
|
|
54
55
|
this.partner = new index_js_12.PartnerClient(options);
|
|
55
56
|
this.dataset = new index_js_6.DatasetClient(options);
|
|
@@ -64,7 +65,6 @@ class ChatBotKit extends client_js_1.ChatBotKitClient {
|
|
|
64
65
|
this.policy = new index_js_14.PolicyClient(options);
|
|
65
66
|
this.portal = new index_js_15.PortalClient(options);
|
|
66
67
|
this.usage = new index_js_21.UsageClient(options);
|
|
67
|
-
this.secrets = new index_js_16.SecretClient(options);
|
|
68
68
|
this.graphql = new index_js_8.GraphqlClient(options);
|
|
69
69
|
}
|
|
70
70
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
4
4
|
bot: BotClient;
|
|
5
5
|
channel: ChannelClient;
|
|
6
6
|
file: FileClient;
|
|
7
|
+
secret: SecretClient;
|
|
7
8
|
magic: MagicClient;
|
|
8
9
|
partner: PartnerClient;
|
|
9
10
|
dataset: DatasetClient;
|
|
@@ -18,7 +19,6 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
18
19
|
policy: PolicyClient;
|
|
19
20
|
portal: PortalClient;
|
|
20
21
|
usage: UsageClient;
|
|
21
|
-
secrets: SecretClient;
|
|
22
22
|
graphql: GraphqlClient;
|
|
23
23
|
}
|
|
24
24
|
export default ChatBotKit;
|
package/dist/cjs/param.cjs
CHANGED
|
@@ -5,7 +5,7 @@ function buildParamString(name, params, defaultParams) {
|
|
|
5
5
|
const parts = [];
|
|
6
6
|
for (const [name, value] of Object.entries(params || {})) {
|
|
7
7
|
if (value) {
|
|
8
|
-
if (
|
|
8
|
+
if (defaultParams?.[name] != value) {
|
|
9
9
|
parts.push(`${name}=${value}`);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -10,6 +10,9 @@ class PlatformContentDocClient extends client_js_1.ChatBotKitClient {
|
|
|
10
10
|
list(request) {
|
|
11
11
|
return (0, v1_js_1.listPlatformContentDocs)(this, request);
|
|
12
12
|
}
|
|
13
|
+
search(request) {
|
|
14
|
+
return (0, v1_js_1.searchPlatformContentDocs)(this, request);
|
|
15
|
+
}
|
|
13
16
|
fetch(docId) {
|
|
14
17
|
return (0, v1_js_1.fetchPlatformContentDoc)(this, docId);
|
|
15
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class PlatformContentDocClient extends ChatBotKitClient {
|
|
2
2
|
list(request?: import("./v1.js").PlatformContentDocListRequest): ResponsePromise<import("./v1.js").PlatformContentDocListResponse, import("./v1.js").PlatformContentDocListStreamType>;
|
|
3
|
+
search(request: import("./v1.js").PlatformContentDocSearchRequest): Promise<import("./v1.js").PlatformContentDocSearchResponse>;
|
|
3
4
|
fetch(docId: string): ResponsePromise<import("./v1.js").PlatformContentDocFetchResponse, never>;
|
|
4
5
|
}
|
|
5
6
|
export default PlatformContentDocClient;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listPlatformContentDocs = listPlatformContentDocs;
|
|
4
|
+
exports.searchPlatformContentDocs = searchPlatformContentDocs;
|
|
4
5
|
exports.fetchPlatformContentDoc = fetchPlatformContentDoc;
|
|
5
6
|
function listPlatformContentDocs(client, request) {
|
|
6
7
|
let url = `/api/v1/platform/content/doc/list`;
|
|
7
8
|
const response = client.clientFetch(url, { query: request });
|
|
8
9
|
return response;
|
|
9
10
|
}
|
|
11
|
+
async function searchPlatformContentDocs(client, request) {
|
|
12
|
+
const url = `/api/v1/platform/content/doc/search`;
|
|
13
|
+
const response = await client.clientFetch(url, {
|
|
14
|
+
record: {
|
|
15
|
+
...request,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
10
20
|
function fetchPlatformContentDoc(client, docId) {
|
|
11
21
|
const url = `/api/v1/platform/content/doc/${docId}/fetch`;
|
|
12
22
|
const response = client.clientFetch(url, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function listPlatformContentDocs(client: ChatBotKitClient, request?: PlatformContentDocListRequest): ResponsePromise<PlatformContentDocListResponse, PlatformContentDocListStreamType>;
|
|
2
|
+
export function searchPlatformContentDocs(client: ChatBotKitClient, request: PlatformContentDocSearchRequest): Promise<PlatformContentDocSearchResponse>;
|
|
2
3
|
export function fetchPlatformContentDoc(client: ChatBotKitClient, docId: string): ResponsePromise<PlatformContentDocFetchResponse, never>;
|
|
3
4
|
export type ChatBotKitClient = import("../../../client.js").ChatBotKitClient;
|
|
4
5
|
export type ResponsePromise<T, U> = import("../../../client.js").ResponsePromise<T, U>;
|
|
@@ -11,4 +12,8 @@ export type PlatformContentDocListRequest = {
|
|
|
11
12
|
export type PlatformContentDocListResponse = import("../../../types/api/v1.js").operations["listPlatformContentDocs"]["responses"]["200"]["content"]["application/json"];
|
|
12
13
|
export type PlatformContentDocListItem = PlatformContentDocListResponse["items"][number];
|
|
13
14
|
export type PlatformContentDocListStreamType = import("../../../types/api/v1.js").operations["listPlatformContentDocs"]["responses"]["200"]["content"]["application/jsonl"];
|
|
15
|
+
export type PlatformContentDocSearchRequestBody = import("../../../types/api/v1.js").operations["searchPlatformContentDocs"]["requestBody"]["content"]["application/json"];
|
|
16
|
+
export type PlatformContentDocSearchRequest = PlatformContentDocSearchRequestBody;
|
|
17
|
+
export type PlatformContentDocSearchResponseBody = import("../../../types/api/v1.js").operations["searchPlatformContentDocs"]["responses"]["200"]["content"]["application/json"];
|
|
18
|
+
export type PlatformContentDocSearchResponse = PlatformContentDocSearchResponseBody;
|
|
14
19
|
export type PlatformContentDocFetchResponse = import("../../../types/api/v1.js").operations["fetchPlatformContentDoc"]["responses"]["200"]["content"]["application/json"];
|
|
@@ -10,6 +10,9 @@ class PlatformContentManualClient extends client_js_1.ChatBotKitClient {
|
|
|
10
10
|
list(request) {
|
|
11
11
|
return (0, v1_js_1.listPlatformContentManuals)(this, request);
|
|
12
12
|
}
|
|
13
|
+
search(request) {
|
|
14
|
+
return (0, v1_js_1.searchPlatformContentManuals)(this, request);
|
|
15
|
+
}
|
|
13
16
|
fetch(manualId) {
|
|
14
17
|
return (0, v1_js_1.fetchPlatformContentManual)(this, manualId);
|
|
15
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class PlatformContentManualClient extends ChatBotKitClient {
|
|
2
2
|
list(request?: import("./v1.js").PlatformContentManualListRequest): ResponsePromise<import("./v1.js").PlatformContentManualListResponse, import("./v1.js").PlatformContentManualListStreamType>;
|
|
3
|
+
search(request: import("./v1.js").PlatformContentManualSearchRequest): Promise<import("./v1.js").PlatformContentManualSearchResponse>;
|
|
3
4
|
fetch(manualId: string): ResponsePromise<import("./v1.js").PlatformContentManualFetchResponse, never>;
|
|
4
5
|
}
|
|
5
6
|
export default PlatformContentManualClient;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listPlatformContentManuals = listPlatformContentManuals;
|
|
4
|
+
exports.searchPlatformContentManuals = searchPlatformContentManuals;
|
|
4
5
|
exports.fetchPlatformContentManual = fetchPlatformContentManual;
|
|
5
6
|
function listPlatformContentManuals(client, request) {
|
|
6
7
|
let url = `/api/v1/platform/content/manual/list`;
|
|
7
8
|
const response = client.clientFetch(url, { query: request });
|
|
8
9
|
return response;
|
|
9
10
|
}
|
|
11
|
+
async function searchPlatformContentManuals(client, request) {
|
|
12
|
+
const url = `/api/v1/platform/content/manual/search`;
|
|
13
|
+
const response = await client.clientFetch(url, {
|
|
14
|
+
record: {
|
|
15
|
+
...request,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
10
20
|
function fetchPlatformContentManual(client, manualId) {
|
|
11
21
|
const url = `/api/v1/platform/content/manual/${manualId}/fetch`;
|
|
12
22
|
const response = client.clientFetch(url, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function listPlatformContentManuals(client: ChatBotKitClient, request?: PlatformContentManualListRequest): ResponsePromise<PlatformContentManualListResponse, PlatformContentManualListStreamType>;
|
|
2
|
+
export function searchPlatformContentManuals(client: ChatBotKitClient, request: PlatformContentManualSearchRequest): Promise<PlatformContentManualSearchResponse>;
|
|
2
3
|
export function fetchPlatformContentManual(client: ChatBotKitClient, manualId: string): ResponsePromise<PlatformContentManualFetchResponse, never>;
|
|
3
4
|
export type ChatBotKitClient = import("../../../client.js").ChatBotKitClient;
|
|
4
5
|
export type ResponsePromise<T, U> = import("../../../client.js").ResponsePromise<T, U>;
|
|
@@ -11,4 +12,8 @@ export type PlatformContentManualListRequest = {
|
|
|
11
12
|
export type PlatformContentManualListResponse = import("../../../types/api/v1.js").operations["listPlatformContentManuals"]["responses"]["200"]["content"]["application/json"];
|
|
12
13
|
export type PlatformContentManualListItem = PlatformContentManualListResponse["items"][number];
|
|
13
14
|
export type PlatformContentManualListStreamType = import("../../../types/api/v1.js").operations["listPlatformContentManuals"]["responses"]["200"]["content"]["application/jsonl"];
|
|
15
|
+
export type PlatformContentManualSearchRequestBody = import("../../../types/api/v1.js").operations["searchPlatformContentManuals"]["requestBody"]["content"]["application/json"];
|
|
16
|
+
export type PlatformContentManualSearchRequest = PlatformContentManualSearchRequestBody;
|
|
17
|
+
export type PlatformContentManualSearchResponseBody = import("../../../types/api/v1.js").operations["searchPlatformContentManuals"]["responses"]["200"]["content"]["application/json"];
|
|
18
|
+
export type PlatformContentManualSearchResponse = PlatformContentManualSearchResponseBody;
|
|
14
19
|
export type PlatformContentManualFetchResponse = import("../../../types/api/v1.js").operations["fetchPlatformContentManual"]["responses"]["200"]["content"]["application/json"];
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -45,19 +45,6 @@ export class ResponsePromise<T, U> {
|
|
|
45
45
|
}
|
|
46
46
|
export class ChatBotKitClient {
|
|
47
47
|
constructor(options: ChatBotKitClientOptions);
|
|
48
|
-
secret: string;
|
|
49
|
-
url: URL;
|
|
50
|
-
endpoints: Record<string, string>;
|
|
51
|
-
runAsUserId: string | undefined;
|
|
52
|
-
runAsChildUserEmail: string | undefined;
|
|
53
|
-
timezone: string | undefined;
|
|
54
|
-
headers: Record<string, string>;
|
|
55
|
-
timeout: number | undefined;
|
|
56
|
-
retries: number | undefined;
|
|
57
|
-
retryDelay: number | undefined;
|
|
58
|
-
retryTimeout: boolean | undefined;
|
|
59
|
-
fetchFn: FetchFunction;
|
|
60
|
-
cacheMap: Map<any, any>;
|
|
61
48
|
clientFetch<T, U>(path: string, options?: {
|
|
62
49
|
method?: string;
|
|
63
50
|
headers?: Record<string, any>;
|
|
@@ -77,6 +64,7 @@ export class ChatBotKitClient {
|
|
|
77
64
|
retryTimeout?: boolean;
|
|
78
65
|
fetchFn?: FetchFunction;
|
|
79
66
|
}): ResponsePromise<T, U>;
|
|
67
|
+
#private;
|
|
80
68
|
}
|
|
81
69
|
export type FetchFunction = import("@chatbotkit/fetch").FetchFn<import("@chatbotkit/fetch").withRetryOptions & import("@chatbotkit/fetch").withTimeoutOptions>;
|
|
82
70
|
export type ChatBotKitClientOptions = {
|
package/dist/esm/client.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var _ChatBotKitClient_secret, _ChatBotKitClient_url, _ChatBotKitClient_endpoints, _ChatBotKitClient_runAsUserId, _ChatBotKitClient_runAsChildUserEmail, _ChatBotKitClient_timezone, _ChatBotKitClient_headers, _ChatBotKitClient_timeout, _ChatBotKitClient_retries, _ChatBotKitClient_retryDelay, _ChatBotKitClient_retryTimeout, _ChatBotKitClient_fetchFn, _ChatBotKitClient_cacheMap;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
import { Blob, FetchError, FormData, fetch, jsonl, withRetry, withTimeout, } from '@chatbotkit/fetch';
|
|
2
4
|
const fetchPlusPlus = withRetry(withTimeout(fetch, { timeout: Infinity }), {
|
|
3
5
|
retries: 3,
|
|
@@ -148,29 +150,42 @@ export class ResponsePromise {
|
|
|
148
150
|
}
|
|
149
151
|
export class ChatBotKitClient {
|
|
150
152
|
constructor(options) {
|
|
151
|
-
this
|
|
152
|
-
this
|
|
153
|
+
_ChatBotKitClient_secret.set(this, null);
|
|
154
|
+
_ChatBotKitClient_url.set(this, void 0);
|
|
155
|
+
_ChatBotKitClient_endpoints.set(this, void 0);
|
|
156
|
+
_ChatBotKitClient_runAsUserId.set(this, void 0);
|
|
157
|
+
_ChatBotKitClient_runAsChildUserEmail.set(this, void 0);
|
|
158
|
+
_ChatBotKitClient_timezone.set(this, void 0);
|
|
159
|
+
_ChatBotKitClient_headers.set(this, void 0);
|
|
160
|
+
_ChatBotKitClient_timeout.set(this, void 0);
|
|
161
|
+
_ChatBotKitClient_retries.set(this, void 0);
|
|
162
|
+
_ChatBotKitClient_retryDelay.set(this, void 0);
|
|
163
|
+
_ChatBotKitClient_retryTimeout.set(this, void 0);
|
|
164
|
+
_ChatBotKitClient_fetchFn.set(this, void 0);
|
|
165
|
+
_ChatBotKitClient_cacheMap.set(this, void 0);
|
|
166
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_secret, options.secret, "f");
|
|
167
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_url, new URL(`https://api.chatbotkit.com`), "f");
|
|
153
168
|
if (options.host) {
|
|
154
|
-
this.
|
|
169
|
+
__classPrivateFieldGet(this, _ChatBotKitClient_url, "f").host = options.host;
|
|
155
170
|
}
|
|
156
171
|
if (options.protocol) {
|
|
157
|
-
this.
|
|
158
|
-
}
|
|
159
|
-
this
|
|
160
|
-
this
|
|
161
|
-
this
|
|
162
|
-
this
|
|
163
|
-
this
|
|
164
|
-
this
|
|
165
|
-
this
|
|
166
|
-
this
|
|
167
|
-
this
|
|
168
|
-
this
|
|
169
|
-
this
|
|
172
|
+
__classPrivateFieldGet(this, _ChatBotKitClient_url, "f").protocol = options.protocol;
|
|
173
|
+
}
|
|
174
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_endpoints, options.endpoints || {}, "f");
|
|
175
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_runAsUserId, options.runAsUserId, "f");
|
|
176
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_runAsChildUserEmail, options.runAsChildUserEmail, "f");
|
|
177
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_timezone, options.timezone, "f");
|
|
178
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_headers, options.headers || {}, "f");
|
|
179
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_timeout, options.timeout, "f");
|
|
180
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_retries, options.retries, "f");
|
|
181
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_retryDelay, options.retryDelay, "f");
|
|
182
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_retryTimeout, options.retryTimeout, "f");
|
|
183
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_fetchFn, options.fetchFn || fetchPlusPlus, "f");
|
|
184
|
+
__classPrivateFieldSet(this, _ChatBotKitClient_cacheMap, new Map(), "f");
|
|
170
185
|
}
|
|
171
186
|
clientFetch(path, options) {
|
|
172
187
|
let method = options?.method;
|
|
173
|
-
const url = new URL(this
|
|
188
|
+
const url = new URL(__classPrivateFieldGet(this, _ChatBotKitClient_endpoints, "f")[options?.endpoint || path] || path, __classPrivateFieldGet(this, _ChatBotKitClient_url, "f"));
|
|
174
189
|
if (url.hostname === 'api.chatbotkit.com' &&
|
|
175
190
|
url.pathname.startsWith('/api/')) {
|
|
176
191
|
url.pathname = url.pathname.substring(4);
|
|
@@ -194,21 +209,21 @@ export class ChatBotKitClient {
|
|
|
194
209
|
}
|
|
195
210
|
}
|
|
196
211
|
const headers = {
|
|
197
|
-
...this
|
|
212
|
+
...__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f"),
|
|
198
213
|
};
|
|
199
214
|
if (!options?.external) {
|
|
200
|
-
if (this
|
|
201
|
-
headers['authorization'] = `Bearer ${this
|
|
215
|
+
if (__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")) {
|
|
216
|
+
headers['authorization'] = `Bearer ${__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")}`;
|
|
202
217
|
}
|
|
203
|
-
if (this
|
|
204
|
-
headers['x-runas-user-id'] = this
|
|
218
|
+
if (__classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f")) {
|
|
219
|
+
headers['x-runas-user-id'] = __classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f");
|
|
205
220
|
}
|
|
206
|
-
if (this
|
|
207
|
-
headers['x-runas-child-user-email'] = this
|
|
221
|
+
if (__classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f")) {
|
|
222
|
+
headers['x-runas-child-user-email'] = __classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f");
|
|
208
223
|
}
|
|
209
224
|
}
|
|
210
|
-
if (this
|
|
211
|
-
headers['x-timezone'] = this
|
|
225
|
+
if (__classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f")) {
|
|
226
|
+
headers['x-timezone'] = __classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f");
|
|
212
227
|
}
|
|
213
228
|
let data;
|
|
214
229
|
if (options?.record) {
|
|
@@ -236,12 +251,13 @@ export class ChatBotKitClient {
|
|
|
236
251
|
method,
|
|
237
252
|
headers,
|
|
238
253
|
data,
|
|
239
|
-
timeout: options?.timeout ?? this
|
|
240
|
-
retries: options?.retries ?? this
|
|
241
|
-
retryDelay: options?.retryDelay ?? this
|
|
242
|
-
retryTimeout: options?.retryTimeout ?? this
|
|
243
|
-
fetchFn: options?.fetchFn || this
|
|
254
|
+
timeout: options?.timeout ?? __classPrivateFieldGet(this, _ChatBotKitClient_timeout, "f"),
|
|
255
|
+
retries: options?.retries ?? __classPrivateFieldGet(this, _ChatBotKitClient_retries, "f"),
|
|
256
|
+
retryDelay: options?.retryDelay ?? __classPrivateFieldGet(this, _ChatBotKitClient_retryDelay, "f"),
|
|
257
|
+
retryTimeout: options?.retryTimeout ?? __classPrivateFieldGet(this, _ChatBotKitClient_retryTimeout, "f"),
|
|
258
|
+
fetchFn: options?.fetchFn || __classPrivateFieldGet(this, _ChatBotKitClient_fetchFn, "f"),
|
|
244
259
|
};
|
|
245
|
-
return new ResponsePromise(url, request, this
|
|
260
|
+
return new ResponsePromise(url, request, __classPrivateFieldGet(this, _ChatBotKitClient_cacheMap, "f"));
|
|
246
261
|
}
|
|
247
262
|
}
|
|
263
|
+
_ChatBotKitClient_secret = new WeakMap(), _ChatBotKitClient_url = new WeakMap(), _ChatBotKitClient_endpoints = new WeakMap(), _ChatBotKitClient_runAsUserId = new WeakMap(), _ChatBotKitClient_runAsChildUserEmail = new WeakMap(), _ChatBotKitClient_timezone = new WeakMap(), _ChatBotKitClient_headers = new WeakMap(), _ChatBotKitClient_timeout = new WeakMap(), _ChatBotKitClient_retries = new WeakMap(), _ChatBotKitClient_retryDelay = new WeakMap(), _ChatBotKitClient_retryTimeout = new WeakMap(), _ChatBotKitClient_fetchFn = new WeakMap(), _ChatBotKitClient_cacheMap = new WeakMap();
|
|
@@ -2,7 +2,7 @@ export class ContactClient extends ChatBotKitClient {
|
|
|
2
2
|
task: TaskClient;
|
|
3
3
|
space: SpaceClient;
|
|
4
4
|
conversation: ConversationClient;
|
|
5
|
-
|
|
5
|
+
secret: SecretClient;
|
|
6
6
|
list(request?: import("./v1.js").ContactListRequest): ResponsePromise<import("./v1.js").ContactListResponse, import("./v1.js").ContactListStreamType>;
|
|
7
7
|
fetch(contactId: string): ResponsePromise<import("./v1.js").ContactFetchResponse, never>;
|
|
8
8
|
create(request: import("./v1.js").ContactCreateRequest): Promise<import("./v1.js").ContactCreateResponse>;
|
|
@@ -10,7 +10,7 @@ export class ContactClient extends ChatBotKitClient {
|
|
|
10
10
|
this.task = new TaskClient(options);
|
|
11
11
|
this.space = new SpaceClient(options);
|
|
12
12
|
this.conversation = new ConversationClient(options);
|
|
13
|
-
this.
|
|
13
|
+
this.secret = new SecretClient(options);
|
|
14
14
|
}
|
|
15
15
|
list(request) {
|
|
16
16
|
return listContacts(this, request);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
4
4
|
bot: BotClient;
|
|
5
5
|
channel: ChannelClient;
|
|
6
6
|
file: FileClient;
|
|
7
|
+
secret: SecretClient;
|
|
7
8
|
magic: MagicClient;
|
|
8
9
|
partner: PartnerClient;
|
|
9
10
|
dataset: DatasetClient;
|
|
@@ -18,7 +19,6 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
18
19
|
policy: PolicyClient;
|
|
19
20
|
portal: PortalClient;
|
|
20
21
|
usage: UsageClient;
|
|
21
|
-
secrets: SecretClient;
|
|
22
22
|
graphql: GraphqlClient;
|
|
23
23
|
}
|
|
24
24
|
export default ChatBotKit;
|
package/dist/esm/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
47
47
|
this.bot = new BotClient(options);
|
|
48
48
|
this.channel = new ChannelClient(options);
|
|
49
49
|
this.file = new FileClient(options);
|
|
50
|
+
this.secret = new SecretClient(options);
|
|
50
51
|
this.magic = new MagicClient(options);
|
|
51
52
|
this.partner = new PartnerClient(options);
|
|
52
53
|
this.dataset = new DatasetClient(options);
|
|
@@ -61,7 +62,6 @@ export class ChatBotKit extends ChatBotKitClient {
|
|
|
61
62
|
this.policy = new PolicyClient(options);
|
|
62
63
|
this.portal = new PortalClient(options);
|
|
63
64
|
this.usage = new UsageClient(options);
|
|
64
|
-
this.secrets = new SecretClient(options);
|
|
65
65
|
this.graphql = new GraphqlClient(options);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class PlatformContentDocClient extends ChatBotKitClient {
|
|
2
2
|
list(request?: import("./v1.js").PlatformContentDocListRequest): ResponsePromise<import("./v1.js").PlatformContentDocListResponse, import("./v1.js").PlatformContentDocListStreamType>;
|
|
3
|
+
search(request: import("./v1.js").PlatformContentDocSearchRequest): Promise<import("./v1.js").PlatformContentDocSearchResponse>;
|
|
3
4
|
fetch(docId: string): ResponsePromise<import("./v1.js").PlatformContentDocFetchResponse, never>;
|
|
4
5
|
}
|
|
5
6
|
export default PlatformContentDocClient;
|