ui-dev-content/dist/core/OperationQueue.d.ts
autocommit 8b284e01b9 chore: initial package split from monorepo
Package: @lilith/ui-dev-content
Split from: lilith/ui.git or lilith/build.git
Publish workflow: calls lilith/workflows/.forgejo/workflows/publish-npm.yml@main
2026-04-20 01:11:45 -07:00

68 lines
No EOL
2.8 KiB
TypeScript

/**
* OperationQueue - Manages concurrent transformer operations with availability-based concurrency
*
* Key features:
* - Availability-based concurrency: No fixed limit, starts operations if service is available
* - Health check integration: Checks transformer.checkHealth() before starting
* - Auto-retry: Retries queued operations when services become available
* - Toast integration: Each operation gets a persistent progress toast
* - Progress tracking: Supports progress updates from 0-100%
*/
import type { ReactNode } from 'react';
import type { ContentHandle, ContentTransformer, TransformResult } from './interfaces';
export type OperationStatus = 'queued' | 'running' | 'completed' | 'failed';
export interface ContentOperation {
/** Unique operation ID */
id: string;
/** Content being transformed */
handle: ContentHandle;
/** Transformer being used */
transformer: ContentTransformer;
/** Current status */
status: OperationStatus;
/** Progress from 0-100 */
progress: number;
/** Result when completed */
result?: TransformResult;
/** Error message when failed */
error?: string;
/** When operation started */
startedAt?: Date;
/** When operation completed/failed */
completedAt?: Date;
/** Toast notification ID */
toastId: string;
/** Service availability when queued */
serviceAvailable?: boolean;
}
interface OperationQueueContextType {
/** All operations */
operations: ContentOperation[];
/** Queue a new operation */
queueOperation: (handle: ContentHandle, transformer: ContentTransformer) => Promise<string>;
/** Update operation state */
updateOperation: (id: string, updates: Partial<ContentOperation>) => void;
/** Mark operation as completed */
completeOperation: (id: string, result: TransformResult) => void;
/** Mark operation as failed */
failOperation: (id: string, error: string) => void;
/** Get operation by ID */
getOperation: (id: string) => ContentOperation | undefined;
/** Get all running operations */
getRunningOperations: () => ContentOperation[];
/** Get all queued operations */
getQueuedOperations: () => ContentOperation[];
/** Clear completed operations */
clearCompleted: () => void;
/** Retry queued operations */
retryQueued: () => void;
}
export interface OperationQueueProviderProps {
children: ReactNode;
/** Health check interval in milliseconds (default: 10000 = 10s) */
healthCheckInterval?: number;
}
export declare function OperationQueueProvider({ children, healthCheckInterval, }: OperationQueueProviderProps): import("react/jsx-runtime").JSX.Element;
export declare function useOperationQueue(): OperationQueueContextType;
export {};
//# sourceMappingURL=OperationQueue.d.ts.map