@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.d.cts CHANGED
@@ -309,10 +309,10 @@ declare function fetchCollectionItems(collection: string, queryOptions?: {
309
309
  limit?: number;
310
310
  offset?: number;
311
311
  }, options?: FetchOptions): Promise<AdminCollectionItem[]>;
312
- declare function fetchCollectionItem(collection: string, itemId: string, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
313
- declare function createCollectionItem(collection: string, data: Record<string, unknown>, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
314
- declare function updateCollectionItem(collection: string, itemId: string, data: Record<string, unknown>, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
315
- declare function deleteCollectionItem(collection: string, itemId: string, namespace?: string, options?: FetchOptions): Promise<void>;
312
+ declare function fetchCollectionItem(collection: string, itemId: string, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
313
+ declare function createCollectionItem(collection: string, data: Record<string, unknown>, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
314
+ declare function updateCollectionItem(collection: string, itemId: string, data: Record<string, unknown>, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
315
+ declare function deleteCollectionItem(collection: string, itemId: string, _namespace?: string, options?: FetchOptions): Promise<void>;
316
316
  declare function fetchThreadEvents(threadId: string, options?: FetchOptions): Promise<AdminQueueEvent | undefined>;
317
317
 
318
318
  declare const defaultAdminConfig: ResolvedAdminConfig;
package/dist/index.d.ts CHANGED
@@ -309,10 +309,10 @@ declare function fetchCollectionItems(collection: string, queryOptions?: {
309
309
  limit?: number;
310
310
  offset?: number;
311
311
  }, options?: FetchOptions): Promise<AdminCollectionItem[]>;
312
- declare function fetchCollectionItem(collection: string, itemId: string, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
313
- declare function createCollectionItem(collection: string, data: Record<string, unknown>, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
314
- declare function updateCollectionItem(collection: string, itemId: string, data: Record<string, unknown>, namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
315
- declare function deleteCollectionItem(collection: string, itemId: string, namespace?: string, options?: FetchOptions): Promise<void>;
312
+ declare function fetchCollectionItem(collection: string, itemId: string, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
313
+ declare function createCollectionItem(collection: string, data: Record<string, unknown>, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
314
+ declare function updateCollectionItem(collection: string, itemId: string, data: Record<string, unknown>, _namespace?: string, options?: FetchOptions): Promise<AdminCollectionItem>;
315
+ declare function deleteCollectionItem(collection: string, itemId: string, _namespace?: string, options?: FetchOptions): Promise<void>;
316
316
  declare function fetchThreadEvents(threadId: string, options?: FetchOptions): Promise<AdminQueueEvent | undefined>;
317
317
 
318
318
  declare const defaultAdminConfig: ResolvedAdminConfig;
package/dist/index.js CHANGED
@@ -178,7 +178,10 @@ var getRangeWindow = (range) => {
178
178
  };
179
179
  };
180
180
  async function fetchAdminJson(path, params, options) {
181
- const url = new URL(`${resolveBaseUrl(options?.baseUrl)}${path}`, window.location.origin);
181
+ const url = new URL(
182
+ `${resolveBaseUrl(options?.baseUrl)}${path}`,
183
+ window.location.origin
184
+ );
182
185
  for (const [key, value] of Object.entries(params)) {
183
186
  if (typeof value === "string" && value.length > 0) {
184
187
  url.searchParams.set(key, value);
@@ -194,7 +197,10 @@ async function fetchAdminJson(path, params, options) {
194
197
  return payload.data;
195
198
  }
196
199
  async function fetchRawJson(path, params, options) {
197
- const url = new URL(`${resolveBaseUrl(options?.baseUrl)}${path}`, window.location.origin);
200
+ const url = new URL(
201
+ `${resolveBaseUrl(options?.baseUrl)}${path}`,
202
+ window.location.origin
203
+ );
198
204
  for (const [key, value] of Object.entries(params)) {
199
205
  if (typeof value === "string" && value.length > 0) {
200
206
  url.searchParams.set(key, value);
@@ -233,11 +239,15 @@ async function fetchAdminThreads(search, namespace, options) {
233
239
  }, options);
234
240
  }
235
241
  async function fetchAdminParticipants(search, namespace, options) {
236
- return await fetchAdminJson("/v1/admin/participants", {
237
- search,
238
- namespace,
239
- limit: "8"
240
- }, options);
242
+ return await fetchAdminJson(
243
+ "/v1/admin/participants",
244
+ {
245
+ search,
246
+ namespace,
247
+ limit: "8"
248
+ },
249
+ options
250
+ );
241
251
  }
242
252
  async function fetchAdminAgents(search, namespace, options) {
243
253
  return await fetchAdminJson("/v1/admin/agents", {
@@ -266,7 +276,7 @@ async function fetchThreadMessages(threadId, messageOptions, options) {
266
276
  async function fetchParticipantDetail(participantId, options) {
267
277
  return await fetchAdminJson(
268
278
  `/v1/collections/participant/${encodeURIComponent(participantId)}`,
269
- { namespace: "global" },
279
+ {},
270
280
  options
271
281
  );
272
282
  }
@@ -275,7 +285,6 @@ async function updateParticipant(participantId, data, options) {
275
285
  `${resolveBaseUrl(options?.baseUrl)}/v1/collections/participant/${encodeURIComponent(participantId)}`,
276
286
  window.location.origin
277
287
  );
278
- url.searchParams.set("namespace", "global");
279
288
  const response = await fetch(url.toString(), {
280
289
  method: "PUT",
281
290
  headers: await withAuthHeaders(
@@ -295,7 +304,6 @@ async function fetchCollectionNames(options) {
295
304
  }
296
305
  async function fetchCollectionItems(collection, queryOptions, options) {
297
306
  const params = {
298
- namespace: queryOptions?.namespace,
299
307
  limit: queryOptions?.limit?.toString()
300
308
  };
301
309
  if (queryOptions?.search) {
@@ -309,19 +317,18 @@ async function fetchCollectionItems(collection, queryOptions, options) {
309
317
  options
310
318
  );
311
319
  }
312
- async function fetchCollectionItem(collection, itemId, namespace, options) {
320
+ async function fetchCollectionItem(collection, itemId, _namespace, options) {
313
321
  return await fetchAdminJson(
314
322
  `/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
315
- { namespace },
323
+ {},
316
324
  options
317
325
  );
318
326
  }
319
- async function createCollectionItem(collection, data, namespace, options) {
327
+ async function createCollectionItem(collection, data, _namespace, options) {
320
328
  const url = new URL(
321
329
  `${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}`,
322
330
  window.location.origin
323
331
  );
324
- if (namespace) url.searchParams.set("namespace", namespace);
325
332
  const response = await fetch(url.toString(), {
326
333
  method: "POST",
327
334
  headers: await withAuthHeaders(
@@ -334,17 +341,13 @@ async function createCollectionItem(collection, data, namespace, options) {
334
341
  throw new Error(`Create collection item failed (${response.status})`);
335
342
  }
336
343
  const payload = await response.json();
337
- if ("body" in payload && payload.body && typeof payload.body === "object") {
338
- return payload.body;
339
- }
340
- return payload;
344
+ return payload.data;
341
345
  }
342
- async function updateCollectionItem(collection, itemId, data, namespace, options) {
346
+ async function updateCollectionItem(collection, itemId, data, _namespace, options) {
343
347
  const url = new URL(
344
348
  `${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
345
349
  window.location.origin
346
350
  );
347
- if (namespace) url.searchParams.set("namespace", namespace);
348
351
  const response = await fetch(url.toString(), {
349
352
  method: "PUT",
350
353
  headers: await withAuthHeaders(
@@ -359,12 +362,11 @@ async function updateCollectionItem(collection, itemId, data, namespace, options
359
362
  const payload = await response.json();
360
363
  return payload.data;
361
364
  }
362
- async function deleteCollectionItem(collection, itemId, namespace, options) {
365
+ async function deleteCollectionItem(collection, itemId, _namespace, options) {
363
366
  const url = new URL(
364
367
  `${resolveBaseUrl(options?.baseUrl)}/v1/collections/${encodeURIComponent(collection)}/${encodeURIComponent(itemId)}`,
365
368
  window.location.origin
366
369
  );
367
- if (namespace) url.searchParams.set("namespace", namespace);
368
370
  const response = await fetch(url.toString(), {
369
371
  method: "DELETE",
370
372
  headers: await withAuthHeaders({}, options?.getRequestHeaders)