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

Function selectSubjects

packages/core/api/src/admin/reads.ts:349–368  ·  view source on GitHub ↗
(
  directory: AdminUserDirectory,
  options: AdminUsersListOptions,
  reads: {
    readonly page: (
      paging: AdminListSubjectsOptions,
    ) => Effect.Effect<readonly T[], AdminUsersError>;
    readonly one: (externalId: string) => Effect.Effect<T | null, AdminUsersError>;
  },
)

Source from the content-addressed store, hash-verified

347 * a search term beside an exact address has nothing left to narrow.
348 */
349const selectSubjects = <T>(
350 directory: AdminUserDirectory,
351 options: AdminUsersListOptions,
352 reads: {
353 readonly page: (
354 paging: AdminListSubjectsOptions,
355 ) => Effect.Effect<readonly T[], AdminUsersError>;
356 readonly one: (externalId: string) => Effect.Effect<T | null, AdminUsersError>;
357 },
358): Effect.Effect<readonly T[], AdminUsersError> => {
359 if (options.email !== undefined) {
360 return selectByEmail(directory, options.email, options, reads.one);
361 }
362 if (options.search !== undefined) {
363 return selectBySearch(directory, options.search, (externalIds) =>
364 reads.page({ ...pagingOf(options), externalIds }),
365 );
366 }
367 return reads.page(pagingOf(options));
368};
369
370/** Only the paging window — never the filters — reaches the SDK: the filters
371 * are resolved here, and the SDK's own `externalIds` is set by this file. */

Callers 2

listUsersFunction · 0.85
listUsersWithConnectionsFunction · 0.85

Calls 3

selectByEmailFunction · 0.85
selectBySearchFunction · 0.85
pagingOfFunction · 0.85

Tested by

no test coverage detected