MCPcopy Create free account
hub / github.com/Effect-TS/effect / group

Function group

packages/effect/src/unstable/httpapi/HttpApiClient.ts:546–575  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi<ApiId, Groups>,
  options: {
    readonly group: GroupIdentifier
    readonly httpClient: HttpClient.HttpClient.With<E, R>
    readonly transformResponse?:
      | ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>)
      | undefined
    readonly baseUrl?: URL | string | undefined
  }
)

Source from the content-addressed store, hash-verified

544 * @since 4.0.0
545 */
546export const group = <
547 ApiId extends string,
548 Groups extends HttpApiGroup.Constraint,
549 const GroupIdentifier extends HttpApiGroup.Identifier<Groups>,
550 E,
551 R
552>(
553 api: HttpApi.HttpApi<ApiId, Groups>,
554 options: {
555 readonly group: GroupIdentifier
556 readonly httpClient: HttpClient.HttpClient.With<E, R>
557 readonly transformResponse?:
558 | ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>)
559 | undefined
560 readonly baseUrl?: URL | string | undefined
561 }
562): Effect.Effect<
563 Client.Group<HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>, E, R>,
564 never,
565 HttpApiGroup.MiddlewareClient<HttpApiGroup.WithIdentifier<Groups, GroupIdentifier>>
566> => {
567 const client: Record<string, any> = {}
568 return makeClient(api, {
569 ...options,
570 predicate: ({ group }) => group.identifier === options.group,
571 onEndpoint({ endpoint, endpointFn }) {
572 InternalRecord.assignProperty(client, endpoint.identifier, endpointFn)
573 }
574 }).pipe(Effect.map(() => client)) as any
575}
576
577type EndpointReturn<
578 Groups extends HttpApiGroup.Constraint,

Callers

nothing calls this directly

Calls 3

makeClientFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected