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

Function selectByEmail

packages/core/api/src/admin/reads.ts:297–309  ·  view source on GitHub ↗
(
  directory: AdminUserDirectory,
  email: string,
  options: AdminUsersListOptions,
  read: (externalId: string) => Effect.Effect<T | null, AdminUsersError>,
)

Source from the content-addressed store, hash-verified

295 * "absent" the single-user path reports, not a storage fault.
296 */
297const selectByEmail = <T>(
298 directory: AdminUserDirectory,
299 email: string,
300 options: AdminUsersListOptions,
301 read: (externalId: string) => Effect.Effect<T | null, AdminUsersError>,
302): Effect.Effect<readonly T[], AdminUsersError> =>
303 Effect.gen(function* () {
304 // An email no directory can resolve matches nothing, and costs no read.
305 const wanted = yield* resolveEmailFilter(directory, email);
306 if (wanted === null) return [];
307 const row = yield* read(wanted);
308 return row === null ? [] : pageOf([row], options);
309 });
310
311/**
312 * The `?search=` read: FILTER by the directory, then PAGE through storage.

Callers 1

selectSubjectsFunction · 0.85

Calls 3

resolveEmailFilterFunction · 0.85
readFunction · 0.70
pageOfFunction · 0.70

Tested by

no test coverage detected