import "@effect-ts/system/Operator"; import * as C from "@effect-ts/core/Collections/Immutable/Chunk"; import * as T from "@effect-ts/core/Effect"; import * as E from "@effect-ts/core/Either"; import type * as O from "@effect-ts/core/Option"; import * as St from "@effect-ts/core/Structural"; import type { _A, _E } from "@effect-ts/core/Utils"; import * as CR from "../CompletedRequestMap/index.js"; import type { Request } from "../Request/index.js"; /** * A `DataSource[R, A]` 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 `CompletedRequestMap` containing a * mapping from requests to results. The type of the collection of requests is * a `Chunk[Chunk[A]]`. 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[A]`, * though that is not strictly necessarily as long as the data source can map * the request type to a `Request[A]`. 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 `CompletedRequestsMap` using * [[CompletedRequestMap.empty]] and [[CompletedRequestMap.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. */ export declare class DataSource { /** * The data source's identifier. */ readonly identifier: string; /** * 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. */ readonly runAll: (requests: C.Chunk>) => T.Effect; readonly _tag = "DataSource"; constructor( /** * The data source's identifier. */ identifier: string, /** * 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: C.Chunk>) => T.Effect); [St.equalsSym](that: unknown): boolean; get [St.hashSym](): number; } export declare function equals(a: DataSource, b: DataSource): boolean; export declare class InvalidBatchConfig { readonly n: number; readonly _tag = "InvalidBatchConfig"; readonly message = "batchN: n must be at least 1 and must be an integer"; constructor(n: number); } /** * Returns a data source that executes at most `n` requests in parallel. */ export declare function batchN_(self: DataSource, n: number): DataSource; /** * Returns a data source that executes at most `n` requests in parallel. * @ets_data_first batchN_ */ export declare function batchN(n: number): (self: DataSource) => DataSource; /** * Returns a new data source that executes requests of type `B` using the * specified function to transform `B` requests into requests that this data * source can execute. */ export declare function contramap_(self: DataSource, description: string, f: (a: B) => A): DataSource; /** * Returns a new data source that executes requests of type `B` using the * specified function to transform `B` requests into requests that this data * source can execute. * @ets_data_first contramap_ */ export declare function contramap(description: string, f: (a: B) => A): (self: DataSource) => DataSource; /** * Returns a new data source that executes requests of type `B` using the * specified effectual function to transform `B` requests into requests that * this data source can execute. */ export declare function contramapM_(self: DataSource, description: string, f: (b: B) => T.Effect): DataSource; /** * Returns a new data source that executes requests of type `B` using the * specified effectual function to transform `B` requests into requests that * this data source can execute. * @ets_data_first contramapM_ */ export declare function contramapM(description: string, f: (b: B) => T.Effect): (self: DataSource) => DataSource; /** * 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. */ export declare function eitherWith_(self: DataSource, description: string, that: DataSource, f: (c: C) => E.Either): DataSource; /** * 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. * @ets_data_first eitherWith_ */ export declare function eitherWith(description: string, that: DataSource, f: (c: C) => E.Either): (self: DataSource) => DataSource; /** * Provides this data source with its required environment. */ export declare function provide_(self: DataSource, description: string, r: R): DataSource; /** * Provides this data source with its required environment. * @ets_data_first provide_ */ export declare function provide(description: string, r: R): (self: DataSource) => DataSource; /** * Provides this data source with part of its required environment. */ export declare function provideSome_(self: DataSource, description: string, f: (r: R0) => R): DataSource; /** * Provides this data source with part of its required environment. * @ets_data_first provideSome_ */ export declare function provideSome(description: string, f: (r: R0) => R): (self: DataSource) => DataSource; /** * 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. */ export declare function race_(self: DataSource, that: DataSource): DataSource; /** * 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. * @ets_data_first race_ */ export declare function race(that: DataSource): (self: DataSource) => DataSource; /** * A data source that executes requests that can be performed in parallel in * batches but does not further optimize batches of requests that must be * performed sequentially. */ export declare function makeBatched(identifier: string): (run: (requests: C.Chunk) => T.Effect) => DataSource; /** * Constructs a data source from a pure function. */ export declare function fromFunction(identifier: string): >(f: (a: A) => _A) => DataSource; /** * 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. */ export declare function fromFunctionBatched(identifier: string): >(f: (a: C.Chunk) => C.Chunk<_A>) => DataSource; /** * Constructs a data source from an effectual 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. */ export declare function fromFunctionBatchedM(identifier: string): >(f: (a: C.Chunk) => T.Effect, C.Chunk<_A>>) => DataSource; /** * Constructs a data source from a pure function that takes a list of * requests and returns a list of optional results of the same size. Each * item in the result list must correspond to the item at the same index in * the request list. */ export declare function fromFunctionBatchedOption(identifier: string): >(f: (a: C.Chunk) => C.Chunk>>) => DataSource; /** * Constructs a data source from an effectual function that takes a list of * requests and returns a list of optional results of the same size. Each * item in the result list must correspond to the item at the same index in * the request list. */ export declare function fromFunctionBatchedOptionM(identifier: string): , E, R>(f: (a: C.Chunk) => T.Effect>>>) => DataSource; //# sourceMappingURL=index.d.ts.map