Skip to main content Link Search Menu Expand Document (external link)

AtomHttpApi overview

Added in v1.0.0


Table of contents


Constructors

Tag

Signature

export declare const Tag: <Self>() => <
  const Id extends string,
  ApiId extends string,
  Groups extends HttpApiGroup.HttpApiGroup.Any,
  ApiE,
  E,
  R
>(
  id: Id,
  options: {
    readonly api: HttpApi.HttpApi<ApiId, Groups, ApiE, R>
    readonly httpClient: Layer.Layer<
      | HttpApiMiddleware.HttpApiMiddleware.Without<
          NoInfer<R> | HttpApiGroup.HttpApiGroup.ClientContext<NoInfer<Groups>>
        >
      | HttpClient.HttpClient,
      E
    >
    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
  }
) => AtomHttpApiClient<Self, Id, Groups, ApiE, E>

Added in v1.0.0

Models

AtomHttpApiClient (interface)

Signature

export interface AtomHttpApiClient<Self, Id extends string, Groups extends HttpApiGroup.HttpApiGroup.Any, ApiE, E>
  extends Context.Tag<Self, Simplify<HttpApiClient.Client<Groups, ApiE, never>>> {
  new (_: never): Context.TagClassShape<Id, Simplify<HttpApiClient.Client<Groups, ApiE, never>>>

  readonly layer: Layer.Layer<Self, E>
  readonly runtime: Atom.AtomRuntime<Self, E>

  readonly mutation: <
    GroupName extends HttpApiGroup.HttpApiGroup.Name<Groups>,
    Name extends HttpApiEndpoint.HttpApiEndpoint.Name<HttpApiGroup.HttpApiGroup.Endpoints<Group>>,
    Group extends HttpApiGroup.HttpApiGroup.Any = HttpApiGroup.HttpApiGroup.WithName<Groups, GroupName>,
    Endpoint extends HttpApiEndpoint.HttpApiEndpoint.Any = HttpApiEndpoint.HttpApiEndpoint.WithName<
      HttpApiGroup.HttpApiGroup.Endpoints<Group>,
      Name
    >
  >(
    group: GroupName,
    endpoint: Name
  ) => [Endpoint] extends [
    HttpApiEndpoint.HttpApiEndpoint<
      infer _Name,
      infer _Method,
      infer _Path,
      infer _UrlParams,
      infer _Payload,
      infer _Headers,
      infer _Success,
      infer _Error,
      infer _R,
      infer _RE
    >
  ]
    ? Atom.AtomResultFn<
        Simplify<
          HttpApiEndpoint.HttpApiEndpoint.ClientRequest<_Path, _UrlParams, _Payload, _Headers, false> & {
            readonly reactivityKeys?: ReadonlyArray<unknown> | undefined
          }
        >,
        _Success,
        _Error | HttpApiGroup.HttpApiGroup.Error<Group> | E | HttpClientError.HttpClientError | ParseResult.ParseError
      >
    : never

  readonly query: <
    GroupName extends HttpApiGroup.HttpApiGroup.Name<Groups>,
    Name extends HttpApiEndpoint.HttpApiEndpoint.Name<HttpApiGroup.HttpApiGroup.Endpoints<Group>>,
    Group extends HttpApiGroup.HttpApiGroup.Any = HttpApiGroup.HttpApiGroup.WithName<Groups, GroupName>,
    Endpoint extends HttpApiEndpoint.HttpApiEndpoint.Any = HttpApiEndpoint.HttpApiEndpoint.WithName<
      HttpApiGroup.HttpApiGroup.Endpoints<Group>,
      Name
    >
  >(
    group: GroupName,
    endpoint: Name,
    request: [Endpoint] extends [
      HttpApiEndpoint.HttpApiEndpoint<
        infer _Name,
        infer _Method,
        infer _Path,
        infer _UrlParams,
        infer _Payload,
        infer _Headers,
        infer _Success,
        infer _Error,
        infer _R,
        infer _RE
      >
    ]
      ? Simplify<
          HttpApiEndpoint.HttpApiEndpoint.ClientRequest<_Path, _UrlParams, _Payload, _Headers, false> & {
            readonly reactivityKeys?:
              | ReadonlyArray<unknown>
              | ReadonlyRecord<string, ReadonlyArray<unknown>>
              | undefined
            readonly timeToLive?: Duration.DurationInput | undefined
          }
        >
      : never
  ) => [Endpoint] extends [
    HttpApiEndpoint.HttpApiEndpoint<
      infer _Name,
      infer _Method,
      infer _Path,
      infer _UrlParams,
      infer _Payload,
      infer _Headers,
      infer _Success,
      infer _Error,
      infer _R,
      infer _RE
    >
  ]
    ? Atom.Atom<
        Result.Result<
          _Success,
          _Error | HttpApiGroup.HttpApiGroup.Error<Group> | E | HttpClientError.HttpClientError | ParseResult.ParseError
        >
      >
    : never
}

Added in v1.0.0