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

Function stubProvider

packages/core/api/src/admin/admin-users.test.ts:218–262  ·  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

216 * member.
217 */
218const stubProvider = (
219 executorFor: (tenant: string) => Effect.Effect<Executor>,
220 authorize: (
221 headers: AdminUsersHeaders,
222 ) => Effect.Effect<string, AdminUsersUnauthorized | AdminUsersForbidden>,
223 directory?: AdminIdentityDirectory | AdminUserDirectory,
224) =>
225 Layer.succeed(AdminUsersProvider)({
226 listUsers: (headers, options) =>
227 authorize(headers).pipe(
228 Effect.flatMap(executorFor),
229 Effect.flatMap((executor) =>
230 platformViewOf(executor).pipe(
231 Effect.flatMap((admin) => listUsers(admin, options, directory)),
232 ),
233 ),
234 ),
235 listUsersWithConnections: (headers, options) =>
236 authorize(headers).pipe(
237 Effect.flatMap(executorFor),
238 Effect.flatMap((executor) =>
239 platformViewOf(executor).pipe(
240 Effect.flatMap((admin) => listUsersWithConnections(admin, options, directory)),
241 ),
242 ),
243 ),
244 listUserConnections: (headers, externalId) =>
245 authorize(headers).pipe(
246 Effect.flatMap(executorFor),
247 Effect.flatMap((executor) =>
248 platformViewOf(executor).pipe(
249 Effect.flatMap((admin) => listUserConnections(admin, externalId)),
250 ),
251 ),
252 ),
253 getUser: (headers, identifier) =>
254 authorize(headers).pipe(
255 Effect.flatMap(executorFor),
256 Effect.flatMap((executor) =>
257 platformViewOf(executor).pipe(
258 Effect.flatMap((admin) => getUser(admin, identifier, directory)),
259 ),
260 ),
261 ),
262 });
263
264/**
265 * 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