import { TypeDaprPubSubCallback } from "../types/DaprPubSubCallback.type"; import { PubSubSubscriptionOptionsType } from "../types/pubsub/PubSubSubscriptionOptions.type"; import { PubSubSubscriptionTopicType } from "../types/pubsub/PubSubSubscriptionTopic.type"; import { PubSubSubscriptionsType } from "../types/pubsub/PubSubSubscriptions.type"; /** * SubscriptionManager manages server-side storage and lookup of subscriptions. */ export declare class SubscriptionManager { private readonly subscriptions; /** * Check if pubsub is registered. * @param pubsub name of the pubsub component * @returns true if the pubsub is registered */ isPubSubRegistered(pubsub: string): boolean; /** * Check if pubsub and topic are registered. * @param pubsub name of the pubsub component * @param topic name of the topic * @returns true if the pubsub and topic are registered */ isTopicRegistered(pubsub: string, topic: string): boolean; /** * Get the subscription for a given pubsub and topic. * @param pubsub name of the pubsub component * @param topic name of the topic * @returns the subscription for the given pubsub and topic */ getSubscription(pubsub: string, topic: string): PubSubSubscriptionTopicType; /** * Get all registered pubsubs. * @returns all registered pubsubs */ getRegisteredPubSubs(): string[]; /** * Get all registered topics for a given pubsub. * @param pubsub name of the pubsub component * @returns all registered topics for the given pubsub */ getRegisteredTopics(pubsub: string): string[]; /** * Register a new subscription for a given pubsub and topic. * @param pubsub name of the pubsub component * @param topic name of the topic */ registerSubscription(pubsub: string, topic: string, options?: PubSubSubscriptionOptionsType): void; /** * Add an event handler to an existing subscription. * @param pubsub name of the pubsub component * @param topic name of the topic * @param route name of the route * @param handler callback to be called when an event is received */ addEventHandlerToSubscription(pubsub: string, topic: string, handler: TypeDaprPubSubCallback, route?: string): void; /** * Lookup the topic and route for a given pubsub, topic (with wildcard support) and path. * If not found, topic is empty. * @param pubsub name of the pubsub component * @param topic name of the topic * @param path path from the event * @returns the topic and route */ lookupTopicWildcard(pubsub: string, topic: string, path: string): [string, string]; /** * Get all subscriptions, used for testing. * @returns all subscriptions. */ getSubscriptions(): PubSubSubscriptionsType; /** * Get the route part from the path. * @param pubsub name of the pubsub component * @param topic name of the topic * @param path path from the event * @returns the route */ private getRouteFromPath; /** * Sanitize the HTTP path. * Replaces special characters with dashes. * @param path path to sanitize */ private sanitizeHttpPath; /** * getMatchingTopic returns the topic that matches the provided topic. * If no topic matches, an empty string is returned. * Note that the pubsub might be subscribed to wildcard topics with identifiers like `#` or `+`. * @param pubsub name of the pubsub component * @param topic name of the topic */ private getMatchingTopic; /** * Get the sanitized route with the default route if not specified. * @param route optional route * @param defaultRoute default route if not specified * @returns the sanitized route */ private getSanitizedRouteWithDefault; /** * Generate the path for a given pubsub, topic and route. * @param pubsub name of the pubsub component * @param topic name of the topic * @param route optional route if explicitly specified in the subscription */ private generatePubSubPath; /** * Generate routes for a given topic in a pubsub using the subscription options. * @param pubsub name of the pubsub component * @param topic name of the topic * @param options subscription options */ private generateRoutes; /** * Generate the subscription object queried by the Dapr sidecar on startup. * This is used to inform the Dapr sidecar of the subscriptions and how to route events. * * Important: we internally translate the provided /example to -> /--example * or if empty to /--default * this is to ensure that HTTP Server endpoints are unique. * @param pubsub name of the pubsub component * @param topic name of the topic * @param options subscription options */ private generateDaprSubscription; }