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

Function stubProvider

packages/core/api/src/admin/admin-users.test.ts:226–270  ·  view source on GitHub ↗
(
  executorFor: (tenant: string) => Effect.Effect<Executor>,
  authorize: (
    headers: AdminUsersHeaders,
  ) => Effect.Effect<string, AdminUsersUnauthorized | AdminUsersForbidden>,
  directory?: AdminIdentityDirectory | AdminUserDirectory,
)

Source from the content-addressed store, hash-verified

224 * member.
225 */
226const stubProvider = (
227 executorFor: (tenant: string) => Effect.Effect<Executor>,
228 authorize: (
229 headers: AdminUsersHeaders,
230 ) => Effect.Effect<string, AdminUsersUnauthorized | AdminUsersForbidden>,
231 directory?: AdminIdentityDirectory | AdminUserDirectory,
232) =>
233 Layer.succeed(AdminUsersProvider)({
234 listUsers: (headers, options) =>
235 authorize(headers).pipe(
236 Effect.flatMap(executorFor),
237 Effect.flatMap((executor) =>
238 platformViewOf(executor).pipe(
239 Effect.flatMap((admin) => listUsers(admin, options, directory)),
240 ),
241 ),
242 ),
243 listUsersWithConnections: (headers, options) =>
244 authorize(headers).pipe(
245 Effect.flatMap(executorFor),
246 Effect.flatMap((executor) =>
247 platformViewOf(executor).pipe(
248 Effect.flatMap((admin) => listUsersWithConnections(admin, options, directory)),
249 ),
250 ),
251 ),
252 listUserConnections: (headers, externalId) =>
253 authorize(headers).pipe(
254 Effect.flatMap(executorFor),
255 Effect.flatMap((executor) =>
256 platformViewOf(executor).pipe(
257 Effect.flatMap((admin) => listUserConnections(admin, externalId)),
258 ),
259 ),
260 ),
261 getUser: (headers, identifier) =>
262 authorize(headers).pipe(
263 Effect.flatMap(executorFor),
264 Effect.flatMap((executor) =>
265 platformViewOf(executor).pipe(
266 Effect.flatMap((admin) => getUser(admin, identifier, directory)),
267 ),
268 ),
269 ),
270 });
271
272/**
273 * The authorization the hosts implement, reduced to its decision table:

Callers 2

singleUserWebFunction · 0.85

Calls 6

platformViewOfFunction · 0.90
listUsersFunction · 0.90
listUsersWithConnectionsFunction · 0.90
listUserConnectionsFunction · 0.90
getUserFunction · 0.90
authorizeFunction · 0.85

Tested by

no test coverage detected