/** * @since 1.0.0 */ import * as Context from "@effect/data/Context"; import type * as Either from "@effect/data/Either"; import type * as Equal from "@effect/data/Equal"; import type { Pipeable } from "@effect/data/Pipeable"; import * as Effect from "@effect/io/Effect"; import type { FiberRef } from "@effect/io/FiberRef"; import type * as Request from "@effect/io/Request"; /** * @since 1.0.0 * @category symbols */ export declare const RequestResolverTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type RequestResolverTypeId = typeof RequestResolverTypeId; /** * A `RequestResolver` requires an environment `R` and is capable of executing * requests of type `A`. * * Data sources must implement the method `runAll` which takes a collection of * requests and returns an effect with a `RequestCompletionMap` containing a * mapping from requests to results. The type of the collection of requests is * a `Chunk>`. The outer `Chunk` represents batches of requests that * must be performed sequentially. The inner `Chunk` represents a batch of * requests that can be performed in parallel. This allows data sources to * introspect on all the requests being executed and optimize the query. * * Data sources will typically be parameterized on a subtype of `Request`, * though that is not strictly necessarily as long as the data source can map * the request type to a `Request`. Data sources can then pattern match on * the collection of requests to determine the information requested, execute * the query, and place the results into the `RequestCompletionMap` using * `RequestCompletionMap.empty` and `RequestCompletionMap.insert`. Data * sources must provide results for all requests received. Failure to do so * will cause a query to die with a `QueryFailure` when run. * * @since 1.0.0 * @category models */ export interface RequestResolver extends Equal.Equal, Pipeable { /** * Execute a collection of requests. The outer `Chunk` represents batches * of requests that must be performed sequentially. The inner `Chunk` * represents a batch of requests that can be performed in parallel. */ runAll(requests: Array>>): Effect.Effect; /** * Identify the data source using the specific identifier */ identified(...identifiers: Array): RequestResolver; } /** * @since 1.0.0 */ export declare namespace RequestResolver { /** * @since 1.0.0 * @category models */ interface Variance { readonly [RequestResolverTypeId]: { readonly _R: (_: never) => R; readonly _A: (_: never) => A; }; } } /** * @since 1.0.0 * @category utils */ export declare const contextFromEffect: >(self: RequestResolver) => Effect.Effect>; /** * @since 1.0.0 * @category utils */ export declare const contextFromServices: []>(...services: Services) => >(self: RequestResolver) => Effect.Effect<{ [k in keyof Services]: Effect.Effect.Context; }[number], never, RequestResolver; }[number]>>>; /** * Returns `true` if the specified value is a `RequestResolver`, `false` otherwise. * * @since 1.0.0 * @category refinements */ export declare const isRequestResolver: (u: unknown) => u is RequestResolver; /** * Constructs a data source with the specified identifier and method to run * requests. * * @since 1.0.0 * @category constructors */ export declare const make: (runAll: (requests: Array>) => Effect.Effect) => RequestResolver; /** * Constructs a data source with the specified identifier and method to run * requests. * * @since 1.0.0 * @category constructors */ export declare const makeWithEntry: (runAll: (requests: Array>>) => Effect.Effect) => RequestResolver; /** * Constructs a data source from a function taking a collection of requests * and returning a `RequestCompletionMap`. * * @since 1.0.0 * @category constructors */ export declare const makeBatched: >(run: (requests: Array) => Effect.Effect) => RequestResolver; /** * A data source aspect that executes requests between two effects, `before` * and `after`, where the result of `before` can be used by `after`. * * @since 1.0.0 * @category combinators */ export declare const around: { (before: Effect.Effect, after: (a: A2) => Effect.Effect): (self: RequestResolver) => RequestResolver; (self: RequestResolver, before: Effect.Effect, after: (a: A2) => Effect.Effect): RequestResolver; }; /** * Returns a data source that executes at most `n` requests in parallel. * * @since 1.0.0 * @category combinators */ export declare const batchN: { (n: number): (self: RequestResolver) => RequestResolver; (self: RequestResolver, n: number): RequestResolver; }; /** * Provides this data source with part of its required context. * * @since 1.0.0 * @category context */ export declare const mapInputContext: { (f: (context: Context.Context) => Context.Context): >(self: RequestResolver) => RequestResolver; , R0>(self: RequestResolver, f: (context: Context.Context) => Context.Context): RequestResolver; }; /** * Returns a new data source that executes requests of type `C` using the * specified function to transform `C` requests into requests that either this * data source or that data source can execute. * * @since 1.0.0 * @category combinators */ export declare const eitherWith: { , R2, B extends Request.Request, C extends Request.Request>(that: RequestResolver, f: (_: Request.Entry) => Either.Either, Request.Entry>): (self: RequestResolver) => RequestResolver; , R2, B extends Request.Request, C extends Request.Request>(self: RequestResolver, that: RequestResolver, f: (_: Request.Entry) => Either.Either, Request.Entry>): RequestResolver; }; /** * Constructs a data source from a pure function. * * @since 1.0.0 * @category constructors */ export declare const fromFunction: >(f: (request: A) => Request.Request.Success) => RequestResolver; /** * Constructs a data source from a pure function that takes a list of requests * and returns a list of results of the same size. Each item in the result * list must correspond to the item at the same index in the request list. * * @since 1.0.0 * @category constructors */ export declare const fromFunctionBatched: >(f: (chunk: Array) => Array>) => RequestResolver; /** * Constructs a data source from an effectual function. * * @since 1.0.0 * @category constructors */ export declare const fromFunctionEffect: >(f: (a: A) => Effect.Effect, Request.Request.Success>) => RequestResolver; /** * A data source that never executes requests. * * @since 1.0.0 * @category constructors */ export declare const never: RequestResolver; /** * Provides this data source with its required context. * * @since 1.0.0 * @category context */ export declare const provideContext: { (context: Context.Context): >(self: RequestResolver) => RequestResolver; >(self: RequestResolver, context: Context.Context): RequestResolver; }; /** * Returns a new data source that executes requests by sending them to this * data source and that data source, returning the results from the first data * source to complete and safely interrupting the loser. * * @since 1.0.0 * @category combinators */ export declare const race: { >(that: RequestResolver): >(self: RequestResolver) => RequestResolver; , R2, A2 extends Request.Request>(self: RequestResolver, that: RequestResolver): RequestResolver; }; /** * Returns a new data source with a localized FiberRef * * @since 1.0.0 * @category combinators */ export declare const locally: { (self: FiberRef, value: A): >(use: RequestResolver) => RequestResolver; , A>(use: RequestResolver, self: FiberRef, value: A): RequestResolver; }; //# sourceMappingURL=RequestResolver.d.ts.map