( directory: AdminUserDirectory, term: string, read: (externalIds: readonly string[]) => Effect.Effect<readonly T[], AdminUsersError>, )
| 325 | * a resolver failure. |
| 326 | */ |
| 327 | const 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 |
no test coverage detected