UNPKG

@clipwhisperer/common

Version:

ClipWhisperer Common - Shared library providing core utilities, database schemas, authentication, bucket management, and common functionality across all ClipWhisperer microservices

264 lines (263 loc) 7.26 kB
/** * Standardized Response Schemas * Common response patterns used across all services */ import { z } from "zod"; /** * Standard success response */ export declare const successResponseSchema: z.ZodObject<{ success: z.ZodDefault<z.ZodBoolean>; message: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { message?: string; timestamp?: string; success?: boolean; }, { message?: string; timestamp?: string; success?: boolean; }>; /** * Standard error response */ export declare const errorResponseSchema: z.ZodObject<{ success: z.ZodDefault<z.ZodBoolean>; error: z.ZodString; message: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { message?: string; error?: string; timestamp?: string; success?: boolean; }, { message?: string; error?: string; timestamp?: string; success?: boolean; }>; /** * Health check response */ export declare const healthResponseSchema: z.ZodObject<{ status: z.ZodEnum<["healthy", "unhealthy"]>; service: z.ZodString; version: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodString>; uptime: z.ZodOptional<z.ZodNumber>; dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<["healthy", "unhealthy"]>>>; }, "strip", z.ZodTypeAny, { status?: "healthy" | "unhealthy"; timestamp?: string; service?: string; version?: string; uptime?: number; dependencies?: Record<string, "healthy" | "unhealthy">; }, { status?: "healthy" | "unhealthy"; timestamp?: string; service?: string; version?: string; uptime?: number; dependencies?: Record<string, "healthy" | "unhealthy">; }>; /** * Job response (for queue operations) */ export declare const jobResponseSchema: z.ZodObject<{ jobId: z.ZodString; status: z.ZodOptional<z.ZodEnum<["queued", "processing", "completed", "failed"]>>; message: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { message?: string; status?: "completed" | "failed" | "queued" | "processing"; timestamp?: string; jobId?: string; }, { message?: string; status?: "completed" | "failed" | "queued" | "processing"; timestamp?: string; jobId?: string; }>; /** * Metadata response wrapper */ export declare const metadataResponseSchema: z.ZodObject<{ success: z.ZodBoolean; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; error: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { error?: string; metadata?: Record<string, any>; timestamp?: string; success?: boolean; }, { error?: string; metadata?: Record<string, any>; timestamp?: string; success?: boolean; }>; /** * Performance metrics response */ export declare const performanceMetricsResponseSchema: z.ZodObject<{ totalRequests: z.ZodNumber; averageResponseTime: z.ZodNumber; successRate: z.ZodNumber; queueSize: z.ZodNumber; memoryUsage: z.ZodObject<{ rss: z.ZodNumber; heapTotal: z.ZodNumber; heapUsed: z.ZodNumber; external: z.ZodNumber; arrayBuffers: z.ZodNumber; }, "strip", z.ZodTypeAny, { rss?: number; heapTotal?: number; heapUsed?: number; external?: number; arrayBuffers?: number; }, { rss?: number; heapTotal?: number; heapUsed?: number; external?: number; arrayBuffers?: number; }>; uptime: z.ZodNumber; timestamp: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { timestamp?: string; uptime?: number; totalRequests?: number; averageResponseTime?: number; successRate?: number; queueSize?: number; memoryUsage?: { rss?: number; heapTotal?: number; heapUsed?: number; external?: number; arrayBuffers?: number; }; }, { timestamp?: string; uptime?: number; totalRequests?: number; averageResponseTime?: number; successRate?: number; queueSize?: number; memoryUsage?: { rss?: number; heapTotal?: number; heapUsed?: number; external?: number; arrayBuffers?: number; }; }>; /** * Workflow status response */ export declare const workflowStatusResponseSchema: z.ZodObject<{ workflowId: z.ZodString; status: z.ZodEnum<["pending", "in_progress", "completed", "failed"]>; currentStep: z.ZodOptional<z.ZodString>; totalSteps: z.ZodOptional<z.ZodNumber>; progress: z.ZodOptional<z.ZodNumber>; message: z.ZodOptional<z.ZodString>; startTime: z.ZodOptional<z.ZodString>; endTime: z.ZodOptional<z.ZodString>; processingTime: z.ZodOptional<z.ZodNumber>; nextSteps: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { message?: string; status?: "pending" | "completed" | "failed" | "in_progress"; startTime?: string; endTime?: string; progress?: number; currentStep?: string; workflowId?: string; totalSteps?: number; processingTime?: number; nextSteps?: string; }, { message?: string; status?: "pending" | "completed" | "failed" | "in_progress"; startTime?: string; endTime?: string; progress?: number; currentStep?: string; workflowId?: string; totalSteps?: number; processingTime?: number; nextSteps?: string; }>; /** * File operation response */ export declare const fileOperationResponseSchema: z.ZodObject<{ success: z.ZodBoolean; filePath: z.ZodOptional<z.ZodString>; fileName: z.ZodOptional<z.ZodString>; fileSize: z.ZodOptional<z.ZodNumber>; mimeType: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; error: z.ZodOptional<z.ZodString>; timestamp: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { error?: string; url?: string; timestamp?: string; success?: boolean; fileSize?: number; filePath?: string; fileName?: string; mimeType?: string; }, { error?: string; url?: string; timestamp?: string; success?: boolean; fileSize?: number; filePath?: string; fileName?: string; mimeType?: string; }>; /** * Batch operation response */ export declare const batchOperationResponseSchema: z.ZodObject<{ success: z.ZodBoolean; processedCount: z.ZodNumber; totalCount: z.ZodNumber; successCount: z.ZodNumber; failureCount: z.ZodNumber; batchId: z.ZodOptional<z.ZodString>; errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; processingTime: z.ZodNumber; timestamp: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { timestamp?: string; totalCount?: number; success?: boolean; processingTime?: number; processedCount?: number; successCount?: number; failureCount?: number; batchId?: string; errors?: string[]; }, { timestamp?: string; totalCount?: number; success?: boolean; processingTime?: number; processedCount?: number; successCount?: number; failureCount?: number; batchId?: string; errors?: string[]; }>;