kernel-script 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lock +1 -8
- package/dist/core/bootstrap/broadcast.d.ts +5 -0
- package/dist/core/bootstrap/command-handler.d.ts +39 -0
- package/dist/core/bootstrap/heartbeat.d.ts +1 -0
- package/dist/core/bootstrap/index.d.ts +6 -0
- package/dist/core/bootstrap/message-handler.d.ts +6 -0
- package/dist/core/bootstrap.d.ts +5 -1
- package/dist/core/engine-hub.d.ts +1 -1
- package/dist/core/helper.d.ts +1 -1
- package/dist/core/hooks/use-queue.d.ts +4 -3
- package/dist/core/persistence-manager.d.ts +2 -2
- package/dist/core/queue/index.d.ts +5 -0
- package/dist/core/queue/persistence.d.ts +14 -0
- package/dist/core/queue/queue-manager.d.ts +59 -0
- package/dist/core/queue/queue-state.d.ts +13 -0
- package/dist/core/queue/task-executor.d.ts +16 -0
- package/dist/core/queue-manager.d.ts +8 -4
- package/dist/core/registry.d.ts +1 -1
- package/dist/core/store/base-task.store.d.ts +4 -7
- package/dist/core/task-context.d.ts +1 -1
- package/dist/core/types/index.d.ts +48 -0
- package/dist/index.cjs +312 -1892
- package/dist/index.d.ts +5 -6
- package/dist/index.js +307 -1434
- package/package.json +4 -5
package/bun.lock
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
"name": "ts-lib-boilerplate",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"p-queue": "^9.1.2",
|
|
8
|
-
"sonner": "^2.0.7",
|
|
9
|
-
"zustand": "^5.0.12",
|
|
10
8
|
},
|
|
11
9
|
"devDependencies": {
|
|
12
10
|
"@types/bun": "latest",
|
|
@@ -22,6 +20,7 @@
|
|
|
22
20
|
},
|
|
23
21
|
"peerDependencies": {
|
|
24
22
|
"react": "^19.2.5",
|
|
23
|
+
"zustand": "^5.0.12",
|
|
25
24
|
},
|
|
26
25
|
},
|
|
27
26
|
},
|
|
@@ -322,22 +321,16 @@
|
|
|
322
321
|
|
|
323
322
|
"react": ["react@19.2.5", "", {}, "sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA=="],
|
|
324
323
|
|
|
325
|
-
"react-dom": ["react-dom@19.2.5", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.5" } }, "sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag=="],
|
|
326
|
-
|
|
327
324
|
"readdirp": ["readdirp@5.0.0", "", {}, "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ=="],
|
|
328
325
|
|
|
329
326
|
"resolve-from": ["resolve-from@4.0.0", "", {}, "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g=="],
|
|
330
327
|
|
|
331
|
-
"scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
|
332
|
-
|
|
333
328
|
"semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
|
|
334
329
|
|
|
335
330
|
"shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
|
|
336
331
|
|
|
337
332
|
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
|
338
333
|
|
|
339
|
-
"sonner": ["sonner@2.0.7", "", { "peerDependencies": { "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" } }, "sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w=="],
|
|
340
|
-
|
|
341
334
|
"strip-json-comments": ["strip-json-comments@3.1.1", "", {}, "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig=="],
|
|
342
335
|
|
|
343
336
|
"supports-color": ["supports-color@7.2.0", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { QueueManager } from './../queue-manager';
|
|
2
|
+
export interface CommandPayload {
|
|
3
|
+
command: string;
|
|
4
|
+
keycard: string;
|
|
5
|
+
identifier?: string;
|
|
6
|
+
payload: {
|
|
7
|
+
task?: any;
|
|
8
|
+
tasks?: any[];
|
|
9
|
+
taskId?: string;
|
|
10
|
+
taskIds?: string[];
|
|
11
|
+
taskConfig?: any;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface CommandHandlerDeps {
|
|
15
|
+
queueManager: QueueManager;
|
|
16
|
+
debug: boolean;
|
|
17
|
+
debugLog: (...args: unknown[]) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const createCommandHandler: ({ queueManager, debug, debugLog }: CommandHandlerDeps) => (message: CommandPayload) => Promise<import("@/core/queue-manager").QueueStatus | {
|
|
20
|
+
tasks: import("../types").Task[];
|
|
21
|
+
status: import("@/core/queue-manager").QueueStatus;
|
|
22
|
+
async?: undefined;
|
|
23
|
+
success?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
async: boolean;
|
|
26
|
+
tasks?: undefined;
|
|
27
|
+
status?: undefined;
|
|
28
|
+
success?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
tasks: import("../types").Task[];
|
|
31
|
+
status?: undefined;
|
|
32
|
+
async?: undefined;
|
|
33
|
+
success?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
success: boolean;
|
|
36
|
+
tasks?: undefined;
|
|
37
|
+
status?: undefined;
|
|
38
|
+
async?: undefined;
|
|
39
|
+
} | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createHeartbeatHandler: () => (count: number) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandHandlerDeps } from './command-handler';
|
|
2
|
+
export interface MessageHandlerDeps extends CommandHandlerDeps {
|
|
3
|
+
broadcast: (message: any) => void;
|
|
4
|
+
handleHeartbeat: (count: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const createMessageHandler: ({ queueManager, debug, debugLog, broadcast, handleHeartbeat, }: MessageHandlerDeps) => (message: any, _sender: any, sendResponse: (response?: any) => void) => true | undefined;
|
package/dist/core/bootstrap.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { BaseEngine } from './types/engine';
|
|
2
|
-
export
|
|
2
|
+
export interface SetupOptions {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
storageKey?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const setupBackgroundEngine: (engines: Record<string, BaseEngine>, options?: SetupOptions) => void;
|
package/dist/core/helper.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const sleep: (seconds: number, signal?: AbortSignal) => Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Task, TaskConfig } from './../types
|
|
1
|
+
import type { Task, TaskConfig } from './../types';
|
|
2
2
|
interface Funcs {
|
|
3
3
|
getTasks: () => Task[];
|
|
4
4
|
setTasks: (tasks: Task[]) => void;
|
|
5
5
|
setPendingCount: (count: number) => void;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
setIsRunning: (running: boolean) => void;
|
|
7
|
+
getIsRunning: () => boolean;
|
|
8
8
|
updateTask: (taskId: string, updates: Partial<Task>) => void;
|
|
9
9
|
deleteTasks: (taskIds: string[]) => void;
|
|
10
10
|
updateTasks: (updates: Record<string, Partial<Task>>) => void;
|
|
@@ -15,6 +15,7 @@ export interface QueueHookConfig {
|
|
|
15
15
|
keycard: string;
|
|
16
16
|
getIdentifier: () => string | undefined;
|
|
17
17
|
funcs: Funcs;
|
|
18
|
+
debug?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export declare function useQueue(config: QueueHookConfig): () => {
|
|
20
21
|
addTask: (task: Task) => Promise<unknown>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface SerializedQueueState {
|
|
2
|
-
isPaused: boolean;
|
|
3
2
|
isRunning: boolean;
|
|
4
3
|
}
|
|
5
4
|
export declare class PersistenceManager {
|
|
6
|
-
private
|
|
5
|
+
private storageKey;
|
|
6
|
+
constructor(storageKey?: string);
|
|
7
7
|
saveQueueStates(states: Record<string, SerializedQueueState>): Promise<void>;
|
|
8
8
|
loadQueueStates(): Promise<Record<string, SerializedQueueState>>;
|
|
9
9
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { TaskExecutor, type TaskExecutorDeps } from './task-executor';
|
|
2
|
+
export { QueuePersistence, type QueuePersistenceDeps } from './persistence';
|
|
3
|
+
export { getQueueManager, type QueueManager, type QueueOptions, type QueueStatus, } from './queue-manager';
|
|
4
|
+
export { TaskContext } from './../task-context';
|
|
5
|
+
export type { Task, TaskConfig, BaseEngine, EngineResult } from './../types';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SerializedQueueState } from './../persistence-manager';
|
|
2
|
+
export interface QueuePersistenceDeps {
|
|
3
|
+
storageKey?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class QueuePersistence {
|
|
6
|
+
private persistenceManager;
|
|
7
|
+
constructor(deps: QueuePersistenceDeps);
|
|
8
|
+
saveQueueStates(states: Record<string, SerializedQueueState>): Promise<void>;
|
|
9
|
+
loadQueueStates(): Promise<Record<string, SerializedQueueState> | null>;
|
|
10
|
+
parseQueueKey(queueKey: string): {
|
|
11
|
+
keycard: string;
|
|
12
|
+
identifier: string;
|
|
13
|
+
} | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Task, TaskConfig, BaseEngine, EngineResult } from './../types';
|
|
2
|
+
export interface QueueStatus {
|
|
3
|
+
size: number;
|
|
4
|
+
pending: number;
|
|
5
|
+
isPaused: boolean;
|
|
6
|
+
isRunning: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface QueueOptions extends Partial<TaskConfig> {
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
storageKey?: string;
|
|
11
|
+
defaultConcurrency?: number;
|
|
12
|
+
onTaskStart?: (keycard: string, identifier: string, taskId: string) => void;
|
|
13
|
+
onTaskComplete?: (keycard: string, identifier: string, taskId: string, result: EngineResult) => void;
|
|
14
|
+
onQueueEmpty?: (keycard: string, identifier: string) => void;
|
|
15
|
+
onPendingCountChange?: (keycard: string, identifier: string, count: number) => void;
|
|
16
|
+
onTasksUpdate?: (keycard: string, identifier: string, tasks: Task[], status: QueueStatus) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class QueueManager {
|
|
19
|
+
private defaultOptions;
|
|
20
|
+
private queues;
|
|
21
|
+
private platformOptions;
|
|
22
|
+
private runningQueues;
|
|
23
|
+
private concurrencyMap;
|
|
24
|
+
debug: boolean;
|
|
25
|
+
private taskExecutor;
|
|
26
|
+
private persistence;
|
|
27
|
+
constructor(defaultOptions: Partial<QueueOptions>);
|
|
28
|
+
private createTaskExecutor;
|
|
29
|
+
private debugLog;
|
|
30
|
+
private logQueueState;
|
|
31
|
+
private getQueueKey;
|
|
32
|
+
registerOptions(keycard: string, options: Partial<QueueOptions>): () => void;
|
|
33
|
+
unregisterOptions(keycard: string, options: QueueOptions): void;
|
|
34
|
+
private getOptions;
|
|
35
|
+
private getOrCreateQueue;
|
|
36
|
+
setConcurrency(keycard: string, concurrency: number): void;
|
|
37
|
+
registerEngine(keycard: string, engine: BaseEngine): void;
|
|
38
|
+
add(keycard: string, identifier: string, task: Task): Promise<void>;
|
|
39
|
+
addMany(keycard: string, identifier: string, newTasks: Task[]): Promise<void>;
|
|
40
|
+
start(keycard: string, identifier: string): Promise<void>;
|
|
41
|
+
stop(keycard: string, identifier: string): Promise<void>;
|
|
42
|
+
pause(keycard: string, identifier: string): Promise<void>;
|
|
43
|
+
resume(keycard: string, identifier: string): Promise<void>;
|
|
44
|
+
clear(keycard: string, identifier: string): Promise<void>;
|
|
45
|
+
haltTask(keycard: string, identifier: string, taskId: string): Promise<void>;
|
|
46
|
+
cancelTask(keycard: string, identifier: string, taskId: string): Promise<void>;
|
|
47
|
+
getStatus(keycard: string, identifier: string): QueueStatus;
|
|
48
|
+
getTasks(keycard: string, identifier: string): Task[];
|
|
49
|
+
private updateTasks;
|
|
50
|
+
private executeTask;
|
|
51
|
+
private autoStopQueue;
|
|
52
|
+
private notifyStatusChange;
|
|
53
|
+
private notifyTasksUpdate;
|
|
54
|
+
private persistState;
|
|
55
|
+
updateTaskConfig(keycard: string, identifier: string, taskConfig: TaskConfig): void;
|
|
56
|
+
hydrate(): Promise<void>;
|
|
57
|
+
rehydrateTasks(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export declare function getQueueManager(options?: Partial<QueueOptions>): QueueManager;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import PQueue from 'p-queue';
|
|
2
|
+
import type { TaskConfig } from './../types';
|
|
3
|
+
export interface QueueEntry {
|
|
4
|
+
queue: PQueue;
|
|
5
|
+
tasks: any[];
|
|
6
|
+
queuedIds: Set<string>;
|
|
7
|
+
consecutiveErrors: number;
|
|
8
|
+
taskConfig?: TaskConfig;
|
|
9
|
+
}
|
|
10
|
+
export interface QueueStateOptions {
|
|
11
|
+
defaultConcurrency?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const createQueueEntry: (concurrency?: number, onIdle?: () => void) => QueueEntry;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Task, TaskConfig, EngineResult, BaseEngine } from './../types';
|
|
2
|
+
export interface TaskExecutorDeps {
|
|
3
|
+
getTaskConfig: (keycard: string, identifier: string) => TaskConfig | undefined;
|
|
4
|
+
getEngine: (keycard: string) => BaseEngine | undefined;
|
|
5
|
+
persistState: () => Promise<void>;
|
|
6
|
+
debug: boolean;
|
|
7
|
+
onTaskStart: (keycard: string, identifier: string, taskId: string) => void;
|
|
8
|
+
onTaskComplete: (keycard: string, identifier: string, taskId: string, result: EngineResult) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class TaskExecutor {
|
|
11
|
+
private deps;
|
|
12
|
+
private abortControllers;
|
|
13
|
+
constructor(deps: TaskExecutorDeps);
|
|
14
|
+
execute(keycard: string, identifier: string, task: Task, tasks: Task[], updateTasks: (tasks: Task[]) => void): Promise<void>;
|
|
15
|
+
abort(taskId: string): void;
|
|
16
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { Task, TaskConfig } from './types
|
|
2
|
-
import type { BaseEngine, EngineResult } from './types
|
|
1
|
+
import type { Task, TaskConfig } from './types';
|
|
2
|
+
import type { BaseEngine, EngineResult } from './types';
|
|
3
3
|
export interface QueueStatus {
|
|
4
4
|
size: number;
|
|
5
5
|
pending: number;
|
|
6
|
-
isPaused: boolean;
|
|
7
6
|
isRunning: boolean;
|
|
8
7
|
}
|
|
9
8
|
export interface QueueOptions {
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
storageKey?: string;
|
|
10
11
|
defaultConcurrency?: number;
|
|
11
12
|
onTaskStart?: (keycard: string, identifier: string, taskId: string) => void;
|
|
12
13
|
onTaskComplete?: (keycard: string, identifier: string, taskId: string, result: EngineResult) => void;
|
|
@@ -21,7 +22,10 @@ export declare class QueueManager {
|
|
|
21
22
|
private runningQueues;
|
|
22
23
|
private concurrencyMap;
|
|
23
24
|
private abortControllers;
|
|
25
|
+
debug: boolean;
|
|
26
|
+
private persistenceManager;
|
|
24
27
|
constructor(options: Partial<QueueOptions>);
|
|
28
|
+
private debugLog;
|
|
25
29
|
private logQueueState;
|
|
26
30
|
private getQueueKey;
|
|
27
31
|
registerOptions(keycard: string, options: Partial<QueueOptions>): () => void;
|
|
@@ -63,4 +67,4 @@ export declare class QueueManager {
|
|
|
63
67
|
*/
|
|
64
68
|
rehydrateTasks(): Promise<void>;
|
|
65
69
|
}
|
|
66
|
-
export declare function getQueueManager(): QueueManager;
|
|
70
|
+
export declare function getQueueManager(options?: Partial<QueueOptions>): QueueManager;
|
package/dist/core/registry.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BaseEngine } from './types
|
|
1
|
+
import type { BaseEngine } from './types';
|
|
2
2
|
import type { QueueManager } from './queue-manager';
|
|
3
3
|
export declare function registerAllEngines(platformEngines: Record<string, BaseEngine>, queueManager: QueueManager): void;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { type StateStorage } from 'zustand/middleware';
|
|
2
|
-
import type { Task, TaskConfig } from './../types
|
|
2
|
+
import type { Task, TaskConfig } from './../types';
|
|
3
3
|
export interface TaskStoreState {
|
|
4
4
|
tasks: Task[];
|
|
5
5
|
taskHistory: Task[];
|
|
6
6
|
pendingCount: number;
|
|
7
|
-
|
|
7
|
+
isRunning: boolean;
|
|
8
8
|
selectedIds: string[];
|
|
9
|
-
generating: boolean;
|
|
10
9
|
taskConfig: TaskConfig;
|
|
11
10
|
getTasks: () => Task[];
|
|
12
11
|
setTasks: (tasks: Task[]) => void;
|
|
13
12
|
setPendingCount: (count: number) => void;
|
|
14
|
-
|
|
13
|
+
setIsRunning: (running: boolean) => void;
|
|
15
14
|
addTask: (task: Task) => void;
|
|
16
15
|
addTasks: (tasks: Task[]) => void;
|
|
17
16
|
updateTask: (taskId: string, updates: Partial<Task>) => void;
|
|
@@ -24,9 +23,7 @@ export interface TaskStoreState {
|
|
|
24
23
|
toggleSelectAll: (ids?: string[]) => void;
|
|
25
24
|
setSelectedIds: (ids: string[]) => void;
|
|
26
25
|
clearSelected: () => void;
|
|
27
|
-
|
|
28
|
-
getIsPaused: () => boolean;
|
|
29
|
-
getGenerating: () => boolean;
|
|
26
|
+
getIsRunning: () => boolean;
|
|
30
27
|
getTaskConfig: () => TaskConfig;
|
|
31
28
|
updateTaskConfig: (updates: Partial<TaskConfig>) => void;
|
|
32
29
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Task = {
|
|
2
|
+
id: string;
|
|
3
|
+
no: number;
|
|
4
|
+
name: string;
|
|
5
|
+
status: 'Draft' | 'Waiting' | 'Running' | 'Completed' | 'Error' | 'Previous' | 'Skipped';
|
|
6
|
+
progress: number;
|
|
7
|
+
payload: Record<string, any>;
|
|
8
|
+
output?: unknown;
|
|
9
|
+
errorMessage?: string;
|
|
10
|
+
isQueued?: boolean;
|
|
11
|
+
isFlagged?: boolean;
|
|
12
|
+
createAt?: number;
|
|
13
|
+
updateAt?: number;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
export type TaskConfig = {
|
|
17
|
+
threads: number;
|
|
18
|
+
delayMin: number;
|
|
19
|
+
delayMax: number;
|
|
20
|
+
stopOnErrorCount: number;
|
|
21
|
+
};
|
|
22
|
+
export type QueueStatus = {
|
|
23
|
+
size: number;
|
|
24
|
+
pending: number;
|
|
25
|
+
isRunning: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type QueueOptions = {
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
storageKey?: string;
|
|
30
|
+
defaultConcurrency?: number;
|
|
31
|
+
onTaskStart?: (keycard: string, identifier: string, taskId: string) => void;
|
|
32
|
+
onTaskComplete?: (keycard: string, identifier: string, taskId: string, result: EngineResult) => void;
|
|
33
|
+
onQueueEmpty?: (keycard: string, identifier: string) => void;
|
|
34
|
+
onPendingCountChange?: (keycard: string, identifier: string, count: number) => void;
|
|
35
|
+
onTasksUpdate?: (keycard: string, identifier: string, tasks: Task[], status: QueueStatus) => void;
|
|
36
|
+
};
|
|
37
|
+
export type EngineResult = {
|
|
38
|
+
success: boolean;
|
|
39
|
+
output?: unknown;
|
|
40
|
+
error?: string;
|
|
41
|
+
};
|
|
42
|
+
export type BaseEngine = {
|
|
43
|
+
keycard: string;
|
|
44
|
+
execute(ctx: any): Promise<EngineResult>;
|
|
45
|
+
};
|
|
46
|
+
export type SerializedQueueState = {
|
|
47
|
+
isRunning: boolean;
|
|
48
|
+
};
|