@savantoai/ai-sdk 2.1.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/index.cjs ADDED
@@ -0,0 +1,2618 @@
1
+
2
+ //#region src/generated/core/bodySerializer.gen.ts
3
+ const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
4
+
5
+ //#endregion
6
+ //#region src/generated/core/serverSentEvents.gen.ts
7
+ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
8
+ let lastEventId;
9
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
10
+ const createStream = async function* () {
11
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
12
+ let attempt = 0;
13
+ const signal = options.signal ?? new AbortController().signal;
14
+ while (true) {
15
+ if (signal.aborted) break;
16
+ attempt++;
17
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
18
+ if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
19
+ try {
20
+ const requestInit = {
21
+ redirect: "follow",
22
+ ...options,
23
+ body: options.serializedBody,
24
+ headers,
25
+ signal
26
+ };
27
+ let request = new Request(url, requestInit);
28
+ if (onRequest) request = await onRequest(url, requestInit);
29
+ const response = await (options.fetch ?? globalThis.fetch)(request);
30
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
31
+ if (!response.body) throw new Error("No body in SSE response");
32
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
33
+ let buffer = "";
34
+ const abortHandler = () => {
35
+ try {
36
+ reader.cancel();
37
+ } catch {}
38
+ };
39
+ signal.addEventListener("abort", abortHandler);
40
+ try {
41
+ while (true) {
42
+ const { done, value } = await reader.read();
43
+ if (done) break;
44
+ buffer += value;
45
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
46
+ const chunks = buffer.split("\n\n");
47
+ buffer = chunks.pop() ?? "";
48
+ for (const chunk of chunks) {
49
+ const lines = chunk.split("\n");
50
+ const dataLines = [];
51
+ let eventName;
52
+ for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
53
+ else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
54
+ else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
55
+ else if (line.startsWith("retry:")) {
56
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
57
+ if (!Number.isNaN(parsed)) retryDelay = parsed;
58
+ }
59
+ let data;
60
+ let parsedJson = false;
61
+ if (dataLines.length) {
62
+ const rawData = dataLines.join("\n");
63
+ try {
64
+ data = JSON.parse(rawData);
65
+ parsedJson = true;
66
+ } catch {
67
+ data = rawData;
68
+ }
69
+ }
70
+ if (parsedJson) {
71
+ if (responseValidator) await responseValidator(data);
72
+ if (responseTransformer) data = await responseTransformer(data);
73
+ }
74
+ onSseEvent?.({
75
+ data,
76
+ event: eventName,
77
+ id: lastEventId,
78
+ retry: retryDelay
79
+ });
80
+ if (dataLines.length) yield data;
81
+ }
82
+ }
83
+ } finally {
84
+ signal.removeEventListener("abort", abortHandler);
85
+ reader.releaseLock();
86
+ }
87
+ break;
88
+ } catch (error) {
89
+ onSseError?.(error);
90
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
91
+ await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
92
+ }
93
+ }
94
+ };
95
+ return { stream: createStream() };
96
+ };
97
+
98
+ //#endregion
99
+ //#region src/generated/core/pathSerializer.gen.ts
100
+ const separatorArrayExplode = (style) => {
101
+ switch (style) {
102
+ case "label": return ".";
103
+ case "matrix": return ";";
104
+ case "simple": return ",";
105
+ default: return "&";
106
+ }
107
+ };
108
+ const separatorArrayNoExplode = (style) => {
109
+ switch (style) {
110
+ case "form": return ",";
111
+ case "pipeDelimited": return "|";
112
+ case "spaceDelimited": return "%20";
113
+ default: return ",";
114
+ }
115
+ };
116
+ const separatorObjectExplode = (style) => {
117
+ switch (style) {
118
+ case "label": return ".";
119
+ case "matrix": return ";";
120
+ case "simple": return ",";
121
+ default: return "&";
122
+ }
123
+ };
124
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
125
+ if (!explode) {
126
+ const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
127
+ switch (style) {
128
+ case "label": return `.${joinedValues$1}`;
129
+ case "matrix": return `;${name}=${joinedValues$1}`;
130
+ case "simple": return joinedValues$1;
131
+ default: return `${name}=${joinedValues$1}`;
132
+ }
133
+ }
134
+ const separator = separatorArrayExplode(style);
135
+ const joinedValues = value.map((v) => {
136
+ if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
137
+ return serializePrimitiveParam({
138
+ allowReserved,
139
+ name,
140
+ value: v
141
+ });
142
+ }).join(separator);
143
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
144
+ };
145
+ const serializePrimitiveParam = ({ allowReserved, name, value }) => {
146
+ if (value === void 0 || value === null) return "";
147
+ if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
148
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
149
+ };
150
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
151
+ if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
152
+ if (style !== "deepObject" && !explode) {
153
+ let values = [];
154
+ Object.entries(value).forEach(([key, v]) => {
155
+ values = [
156
+ ...values,
157
+ key,
158
+ allowReserved ? v : encodeURIComponent(v)
159
+ ];
160
+ });
161
+ const joinedValues$1 = values.join(",");
162
+ switch (style) {
163
+ case "form": return `${name}=${joinedValues$1}`;
164
+ case "label": return `.${joinedValues$1}`;
165
+ case "matrix": return `;${name}=${joinedValues$1}`;
166
+ default: return joinedValues$1;
167
+ }
168
+ }
169
+ const separator = separatorObjectExplode(style);
170
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
171
+ allowReserved,
172
+ name: style === "deepObject" ? `${name}[${key}]` : key,
173
+ value: v
174
+ })).join(separator);
175
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
176
+ };
177
+
178
+ //#endregion
179
+ //#region src/generated/core/utils.gen.ts
180
+ const PATH_PARAM_RE = /\{[^{}]+\}/g;
181
+ const defaultPathSerializer = ({ path, url: _url }) => {
182
+ let url = _url;
183
+ const matches = _url.match(PATH_PARAM_RE);
184
+ if (matches) for (const match of matches) {
185
+ let explode = false;
186
+ let name = match.substring(1, match.length - 1);
187
+ let style = "simple";
188
+ if (name.endsWith("*")) {
189
+ explode = true;
190
+ name = name.substring(0, name.length - 1);
191
+ }
192
+ if (name.startsWith(".")) {
193
+ name = name.substring(1);
194
+ style = "label";
195
+ } else if (name.startsWith(";")) {
196
+ name = name.substring(1);
197
+ style = "matrix";
198
+ }
199
+ const value = path[name];
200
+ if (value === void 0 || value === null) continue;
201
+ if (Array.isArray(value)) {
202
+ url = url.replace(match, serializeArrayParam({
203
+ explode,
204
+ name,
205
+ style,
206
+ value
207
+ }));
208
+ continue;
209
+ }
210
+ if (typeof value === "object") {
211
+ url = url.replace(match, serializeObjectParam({
212
+ explode,
213
+ name,
214
+ style,
215
+ value,
216
+ valueOnly: true
217
+ }));
218
+ continue;
219
+ }
220
+ if (style === "matrix") {
221
+ url = url.replace(match, `;${serializePrimitiveParam({
222
+ name,
223
+ value
224
+ })}`);
225
+ continue;
226
+ }
227
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
228
+ url = url.replace(match, replaceValue);
229
+ }
230
+ return url;
231
+ };
232
+ const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
233
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
234
+ let url = (baseUrl ?? "") + pathUrl;
235
+ if (path) url = defaultPathSerializer({
236
+ path,
237
+ url
238
+ });
239
+ let search = query ? querySerializer(query) : "";
240
+ if (search.startsWith("?")) search = search.substring(1);
241
+ if (search) url += `?${search}`;
242
+ return url;
243
+ };
244
+ function getValidRequestBody(options) {
245
+ const hasBody = options.body !== void 0;
246
+ if (hasBody && options.bodySerializer) {
247
+ if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
248
+ return options.body !== "" ? options.body : null;
249
+ }
250
+ if (hasBody) return options.body;
251
+ }
252
+
253
+ //#endregion
254
+ //#region src/generated/core/auth.gen.ts
255
+ const getAuthToken = async (auth, callback) => {
256
+ const token = typeof callback === "function" ? await callback(auth) : callback;
257
+ if (!token) return;
258
+ if (auth.scheme === "bearer") return `Bearer ${token}`;
259
+ if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
260
+ return token;
261
+ };
262
+
263
+ //#endregion
264
+ //#region src/generated/client/utils.gen.ts
265
+ const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
266
+ const querySerializer = (queryParams) => {
267
+ const search = [];
268
+ if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
269
+ const value = queryParams[name];
270
+ if (value === void 0 || value === null) continue;
271
+ const options = parameters[name] || args;
272
+ if (Array.isArray(value)) {
273
+ const serializedArray = serializeArrayParam({
274
+ allowReserved: options.allowReserved,
275
+ explode: true,
276
+ name,
277
+ style: "form",
278
+ value,
279
+ ...options.array
280
+ });
281
+ if (serializedArray) search.push(serializedArray);
282
+ } else if (typeof value === "object") {
283
+ const serializedObject = serializeObjectParam({
284
+ allowReserved: options.allowReserved,
285
+ explode: true,
286
+ name,
287
+ style: "deepObject",
288
+ value,
289
+ ...options.object
290
+ });
291
+ if (serializedObject) search.push(serializedObject);
292
+ } else {
293
+ const serializedPrimitive = serializePrimitiveParam({
294
+ allowReserved: options.allowReserved,
295
+ name,
296
+ value
297
+ });
298
+ if (serializedPrimitive) search.push(serializedPrimitive);
299
+ }
300
+ }
301
+ return search.join("&");
302
+ };
303
+ return querySerializer;
304
+ };
305
+ /**
306
+ * Infers parseAs value from provided Content-Type header.
307
+ */
308
+ const getParseAs = (contentType) => {
309
+ if (!contentType) return "stream";
310
+ const cleanContent = contentType.split(";")[0]?.trim();
311
+ if (!cleanContent) return;
312
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
313
+ if (cleanContent === "multipart/form-data") return "formData";
314
+ if ([
315
+ "application/",
316
+ "audio/",
317
+ "image/",
318
+ "video/"
319
+ ].some((type) => cleanContent.startsWith(type))) return "blob";
320
+ if (cleanContent.startsWith("text/")) return "text";
321
+ };
322
+ const checkForExistence = (options, name) => {
323
+ if (!name) return false;
324
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
325
+ return false;
326
+ };
327
+ const setAuthParams = async ({ security, ...options }) => {
328
+ for (const auth of security) {
329
+ if (checkForExistence(options, auth.name)) continue;
330
+ const token = await getAuthToken(auth, options.auth);
331
+ if (!token) continue;
332
+ const name = auth.name ?? "Authorization";
333
+ switch (auth.in) {
334
+ case "query":
335
+ if (!options.query) options.query = {};
336
+ options.query[name] = token;
337
+ break;
338
+ case "cookie":
339
+ options.headers.append("Cookie", `${name}=${token}`);
340
+ break;
341
+ case "header":
342
+ default:
343
+ options.headers.set(name, token);
344
+ break;
345
+ }
346
+ }
347
+ };
348
+ const buildUrl = (options) => getUrl({
349
+ baseUrl: options.baseUrl,
350
+ path: options.path,
351
+ query: options.query,
352
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
353
+ url: options.url
354
+ });
355
+ const mergeConfigs = (a, b) => {
356
+ const config = {
357
+ ...a,
358
+ ...b
359
+ };
360
+ if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
361
+ config.headers = mergeHeaders(a.headers, b.headers);
362
+ return config;
363
+ };
364
+ const headersEntries = (headers) => {
365
+ const entries = [];
366
+ headers.forEach((value, key) => {
367
+ entries.push([key, value]);
368
+ });
369
+ return entries;
370
+ };
371
+ const mergeHeaders = (...headers) => {
372
+ const mergedHeaders = new Headers();
373
+ for (const header of headers) {
374
+ if (!header) continue;
375
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
376
+ for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
377
+ else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
378
+ else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
379
+ }
380
+ return mergedHeaders;
381
+ };
382
+ var Interceptors = class {
383
+ constructor() {
384
+ this.fns = [];
385
+ }
386
+ clear() {
387
+ this.fns = [];
388
+ }
389
+ eject(id) {
390
+ const index = this.getInterceptorIndex(id);
391
+ if (this.fns[index]) this.fns[index] = null;
392
+ }
393
+ exists(id) {
394
+ const index = this.getInterceptorIndex(id);
395
+ return Boolean(this.fns[index]);
396
+ }
397
+ getInterceptorIndex(id) {
398
+ if (typeof id === "number") return this.fns[id] ? id : -1;
399
+ return this.fns.indexOf(id);
400
+ }
401
+ update(id, fn) {
402
+ const index = this.getInterceptorIndex(id);
403
+ if (this.fns[index]) {
404
+ this.fns[index] = fn;
405
+ return id;
406
+ }
407
+ return false;
408
+ }
409
+ use(fn) {
410
+ this.fns.push(fn);
411
+ return this.fns.length - 1;
412
+ }
413
+ };
414
+ const createInterceptors = () => ({
415
+ error: new Interceptors(),
416
+ request: new Interceptors(),
417
+ response: new Interceptors()
418
+ });
419
+ const defaultQuerySerializer = createQuerySerializer({
420
+ allowReserved: false,
421
+ array: {
422
+ explode: true,
423
+ style: "form"
424
+ },
425
+ object: {
426
+ explode: true,
427
+ style: "deepObject"
428
+ }
429
+ });
430
+ const defaultHeaders = { "Content-Type": "application/json" };
431
+ const createConfig = (override = {}) => ({
432
+ ...jsonBodySerializer,
433
+ headers: defaultHeaders,
434
+ parseAs: "auto",
435
+ querySerializer: defaultQuerySerializer,
436
+ ...override
437
+ });
438
+
439
+ //#endregion
440
+ //#region src/generated/client/client.gen.ts
441
+ const createClient = (config = {}) => {
442
+ let _config = mergeConfigs(createConfig(), config);
443
+ const getConfig = () => ({ ..._config });
444
+ const setConfig = (config$1) => {
445
+ _config = mergeConfigs(_config, config$1);
446
+ return getConfig();
447
+ };
448
+ const interceptors = createInterceptors();
449
+ const beforeRequest = async (options) => {
450
+ const opts = {
451
+ ..._config,
452
+ ...options,
453
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
454
+ headers: mergeHeaders(_config.headers, options.headers),
455
+ serializedBody: void 0
456
+ };
457
+ if (opts.security) await setAuthParams({
458
+ ...opts,
459
+ security: opts.security
460
+ });
461
+ if (opts.requestValidator) await opts.requestValidator(opts);
462
+ if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
463
+ if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
464
+ return {
465
+ opts,
466
+ url: buildUrl(opts)
467
+ };
468
+ };
469
+ const request = async (options) => {
470
+ const { opts, url } = await beforeRequest(options);
471
+ const requestInit = {
472
+ redirect: "follow",
473
+ ...opts,
474
+ body: getValidRequestBody(opts)
475
+ };
476
+ let request$1 = new Request(url, requestInit);
477
+ for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
478
+ const _fetch = opts.fetch;
479
+ let response;
480
+ try {
481
+ response = await _fetch(request$1);
482
+ } catch (error$1) {
483
+ let finalError$1 = error$1;
484
+ for (const fn of interceptors.error.fns) if (fn) finalError$1 = await fn(error$1, void 0, request$1, opts);
485
+ finalError$1 = finalError$1 || {};
486
+ if (opts.throwOnError) throw finalError$1;
487
+ return opts.responseStyle === "data" ? void 0 : {
488
+ error: finalError$1,
489
+ request: request$1,
490
+ response: void 0
491
+ };
492
+ }
493
+ for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request$1, opts);
494
+ const result = {
495
+ request: request$1,
496
+ response
497
+ };
498
+ if (response.ok) {
499
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
500
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
501
+ let emptyData;
502
+ switch (parseAs) {
503
+ case "arrayBuffer":
504
+ case "blob":
505
+ case "text":
506
+ emptyData = await response[parseAs]();
507
+ break;
508
+ case "formData":
509
+ emptyData = new FormData();
510
+ break;
511
+ case "stream":
512
+ emptyData = response.body;
513
+ break;
514
+ case "json":
515
+ default:
516
+ emptyData = {};
517
+ break;
518
+ }
519
+ return opts.responseStyle === "data" ? emptyData : {
520
+ data: emptyData,
521
+ ...result
522
+ };
523
+ }
524
+ let data;
525
+ switch (parseAs) {
526
+ case "arrayBuffer":
527
+ case "blob":
528
+ case "formData":
529
+ case "text":
530
+ data = await response[parseAs]();
531
+ break;
532
+ case "json": {
533
+ const text = await response.text();
534
+ data = text ? JSON.parse(text) : {};
535
+ break;
536
+ }
537
+ case "stream": return opts.responseStyle === "data" ? response.body : {
538
+ data: response.body,
539
+ ...result
540
+ };
541
+ }
542
+ if (parseAs === "json") {
543
+ if (opts.responseValidator) await opts.responseValidator(data);
544
+ if (opts.responseTransformer) data = await opts.responseTransformer(data);
545
+ }
546
+ return opts.responseStyle === "data" ? data : {
547
+ data,
548
+ ...result
549
+ };
550
+ }
551
+ const textError = await response.text();
552
+ let jsonError;
553
+ try {
554
+ jsonError = JSON.parse(textError);
555
+ } catch {}
556
+ const error = jsonError ?? textError;
557
+ let finalError = error;
558
+ for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request$1, opts);
559
+ finalError = finalError || {};
560
+ if (opts.throwOnError) throw finalError;
561
+ return opts.responseStyle === "data" ? void 0 : {
562
+ error: finalError,
563
+ ...result
564
+ };
565
+ };
566
+ const makeMethodFn = (method) => (options) => request({
567
+ ...options,
568
+ method
569
+ });
570
+ const makeSseFn = (method) => async (options) => {
571
+ const { opts, url } = await beforeRequest(options);
572
+ return createSseClient({
573
+ ...opts,
574
+ body: opts.body,
575
+ headers: opts.headers,
576
+ method,
577
+ onRequest: async (url$1, init) => {
578
+ let request$1 = new Request(url$1, init);
579
+ for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
580
+ return request$1;
581
+ },
582
+ serializedBody: getValidRequestBody(opts),
583
+ url
584
+ });
585
+ };
586
+ const _buildUrl = (options) => buildUrl({
587
+ ..._config,
588
+ ...options
589
+ });
590
+ return {
591
+ buildUrl: _buildUrl,
592
+ connect: makeMethodFn("CONNECT"),
593
+ delete: makeMethodFn("DELETE"),
594
+ get: makeMethodFn("GET"),
595
+ getConfig,
596
+ head: makeMethodFn("HEAD"),
597
+ interceptors,
598
+ options: makeMethodFn("OPTIONS"),
599
+ patch: makeMethodFn("PATCH"),
600
+ post: makeMethodFn("POST"),
601
+ put: makeMethodFn("PUT"),
602
+ request,
603
+ setConfig,
604
+ sse: {
605
+ connect: makeSseFn("CONNECT"),
606
+ delete: makeSseFn("DELETE"),
607
+ get: makeSseFn("GET"),
608
+ head: makeSseFn("HEAD"),
609
+ options: makeSseFn("OPTIONS"),
610
+ patch: makeSseFn("PATCH"),
611
+ post: makeSseFn("POST"),
612
+ put: makeSseFn("PUT"),
613
+ trace: makeSseFn("TRACE")
614
+ },
615
+ trace: makeMethodFn("TRACE")
616
+ };
617
+ };
618
+
619
+ //#endregion
620
+ //#region src/generated/client.gen.ts
621
+ const client = createClient(createConfig({ baseUrl: "https://api.savanto.ai" }));
622
+
623
+ //#endregion
624
+ //#region src/generated/sdk.gen.ts
625
+ /**
626
+ * Send a chat message
627
+ *
628
+ * Send a message and receive AI response. Supports streaming via NDJSON.
629
+ */
630
+ const chat = (options) => (options?.client ?? client).post({
631
+ security: [{
632
+ scheme: "bearer",
633
+ type: "http"
634
+ }],
635
+ url: "/chat",
636
+ ...options,
637
+ headers: {
638
+ "Content-Type": "application/json",
639
+ ...options?.headers
640
+ }
641
+ });
642
+ /**
643
+ * Start a website crawl
644
+ *
645
+ * Initiate a crawl of a website URL. Pages are discovered and indexed into the knowledge base.
646
+ */
647
+ const startCrawl = (options) => (options?.client ?? client).post({
648
+ security: [{
649
+ scheme: "bearer",
650
+ type: "http"
651
+ }],
652
+ url: "/crawl",
653
+ ...options,
654
+ headers: {
655
+ "Content-Type": "application/json",
656
+ ...options?.headers
657
+ }
658
+ });
659
+ /**
660
+ * Scrape a single page
661
+ *
662
+ * Scrape and index a single page via the crawl queue.
663
+ */
664
+ const scrapeSinglePage = (options) => (options?.client ?? client).post({
665
+ security: [{
666
+ scheme: "bearer",
667
+ type: "http"
668
+ }],
669
+ url: "/crawl/scrape",
670
+ ...options,
671
+ headers: {
672
+ "Content-Type": "application/json",
673
+ ...options?.headers
674
+ }
675
+ });
676
+ /**
677
+ * Get crawl configuration
678
+ *
679
+ * Retrieve the crawl configuration for a workspace.
680
+ */
681
+ const getCrawlConfig = (options) => (options?.client ?? client).get({
682
+ security: [{
683
+ scheme: "bearer",
684
+ type: "http"
685
+ }],
686
+ url: "/crawl/config",
687
+ ...options
688
+ });
689
+ /**
690
+ * Update crawl configuration
691
+ *
692
+ * Update the crawl configuration for a workspace including strategy, schedule, exclude patterns, etc.
693
+ */
694
+ const updateCrawlConfig = (options) => (options?.client ?? client).put({
695
+ security: [{
696
+ scheme: "bearer",
697
+ type: "http"
698
+ }],
699
+ url: "/crawl/config",
700
+ ...options,
701
+ headers: {
702
+ "Content-Type": "application/json",
703
+ ...options?.headers
704
+ }
705
+ });
706
+ /**
707
+ * Get crawl history
708
+ *
709
+ * Retrieve recent crawl history for the tenant.
710
+ */
711
+ const getCrawlHistory = (options) => (options?.client ?? client).get({
712
+ security: [{
713
+ scheme: "bearer",
714
+ type: "http"
715
+ }],
716
+ url: "/crawl/history",
717
+ ...options
718
+ });
719
+ /**
720
+ * Get crawl status
721
+ *
722
+ * Check the progress and status of a running or completed crawl.
723
+ */
724
+ const getCrawlStatus = (options) => (options.client ?? client).get({
725
+ security: [{
726
+ scheme: "bearer",
727
+ type: "http"
728
+ }],
729
+ url: "/crawl/{id}/status",
730
+ ...options
731
+ });
732
+ /**
733
+ * Cancel a running crawl
734
+ *
735
+ * Cancel a crawl that is currently in progress.
736
+ */
737
+ const cancelCrawl = (options) => (options.client ?? client).post({
738
+ security: [{
739
+ scheme: "bearer",
740
+ type: "http"
741
+ }],
742
+ url: "/crawl/{id}/cancel",
743
+ ...options
744
+ });
745
+ /**
746
+ * Scrape or delete a single page
747
+ *
748
+ * Scrape a URL and index it into the knowledge base, or delete a previously scraped page.
749
+ */
750
+ const scrapePage = (options) => (options?.client ?? client).post({
751
+ security: [{
752
+ scheme: "bearer",
753
+ type: "http"
754
+ }],
755
+ url: "/webhooks/scrape",
756
+ ...options,
757
+ headers: {
758
+ "Content-Type": "application/json",
759
+ ...options?.headers
760
+ }
761
+ });
762
+ /**
763
+ * List products
764
+ *
765
+ * List products with optional filters. Supports pagination, category/tag/status filters, and metadata queries.
766
+ */
767
+ const listProducts = (options) => (options?.client ?? client).get({
768
+ security: [{
769
+ scheme: "bearer",
770
+ type: "http"
771
+ }],
772
+ url: "/products",
773
+ ...options
774
+ });
775
+ /**
776
+ * Upsert a product
777
+ *
778
+ * Create or update a product by external ID. Generates vector embeddings for semantic search.
779
+ */
780
+ const upsertProduct = (options) => (options?.client ?? client).post({
781
+ security: [{
782
+ scheme: "bearer",
783
+ type: "http"
784
+ }],
785
+ url: "/products",
786
+ ...options,
787
+ headers: {
788
+ "Content-Type": "application/json",
789
+ ...options?.headers
790
+ }
791
+ });
792
+ /**
793
+ * Bulk delete products
794
+ *
795
+ * Delete multiple products by their external IDs.
796
+ */
797
+ const bulkDeleteProducts = (options) => (options?.client ?? client).delete({
798
+ security: [{
799
+ scheme: "bearer",
800
+ type: "http"
801
+ }],
802
+ url: "/products/bulk",
803
+ ...options,
804
+ headers: {
805
+ "Content-Type": "application/json",
806
+ ...options?.headers
807
+ }
808
+ });
809
+ /**
810
+ * Bulk upsert products
811
+ *
812
+ * Create or update up to 100 products in a single request.
813
+ */
814
+ const bulkUpsertProducts = (options) => (options?.client ?? client).post({
815
+ security: [{
816
+ scheme: "bearer",
817
+ type: "http"
818
+ }],
819
+ url: "/products/bulk",
820
+ ...options,
821
+ headers: {
822
+ "Content-Type": "application/json",
823
+ ...options?.headers
824
+ }
825
+ });
826
+ /**
827
+ * Search products
828
+ *
829
+ * Semantic search across products with optional filters and facets. Uses AI agent for query enhancement when beneficial.
830
+ */
831
+ const searchProducts = (options) => (options?.client ?? client).post({
832
+ security: [{
833
+ scheme: "bearer",
834
+ type: "http"
835
+ }],
836
+ url: "/products/search",
837
+ ...options,
838
+ headers: {
839
+ "Content-Type": "application/json",
840
+ ...options?.headers
841
+ }
842
+ });
843
+ /**
844
+ * Delete products by query
845
+ *
846
+ * Delete all products matching the given filter criteria.
847
+ */
848
+ const deleteProductsByQuery = (options) => (options?.client ?? client).post({
849
+ security: [{
850
+ scheme: "bearer",
851
+ type: "http"
852
+ }],
853
+ url: "/products/delete-by-query",
854
+ ...options,
855
+ headers: {
856
+ "Content-Type": "application/json",
857
+ ...options?.headers
858
+ }
859
+ });
860
+ /**
861
+ * List product IDs
862
+ *
863
+ * Retrieve external IDs of indexed products with optional filters. Supports large offsets for sync.
864
+ */
865
+ const listProductIds = (options) => (options?.client ?? client).get({
866
+ security: [{
867
+ scheme: "bearer",
868
+ type: "http"
869
+ }],
870
+ url: "/products/ids",
871
+ ...options
872
+ });
873
+ /**
874
+ * Delete a product
875
+ *
876
+ * Delete a single product by external ID.
877
+ */
878
+ const deleteProduct = (options) => (options.client ?? client).delete({
879
+ security: [{
880
+ scheme: "bearer",
881
+ type: "http"
882
+ }],
883
+ url: "/products/{id}",
884
+ ...options
885
+ });
886
+ /**
887
+ * Get a product
888
+ *
889
+ * Retrieve a single product by external ID.
890
+ */
891
+ const getProduct = (options) => (options.client ?? client).get({
892
+ security: [{
893
+ scheme: "bearer",
894
+ type: "http"
895
+ }],
896
+ url: "/products/{id}",
897
+ ...options
898
+ });
899
+ /**
900
+ * Patch a product
901
+ *
902
+ * Partially update a product (e.g. change indexStatus).
903
+ */
904
+ const patchProduct = (options) => (options.client ?? client).patch({
905
+ security: [{
906
+ scheme: "bearer",
907
+ type: "http"
908
+ }],
909
+ url: "/products/{id}",
910
+ ...options,
911
+ headers: {
912
+ "Content-Type": "application/json",
913
+ ...options.headers
914
+ }
915
+ });
916
+ /**
917
+ * Upsert a post
918
+ *
919
+ * Create or update a post by external ID. Generates vector embeddings for semantic search.
920
+ */
921
+ const upsertPost = (options) => (options?.client ?? client).post({
922
+ security: [{
923
+ scheme: "bearer",
924
+ type: "http"
925
+ }],
926
+ url: "/posts",
927
+ ...options,
928
+ headers: {
929
+ "Content-Type": "application/json",
930
+ ...options?.headers
931
+ }
932
+ });
933
+ /**
934
+ * Bulk delete posts
935
+ *
936
+ * Delete multiple posts by their external IDs.
937
+ */
938
+ const bulkDeletePosts = (options) => (options?.client ?? client).delete({
939
+ security: [{
940
+ scheme: "bearer",
941
+ type: "http"
942
+ }],
943
+ url: "/posts/bulk",
944
+ ...options,
945
+ headers: {
946
+ "Content-Type": "application/json",
947
+ ...options?.headers
948
+ }
949
+ });
950
+ /**
951
+ * Bulk upsert posts
952
+ *
953
+ * Create or update up to 100 posts in a single request.
954
+ */
955
+ const bulkUpsertPosts = (options) => (options?.client ?? client).post({
956
+ security: [{
957
+ scheme: "bearer",
958
+ type: "http"
959
+ }],
960
+ url: "/posts/bulk",
961
+ ...options,
962
+ headers: {
963
+ "Content-Type": "application/json",
964
+ ...options?.headers
965
+ }
966
+ });
967
+ /**
968
+ * Search posts
969
+ *
970
+ * Semantic search across posts with optional filters. Uses AI agent for query enhancement when beneficial.
971
+ */
972
+ const searchPosts = (options) => (options?.client ?? client).post({
973
+ security: [{
974
+ scheme: "bearer",
975
+ type: "http"
976
+ }],
977
+ url: "/posts/search",
978
+ ...options,
979
+ headers: {
980
+ "Content-Type": "application/json",
981
+ ...options?.headers
982
+ }
983
+ });
984
+ /**
985
+ * Delete posts by query
986
+ *
987
+ * Delete all posts matching the given filter criteria.
988
+ */
989
+ const deletePostsByQuery = (options) => (options?.client ?? client).post({
990
+ security: [{
991
+ scheme: "bearer",
992
+ type: "http"
993
+ }],
994
+ url: "/posts/delete-by-query",
995
+ ...options,
996
+ headers: {
997
+ "Content-Type": "application/json",
998
+ ...options?.headers
999
+ }
1000
+ });
1001
+ /**
1002
+ * List post IDs
1003
+ *
1004
+ * Retrieve external IDs of indexed posts with optional filters. Supports large offsets for sync.
1005
+ */
1006
+ const listPostIds = (options) => (options?.client ?? client).get({
1007
+ security: [{
1008
+ scheme: "bearer",
1009
+ type: "http"
1010
+ }],
1011
+ url: "/posts/ids",
1012
+ ...options
1013
+ });
1014
+ /**
1015
+ * Delete a post
1016
+ *
1017
+ * Delete a single post by external ID.
1018
+ */
1019
+ const deletePost = (options) => (options.client ?? client).delete({
1020
+ security: [{
1021
+ scheme: "bearer",
1022
+ type: "http"
1023
+ }],
1024
+ url: "/posts/{id}",
1025
+ ...options
1026
+ });
1027
+ /**
1028
+ * Get a post
1029
+ *
1030
+ * Retrieve a single post by external ID.
1031
+ */
1032
+ const getPost = (options) => (options.client ?? client).get({
1033
+ security: [{
1034
+ scheme: "bearer",
1035
+ type: "http"
1036
+ }],
1037
+ url: "/posts/{id}",
1038
+ ...options
1039
+ });
1040
+ /**
1041
+ * Patch a post
1042
+ *
1043
+ * Partially update a post (e.g. change indexStatus).
1044
+ */
1045
+ const patchPost = (options) => (options.client ?? client).patch({
1046
+ security: [{
1047
+ scheme: "bearer",
1048
+ type: "http"
1049
+ }],
1050
+ url: "/posts/{id}",
1051
+ ...options,
1052
+ headers: {
1053
+ "Content-Type": "application/json",
1054
+ ...options.headers
1055
+ }
1056
+ });
1057
+ /**
1058
+ * Search threads
1059
+ *
1060
+ * Search and filter conversation threads with pagination, date ranges, and sorting.
1061
+ */
1062
+ const searchThreads = (options) => (options?.client ?? client).post({
1063
+ security: [{
1064
+ scheme: "bearer",
1065
+ type: "http"
1066
+ }],
1067
+ url: "/threads/search",
1068
+ ...options,
1069
+ headers: {
1070
+ "Content-Type": "application/json",
1071
+ ...options?.headers
1072
+ }
1073
+ });
1074
+ /**
1075
+ * Export threads
1076
+ *
1077
+ * Export conversation threads in JSON or CSV format with optional date and user filtering.
1078
+ */
1079
+ const exportThreads = (options) => (options?.client ?? client).post({
1080
+ security: [{
1081
+ scheme: "bearer",
1082
+ type: "http"
1083
+ }],
1084
+ url: "/threads/export",
1085
+ ...options,
1086
+ headers: {
1087
+ "Content-Type": "application/json",
1088
+ ...options?.headers
1089
+ }
1090
+ });
1091
+ /**
1092
+ * Get thread analytics
1093
+ *
1094
+ * Retrieve aggregate analytics and statistics about conversation threads.
1095
+ */
1096
+ const getThreadAnalytics = (options) => (options?.client ?? client).get({
1097
+ security: [{
1098
+ scheme: "bearer",
1099
+ type: "http"
1100
+ }],
1101
+ url: "/threads/analytics",
1102
+ ...options
1103
+ });
1104
+ /**
1105
+ * Get thread messages
1106
+ *
1107
+ * Retrieve all messages for a specific conversation thread. Requires admin:threads or chat scope.
1108
+ */
1109
+ const getThreadMessages = (options) => (options.client ?? client).get({
1110
+ security: [{
1111
+ scheme: "bearer",
1112
+ type: "http"
1113
+ }],
1114
+ url: "/threads/{id}/messages",
1115
+ ...options
1116
+ });
1117
+ /**
1118
+ * End live agent handoff
1119
+ *
1120
+ * End a live agent handoff session for a thread. Requires admin:threads or chat scope.
1121
+ */
1122
+ const endHandoff = (options) => (options.client ?? client).post({
1123
+ security: [{
1124
+ scheme: "bearer",
1125
+ type: "http"
1126
+ }],
1127
+ url: "/threads/{id}/handoff/end",
1128
+ ...options
1129
+ });
1130
+ /**
1131
+ * Delete a thread
1132
+ *
1133
+ * Permanently delete a conversation thread by its ID.
1134
+ */
1135
+ const deleteThread = (options) => (options.client ?? client).delete({
1136
+ security: [{
1137
+ scheme: "bearer",
1138
+ type: "http"
1139
+ }],
1140
+ url: "/threads/{id}",
1141
+ ...options
1142
+ });
1143
+ /**
1144
+ * Get thread by ID
1145
+ *
1146
+ * Retrieve a single conversation thread by its ID, optionally including feedback data.
1147
+ */
1148
+ const getThread = (options) => (options.client ?? client).get({
1149
+ security: [{
1150
+ scheme: "bearer",
1151
+ type: "http"
1152
+ }],
1153
+ url: "/threads/{id}",
1154
+ ...options
1155
+ });
1156
+ /**
1157
+ * Bulk delete threads
1158
+ *
1159
+ * Delete multiple conversation threads by their IDs in a single request.
1160
+ */
1161
+ const bulkDeleteThreads = (options) => (options?.client ?? client).delete({
1162
+ security: [{
1163
+ scheme: "bearer",
1164
+ type: "http"
1165
+ }],
1166
+ url: "/threads",
1167
+ ...options,
1168
+ headers: {
1169
+ "Content-Type": "application/json",
1170
+ ...options?.headers
1171
+ }
1172
+ });
1173
+ /**
1174
+ * Search feedback
1175
+ *
1176
+ * Search and filter feedback entries with pagination.
1177
+ */
1178
+ const listFeedback = (options) => (options?.client ?? client).get({
1179
+ security: [{
1180
+ scheme: "bearer",
1181
+ type: "http"
1182
+ }],
1183
+ url: "/feedback",
1184
+ ...options
1185
+ });
1186
+ /**
1187
+ * Submit feedback
1188
+ *
1189
+ * Submit user feedback for a piece of content or chat message.
1190
+ */
1191
+ const submitFeedback = (options) => (options?.client ?? client).post({
1192
+ security: [{
1193
+ scheme: "bearer",
1194
+ type: "http"
1195
+ }],
1196
+ url: "/feedback",
1197
+ ...options,
1198
+ headers: {
1199
+ "Content-Type": "application/json",
1200
+ ...options?.headers
1201
+ }
1202
+ });
1203
+ /**
1204
+ * Get feedback analytics
1205
+ *
1206
+ * Retrieve aggregated feedback analytics for a date range.
1207
+ */
1208
+ const getFeedbackAnalytics = (options) => (options?.client ?? client).get({
1209
+ security: [{
1210
+ scheme: "bearer",
1211
+ type: "http"
1212
+ }],
1213
+ url: "/feedback/analytics",
1214
+ ...options
1215
+ });
1216
+ /**
1217
+ * Get feedback for a thread
1218
+ *
1219
+ * Retrieve all feedback entries associated with a specific thread.
1220
+ */
1221
+ const getThreadFeedback = (options) => (options.client ?? client).get({
1222
+ security: [{
1223
+ scheme: "bearer",
1224
+ type: "http"
1225
+ }],
1226
+ url: "/feedback/thread/{threadId}",
1227
+ ...options
1228
+ });
1229
+ /**
1230
+ * Delete feedback
1231
+ *
1232
+ * Delete a feedback entry by ID.
1233
+ */
1234
+ const deleteFeedback = (options) => (options.client ?? client).delete({
1235
+ security: [{
1236
+ scheme: "bearer",
1237
+ type: "http"
1238
+ }],
1239
+ url: "/feedback/{id}",
1240
+ ...options
1241
+ });
1242
+ /**
1243
+ * List prompts
1244
+ *
1245
+ * List prompts with optional pagination and metadata filters.
1246
+ */
1247
+ const listPrompts = (options) => (options?.client ?? client).get({
1248
+ security: [{
1249
+ scheme: "bearer",
1250
+ type: "http"
1251
+ }],
1252
+ url: "/prompts",
1253
+ ...options
1254
+ });
1255
+ /**
1256
+ * Upsert a prompt
1257
+ *
1258
+ * Create or update a prompt by external ID.
1259
+ */
1260
+ const upsertPrompt = (options) => (options?.client ?? client).post({
1261
+ security: [{
1262
+ scheme: "bearer",
1263
+ type: "http"
1264
+ }],
1265
+ url: "/prompts",
1266
+ ...options,
1267
+ headers: {
1268
+ "Content-Type": "application/json",
1269
+ ...options?.headers
1270
+ }
1271
+ });
1272
+ /**
1273
+ * Search prompts
1274
+ *
1275
+ * Semantic search across prompts with optional filters.
1276
+ */
1277
+ const searchPrompts = (options) => (options?.client ?? client).post({
1278
+ security: [{
1279
+ scheme: "bearer",
1280
+ type: "http"
1281
+ }],
1282
+ url: "/prompts/search",
1283
+ ...options,
1284
+ headers: {
1285
+ "Content-Type": "application/json",
1286
+ ...options?.headers
1287
+ }
1288
+ });
1289
+ /**
1290
+ * Bulk delete prompts
1291
+ *
1292
+ * Delete multiple prompts by their external IDs.
1293
+ */
1294
+ const bulkDeletePrompts = (options) => (options?.client ?? client).delete({
1295
+ security: [{
1296
+ scheme: "bearer",
1297
+ type: "http"
1298
+ }],
1299
+ url: "/prompts/bulk",
1300
+ ...options,
1301
+ headers: {
1302
+ "Content-Type": "application/json",
1303
+ ...options?.headers
1304
+ }
1305
+ });
1306
+ /**
1307
+ * Bulk upsert prompts
1308
+ *
1309
+ * Create or update up to 100 prompts in a single request.
1310
+ */
1311
+ const bulkUpsertPrompts = (options) => (options?.client ?? client).post({
1312
+ security: [{
1313
+ scheme: "bearer",
1314
+ type: "http"
1315
+ }],
1316
+ url: "/prompts/bulk",
1317
+ ...options,
1318
+ headers: {
1319
+ "Content-Type": "application/json",
1320
+ ...options?.headers
1321
+ }
1322
+ });
1323
+ /**
1324
+ * Delete a prompt
1325
+ *
1326
+ * Delete a single prompt by external ID.
1327
+ */
1328
+ const deletePrompt = (options) => (options.client ?? client).delete({
1329
+ security: [{
1330
+ scheme: "bearer",
1331
+ type: "http"
1332
+ }],
1333
+ url: "/prompts/{id}",
1334
+ ...options
1335
+ });
1336
+ /**
1337
+ * Get a prompt
1338
+ *
1339
+ * Retrieve a single prompt by external ID.
1340
+ */
1341
+ const getPrompt = (options) => (options.client ?? client).get({
1342
+ security: [{
1343
+ scheme: "bearer",
1344
+ type: "http"
1345
+ }],
1346
+ url: "/prompts/{id}",
1347
+ ...options
1348
+ });
1349
+ /**
1350
+ * Bulk update webhook status
1351
+ *
1352
+ * Update the status of multiple webhooks at once.
1353
+ */
1354
+ const bulkUpdateWebhookStatus = (options) => (options?.client ?? client).post({
1355
+ security: [{
1356
+ scheme: "bearer",
1357
+ type: "http"
1358
+ }],
1359
+ url: "/webhooks/bulk-status",
1360
+ ...options,
1361
+ headers: {
1362
+ "Content-Type": "application/json",
1363
+ ...options?.headers
1364
+ }
1365
+ });
1366
+ /**
1367
+ * List webhooks
1368
+ *
1369
+ * List all webhooks with optional filters, pagination, and sorting.
1370
+ */
1371
+ const listWebhooks = (options) => (options?.client ?? client).get({
1372
+ security: [{
1373
+ scheme: "bearer",
1374
+ type: "http"
1375
+ }],
1376
+ url: "/webhooks",
1377
+ ...options
1378
+ });
1379
+ /**
1380
+ * Create a webhook
1381
+ *
1382
+ * Register a new webhook endpoint to receive event notifications.
1383
+ */
1384
+ const createWebhook = (options) => (options?.client ?? client).post({
1385
+ security: [{
1386
+ scheme: "bearer",
1387
+ type: "http"
1388
+ }],
1389
+ url: "/webhooks",
1390
+ ...options,
1391
+ headers: {
1392
+ "Content-Type": "application/json",
1393
+ ...options?.headers
1394
+ }
1395
+ });
1396
+ /**
1397
+ * Test a webhook
1398
+ *
1399
+ * Send a test event to a webhook endpoint to verify connectivity.
1400
+ */
1401
+ const testWebhook = (options) => (options.client ?? client).post({
1402
+ security: [{
1403
+ scheme: "bearer",
1404
+ type: "http"
1405
+ }],
1406
+ url: "/webhooks/{id}/test",
1407
+ ...options
1408
+ });
1409
+ /**
1410
+ * Get webhook stats
1411
+ *
1412
+ * Retrieve delivery statistics for a specific webhook.
1413
+ */
1414
+ const getWebhookStats = (options) => (options.client ?? client).get({
1415
+ security: [{
1416
+ scheme: "bearer",
1417
+ type: "http"
1418
+ }],
1419
+ url: "/webhooks/{id}/stats",
1420
+ ...options
1421
+ });
1422
+ /**
1423
+ * Delete a webhook
1424
+ *
1425
+ * Permanently delete a webhook by ID.
1426
+ */
1427
+ const deleteWebhook = (options) => (options.client ?? client).delete({
1428
+ security: [{
1429
+ scheme: "bearer",
1430
+ type: "http"
1431
+ }],
1432
+ url: "/webhooks/{id}",
1433
+ ...options
1434
+ });
1435
+ /**
1436
+ * Get a webhook
1437
+ *
1438
+ * Retrieve a single webhook by ID. Sensitive fields are redacted.
1439
+ */
1440
+ const getWebhook = (options) => (options.client ?? client).get({
1441
+ security: [{
1442
+ scheme: "bearer",
1443
+ type: "http"
1444
+ }],
1445
+ url: "/webhooks/{id}",
1446
+ ...options
1447
+ });
1448
+ /**
1449
+ * Update a webhook
1450
+ *
1451
+ * Update an existing webhook configuration.
1452
+ */
1453
+ const updateWebhook = (options) => (options.client ?? client).put({
1454
+ security: [{
1455
+ scheme: "bearer",
1456
+ type: "http"
1457
+ }],
1458
+ url: "/webhooks/{id}",
1459
+ ...options,
1460
+ headers: {
1461
+ "Content-Type": "application/json",
1462
+ ...options.headers
1463
+ }
1464
+ });
1465
+ /**
1466
+ * List taxonomy terms
1467
+ *
1468
+ * List taxonomy terms with optional filters and pagination.
1469
+ */
1470
+ const listTaxonomies = (options) => (options?.client ?? client).get({
1471
+ security: [{
1472
+ scheme: "bearer",
1473
+ type: "http"
1474
+ }],
1475
+ url: "/taxonomies",
1476
+ ...options
1477
+ });
1478
+ /**
1479
+ * Upsert a taxonomy term
1480
+ *
1481
+ * Create or update a taxonomy term by external ID.
1482
+ */
1483
+ const upsertTaxonomy = (options) => (options?.client ?? client).post({
1484
+ security: [{
1485
+ scheme: "bearer",
1486
+ type: "http"
1487
+ }],
1488
+ url: "/taxonomies",
1489
+ ...options,
1490
+ headers: {
1491
+ "Content-Type": "application/json",
1492
+ ...options?.headers
1493
+ }
1494
+ });
1495
+ /**
1496
+ * Bulk delete taxonomy terms
1497
+ *
1498
+ * Delete multiple taxonomy terms by their external IDs.
1499
+ */
1500
+ const bulkDeleteTaxonomies = (options) => (options?.client ?? client).delete({
1501
+ security: [{
1502
+ scheme: "bearer",
1503
+ type: "http"
1504
+ }],
1505
+ url: "/taxonomies/bulk",
1506
+ ...options,
1507
+ headers: {
1508
+ "Content-Type": "application/json",
1509
+ ...options?.headers
1510
+ }
1511
+ });
1512
+ /**
1513
+ * Bulk upsert taxonomy terms
1514
+ *
1515
+ * Create or update up to 100 taxonomy terms in a single request.
1516
+ */
1517
+ const bulkUpsertTaxonomies = (options) => (options?.client ?? client).post({
1518
+ security: [{
1519
+ scheme: "bearer",
1520
+ type: "http"
1521
+ }],
1522
+ url: "/taxonomies/bulk",
1523
+ ...options,
1524
+ headers: {
1525
+ "Content-Type": "application/json",
1526
+ ...options?.headers
1527
+ }
1528
+ });
1529
+ /**
1530
+ * Delete taxonomy terms by query
1531
+ *
1532
+ * Delete all taxonomy terms matching the given filter criteria.
1533
+ */
1534
+ const deleteTaxonomiesByQuery = (options) => (options?.client ?? client).post({
1535
+ security: [{
1536
+ scheme: "bearer",
1537
+ type: "http"
1538
+ }],
1539
+ url: "/taxonomies/delete-by-query",
1540
+ ...options,
1541
+ headers: {
1542
+ "Content-Type": "application/json",
1543
+ ...options?.headers
1544
+ }
1545
+ });
1546
+ /**
1547
+ * List taxonomy term IDs
1548
+ *
1549
+ * Retrieve external IDs of indexed taxonomy terms with optional filters.
1550
+ */
1551
+ const listTaxonomyIds = (options) => (options?.client ?? client).get({
1552
+ security: [{
1553
+ scheme: "bearer",
1554
+ type: "http"
1555
+ }],
1556
+ url: "/taxonomies/ids",
1557
+ ...options
1558
+ });
1559
+ /**
1560
+ * Delete a taxonomy term
1561
+ *
1562
+ * Delete a single taxonomy term by external ID.
1563
+ */
1564
+ const deleteTaxonomy = (options) => (options.client ?? client).delete({
1565
+ security: [{
1566
+ scheme: "bearer",
1567
+ type: "http"
1568
+ }],
1569
+ url: "/taxonomies/{id}",
1570
+ ...options
1571
+ });
1572
+ /**
1573
+ * Get a taxonomy term
1574
+ *
1575
+ * Retrieve a single taxonomy term by external ID.
1576
+ */
1577
+ const getTaxonomy = (options) => (options.client ?? client).get({
1578
+ security: [{
1579
+ scheme: "bearer",
1580
+ type: "http"
1581
+ }],
1582
+ url: "/taxonomies/{id}",
1583
+ ...options
1584
+ });
1585
+ /**
1586
+ * Get search analytics
1587
+ *
1588
+ * Retrieve search analytics data including top queries, zero-result queries, and volume over time.
1589
+ */
1590
+ const getSearchAnalytics = (options) => (options?.client ?? client).get({
1591
+ security: [{
1592
+ scheme: "bearer",
1593
+ type: "http"
1594
+ }],
1595
+ url: "/analytics/search",
1596
+ ...options
1597
+ });
1598
+ /**
1599
+ * Search through search logs
1600
+ *
1601
+ * Query and filter recorded search logs with pagination and sorting.
1602
+ */
1603
+ const searchSearches = (options) => (options?.client ?? client).post({
1604
+ security: [{
1605
+ scheme: "bearer",
1606
+ type: "http"
1607
+ }],
1608
+ url: "/analytics/searches/search",
1609
+ ...options,
1610
+ headers: {
1611
+ "Content-Type": "application/json",
1612
+ ...options?.headers
1613
+ }
1614
+ });
1615
+ /**
1616
+ * Commit a search event
1617
+ *
1618
+ * Record a search event for analytics tracking. Requires search scope.
1619
+ */
1620
+ const commitSearch = (options) => (options?.client ?? client).post({
1621
+ security: [{
1622
+ scheme: "bearer",
1623
+ type: "http"
1624
+ }],
1625
+ url: "/analytics/searches/commit",
1626
+ ...options,
1627
+ headers: {
1628
+ "Content-Type": "application/json",
1629
+ ...options?.headers
1630
+ }
1631
+ });
1632
+ /**
1633
+ * Get chat analytics
1634
+ *
1635
+ * Retrieve chat/thread analytics data over a configurable time window.
1636
+ */
1637
+ const getChatAnalytics = (options) => (options?.client ?? client).get({
1638
+ security: [{
1639
+ scheme: "bearer",
1640
+ type: "http"
1641
+ }],
1642
+ url: "/analytics/chat",
1643
+ ...options
1644
+ });
1645
+ /**
1646
+ * Get feedback analytics
1647
+ *
1648
+ * Retrieve feedback analytics data with optional date range filtering.
1649
+ */
1650
+ const getAnalyticsFeedback = (options) => (options?.client ?? client).get({
1651
+ security: [{
1652
+ scheme: "bearer",
1653
+ type: "http"
1654
+ }],
1655
+ url: "/analytics/feedback",
1656
+ ...options
1657
+ });
1658
+ /**
1659
+ * Get product recommendations
1660
+ *
1661
+ * Retrieve AI-powered product recommendations based on a source product, basket affinity, and optional filters.
1662
+ */
1663
+ const getProductRecommendations = (options) => (options?.client ?? client).post({
1664
+ security: [{
1665
+ scheme: "bearer",
1666
+ type: "http"
1667
+ }],
1668
+ url: "/recommendations/products",
1669
+ ...options,
1670
+ headers: {
1671
+ "Content-Type": "application/json",
1672
+ ...options?.headers
1673
+ }
1674
+ });
1675
+ /**
1676
+ * Self-delete tenant
1677
+ */
1678
+ const deleteTenant = (options) => (options.client ?? client).delete({
1679
+ security: [{
1680
+ scheme: "bearer",
1681
+ type: "http"
1682
+ }],
1683
+ url: "/tenant/{tenantId}",
1684
+ ...options
1685
+ });
1686
+ /**
1687
+ * Get tenant status
1688
+ *
1689
+ * Validate API key and retrieve tenant account information including tier, publishable key, and JWT secret.
1690
+ */
1691
+ const getTenantStatus = (options) => (options?.client ?? client).get({
1692
+ security: [{
1693
+ scheme: "bearer",
1694
+ type: "http"
1695
+ }],
1696
+ url: "/tenant/status",
1697
+ ...options
1698
+ });
1699
+ /**
1700
+ * Update tenant feature flags
1701
+ */
1702
+ const updateTenantFeatures = (options) => (options?.client ?? client).patch({
1703
+ security: [{
1704
+ scheme: "bearer",
1705
+ type: "http"
1706
+ }],
1707
+ url: "/tenant/features",
1708
+ ...options,
1709
+ headers: {
1710
+ "Content-Type": "application/json",
1711
+ ...options?.headers
1712
+ }
1713
+ });
1714
+ /**
1715
+ * Get usage summary
1716
+ */
1717
+ const getTenantUsage = (options) => (options?.client ?? client).get({
1718
+ security: [{
1719
+ scheme: "bearer",
1720
+ type: "http"
1721
+ }],
1722
+ url: "/tenant/usage",
1723
+ ...options
1724
+ });
1725
+ /**
1726
+ * Get daily usage history
1727
+ */
1728
+ const getTenantUsageHistory = (options) => (options?.client ?? client).get({
1729
+ security: [{
1730
+ scheme: "bearer",
1731
+ type: "http"
1732
+ }],
1733
+ url: "/tenant/usage/history",
1734
+ ...options
1735
+ });
1736
+ /**
1737
+ * List workspaces
1738
+ *
1739
+ * List all workspaces for the authenticated tenant.
1740
+ */
1741
+ const listTenantWorkspaces = (options) => (options?.client ?? client).get({
1742
+ security: [{
1743
+ scheme: "bearer",
1744
+ type: "http"
1745
+ }],
1746
+ url: "/tenant/workspaces",
1747
+ ...options
1748
+ });
1749
+ /**
1750
+ * Create a workspace
1751
+ *
1752
+ * Create a new workspace under the authenticated tenant.
1753
+ */
1754
+ const createTenantWorkspace = (options) => (options?.client ?? client).post({
1755
+ security: [{
1756
+ scheme: "bearer",
1757
+ type: "http"
1758
+ }],
1759
+ url: "/tenant/workspaces",
1760
+ ...options,
1761
+ headers: {
1762
+ "Content-Type": "application/json",
1763
+ ...options?.headers
1764
+ }
1765
+ });
1766
+ /**
1767
+ * Delete a workspace
1768
+ */
1769
+ const deleteWorkspace = (options) => (options.client ?? client).delete({
1770
+ security: [{
1771
+ scheme: "bearer",
1772
+ type: "http"
1773
+ }],
1774
+ url: "/tenant/workspaces/{workspaceId}",
1775
+ ...options
1776
+ });
1777
+ /**
1778
+ * Update a workspace
1779
+ */
1780
+ const updateWorkspace = (options) => (options.client ?? client).put({
1781
+ security: [{
1782
+ scheme: "bearer",
1783
+ type: "http"
1784
+ }],
1785
+ url: "/tenant/workspaces/{workspaceId}",
1786
+ ...options,
1787
+ headers: {
1788
+ "Content-Type": "application/json",
1789
+ ...options.headers
1790
+ }
1791
+ });
1792
+ /**
1793
+ * Get document statistics
1794
+ *
1795
+ * Retrieve document counts and breakdown by type from the knowledge base.
1796
+ */
1797
+ const getKnowledge = (options) => (options?.client ?? client).get({
1798
+ security: [{
1799
+ scheme: "bearer",
1800
+ type: "http"
1801
+ }],
1802
+ url: "/tenant/knowledge",
1803
+ ...options
1804
+ });
1805
+ /**
1806
+ * Search knowledge base documents
1807
+ */
1808
+ const searchKnowledge = (options) => (options?.client ?? client).get({
1809
+ security: [{
1810
+ scheme: "bearer",
1811
+ type: "http"
1812
+ }],
1813
+ url: "/tenant/knowledge/search",
1814
+ ...options
1815
+ });
1816
+ /**
1817
+ * Get presigned upload URL
1818
+ */
1819
+ const getUploadUrl = (options) => (options?.client ?? client).post({
1820
+ security: [{
1821
+ scheme: "bearer",
1822
+ type: "http"
1823
+ }],
1824
+ url: "/tenant/upload-url",
1825
+ ...options,
1826
+ headers: {
1827
+ "Content-Type": "application/json",
1828
+ ...options?.headers
1829
+ }
1830
+ });
1831
+ /**
1832
+ * Delete MCP configuration
1833
+ */
1834
+ const deleteMcpConfig = (options) => (options?.client ?? client).delete({
1835
+ security: [{
1836
+ scheme: "bearer",
1837
+ type: "http"
1838
+ }],
1839
+ url: "/tenant/mcp",
1840
+ ...options
1841
+ });
1842
+ /**
1843
+ * Get MCP configuration
1844
+ */
1845
+ const getMcpConfig = (options) => (options?.client ?? client).get({
1846
+ security: [{
1847
+ scheme: "bearer",
1848
+ type: "http"
1849
+ }],
1850
+ url: "/tenant/mcp",
1851
+ ...options
1852
+ });
1853
+ /**
1854
+ * Update MCP configuration
1855
+ */
1856
+ const updateMcpConfig = (options) => (options?.client ?? client).put({
1857
+ security: [{
1858
+ scheme: "bearer",
1859
+ type: "http"
1860
+ }],
1861
+ url: "/tenant/mcp",
1862
+ ...options,
1863
+ headers: {
1864
+ "Content-Type": "application/json",
1865
+ ...options?.headers
1866
+ }
1867
+ });
1868
+ /**
1869
+ * Check live agent credential status
1870
+ */
1871
+ const getCredentialStatus = (options) => (options?.client ?? client).get({
1872
+ security: [{
1873
+ scheme: "bearer",
1874
+ type: "http"
1875
+ }],
1876
+ url: "/tenant/credentials/status",
1877
+ ...options
1878
+ });
1879
+ /**
1880
+ * Delete live agent credentials
1881
+ */
1882
+ const deleteCredentials = (options) => (options?.client ?? client).delete({
1883
+ security: [{
1884
+ scheme: "bearer",
1885
+ type: "http"
1886
+ }],
1887
+ url: "/tenant/credentials",
1888
+ ...options
1889
+ });
1890
+ /**
1891
+ * Store live agent credentials
1892
+ */
1893
+ const storeCredentials = (options) => (options?.client ?? client).post({
1894
+ security: [{
1895
+ scheme: "bearer",
1896
+ type: "http"
1897
+ }],
1898
+ url: "/tenant/credentials",
1899
+ ...options,
1900
+ headers: {
1901
+ "Content-Type": "application/json",
1902
+ ...options?.headers
1903
+ }
1904
+ });
1905
+ /**
1906
+ * Delete live agent schedule
1907
+ */
1908
+ const deleteLiveAgentSchedule = (options) => (options?.client ?? client).delete({
1909
+ security: [{
1910
+ scheme: "bearer",
1911
+ type: "http"
1912
+ }],
1913
+ url: "/tenant/schedule",
1914
+ ...options
1915
+ });
1916
+ /**
1917
+ * Get live agent schedule
1918
+ */
1919
+ const getLiveAgentSchedule = (options) => (options?.client ?? client).get({
1920
+ security: [{
1921
+ scheme: "bearer",
1922
+ type: "http"
1923
+ }],
1924
+ url: "/tenant/schedule",
1925
+ ...options
1926
+ });
1927
+ /**
1928
+ * Update live agent schedule
1929
+ */
1930
+ const updateLiveAgentSchedule = (options) => (options?.client ?? client).put({
1931
+ security: [{
1932
+ scheme: "bearer",
1933
+ type: "http"
1934
+ }],
1935
+ url: "/tenant/schedule",
1936
+ ...options,
1937
+ headers: {
1938
+ "Content-Type": "application/json",
1939
+ ...options?.headers
1940
+ }
1941
+ });
1942
+ /**
1943
+ * Get workspace settings
1944
+ *
1945
+ * Retrieve settings for a workspace including live agent configuration and special instructions.
1946
+ */
1947
+ const getWorkspaceSettings = (options) => (options.client ?? client).get({
1948
+ security: [{
1949
+ scheme: "bearer",
1950
+ type: "http"
1951
+ }],
1952
+ url: "/workspace/{workspaceId}/settings",
1953
+ ...options
1954
+ });
1955
+ /**
1956
+ * Update workspace settings
1957
+ *
1958
+ * Update workspace settings such as live agent configuration, description, and special instructions.
1959
+ */
1960
+ const updateWorkspaceSettings = (options) => (options.client ?? client).patch({
1961
+ security: [{
1962
+ scheme: "bearer",
1963
+ type: "http"
1964
+ }],
1965
+ url: "/workspace/{workspaceId}/settings",
1966
+ ...options,
1967
+ headers: {
1968
+ "Content-Type": "application/json",
1969
+ ...options.headers
1970
+ }
1971
+ });
1972
+ /**
1973
+ * Get live agent connection status
1974
+ */
1975
+ const getLiveAgentStatus = (options) => (options.client ?? client).get({
1976
+ security: [{
1977
+ scheme: "bearer",
1978
+ type: "http"
1979
+ }],
1980
+ url: "/workspace/{workspaceId}/live-agent/status",
1981
+ ...options
1982
+ });
1983
+ /**
1984
+ * List Slack channels for live agent
1985
+ */
1986
+ const listSlackChannels = (options) => (options.client ?? client).get({
1987
+ security: [{
1988
+ scheme: "bearer",
1989
+ type: "http"
1990
+ }],
1991
+ url: "/workspace/{workspaceId}/live-agent/slack/channels",
1992
+ ...options
1993
+ });
1994
+ /**
1995
+ * Get chat widget configuration
1996
+ */
1997
+ const getChatWidgetConfig = (options) => (options.client ?? client).get({
1998
+ security: [{
1999
+ scheme: "bearer",
2000
+ type: "http"
2001
+ }],
2002
+ url: "/workspace/{workspaceId}/chat",
2003
+ ...options
2004
+ });
2005
+ /**
2006
+ * Update chat widget configuration
2007
+ */
2008
+ const updateChatWidgetConfig = (options) => (options.client ?? client).post({
2009
+ security: [{
2010
+ scheme: "bearer",
2011
+ type: "http"
2012
+ }],
2013
+ url: "/workspace/{workspaceId}/chat",
2014
+ ...options,
2015
+ headers: {
2016
+ "Content-Type": "application/json",
2017
+ ...options.headers
2018
+ }
2019
+ });
2020
+ /**
2021
+ * Get search widget configuration
2022
+ */
2023
+ const getSearchWidgetConfig = (options) => (options.client ?? client).get({
2024
+ security: [{
2025
+ scheme: "bearer",
2026
+ type: "http"
2027
+ }],
2028
+ url: "/workspace/{workspaceId}/search",
2029
+ ...options
2030
+ });
2031
+ /**
2032
+ * Update search widget configuration
2033
+ */
2034
+ const updateSearchWidgetConfig = (options) => (options.client ?? client).post({
2035
+ security: [{
2036
+ scheme: "bearer",
2037
+ type: "http"
2038
+ }],
2039
+ url: "/workspace/{workspaceId}/search",
2040
+ ...options,
2041
+ headers: {
2042
+ "Content-Type": "application/json",
2043
+ ...options.headers
2044
+ }
2045
+ });
2046
+ /**
2047
+ * List custom domains
2048
+ */
2049
+ const listCustomDomains = (options) => (options.client ?? client).get({
2050
+ security: [{
2051
+ scheme: "bearer",
2052
+ type: "http"
2053
+ }],
2054
+ url: "/workspace/{workspaceId}/custom-domain",
2055
+ ...options
2056
+ });
2057
+ /**
2058
+ * Create a custom domain
2059
+ *
2060
+ * Register a custom domain (MCP server, API endpoints) for AI chat integration.
2061
+ */
2062
+ const createCustomDomain = (options) => (options.client ?? client).post({
2063
+ security: [{
2064
+ scheme: "bearer",
2065
+ type: "http"
2066
+ }],
2067
+ url: "/workspace/{workspaceId}/custom-domain",
2068
+ ...options,
2069
+ headers: {
2070
+ "Content-Type": "application/json",
2071
+ ...options.headers
2072
+ }
2073
+ });
2074
+ /**
2075
+ * Delete a custom domain
2076
+ *
2077
+ * Remove a custom domain configuration from the workspace.
2078
+ */
2079
+ const deleteCustomDomain = (options) => (options.client ?? client).delete({
2080
+ security: [{
2081
+ scheme: "bearer",
2082
+ type: "http"
2083
+ }],
2084
+ url: "/workspace/{workspaceId}/custom-domain/{domainId}",
2085
+ ...options
2086
+ });
2087
+ /**
2088
+ * Update a custom domain
2089
+ */
2090
+ const updateCustomDomain = (options) => (options.client ?? client).put({
2091
+ security: [{
2092
+ scheme: "bearer",
2093
+ type: "http"
2094
+ }],
2095
+ url: "/workspace/{workspaceId}/custom-domain/{domainId}",
2096
+ ...options,
2097
+ headers: {
2098
+ "Content-Type": "application/json",
2099
+ ...options.headers
2100
+ }
2101
+ });
2102
+ /**
2103
+ * Get error counts across all domains
2104
+ */
2105
+ const getDomainErrorSummary = (options) => (options.client ?? client).get({
2106
+ security: [{
2107
+ scheme: "bearer",
2108
+ type: "http"
2109
+ }],
2110
+ url: "/workspace/{workspaceId}/custom-domain/error-summary",
2111
+ ...options
2112
+ });
2113
+ /**
2114
+ * Clear error logs for a domain
2115
+ */
2116
+ const clearDomainErrors = (options) => (options.client ?? client).delete({
2117
+ security: [{
2118
+ scheme: "bearer",
2119
+ type: "http"
2120
+ }],
2121
+ url: "/workspace/{workspaceId}/custom-domain/{domainId}/errors",
2122
+ ...options
2123
+ });
2124
+ /**
2125
+ * Get error logs for a domain
2126
+ */
2127
+ const getDomainErrors = (options) => (options.client ?? client).get({
2128
+ security: [{
2129
+ scheme: "bearer",
2130
+ type: "http"
2131
+ }],
2132
+ url: "/workspace/{workspaceId}/custom-domain/{domainId}/errors",
2133
+ ...options
2134
+ });
2135
+ /**
2136
+ * Validate a custom domain configuration
2137
+ */
2138
+ const validateCustomDomain = (options) => (options.client ?? client).post({
2139
+ security: [{
2140
+ scheme: "bearer",
2141
+ type: "http"
2142
+ }],
2143
+ url: "/workspace/{workspaceId}/custom-domain/validate",
2144
+ ...options,
2145
+ headers: {
2146
+ "Content-Type": "application/json",
2147
+ ...options.headers
2148
+ }
2149
+ });
2150
+ /**
2151
+ * Test domain classification with sample queries
2152
+ */
2153
+ const testDomainConnection = (options) => (options.client ?? client).post({
2154
+ security: [{
2155
+ scheme: "bearer",
2156
+ type: "http"
2157
+ }],
2158
+ url: "/workspace/{workspaceId}/test-connection",
2159
+ ...options,
2160
+ headers: {
2161
+ "Content-Type": "application/json",
2162
+ ...options.headers
2163
+ }
2164
+ });
2165
+ /**
2166
+ * Get workspace details
2167
+ */
2168
+ const getWorkspaceDetails = (options) => (options.client ?? client).get({
2169
+ security: [{
2170
+ scheme: "bearer",
2171
+ type: "http"
2172
+ }],
2173
+ url: "/workspace/{workspaceId}/details",
2174
+ ...options
2175
+ });
2176
+ /**
2177
+ * Discover available tools from MCP servers
2178
+ */
2179
+ const discoverTools = (options) => (options.client ?? client).post({
2180
+ security: [{
2181
+ scheme: "bearer",
2182
+ type: "http"
2183
+ }],
2184
+ url: "/workspace/{workspaceId}/discover-tools",
2185
+ ...options,
2186
+ headers: {
2187
+ "Content-Type": "application/json",
2188
+ ...options.headers
2189
+ }
2190
+ });
2191
+ /**
2192
+ * AI-generate a custom domain configuration
2193
+ */
2194
+ const generateDomainConfig = (options) => (options.client ?? client).post({
2195
+ security: [{
2196
+ scheme: "bearer",
2197
+ type: "http"
2198
+ }],
2199
+ url: "/workspace/{workspaceId}/custom-domain/generate",
2200
+ ...options,
2201
+ headers: {
2202
+ "Content-Type": "application/json",
2203
+ ...options.headers
2204
+ }
2205
+ });
2206
+ /**
2207
+ * Get available domain templates
2208
+ */
2209
+ const getDomainTemplates = (options) => (options.client ?? client).get({
2210
+ security: [{
2211
+ scheme: "bearer",
2212
+ type: "http"
2213
+ }],
2214
+ url: "/workspace/{workspaceId}/templates",
2215
+ ...options
2216
+ });
2217
+ /**
2218
+ * Deprovision a tenant or workspace
2219
+ *
2220
+ * Tear down a tenant or single workspace. Supports two auth modes: admin (set tenantId in the body to deprovision any tenant) or tenant self-deprovision (authenticate with the tenant API key; tenantId is derived from the auth context). Used by the Shopify app on app uninstall.
2221
+ */
2222
+ const deprovision = (options) => (options?.client ?? client).post({
2223
+ security: [{
2224
+ scheme: "bearer",
2225
+ type: "http"
2226
+ }],
2227
+ url: "/provision/deprovision",
2228
+ ...options,
2229
+ headers: {
2230
+ "Content-Type": "application/json",
2231
+ ...options?.headers
2232
+ }
2233
+ });
2234
+ /**
2235
+ * List API keys
2236
+ *
2237
+ * List all API keys for the authenticated tenant.
2238
+ */
2239
+ const listApiKeys = (options) => (options?.client ?? client).get({
2240
+ security: [{
2241
+ scheme: "bearer",
2242
+ type: "http"
2243
+ }],
2244
+ url: "/provision/keys",
2245
+ ...options
2246
+ });
2247
+ /**
2248
+ * Create an API key
2249
+ *
2250
+ * Create a new API key for the authenticated tenant.
2251
+ */
2252
+ const createApiKey = (options) => (options?.client ?? client).post({
2253
+ security: [{
2254
+ scheme: "bearer",
2255
+ type: "http"
2256
+ }],
2257
+ url: "/provision/keys",
2258
+ ...options,
2259
+ headers: {
2260
+ "Content-Type": "application/json",
2261
+ ...options?.headers
2262
+ }
2263
+ });
2264
+ /**
2265
+ * Revoke an API key
2266
+ *
2267
+ * Revoke an API key by ID.
2268
+ */
2269
+ const revokeApiKey = (options) => (options.client ?? client).post({
2270
+ security: [{
2271
+ scheme: "bearer",
2272
+ type: "http"
2273
+ }],
2274
+ url: "/provision/keys/{keyId}/revoke",
2275
+ ...options
2276
+ });
2277
+ /**
2278
+ * Rotate an API key
2279
+ *
2280
+ * Rotate an API key, generating a new key and revoking the old one.
2281
+ */
2282
+ const rotateApiKey = (options) => (options.client ?? client).post({
2283
+ security: [{
2284
+ scheme: "bearer",
2285
+ type: "http"
2286
+ }],
2287
+ url: "/provision/keys/{keyId}/rotate",
2288
+ ...options,
2289
+ headers: {
2290
+ "Content-Type": "application/json",
2291
+ ...options.headers
2292
+ }
2293
+ });
2294
+ /**
2295
+ * Provision a Shopify tenant
2296
+ *
2297
+ * Called by the Savanto Shopify app after a merchant completes OAuth. Creates a new tenant + workspace, or reactivates and reissues keys if the shop was previously installed.
2298
+ */
2299
+ const provisionShopify = (options) => (options?.client ?? client).post({
2300
+ security: [{
2301
+ scheme: "bearer",
2302
+ type: "http"
2303
+ }],
2304
+ url: "/provision/shopify",
2305
+ ...options,
2306
+ headers: {
2307
+ "Content-Type": "application/json",
2308
+ ...options?.headers
2309
+ }
2310
+ });
2311
+ /**
2312
+ * Delete a tenant and all associated data
2313
+ */
2314
+ const adminDeleteTenant = (options) => (options.client ?? client).delete({
2315
+ security: [{
2316
+ scheme: "bearer",
2317
+ type: "http"
2318
+ }],
2319
+ url: "/admin/tenant/{tenantId}",
2320
+ ...options
2321
+ });
2322
+ /**
2323
+ * Get tenant details
2324
+ */
2325
+ const adminGetTenant = (options) => (options.client ?? client).get({
2326
+ security: [{
2327
+ scheme: "bearer",
2328
+ type: "http"
2329
+ }],
2330
+ url: "/admin/tenant/{tenantId}",
2331
+ ...options
2332
+ });
2333
+ /**
2334
+ * Find unclaimed tenants by email
2335
+ */
2336
+ const adminFindByEmail = (options) => (options.client ?? client).get({
2337
+ security: [{
2338
+ scheme: "bearer",
2339
+ type: "http"
2340
+ }],
2341
+ url: "/admin/tenant/by-email/{email}",
2342
+ ...options
2343
+ });
2344
+ /**
2345
+ * Find tenants by owner ID
2346
+ */
2347
+ const adminFindByOwner = (options) => (options.client ?? client).get({
2348
+ security: [{
2349
+ scheme: "bearer",
2350
+ type: "http"
2351
+ }],
2352
+ url: "/admin/tenant/by-owner/{ownerId}",
2353
+ ...options
2354
+ });
2355
+ /**
2356
+ * Claim an unclaimed tenant
2357
+ */
2358
+ const adminClaimTenant = (options) => (options.client ?? client).post({
2359
+ security: [{
2360
+ scheme: "bearer",
2361
+ type: "http"
2362
+ }],
2363
+ url: "/admin/tenant/{tenantId}/claim",
2364
+ ...options,
2365
+ headers: {
2366
+ "Content-Type": "application/json",
2367
+ ...options.headers
2368
+ }
2369
+ });
2370
+ /**
2371
+ * Update a tenant's owner email
2372
+ */
2373
+ const adminUpdateOwnerEmail = (options) => (options.client ?? client).patch({
2374
+ security: [{
2375
+ scheme: "bearer",
2376
+ type: "http"
2377
+ }],
2378
+ url: "/admin/tenant/{tenantId}/owner-email",
2379
+ ...options,
2380
+ headers: {
2381
+ "Content-Type": "application/json",
2382
+ ...options.headers
2383
+ }
2384
+ });
2385
+ /**
2386
+ * Update a tenant's subscription
2387
+ */
2388
+ const adminUpdateSubscription = (options) => (options.client ?? client).patch({
2389
+ security: [{
2390
+ scheme: "bearer",
2391
+ type: "http"
2392
+ }],
2393
+ url: "/admin/tenant/{tenantId}/subscription",
2394
+ ...options,
2395
+ headers: {
2396
+ "Content-Type": "application/json",
2397
+ ...options.headers
2398
+ }
2399
+ });
2400
+ /**
2401
+ * Reactivate a soft-deleted tenant
2402
+ */
2403
+ const adminReactivateTenant = (options) => (options.client ?? client).post({
2404
+ security: [{
2405
+ scheme: "bearer",
2406
+ type: "http"
2407
+ }],
2408
+ url: "/admin/tenant/{tenantId}/reactivate",
2409
+ ...options
2410
+ });
2411
+ /**
2412
+ * Get detailed usage for a tenant
2413
+ */
2414
+ const adminGetUsage = (options) => (options.client ?? client).get({
2415
+ security: [{
2416
+ scheme: "bearer",
2417
+ type: "http"
2418
+ }],
2419
+ url: "/admin/tenant/{tenantId}/usage",
2420
+ ...options
2421
+ });
2422
+ /**
2423
+ * Set usage metric values
2424
+ */
2425
+ const adminUpdateUsage = (options) => (options.client ?? client).patch({
2426
+ security: [{
2427
+ scheme: "bearer",
2428
+ type: "http"
2429
+ }],
2430
+ url: "/admin/tenant/{tenantId}/usage",
2431
+ ...options,
2432
+ headers: {
2433
+ "Content-Type": "application/json",
2434
+ ...options.headers
2435
+ }
2436
+ });
2437
+ /**
2438
+ * Update a tenant's tier
2439
+ */
2440
+ const adminUpdateTier = (options) => (options.client ?? client).patch({
2441
+ security: [{
2442
+ scheme: "bearer",
2443
+ type: "http"
2444
+ }],
2445
+ url: "/admin/tenant/{tenantId}/tier",
2446
+ ...options,
2447
+ headers: {
2448
+ "Content-Type": "application/json",
2449
+ ...options.headers
2450
+ }
2451
+ });
2452
+ /**
2453
+ * Reset a tenant's crawl records for the current month
2454
+ */
2455
+ const adminResetCrawls = (options) => (options.client ?? client).post({
2456
+ security: [{
2457
+ scheme: "bearer",
2458
+ type: "http"
2459
+ }],
2460
+ url: "/admin/tenant/{tenantId}/crawls/reset",
2461
+ ...options
2462
+ });
2463
+
2464
+ //#endregion
2465
+ //#region src/util.ts
2466
+ /**
2467
+ * Convert a URL or domain to a normalized workspace ID.
2468
+ *
2469
+ * @example
2470
+ * workspaceIdFromUrl('https://mystore.com') // 'mystore-com'
2471
+ * workspaceIdFromUrl('my-store.myshopify.com') // 'my-store-myshopify-com'
2472
+ * workspaceIdFromUrl('example.com/path') // 'example-com'
2473
+ */
2474
+ function workspaceIdFromUrl(url) {
2475
+ if (!url) return "";
2476
+ try {
2477
+ return new URL(url.startsWith("http") ? url : `https://${url}`).hostname.replace(/\./g, "-").toLowerCase();
2478
+ } catch {
2479
+ return url.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/[^a-z0-9-]/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
2480
+ }
2481
+ }
2482
+
2483
+ //#endregion
2484
+ exports.adminClaimTenant = adminClaimTenant;
2485
+ exports.adminDeleteTenant = adminDeleteTenant;
2486
+ exports.adminFindByEmail = adminFindByEmail;
2487
+ exports.adminFindByOwner = adminFindByOwner;
2488
+ exports.adminGetTenant = adminGetTenant;
2489
+ exports.adminGetUsage = adminGetUsage;
2490
+ exports.adminReactivateTenant = adminReactivateTenant;
2491
+ exports.adminResetCrawls = adminResetCrawls;
2492
+ exports.adminUpdateOwnerEmail = adminUpdateOwnerEmail;
2493
+ exports.adminUpdateSubscription = adminUpdateSubscription;
2494
+ exports.adminUpdateTier = adminUpdateTier;
2495
+ exports.adminUpdateUsage = adminUpdateUsage;
2496
+ exports.bulkDeletePosts = bulkDeletePosts;
2497
+ exports.bulkDeleteProducts = bulkDeleteProducts;
2498
+ exports.bulkDeletePrompts = bulkDeletePrompts;
2499
+ exports.bulkDeleteTaxonomies = bulkDeleteTaxonomies;
2500
+ exports.bulkDeleteThreads = bulkDeleteThreads;
2501
+ exports.bulkUpdateWebhookStatus = bulkUpdateWebhookStatus;
2502
+ exports.bulkUpsertPosts = bulkUpsertPosts;
2503
+ exports.bulkUpsertProducts = bulkUpsertProducts;
2504
+ exports.bulkUpsertPrompts = bulkUpsertPrompts;
2505
+ exports.bulkUpsertTaxonomies = bulkUpsertTaxonomies;
2506
+ exports.cancelCrawl = cancelCrawl;
2507
+ exports.chat = chat;
2508
+ exports.clearDomainErrors = clearDomainErrors;
2509
+ exports.client = client;
2510
+ exports.commitSearch = commitSearch;
2511
+ exports.createApiKey = createApiKey;
2512
+ exports.createClient = createClient;
2513
+ exports.createConfig = createConfig;
2514
+ exports.createCustomDomain = createCustomDomain;
2515
+ exports.createTenantWorkspace = createTenantWorkspace;
2516
+ exports.createWebhook = createWebhook;
2517
+ exports.deleteCredentials = deleteCredentials;
2518
+ exports.deleteCustomDomain = deleteCustomDomain;
2519
+ exports.deleteFeedback = deleteFeedback;
2520
+ exports.deleteLiveAgentSchedule = deleteLiveAgentSchedule;
2521
+ exports.deleteMcpConfig = deleteMcpConfig;
2522
+ exports.deletePost = deletePost;
2523
+ exports.deletePostsByQuery = deletePostsByQuery;
2524
+ exports.deleteProduct = deleteProduct;
2525
+ exports.deleteProductsByQuery = deleteProductsByQuery;
2526
+ exports.deletePrompt = deletePrompt;
2527
+ exports.deleteTaxonomiesByQuery = deleteTaxonomiesByQuery;
2528
+ exports.deleteTaxonomy = deleteTaxonomy;
2529
+ exports.deleteTenant = deleteTenant;
2530
+ exports.deleteThread = deleteThread;
2531
+ exports.deleteWebhook = deleteWebhook;
2532
+ exports.deleteWorkspace = deleteWorkspace;
2533
+ exports.deprovision = deprovision;
2534
+ exports.discoverTools = discoverTools;
2535
+ exports.endHandoff = endHandoff;
2536
+ exports.exportThreads = exportThreads;
2537
+ exports.generateDomainConfig = generateDomainConfig;
2538
+ exports.getAnalyticsFeedback = getAnalyticsFeedback;
2539
+ exports.getChatAnalytics = getChatAnalytics;
2540
+ exports.getChatWidgetConfig = getChatWidgetConfig;
2541
+ exports.getCrawlConfig = getCrawlConfig;
2542
+ exports.getCrawlHistory = getCrawlHistory;
2543
+ exports.getCrawlStatus = getCrawlStatus;
2544
+ exports.getCredentialStatus = getCredentialStatus;
2545
+ exports.getDomainErrorSummary = getDomainErrorSummary;
2546
+ exports.getDomainErrors = getDomainErrors;
2547
+ exports.getDomainTemplates = getDomainTemplates;
2548
+ exports.getFeedbackAnalytics = getFeedbackAnalytics;
2549
+ exports.getKnowledge = getKnowledge;
2550
+ exports.getLiveAgentSchedule = getLiveAgentSchedule;
2551
+ exports.getLiveAgentStatus = getLiveAgentStatus;
2552
+ exports.getMcpConfig = getMcpConfig;
2553
+ exports.getPost = getPost;
2554
+ exports.getProduct = getProduct;
2555
+ exports.getProductRecommendations = getProductRecommendations;
2556
+ exports.getPrompt = getPrompt;
2557
+ exports.getSearchAnalytics = getSearchAnalytics;
2558
+ exports.getSearchWidgetConfig = getSearchWidgetConfig;
2559
+ exports.getTaxonomy = getTaxonomy;
2560
+ exports.getTenantStatus = getTenantStatus;
2561
+ exports.getTenantUsage = getTenantUsage;
2562
+ exports.getTenantUsageHistory = getTenantUsageHistory;
2563
+ exports.getThread = getThread;
2564
+ exports.getThreadAnalytics = getThreadAnalytics;
2565
+ exports.getThreadFeedback = getThreadFeedback;
2566
+ exports.getThreadMessages = getThreadMessages;
2567
+ exports.getUploadUrl = getUploadUrl;
2568
+ exports.getWebhook = getWebhook;
2569
+ exports.getWebhookStats = getWebhookStats;
2570
+ exports.getWorkspaceDetails = getWorkspaceDetails;
2571
+ exports.getWorkspaceSettings = getWorkspaceSettings;
2572
+ exports.listApiKeys = listApiKeys;
2573
+ exports.listCustomDomains = listCustomDomains;
2574
+ exports.listFeedback = listFeedback;
2575
+ exports.listPostIds = listPostIds;
2576
+ exports.listProductIds = listProductIds;
2577
+ exports.listProducts = listProducts;
2578
+ exports.listPrompts = listPrompts;
2579
+ exports.listSlackChannels = listSlackChannels;
2580
+ exports.listTaxonomies = listTaxonomies;
2581
+ exports.listTaxonomyIds = listTaxonomyIds;
2582
+ exports.listTenantWorkspaces = listTenantWorkspaces;
2583
+ exports.listWebhooks = listWebhooks;
2584
+ exports.patchPost = patchPost;
2585
+ exports.patchProduct = patchProduct;
2586
+ exports.provisionShopify = provisionShopify;
2587
+ exports.revokeApiKey = revokeApiKey;
2588
+ exports.rotateApiKey = rotateApiKey;
2589
+ exports.scrapePage = scrapePage;
2590
+ exports.scrapeSinglePage = scrapeSinglePage;
2591
+ exports.searchKnowledge = searchKnowledge;
2592
+ exports.searchPosts = searchPosts;
2593
+ exports.searchProducts = searchProducts;
2594
+ exports.searchPrompts = searchPrompts;
2595
+ exports.searchSearches = searchSearches;
2596
+ exports.searchThreads = searchThreads;
2597
+ exports.startCrawl = startCrawl;
2598
+ exports.storeCredentials = storeCredentials;
2599
+ exports.submitFeedback = submitFeedback;
2600
+ exports.testDomainConnection = testDomainConnection;
2601
+ exports.testWebhook = testWebhook;
2602
+ exports.updateChatWidgetConfig = updateChatWidgetConfig;
2603
+ exports.updateCrawlConfig = updateCrawlConfig;
2604
+ exports.updateCustomDomain = updateCustomDomain;
2605
+ exports.updateLiveAgentSchedule = updateLiveAgentSchedule;
2606
+ exports.updateMcpConfig = updateMcpConfig;
2607
+ exports.updateSearchWidgetConfig = updateSearchWidgetConfig;
2608
+ exports.updateTenantFeatures = updateTenantFeatures;
2609
+ exports.updateWebhook = updateWebhook;
2610
+ exports.updateWorkspace = updateWorkspace;
2611
+ exports.updateWorkspaceSettings = updateWorkspaceSettings;
2612
+ exports.upsertPost = upsertPost;
2613
+ exports.upsertProduct = upsertProduct;
2614
+ exports.upsertPrompt = upsertPrompt;
2615
+ exports.upsertTaxonomy = upsertTaxonomy;
2616
+ exports.validateCustomDomain = validateCustomDomain;
2617
+ exports.workspaceIdFromUrl = workspaceIdFromUrl;
2618
+ //# sourceMappingURL=index.cjs.map