export = queueConstructorProxy; /** * @param {string} url * @param {QueueConstructorOptions} options * @returns {Queue} */ declare function queueConstructorProxy(url: string, options?: QueueConstructorOptions): Queue; declare namespace queueConstructorProxy { export { query, callback, Queue as class, QueueConstructorOptions, QueueMessageBody, SQSQueueOptions }; } type QueueConstructorOptions = { sqs?: typeof import("@aws-sdk/client-sqs"); messageAttributes?: any; }; /** * @typedef {{ * sqs?: import('@aws-sdk/client-sqs'), * messageAttributes?: any * }} QueueConstructorOptions */ /** * We should be able to type this with something like Record, but for some reason * that is getting converted to the literal type {} in the language server (the emitted type is fine). * This causes type errors because you can't assign any properties to the literal type {}. * * When we move to Typescript, this shouldn't be an issue. * @typedef {any} QueueMessageBody */ /** * @typedef {{ messageAttributes?: any, groupID?: null|string }} SQSQueueOptions */ /** * Class represent a SQS queueSQS */ declare class Queue { /** * * @param {Object || Array} obj Object, array, string, or number to pascalCase * @returns PascalCase object * @static * @description Recursive function that loops through a array or object and pascalCases the value. Useful for standardizing message formats between Lambda and containers. */ static standardizeMessage(obj: any): any; static paramsOptions(args: any): { params: any; options: any; }; static messagesParamsOptions(args: any): { messages: any; params: any; options: any; }; /** * * @param {Object} attribute Object contains key/values that should be converted into message attributes * @returns {Object} Returns a SQS formatted message attribute object that can be used when sending SQS messages * @description Converts key/value object into a SQS message attribute object * @static */ static toMessageAttribute(attribute: any): any; /** * * @param {Object} attribute SQS MessageAttribute formatted object * @returns {Object} Returns key/value MessageAttributes * @description Converts a SQS formatted MessageAttribute object into a normal key/value object * @static */ static fromMessageAttribute(attribute: any): any; /** * Sets up a verbose logger with metadata about the message. * @param {Object} message The SQS message object. * @returns {Object} A logger instance with metadata. */ static verboseLogger(message: any): any; /** * @param {Object} event Lambda SQS event * @param {Function} handler Async function to use for processing messages * @description Takes a Lambda SQS event and processes them using a provided handler functions */ static lambdaGet(event: any, handler: Function): Promise; /** * Create a class * @param {string} url The URL endpoint (including protocols) of the SQS queue * @param {QueueConstructorOptions} [options] Optional SQS options. */ constructor(url: string, options?: QueueConstructorOptions); queueUrl: string; batchSize: any; messageAttributes: any; fifo: boolean; sqs: typeof import("@aws-sdk/client-sqs") | SQSClient; /** * @throws Error if SQS class was initialized incorrectly * @description Checks that the class was initialized correctly. * @private */ private _validate; /** * * @returns {Promise} Returns the approximate number of message on the queue * @description Retrieves the approximate number of message on the queue * @async * @public */ public size(): Promise; /** * @template {QueueMessageBody} T * @param {String} callback The callback URL endpoint (including protocols) * @param {T|Array} messages single object or array of single and object to make messages from. * @param {SQSQueueOptions & { timeout?: number}} options Optional configuration * @returns {Promise>} Returns an array of successfully sent messages. * @description Puts a callback message on a EZQ. EZQ will callback the provided URL when the message is processed. * @async * @public */ public callback(callback: string, messages?: T | T[], options?: SQSQueueOptions & { timeout?: number; }): Promise; /** * @template {QueueMessageBody} T * @param {T|Array} messages Single string, array of strings, or array of arrays * @param {Array} [params] Array of values to escape * @param {SQSQueueOptions} options Optional configuration * @returns {Promise>}Returns an array of successfully sent messages. * @description Puts a MySQL query on a EZQ * @async * @public */ public query(...args: any[]): Promise; /** * @template {QueueMessageBody} T * @param {T|Array} messages single, object or array of single and object to make messages from. * @param {SQSQueueOptions}options Optional configuration * @returns {Promise>} Returns an array of successfully sent messages. * @async * @public */ public put(messages: T_2 | T_2[], options?: SQSQueueOptions): Promise; /** * @template {QueueMessageBody} T * @param {Array} failedMessages Array of failed messages that is accumulated over each recursive iteration * @param {Array} successfulMessages Array of success messages that is accumulated over each recursive iteration * @param {Array} messages Array of messages to send * @param {number} startIndex The starting index * @param {any} messageAttributes Object containing messageAttributes * @return {Promise>} A list of the messages that were succesfully queued. * @async * @private */ private _sendBatch; /** * * @param {String || Object} Message String or object to make into a SQS message * @param {Object} [messageAttributes] Object contain message attributes to pu on the message * @description Creates a SQS formatted message from a single string or object. * @returns {Object} Formatted message object made from a single string value or object */ toEntry(message: any, messageAttributes?: any, groupID?: any): any; /** * @description Purges all message from the queue. Purge has a 60 second cool down. * @returns {Promise} Promise that resolve when the queue is purged * @async */ purge(): Promise; /** * @description Initializes the loggerMap and bidirectionalMessageMetadataMap for the instance. */ _initializeLoggerMap(): void; loggerMap: Map; bidirectionalMessageMetadataMap: Map; /** * @description Updates the loggerMap and bidirectionalMessageMetadataMap with new messages. * @param {Array} messages The array of SQS messages. */ _updateLoggerAndMetadataMaps(messages: any[]): void; /** * @description Retrieves the logger for a given messageId or receiptHandle. * @param {string} key The messageId or receiptHandle. * @returns {Object} The logger instance for the given key. */ _getLogger(key: string): any; /** * @param {Object} [event] Lambda SQS event * @param {Function} [handler] Async function to use for processing messages * @param {Object} [options] Valid SQS receiveMessage params * @param {Boolean} [options.poll=true] Continuously poll for new messages * @description Takes either Lambda SQS event and a async handler OR a async handler and a optional options object. Depending of type of arguments passed, * different get logic will be used. This allows for support for Lambda and containers. */ get(...args: any[]): Promise; /** * @param {String} receiptHandle The receipt handle of the message to delete * @description Deletes a message from the queue given a receipt handle * @returns {Promise} Promise that resolves when the message is deleted * @async * @private * @throws Error if the message cannot be deleted */ private _deleteMessage; /** * @param {Array} receiptHandles The receipt handles of the messages to delete * @description Deletes multiple messages from the queue given their receipt handles * @returns {Promise} Promise that resolves when the messages are deleted * @async * @private * @throws Error if the messages cannot be deleted */ private _deleteMessages; /** * @param {String} receiptHandle The receipt handle of the message to requeue * @description Requeues a message from the queue given a receipt handle * @returns {Promise} Promise that resolves when the message is requeued * @async * @private * @throws Error if the message cannot be requeued */ private _requeueMessage; /** * @param {Array} receiptHandles The receipt handles of the messages to requeue * @description Requeues multiple messages from the queue given their receipt handles * @returns {Promise} Promise that resolves when the messages are requeued * @async * @private * @throws Error if the messages cannot be requeued */ private _requeueMessages; /** * * @param {Function} handler Async function to use for processing messages * @param {Object} [options] Valid SQS receiveMessage params * @param {Boolean} [options.poll=true] Continuously poll for new messages * @description Pull messages from SQS and process them using a provided handler functions */ _containerGet(handler: Function, options?: { poll?: boolean; }): Promise; /** * @param {Function} handler Async function to use for processing messages * @param {Object} [options] Valid SQS receiveMessage params * @returns {Promise} * @async * @description Process multiple SQS messages in a single handler invocation. Can either handle all messages received from a single Poll in a single handler invocation * or process messages in parallel using the maxHandlerBatchSize option. */ batchGet(handler: Function, options?: any): Promise; } /** * @param {string|string[]} messages One or more queries to run * @param {Array} [params] A list of bind parameters to pass to the prepared statement * @param {SQSQueueOptions} [options] * @returns */ declare function query(messages?: string | string[], params?: Array>, options?: SQSQueueOptions): Promise; /** * @param {string} callback URL to send the differed call to. * @param {any} [messages] Content of HTTP body when callback is made * @param {SQSQueueOptions} [options] * @returns {Promise} */ declare function callback(callback: string, messages?: any, options?: SQSQueueOptions): Promise; /** * We should be able to type this with something like Record, but for some reason * that is getting converted to the literal type {} in the language server (the emitted type is fine). * This causes type errors because you can't assign any properties to the literal type {}. * * When we move to Typescript, this shouldn't be an issue. */ type QueueMessageBody = any; type SQSQueueOptions = { messageAttributes?: any; groupID?: null | string; }; import { SQSClient } from "@aws-sdk/client-sqs/dist-types/SQSClient"; //# sourceMappingURL=index.d.ts.map