MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / selectBySearch

Function selectBySearch

packages/core/api/src/admin/reads.ts:327–342  ·  view source on GitHub ↗
(
  directory: AdminUserDirectory,
  term: string,
  read: (externalIds: readonly string[]) => Effect.Effect<readonly T[], AdminUsersError>,
)

Source from the content-addressed store, hash-verified

325 * a resolver failure.
326 */
327const selectBySearch = <T>(
328 directory: AdminUserDirectory,
329 term: string,
330 read: (externalIds: readonly string[]) => Effect.Effect<readonly T[], AdminUsersError>,
331): Effect.Effect<readonly T[], AdminUsersError> =>
332 Effect.gen(function* () {
333 const search = directory.search;
334 if (!search) return [];
335 const wanted = yield* search(term).pipe(
336 Effect.mapError(() => new AdminUsersError({ message: "Failed to search the directory" })),
337 );
338 // Nobody matches: an empty page, and no storage read for an `in ()` that
339 // could not match anyway.
340 if (wanted.length === 0) return [];
341 return yield* read(wanted);
342 });
343
344/**
345 * Which filtered read a list request takes. `email` names ONE principal and

Callers 1

selectSubjectsFunction · 0.85

Calls 1

readFunction · 0.70

Tested by

no test coverage detected