import { OrderedDict } from "../ordered-dict/ordered_dict"; import { AsyncFunction } from "../types"; import { DDPSession, SessionConnectionHandle } from "./session"; export type SubscriptionHandle = `N${string}` | `U${string}`; export type SubscriptionCallbacks = Pick; /** * @summary The server's side of a subscription * @class Subscription * @instanceName this * @showInstanceName true */ export declare class Subscription { _session: DDPSession; private _handler; private _subscriptionId; private _params; _name?: string; connection: SessionConnectionHandle; private _subscriptionHandle; private _deactivated; private _stopCallbacks; private _documents; private _ready; userId: string | null; private _idFilter; constructor(_session: DDPSession, _handler: (...args: any[]) => any | AsyncFunction, _subscriptionId: string, _params?: any[], _name?: string); _runHandler(): Promise; _publishHandlerResult(res: any): Promise; _deactivate(): void; _callStopCallbacks(): void; _removeAllDocuments(): void; _recreate(): Subscription; /** * @summary Call inside the publish function. Stops this client's subscription, triggering a call on the client to the `onStop` callback passed to [`Meteor.subscribe`](#meteor_subscribe), if any. If `error` is not a [`Meteor.Error`](#meteor_error), it will be [sanitized](#meteor_error). * @locus Server * @param {Error} error The error to pass to the client. * @instance * @memberOf Subscription */ error(error: Error): void; /** * @summary Call inside the publish function. Stops this client's subscription and invokes the client's `onStop` callback with no error. * @locus Server * @instance * @memberOf Subscription */ stop(): void; /** * @summary Call inside the publish function. Registers a callback function to run when the subscription is stopped. * @locus Server * @memberOf Subscription * @instance * @param {Function} func The callback function */ onStop(func: () => void): void; _isDeactivated(): boolean; initialAdds(collectionName: string, documents: Map | OrderedDict): void; /** * @summary Call inside the publish function. Informs the subscriber that a document has been added to the record set. * @locus Server * @memberOf Subscription * @instance * @param {String} collection The name of the collection that contains the new document. * @param {String} id The new document's ID. * @param {Object} fields The fields in the new document. If `_id` is present it is ignored. */ added(collectionName: string, id: string, fields: Record): void; /** * @summary Call inside the publish function. Informs the subscriber that a document in the record set has been modified. * @locus Server * @memberOf Subscription * @instance * @param {String} collection The name of the collection that contains the changed document. * @param {String} id The changed document's ID. * @param {Object} fields The fields in the document that have changed, together with their new values. If a field is not present in `fields` it was left unchanged; if it is present in `fields` and has a value of `undefined` it was removed from the document. If `_id` is present it is ignored. */ changed(collectionName: string, id: string, fields: Record): void; /** * @summary Call inside the publish function. Informs the subscriber that a document has been removed from the record set. * @locus Server * @memberOf Subscription * @instance * @param {String} collection The name of the collection that the document has been removed from. * @param {String} id The ID of the document that has been removed. */ removed(collectionName: string, id: string): void; /** * @summary Call inside the publish function. Informs the subscriber that an initial, complete snapshot of the record set has been sent. This will trigger a call on the client to the `onReady` callback passed to [`Meteor.subscribe`](#meteor_subscribe), if any. * @locus Server * @memberOf Subscription * @instance */ ready(): void; }