@chatbotkit/sdk 1.20.0 → 1.21.5

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.
@@ -1,3 +1,5 @@
1
+ var _ChatBotKitClient_secret, _ChatBotKitClient_baseUrl, _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,
@@ -58,7 +60,7 @@ export class ResponsePromise {
58
60
  message = data.message || `HTTP Error: ${response.statusText}`;
59
61
  code = data.code || `ERROR_${response.status}`;
60
62
  }
61
- catch (e) {
63
+ catch {
62
64
  const data = standardErrors[response.status] || standardErrors.default;
63
65
  message = data.message;
64
66
  code = data.code;
@@ -148,29 +150,71 @@ export class ResponsePromise {
148
150
  }
149
151
  export class ChatBotKitClient {
150
152
  constructor(options) {
151
- this.secret = options.secret;
152
- this.url = new URL(`https://api.chatbotkit.com`);
153
+ _ChatBotKitClient_secret.set(this, null);
154
+ _ChatBotKitClient_baseUrl.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_baseUrl, new URL(options.baseUrl || `https://api.chatbotkit.com`), "f");
153
168
  if (options.host) {
154
- this.url.host = options.host;
169
+ __classPrivateFieldGet(this, _ChatBotKitClient_baseUrl, "f").host = options.host;
155
170
  }
156
171
  if (options.protocol) {
157
- this.url.protocol = options.protocol;
158
- }
159
- this.endpoints = options.endpoints || {};
160
- this.runAsUserId = options.runAsUserId;
161
- this.runAsChildUserEmail = options.runAsChildUserEmail;
162
- this.timezone = options.timezone;
163
- this.headers = options.headers || {};
164
- this.timeout = options.timeout;
165
- this.retries = options.retries;
166
- this.retryDelay = options.retryDelay;
167
- this.retryTimeout = options.retryTimeout;
168
- this.fetchFn = options.fetchFn || fetchPlusPlus;
169
- this.cacheMap = new Map();
172
+ __classPrivateFieldGet(this, _ChatBotKitClient_baseUrl, "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");
185
+ }
186
+ extend(extensionOptions) {
187
+ const currentOptions = {
188
+ secret: __classPrivateFieldGet(this, _ChatBotKitClient_secret, "f") || '',
189
+ baseUrl: __classPrivateFieldGet(this, _ChatBotKitClient_baseUrl, "f").toString(),
190
+ endpoints: { ...__classPrivateFieldGet(this, _ChatBotKitClient_endpoints, "f") },
191
+ runAsUserId: __classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f"),
192
+ runAsChildUserEmail: __classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f"),
193
+ timezone: __classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f"),
194
+ headers: { ...__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f") },
195
+ timeout: __classPrivateFieldGet(this, _ChatBotKitClient_timeout, "f"),
196
+ retries: __classPrivateFieldGet(this, _ChatBotKitClient_retries, "f"),
197
+ retryDelay: __classPrivateFieldGet(this, _ChatBotKitClient_retryDelay, "f"),
198
+ retryTimeout: __classPrivateFieldGet(this, _ChatBotKitClient_retryTimeout, "f"),
199
+ fetchFn: __classPrivateFieldGet(this, _ChatBotKitClient_fetchFn, "f"),
200
+ };
201
+ const mergedOptions = {
202
+ ...currentOptions,
203
+ ...extensionOptions,
204
+ endpoints: {
205
+ ...currentOptions.endpoints,
206
+ ...(extensionOptions.endpoints || {}),
207
+ },
208
+ headers: {
209
+ ...currentOptions.headers,
210
+ ...(extensionOptions.headers || {}),
211
+ },
212
+ };
213
+ return new this.constructor(mergedOptions);
170
214
  }
171
215
  clientFetch(path, options) {
172
216
  let method = options?.method;
173
- const url = new URL(this.endpoints[options?.endpoint || path] || path, this.url);
217
+ const url = new URL(__classPrivateFieldGet(this, _ChatBotKitClient_endpoints, "f")[options?.endpoint || path] || path, __classPrivateFieldGet(this, _ChatBotKitClient_baseUrl, "f"));
174
218
  if (url.hostname === 'api.chatbotkit.com' &&
175
219
  url.pathname.startsWith('/api/')) {
176
220
  url.pathname = url.pathname.substring(4);
@@ -194,21 +238,21 @@ export class ChatBotKitClient {
194
238
  }
195
239
  }
196
240
  const headers = {
197
- ...this.headers,
241
+ ...__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f"),
198
242
  };
199
243
  if (!options?.external) {
200
- if (this.secret) {
201
- headers['authorization'] = `Bearer ${this.secret}`;
244
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")) {
245
+ headers['authorization'] = `Bearer ${__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")}`;
202
246
  }
203
- if (this.runAsUserId) {
204
- headers['x-runas-user-id'] = this.runAsUserId;
247
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f")) {
248
+ headers['x-runas-user-id'] = __classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f");
205
249
  }
206
- if (this.runAsChildUserEmail) {
207
- headers['x-runas-child-user-email'] = this.runAsChildUserEmail;
250
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f")) {
251
+ headers['x-runas-child-user-email'] = __classPrivateFieldGet(this, _ChatBotKitClient_runAsChildUserEmail, "f");
208
252
  }
209
253
  }
210
- if (this.timezone) {
211
- headers['x-timezone'] = this.timezone;
254
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f")) {
255
+ headers['x-timezone'] = __classPrivateFieldGet(this, _ChatBotKitClient_timezone, "f");
212
256
  }
213
257
  let data;
214
258
  if (options?.record) {
@@ -236,12 +280,13 @@ export class ChatBotKitClient {
236
280
  method,
237
281
  headers,
238
282
  data,
239
- timeout: options?.timeout ?? this.timeout,
240
- retries: options?.retries ?? this.retries,
241
- retryDelay: options?.retryDelay ?? this.retryDelay,
242
- retryTimeout: options?.retryTimeout ?? this.retryTimeout,
243
- fetchFn: options?.fetchFn || this.fetchFn,
283
+ timeout: options?.timeout ?? __classPrivateFieldGet(this, _ChatBotKitClient_timeout, "f"),
284
+ retries: options?.retries ?? __classPrivateFieldGet(this, _ChatBotKitClient_retries, "f"),
285
+ retryDelay: options?.retryDelay ?? __classPrivateFieldGet(this, _ChatBotKitClient_retryDelay, "f"),
286
+ retryTimeout: options?.retryTimeout ?? __classPrivateFieldGet(this, _ChatBotKitClient_retryTimeout, "f"),
287
+ fetchFn: options?.fetchFn || __classPrivateFieldGet(this, _ChatBotKitClient_fetchFn, "f"),
244
288
  };
245
- return new ResponsePromise(url, request, this.cacheMap);
289
+ return new ResponsePromise(url, request, __classPrivateFieldGet(this, _ChatBotKitClient_cacheMap, "f"));
246
290
  }
247
291
  }
292
+ _ChatBotKitClient_secret = new WeakMap(), _ChatBotKitClient_baseUrl = 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
- secrets: SecretClient;
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.secrets = new SecretClient(options);
13
+ this.secret = new SecretClient(options);
14
14
  }
15
15
  list(request) {
16
16
  return listContacts(this, request);
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { ChatBotKitClient } from '../../../client.js';
2
- import { fetchPlatformContentDoc, listPlatformContentDocs } from './v1.js';
2
+ import { fetchPlatformContentDoc, listPlatformContentDocs, searchPlatformContentDocs, } from './v1.js';
3
3
  export class PlatformContentDocClient extends ChatBotKitClient {
4
4
  constructor(options) {
5
5
  super(options);
@@ -7,6 +7,9 @@ export class PlatformContentDocClient extends ChatBotKitClient {
7
7
  list(request) {
8
8
  return listPlatformContentDocs(this, request);
9
9
  }
10
+ search(request) {
11
+ return searchPlatformContentDocs(this, request);
12
+ }
10
13
  fetch(docId) {
11
14
  return fetchPlatformContentDoc(this, docId);
12
15
  }
@@ -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"];
@@ -3,6 +3,15 @@ export function listPlatformContentDocs(client, request) {
3
3
  const response = client.clientFetch(url, { query: request });
4
4
  return response;
5
5
  }
6
+ export async function searchPlatformContentDocs(client, request) {
7
+ const url = `/api/v1/platform/content/doc/search`;
8
+ const response = await client.clientFetch(url, {
9
+ record: {
10
+ ...request,
11
+ },
12
+ });
13
+ return response;
14
+ }
6
15
  export function fetchPlatformContentDoc(client, docId) {
7
16
  const url = `/api/v1/platform/content/doc/${docId}/fetch`;
8
17
  const response = client.clientFetch(url, {
@@ -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,5 +1,5 @@
1
1
  import { ChatBotKitClient } from '../../../client.js';
2
- import { fetchPlatformContentManual, listPlatformContentManuals } from './v1.js';
2
+ import { fetchPlatformContentManual, listPlatformContentManuals, searchPlatformContentManuals, } from './v1.js';
3
3
  export class PlatformContentManualClient extends ChatBotKitClient {
4
4
  constructor(options) {
5
5
  super(options);
@@ -7,6 +7,9 @@ export class PlatformContentManualClient extends ChatBotKitClient {
7
7
  list(request) {
8
8
  return listPlatformContentManuals(this, request);
9
9
  }
10
+ search(request) {
11
+ return searchPlatformContentManuals(this, request);
12
+ }
10
13
  fetch(manualId) {
11
14
  return fetchPlatformContentManual(this, manualId);
12
15
  }
@@ -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"];
@@ -3,6 +3,15 @@ export function listPlatformContentManuals(client, request) {
3
3
  const response = client.clientFetch(url, { query: request });
4
4
  return response;
5
5
  }
6
+ export async function searchPlatformContentManuals(client, request) {
7
+ const url = `/api/v1/platform/content/manual/search`;
8
+ const response = await client.clientFetch(url, {
9
+ record: {
10
+ ...request,
11
+ },
12
+ });
13
+ return response;
14
+ }
6
15
  export function fetchPlatformContentManual(client, manualId) {
7
16
  const url = `/api/v1/platform/content/manual/${manualId}/fetch`;
8
17
  const response = client.clientFetch(url, {