/** * Input validation utilities for FlashQ client. * * Provides validation functions for queue names, job data sizes, * and batch operation limits. */ import type { PushOptions } from '../types'; /** Maximum allowed job data size in bytes (1MB) */ export declare const MAX_JOB_DATA_SIZE: number; /** Maximum number of jobs per batch operation */ export declare const MAX_BATCH_SIZE = 1000; /** * Validates a queue name against naming rules. * * Queue names must: * - Be non-empty strings * - Contain only alphanumeric characters, underscores, hyphens, or dots * - Be between 1 and 256 characters long * * @param queue - The queue name to validate * @throws ValidationError if the queue name is invalid * * @example * ```typescript * validateQueueName('my-queue'); // OK * validateQueueName('queue.name'); // OK * validateQueueName('queue name'); // Throws: contains space * validateQueueName(''); // Throws: empty * ``` */ export declare function validateQueueName(queue: string): void; /** * Validates that job data does not exceed the maximum allowed size. * * The size is calculated by JSON-stringifying the data and measuring * the resulting string length in bytes. * * @param data - The job data to validate * @throws ValidationError if the data exceeds MAX_JOB_DATA_SIZE * * @example * ```typescript * validateJobDataSize({ small: 'data' }); // OK * validateJobDataSize(largeBuffer); // Throws if > 1MB * ``` */ export declare function validateJobDataSize(data: unknown): void; /** * Validates batch operation size. * * @param count - Number of items in the batch * @param operation - Name of the operation for error messages * @throws ValidationError if count exceeds MAX_BATCH_SIZE * * @example * ```typescript * validateBatchSize(100, 'push'); // OK * validateBatchSize(1500, 'push'); // Throws: exceeds 1000 * ``` */ export declare function validateBatchSize(count: number, operation: string): void; /** * Validates a job ID is a positive integer. * * @param jobId - The job ID to validate * @throws ValidationError if jobId is not a positive integer */ export declare function validateJobId(jobId: number): void; /** * Validates a timeout value is within acceptable bounds. * * @param timeout - Timeout in milliseconds * @param min - Minimum allowed value (default: 0) * @param max - Maximum allowed value (default: 10 minutes) * @throws ValidationError if timeout is out of bounds */ export declare function validateTimeout(timeout: number, min?: number, max?: number): void; /** * Server-side job payload structure. * This is the format expected by the flashQ server. */ export interface JobPayload { data: T; priority: number; delay?: number; ttl?: number; timeout?: number; max_attempts?: number; backoff?: number; unique_key?: string; depends_on?: number[]; tags?: string[]; lifo: boolean; remove_on_complete: boolean; remove_on_fail: boolean; stall_timeout?: number; debounce_id?: string; debounce_ttl?: number; job_id?: string; keep_completed_age?: number; keep_completed_count?: number; group_id?: string; } /** * Maps PushOptions to server payload format. * * This is the single source of truth for option-to-payload mapping, * eliminating duplication across push, pushBatch, and pushBatchSafe. * * @param data - Job data payload * @param options - Push options * @returns Server-compatible job payload * * @example * ```typescript * const payload = mapJobToPayload({ email: 'test@example.com' }, { priority: 10 }); * ``` */ export declare function mapJobToPayload(data: T, options?: PushOptions): JobPayload; //# sourceMappingURL=validation.d.ts.map