@applica-software-guru/persona-sdk 0.1.12 → 0.1.14
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/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +114 -94
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/persona-sdk.ts +1 -1
- package/src/projects/projects-api.ts +28 -4
- package/src/sessions/sessions-api.ts +4 -0
package/dist/bundle.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var d = (o, t, s) => t in o ? g(o, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[t] = s;
|
|
3
|
+
var c = (o, t, s) => d(o, typeof t != "symbol" ? t + "" : t, s);
|
|
4
4
|
class p extends Error {
|
|
5
5
|
constructor(s, e) {
|
|
6
6
|
super(`API Error: ${s} - ${e}`);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
c(this, "statusCode");
|
|
8
|
+
c(this, "body");
|
|
9
9
|
this.statusCode = s, this.body = e;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -20,10 +20,10 @@ class y {
|
|
|
20
20
|
return this.apiKey;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class u {
|
|
24
24
|
constructor(t, s) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
c(this, "baseUrl");
|
|
26
|
+
c(this, "authProvider");
|
|
27
27
|
this.baseUrl = t, this.authProvider = typeof s == "string" ? new y(s) : s;
|
|
28
28
|
}
|
|
29
29
|
getBaseUrl() {
|
|
@@ -44,8 +44,8 @@ class c {
|
|
|
44
44
|
}
|
|
45
45
|
buildUrl(t, s) {
|
|
46
46
|
const e = new URL(this.baseUrl + t);
|
|
47
|
-
return s && Object.entries(s).forEach(([r,
|
|
48
|
-
|
|
47
|
+
return s && Object.entries(s).forEach(([r, i]) => {
|
|
48
|
+
i != null && e.searchParams.set(r, String(i));
|
|
49
49
|
}), e.toString();
|
|
50
50
|
}
|
|
51
51
|
async handleResponse(t) {
|
|
@@ -98,46 +98,63 @@ class c {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
class m extends
|
|
102
|
-
constructor(
|
|
103
|
-
super(
|
|
101
|
+
class m extends u {
|
|
102
|
+
constructor(s, e, r) {
|
|
103
|
+
super(s, e);
|
|
104
|
+
c(this, "billingBaseUrl");
|
|
105
|
+
this.billingBaseUrl = (r || s).replace(/\/$/, "");
|
|
104
106
|
}
|
|
105
|
-
async list(
|
|
106
|
-
const { page:
|
|
107
|
-
return
|
|
107
|
+
async list(s, e, r) {
|
|
108
|
+
const { page: i, size: n } = this.normalizePageParams(e, r), a = { page: i, size: n };
|
|
109
|
+
return s && (a.keyword = s), this.httpGet("/projects", a);
|
|
108
110
|
}
|
|
109
|
-
async get(
|
|
110
|
-
return this.httpGet("/projects/" +
|
|
111
|
+
async get(s) {
|
|
112
|
+
return this.httpGet("/projects/" + s);
|
|
111
113
|
}
|
|
112
114
|
async getMine() {
|
|
113
115
|
return this.httpGet("/projects/mine");
|
|
114
116
|
}
|
|
115
|
-
async create(
|
|
116
|
-
return this.httpPost("/projects",
|
|
117
|
+
async create(s) {
|
|
118
|
+
return this.httpPost("/projects", s);
|
|
117
119
|
}
|
|
118
|
-
async update(
|
|
119
|
-
return this.httpPut("/projects/" +
|
|
120
|
+
async update(s) {
|
|
121
|
+
return this.httpPut("/projects/" + s.projectId, s);
|
|
120
122
|
}
|
|
121
|
-
async remove(
|
|
122
|
-
await this.httpDelete("/projects/" +
|
|
123
|
+
async remove(s) {
|
|
124
|
+
await this.httpDelete("/projects/" + s);
|
|
123
125
|
}
|
|
124
|
-
async getSubscription(
|
|
125
|
-
return this.
|
|
126
|
+
async getSubscription(s) {
|
|
127
|
+
return this.billingRequest("/projects/" + s + "/subscription", "GET");
|
|
126
128
|
}
|
|
127
|
-
async changeSubscriptionPlan(
|
|
128
|
-
return this.
|
|
129
|
+
async changeSubscriptionPlan(s, e) {
|
|
130
|
+
return this.billingRequest("/projects/" + s + "/subscription/actions/change-plan", "POST", e);
|
|
129
131
|
}
|
|
130
|
-
async addSubscriptionCredits(
|
|
131
|
-
return this.
|
|
132
|
+
async addSubscriptionCredits(s, e) {
|
|
133
|
+
return this.billingRequest("/projects/" + s + "/subscription/actions/add-credits", "POST", e);
|
|
134
|
+
}
|
|
135
|
+
async billingRequest(s, e, r) {
|
|
136
|
+
const i = new Headers();
|
|
137
|
+
i.set("Content-Type", "application/json"), this.getAuthProvider().applyHeaders(i);
|
|
138
|
+
const n = await fetch(this.billingBaseUrl + s, {
|
|
139
|
+
method: e,
|
|
140
|
+
headers: i,
|
|
141
|
+
body: r ? JSON.stringify(r) : void 0
|
|
142
|
+
});
|
|
143
|
+
if (!n.ok) {
|
|
144
|
+
const l = await n.text();
|
|
145
|
+
throw new p(n.status, l);
|
|
146
|
+
}
|
|
147
|
+
const a = await n.text();
|
|
148
|
+
return a ? JSON.parse(a) : void 0;
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
|
-
class
|
|
151
|
+
class w extends u {
|
|
135
152
|
constructor(t, s) {
|
|
136
153
|
super(t, s);
|
|
137
154
|
}
|
|
138
155
|
async list(t, s, e, r) {
|
|
139
|
-
const { page:
|
|
140
|
-
return t && (
|
|
156
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
157
|
+
return t && (a.keyword = t), this.httpGet("/agents", a);
|
|
141
158
|
}
|
|
142
159
|
async get(t) {
|
|
143
160
|
return this.httpGet("/agents/" + t);
|
|
@@ -171,15 +188,15 @@ class P extends c {
|
|
|
171
188
|
return this.httpGet("/agents/architect");
|
|
172
189
|
}
|
|
173
190
|
}
|
|
174
|
-
class
|
|
191
|
+
class P extends u {
|
|
175
192
|
constructor(s, e, r) {
|
|
176
193
|
super(s, e);
|
|
177
|
-
|
|
194
|
+
c(this, "knowledgeBaseId");
|
|
178
195
|
this.knowledgeBaseId = r;
|
|
179
196
|
}
|
|
180
197
|
async list(s, e, r) {
|
|
181
|
-
const { page:
|
|
182
|
-
return s && (
|
|
198
|
+
const { page: i, size: n } = this.normalizePageParams(e, r), a = { page: i, size: n };
|
|
199
|
+
return s && (a.keyword = s), this.httpGet("/knowledge-bases/" + this.knowledgeBaseId + "/documents", a);
|
|
183
200
|
}
|
|
184
201
|
async upload(s) {
|
|
185
202
|
return this.httpPost("/knowledge-bases/" + this.knowledgeBaseId + "/documents", s);
|
|
@@ -194,13 +211,13 @@ class w extends c {
|
|
|
194
211
|
await this.httpDelete("/knowledge-bases/" + this.knowledgeBaseId + "/documents/" + s);
|
|
195
212
|
}
|
|
196
213
|
}
|
|
197
|
-
class b extends
|
|
214
|
+
class b extends u {
|
|
198
215
|
constructor(t, s) {
|
|
199
216
|
super(t, s);
|
|
200
217
|
}
|
|
201
218
|
async list(t, s, e, r) {
|
|
202
|
-
const { page:
|
|
203
|
-
return t && (
|
|
219
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
220
|
+
return t && (a.keyword = t), this.httpGet("/knowledge-bases", a);
|
|
204
221
|
}
|
|
205
222
|
async get(t) {
|
|
206
223
|
return this.httpGet("/knowledge-bases/" + t);
|
|
@@ -215,19 +232,19 @@ class b extends c {
|
|
|
215
232
|
await this.httpDelete("/knowledge-bases/" + t);
|
|
216
233
|
}
|
|
217
234
|
documents(t) {
|
|
218
|
-
return new
|
|
235
|
+
return new P(this.getBaseUrl(), this.getAuthProvider(), t);
|
|
219
236
|
}
|
|
220
237
|
async searchChunks(t, s) {
|
|
221
238
|
return this.httpPost("/knowledge-bases/" + t + "/search", s);
|
|
222
239
|
}
|
|
223
240
|
}
|
|
224
|
-
class v extends
|
|
241
|
+
class v extends u {
|
|
225
242
|
constructor(t, s) {
|
|
226
243
|
super(t, s);
|
|
227
244
|
}
|
|
228
245
|
async list(t, s, e) {
|
|
229
|
-
const { page: r, size:
|
|
230
|
-
return this.httpGet("/workflows/" + t + "/executions",
|
|
246
|
+
const { page: r, size: i } = this.normalizePageParams(s, e), n = { page: r, size: i };
|
|
247
|
+
return this.httpGet("/workflows/" + t + "/executions", n);
|
|
231
248
|
}
|
|
232
249
|
async get(t, s) {
|
|
233
250
|
return this.httpGet("/workflows/" + t + "/executions/" + s);
|
|
@@ -239,13 +256,13 @@ class v extends c {
|
|
|
239
256
|
return this.httpPost("/workflows/" + t + "/executions/queue", s);
|
|
240
257
|
}
|
|
241
258
|
}
|
|
242
|
-
class f extends
|
|
259
|
+
class f extends u {
|
|
243
260
|
constructor(t, s) {
|
|
244
261
|
super(t, s);
|
|
245
262
|
}
|
|
246
263
|
async list(t, s, e, r) {
|
|
247
|
-
const { page:
|
|
248
|
-
return t && (
|
|
264
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
265
|
+
return t && (a.keyword = t), this.httpGet("/workflows", a);
|
|
249
266
|
}
|
|
250
267
|
async create(t) {
|
|
251
268
|
return this.httpPost("/workflows", t);
|
|
@@ -272,7 +289,7 @@ class f extends c {
|
|
|
272
289
|
return this.httpPost("/workflows/" + t + "/revisions/" + s + "/rollback", {});
|
|
273
290
|
}
|
|
274
291
|
}
|
|
275
|
-
class G extends
|
|
292
|
+
class G extends u {
|
|
276
293
|
constructor(t, s) {
|
|
277
294
|
super(t, s);
|
|
278
295
|
}
|
|
@@ -280,8 +297,8 @@ class G extends c {
|
|
|
280
297
|
return this.httpPost("/credentials/" + t + "/authorize", s);
|
|
281
298
|
}
|
|
282
299
|
async handleOAuth2Callback(t, s, e, r) {
|
|
283
|
-
const
|
|
284
|
-
return r && (
|
|
300
|
+
const i = { code: s, state: e };
|
|
301
|
+
return r && (i.scope = r), this.httpGet("/credentials/" + t + "/oauth2/callback", i);
|
|
285
302
|
}
|
|
286
303
|
async list() {
|
|
287
304
|
return this.httpGet("/credentials");
|
|
@@ -296,13 +313,13 @@ class G extends c {
|
|
|
296
313
|
await this.httpDelete("/credentials/all/" + t);
|
|
297
314
|
}
|
|
298
315
|
}
|
|
299
|
-
class k extends
|
|
316
|
+
class k extends u {
|
|
300
317
|
constructor(t, s) {
|
|
301
318
|
super(t, s);
|
|
302
319
|
}
|
|
303
320
|
async list(t, s, e, r) {
|
|
304
|
-
const { page:
|
|
305
|
-
return t && (
|
|
321
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
322
|
+
return t && (a.keyword = t), this.httpGet("/features/templates", a);
|
|
306
323
|
}
|
|
307
324
|
async get(t) {
|
|
308
325
|
return this.httpGet("/features/templates/" + t);
|
|
@@ -325,21 +342,21 @@ class k extends c {
|
|
|
325
342
|
}
|
|
326
343
|
class z {
|
|
327
344
|
constructor(t, s) {
|
|
328
|
-
|
|
329
|
-
|
|
345
|
+
c(this, "baseUrl");
|
|
346
|
+
c(this, "auth");
|
|
330
347
|
this.baseUrl = t, this.auth = s;
|
|
331
348
|
}
|
|
332
349
|
templates() {
|
|
333
350
|
return new k(this.baseUrl, this.auth);
|
|
334
351
|
}
|
|
335
352
|
}
|
|
336
|
-
class x extends
|
|
353
|
+
class x extends u {
|
|
337
354
|
constructor(t, s) {
|
|
338
355
|
super(t, s);
|
|
339
356
|
}
|
|
340
357
|
async list(t, s, e) {
|
|
341
|
-
const { page: r, size:
|
|
342
|
-
return this.httpGet("/triggers/" + t + "/executions",
|
|
358
|
+
const { page: r, size: i } = this.normalizePageParams(s, e), n = { page: r, size: i };
|
|
359
|
+
return this.httpGet("/triggers/" + t + "/executions", n);
|
|
343
360
|
}
|
|
344
361
|
async execute(t, s) {
|
|
345
362
|
return this.httpPost("/triggers/" + t + "/executions", s);
|
|
@@ -351,13 +368,13 @@ class x extends c {
|
|
|
351
368
|
await this.httpDelete("/triggers/executions/" + t);
|
|
352
369
|
}
|
|
353
370
|
}
|
|
354
|
-
class U extends
|
|
371
|
+
class U extends u {
|
|
355
372
|
constructor(t, s) {
|
|
356
373
|
super(t, s);
|
|
357
374
|
}
|
|
358
375
|
async list(t, s, e, r) {
|
|
359
|
-
const { page:
|
|
360
|
-
return t && (
|
|
376
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
377
|
+
return t && (a.keyword = t), this.httpGet("/triggers", a);
|
|
361
378
|
}
|
|
362
379
|
async create(t) {
|
|
363
380
|
return this.httpPost("/triggers", t);
|
|
@@ -375,13 +392,13 @@ class U extends c {
|
|
|
375
392
|
return new x(this.getBaseUrl(), this.getAuthProvider());
|
|
376
393
|
}
|
|
377
394
|
}
|
|
378
|
-
class S extends
|
|
395
|
+
class S extends u {
|
|
379
396
|
constructor(t, s) {
|
|
380
397
|
super(t, s);
|
|
381
398
|
}
|
|
382
399
|
async list(t, s, e, r) {
|
|
383
|
-
const { page:
|
|
384
|
-
return t && (
|
|
400
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n, ...r };
|
|
401
|
+
return t && (a.keyword = t), this.httpGet("/service-prices", a);
|
|
385
402
|
}
|
|
386
403
|
async get(t) {
|
|
387
404
|
return this.httpGet("/service-prices/" + t);
|
|
@@ -396,12 +413,12 @@ class S extends c {
|
|
|
396
413
|
await this.httpDelete("/service-prices/" + t);
|
|
397
414
|
}
|
|
398
415
|
}
|
|
399
|
-
class T extends
|
|
416
|
+
class T extends u {
|
|
400
417
|
constructor(t, s) {
|
|
401
418
|
super(t, s);
|
|
402
419
|
}
|
|
403
|
-
async list(t, s, e, r,
|
|
404
|
-
const { page:
|
|
420
|
+
async list(t, s, e, r, i, n) {
|
|
421
|
+
const { page: a, size: l } = this.normalizePageParams(i, n), h = { page: a, size: l };
|
|
405
422
|
return t && (h.keyword = t), s && (h.status = s), e && (h.agentId = e), r && (h.userId = r), this.httpGet("/sessions", h);
|
|
406
423
|
}
|
|
407
424
|
async get(t) {
|
|
@@ -414,20 +431,23 @@ class T extends c {
|
|
|
414
431
|
return this.httpPost("/sessions/" + t + "/messages", s);
|
|
415
432
|
}
|
|
416
433
|
async findMessages(t, s, e) {
|
|
417
|
-
const { page: r, size:
|
|
418
|
-
return this.httpGet("/sessions/" + t + "/messages",
|
|
434
|
+
const { page: r, size: i } = this.normalizePageParams(s, e), n = { page: r, size: i };
|
|
435
|
+
return this.httpGet("/sessions/" + t + "/messages", n);
|
|
419
436
|
}
|
|
420
437
|
async remove(t) {
|
|
421
438
|
await this.httpDelete("/sessions/" + t);
|
|
422
439
|
}
|
|
440
|
+
async rename(t, s) {
|
|
441
|
+
return this.httpPut("/sessions/" + t + "/name", { name: s });
|
|
442
|
+
}
|
|
423
443
|
}
|
|
424
|
-
class A extends
|
|
444
|
+
class A extends u {
|
|
425
445
|
constructor(t, s) {
|
|
426
446
|
super(t, s);
|
|
427
447
|
}
|
|
428
448
|
async list(t, s, e, r) {
|
|
429
|
-
const { page:
|
|
430
|
-
return t && (
|
|
449
|
+
const { page: i, size: n } = this.normalizePageParams(s, e), a = { page: i, size: n };
|
|
450
|
+
return t && (a.keyword = t), r && (a.status = r), this.httpGet("/missions", a);
|
|
431
451
|
}
|
|
432
452
|
async get(t) {
|
|
433
453
|
return this.httpGet("/missions/" + t);
|
|
@@ -465,8 +485,8 @@ class A extends c {
|
|
|
465
485
|
}
|
|
466
486
|
class B {
|
|
467
487
|
constructor(t, s) {
|
|
468
|
-
|
|
469
|
-
|
|
488
|
+
c(this, "baseUrl");
|
|
489
|
+
c(this, "authProvider");
|
|
470
490
|
this.baseUrl = (t || "https://persona.applica.guru/billing").replace(/\/$/, ""), this.authProvider = s ?? null;
|
|
471
491
|
}
|
|
472
492
|
buildHeaders() {
|
|
@@ -480,11 +500,11 @@ class B {
|
|
|
480
500
|
body: e ? JSON.stringify(e) : void 0
|
|
481
501
|
});
|
|
482
502
|
if (!r.ok) {
|
|
483
|
-
const
|
|
484
|
-
throw new p(r.status,
|
|
503
|
+
const n = await r.text();
|
|
504
|
+
throw new p(r.status, n);
|
|
485
505
|
}
|
|
486
|
-
const
|
|
487
|
-
return
|
|
506
|
+
const i = await r.text();
|
|
507
|
+
return i ? JSON.parse(i) : void 0;
|
|
488
508
|
}
|
|
489
509
|
async createCustomer(t) {
|
|
490
510
|
return this.request("/customers", "POST", t);
|
|
@@ -529,8 +549,8 @@ class B {
|
|
|
529
549
|
return this.request("/customers/" + t + "/subscription/credits", "POST", { credits: s });
|
|
530
550
|
}
|
|
531
551
|
async useCredits(t, s, e, r) {
|
|
532
|
-
const
|
|
533
|
-
return r && (
|
|
552
|
+
const i = { credits: s, services: e };
|
|
553
|
+
return r && (i.referenceId = r), this.request("/customers/" + t + "/subscription/credits", "DELETE", i);
|
|
534
554
|
}
|
|
535
555
|
async getCredits(t) {
|
|
536
556
|
try {
|
|
@@ -549,14 +569,14 @@ class B {
|
|
|
549
569
|
async listInvoices(t, s, e) {
|
|
550
570
|
const r = [];
|
|
551
571
|
s && r.push("date_from=" + s), e && r.push("date_to=" + e);
|
|
552
|
-
const
|
|
553
|
-
return this.request("/customers/" + t + "/invoices" +
|
|
572
|
+
const i = r.length > 0 ? "?" + r.join("&") : "";
|
|
573
|
+
return this.request("/customers/" + t + "/invoices" + i, "GET");
|
|
554
574
|
}
|
|
555
575
|
async cancelSubscription(t) {
|
|
556
576
|
return this.request("/customers/" + t + "/subscription/actions/cancel", "POST", {});
|
|
557
577
|
}
|
|
558
578
|
}
|
|
559
|
-
class E extends
|
|
579
|
+
class E extends u {
|
|
560
580
|
constructor(t, s) {
|
|
561
581
|
super(t, s);
|
|
562
582
|
}
|
|
@@ -618,18 +638,18 @@ class E extends c {
|
|
|
618
638
|
return this.httpGet("/values/trigger-destination-types");
|
|
619
639
|
}
|
|
620
640
|
}
|
|
621
|
-
class
|
|
641
|
+
class q {
|
|
622
642
|
constructor(t, s, e) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
643
|
+
c(this, "baseUrl");
|
|
644
|
+
c(this, "workflowsBaseUrl");
|
|
645
|
+
c(this, "billingBaseUrl");
|
|
626
646
|
this.baseUrl = t, this.workflowsBaseUrl = s, this.billingBaseUrl = e || "https://persona.applica.guru/billing";
|
|
627
647
|
}
|
|
628
648
|
projects(t) {
|
|
629
|
-
return new m(this.baseUrl, t);
|
|
649
|
+
return new m(this.baseUrl, t, this.billingBaseUrl);
|
|
630
650
|
}
|
|
631
651
|
agents(t) {
|
|
632
|
-
return new
|
|
652
|
+
return new w(this.baseUrl, t);
|
|
633
653
|
}
|
|
634
654
|
knowledgeBases(t) {
|
|
635
655
|
return new b(this.baseUrl, t);
|
|
@@ -662,7 +682,7 @@ class j {
|
|
|
662
682
|
return new E(this.baseUrl, t);
|
|
663
683
|
}
|
|
664
684
|
}
|
|
665
|
-
class
|
|
685
|
+
class C {
|
|
666
686
|
constructor(t) {
|
|
667
687
|
this.token = t;
|
|
668
688
|
}
|
|
@@ -674,18 +694,18 @@ class O {
|
|
|
674
694
|
}
|
|
675
695
|
}
|
|
676
696
|
export {
|
|
677
|
-
|
|
697
|
+
w as AgentsApi,
|
|
678
698
|
p as ApiException,
|
|
679
699
|
y as ApiKeyAuthenticationProvider,
|
|
680
|
-
|
|
700
|
+
C as BearerTokenAuthenticationProvider,
|
|
681
701
|
B as BillingClient,
|
|
682
702
|
G as CredentialsApi,
|
|
683
703
|
k as FeatureTemplatesApi,
|
|
684
704
|
z as FeaturesApi,
|
|
685
|
-
|
|
705
|
+
P as KnowledgeBaseDocumentsApi,
|
|
686
706
|
b as KnowledgeBasesApi,
|
|
687
707
|
A as MissionsApi,
|
|
688
|
-
|
|
708
|
+
q as PersonaSdk,
|
|
689
709
|
m as ProjectsApi,
|
|
690
710
|
S as ServicePricesApi,
|
|
691
711
|
T as SessionsApi,
|