( headers: AdminUsersHeaders, body: (executor: Executor, organizationId: string) => Effect.Effect<A, E>, )
| 250 | * I/O isolation forbids sharing across requests. |
| 251 | */ |
| 252 | const withPlatformView = <A, E extends AdminUsersError | AdminUserNotFound = AdminUsersError>( |
| 253 | headers: AdminUsersHeaders, |
| 254 | body: (executor: Executor, organizationId: string) => Effect.Effect<A, E>, |
| 255 | ): Effect.Effect< |
| 256 | A, |
| 257 | // `AdminUsersError` unconditionally: opening the platform view can fail that |
| 258 | // way regardless of what `body` itself raises. |
| 259 | E | AdminUsersError | AdminUsersUnauthorized | AdminUsersForbidden, |
| 260 | WorkOSClient | ApiKeyService | UserStoreService | DbProvider | PluginsProvider | HostConfig |
| 261 | > => |
| 262 | Effect.gen(function* () { |
| 263 | const organizationId = yield* authorizeTenant( |
| 264 | new Request("https://admin.invalid", { headers }), |
| 265 | ); |
| 266 | const executor = yield* makePlatformExecutor(organizationId).pipe( |
| 267 | Effect.mapError(() => new AdminUsersError({ message: "Failed to open the platform view" })), |
| 268 | ); |
| 269 | // The authorized tenant is handed to the body so an identity join reads the |
| 270 | // SAME org the reads are scoped to — never one named by client input. |
| 271 | return yield* Effect.ensuring( |
| 272 | body(executor, organizationId), |
| 273 | executor.close().pipe(Effect.ignore), |
| 274 | ); |
| 275 | }); |
| 276 | |
| 277 | /** |
| 278 | * Cloud's `AdminUsersProvider`, built per request so the platform executor |
no test coverage detected