@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.
- package/dist/classes/admin.d.ts +1 -1
- package/dist/core/utils.d.ts +0 -6
- package/dist/core/utils.js +4 -15
- package/package.json +1 -1
package/dist/classes/admin.d.ts
CHANGED
|
@@ -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 = {
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -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;
|
package/dist/core/utils.js
CHANGED
|
@@ -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
|
-
|
|
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