/** * @since 1.0.0 */ import type * as Context from "@effect/data/Context" import type * as Either from "@effect/data/Either" import type * as HashMap from "@effect/data/HashMap" import type * as HashSet from "@effect/data/HashSet" import type * as MutableRef from "@effect/data/MutableRef" import type * as Option from "@effect/data/Option" import * as internal from "@effect/query/internal_effect_untraced/completedRequestMap" import type * as Request from "@effect/query/Request" /** * @since 1.0.0 * @category symbols */ export const CompletedRequestMapTypeId: unique symbol = internal.CompletedRequestMapTypeId /** * @since 1.0.0 * @category symbols */ export type CompletedRequestMapTypeId = typeof CompletedRequestMapTypeId /** * A `CompletedRequestMap` is a universally quantified mapping from requests of * type `Request` to results of type `Either` for all types `E` and * `A`. The guarantee is that for any request of type `Request`, if there * is a corresponding value in the map, that value is of type `Either`. * This is used 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 1.0.0 * @category models */ export interface CompletedRequestMap extends CompletedRequestMap.Proto { /** @internal */ readonly map: MutableRef.MutableRef< HashMap.HashMap< Request.Request, Either.Either > > } /** * The context tag for a `CompletedRequestMap`. * * @since 1.0.0 * @category context */ export const CompletedRequestMap: Context.Tag = internal.CompletedRequestMap /** * @since 1.0.0 */ export declare namespace CompletedRequestMap { /** * @since 1.0.0 * @category models */ export interface Proto { readonly [CompletedRequestMapTypeId]: CompletedRequestMapTypeId } } /** * An empty completed requests map. * * @since 1.0.0 * @category constructors */ export const empty: () => CompletedRequestMap = internal.empty /** * Constructs a new completed requests map with the specified request and * result. * * @since 1.0.0 * @category constructors */ export const make: (request: Request.Request, result: Either.Either) => CompletedRequestMap = internal.make /** * Combines two completed request maps into a single completed request map. * * @since 1.0.0 * @category combinators */ export const combine: { (that: CompletedRequestMap): (self: CompletedRequestMap) => CompletedRequestMap (self: CompletedRequestMap, that: CompletedRequestMap): CompletedRequestMap } = internal.combine /** * Retrieves the result of the specified request if it exists. * * @since 1.0.0 * @category elements */ export const get: { >( request: A ): (self: CompletedRequestMap) => Option.Option> >(self: CompletedRequestMap, request: A): Option.Option> } = internal.get /** * Returns whether a result exists for the specified request. * * @since 1.0.0 * @category elements */ export const has: { >(request: A): (self: CompletedRequestMap) => boolean >(self: CompletedRequestMap, request: A): boolean } = internal.has /** * Collects all requests in a set. * * @since 1.0.0 * @category elements */ export const requests: (self: CompletedRequestMap) => HashSet.HashSet> = internal.requests /** * Appends the specified result to the completed requests map. * * @since 1.0.0 * @category combinators */ export const set: { >( request: A, result: Request.Request.Result ): (self: CompletedRequestMap) => void >(self: CompletedRequestMap, request: A, result: Request.Request.Result): void } = internal.set /** * Appends the specified optional result to the completed request map. * * @since 1.0.0 * @category combinators */ export const setOption: { >( request: A, result: Request.Request.OptionalResult ): (self: CompletedRequestMap) => void >( self: CompletedRequestMap, request: A, result: Request.Request.OptionalResult ): void } = internal.setOption