HttpApiClient.ts overview
Since v1.0.0
Exports Grouped by Category
constructors
endpoint
Signature
declare const endpoint: <
ApiId extends string,
Groups extends HttpApiGroup.Any,
ApiError,
ApiR,
const GroupName extends HttpApiGroup.Name<Groups>,
const EndpointName extends HttpApiEndpoint.Name<HttpApiGroup.EndpointsWithName<Groups, GroupName>>,
E,
R
>(
api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
options: {
readonly group: GroupName
readonly endpoint: EndpointName
readonly httpClient: HttpClient.HttpClient.With<E, R>
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
readonly transformResponse?:
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
| undefined
readonly baseUrl?: URL | string | undefined
}
) => Effect.Effect<
Client.Method<
HttpApiEndpoint.WithName<HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>, EndpointName>,
HttpApiGroup.Error<HttpApiGroup.WithName<Groups, GroupName>>,
ApiError | E,
R
>,
never,
HttpApiMiddleware.HttpApiMiddleware.Without<
| ApiR
| HttpApiGroup.Context<HttpApiGroup.WithName<Groups, GroupName>>
| HttpApiEndpoint.ContextWithName<HttpApiGroup.EndpointsWithName<Groups, GroupName>, EndpointName>
| HttpApiEndpoint.ErrorContextWithName<HttpApiGroup.EndpointsWithName<Groups, GroupName>, EndpointName>
>
>
Since v1.0.0
group
Signature
declare const group: <
ApiId extends string,
Groups extends HttpApiGroup.Any,
ApiError,
ApiR,
const GroupName extends HttpApiGroup.Name<Groups>,
E,
R
>(
api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
options: {
readonly group: GroupName
readonly httpClient: HttpClient.HttpClient.With<E, R>
readonly transformResponse?:
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
| undefined
readonly baseUrl?: URL | string | undefined
}
) => Effect.Effect<
Client.Group<Groups, GroupName, ApiError | E, R>,
never,
HttpApiMiddleware.HttpApiMiddleware.Without<
ApiR | HttpApiGroup.ClientContext<HttpApiGroup.WithName<Groups, GroupName>>
>
>
Since v1.0.0
make
Signature
declare const make: <ApiId extends string, Groups extends HttpApiGroup.Any, ApiError, ApiR>(
api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
options?: {
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
readonly transformResponse?:
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
| undefined
readonly baseUrl?: URL | string | undefined
}
) => Effect.Effect<
Simplify<Client<Groups, ApiError, never>>,
never,
HttpApiMiddleware.HttpApiMiddleware.Without<ApiR | HttpApiGroup.ClientContext<Groups>> | HttpClient.HttpClient
>
Since v1.0.0
makeWith
Signature
declare const makeWith: <ApiId extends string, Groups extends HttpApiGroup.Any, ApiError, ApiR, E, R>(
api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
options: {
readonly httpClient: HttpClient.HttpClient.With<E, R>
readonly transformResponse?:
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
| undefined
readonly baseUrl?: URL | string | undefined
}
) => Effect.Effect<
Simplify<Client<Groups, ApiError | E, R>>,
never,
HttpApiMiddleware.HttpApiMiddleware.Without<ApiR | HttpApiGroup.ClientContext<Groups>>
>
Since v1.0.0
models
Client (type alias)
Signature
type Client<Groups, E, R> = Simplify<
{
readonly [Group in Extract<Groups, { readonly topLevel: false }> as HttpApiGroup.Name<Group>]: Client.Group<
Group,
Group["identifier"],
E,
R
>
} & {
readonly [Method in Client.TopLevelMethods<Groups, E, R> as Method[0]]: Method[1]
}
>
Since v1.0.0
Client (namespace)
Since v1.0.0
Group (type alias)
Signature
type Group<Groups, GroupName, E, R> = [HttpApiGroup.WithName<Groups, GroupName>] extends [
HttpApiGroup<infer _GroupName, infer _Endpoints, infer _GroupError, infer _GroupErrorR>
]
? {
readonly [Endpoint in _Endpoints as HttpApiEndpoint.Name<Endpoint>]: Method<Endpoint, E, _GroupError, R>
}
: never
Since v1.0.0
Method (type alias)
Signature
type Method<Endpoint, E, GroupError, R> = [Endpoint] extends [
HttpApiEndpoint<
infer _Name,
infer _Method,
infer _Path,
infer _UrlParams,
infer _Payload,
infer _Headers,
infer _Success,
infer _Error,
infer _R,
infer _RE
>
]
? <WithResponse extends boolean = false>(
request: Simplify<HttpApiEndpoint.ClientRequest<_Path, _UrlParams, _Payload, _Headers, WithResponse>>
) => Effect.Effect<
WithResponse extends true ? [_Success, HttpClientResponse.HttpClientResponse] : _Success,
_Error | GroupError | E | HttpClientError.HttpClientError | ParseResult.ParseError,
R
>
: never
Since v1.0.0
TopLevelMethods (type alias)
Signature
type TopLevelMethods<Groups, E, R> =
Extract<Groups, { readonly topLevel: true }> extends HttpApiGroup<
infer _Id,
infer _Endpoints,
infer _Error,
infer _ErrorR,
infer _TopLevel
>
? _Endpoints extends infer Endpoint
? [HttpApiEndpoint.Name<Endpoint>, Method<Endpoint, E, _Error, R>]
: never
: never
Since v1.0.0