import { MethodInvocation } from "./method-invocation"; import { StreamServerSocket } from "./stream_server"; import { DDPSession, SessionConnectionHandle } from "./session"; import { Server } from "http"; import { Hook } from "../callback-hook/hook"; import { Subscription } from "./subscription"; export declare const DDP: { _CurrentPublicationInvocation: Subscription; _CurrentMethodInvocation: MethodInvocation; }; /******************************************************************************/ /******************************************************************************/ interface PublicationStrategy { useCollectionView: boolean; doAccountingForCollection: boolean; } export declare class DDPServer { private options; private onConnectionHook; onMessageHook: Hook; private publish_handlers; universal_publish_handlers: any[]; private method_handlers; private _publicationStrategies; private sessions; private stream_server; constructor(options: {}, httpServer: Server); static publicationStrategies: { SERVER_MERGE: { useCollectionView: boolean; doAccountingForCollection: boolean; }; NO_MERGE_NO_HISTORY: { useCollectionView: boolean; doAccountingForCollection: boolean; }; NO_MERGE: { useCollectionView: boolean; doAccountingForCollection: boolean; }; }; /** * @summary Register a callback to be called when a new DDP connection is made to the server. * @locus Server * @param {function} callback The function to call when a new DDP connection is established. * @memberOf Meteor * @importFromPackage meteor */ onConnection(fn: (conn: SessionConnectionHandle) => void): { callback: any; stop: () => void; }; /** * @summary Set publication strategy for the given publication. Publications strategies are available from `DDPServer.publicationStrategies`. You call this method from `Meteor.server`, like `Meteor.server.setPublicationStrategy()` * @locus Server * @alias setPublicationStrategy * @param publicationName {String} * @param strategy {{useCollectionView: boolean, doAccountingForCollection: boolean}} * @memberOf Meteor.server * @importFromPackage meteor */ setPublicationStrategy(publicationName: string, strategy: PublicationStrategy): void; /** * @summary Gets the publication strategy for the requested publication. You call this method from `Meteor.server`, like `Meteor.server.getPublicationStrategy()` * @locus Server * @alias getPublicationStrategy * @param publicationName {String} * @memberOf Meteor.server * @importFromPackage meteor * @return {{useCollectionView: boolean, doAccountingForCollection: boolean}} */ getPublicationStrategy(publicationName: string): PublicationStrategy; /** * @summary Register a callback to be called when a new DDP message is received. * @locus Server * @param {function} callback The function to call when a new DDP message is received. * @memberOf Meteor * @importFromPackage meteor */ onMessage(fn: any): { callback: any; stop: () => void; }; _handleConnect(socket: StreamServerSocket, msg: any): void; /** * Register a publish handler function. * * @param name {String} identifier for query * @param handler {Function} publish handler * * Server will call handler function on each new subscription, * either when receiving DDP sub message for a named subscription, or on * DDP connect for a universal subscription. * * If name is null, this will be a subscription that is * automatically established and permanently on for all connected * client, instead of a subscription that can be turned on and off * with subscribe(). * */ /** * @summary Publish a record set. * @memberOf Meteor * @importFromPackage meteor * @locus Server * @param {String|Object} name If String, name of the record set. If Object, publications Dictionary of publish functions by name. If `null`, the set has no name, and the record set is automatically sent to all connected clients. * @param {Function} func Function called on the server each time a client subscribes. Inside the function, `this` is the publish handler object, described below. If the client passed arguments to `subscribe`, the function is called with the same arguments. */ publish(name: string | Record Promise> | null, handler?: (this: MethodInvocation, ...args: any[]) => Promise): void; _removeSession(session: DDPSession): void; /** * @summary Defines functions that can be invoked over the network by clients. * @locus Anywhere * @param {Object} methods Dictionary whose keys are method names and values are functions. * @memberOf Meteor * @importFromPackage meteor */ methods(methods: Record Promise>): void; callAsync(name: string, ...args: any[]): Promise; applyAsync(name: string, args: any[]): Promise; _urlForSession(sessionId: any): string; } export declare function _calculateVersion(clientSupportedVersions: any, serverSupportedVersions: any): any; export declare function wrapInternalException(exception: any, context: string): any; export declare function maybeAuditArgumentChecks(f: (...args: any[]) => T, context: any, args: any[] | null, description: string): T; export declare function ddpError(error: string | number, reason?: string, details?: string): { isClientSafe: boolean; error: string | number; reason: string; message: string; errorType: string; }; export declare class ClientSafeError extends Error { error: string | number; reason?: string; details?: string; constructor(error: string | number, reason?: string, details?: string); isClientSafe: boolean; errorType: string; } export {};