MCPcopy
hub / github.com/simstudioai/sim / fetchAdminUsers

Function fetchAdminUsers

apps/sim/hooks/queries/admin-users.ts:47–80  ·  view source on GitHub ↗
(
  offset: number,
  limit: number,
  searchQuery: string,
  signal?: AbortSignal
)

Source from the content-addressed store, hash-verified

45}
46
47async function fetchAdminUsers(
48 offset: number,
49 limit: number,
50 searchQuery: string,
51 signal?: AbortSignal
52): Promise<AdminUserListData> {
53 if (isValidUuid(searchQuery.trim())) {
54 const { data, error } = await client.admin.getUser(
55 { query: { id: searchQuery.trim() } },
56 { signal }
57 )
58 if (error) throw new Error(error.message ?? 'Failed to fetch user')
59 if (!data) return { users: [], total: 0 }
60 return { users: [mapUser(data)], total: 1 }
61 }
62
63 const { data, error } = await client.admin.listUsers(
64 {
65 query: {
66 limit,
67 offset,
68 searchField: 'email',
69 searchValue: searchQuery,
70 searchOperator: 'contains',
71 },
72 },
73 { signal }
74 )
75 if (error) throw new Error(error.message ?? 'Failed to fetch users')
76 return {
77 users: (data?.users ?? []).map(mapUser),
78 total: data?.total ?? 0,
79 }
80}
81
82export function useAdminUsers(offset: number, limit: number, searchQuery: string) {
83 return useQuery({

Callers 1

useAdminUsersFunction · 0.85

Calls 2

isValidUuidFunction · 0.90
mapUserFunction · 0.70

Tested by

no test coverage detected