@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.
@@ -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 = (params === null || params === void 0 ? void 0 : params.data) || data;
38
+ body = params?.data || data;
38
39
  }
39
40
  const url = this.url.toString();
40
- const response = await ((params === null || params === void 0 ? void 0 : params.fetchFn) || fetchFn || fetchPlusPlus)(url, {
41
- method: (params === null || params === void 0 ? void 0 : params.method) || method,
41
+ const response = await (params?.fetchFn || fetchFn || fetchPlusPlus)(url, {
42
+ method: params?.method || method,
42
43
  headers: {
43
44
  ...headers,
44
- ...params === null || params === void 0 ? void 0 : params.headers,
45
+ ...params?.headers,
45
46
  },
46
47
  body,
47
48
  ...{
48
- timeout: (_a = params === null || params === void 0 ? void 0 : params.timeout) !== null && _a !== void 0 ? _a : timeout,
49
- retries: (_b = params === null || params === void 0 ? void 0 : params.retries) !== null && _b !== void 0 ? _b : retries,
50
- retryDelay: (_c = params === null || params === void 0 ? void 0 : params.retryDelay) !== null && _c !== void 0 ? _c : retryDelay,
51
- retryTimeout: (_d = params === null || params === void 0 ? void 0 : params.retryTimeout) !== null && _d !== void 0 ? _d : 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: ((_a = this.request) === null || _a === void 0 ? void 0 : _a.method) || 'GET',
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.secret = options.secret;
158
- this.url = new URL(`https://api.chatbotkit.com`);
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.url.host = options.host;
173
+ tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_url, "f").host = options.host;
161
174
  }
162
175
  if (options.protocol) {
163
- this.url.protocol = options.protocol;
164
- }
165
- this.endpoints = options.endpoints || {};
166
- this.runAsUserId = options.runAsUserId;
167
- this.runAsChildUserEmail = options.runAsChildUserEmail;
168
- this.timezone = options.timezone;
169
- this.headers = options.headers || {};
170
- this.timeout = options.timeout;
171
- this.retries = options.retries;
172
- this.retryDelay = options.retryDelay;
173
- this.retryTimeout = options.retryTimeout;
174
- this.fetchFn = options.fetchFn || fetchPlusPlus;
175
- this.cacheMap = new Map();
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
- var _a, _b, _c, _d;
179
- let method = options === null || options === void 0 ? void 0 : options.method;
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 === null || options === void 0 ? void 0 : options.query) {
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.headers,
216
+ ...tslib_1.__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f"),
205
217
  };
206
- if (!(options === null || options === void 0 ? void 0 : options.external)) {
207
- if (this.secret) {
208
- headers['authorization'] = `Bearer ${this.secret}`;
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.runAsUserId) {
211
- headers['x-runas-user-id'] = this.runAsUserId;
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.runAsChildUserEmail) {
214
- headers['x-runas-child-user-email'] = this.runAsChildUserEmail;
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.timezone) {
218
- headers['x-timezone'] = this.timezone;
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 === null || options === void 0 ? void 0 : options.record) {
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 === null || options === void 0 ? void 0 : options.buffer) {
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 === null || options === void 0 ? void 0 : options.file) {
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 === null || options === void 0 ? void 0 : options.headers) {
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: (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : this.timeout,
247
- retries: (_b = options === null || options === void 0 ? void 0 : options.retries) !== null && _b !== void 0 ? _b : this.retries,
248
- retryDelay: (_c = options === null || options === void 0 ? void 0 : options.retryDelay) !== null && _c !== void 0 ? _c : this.retryDelay,
249
- retryTimeout: (_d = options === null || options === void 0 ? void 0 : options.retryTimeout) !== null && _d !== void 0 ? _d : this.retryTimeout,
250
- fetchFn: (options === null || options === void 0 ? void 0 : options.fetchFn) || this.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.cacheMap);
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();
@@ -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.secrets = new index_js_2.SecretClient(options);
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
- 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>;
@@ -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
  }
@@ -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;
@@ -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 ((defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[name]) != value) {
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"];
@@ -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 = {
@@ -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.secret = options.secret;
152
- this.url = new URL(`https://api.chatbotkit.com`);
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.url.host = options.host;
169
+ __classPrivateFieldGet(this, _ChatBotKitClient_url, "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_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.endpoints[options?.endpoint || path] || path, this.url);
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.headers,
212
+ ...__classPrivateFieldGet(this, _ChatBotKitClient_headers, "f"),
198
213
  };
199
214
  if (!options?.external) {
200
- if (this.secret) {
201
- headers['authorization'] = `Bearer ${this.secret}`;
215
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")) {
216
+ headers['authorization'] = `Bearer ${__classPrivateFieldGet(this, _ChatBotKitClient_secret, "f")}`;
202
217
  }
203
- if (this.runAsUserId) {
204
- headers['x-runas-user-id'] = this.runAsUserId;
218
+ if (__classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f")) {
219
+ headers['x-runas-user-id'] = __classPrivateFieldGet(this, _ChatBotKitClient_runAsUserId, "f");
205
220
  }
206
- if (this.runAsChildUserEmail) {
207
- headers['x-runas-child-user-email'] = this.runAsChildUserEmail;
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.timezone) {
211
- headers['x-timezone'] = this.timezone;
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.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,
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.cacheMap);
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
- 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;