import type { PubSub, Subscription, Topic } from '@google-cloud/pubsub'; import type { DeletionConfig } from '@message-queue-toolkit/core'; import type { PubSubCreationConfig, PubSubQueueLocatorType } from '../pubsub/AbstractPubSubService.ts'; export type PubSubInitResult = { topicName: string; topic: Topic; subscriptionName?: string; subscription?: Subscription; dlqTopicName?: string; dlqTopic?: Topic; }; export type PubSubDeadLetterQueueConfig = { deadLetterPolicy: { maxDeliveryAttempts: number; }; creationConfig?: { topic: { name: string; }; }; locatorConfig?: { topicName: string; }; }; /** * Initializes Pub/Sub resources (topics and subscriptions). * * Config precedence: * - If both locatorConfig and creationConfig are provided, an error is thrown * - locatorConfig: Locates existing resources and fails if they don't exist (production-safe) * - creationConfig: Creates resources if they don't exist, or uses existing ones (dev-friendly) * * The updateAttributesIfExists flag (creationConfig only): * - When true and resources already exist, their attributes/metadata will be updated via setMetadata() * - When false (default), existing resources are used as-is without updates * - Applies to both topics and subscriptions * - Useful for updating resource configurations without manual intervention * - Example use cases: updating retention policies, ack deadlines, or dead letter policies * * Dead Letter Queue configuration: * - Optional deadLetterQueueConfig parameter enables DLQ support for subscriptions * - Can use either locatorConfig (locate existing DLQ topic) or creationConfig (create if missing) * - Automatically configures the subscription's deadLetterPolicy with the DLQ topic ARN * - maxDeliveryAttempts determines how many times a message is retried before moving to DLQ */ export declare function initPubSub(pubSubClient: PubSub, locatorConfig?: PubSubQueueLocatorType, creationConfig?: PubSubCreationConfig, deadLetterQueueConfig?: PubSubDeadLetterQueueConfig): Promise; export type PubSubDeletionOptions = { /** * When true, only deletes the subscription without deleting the topic. * Use this for consumers to avoid deleting shared topics. * Default: false (deletes both subscription and topic) */ deleteSubscriptionOnly?: boolean; }; /** * Deletes Pub/Sub resources (topics and subscriptions). * * Deletion behavior: * - Only deletes if deletionConfig.deleteIfExists is true and creationConfig is provided * - Checks forceDeleteInProduction flag to prevent accidental deletion in production environments * - If deleteSubscriptionOnly is true, only the subscription is deleted (safe for consumers) * - If deleteSubscriptionOnly is false (default), deletes subscription first, then topic * - If waitForConfirmation is true (default), polls to confirm resources are actually deleted * using the core waitAndRetry utility (similar to SQS implementation) */ export declare function deletePubSub(pubSubClient: PubSub, deletionConfig: DeletionConfig, creationConfig?: PubSubCreationConfig, options?: PubSubDeletionOptions): Promise;