import { DecafRequestContext } from "../request/index.d.cts"; import { DecafController } from "../controllers.d.cts"; import { DecafServerCtx } from "../constants.d.cts"; import type { ObserverEventsOptions } from "../types.d.cts"; import { ObserverSubscriptionRegistry } from "./ObserverSubscriptionRegistry.d.cts"; /** * @description REST payload for subscribing an SSE client to topics * @summary The request body accepted by the subscribe endpoint: an optional list * of webhook-style topic patterns. * @typedef {Object} SubscriptionPayload * @property {string[]} [topics] - The topics to subscribe the requester to * @memberOf module:for-nest.events */ type SubscriptionPayload = { topics?: string[]; }; /** * @description REST controller managing SSE topic subscriptions * @summary Exposes `POST subscribe` and `POST unsubscribe` endpoints that upsert or * remove the requester's topic subscriptions in the {@link ObserverSubscriptionRegistry}. * Both endpoints no-op with `{ enabled: false }` when subscription mode is disabled. * @class EventsSubscriptionController * @param {DecafRequestContext} clientContext - The active request context * @param {ObserverEventsOptions} options - Observer events configuration (injected via {@link OBSERVER_EVENTS_OPTIONS}) * @param {ObserverSubscriptionRegistry} registry - The topic-subscription registry * @memberOf module:for-nest.events */ export declare class EventsSubscriptionController extends DecafController { private readonly options; private readonly registry; constructor(clientContext: DecafRequestContext, options: ObserverEventsOptions, registry: ObserverSubscriptionRegistry); /** * @description Resolves the request's requester fingerprint * @summary Delegates to {@link resolveRequesterFingerprint}, falling back to a * freshly generated id so every anonymous request still gets a stable key. * @returns {string} The resolved fingerprint value */ private resolveFingerprint; /** * @description Subscribes the requester to a set of webhook topics * @summary Upserts the requester's topic subscriptions in the registry and returns * the stored (sanitized) topics plus a truncated fingerprint label. Returns * `{ enabled: false }` when subscription mode is disabled. * @param {SubscriptionPayload} body - The topics to subscribe to * @returns {Promise>} `{ enabled, fingerprint, topics }` or `{ enabled: false }` * @mermaid * sequenceDiagram * participant Client * participant Controller as EventsSubscriptionController * participant Registry as ObserverSubscriptionRegistry * Client->>Controller: POST subscribe { topics } * alt subscription mode disabled * Controller-->>Client: { enabled: false } * else * Controller->>Controller: resolveFingerprint() * Controller->>Registry: upsert(fingerprint, topics) * Registry-->>Controller: record * Controller-->>Client: { fingerprint, topics } * end */ subscribe(body: SubscriptionPayload): Promise>; /** * @description Removes the requester's topic subscriptions * @summary Deletes the requester's record from the registry and reports whether a * subscription existed. Returns `{ enabled: false }` when subscription mode is * disabled. * @returns {Record} `{ enabled, unsubscribed, fingerprint }` or `{ enabled: false }` */ unsubscribe(): Record; } export {};