import type { ClientContext } from './request.js'; import type { IZcap } from '../types.js'; /** * The read side of a backend-feature probe, so a consumer can be handed an * already-memoized probe instead of building its own (and repeating the * descriptor round trip). {@link BackendFeatures} is the implementation; * {@link featureProbeFrom} adapts a bare "resolve the feature tokens" thunk -- * the shape a handle shares with its children -- to the same interface. */ export interface FeatureProbe { get(): Promise; has(feature: string): Promise; /** * Whether the probe's answer came from a backend descriptor that could not be * read at all (`404` / `405` / `501`) rather than from one that was read and * advertises a feature set. Both answer "no features", but only the second is * evidence about the server's capabilities: the first also covers a deleted * collection and a capability that cannot read the descriptor (WAS masks * unauthorized reads as 404). An affordance gate consults it so its error * names the right cause. * * @returns {Promise} */ descriptorAbsent(): Promise; } /** * Adapts a resolve-the-feature-tokens thunk (a handle's shared, memoized probe) * to the {@link FeatureProbe} interface, so a consumer that only needs to ask * `has(...)` can be driven by someone else's memo. * * @param get {function} resolves the backend's advertised feature tokens * @param [descriptorAbsent] {function} resolves whether the descriptor was * unreadable; a bare thunk carries no such signal, so it defaults to `false` * ("a descriptor was read, and it advertises these tokens") * @returns {FeatureProbe} */ export declare function featureProbeFrom(get: () => Promise, descriptorAbsent?: () => Promise): FeatureProbe; /** * A memoizing probe of one collection backend's advertised feature tokens. * Memoized once it produces a definitive answer: a successful read (including * one that lists no features) and a definitive "endpoint absent" * (`404` / `405` / `501`) both resolve to a cached feature list, so every * affordance gate falls closed against a server that has no backend * descriptors. * * A transient/ambiguous failure (network error, timeout, `401`, `429`, other * `5xx`) is NOT cached: the memo is cleared so the next call re-probes, and * the error is rethrown so the caller fails loud rather than silently * degrading against a server that may well be capable. (A single transient * failure must not poison the probe for its lifetime.) */ export declare class BackendFeatures implements FeatureProbe { #private; /** * @param readDescriptor {function} reads and parses the backend descriptor * JSON (`GET .../backend`); expected to throw an error carrying an HTTP * status (readable via `httpStatus`) on failure */ constructor(readDescriptor: () => Promise); /** * The feature tokens the backend advertises, probed once and cached on a * definitive answer. * * @returns {Promise} */ get(): Promise; /** * Whether the backend advertises the given feature token. * * @param feature {string} the affordance token (e.g. `conditional-writes`) * @returns {Promise} */ has(feature: string): Promise; /** * Whether the (definitive) answer came from an unreadable backend descriptor * rather than from one that was read. Awaits the probe, so it reports the * same answer `get()` resolved. * * @returns {Promise} */ descriptorAbsent(): Promise; } /** * Builds the {@link BackendFeatures} probe for a collection, reading its * backend descriptor with a signed `GET` through the shared request layer -- * the probe the core handles (Collection/Resource) hold, mirroring the one * `WasTransport` builds over its own requester. A descriptor that is not * readable with the bound capability surfaces as a 404 (WAS masks unauthorized * reads), which the probe treats as "no features advertised" -- so every * affordance gate falls closed for a capability that cannot read the * descriptor. * * @param context {ClientContext} * @param options {object} * @param options.spaceId {string} * @param options.collectionId {string} * @param [options.capability] {IZcap} capability attached to the probe * @returns {BackendFeatures} */ export declare function collectionBackendFeatures(context: ClientContext, { spaceId, collectionId, capability }: { spaceId: string; collectionId: string; capability?: IZcap; }): BackendFeatures; //# sourceMappingURL=features.d.ts.map