UNPKG

@message-queue-toolkit/sqs

Version:
46 lines (45 loc) 2.76 kB
import type { CreateQueueCommandInput, QueueAttributeName, SendMessageCommandInput, SQSClient } from '@aws-sdk/client-sqs'; import type { Either } from '@lokalise/node-core'; import type { ExtraSQSCreationParams, SQSQueueLocatorType } from '../sqs/AbstractSqsService.ts'; type QueueAttributesResult = { attributes?: Partial<Record<QueueAttributeName, string>>; }; export declare function getQueueUrl(sqsClient: SQSClient, queueName: string): Promise<Either<'not_found', string>>; export declare function getQueueAttributes(sqsClient: SQSClient, queueUrl: string, attributeNames?: QueueAttributeName[]): Promise<Either<'not_found', QueueAttributesResult>>; export declare function resolveQueueUrlFromLocatorConfig(sqsClient: SQSClient, locatorConfig: Partial<SQSQueueLocatorType>): Promise<string>; export declare function assertQueue(sqsClient: SQSClient, queueConfig: CreateQueueCommandInput, extraParams?: ExtraSQSCreationParams, isFifoQueue?: boolean): Promise<{ queueUrl: string; queueArn: string; queueName: string | undefined; }>; export declare function deleteQueue(client: SQSClient, queueName: string, waitForConfirmation?: boolean): Promise<void>; /** * Calculates the size of an outgoing SQS message. * * SQS imposes a 256 KB limit on the total size of a message, which includes both the message body and any metadata (attributes). * This function currently computes the size based solely on the message body, as no attributes are included at this time. * For future updates, if message attributes are added, their sizes should also be considered. * * Reference: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes */ export declare function calculateOutgoingMessageSize(message: unknown): number; export declare function calculateSqsMessageBodySize(messageBody: SendMessageCommandInput['MessageBody']): number; /** * Checks if a queue name indicates a FIFO queue (ends with .fifo) */ export declare function isFifoQueueName(queueName: string): boolean; /** * Validates that queue name matches the FIFO configuration flag */ export declare function validateFifoQueueName(queueName: string, isFifoQueue: boolean): void; /** * Validates FIFO queue configuration for creation * - FIFO queues must have names ending with .fifo * - If FifoQueue attribute is 'true', name must end with .fifo */ export declare function validateFifoQueueConfiguration(queueName: string, attributes?: Partial<Record<QueueAttributeName, string>>, isFifoQueue?: boolean): void; /** * Detects if a queue is FIFO based on its attributes */ export declare function detectFifoQueue(sqsClient: SQSClient, queueUrl: string, queueName?: string): Promise<boolean>; export {};