@excali-boards/boards-api-client 1.1.39 → 1.1.40

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.
@@ -5,7 +5,7 @@ import { Paginated } from '../types';
5
5
  export declare class APIAdmin {
6
6
  private web;
7
7
  constructor(web: BoardsManager);
8
- getUsers({ auth, page, limit }: AdminFunctionsInput['getUsers']): Promise<import("../types").WebResponse<Paginated<GetUsersOutput[]>>>;
8
+ getUsers({ auth, page, limit }: AdminFunctionsInput['getUsers']): Promise<import("../types").WebResponse<Paginated<GetUsersOutput>>>;
9
9
  getActiveRooms({ auth }: AdminFunctionsInput['getActiveRooms']): Promise<import("../types").WebResponse<AllRooms>>;
10
10
  }
11
11
  export type AdminFunctionsInput = {
@@ -3,12 +3,6 @@ import { AxiosResponse } from 'axios';
3
3
  export declare function isDateStringRegex(value: unknown): value is string;
4
4
  export declare function recursiveDateConversion<T>(data: T): T;
5
5
  export declare function transformDates<T>(response: AxiosResponse<T>): AxiosResponse<T>;
6
- /**
7
- * Automatically fetches all pages of a paginated endpoint
8
- * @param fetcher Function that fetches a single page, receives page and limit as parameters
9
- * @param options Optional configuration for page size and max items
10
- * @returns Array of all items from all pages
11
- */
12
6
  export declare function getAll<T>(fetcher: (page: number, limit: number) => Promise<WebResponse<Paginated<T>>>, options?: {
13
7
  limit?: number;
14
8
  maxItems?: number;
@@ -25,28 +25,17 @@ function transformDates(response) {
25
25
  response.data = recursiveDateConversion(response.data);
26
26
  return response;
27
27
  }
28
- /**
29
- * Automatically fetches all pages of a paginated endpoint
30
- * @param fetcher Function that fetches a single page, receives page and limit as parameters
31
- * @param options Optional configuration for page size and max items
32
- * @returns Array of all items from all pages
33
- */
34
28
  async function getAll(fetcher, options) {
35
29
  const limit = options?.limit ?? 50;
36
30
  const maxItems = options?.maxItems ?? Infinity;
37
31
  const allItems = [];
38
- let page = 1;
39
32
  let hasMore = true;
33
+ let page = 1;
40
34
  while (hasMore && allItems.length < maxItems) {
41
35
  const response = await fetcher(page, limit);
42
- if (response.status !== 200) {
43
- throw new Error(typeof response.error === 'string'
44
- ? response.error
45
- : 'Failed to fetch paginated data');
46
- }
47
- const items = Array.isArray(response.data.data)
48
- ? response.data.data
49
- : [response.data.data];
36
+ if (response.status !== 200)
37
+ throw new Error(typeof response.error === 'string' ? response.error : 'Failed to fetch paginated data');
38
+ const items = Array.isArray(response.data.data) ? response.data.data : [response.data.data];
50
39
  allItems.push(...items.slice(0, maxItems - allItems.length));
51
40
  hasMore = response.data.pagination.hasMore && allItems.length < maxItems;
52
41
  page++;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.39",
2
+ "version": "1.1.40",
3
3
  "name": "@excali-boards/boards-api-client",
4
4
  "description": "A simple API client for the Boards API.",
5
5
  "repository": "https://github.com/Excali-Boards/boards-api-client",