@kerabie/sdk 0.0.0-stage → 1.0.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/README.md +344 -3
- package/dist/index.d.mts +1292 -0
- package/dist/index.d.ts +1292 -0
- package/dist/index.js +537 -0
- package/dist/index.mjs +507 -0
- package/package.json +30 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
HttpError: () => HttpError,
|
|
24
|
+
KerAbieClient: () => KerAbieClient,
|
|
25
|
+
StoreResource: () => StoreResource,
|
|
26
|
+
WebhooksResource: () => WebhooksResource
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/http.ts
|
|
31
|
+
var HttpError = class extends Error {
|
|
32
|
+
constructor(status, message, body) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.body = body;
|
|
36
|
+
this.name = "HttpError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var HttpClient = class {
|
|
40
|
+
constructor(baseUrl, apiKey, orgId, timeout = 3e4) {
|
|
41
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
42
|
+
this.apiKey = apiKey;
|
|
43
|
+
this.orgId = orgId;
|
|
44
|
+
this.timeout = timeout;
|
|
45
|
+
}
|
|
46
|
+
async request(opts) {
|
|
47
|
+
const url = new URL(this.baseUrl + opts.path);
|
|
48
|
+
if (opts.params) {
|
|
49
|
+
Object.entries(opts.params).forEach(([k, v]) => {
|
|
50
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
55
|
+
const headers = {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
58
|
+
};
|
|
59
|
+
if (this.orgId) headers["X-Kerabie-Org"] = this.orgId;
|
|
60
|
+
try {
|
|
61
|
+
const res = await fetch(url.toString(), {
|
|
62
|
+
method: opts.method ?? "GET",
|
|
63
|
+
headers,
|
|
64
|
+
body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0,
|
|
65
|
+
signal: controller.signal
|
|
66
|
+
});
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
if (!res.ok) {
|
|
69
|
+
const errBody = await res.json().catch(() => ({}));
|
|
70
|
+
throw new HttpError(res.status, errBody.message ?? `HTTP ${res.status}`, errBody);
|
|
71
|
+
}
|
|
72
|
+
if (res.status === 204) return void 0;
|
|
73
|
+
return await res.json();
|
|
74
|
+
} finally {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
get(path, params) {
|
|
79
|
+
return this.request({ method: "GET", path, params });
|
|
80
|
+
}
|
|
81
|
+
post(path, body) {
|
|
82
|
+
return this.request({ method: "POST", path, body });
|
|
83
|
+
}
|
|
84
|
+
patch(path, body) {
|
|
85
|
+
return this.request({ method: "PATCH", path, body });
|
|
86
|
+
}
|
|
87
|
+
delete(path) {
|
|
88
|
+
return this.request({ method: "DELETE", path });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/resources/conversations.ts
|
|
93
|
+
var ConversationsResource = class {
|
|
94
|
+
constructor(http) {
|
|
95
|
+
this.http = http;
|
|
96
|
+
}
|
|
97
|
+
async list(params) {
|
|
98
|
+
return this.http.get("/v1/conversations", params);
|
|
99
|
+
}
|
|
100
|
+
async get(id) {
|
|
101
|
+
return this.http.get(`/v1/conversations/${id}`);
|
|
102
|
+
}
|
|
103
|
+
async create(params) {
|
|
104
|
+
return this.http.post("/v1/conversations", params);
|
|
105
|
+
}
|
|
106
|
+
async update(id, params) {
|
|
107
|
+
return this.http.patch(`/v1/conversations/${id}`, params);
|
|
108
|
+
}
|
|
109
|
+
async resolve(id) {
|
|
110
|
+
return this.update(id, { status: "RESOLVED" });
|
|
111
|
+
}
|
|
112
|
+
async close(id) {
|
|
113
|
+
return this.update(id, { status: "CLOSED" });
|
|
114
|
+
}
|
|
115
|
+
async assign(id, agentId) {
|
|
116
|
+
return this.update(id, { assignedTeamMemberId: agentId });
|
|
117
|
+
}
|
|
118
|
+
/** The same customer's earlier conversations, newest first (default 5, max 20). */
|
|
119
|
+
async getHistory(id, limit) {
|
|
120
|
+
return this.http.get(`/v1/conversations/${id}/history`, { limit });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Hand a conversation from the AI assistant to a human: stops the bot and
|
|
124
|
+
* assigns `agentId` (a team-member id) if nobody holds it yet. Fails with
|
|
125
|
+
* 400 if the AI is no longer handling it.
|
|
126
|
+
*/
|
|
127
|
+
async takeOver(id, params) {
|
|
128
|
+
return this.http.post(`/v1/conversations/${id}/take-over`, params);
|
|
129
|
+
}
|
|
130
|
+
async getMessages(id, params) {
|
|
131
|
+
return this.http.get(`/v1/conversations/${id}/messages`, params);
|
|
132
|
+
}
|
|
133
|
+
async sendMessage(id, params) {
|
|
134
|
+
return this.http.post(`/v1/conversations/${id}/messages`, params);
|
|
135
|
+
}
|
|
136
|
+
async delete(id) {
|
|
137
|
+
return this.http.delete(`/v1/conversations/${id}`);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/resources/customers.ts
|
|
142
|
+
var CustomersResource = class {
|
|
143
|
+
constructor(http) {
|
|
144
|
+
this.http = http;
|
|
145
|
+
}
|
|
146
|
+
async list(params) {
|
|
147
|
+
return this.http.get("/v1/customers", params);
|
|
148
|
+
}
|
|
149
|
+
async get(id) {
|
|
150
|
+
return this.http.get(`/v1/customers/${id}`);
|
|
151
|
+
}
|
|
152
|
+
async upsert(params) {
|
|
153
|
+
return this.http.post("/v1/customers", params);
|
|
154
|
+
}
|
|
155
|
+
async update(id, params) {
|
|
156
|
+
return this.http.patch(`/v1/customers/${id}`, params);
|
|
157
|
+
}
|
|
158
|
+
async getConversations(id) {
|
|
159
|
+
return this.http.get(`/v1/customers/${id}/conversations`);
|
|
160
|
+
}
|
|
161
|
+
async delete(id) {
|
|
162
|
+
return this.http.delete(`/v1/customers/${id}`);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/resources/visitors.ts
|
|
167
|
+
var VisitorsResource = class {
|
|
168
|
+
constructor(http) {
|
|
169
|
+
this.http = http;
|
|
170
|
+
}
|
|
171
|
+
/** Visitors from the last few days (online and offline) with visit counts and block/allow status. */
|
|
172
|
+
async list(params) {
|
|
173
|
+
return this.http.get("/v1/visitors", params);
|
|
174
|
+
}
|
|
175
|
+
/** Visitors on the site right now. */
|
|
176
|
+
async getActive() {
|
|
177
|
+
const { data } = await this.list({ status: "online", limit: 100 });
|
|
178
|
+
return { data };
|
|
179
|
+
}
|
|
180
|
+
/** Online now, countries and returning visitors (24h), active IP blocks, top countries. */
|
|
181
|
+
async getOverview() {
|
|
182
|
+
return this.http.get("/v1/visitors/overview");
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* CSV of the visitors matching the filters (max 5,000). Requires a plan with
|
|
186
|
+
* data exports (Pro and above) — otherwise throws an HttpError with status 403.
|
|
187
|
+
*/
|
|
188
|
+
async export(params) {
|
|
189
|
+
return this.http.get("/v1/visitors/export", params);
|
|
190
|
+
}
|
|
191
|
+
async getPages(sessionId) {
|
|
192
|
+
return this.http.get(`/v1/visitors/${sessionId}/pages`);
|
|
193
|
+
}
|
|
194
|
+
async block(sessionId, params) {
|
|
195
|
+
return this.http.post(`/v1/visitors/${sessionId}/block`, params ?? {});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/resources/agents.ts
|
|
200
|
+
var AgentsResource = class {
|
|
201
|
+
constructor(http) {
|
|
202
|
+
this.http = http;
|
|
203
|
+
}
|
|
204
|
+
async list() {
|
|
205
|
+
return this.http.get("/v1/agents");
|
|
206
|
+
}
|
|
207
|
+
async getOnline() {
|
|
208
|
+
return this.http.get("/v1/agents/online");
|
|
209
|
+
}
|
|
210
|
+
async invite(params) {
|
|
211
|
+
return this.http.post("/v1/agents/invite", params);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// src/resources/knowledge-base.ts
|
|
216
|
+
var KnowledgeBaseResource = class {
|
|
217
|
+
constructor(http) {
|
|
218
|
+
this.http = http;
|
|
219
|
+
}
|
|
220
|
+
async list(params) {
|
|
221
|
+
return this.http.get("/v1/kb/articles", params);
|
|
222
|
+
}
|
|
223
|
+
/** Totals and the categories in use. */
|
|
224
|
+
async getStats() {
|
|
225
|
+
return this.http.get("/v1/kb/stats");
|
|
226
|
+
}
|
|
227
|
+
/** What to write or fix next: most viewed, unanswered customer questions, lowest rated, and stale articles. */
|
|
228
|
+
async getInsights() {
|
|
229
|
+
return this.http.get("/v1/kb/insights");
|
|
230
|
+
}
|
|
231
|
+
async get(id) {
|
|
232
|
+
return this.http.get(`/v1/kb/articles/${id}`);
|
|
233
|
+
}
|
|
234
|
+
async search(query) {
|
|
235
|
+
return this.http.get("/v1/kb/articles", { search: query });
|
|
236
|
+
}
|
|
237
|
+
async createArticle(params) {
|
|
238
|
+
return this.http.post("/v1/kb/articles", params);
|
|
239
|
+
}
|
|
240
|
+
async updateArticle(id, params) {
|
|
241
|
+
return this.http.patch(`/v1/kb/articles/${id}`, params);
|
|
242
|
+
}
|
|
243
|
+
async deleteArticle(id) {
|
|
244
|
+
return this.http.delete(`/v1/kb/articles/${id}`);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// src/resources/webhooks.ts
|
|
249
|
+
var import_crypto = require("crypto");
|
|
250
|
+
var WebhooksResource = class {
|
|
251
|
+
constructor(http) {
|
|
252
|
+
this.http = http;
|
|
253
|
+
}
|
|
254
|
+
async list() {
|
|
255
|
+
return this.http.get("/v1/webhooks");
|
|
256
|
+
}
|
|
257
|
+
async get(id) {
|
|
258
|
+
return this.http.get(`/v1/webhooks/${id}`);
|
|
259
|
+
}
|
|
260
|
+
async create(params) {
|
|
261
|
+
return this.http.post("/v1/webhooks", params);
|
|
262
|
+
}
|
|
263
|
+
async update(id, params) {
|
|
264
|
+
return this.http.patch(`/v1/webhooks/${id}`, params);
|
|
265
|
+
}
|
|
266
|
+
async delete(id) {
|
|
267
|
+
return this.http.delete(`/v1/webhooks/${id}`);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Verify an incoming webhook signature.
|
|
271
|
+
* The signature header is `X-Kerabie-Signature`.
|
|
272
|
+
*/
|
|
273
|
+
static verify(rawBody, signature, secret) {
|
|
274
|
+
const expected = (0, import_crypto.createHmac)("sha256", secret).update(rawBody).digest("hex");
|
|
275
|
+
const expectedHeader = `sha256=${expected}`;
|
|
276
|
+
try {
|
|
277
|
+
return (0, import_crypto.timingSafeEqual)(Buffer.from(expectedHeader), Buffer.from(signature));
|
|
278
|
+
} catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Parse a verified webhook payload with full TypeScript types.
|
|
284
|
+
*/
|
|
285
|
+
static parse(rawBody) {
|
|
286
|
+
return JSON.parse(rawBody);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// src/resources/analytics.ts
|
|
291
|
+
var AnalyticsResource = class {
|
|
292
|
+
constructor(http) {
|
|
293
|
+
this.http = http;
|
|
294
|
+
}
|
|
295
|
+
/** Conversation, response-time, satisfaction and AI numbers for the last `days` days (default 30), with deltas vs the previous period. */
|
|
296
|
+
async getSummary(params) {
|
|
297
|
+
return this.http.get("/v1/analytics/summary", params);
|
|
298
|
+
}
|
|
299
|
+
async getAgentStats(params) {
|
|
300
|
+
return this.http.get("/v1/analytics/agents", params);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The deeper numbers: first-response times, per-agent and per-channel results, the questions customers ask,
|
|
304
|
+
* who they are, when they write in, and which pages start conversations.
|
|
305
|
+
*/
|
|
306
|
+
async getInsights(params) {
|
|
307
|
+
return this.http.get("/v1/analytics/insights", params);
|
|
308
|
+
}
|
|
309
|
+
/** Open tickets by priority, and the percentage still within their SLA. */
|
|
310
|
+
async getTicketSla() {
|
|
311
|
+
return this.http.get("/v1/analytics/tickets-sla");
|
|
312
|
+
}
|
|
313
|
+
/** Which of the first-run steps (connect a channel, train the AI, create an automation) are done. */
|
|
314
|
+
async getSetupStatus() {
|
|
315
|
+
return this.http.get("/v1/analytics/setup-status");
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// src/resources/store.ts
|
|
320
|
+
var StoreResource = class {
|
|
321
|
+
constructor(http) {
|
|
322
|
+
this.http = http;
|
|
323
|
+
}
|
|
324
|
+
async list(params) {
|
|
325
|
+
return this.http.get("/v1/store/products", params);
|
|
326
|
+
}
|
|
327
|
+
async get(id) {
|
|
328
|
+
return this.http.get(`/v1/store/products/${id}`);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// src/resources/tickets.ts
|
|
333
|
+
var TicketsResource = class {
|
|
334
|
+
constructor(http) {
|
|
335
|
+
this.http = http;
|
|
336
|
+
}
|
|
337
|
+
async list(params) {
|
|
338
|
+
return this.http.get("/v1/tickets", params);
|
|
339
|
+
}
|
|
340
|
+
/** Open, unassigned and SLA-breaching counts plus the 7-day average resolution time and its change. */
|
|
341
|
+
async getStats() {
|
|
342
|
+
return this.http.get("/v1/tickets/stats");
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* CSV of tickets matching the filters (max 5,000). Requires a plan with
|
|
346
|
+
* data exports (Pro and above) — otherwise throws an HttpError with status 403.
|
|
347
|
+
*/
|
|
348
|
+
async export(params) {
|
|
349
|
+
return this.http.get("/v1/tickets/export", params);
|
|
350
|
+
}
|
|
351
|
+
async get(id) {
|
|
352
|
+
return this.http.get(`/v1/tickets/${id}`);
|
|
353
|
+
}
|
|
354
|
+
async create(params) {
|
|
355
|
+
return this.http.post("/v1/tickets", params);
|
|
356
|
+
}
|
|
357
|
+
async update(id, params) {
|
|
358
|
+
return this.http.patch(`/v1/tickets/${id}`, params);
|
|
359
|
+
}
|
|
360
|
+
async resolve(id) {
|
|
361
|
+
return this.update(id, { status: "RESOLVED" });
|
|
362
|
+
}
|
|
363
|
+
async close(id) {
|
|
364
|
+
return this.update(id, { status: "CLOSED" });
|
|
365
|
+
}
|
|
366
|
+
async reply(id, message) {
|
|
367
|
+
return this.http.post(`/v1/tickets/${id}/reply`, { message });
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/resources/contacts.ts
|
|
372
|
+
var ContactsResource = class {
|
|
373
|
+
constructor(http) {
|
|
374
|
+
this.http = http;
|
|
375
|
+
}
|
|
376
|
+
/** People with a name, email or phone number, last-contacted first. */
|
|
377
|
+
async list(params) {
|
|
378
|
+
return this.http.get("/v1/contacts", params);
|
|
379
|
+
}
|
|
380
|
+
/** Totals for the overview: everyone, new this week, leads, VIPs. */
|
|
381
|
+
async getStats() {
|
|
382
|
+
return this.http.get("/v1/contacts/stats");
|
|
383
|
+
}
|
|
384
|
+
async get(id) {
|
|
385
|
+
return this.http.get(`/v1/contacts/${id}`);
|
|
386
|
+
}
|
|
387
|
+
/** Adds a contact. Needs a name, email or phone. Throws an HttpError with status 409 if the email is already saved. */
|
|
388
|
+
async create(params) {
|
|
389
|
+
return this.http.post("/v1/contacts", params);
|
|
390
|
+
}
|
|
391
|
+
async update(id, params) {
|
|
392
|
+
return this.http.patch(`/v1/contacts/${id}`, params);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Imports up to 1,000 contacts per call. Rows whose email is already saved are skipped;
|
|
396
|
+
* invalid rows are reported with their number instead of failing the whole import.
|
|
397
|
+
*/
|
|
398
|
+
async import(rows) {
|
|
399
|
+
return this.http.post("/v1/contacts/import", { rows });
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/resources/campaigns.ts
|
|
404
|
+
var CampaignsResource = class {
|
|
405
|
+
constructor(http) {
|
|
406
|
+
this.http = http;
|
|
407
|
+
}
|
|
408
|
+
/** Proactive messages shown on your chat widget, newest first. */
|
|
409
|
+
async list(params) {
|
|
410
|
+
return this.http.get("/v1/campaigns", params);
|
|
411
|
+
}
|
|
412
|
+
/** Totals and funnel numbers, plus how many campaigns your plan lets you run at once. */
|
|
413
|
+
async getStats() {
|
|
414
|
+
return this.http.get("/v1/campaigns/stats");
|
|
415
|
+
}
|
|
416
|
+
async get(id) {
|
|
417
|
+
return this.http.get(`/v1/campaigns/${id}`);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Saves a draft, or launches it with `isActive: true`.
|
|
421
|
+
* Throws an HttpError with status 403 when launching would exceed your plan's live-campaign limit.
|
|
422
|
+
*/
|
|
423
|
+
async create(params) {
|
|
424
|
+
return this.http.post("/v1/campaigns", params);
|
|
425
|
+
}
|
|
426
|
+
/** Edits fields and/or turns it on or off with `isActive`. Send only what you want to change. */
|
|
427
|
+
async update(id, params) {
|
|
428
|
+
return this.http.patch(`/v1/campaigns/${id}`, params);
|
|
429
|
+
}
|
|
430
|
+
/** A copy saved as a draft, with fresh results. */
|
|
431
|
+
async duplicate(id) {
|
|
432
|
+
return this.http.post(`/v1/campaigns/${id}/duplicate`, {});
|
|
433
|
+
}
|
|
434
|
+
async delete(id) {
|
|
435
|
+
return this.http.delete(`/v1/campaigns/${id}`);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// src/resources/ai-tools.ts
|
|
440
|
+
var AiToolsResource = class {
|
|
441
|
+
constructor(http) {
|
|
442
|
+
this.http = http;
|
|
443
|
+
}
|
|
444
|
+
/** Your AI agent tools (custom API actions the chatbot can call), with 30-day usage and your plan's limit. */
|
|
445
|
+
async list() {
|
|
446
|
+
return this.http.get("/v1/ai-tools");
|
|
447
|
+
}
|
|
448
|
+
/** One tool. Secrets are never returned. */
|
|
449
|
+
async get(id) {
|
|
450
|
+
return this.http.get(`/v1/ai-tools/${id}`);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Adds a tool. Throws an HttpError with status 403 when your plan has no room for another,
|
|
454
|
+
* 409 when the function name is taken, and 400 for a private or local endpoint.
|
|
455
|
+
*/
|
|
456
|
+
async create(params) {
|
|
457
|
+
return this.http.post("/v1/ai-tools", params);
|
|
458
|
+
}
|
|
459
|
+
/** Edits fields and/or switches the tool on or off with `enabled`. Send only what you want to change. */
|
|
460
|
+
async update(id, params) {
|
|
461
|
+
return this.http.patch(`/v1/ai-tools/${id}`, params);
|
|
462
|
+
}
|
|
463
|
+
/** A copy that starts switched off. Counts against your plan's tool limit. */
|
|
464
|
+
async duplicate(id) {
|
|
465
|
+
return this.http.post(`/v1/ai-tools/${id}/duplicate`, {});
|
|
466
|
+
}
|
|
467
|
+
async delete(id) {
|
|
468
|
+
return this.http.delete(`/v1/ai-tools/${id}`);
|
|
469
|
+
}
|
|
470
|
+
/** Calls the tool's real endpoint once with `args`, the way the AI would. Not counted as usage. Limited to 40 a hour. */
|
|
471
|
+
async test(id, args = {}) {
|
|
472
|
+
return this.http.post(`/v1/ai-tools/${id}/test`, { args });
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// src/resources/mcp-servers.ts
|
|
477
|
+
var McpServersResource = class {
|
|
478
|
+
constructor(http) {
|
|
479
|
+
this.http = http;
|
|
480
|
+
}
|
|
481
|
+
/** Connected servers, with the tools each offers and which are switched on. */
|
|
482
|
+
async list() {
|
|
483
|
+
return this.http.get("/v1/mcp-servers");
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Connects a server and reads its tools. No tool is switched on yet: use `update` with `enabledTools`.
|
|
487
|
+
* Throws an HttpError with status 400 when the server can't be reached, 403 when your plan has no AI tools,
|
|
488
|
+
* and 409 when it is already connected.
|
|
489
|
+
*/
|
|
490
|
+
async create(params) {
|
|
491
|
+
return this.http.post("/v1/mcp-servers", params);
|
|
492
|
+
}
|
|
493
|
+
/** Reads the server's tools again. Switched-on tools the server no longer offers are dropped. */
|
|
494
|
+
async sync(id) {
|
|
495
|
+
return this.http.post(`/v1/mcp-servers/${id}/sync`, {});
|
|
496
|
+
}
|
|
497
|
+
/** Renames, switches the server on or off, changes which tools the chatbot may use, or updates credentials. */
|
|
498
|
+
async update(id, params) {
|
|
499
|
+
return this.http.patch(`/v1/mcp-servers/${id}`, params);
|
|
500
|
+
}
|
|
501
|
+
async delete(id) {
|
|
502
|
+
return this.http.delete(`/v1/mcp-servers/${id}`);
|
|
503
|
+
}
|
|
504
|
+
/** Runs one of the server's tools once with `args`, the way the chatbot would. Limited to 40 a hour. */
|
|
505
|
+
async test(id, tool, args = {}) {
|
|
506
|
+
return this.http.post(`/v1/mcp-servers/${id}/test`, { tool, args });
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/client.ts
|
|
511
|
+
var KerAbieClient = class {
|
|
512
|
+
constructor(config) {
|
|
513
|
+
if (!config.apiKey) throw new Error("KerAbieClient: apiKey is required");
|
|
514
|
+
const baseUrl = config.baseUrl ?? "https://api.kerabie.com";
|
|
515
|
+
this.http = new HttpClient(baseUrl, config.apiKey, config.orgId, config.timeout);
|
|
516
|
+
this.conversations = new ConversationsResource(this.http);
|
|
517
|
+
this.customers = new CustomersResource(this.http);
|
|
518
|
+
this.visitors = new VisitorsResource(this.http);
|
|
519
|
+
this.agents = new AgentsResource(this.http);
|
|
520
|
+
this.kb = new KnowledgeBaseResource(this.http);
|
|
521
|
+
this.webhooks = new WebhooksResource(this.http);
|
|
522
|
+
this.analytics = new AnalyticsResource(this.http);
|
|
523
|
+
this.store = new StoreResource(this.http);
|
|
524
|
+
this.tickets = new TicketsResource(this.http);
|
|
525
|
+
this.contacts = new ContactsResource(this.http);
|
|
526
|
+
this.campaigns = new CampaignsResource(this.http);
|
|
527
|
+
this.aiTools = new AiToolsResource(this.http);
|
|
528
|
+
this.mcpServers = new McpServersResource(this.http);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
532
|
+
0 && (module.exports = {
|
|
533
|
+
HttpError,
|
|
534
|
+
KerAbieClient,
|
|
535
|
+
StoreResource,
|
|
536
|
+
WebhooksResource
|
|
537
|
+
});
|