import type { ApiProfile, ApiRequest, TargetPrecondition } from "@decionis/agent-safe-pipeline"; import { type EffectPending, type ExpectedEffect, type ObservedEffect, type RefusalOutcome } from "./TargetEffect.js"; import type { Upstream } from "./Upstream.js"; /** * What the gateway read of one profiled write's target before the authority * was asked: the read its profile names, the precondition the answer stated, * and what the grant commits the write's effect to, or why it commits to none. */ export interface TargetPlan { /** The write's operation in the profile. */ readonly operation: string; readonly read: ApiRequest; readonly precondition: TargetPrecondition; readonly effect: ExpectedEffect | EffectPending; } /** Why a write was refused before the authority was asked: its target stated no usable version. */ export interface TargetRefusal { readonly reasonCodes: readonly ["TARGET_STATE_UNREADABLE", string]; } /** One read of a write's target after a refusal, against the read before the decision. */ export interface RefusalRead { readonly outcome: RefusalOutcome; readonly version: string | null; readonly readAt: string; } export interface TargetReaderOptions { readonly profile: ApiProfile; readonly upstream: Upstream; readonly clock: () => number; /** The reason code for a send that threw, as the gateway names a failed forward. */ readonly failure: (error: unknown) => string; } /** * The gateway's reads of a write's target, the one read its API profile * names, at three moments: before the authority is asked, so the intent * binds the version it is decided against; after an `ALLOW` the upstream * answered with a `2xx`, so what landed is compared with what was * authorised; and after a refusal, so the target is seen to have stayed * where it was. Every read is a `GET` the gateway makes as itself * (`Upstream.ownHeaders`), bounded like a forward, and nothing it reads is * relayed to a caller. */ export declare class TargetReader { private readonly options; constructor(options: TargetReaderOptions); /** * The plan for a write, or null when its operation names no read. A read * that does not answer `2xx`, or whose answer states no usable version, is * a refusal: the write is never decided against no version at all. */ plan(operation: string, request: ApiRequest, factsOnly: boolean): Promise; /** The read after a write the upstream answered `2xx`, against what the grant committed to. */ effect(plan: TargetPlan, effect: ExpectedEffect): Promise; /** The read after a refusal: the version now, against the one the decision was asked about. */ refusal(plan: TargetPlan): Promise; /** An operation as the effect digest names it: `#`, as a precondition's source does. */ private named; /** * One `GET` of the target: its headers, which the relay already names in * lower case, and its body when it is JSON; or why there is no answer to * read, a status past `2xx` included (the transport delivers no `1xx`). */ private read; /** * A read's query as a query string, each name and value percent-encoded: * the exact values its profile operation names, one string each. */ private static search; } //# sourceMappingURL=TargetReader.d.ts.map