@chatbotkit/sdk 1.19.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/channel/index.cjs +18 -0
- package/dist/cjs/channel/index.d.ts +7 -0
- package/dist/cjs/channel/v1.cjs +22 -0
- package/dist/cjs/channel/v1.d.ts +12 -0
- package/dist/cjs/client.cjs +64 -51
- package/dist/cjs/client.d.ts +1 -13
- package/dist/cjs/contact/index.cjs +5 -3
- package/dist/cjs/contact/index.d.ts +3 -1
- package/dist/cjs/contact/space/index.cjs +15 -0
- package/dist/cjs/contact/space/index.d.ts +6 -0
- package/dist/cjs/contact/space/v1.cjs +8 -0
- package/dist/cjs/contact/space/v1.d.ts +11 -0
- package/dist/cjs/conversation/index.cjs +1 -1
- package/dist/cjs/conversation/v1.cjs +3 -3
- package/dist/cjs/conversation/v1.d.ts +37 -67
- package/dist/cjs/index.cjs +56 -47
- package/dist/cjs/index.d.ts +8 -2
- package/dist/cjs/param.cjs +1 -1
- package/dist/cjs/platform/content/doc/index.cjs +21 -0
- package/dist/cjs/platform/content/doc/index.d.ts +8 -0
- package/dist/cjs/platform/content/doc/v1.cjs +26 -0
- package/dist/cjs/platform/content/doc/v1.d.ts +19 -0
- package/dist/cjs/platform/content/index.cjs +15 -0
- package/dist/cjs/platform/content/index.d.ts +8 -0
- package/dist/cjs/platform/content/manual/index.cjs +21 -0
- package/dist/cjs/platform/content/manual/index.d.ts +8 -0
- package/dist/cjs/platform/content/manual/v1.cjs +26 -0
- package/dist/cjs/platform/content/manual/v1.d.ts +19 -0
- package/dist/cjs/platform/index.cjs +8 -6
- package/dist/cjs/platform/index.d.ts +2 -0
- package/dist/cjs/portal/index.cjs +27 -0
- package/dist/cjs/portal/index.d.ts +10 -0
- package/dist/cjs/portal/v1.cjs +42 -0
- package/dist/cjs/portal/v1.d.ts +28 -0
- package/dist/cjs/space/index.cjs +27 -0
- package/dist/cjs/space/index.d.ts +10 -0
- package/dist/cjs/space/v1.cjs +42 -0
- package/dist/cjs/space/v1.d.ts +28 -0
- package/dist/esm/channel/index.d.ts +7 -0
- package/dist/esm/channel/index.js +14 -0
- package/dist/esm/channel/v1.d.ts +12 -0
- package/dist/esm/channel/v1.js +18 -0
- package/dist/esm/client.d.ts +1 -13
- package/dist/esm/client.js +48 -32
- package/dist/esm/contact/index.d.ts +3 -1
- package/dist/esm/contact/index.js +3 -1
- package/dist/esm/contact/space/index.d.ts +6 -0
- package/dist/esm/contact/space/index.js +11 -0
- package/dist/esm/contact/space/v1.d.ts +11 -0
- package/dist/esm/contact/space/v1.js +5 -0
- package/dist/esm/conversation/index.js +1 -1
- package/dist/esm/conversation/v1.d.ts +37 -67
- package/dist/esm/conversation/v1.js +3 -3
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +10 -1
- package/dist/esm/platform/content/doc/index.d.ts +8 -0
- package/dist/esm/platform/content/doc/index.js +17 -0
- package/dist/esm/platform/content/doc/v1.d.ts +19 -0
- package/dist/esm/platform/content/doc/v1.js +21 -0
- package/dist/esm/platform/content/index.d.ts +8 -0
- package/dist/esm/platform/content/index.js +11 -0
- package/dist/esm/platform/content/manual/index.d.ts +8 -0
- package/dist/esm/platform/content/manual/index.js +17 -0
- package/dist/esm/platform/content/manual/v1.d.ts +19 -0
- package/dist/esm/platform/content/manual/v1.js +21 -0
- package/dist/esm/platform/index.d.ts +2 -0
- package/dist/esm/platform/index.js +2 -0
- package/dist/esm/portal/index.d.ts +10 -0
- package/dist/esm/portal/index.js +23 -0
- package/dist/esm/portal/v1.d.ts +28 -0
- package/dist/esm/portal/v1.js +35 -0
- package/dist/esm/space/index.d.ts +10 -0
- package/dist/esm/space/index.js +23 -0
- package/dist/esm/space/v1.d.ts +28 -0
- package/dist/esm/space/v1.js +35 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +331 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelClient = void 0;
|
|
4
|
+
const client_js_1 = require("../client.cjs");
|
|
5
|
+
const v1_js_1 = require("./v1.cjs");
|
|
6
|
+
class ChannelClient extends client_js_1.ChatBotKitClient {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
}
|
|
10
|
+
publish(channelId, request) {
|
|
11
|
+
return (0, v1_js_1.publishChannelMessage)(this, channelId, request);
|
|
12
|
+
}
|
|
13
|
+
subscribe(channelId, request) {
|
|
14
|
+
return (0, v1_js_1.subscribeChannelMessages)(this, channelId, request);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ChannelClient = ChannelClient;
|
|
18
|
+
exports.default = ChannelClient;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export class ChannelClient extends ChatBotKitClient {
|
|
2
|
+
publish(channelId: string, request: import("./v1.js").ChannelPublishRequest): Promise<import("./v1.js").ChannelPublishResponse>;
|
|
3
|
+
subscribe(channelId: string, request?: import("./v1.js").ChannelSubscribeRequest): ResponsePromise<never, import("./v1.js").ChannelSubscribeStreamType>;
|
|
4
|
+
}
|
|
5
|
+
export default ChannelClient;
|
|
6
|
+
export type ResponsePromise<T, U> = import("../client.js").ResponsePromise<T, U>;
|
|
7
|
+
import { ChatBotKitClient } from '../client.cjs';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishChannelMessage = publishChannelMessage;
|
|
4
|
+
exports.subscribeChannelMessages = subscribeChannelMessages;
|
|
5
|
+
async function publishChannelMessage(client, channelId, request) {
|
|
6
|
+
const url = `/api/v1/channel/${channelId}/publish`;
|
|
7
|
+
const response = await client.clientFetch(url, {
|
|
8
|
+
record: {
|
|
9
|
+
...request,
|
|
10
|
+
},
|
|
11
|
+
endpoint: '/api/v1/channel/{channelId}/publish',
|
|
12
|
+
});
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
function subscribeChannelMessages(client, channelId, request) {
|
|
16
|
+
const url = `/api/v1/channel/${channelId}/subscribe`;
|
|
17
|
+
const response = client.clientFetch(url, {
|
|
18
|
+
record: request || {},
|
|
19
|
+
endpoint: '/api/v1/channel/{channelId}/subscribe',
|
|
20
|
+
});
|
|
21
|
+
return response;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function publishChannelMessage(client: ChatBotKitClient, channelId: string, request: ChannelPublishRequest): Promise<ChannelPublishResponse>;
|
|
2
|
+
export function subscribeChannelMessages(client: ChatBotKitClient, channelId: string, request?: ChannelSubscribeRequest): ResponsePromise<never, ChannelSubscribeStreamType>;
|
|
3
|
+
export type ChatBotKitClient = import("../client.js").ChatBotKitClient;
|
|
4
|
+
export type ResponsePromise<T, U> = import("../client.js").ResponsePromise<T, U>;
|
|
5
|
+
export type ChannelPublishRequestBody = import("../types/api/v1.js").operations["publishChannelMessage"]["requestBody"]["content"]["application/json"];
|
|
6
|
+
export type ChannelPublishRequest = ChannelPublishRequestBody;
|
|
7
|
+
export type ChannelPublishResponseBody = import("../types/api/v1.js").operations["publishChannelMessage"]["responses"]["200"]["content"]["application/json"];
|
|
8
|
+
export type ChannelPublishResponse = ChannelPublishResponseBody;
|
|
9
|
+
export type ChannelSubscribeRequestBody = import("../types/api/v1.js").operations["subscribeChannelMessages"]["requestBody"]["content"]["application/json"];
|
|
10
|
+
export type ChannelSubscribeRequest = ChannelSubscribeRequestBody;
|
|
11
|
+
export type ChannelSubscribeResponseBody = import("../types/api/v1.js").operations["subscribeChannelMessages"]["responses"]["200"]["content"]["application/jsonl"];
|
|
12
|
+
export type ChannelSubscribeStreamType = ChannelSubscribeResponseBody;
|
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 = {
|
|
@@ -4,14 +4,16 @@ exports.ContactClient = void 0;
|
|
|
4
4
|
const client_js_1 = require("../client.cjs");
|
|
5
5
|
const index_js_1 = require("./conversation/index.cjs");
|
|
6
6
|
const index_js_2 = require("./secret/index.cjs");
|
|
7
|
-
const index_js_3 = require("./
|
|
7
|
+
const index_js_3 = require("./space/index.cjs");
|
|
8
|
+
const index_js_4 = require("./task/index.cjs");
|
|
8
9
|
const v1_js_1 = require("./v1.cjs");
|
|
9
10
|
class ContactClient extends client_js_1.ChatBotKitClient {
|
|
10
11
|
constructor(options) {
|
|
11
12
|
super(options);
|
|
12
|
-
this.task = new
|
|
13
|
+
this.task = new index_js_4.TaskClient(options);
|
|
14
|
+
this.space = new index_js_3.SpaceClient(options);
|
|
13
15
|
this.conversation = new index_js_1.ConversationClient(options);
|
|
14
|
-
this.
|
|
16
|
+
this.secret = new index_js_2.SecretClient(options);
|
|
15
17
|
}
|
|
16
18
|
list(request) {
|
|
17
19
|
return (0, v1_js_1.listContacts)(this, request);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export class ContactClient extends ChatBotKitClient {
|
|
2
2
|
task: TaskClient;
|
|
3
|
+
space: SpaceClient;
|
|
3
4
|
conversation: ConversationClient;
|
|
4
|
-
|
|
5
|
+
secret: SecretClient;
|
|
5
6
|
list(request?: import("./v1.js").ContactListRequest): ResponsePromise<import("./v1.js").ContactListResponse, import("./v1.js").ContactListStreamType>;
|
|
6
7
|
fetch(contactId: string): ResponsePromise<import("./v1.js").ContactFetchResponse, never>;
|
|
7
8
|
create(request: import("./v1.js").ContactCreateRequest): Promise<import("./v1.js").ContactCreateResponse>;
|
|
@@ -13,5 +14,6 @@ export default ContactClient;
|
|
|
13
14
|
export type ResponsePromise<T, U> = import("../client.js").ResponsePromise<T, U>;
|
|
14
15
|
import { ChatBotKitClient } from '../client.cjs';
|
|
15
16
|
import { TaskClient } from './task/index.cjs';
|
|
17
|
+
import { SpaceClient } from './space/index.cjs';
|
|
16
18
|
import { ConversationClient } from './conversation/index.cjs';
|
|
17
19
|
import { SecretClient } from './secret/index.cjs';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpaceClient = void 0;
|
|
4
|
+
const client_js_1 = require("../../client.cjs");
|
|
5
|
+
const v1_js_1 = require("./v1.cjs");
|
|
6
|
+
class SpaceClient extends client_js_1.ChatBotKitClient {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
}
|
|
10
|
+
list(contactId, request) {
|
|
11
|
+
return (0, v1_js_1.listSpaces)(this, contactId, request);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SpaceClient = SpaceClient;
|
|
15
|
+
exports.default = SpaceClient;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export class SpaceClient extends ChatBotKitClient {
|
|
2
|
+
list(contactId: string, request?: import("./v1.js").SpaceListRequest): ResponsePromise<import("./v1.js").SpaceListResponse, import("./v1.js").SpaceListStreamType>;
|
|
3
|
+
}
|
|
4
|
+
export default SpaceClient;
|
|
5
|
+
export type ResponsePromise<T, U> = import("../../client.js").ResponsePromise<T, U>;
|
|
6
|
+
import { ChatBotKitClient } from '../../client.cjs';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listSpaces = listSpaces;
|
|
4
|
+
function listSpaces(client, contactId, request) {
|
|
5
|
+
let url = `/api/v1/contact/${contactId}/space/list`;
|
|
6
|
+
const response = client.clientFetch(url, { query: request });
|
|
7
|
+
return response;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function listSpaces(client: ChatBotKitClient, contactId: string, request?: SpaceListRequest): ResponsePromise<SpaceListResponse, SpaceListStreamType>;
|
|
2
|
+
export type ChatBotKitClient = import("../../client.js").ChatBotKitClient;
|
|
3
|
+
export type ResponsePromise<T, U> = import("../../client.js").ResponsePromise<T, U>;
|
|
4
|
+
export type SpaceListRequest = {
|
|
5
|
+
cursor?: string;
|
|
6
|
+
order?: "desc" | "asc";
|
|
7
|
+
take?: number;
|
|
8
|
+
meta?: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
export type SpaceListResponse = import("../../types/api/v1.js").operations["listContactSpaces"]["responses"]["200"]["content"]["application/json"];
|
|
11
|
+
export type SpaceListStreamType = import("../../types/api/v1.js").operations["listContactSpaces"]["responses"]["200"]["content"]["application/jsonl"];
|
|
@@ -29,7 +29,7 @@ class ConversationClient extends client_js_1.ChatBotKitClient {
|
|
|
29
29
|
return (0, v1_js_1.deleteConversation)(this, conversationId);
|
|
30
30
|
}
|
|
31
31
|
complete(conversationId, request) {
|
|
32
|
-
if (
|
|
32
|
+
if (conversationId === null) {
|
|
33
33
|
return (0, v1_js_1.completeConversation)(this, (request));
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
@@ -58,7 +58,9 @@ function completeConversation(client, request) {
|
|
|
58
58
|
const response = client.clientFetch(url, {
|
|
59
59
|
record: {
|
|
60
60
|
...request,
|
|
61
|
-
model:
|
|
61
|
+
model: 'model' in request && request.model
|
|
62
|
+
? (0, v1_js_1.buildModelString)(request.model)
|
|
63
|
+
: undefined,
|
|
62
64
|
},
|
|
63
65
|
});
|
|
64
66
|
return response;
|
|
@@ -97,7 +99,6 @@ async function upvoteConversation(client, conversationId, request) {
|
|
|
97
99
|
const url = `/api/v1/conversation/${conversationId}/upvote`;
|
|
98
100
|
const response = await client.clientFetch(url, {
|
|
99
101
|
record: {
|
|
100
|
-
value: 100,
|
|
101
102
|
...request,
|
|
102
103
|
},
|
|
103
104
|
endpoint: '/api/v1/conversation/{conversationId}/upvote',
|
|
@@ -108,7 +109,6 @@ async function downvoteConversation(client, conversationId, request) {
|
|
|
108
109
|
const url = `/api/v1/conversation/${conversationId}/downvote`;
|
|
109
110
|
const response = await client.clientFetch(url, {
|
|
110
111
|
record: {
|
|
111
|
-
value: -100,
|
|
112
112
|
...request,
|
|
113
113
|
},
|
|
114
114
|
endpoint: '/api/v1/conversation/{conversationId}/downvote',
|
|
@@ -37,81 +37,51 @@ export type ConversationListRequest = {
|
|
|
37
37
|
export type ConversationListResponse = import("../types/api/v1.js").operations["listConversations"]["responses"]["200"]["content"]["application/json"];
|
|
38
38
|
export type ConversationListStreamType = import("../types/api/v1.js").operations["listConversations"]["responses"]["200"]["content"]["application/jsonl"];
|
|
39
39
|
export type ConversationFetchResponse = import("../types/api/v1.js").operations["fetchConversation"]["responses"]["200"]["content"]["application/json"];
|
|
40
|
-
export type
|
|
41
|
-
name?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
contactId?: string;
|
|
44
|
-
taskId?: string;
|
|
45
|
-
botId?: string;
|
|
46
|
-
backstory?: string;
|
|
40
|
+
export type ConversationCreateRequestBody = Omit<import("../types/api/v1.js").operations["createConversation"]["requestBody"]["content"]["application/json"], "model"> & {
|
|
47
41
|
model?: string | import("../model/v1.js").Model;
|
|
48
|
-
datasetId?: string;
|
|
49
|
-
skillsetId?: string;
|
|
50
|
-
meta?: Record<string, any>;
|
|
51
42
|
};
|
|
52
|
-
export type
|
|
53
|
-
export type
|
|
54
|
-
export type
|
|
55
|
-
|
|
56
|
-
description?: string;
|
|
57
|
-
contactId?: string;
|
|
58
|
-
taskId?: string;
|
|
59
|
-
botId?: string;
|
|
60
|
-
backstory?: string;
|
|
43
|
+
export type ConversationCreateRequest = ConversationCreateRequestBody;
|
|
44
|
+
export type ConversationCreateResponseBody = import("../types/api/v1.js").operations["createConversation"]["responses"]["200"]["content"]["application/json"];
|
|
45
|
+
export type ConversationCreateResponse = ConversationCreateResponseBody;
|
|
46
|
+
export type ConversationUpdateRequestBody = Omit<import("../types/api/v1.js").operations["updateConversation"]["requestBody"]["content"]["application/json"], "model"> & {
|
|
61
47
|
model?: string | import("../model/v1.js").Model;
|
|
62
|
-
datasetId?: string;
|
|
63
|
-
skillsetId?: string;
|
|
64
|
-
meta?: Record<string, any>;
|
|
65
48
|
};
|
|
66
|
-
export type
|
|
67
|
-
export type
|
|
49
|
+
export type ConversationUpdateRequest = ConversationUpdateRequestBody;
|
|
50
|
+
export type ConversationUpdateResponseBody = import("../types/api/v1.js").operations["updateConversation"]["responses"]["200"]["content"]["application/json"];
|
|
51
|
+
export type ConversationUpdateResponse = ConversationUpdateResponseBody;
|
|
68
52
|
export type ConversationDeleteRequestBody = import("../types/api/v1.js").operations["deleteConversation"]["requestBody"]["content"]["application/json"];
|
|
69
|
-
export type
|
|
70
|
-
export type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
name: string;
|
|
81
|
-
description: string;
|
|
82
|
-
parameters: any;
|
|
83
|
-
}[];
|
|
84
|
-
} & ({
|
|
85
|
-
text: string;
|
|
86
|
-
} | {
|
|
87
|
-
messages: Message[];
|
|
88
|
-
});
|
|
89
|
-
export type ConversationCompleteResponse = import("../types/api/v1.js").operations["completeConversation"]["responses"]["200"]["content"]["application/json"];
|
|
53
|
+
export type ConversationDeleteRequest = ConversationDeleteRequestBody;
|
|
54
|
+
export type ConversationDeleteResponseBody = import("../types/api/v1.js").operations["deleteConversation"]["responses"]["200"]["content"]["application/json"];
|
|
55
|
+
export type ConversationDeleteResponse = ConversationDeleteResponseBody;
|
|
56
|
+
export type ConversationCompleteRequestBody = import("../types/api/v1.js").operations["completeConversation"]["requestBody"]["content"]["application/json"];
|
|
57
|
+
export type ConversationCompleteRequest = ConversationCompleteRequestBody extends infer U ? U extends any ? U extends {
|
|
58
|
+
model?: any;
|
|
59
|
+
} ? Omit<U, "model"> & {
|
|
60
|
+
model?: string | import("../model/v1.js").Model;
|
|
61
|
+
} : U : never : never;
|
|
62
|
+
export type ConversationCompleteResponseBody = import("../types/api/v1.js").operations["completeConversation"]["responses"]["200"]["content"]["application/json"];
|
|
63
|
+
export type ConversationCompleteResponse = ConversationCompleteResponseBody;
|
|
90
64
|
export type ConversationCompleteStreamType = import("../types/api/v1.js").operations["completeConversation"]["responses"]["200"]["content"]["application/jsonl"];
|
|
91
|
-
export type
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export type ConversationCompleteMessageResponse = import("../types/api/v1.js").operations["completeConversationMessage"]["responses"]["200"]["content"]["application/json"];
|
|
65
|
+
export type ConversationCompleteMessageRequestBody = import("../types/api/v1.js").operations["completeConversationMessage"]["requestBody"]["content"]["application/json"];
|
|
66
|
+
export type ConversationCompleteMessageRequest = ConversationCompleteMessageRequestBody;
|
|
67
|
+
export type ConversationCompleteMessageResponseBody = import("../types/api/v1.js").operations["completeConversationMessage"]["responses"]["200"]["content"]["application/json"];
|
|
68
|
+
export type ConversationCompleteMessageResponse = ConversationCompleteMessageResponseBody;
|
|
96
69
|
export type ConversationCompleteMessageStreamType = import("../types/api/v1.js").operations["completeConversationMessage"]["responses"]["200"]["content"]["application/jsonl"];
|
|
97
|
-
export type
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export type ConversationSendMessageResponse = import("../types/api/v1.js").operations["sendConversationMessage"]["responses"]["200"]["content"]["application/json"];
|
|
70
|
+
export type ConversationSendMessageRequestBody = import("../types/api/v1.js").operations["sendConversationMessage"]["requestBody"]["content"]["application/json"];
|
|
71
|
+
export type ConversationSendMessageRequest = ConversationSendMessageRequestBody;
|
|
72
|
+
export type ConversationSendMessageResponseBody = import("../types/api/v1.js").operations["sendConversationMessage"]["responses"]["200"]["content"]["application/json"];
|
|
73
|
+
export type ConversationSendMessageResponse = ConversationSendMessageResponseBody;
|
|
102
74
|
export type ConversationSendMessageStreamType = import("../types/api/v1.js").operations["sendConversationMessage"]["responses"]["200"]["content"]["application/jsonl"];
|
|
103
|
-
export type
|
|
104
|
-
export type
|
|
75
|
+
export type ConversationReceiveMessageRequestBody = import("../types/api/v1.js").operations["receiveConversationMessage"]["requestBody"]["content"]["application/json"];
|
|
76
|
+
export type ConversationReceiveMessageRequest = ConversationReceiveMessageRequestBody;
|
|
77
|
+
export type ConversationReceiveMessageResponseBody = import("../types/api/v1.js").operations["receiveConversationMessage"]["responses"]["200"]["content"]["application/json"];
|
|
78
|
+
export type ConversationReceiveMessageResponse = ConversationReceiveMessageResponseBody;
|
|
105
79
|
export type ConversationReceiveMessageStreamType = import("../types/api/v1.js").operations["receiveConversationMessage"]["responses"]["200"]["content"]["application/jsonl"];
|
|
106
|
-
export type ConversationUpvoteRequest = {
|
|
107
|
-
value?: number;
|
|
108
|
-
reason?: string;
|
|
109
|
-
};
|
|
110
80
|
export type ConversationUpvoteRequestBody = import("../types/api/v1.js").operations["upvoteConversation"]["requestBody"]["content"]["application/json"];
|
|
111
|
-
export type
|
|
112
|
-
export type
|
|
113
|
-
|
|
114
|
-
reason?: string;
|
|
115
|
-
};
|
|
81
|
+
export type ConversationUpvoteRequest = ConversationUpvoteRequestBody;
|
|
82
|
+
export type ConversationUpvoteResponseBody = import("../types/api/v1.js").operations["upvoteConversation"]["responses"]["200"]["content"]["application/json"];
|
|
83
|
+
export type ConversationUpvoteResponse = ConversationUpvoteResponseBody;
|
|
116
84
|
export type ConversationDownvoteRequestBody = import("../types/api/v1.js").operations["downvoteConversation"]["requestBody"]["content"]["application/json"];
|
|
117
|
-
export type
|
|
85
|
+
export type ConversationDownvoteRequest = ConversationDownvoteRequestBody;
|
|
86
|
+
export type ConversationDownvoteResponseBody = import("../types/api/v1.js").operations["downvoteConversation"]["responses"]["200"]["content"]["application/json"];
|
|
87
|
+
export type ConversationDownvoteResponse = ConversationDownvoteResponseBody;
|