@copilotz/admin 0.7.7 → 0.8.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 +24 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -221,7 +221,10 @@ var getRangeWindow = (range) => {
|
|
|
221
221
|
};
|
|
222
222
|
};
|
|
223
223
|
async function fetchAdminJson(path, params, options) {
|
|
224
|
-
const url = new URL(
|
|
224
|
+
const url = new URL(
|
|
225
|
+
`${resolveBaseUrl(options?.baseUrl)}${path}`,
|
|
226
|
+
window.location.origin
|
|
227
|
+
);
|
|
225
228
|
for (const [key, value] of Object.entries(params)) {
|
|
226
229
|
if (typeof value === "string" && value.length > 0) {
|
|
227
230
|
url.searchParams.set(key, value);
|
|
@@ -237,7 +240,10 @@ async function fetchAdminJson(path, params, options) {
|
|
|
237
240
|
return payload.data;
|
|
238
241
|
}
|
|
239
242
|
async function fetchRawJson(path, params, options) {
|
|
240
|
-
const url = new URL(
|
|
243
|
+
const url = new URL(
|
|
244
|
+
`${resolveBaseUrl(options?.baseUrl)}${path}`,
|
|
245
|
+
window.location.origin
|
|
246
|
+
);
|
|
241
247
|
for (const [key, value] of Object.entries(params)) {
|
|
242
248
|
if (typeof value === "string" && value.length > 0) {
|
|
243
249
|
url.searchParams.set(key, value);
|
|
@@ -276,11 +282,15 @@ async function fetchAdminThreads(search, namespace, options) {
|
|
|
276
282
|
}, options);
|
|
277
283
|
}
|
|
278
284
|
async function fetchAdminParticipants(search, namespace, options) {
|
|
279
|
-
return await fetchAdminJson(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
285
|
+
return await fetchAdminJson(
|
|
286
|
+
"/v1/admin/participants",
|
|
287
|
+
{
|
|
288
|
+
search,
|
|
289
|
+
namespace,
|
|
290
|
+
limit: "8"
|
|
291
|
+
},
|
|
292
|
+
options
|
|
293
|
+
);
|
|
284
294
|
}
|
|
285
295
|
async function fetchAdminAgents(search, namespace, options) {
|
|
286
296
|
return await fetchAdminJson("/v1/admin/agents", {
|
|
@@ -309,7 +319,7 @@ async function fetchThreadMessages(threadId, messageOptions, options) {
|
|
|
309
319
|
async function fetchParticipantDetail(participantId, options) {
|
|
310
320
|
return await fetchAdminJson(
|
|
311
321
|
`/v1/collections/participant/${encodeURIComponent(participantId)}`,
|
|
312
|
-
{
|
|
322
|
+
{},
|
|
313
323
|
options
|
|
314
324
|
);
|
|
315
325
|
}
|
|
@@ -318,7 +328,6 @@ async function updateParticipant(participantId, data, options) {
|
|
|
318
328
|
`${resolveBaseUrl(options?.baseUrl)}/v1/collections/participant/${encodeURIComponent(participantId)}`,
|
|
319
329
|
window.location.origin
|
|
320
330
|
);
|
|
321
|
-
url.searchParams.set("namespace", "global");
|
|
322
331
|
const response = await fetch(url.toString(), {
|
|
323
332
|
method: "PUT",
|
|
324
333
|
headers: await withAuthHeaders(
|
|
@@ -338,7 +347,6 @@ async function fetchCollectionNames(options) {
|
|
|
338
347
|
}
|
|
339
348
|
async function fetchCollectionItems(collection, queryOptions, options) {
|
|
340
349
|
const params = {
|
|
341
|
-
namespace: queryOptions?.namespace,
|
|
342
350
|
limit: queryOptions?.limit?.toString()
|
|
343
351
|
};
|
|
344
352
|
if (queryOptions?.search) {
|
|
@@ -352,19 +360,18 @@ async function fetchCollectionItems(collection, queryOptions, options) {
|
|
|
352
360
|
options
|
|
353
361
|
);
|
|
354
362
|
}
|
|
355
|
-
async function fetchCollectionItem(collection, itemId,
|
|
363
|
+
async function fetchCollectionItem(collection, itemId, _namespace, options) {
|
|
356
364
|
return await fetchAdminJson(
|
|
357
365
|
`/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
|
|
358
|
-
{
|
|
366
|
+
{},
|
|
359
367
|
options
|
|
360
368
|
);
|
|
361
369
|
}
|
|
362
|
-
async function createCollectionItem(collection, data,
|
|
370
|
+
async function createCollectionItem(collection, data, _namespace, options) {
|
|
363
371
|
const url = new URL(
|
|
364
372
|
`${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}`,
|
|
365
373
|
window.location.origin
|
|
366
374
|
);
|
|
367
|
-
if (namespace) url.searchParams.set("namespace", namespace);
|
|
368
375
|
const response = await fetch(url.toString(), {
|
|
369
376
|
method: "POST",
|
|
370
377
|
headers: await withAuthHeaders(
|
|
@@ -377,17 +384,13 @@ async function createCollectionItem(collection, data, namespace, options) {
|
|
|
377
384
|
throw new Error(`Create collection item failed (${response.status})`);
|
|
378
385
|
}
|
|
379
386
|
const payload = await response.json();
|
|
380
|
-
|
|
381
|
-
return payload.body;
|
|
382
|
-
}
|
|
383
|
-
return payload;
|
|
387
|
+
return payload.data;
|
|
384
388
|
}
|
|
385
|
-
async function updateCollectionItem(collection, itemId, data,
|
|
389
|
+
async function updateCollectionItem(collection, itemId, data, _namespace, options) {
|
|
386
390
|
const url = new URL(
|
|
387
391
|
`${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
|
|
388
392
|
window.location.origin
|
|
389
393
|
);
|
|
390
|
-
if (namespace) url.searchParams.set("namespace", namespace);
|
|
391
394
|
const response = await fetch(url.toString(), {
|
|
392
395
|
method: "PUT",
|
|
393
396
|
headers: await withAuthHeaders(
|
|
@@ -402,12 +405,11 @@ async function updateCollectionItem(collection, itemId, data, namespace, options
|
|
|
402
405
|
const payload = await response.json();
|
|
403
406
|
return payload.data;
|
|
404
407
|
}
|
|
405
|
-
async function deleteCollectionItem(collection, itemId,
|
|
408
|
+
async function deleteCollectionItem(collection, itemId, _namespace, options) {
|
|
406
409
|
const url = new URL(
|
|
407
410
|
`${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
|
|
408
411
|
window.location.origin
|
|
409
412
|
);
|
|
410
|
-
if (namespace) url.searchParams.set("namespace", namespace);
|
|
411
413
|
const response = await fetch(url.toString(), {
|
|
412
414
|
method: "DELETE",
|
|
413
415
|
headers: await withAuthHeaders({}, options?.getRequestHeaders)
|