| 395 | }); |
| 396 | |
| 397 | export const listUsersWithConnections = ( |
| 398 | admin: ExecutorAdmin, |
| 399 | options: AdminUsersListOptions, |
| 400 | directory?: AdminIdentityDirectory | AdminUserDirectory, |
| 401 | ): Effect.Effect<typeof AdminUsersWithConnectionsResponse.Type, AdminUsersError> => |
| 402 | Effect.gen(function* () { |
| 403 | const dir = asDirectory(directory); |
| 404 | const subjects = yield* selectSubjects(dir, options, { |
| 405 | page: (paging) => |
| 406 | admin.listSubjectsWithConnections(paging).pipe(Effect.mapError(readFailed("users"))), |
| 407 | one: (externalId) => |
| 408 | admin.getSubjectWithConnections(externalId).pipe(Effect.mapError(readFailed("users"))), |
| 409 | }); |
| 410 | const identities = yield* resolveIdentities( |
| 411 | dir.identities, |
| 412 | subjects.map((subject) => subject.externalId), |
| 413 | ); |
| 414 | return { users: subjects.map((subject) => toUserWithConnections(subject, identities)) }; |
| 415 | }); |
| 416 | |
| 417 | /** |
| 418 | * One user by `externalId` OR email, with connections. |