@ultrst-armada/kloks 1.4.3 → 1.4.4
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/package.json +8 -20
- package/packages/audio-midi/dist/index.d.ts +23 -14
- package/packages/audio-midi/dist/index.js +170 -45
- package/packages/audio-midi/kloks.manifest.json +8 -8
- package/packages/audio-midi/package.json +1 -1
- package/packages/backend/dist/{WebSocketTransport-CxUzUfwl.d.ts → WebSocketTransport-CHmkJ0tj.d.ts} +109 -2
- package/packages/backend/dist/auth/index.js +6 -6
- package/packages/backend/dist/chunk-5336MTXD.js +597 -0
- package/packages/backend/dist/{chunk-T3NYNBDC.js → chunk-5E6JRFUH.js} +201 -3
- package/packages/backend/dist/{chunk-XTWHEZWS.js → chunk-7B24ZWB3.js} +16 -1
- package/packages/backend/dist/{chunk-DZ4ZGIZM.js → chunk-JXUSBKJ2.js} +91 -654
- package/packages/backend/dist/{chunk-FO6WYLW4.js → chunk-KI3LHMUN.js} +133 -46
- package/packages/backend/dist/{chunk-4ZFXEFOE.js → chunk-MPYASJ5A.js} +2 -87
- package/packages/backend/dist/{chunk-KX3OTBQ3.js → chunk-OZDYAEH4.js} +0 -114
- package/packages/backend/dist/chunk-TY32TUNI.js +376 -0
- package/packages/backend/dist/chunk-VDROUXFT.js +116 -0
- package/packages/backend/dist/chunk-ZDH4XI7W.js +140 -0
- package/packages/backend/dist/client/index.d.ts +2 -3
- package/packages/backend/dist/connectivity/index.d.ts +18 -6
- package/packages/backend/dist/connectivity/index.js +3 -7
- package/packages/backend/dist/index.d.ts +3 -6
- package/packages/backend/dist/index.js +101 -91
- package/packages/backend/dist/krnl-services.d.ts +84 -7
- package/packages/backend/dist/krnl-services.js +40 -12
- package/packages/backend/dist/services/index.d.ts +4 -6
- package/packages/backend/dist/services/index.js +2 -2
- package/packages/backend/dist/srkl/index.js +6 -4
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/backend/kloks.manifest.json +47 -45
- package/packages/backend/package.json +3 -8
- package/packages/client/package.json +1 -1
- package/packages/contracts/dist/index.js +5 -10
- package/packages/contracts/package.json +1 -1
- package/packages/functions/dist/index.d.ts +12 -1
- package/packages/functions/dist/index.js +132 -24
- package/packages/functions/package.json +1 -1
- package/packages/orchestrations/dist/index.d.ts +33 -31
- package/packages/orchestrations/dist/index.js +81 -203
- package/packages/orchestrations/kloks.manifest.json +10 -2
- package/packages/orchestrations/package.json +2 -2
- package/packages/services/dist/index.d.ts +51 -1
- package/packages/services/dist/index.js +234 -36
- package/packages/services/kloks.manifest.json +69 -33
- package/packages/services/package.json +1 -1
- package/packages/state-graph/dist/{BaseGraph-BvkSYOTw.d.ts → BaseGraph-Bd5F1NMP.d.ts} +1 -1
- package/packages/state-graph/dist/{BaseNode-DTcd3K1B.d.ts → BaseNode-DKpGXMy8.d.ts} +6 -0
- package/packages/state-graph/dist/{CompatibilityMatrix-Dj-tCWUA.d.ts → CompatibilityMatrix-TiEJ3j3_.d.ts} +1 -1
- package/packages/state-graph/dist/domain/index.d.ts +3 -3
- package/packages/state-graph/dist/domain/index.js +0 -1
- package/packages/state-graph/dist/index.d.ts +40 -8
- package/packages/state-graph/dist/index.js +214 -65
- package/packages/state-graph/dist/rules/index.d.ts +3 -3
- package/packages/state-graph/dist/rules/index.js +0 -1
- package/packages/state-graph/dist/spatial/index.d.ts +4 -4
- package/packages/state-graph/dist/spatial/index.js +0 -1
- package/packages/state-graph/dist/state/index.js +1 -3
- package/packages/state-graph/dist/store/index.d.ts +4 -4
- package/packages/state-graph/dist/store/index.js +0 -1
- package/packages/state-graph/dist/{types-VDoc4FIc.d.ts → types-D5kQSa65.d.ts} +2 -2
- package/packages/state-graph/kloks.manifest.json +26 -10
- package/packages/state-graph/package.json +2 -8
- package/packages/backend/dist/IdempotencyManager-B5MjK871.d.ts +0 -16
- package/packages/backend/dist/chunk-25Y7AVTP.js +0 -55
- package/packages/backend/dist/chunk-3EPY34R6.js +0 -67
- package/packages/backend/dist/chunk-7KNGX522.js +0 -220
- package/packages/backend/dist/chunk-FZKBTF34.js +0 -15
- package/packages/backend/dist/chunk-QGHDJGYS.js +0 -92
- package/packages/backend/dist/chunk-UPFKBBQI.js +0 -138
- package/packages/backend/dist/chunk-VQEFULWT.js +0 -88
- package/packages/backend/dist/execution/index.d.ts +0 -124
- package/packages/backend/dist/execution/index.js +0 -20
- package/packages/backend/dist/types-BERZJ93O.d.ts +0 -110
- package/packages/state-graph/dist/chunk-3RG5ZIWI.js +0 -10
- package/packages/state-graph/dist/chunk-Q5I42UX7.js +0 -0
- package/packages/state-graph/dist/chunk-ZTHBPV24.js +0 -267
- package/packages/state-graph/dist/execution/index.d.ts +0 -152
- package/packages/state-graph/dist/execution/index.js +0 -16
- /package/packages/state-graph/dist/{chunk-SHIBCPGQ.js → chunk-EW4ACSZB.js} +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
JobScheduler
|
|
3
|
-
} from "./chunk-UPFKBBQI.js";
|
|
4
|
-
|
|
5
|
-
// src/execution/OperationComponent.ts
|
|
6
|
-
function createOperationComponent(name, handler) {
|
|
7
|
-
return {
|
|
8
|
-
name,
|
|
9
|
-
async execute(input) {
|
|
10
|
-
try {
|
|
11
|
-
return await handler(input);
|
|
12
|
-
} catch (err) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
`[OperationComponent:${name}] Execution failure: ${err?.message || String(err)}`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/execution/ServiceDispatcher.ts
|
|
22
|
-
var ServiceDispatcher = class {
|
|
23
|
-
constructor(name) {
|
|
24
|
-
this.name = name;
|
|
25
|
-
}
|
|
26
|
-
name;
|
|
27
|
-
operations = {};
|
|
28
|
-
registerOperation(opName, operation) {
|
|
29
|
-
this.operations[opName] = operation;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
async execute(operationName, input) {
|
|
33
|
-
const op = this.operations[operationName];
|
|
34
|
-
if (!op) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`[ServiceDispatcher:${this.name}] Operation "${operationName}" not found.`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return await op.execute(input);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/execution/DependencyOrdering.ts
|
|
44
|
-
var JobDependencyGraph = class {
|
|
45
|
-
scheduler;
|
|
46
|
-
constructor(maxConcurrency = 5) {
|
|
47
|
-
this.scheduler = new JobScheduler(maxConcurrency);
|
|
48
|
-
}
|
|
49
|
-
registerHandler(type, handler) {
|
|
50
|
-
this.scheduler.registerHandler(type, (job) => handler(job));
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
submitJob(type, payload, dependencies = [], idempotencyKey) {
|
|
54
|
-
return this.scheduler.submit({
|
|
55
|
-
type,
|
|
56
|
-
payload,
|
|
57
|
-
dependencies,
|
|
58
|
-
correlationId: idempotencyKey
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
getJob(jobId) {
|
|
62
|
-
return this.scheduler.status(jobId);
|
|
63
|
-
}
|
|
64
|
-
clear() {
|
|
65
|
-
this.scheduler.clear();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/execution/ResultFlowBridge.ts
|
|
70
|
-
var ResultFlowBridge = class {
|
|
71
|
-
static formatStateUpdate(result) {
|
|
72
|
-
return {
|
|
73
|
-
type: "SKIPO_STATE_UPDATE",
|
|
74
|
-
correlationId: result.correlationId,
|
|
75
|
-
status: result.status,
|
|
76
|
-
data: result.data,
|
|
77
|
-
error: result.error,
|
|
78
|
-
timestamp: result.executionTimestamp
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
createOperationComponent,
|
|
85
|
-
ServiceDispatcher,
|
|
86
|
-
JobDependencyGraph,
|
|
87
|
-
ResultFlowBridge
|
|
88
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { I as IdempotencyManager } from '../IdempotencyManager-B5MjK871.js';
|
|
2
|
-
import { J as Job } from '../types-BERZJ93O.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file types.ts
|
|
6
|
-
* @description Formal TypeScript types for backend execution boundary.
|
|
7
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
8
|
-
*/
|
|
9
|
-
interface ExecutionContext {
|
|
10
|
-
isWorkerContext: boolean;
|
|
11
|
-
workerId?: string;
|
|
12
|
-
timestamp: number;
|
|
13
|
-
}
|
|
14
|
-
interface BackendCommand<TPayload = unknown> {
|
|
15
|
-
id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
payload: TPayload;
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
correlationId: string;
|
|
20
|
-
idempotencyKey?: string;
|
|
21
|
-
createdAt: number;
|
|
22
|
-
}
|
|
23
|
-
interface NormalizedResult<TData = unknown> {
|
|
24
|
-
correlationId: string;
|
|
25
|
-
status: 'COMPLETED' | 'FAILED';
|
|
26
|
-
data?: TData;
|
|
27
|
-
error?: string;
|
|
28
|
-
executionTimestamp: number;
|
|
29
|
-
}
|
|
30
|
-
interface OperationComponent<TInput = unknown, TOutput = unknown> {
|
|
31
|
-
name: string;
|
|
32
|
-
execute(input: TInput): Promise<TOutput>;
|
|
33
|
-
}
|
|
34
|
-
interface DomainService {
|
|
35
|
-
name: string;
|
|
36
|
-
operations: Record<string, OperationComponent<any, any>>;
|
|
37
|
-
execute(operationName: string, input: unknown): Promise<unknown>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @file OperationComponent.ts
|
|
42
|
-
* @description Smallest deterministic executable domain operation.
|
|
43
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
declare function createOperationComponent<TInput = unknown, TOutput = unknown>(name: string, handler: (input: TInput) => Promise<TOutput> | TOutput): OperationComponent<TInput, TOutput>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @file ServiceDispatcher.ts
|
|
50
|
-
* @description Domain-level orchestration unit coordinating OperationComponents.
|
|
51
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
declare class ServiceDispatcher implements DomainService {
|
|
55
|
-
readonly name: string;
|
|
56
|
-
operations: Record<string, OperationComponent<any, any>>;
|
|
57
|
-
constructor(name: string);
|
|
58
|
-
registerOperation<TIn = unknown, TOut = unknown>(opName: string, operation: OperationComponent<TIn, TOut>): this;
|
|
59
|
-
execute(operationName: string, input: unknown): Promise<unknown>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @file BackendFacade.ts
|
|
64
|
-
* @description Single Public Execution Interface for the backend plane.
|
|
65
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
declare class ExecutableBackendFacade {
|
|
69
|
-
readonly name: string;
|
|
70
|
-
private services;
|
|
71
|
-
private idempotency;
|
|
72
|
-
constructor(name: string, idempotency?: IdempotencyManager);
|
|
73
|
-
registerService(service: ServiceDispatcher): this;
|
|
74
|
-
executeCommand<T = unknown>(command: BackendCommand<any>, context: ExecutionContext): Promise<NormalizedResult<T>>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @file WorkerExecutionBoundary.ts
|
|
79
|
-
* @description Worker execution boundary enforcing worker-only access to Backend Facade.
|
|
80
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
declare class WorkerExecutionBoundary {
|
|
84
|
-
readonly workerId: string;
|
|
85
|
-
private facade;
|
|
86
|
-
constructor(workerId: string, facade: ExecutableBackendFacade);
|
|
87
|
-
processJob<T = unknown>(command: BackendCommand<any>): Promise<NormalizedResult<T>>;
|
|
88
|
-
static assertWorkerContext(context?: ExecutionContext): void;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @file DependencyOrdering.ts
|
|
93
|
-
* @description Dependency graph ordering and race-condition prevention for jobs.
|
|
94
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
declare class JobDependencyGraph {
|
|
98
|
-
private scheduler;
|
|
99
|
-
constructor(maxConcurrency?: number);
|
|
100
|
-
registerHandler<TPayload = any, TResult = any>(type: string, handler: (job: Job<TPayload, TResult>) => Promise<TResult>): this;
|
|
101
|
-
submitJob<TPayload = any, TResult = any>(type: string, payload: TPayload, dependencies?: string[], idempotencyKey?: string): Job<TPayload, TResult>;
|
|
102
|
-
getJob(jobId: string): Job | undefined;
|
|
103
|
-
clear(): void;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @file ResultFlowBridge.ts
|
|
108
|
-
* @description Bridges execution results back to frontend state update streams.
|
|
109
|
-
* Conforms to SKIPO::STATE_EXECUTION_ARCHITECTURE and L9 (<=200L).
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
interface StateUpdateEvent<T = unknown> {
|
|
113
|
-
type: 'SKIPO_STATE_UPDATE';
|
|
114
|
-
correlationId: string;
|
|
115
|
-
status: 'COMPLETED' | 'FAILED';
|
|
116
|
-
data?: T;
|
|
117
|
-
error?: string;
|
|
118
|
-
timestamp: number;
|
|
119
|
-
}
|
|
120
|
-
declare class ResultFlowBridge {
|
|
121
|
-
static formatStateUpdate<T = unknown>(result: NormalizedResult<T>): StateUpdateEvent<T>;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export { type BackendCommand, type DomainService, ExecutableBackendFacade, type ExecutionContext, JobDependencyGraph, type NormalizedResult, type OperationComponent, ResultFlowBridge, ServiceDispatcher, type StateUpdateEvent, WorkerExecutionBoundary, createOperationComponent };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
JobDependencyGraph,
|
|
3
|
-
ResultFlowBridge,
|
|
4
|
-
ServiceDispatcher,
|
|
5
|
-
createOperationComponent
|
|
6
|
-
} from "../chunk-VQEFULWT.js";
|
|
7
|
-
import {
|
|
8
|
-
ExecutableBackendFacade,
|
|
9
|
-
WorkerExecutionBoundary
|
|
10
|
-
} from "../chunk-QGHDJGYS.js";
|
|
11
|
-
import "../chunk-UPFKBBQI.js";
|
|
12
|
-
import "../chunk-3EPY34R6.js";
|
|
13
|
-
export {
|
|
14
|
-
ExecutableBackendFacade,
|
|
15
|
-
JobDependencyGraph,
|
|
16
|
-
ResultFlowBridge,
|
|
17
|
-
ServiceDispatcher,
|
|
18
|
-
WorkerExecutionBoundary,
|
|
19
|
-
createOperationComponent
|
|
20
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file types.ts
|
|
3
|
-
* @description Canonical protocol types, messages, jobs, callbacks, and resolution interfaces.
|
|
4
|
-
*/
|
|
5
|
-
type MessageType = 'COMMAND' | 'QUERY' | 'RESULT' | 'EVENT' | 'CALLBACK_REQUEST' | 'CALLBACK_RESULT' | 'JOB_SUBMIT' | 'JOB_PROGRESS' | 'JOB_RESULT' | 'ERROR' | 'ACK';
|
|
6
|
-
interface AuthContext {
|
|
7
|
-
userId?: string;
|
|
8
|
-
role?: string;
|
|
9
|
-
permissions?: string[];
|
|
10
|
-
token?: string;
|
|
11
|
-
}
|
|
12
|
-
interface CapabilityContext {
|
|
13
|
-
domain: string;
|
|
14
|
-
capability: string;
|
|
15
|
-
scope?: string;
|
|
16
|
-
}
|
|
17
|
-
interface Message<T = unknown> {
|
|
18
|
-
id: string;
|
|
19
|
-
type: MessageType;
|
|
20
|
-
operation: string;
|
|
21
|
-
payload?: T;
|
|
22
|
-
sessionId?: string;
|
|
23
|
-
correlationId?: string;
|
|
24
|
-
causationId?: string;
|
|
25
|
-
sequence?: number;
|
|
26
|
-
timestamp: number;
|
|
27
|
-
authContext?: AuthContext;
|
|
28
|
-
capabilityContext?: CapabilityContext;
|
|
29
|
-
error?: {
|
|
30
|
-
code: string;
|
|
31
|
-
message: string;
|
|
32
|
-
details?: unknown;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
interface CallbackHandle {
|
|
36
|
-
id: string;
|
|
37
|
-
sessionId: string;
|
|
38
|
-
capability: string;
|
|
39
|
-
expiration: number;
|
|
40
|
-
}
|
|
41
|
-
interface Delegation<T = unknown> {
|
|
42
|
-
target: string;
|
|
43
|
-
operation: string;
|
|
44
|
-
payload: T;
|
|
45
|
-
callbackHandle?: CallbackHandle;
|
|
46
|
-
eventChannel?: string;
|
|
47
|
-
sessionId?: string;
|
|
48
|
-
correlationId?: string;
|
|
49
|
-
}
|
|
50
|
-
type JobState = 'PENDING' | 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
51
|
-
type JobPriority = 'LOW' | 'NORMAL' | 'HIGH' | 'CRITICAL';
|
|
52
|
-
interface Job<TPayload = unknown, TResult = unknown> {
|
|
53
|
-
id: string;
|
|
54
|
-
type: string;
|
|
55
|
-
payload: TPayload;
|
|
56
|
-
priority?: JobPriority;
|
|
57
|
-
sequence?: number;
|
|
58
|
-
sequenceKey?: string;
|
|
59
|
-
dependencies?: string[];
|
|
60
|
-
sessionId?: string;
|
|
61
|
-
correlationId?: string;
|
|
62
|
-
state: JobState;
|
|
63
|
-
progress?: number;
|
|
64
|
-
result?: TResult;
|
|
65
|
-
error?: string;
|
|
66
|
-
createdAt: number;
|
|
67
|
-
updatedAt: number;
|
|
68
|
-
}
|
|
69
|
-
type ResolutionStrategy = 'LOCAL' | 'REMOTE' | 'REMOTE_FIRST' | 'LOCAL_FIRST';
|
|
70
|
-
interface ResourceVersion {
|
|
71
|
-
version: number;
|
|
72
|
-
updatedAt: number;
|
|
73
|
-
checksum?: string;
|
|
74
|
-
}
|
|
75
|
-
interface DistributedLock {
|
|
76
|
-
key: string;
|
|
77
|
-
ownerId: string;
|
|
78
|
-
leaseId: string;
|
|
79
|
-
expiration: number;
|
|
80
|
-
}
|
|
81
|
-
interface BackendInstance {
|
|
82
|
-
id: string;
|
|
83
|
-
url: string;
|
|
84
|
-
healthy: boolean;
|
|
85
|
-
capacity: number;
|
|
86
|
-
activeJobs: number;
|
|
87
|
-
activeConnections: number;
|
|
88
|
-
latencyMs: number;
|
|
89
|
-
lastHeartbeat: number;
|
|
90
|
-
weight?: number;
|
|
91
|
-
}
|
|
92
|
-
type RoutingStrategy = 'roundRobin' | 'weighted' | 'leastConnections' | 'latencyAware' | 'capacityAware';
|
|
93
|
-
interface IdempotentRequest<T = unknown> {
|
|
94
|
-
id: string;
|
|
95
|
-
idempotencyKey: string;
|
|
96
|
-
operation: string;
|
|
97
|
-
payload: T;
|
|
98
|
-
timestamp: number;
|
|
99
|
-
}
|
|
100
|
-
interface BackendExecutor {
|
|
101
|
-
execute<T = unknown, R = unknown>(command: Message<T>): Promise<R>;
|
|
102
|
-
query<T = unknown, R = unknown>(query: Message<T>): Promise<R>;
|
|
103
|
-
subscribe(channel: string, handler: (event: Message) => void): () => void;
|
|
104
|
-
emit(event: Message): Promise<void>;
|
|
105
|
-
registerCallback(callback: (...args: unknown[]) => unknown): CallbackHandle;
|
|
106
|
-
delegate<T = unknown, R = unknown>(delegation: Delegation<T>): Promise<R>;
|
|
107
|
-
submitJob<T = unknown, R = unknown>(job: Partial<Job<T, R>>): Promise<Job<T, R>>;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export type { AuthContext as A, BackendExecutor as B, CallbackHandle as C, Delegation as D, IdempotentRequest as I, Job as J, Message as M, ResolutionStrategy as R, BackendInstance as a, CapabilityContext as b, DistributedLock as c, JobPriority as d, JobState as e, MessageType as f, ResourceVersion as g, RoutingStrategy as h };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
__require
|
|
10
|
-
};
|
|
File without changes
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SKIPO_STATE,
|
|
3
|
-
useSkipoState
|
|
4
|
-
} from "./chunk-SHIBCPGQ.js";
|
|
5
|
-
import {
|
|
6
|
-
__require
|
|
7
|
-
} from "./chunk-3RG5ZIWI.js";
|
|
8
|
-
|
|
9
|
-
// src/execution/BullMQAdapter.ts
|
|
10
|
-
var BullMQAdapter = class {
|
|
11
|
-
queue;
|
|
12
|
-
worker;
|
|
13
|
-
inMemoryJobs = /* @__PURE__ */ new Map();
|
|
14
|
-
inMemoryResults = /* @__PURE__ */ new Map();
|
|
15
|
-
inMemoryListeners = /* @__PURE__ */ new Map();
|
|
16
|
-
isInMemory = false;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.isInMemory = true;
|
|
19
|
-
if (typeof window === "undefined" && !options.useInMemory && options.connection) {
|
|
20
|
-
try {
|
|
21
|
-
const req = typeof __require !== "undefined" ? __require : null;
|
|
22
|
-
if (req) {
|
|
23
|
-
const { Queue } = req("bullmq");
|
|
24
|
-
this.queue = new Queue(options.queueName, { connection: options.connection });
|
|
25
|
-
this.isInMemory = false;
|
|
26
|
-
}
|
|
27
|
-
} catch {
|
|
28
|
-
this.isInMemory = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async enqueue(job) {
|
|
33
|
-
if (!this.isInMemory && this.queue) {
|
|
34
|
-
const priorityVal = this.getPriorityNumber(job.priority);
|
|
35
|
-
const bJob = await this.queue.add(job.command.type, job, {
|
|
36
|
-
jobId: job.id,
|
|
37
|
-
priority: priorityVal,
|
|
38
|
-
attempts: job.retryPolicy?.maxAttempts || 3,
|
|
39
|
-
backoff: job.retryPolicy ? { type: "exponential", delay: job.retryPolicy.backoffMs } : void 0
|
|
40
|
-
});
|
|
41
|
-
return bJob.id || job.id;
|
|
42
|
-
}
|
|
43
|
-
this.inMemoryJobs.set(job.id, { ...job, status: "QUEUED" });
|
|
44
|
-
return job.id;
|
|
45
|
-
}
|
|
46
|
-
async getJobStatus(jobId) {
|
|
47
|
-
if (!this.isInMemory && this.queue) {
|
|
48
|
-
const bJob = await this.queue.getJob(jobId);
|
|
49
|
-
if (!bJob) return void 0;
|
|
50
|
-
const state = await bJob.getState();
|
|
51
|
-
switch (state) {
|
|
52
|
-
case "completed":
|
|
53
|
-
return "COMPLETED";
|
|
54
|
-
case "failed":
|
|
55
|
-
return "FAILED";
|
|
56
|
-
case "active":
|
|
57
|
-
return "RUNNING";
|
|
58
|
-
case "waiting":
|
|
59
|
-
case "delayed":
|
|
60
|
-
return "QUEUED";
|
|
61
|
-
default:
|
|
62
|
-
return "PENDING";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return this.inMemoryJobs.get(jobId)?.status;
|
|
66
|
-
}
|
|
67
|
-
async getJobResult(jobId) {
|
|
68
|
-
if (!this.isInMemory && this.queue) {
|
|
69
|
-
const bJob = await this.queue.getJob(jobId);
|
|
70
|
-
if (!bJob) return void 0;
|
|
71
|
-
if (await bJob.isCompleted()) {
|
|
72
|
-
return { correlationId: bJob.data.correlationId, status: "COMPLETED", data: bJob.returnvalue };
|
|
73
|
-
}
|
|
74
|
-
if (await bJob.isFailed()) {
|
|
75
|
-
return { correlationId: bJob.data.correlationId, status: "FAILED", error: bJob.failedReason };
|
|
76
|
-
}
|
|
77
|
-
return void 0;
|
|
78
|
-
}
|
|
79
|
-
return this.inMemoryResults.get(jobId);
|
|
80
|
-
}
|
|
81
|
-
completeInMemoryJob(jobId, result) {
|
|
82
|
-
const job = this.inMemoryJobs.get(jobId);
|
|
83
|
-
if (job) {
|
|
84
|
-
job.status = result.status === "COMPLETED" ? "COMPLETED" : "FAILED";
|
|
85
|
-
job.updatedAt = Date.now();
|
|
86
|
-
this.inMemoryResults.set(jobId, result);
|
|
87
|
-
const listeners = this.inMemoryListeners.get(jobId) || [];
|
|
88
|
-
listeners.forEach((fn) => fn(result));
|
|
89
|
-
this.inMemoryListeners.delete(jobId);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
subscribeInMemoryJob(jobId, listener) {
|
|
93
|
-
const existing = this.inMemoryResults.get(jobId);
|
|
94
|
-
if (existing) {
|
|
95
|
-
listener(existing);
|
|
96
|
-
return () => {
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const current = this.inMemoryListeners.get(jobId) || [];
|
|
100
|
-
current.push(listener);
|
|
101
|
-
this.inMemoryListeners.set(jobId, current);
|
|
102
|
-
return () => {
|
|
103
|
-
const arr = this.inMemoryListeners.get(jobId) || [];
|
|
104
|
-
this.inMemoryListeners.set(jobId, arr.filter((fn) => fn !== listener));
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
getQueuedInMemoryJobs() {
|
|
108
|
-
return Array.from(this.inMemoryJobs.values()).filter((j) => j.status === "QUEUED").sort((a, b) => this.getPriorityNumber(b.priority) - this.getPriorityNumber(a.priority));
|
|
109
|
-
}
|
|
110
|
-
async cancel(jobId) {
|
|
111
|
-
if (!this.isInMemory && this.queue) {
|
|
112
|
-
const bJob = await this.queue.getJob(jobId);
|
|
113
|
-
if (bJob) {
|
|
114
|
-
await bJob.remove();
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return this.inMemoryJobs.delete(jobId);
|
|
120
|
-
}
|
|
121
|
-
async close() {
|
|
122
|
-
if (this.worker) await this.worker.close();
|
|
123
|
-
if (this.queue) await this.queue.close();
|
|
124
|
-
this.inMemoryJobs.clear();
|
|
125
|
-
this.inMemoryResults.clear();
|
|
126
|
-
}
|
|
127
|
-
getPriorityNumber(priority) {
|
|
128
|
-
switch (priority) {
|
|
129
|
-
case "CRITICAL":
|
|
130
|
-
return 1;
|
|
131
|
-
case "HIGH":
|
|
132
|
-
return 2;
|
|
133
|
-
case "NORMAL":
|
|
134
|
-
return 3;
|
|
135
|
-
case "LOW":
|
|
136
|
-
return 4;
|
|
137
|
-
default:
|
|
138
|
-
return 3;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// src/execution/CommandBus.ts
|
|
144
|
-
var CommandBus = class {
|
|
145
|
-
constructor(adapter) {
|
|
146
|
-
this.adapter = adapter;
|
|
147
|
-
}
|
|
148
|
-
adapter;
|
|
149
|
-
createCommand(type, payload, metadata, lifecycle) {
|
|
150
|
-
const timestamp = Date.now();
|
|
151
|
-
const id = `cmd_${timestamp}_${Math.random().toString(36).slice(2, 7)}`;
|
|
152
|
-
const correlationId = `corr_${timestamp}_${Math.random().toString(36).slice(2, 9)}`;
|
|
153
|
-
return {
|
|
154
|
-
id,
|
|
155
|
-
type,
|
|
156
|
-
payload,
|
|
157
|
-
metadata,
|
|
158
|
-
correlationId,
|
|
159
|
-
lifecycle,
|
|
160
|
-
createdAt: timestamp
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
async enqueue(command, options = {}) {
|
|
164
|
-
const now = Date.now();
|
|
165
|
-
const idempotencyKey = options.idempotencyKey || `idem_${command.type}_${command.correlationId}`;
|
|
166
|
-
const job = {
|
|
167
|
-
id: `job_${now}_${Math.random().toString(36).slice(2, 7)}`,
|
|
168
|
-
command,
|
|
169
|
-
idempotencyKey,
|
|
170
|
-
correlationId: options.correlationId || command.correlationId,
|
|
171
|
-
retryPolicy: options.retryPolicy || { maxAttempts: 3, backoffMs: 1e3 },
|
|
172
|
-
priority: options.priority || "NORMAL",
|
|
173
|
-
dependencies: options.dependencies || [],
|
|
174
|
-
status: "QUEUED",
|
|
175
|
-
attempts: 0,
|
|
176
|
-
createdAt: now,
|
|
177
|
-
updatedAt: now
|
|
178
|
-
};
|
|
179
|
-
await this.adapter.enqueue(job);
|
|
180
|
-
return job;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// src/execution/SkipoExecution.ts
|
|
185
|
-
var SkipoExecutionEngine = class {
|
|
186
|
-
frontendQueue;
|
|
187
|
-
backendQueue;
|
|
188
|
-
commandBus;
|
|
189
|
-
constructor(options = {}) {
|
|
190
|
-
this.frontendQueue = new BullMQAdapter({
|
|
191
|
-
queueName: "FRONTEND_EXECUTION_QUEUE",
|
|
192
|
-
connection: options.redisConnection
|
|
193
|
-
});
|
|
194
|
-
this.backendQueue = new BullMQAdapter({
|
|
195
|
-
queueName: "BACKEND_EXECUTION_QUEUE",
|
|
196
|
-
connection: options.redisConnection
|
|
197
|
-
});
|
|
198
|
-
this.commandBus = new CommandBus(this.frontendQueue);
|
|
199
|
-
}
|
|
200
|
-
createCommand(type, payload, metadata, lifecycle) {
|
|
201
|
-
return this.commandBus.createCommand(type, payload, metadata, lifecycle);
|
|
202
|
-
}
|
|
203
|
-
async dispatch(type, payload, options = {}) {
|
|
204
|
-
const cmd = this.createCommand(type, payload, void 0, options.correlationId);
|
|
205
|
-
const job = await this.commandBus.enqueue(cmd, options);
|
|
206
|
-
const stateId = `execution_${job.correlationId}`;
|
|
207
|
-
SKIPO_STATE.create(
|
|
208
|
-
"SKIPO_EXECUTION",
|
|
209
|
-
{ type: "APP" },
|
|
210
|
-
{ status: "QUEUED", correlationId: job.correlationId, progress: 0 },
|
|
211
|
-
stateId
|
|
212
|
-
);
|
|
213
|
-
return job;
|
|
214
|
-
}
|
|
215
|
-
propagateResult(correlationId, result) {
|
|
216
|
-
const stateId = `execution_${correlationId}`;
|
|
217
|
-
if (SKIPO_STATE.get(stateId)) {
|
|
218
|
-
SKIPO_STATE.update(stateId, () => ({
|
|
219
|
-
status: result.status,
|
|
220
|
-
correlationId,
|
|
221
|
-
data: result.data,
|
|
222
|
-
error: result.error,
|
|
223
|
-
completedAt: Date.now()
|
|
224
|
-
}));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
async close() {
|
|
228
|
-
await this.frontendQueue.close();
|
|
229
|
-
await this.backendQueue.close();
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
var SKIPO_EXECUTION = new SkipoExecutionEngine();
|
|
233
|
-
|
|
234
|
-
// src/execution/hooks.ts
|
|
235
|
-
import { useState, useCallback } from "react";
|
|
236
|
-
function useCommand(type, defaultOptions = {}) {
|
|
237
|
-
const [activeCorrId, setActiveCorrId] = useState(null);
|
|
238
|
-
const [execState] = useSkipoState(
|
|
239
|
-
activeCorrId ? `execution_${activeCorrId}` : `execution_idle_${type}`,
|
|
240
|
-
{ status: "IDLE" }
|
|
241
|
-
);
|
|
242
|
-
const dispatch = useCallback(
|
|
243
|
-
async (payload, options) => {
|
|
244
|
-
const mergedOptions = { ...defaultOptions, ...options };
|
|
245
|
-
const job = await SKIPO_EXECUTION.dispatch(type, payload, mergedOptions);
|
|
246
|
-
setActiveCorrId(job.correlationId);
|
|
247
|
-
return job;
|
|
248
|
-
},
|
|
249
|
-
[type, defaultOptions]
|
|
250
|
-
);
|
|
251
|
-
return {
|
|
252
|
-
dispatch,
|
|
253
|
-
status: execState.status,
|
|
254
|
-
isPending: execState.status === "QUEUED" || execState.status === "RUNNING",
|
|
255
|
-
result: execState.data,
|
|
256
|
-
error: execState.error,
|
|
257
|
-
correlationId: execState.correlationId
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export {
|
|
262
|
-
BullMQAdapter,
|
|
263
|
-
CommandBus,
|
|
264
|
-
SkipoExecutionEngine,
|
|
265
|
-
SKIPO_EXECUTION,
|
|
266
|
-
useCommand
|
|
267
|
-
};
|