/** * @since 2.0.0 */ import type * as _Cache from "./Cache.js"; import type { Cause } from "./Cause.js"; import type { Deferred } from "./Deferred.js"; import type { DurationInput } from "./Duration.js"; import type * as Effect from "./Effect.js"; import type * as Exit from "./Exit.js"; import type { FiberId } from "./FiberId.js"; import type * as Option from "./Option.js"; import type * as Types from "./Types.js"; /** * @since 2.0.0 * @category symbols */ export declare const RequestTypeId: unique symbol; /** * @since 2.0.0 * @category symbols */ export type RequestTypeId = typeof RequestTypeId; /** * A `Request` is a request from a data source for a value of type `A` * that may fail with an `E`. * * @since 2.0.0 * @category models */ export interface Request extends Request.Variance { } /** * @since 2.0.0 */ export declare namespace Request { /** * @since 2.0.0 * @category models */ interface Variance { readonly [RequestTypeId]: { readonly _A: Types.Covariant; readonly _E: Types.Covariant; }; } /** * @since 2.0.0 * @category models */ interface Constructor, T extends keyof R = never> { (args: Omit, Request.Error>)>): R; } /** * A utility type to extract the error type from a `Request`. * * @since 2.0.0 * @category type-level */ type Error> = [T] extends [Request] ? _E : never; /** * A utility type to extract the value type from a `Request`. * * @since 2.0.0 * @category type-level */ type Success> = [T] extends [Request] ? _A : never; /** * A utility type to extract the result type from a `Request`. * * @since 2.0.0 * @category type-level */ type Result> = T extends Request ? Exit.Exit : never; /** * A utility type to extract the optional result type from a `Request`. * * @since 2.0.0 * @category type-level */ type OptionalResult> = T extends Request ? Exit.Exit, E> : never; } /** * Returns `true` if the specified value is a `Request`, `false` otherwise. * * @since 2.0.0 * @category refinements */ export declare const isRequest: (u: unknown) => u is Request; /** * Constructs a new `Request`. * * @since 2.0.0 * @category constructors */ export declare const of: >() => Request.Constructor; /** * Constructs a new `Request`. * * @since 2.0.0 * @category constructors */ export declare const tagged: & { _tag: string; }>(tag: R["_tag"]) => Request.Constructor; /** * Provides a constructor for a Request Class. * * @example * ```ts * import { Request } from "effect" * * type Success = string * type Error = never * * class MyRequest extends Request.Class {} * ``` * * @since 2.0.0 * @category constructors */ export declare const Class: new >(args: Types.Equals>, {}> extends true ? void : { readonly [P in keyof A as P extends keyof Request ? never : P]: A[P]; }) => Request & Readonly; /** * Provides a Tagged constructor for a Request Class. * * @example * ```ts * import { Request } from "effect" * * type Success = string * type Error = never * * class MyRequest extends Request.TaggedClass("MyRequest") {} * ``` * * @since 2.0.0 * @category constructors */ export declare const TaggedClass: (tag: Tag) => new >(args: Types.Equals>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof Request ? never : P]: A[P]; }) => Request & Readonly & { readonly _tag: Tag; }; /** * Complete a `Request` with the specified result. * * @since 2.0.0 * @category request completion */ export declare const complete: { /** * Complete a `Request` with the specified result. * * @since 2.0.0 * @category request completion */ >(result: Request.Result): (self: A) => Effect.Effect; /** * Complete a `Request` with the specified result. * * @since 2.0.0 * @category request completion */ >(self: A, result: Request.Result): Effect.Effect; }; /** * Interrupts the child effect when requests are no longer needed * * @since 2.0.0 * @category request completion */ export declare const interruptWhenPossible: { /** * Interrupts the child effect when requests are no longer needed * * @since 2.0.0 * @category request completion */ (all: Iterable>): (self: Effect.Effect) => Effect.Effect; /** * Interrupts the child effect when requests are no longer needed * * @since 2.0.0 * @category request completion */ (self: Effect.Effect, all: Iterable>): Effect.Effect; }; /** * Complete a `Request` with the specified effectful computation, failing the * request with the error from the effect workflow if it fails, and completing * the request with the value of the effect workflow if it succeeds. * * @since 2.0.0 * @category request completion */ export declare const completeEffect: { /** * Complete a `Request` with the specified effectful computation, failing the * request with the error from the effect workflow if it fails, and completing * the request with the value of the effect workflow if it succeeds. * * @since 2.0.0 * @category request completion */ , R>(effect: Effect.Effect, Request.Error, R>): (self: A) => Effect.Effect; /** * Complete a `Request` with the specified effectful computation, failing the * request with the error from the effect workflow if it fails, and completing * the request with the value of the effect workflow if it succeeds. * * @since 2.0.0 * @category request completion */ , R>(self: A, effect: Effect.Effect, Request.Error, R>): Effect.Effect; }; /** * Complete a `Request` with the specified error. * * @since 2.0.0 * @category request completion */ export declare const fail: { /** * Complete a `Request` with the specified error. * * @since 2.0.0 * @category request completion */ >(error: Request.Error): (self: A) => Effect.Effect; /** * Complete a `Request` with the specified error. * * @since 2.0.0 * @category request completion */ >(self: A, error: Request.Error): Effect.Effect; }; /** * Complete a `Request` with the specified cause. * * @since 2.0.0 * @category request completion */ export declare const failCause: { /** * Complete a `Request` with the specified cause. * * @since 2.0.0 * @category request completion */ >(cause: Cause>): (self: A) => Effect.Effect; /** * Complete a `Request` with the specified cause. * * @since 2.0.0 * @category request completion */ >(self: A, cause: Cause>): Effect.Effect; }; /** * Complete a `Request` with the specified value. * * @since 2.0.0 * @category request completion */ export declare const succeed: { /** * Complete a `Request` with the specified value. * * @since 2.0.0 * @category request completion */ >(value: Request.Success): (self: A) => Effect.Effect; /** * Complete a `Request` with the specified value. * * @since 2.0.0 * @category request completion */ >(self: A, value: Request.Success): Effect.Effect; }; /** * @category models * @since 2.0.0 */ export interface Listeners { readonly count: number; readonly observers: Set<(count: number) => void>; interrupted: boolean; addObserver(f: (count: number) => void): void; removeObserver(f: (count: number) => void): void; increment(): void; decrement(): void; } /** * @category models * @since 2.0.0 */ export interface Cache extends _Cache.ConsumerCache, { listeners: Listeners; handle: Deferred; }> { } /** * @since 2.0.0 * @category models */ export declare const makeCache: (options: { readonly capacity: number; readonly timeToLive: DurationInput; }) => Effect.Effect; /** * @since 2.0.0 * @category symbols */ export declare const EntryTypeId: unique symbol; /** * @since 2.0.0 * @category symbols */ export type EntryTypeId = typeof EntryTypeId; /** * A `Entry` keeps track of a request of type `A` along with a * `Ref` containing the result of the request, existentially hiding the result * type. This is used internally by the library to support data sources that * return different result types for different requests while guaranteeing that * results will be of the type requested. * * @since 2.0.0 * @category models */ export interface Entry extends Entry.Variance { readonly request: R; readonly result: Deferred<[ R ] extends [Request] ? _A : never, [ R ] extends [Request] ? _E : never>; readonly listeners: Listeners; readonly ownerId: FiberId; readonly state: { completed: boolean; }; } /** * @since 2.0.0 * @category models */ export declare namespace Entry { /** * @since 2.0.0 * @category models */ interface Variance { readonly [EntryTypeId]: { readonly _R: Types.Covariant; }; } } /** * @since 2.0.0 * @category guards */ export declare const isEntry: (u: unknown) => u is Entry; /** * @since 2.0.0 * @category constructors */ export declare const makeEntry: >(options: { readonly request: A; readonly result: Deferred, Request.Error>; readonly listeners: Listeners; readonly ownerId: FiberId; readonly state: { completed: boolean; }; }) => Entry; //# sourceMappingURL=Request.d.ts.map