MCPcopy Create free account
hub / github.com/dfinity/orbit / paginated

Function paginated

cli/src/audit/station.core.ts:29–44  ·  view source on GitHub ↗
(
  method: string,
  call: (pageArg: { offset: bigint; limit: bigint }) => Promise<unknown>,
  extract: (page: unknown) => { items: Item[]; next: Array<bigint> | [] },
)

Source from the content-addressed store, hash-verified

27 next_offset.length > 0 ? next_offset[0] : null;
28
29const paginated = async <Item>(
30 method: string,
31 call: (pageArg: { offset: bigint; limit: bigint }) => Promise<unknown>,
32 extract: (page: unknown) => { items: Item[]; next: Array<bigint> | [] },
33): Promise<Item[]> => {
34 const items: Item[] = [];
35 let offset: bigint | null = 0n;
36 while (offset !== null) {
37 const response = await call({ offset, limit: PAGE_SIZE });
38 const ok = unwrapOk<unknown>(response, method);
39 const page = extract(ok);
40 items.push(...page.items);
41 offset = nextOffset(page.next);
42 }
43 return items;
44};
45
46/**
47 * Builds an authenticated agent-js actor for the target station.

Callers 6

listRequestPoliciesFunction · 0.85
listUsersFunction · 0.85
listUserGroupsFunction · 0.85
listAssetsFunction · 0.85
listPermissionsFunction · 0.85
listNamedRulesFunction · 0.85

Calls 3

callFunction · 0.85
unwrapOkFunction · 0.85
nextOffsetFunction · 0.85

Tested by

no test coverage detected