/** * Connects typed `HttpApi` clients to atoms. * * The service created here exposes the generated HTTP API client plus * atom-based query and mutation helpers. Query atoms call endpoints and track * their asynchronous result, while mutations run endpoint calls that can * invalidate reactivity keys after a successful request. Query atoms can also be * cached, serialized for hydration, and kept alive with a time-to-live. * * @stability unstable * @since 4.0.0 */ import * as Context from "../Context.ts"; import * as Duration from "../Duration.ts"; import * as Effect from "../Effect.ts"; import type * as HttpApi from "../http-api/HttpApi.ts"; import * as HttpApiClient from "../http-api/HttpApiClient.ts"; import * as HttpApiEndpoint from "../http-api/HttpApiEndpoint.ts"; import type * as HttpApiGroup from "../http-api/HttpApiGroup.ts"; import type * as HttpApiMiddleware from "../http-api/HttpApiMiddleware.ts"; import type * as HttpClient from "../http/HttpClient.ts"; import * as Layer from "../Layer.ts"; import * as Schema from "../Schema.ts"; import type { Simplify } from "../Types.ts"; import * as AsyncResult from "./AsyncResult.ts"; import * as Atom from "./Atom.ts"; import * as Reactivity from "./Reactivity.ts"; /** * A `Context.Service` for an HTTP API client integrated with atom reactivity. * * **Details** * * It exposes the generated HTTP API client, an atom runtime, mutation helpers that * return `AtomResultFn`s, and query helpers that return atoms of endpoint results. * * @stability unstable * @category services * @since 4.0.0 */ export interface AtomHttpApiClient extends Context.Service> { new (_: never): Context.ServiceClass.Shape>; readonly runtime: Atom.AtomRuntime; readonly mutation: , EndpointIdentifier extends HttpApiEndpoint.Identifier>, Group extends HttpApiGroup.Constraint = HttpApiGroup.WithIdentifier, Endpoint extends HttpApiEndpoint.Constraint = HttpApiEndpoint.WithIdentifier, EndpointIdentifier>, const ResponseMode extends HttpApiEndpoint.ClientResponseMode = "decoded-only">(group: GroupIdentifier, endpoint: EndpointIdentifier, options?: { readonly responseMode?: ResponseMode | undefined; }) => [Endpoint] extends [ HttpApiEndpoint.HttpApiEndpoint ] ? Atom.AtomResultFn & { readonly reactivityKeys?: Reactivity.KeysInput | undefined; }>, ResponseByMode, ErrorByMode<_Error, _Middleware, ResponseMode>> : never; readonly query: , EndpointIdentifier extends HttpApiEndpoint.Identifier>, Group extends HttpApiGroup.Constraint = HttpApiGroup.WithIdentifier, Endpoint extends HttpApiEndpoint.Constraint = HttpApiEndpoint.WithIdentifier, EndpointIdentifier>, const ResponseMode extends HttpApiEndpoint.ClientResponseMode = "decoded-only">(group: GroupIdentifier, endpoint: EndpointIdentifier, request: [Endpoint] extends [ HttpApiEndpoint.HttpApiEndpoint ] ? HttpApiEndpoint.ClientRequest<_Params, _Query, _Payload, _Headers, ResponseMode> & { readonly reactivityKeys?: Reactivity.KeysInput | undefined; readonly timeToLive?: Duration.Input | undefined; readonly serializationKey?: string | undefined; } : never) => [Endpoint] extends [ HttpApiEndpoint.HttpApiEndpoint ] ? Atom.Atom, ErrorByMode<_Error, _Middleware, ResponseMode>>> : never; } declare global { interface ErrorConstructor { stackTraceLimit: number; } } /** * Creates a `Context.Service` class for an HTTP API client backed by an atom * runtime. * * **Details** * * The options provide the API definition, HTTP client layer, optional client and * response transforms, base URL, and runtime factory used by the query and * mutation helpers. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const Service: () => (id: Id, options: { readonly api: HttpApi.HttpApi; readonly httpClient: Layer.Layer | HttpClient.HttpClient> | ((get: Atom.AtomContext) => Layer.Layer | HttpClient.HttpClient>); readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined; readonly transformResponse?: ((effect: Effect.Effect) => Effect.Effect) | undefined; readonly baseUrl?: URL | string | undefined; readonly runtime?: Atom.RuntimeFactory | undefined; }) => AtomHttpApiClient; type ResponseByMode = HttpApiClient.Client.Response["~Success"]>, ResponseMode>; type ErrorByMode = HttpApiMiddleware.Error | HttpApiMiddleware.ClientError | ([ResponseMode] extends ["response-only"] ? never : Error["Type"]); export {}; //# sourceMappingURL=AtomHttpApi.d.ts.map