@emmvish/stable-request 2.8.4 → 3.0.0
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/LICENSE +1 -1
- package/README.md +1153 -2319
- package/dist/constants/index.d.ts +0 -10
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +0 -113
- package/dist/constants/index.js.map +1 -1
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -5
- package/dist/core/index.js.map +1 -1
- package/dist/core/stable-request.d.ts.map +1 -1
- package/dist/core/stable-request.js +22 -7
- package/dist/core/stable-request.js.map +1 -1
- package/dist/enums/index.d.ts +0 -37
- package/dist/enums/index.d.ts.map +1 -1
- package/dist/enums/index.js +0 -43
- package/dist/enums/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +100 -1135
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utilities/index.d.ts +0 -18
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +0 -18
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/infrastructure-persistence.d.ts +0 -1
- package/dist/utilities/infrastructure-persistence.d.ts.map +1 -1
- package/dist/utilities/infrastructure-persistence.js +12 -15
- package/dist/utilities/infrastructure-persistence.js.map +1 -1
- package/dist/utilities/metrics-aggregator.d.ts +2 -13
- package/dist/utilities/metrics-aggregator.d.ts.map +1 -1
- package/dist/utilities/metrics-aggregator.js +9 -251
- package/dist/utilities/metrics-aggregator.js.map +1 -1
- package/dist/utilities/metrics-validator.d.ts +6 -76
- package/dist/utilities/metrics-validator.d.ts.map +1 -1
- package/dist/utilities/metrics-validator.js +12 -181
- package/dist/utilities/metrics-validator.js.map +1 -1
- package/dist/utilities/validate-trial-mode-probabilities.js +2 -2
- package/dist/utilities/validate-trial-mode-probabilities.js.map +1 -1
- package/package.json +20 -24
- package/dist/core/stable-api-gateway.d.ts +0 -4
- package/dist/core/stable-api-gateway.d.ts.map +0 -1
- package/dist/core/stable-api-gateway.js +0 -136
- package/dist/core/stable-api-gateway.js.map +0 -1
- package/dist/core/stable-function.d.ts +0 -11
- package/dist/core/stable-function.d.ts.map +0 -1
- package/dist/core/stable-function.js +0 -340
- package/dist/core/stable-function.js.map +0 -1
- package/dist/core/stable-scheduler.d.ts +0 -71
- package/dist/core/stable-scheduler.d.ts.map +0 -1
- package/dist/core/stable-scheduler.js +0 -768
- package/dist/core/stable-scheduler.js.map +0 -1
- package/dist/core/stable-workflow-graph.d.ts +0 -3
- package/dist/core/stable-workflow-graph.d.ts.map +0 -1
- package/dist/core/stable-workflow-graph.js +0 -5
- package/dist/core/stable-workflow-graph.js.map +0 -1
- package/dist/core/stable-workflow.d.ts +0 -3
- package/dist/core/stable-workflow.d.ts.map +0 -1
- package/dist/core/stable-workflow.js +0 -362
- package/dist/core/stable-workflow.js.map +0 -1
- package/dist/stable-runner/index.d.ts +0 -2
- package/dist/stable-runner/index.d.ts.map +0 -1
- package/dist/stable-runner/index.js +0 -324
- package/dist/stable-runner/index.js.map +0 -1
- package/dist/utilities/concurrency-limiter.d.ts +0 -46
- package/dist/utilities/concurrency-limiter.d.ts.map +0 -1
- package/dist/utilities/concurrency-limiter.js +0 -172
- package/dist/utilities/concurrency-limiter.js.map +0 -1
- package/dist/utilities/execute-branch-workflow.d.ts +0 -3
- package/dist/utilities/execute-branch-workflow.d.ts.map +0 -1
- package/dist/utilities/execute-branch-workflow.js +0 -730
- package/dist/utilities/execute-branch-workflow.js.map +0 -1
- package/dist/utilities/execute-concurrently.d.ts +0 -3
- package/dist/utilities/execute-concurrently.d.ts.map +0 -1
- package/dist/utilities/execute-concurrently.js +0 -258
- package/dist/utilities/execute-concurrently.js.map +0 -1
- package/dist/utilities/execute-gateway-item.d.ts +0 -6
- package/dist/utilities/execute-gateway-item.d.ts.map +0 -1
- package/dist/utilities/execute-gateway-item.js +0 -127
- package/dist/utilities/execute-gateway-item.js.map +0 -1
- package/dist/utilities/execute-non-linear-workflow.d.ts +0 -3
- package/dist/utilities/execute-non-linear-workflow.d.ts.map +0 -1
- package/dist/utilities/execute-non-linear-workflow.js +0 -483
- package/dist/utilities/execute-non-linear-workflow.js.map +0 -1
- package/dist/utilities/execute-phase.d.ts +0 -3
- package/dist/utilities/execute-phase.d.ts.map +0 -1
- package/dist/utilities/execute-phase.js +0 -129
- package/dist/utilities/execute-phase.js.map +0 -1
- package/dist/utilities/execute-sequentially.d.ts +0 -3
- package/dist/utilities/execute-sequentially.d.ts.map +0 -1
- package/dist/utilities/execute-sequentially.js +0 -49
- package/dist/utilities/execute-sequentially.js.map +0 -1
- package/dist/utilities/execute-with-timeout.d.ts +0 -6
- package/dist/utilities/execute-with-timeout.d.ts.map +0 -1
- package/dist/utilities/execute-with-timeout.js +0 -28
- package/dist/utilities/execute-with-timeout.js.map +0 -1
- package/dist/utilities/execute-workflow-graph.d.ts +0 -3
- package/dist/utilities/execute-workflow-graph.d.ts.map +0 -1
- package/dist/utilities/execute-workflow-graph.js +0 -429
- package/dist/utilities/execute-workflow-graph.js.map +0 -1
- package/dist/utilities/extract-common-request-config-options.d.ts +0 -3
- package/dist/utilities/extract-common-request-config-options.d.ts.map +0 -1
- package/dist/utilities/extract-common-request-config-options.js +0 -12
- package/dist/utilities/extract-common-request-config-options.js.map +0 -1
- package/dist/utilities/fn-exec.d.ts +0 -3
- package/dist/utilities/fn-exec.d.ts.map +0 -1
- package/dist/utilities/fn-exec.js +0 -66
- package/dist/utilities/fn-exec.js.map +0 -1
- package/dist/utilities/function-cache-manager.d.ts +0 -32
- package/dist/utilities/function-cache-manager.d.ts.map +0 -1
- package/dist/utilities/function-cache-manager.js +0 -172
- package/dist/utilities/function-cache-manager.js.map +0 -1
- package/dist/utilities/prepare-api-function-options.d.ts +0 -3
- package/dist/utilities/prepare-api-function-options.d.ts.map +0 -1
- package/dist/utilities/prepare-api-function-options.js +0 -51
- package/dist/utilities/prepare-api-function-options.js.map +0 -1
- package/dist/utilities/prepare-api-request-data.d.ts +0 -3
- package/dist/utilities/prepare-api-request-data.d.ts.map +0 -1
- package/dist/utilities/prepare-api-request-data.js +0 -15
- package/dist/utilities/prepare-api-request-data.js.map +0 -1
- package/dist/utilities/prepare-api-request-options.d.ts +0 -3
- package/dist/utilities/prepare-api-request-options.d.ts.map +0 -1
- package/dist/utilities/prepare-api-request-options.js +0 -22
- package/dist/utilities/prepare-api-request-options.js.map +0 -1
- package/dist/utilities/rate-limiter.d.ts +0 -49
- package/dist/utilities/rate-limiter.d.ts.map +0 -1
- package/dist/utilities/rate-limiter.js +0 -197
- package/dist/utilities/rate-limiter.js.map +0 -1
- package/dist/utilities/validate-workflow-graph.d.ts +0 -7
- package/dist/utilities/validate-workflow-graph.d.ts.map +0 -1
- package/dist/utilities/validate-workflow-graph.js +0 -235
- package/dist/utilities/validate-workflow-graph.js.map +0 -1
- package/dist/utilities/workflow-graph-builder.d.ts +0 -37
- package/dist/utilities/workflow-graph-builder.d.ts.map +0 -1
- package/dist/utilities/workflow-graph-builder.js +0 -225
- package/dist/utilities/workflow-graph-builder.js.map +0 -1
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { InfrastructurePersistenceCoordinator } from './infrastructure-persistence.js';
|
|
2
|
-
export class RateLimiter {
|
|
3
|
-
maxRequests;
|
|
4
|
-
windowMs;
|
|
5
|
-
tokens;
|
|
6
|
-
lastRefillTime;
|
|
7
|
-
queue = [];
|
|
8
|
-
totalRequests = 0;
|
|
9
|
-
throttledRequests = 0;
|
|
10
|
-
completedRequests = 0;
|
|
11
|
-
peakQueueLength = 0;
|
|
12
|
-
totalQueueWaitTime = 0;
|
|
13
|
-
peakRequestRate = 0;
|
|
14
|
-
requestsInCurrentWindow = 0;
|
|
15
|
-
windowStartTime = Date.now();
|
|
16
|
-
persistence;
|
|
17
|
-
persistenceCoordinator;
|
|
18
|
-
initialized = false;
|
|
19
|
-
constructor(maxRequestsOrConfig, windowMs, persistence) {
|
|
20
|
-
if (typeof maxRequestsOrConfig === 'object') {
|
|
21
|
-
this.maxRequests = Math.max(1, Math.floor(maxRequestsOrConfig.maxRequests));
|
|
22
|
-
this.windowMs = Math.max(100, maxRequestsOrConfig.windowMs);
|
|
23
|
-
this.persistence = maxRequestsOrConfig.persistence;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
this.maxRequests = Math.max(1, Math.floor(maxRequestsOrConfig));
|
|
27
|
-
this.windowMs = Math.max(100, windowMs);
|
|
28
|
-
this.persistence = persistence;
|
|
29
|
-
}
|
|
30
|
-
this.persistenceCoordinator = this.persistence
|
|
31
|
-
? new InfrastructurePersistenceCoordinator(this.persistence, 'rate-limiter')
|
|
32
|
-
: undefined;
|
|
33
|
-
this.tokens = this.maxRequests;
|
|
34
|
-
this.lastRefillTime = Date.now();
|
|
35
|
-
}
|
|
36
|
-
async initialize() {
|
|
37
|
-
if (this.initialized)
|
|
38
|
-
return;
|
|
39
|
-
if (this.persistenceCoordinator) {
|
|
40
|
-
try {
|
|
41
|
-
const persistedState = await this.persistenceCoordinator.load();
|
|
42
|
-
if (persistedState) {
|
|
43
|
-
this.restoreState(persistedState);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.warn('stable-request: Unable to load rate limiter state from persistence.');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
this.initialized = true;
|
|
51
|
-
}
|
|
52
|
-
restoreState(persistedState) {
|
|
53
|
-
this.tokens = persistedState.tokens;
|
|
54
|
-
this.lastRefillTime = persistedState.lastRefillTime;
|
|
55
|
-
this.totalRequests = persistedState.totalRequests;
|
|
56
|
-
this.throttledRequests = persistedState.throttledRequests;
|
|
57
|
-
this.completedRequests = persistedState.completedRequests;
|
|
58
|
-
this.peakQueueLength = persistedState.peakQueueLength;
|
|
59
|
-
this.totalQueueWaitTime = persistedState.totalQueueWaitTime;
|
|
60
|
-
this.peakRequestRate = persistedState.peakRequestRate;
|
|
61
|
-
this.requestsInCurrentWindow = persistedState.requestsInCurrentWindow;
|
|
62
|
-
this.windowStartTime = persistedState.windowStartTime;
|
|
63
|
-
}
|
|
64
|
-
getPersistedState() {
|
|
65
|
-
return {
|
|
66
|
-
tokens: this.tokens,
|
|
67
|
-
lastRefillTime: this.lastRefillTime,
|
|
68
|
-
totalRequests: this.totalRequests,
|
|
69
|
-
throttledRequests: this.throttledRequests,
|
|
70
|
-
completedRequests: this.completedRequests,
|
|
71
|
-
peakQueueLength: this.peakQueueLength,
|
|
72
|
-
totalQueueWaitTime: this.totalQueueWaitTime,
|
|
73
|
-
peakRequestRate: this.peakRequestRate,
|
|
74
|
-
requestsInCurrentWindow: this.requestsInCurrentWindow,
|
|
75
|
-
windowStartTime: this.windowStartTime
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async persistState() {
|
|
79
|
-
if (this.persistenceCoordinator) {
|
|
80
|
-
try {
|
|
81
|
-
await this.persistenceCoordinator.store(this.getPersistedState());
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.warn('stable-request: Unable to store rate limiter state to persistence.');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
refillTokens() {
|
|
89
|
-
const now = Date.now();
|
|
90
|
-
const elapsed = now - this.lastRefillTime;
|
|
91
|
-
if (elapsed >= this.windowMs) {
|
|
92
|
-
const windowsPassed = Math.floor(elapsed / this.windowMs);
|
|
93
|
-
this.tokens = Math.min(this.maxRequests, this.tokens + (windowsPassed * this.maxRequests));
|
|
94
|
-
this.lastRefillTime = now;
|
|
95
|
-
this.requestsInCurrentWindow = 0;
|
|
96
|
-
this.windowStartTime = now;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async acquire() {
|
|
100
|
-
this.totalRequests++;
|
|
101
|
-
this.refillTokens();
|
|
102
|
-
if (this.tokens > 0) {
|
|
103
|
-
this.tokens--;
|
|
104
|
-
this.requestsInCurrentWindow++;
|
|
105
|
-
this.peakRequestRate = Math.max(this.peakRequestRate, this.requestsInCurrentWindow);
|
|
106
|
-
this.persistState();
|
|
107
|
-
return Promise.resolve();
|
|
108
|
-
}
|
|
109
|
-
this.throttledRequests++;
|
|
110
|
-
const queueStartTime = Date.now();
|
|
111
|
-
return new Promise((resolve) => {
|
|
112
|
-
this.queue.push(() => {
|
|
113
|
-
this.totalQueueWaitTime += (Date.now() - queueStartTime);
|
|
114
|
-
resolve();
|
|
115
|
-
});
|
|
116
|
-
this.peakQueueLength = Math.max(this.peakQueueLength, this.queue.length);
|
|
117
|
-
this.persistState();
|
|
118
|
-
this.scheduleRefill();
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
scheduleRefill() {
|
|
122
|
-
const now = Date.now();
|
|
123
|
-
const timeUntilRefill = this.windowMs - (now - this.lastRefillTime);
|
|
124
|
-
if (timeUntilRefill > 0) {
|
|
125
|
-
setTimeout(() => {
|
|
126
|
-
this.refillTokens();
|
|
127
|
-
this.processQueue();
|
|
128
|
-
}, timeUntilRefill);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
processQueue() {
|
|
132
|
-
while (this.queue.length > 0 && this.tokens > 0) {
|
|
133
|
-
const next = this.queue.shift();
|
|
134
|
-
if (next) {
|
|
135
|
-
this.tokens--;
|
|
136
|
-
next();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (this.queue.length > 0) {
|
|
140
|
-
this.scheduleRefill();
|
|
141
|
-
}
|
|
142
|
-
this.persistState();
|
|
143
|
-
}
|
|
144
|
-
async execute(fn) {
|
|
145
|
-
await this.acquire();
|
|
146
|
-
try {
|
|
147
|
-
const result = await fn();
|
|
148
|
-
this.completedRequests++;
|
|
149
|
-
this.persistState();
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
this.completedRequests++;
|
|
154
|
-
this.persistState();
|
|
155
|
-
throw error;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async executeAll(fns) {
|
|
159
|
-
return Promise.all(fns.map(fn => this.execute(fn)));
|
|
160
|
-
}
|
|
161
|
-
getState() {
|
|
162
|
-
this.refillTokens();
|
|
163
|
-
const throttleRate = this.totalRequests > 0
|
|
164
|
-
? (this.throttledRequests / this.totalRequests) * 100
|
|
165
|
-
: 0;
|
|
166
|
-
const averageQueueWaitTime = this.throttledRequests > 0
|
|
167
|
-
? this.totalQueueWaitTime / this.throttledRequests
|
|
168
|
-
: 0;
|
|
169
|
-
const currentRate = this.requestsInCurrentWindow / ((Date.now() - this.windowStartTime) / 1000);
|
|
170
|
-
return {
|
|
171
|
-
availableTokens: this.tokens,
|
|
172
|
-
queueLength: this.queue.length,
|
|
173
|
-
maxRequests: this.maxRequests,
|
|
174
|
-
windowMs: this.windowMs,
|
|
175
|
-
totalRequests: this.totalRequests,
|
|
176
|
-
throttledRequests: this.throttledRequests,
|
|
177
|
-
completedRequests: this.completedRequests,
|
|
178
|
-
throttleRate: throttleRate,
|
|
179
|
-
peakQueueLength: this.peakQueueLength,
|
|
180
|
-
averageQueueWaitTime: averageQueueWaitTime,
|
|
181
|
-
peakRequestRate: this.peakRequestRate,
|
|
182
|
-
currentRequestRate: currentRate,
|
|
183
|
-
requestsInCurrentWindow: this.requestsInCurrentWindow
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
let globalRateLimiter = null;
|
|
188
|
-
export function getGlobalRateLimiter(maxRequests, windowMs) {
|
|
189
|
-
if (!globalRateLimiter && maxRequests !== undefined && windowMs !== undefined) {
|
|
190
|
-
globalRateLimiter = new RateLimiter(maxRequests, windowMs);
|
|
191
|
-
}
|
|
192
|
-
return globalRateLimiter;
|
|
193
|
-
}
|
|
194
|
-
export function resetGlobalRateLimiter() {
|
|
195
|
-
globalRateLimiter = null;
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=rate-limiter.js.map
|
|
@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D,CAAC;IACN,CAAC;CACJ;AAED,IAAI,iBAAiB,GAAuB,IAAI,CAAC;AAEjD,MAAM,UAAU,oBAAoB,CAAC,WAAoB,EAAE,QAAiB;IACxE,IAAI,CAAC,iBAAiB,IAAI,WAAW,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5E,iBAAiB,GAAG,IAAI,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,iBAAkB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,sBAAsB;IAClC,iBAAiB,GAAG,IAAI,CAAC;AAC7B,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WorkflowGraph, WorkflowGraphValidationResult } from '../types/index.js';
|
|
2
|
-
export declare function validateWorkflowGraph<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any, FunctionReturnType = any>(graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): WorkflowGraphValidationResult;
|
|
3
|
-
export declare function detectCycles<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any>(graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): string[][];
|
|
4
|
-
export declare function detectUnreachableNodes<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any>(graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): string[];
|
|
5
|
-
export declare function detectOrphanNodes<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any>(graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): string[];
|
|
6
|
-
export declare function calculateGraphDepth<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any>(graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): number;
|
|
7
|
-
//# sourceMappingURL=validate-workflow-graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-workflow-graph.d.ts","sourceRoot":"","sources":["../../src/utilities/validate-workflow-graph.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,6BAA6B,EAE9B,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,qBAAqB,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,kBAAkB,GAAG,GAAG,EACjJ,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,GAC5F,6BAA6B,CA0D/B;AAiED,wBAAgB,YAAY,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,kBAAkB,GAAG,GAAG,EAC1I,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,GAC5F,MAAM,EAAE,EAAE,CAyCZ;AAED,wBAAgB,sBAAsB,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,kBAAkB,GAAG,GAAG,EACpJ,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,GAC5F,MAAM,EAAE,CAoDV;AAED,wBAAgB,iBAAiB,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,kBAAkB,GAAG,GAAG,EAC/I,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,GAC5F,MAAM,EAAE,CA+BV;AAED,wBAAgB,mBAAmB,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,kBAAkB,GAAG,GAAG,EACjJ,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,GAC5F,MAAM,CA4BR"}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { WorkflowNodeTypes, RequestOrFunction } from '../enums/index.js';
|
|
2
|
-
export function validateWorkflowGraph(graph) {
|
|
3
|
-
const errors = [];
|
|
4
|
-
const warnings = [];
|
|
5
|
-
if (!graph.entryPoint) {
|
|
6
|
-
errors.push('Graph must have an entry point');
|
|
7
|
-
}
|
|
8
|
-
else if (!graph.nodes.has(graph.entryPoint)) {
|
|
9
|
-
errors.push(`Entry point '${graph.entryPoint}' does not exist in graph nodes`);
|
|
10
|
-
}
|
|
11
|
-
if (graph.exitPoints) {
|
|
12
|
-
for (const exitPoint of graph.exitPoints) {
|
|
13
|
-
if (!graph.nodes.has(exitPoint)) {
|
|
14
|
-
errors.push(`Exit point '${exitPoint}' does not exist in graph nodes`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
for (const [fromId, edges] of graph.edges) {
|
|
19
|
-
if (!graph.nodes.has(fromId)) {
|
|
20
|
-
errors.push(`Edge source node '${fromId}' does not exist in graph`);
|
|
21
|
-
}
|
|
22
|
-
for (const edge of edges) {
|
|
23
|
-
if (!graph.nodes.has(edge.to)) {
|
|
24
|
-
errors.push(`Edge target node '${edge.to}' (from '${fromId}') does not exist in graph`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
for (const [nodeId, node] of graph.nodes) {
|
|
29
|
-
const nodeErrors = validateNode(node, graph);
|
|
30
|
-
errors.push(...nodeErrors);
|
|
31
|
-
}
|
|
32
|
-
const cycles = detectCycles(graph);
|
|
33
|
-
if (cycles.length > 0) {
|
|
34
|
-
errors.push(`Graph contains ${cycles.length} cycle(s), violating DAG constraints. Cycles: ${cycles.map(c => c.join(' → ')).join('; ')}`);
|
|
35
|
-
}
|
|
36
|
-
const unreachableNodes = detectUnreachableNodes(graph);
|
|
37
|
-
if (unreachableNodes.length > 0) {
|
|
38
|
-
warnings.push(`Found ${unreachableNodes.length} unreachable node(s): ${unreachableNodes.join(', ')}`);
|
|
39
|
-
}
|
|
40
|
-
const orphanNodes = detectOrphanNodes(graph);
|
|
41
|
-
if (orphanNodes.length > 0) {
|
|
42
|
-
warnings.push(`Found ${orphanNodes.length} orphan node(s) with no connections: ${orphanNodes.join(', ')}`);
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
valid: errors.length === 0,
|
|
46
|
-
errors,
|
|
47
|
-
warnings,
|
|
48
|
-
cycles: cycles.length > 0 ? cycles : undefined,
|
|
49
|
-
unreachableNodes: unreachableNodes.length > 0 ? unreachableNodes : undefined,
|
|
50
|
-
orphanNodes: orphanNodes.length > 0 ? orphanNodes : undefined
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function validateNode(node, graph) {
|
|
54
|
-
const errors = [];
|
|
55
|
-
switch (node.type) {
|
|
56
|
-
case WorkflowNodeTypes.PHASE:
|
|
57
|
-
if (!node.phase) {
|
|
58
|
-
errors.push(`Phase node '${node.id}' is missing phase configuration`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
const hasRequests = node.phase.requests && node.phase.requests.length > 0;
|
|
62
|
-
const hasFunctions = node.phase.functions && node.phase.functions.length > 0;
|
|
63
|
-
const hasItems = node.phase.items && node.phase.items.length > 0;
|
|
64
|
-
if (!hasRequests && !hasFunctions && !hasItems) {
|
|
65
|
-
errors.push(`Phase node '${node.id}' has no requests, functions, or items`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
69
|
-
case WorkflowNodeTypes.BRANCH:
|
|
70
|
-
if (!node.branch) {
|
|
71
|
-
errors.push(`Branch node '${node.id}' is missing branch configuration`);
|
|
72
|
-
}
|
|
73
|
-
else if (!node.branch.phases || node.branch.phases.length === 0) {
|
|
74
|
-
errors.push(`Branch node '${node.id}' has no phases`);
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case WorkflowNodeTypes.CONDITIONAL:
|
|
78
|
-
if (!node.condition || typeof node.condition.evaluate !== RequestOrFunction.FUNCTION) {
|
|
79
|
-
errors.push(`Conditional node '${node.id}' is missing evaluation function`);
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
case WorkflowNodeTypes.PARALLEL_GROUP:
|
|
83
|
-
if (!node.parallelNodes || node.parallelNodes.length === 0) {
|
|
84
|
-
errors.push(`Parallel group node '${node.id}' has no parallel nodes specified`);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
for (const parallelNodeId of node.parallelNodes) {
|
|
88
|
-
if (!graph.nodes.has(parallelNodeId)) {
|
|
89
|
-
errors.push(`Parallel group node '${node.id}' references non-existent node '${parallelNodeId}'`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case WorkflowNodeTypes.MERGE_POINT:
|
|
95
|
-
if (!node.waitForNodes || node.waitForNodes.length === 0) {
|
|
96
|
-
errors.push(`Merge point node '${node.id}' has no nodes to wait for`);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
for (const waitForNodeId of node.waitForNodes) {
|
|
100
|
-
if (!graph.nodes.has(waitForNodeId)) {
|
|
101
|
-
errors.push(`Merge point node '${node.id}' references non-existent node '${waitForNodeId}'`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
return errors;
|
|
108
|
-
}
|
|
109
|
-
export function detectCycles(graph) {
|
|
110
|
-
const cycles = [];
|
|
111
|
-
const visited = new Set();
|
|
112
|
-
const recursionStack = new Set();
|
|
113
|
-
const currentPath = [];
|
|
114
|
-
function dfs(nodeId) {
|
|
115
|
-
visited.add(nodeId);
|
|
116
|
-
recursionStack.add(nodeId);
|
|
117
|
-
currentPath.push(nodeId);
|
|
118
|
-
const edges = graph.edges.get(nodeId) || [];
|
|
119
|
-
for (const edge of edges) {
|
|
120
|
-
const targetId = edge.to;
|
|
121
|
-
if (!visited.has(targetId)) {
|
|
122
|
-
dfs(targetId);
|
|
123
|
-
}
|
|
124
|
-
else if (recursionStack.has(targetId)) {
|
|
125
|
-
const cycleStartIndex = currentPath.indexOf(targetId);
|
|
126
|
-
const cycle = currentPath.slice(cycleStartIndex);
|
|
127
|
-
cycle.push(targetId);
|
|
128
|
-
cycles.push(cycle);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
currentPath.pop();
|
|
132
|
-
recursionStack.delete(nodeId);
|
|
133
|
-
}
|
|
134
|
-
if (graph.entryPoint && graph.nodes.has(graph.entryPoint)) {
|
|
135
|
-
dfs(graph.entryPoint);
|
|
136
|
-
}
|
|
137
|
-
for (const nodeId of graph.nodes.keys()) {
|
|
138
|
-
if (!visited.has(nodeId)) {
|
|
139
|
-
dfs(nodeId);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return cycles;
|
|
143
|
-
}
|
|
144
|
-
export function detectUnreachableNodes(graph) {
|
|
145
|
-
if (!graph.entryPoint) {
|
|
146
|
-
return Array.from(graph.nodes.keys());
|
|
147
|
-
}
|
|
148
|
-
const reachable = new Set();
|
|
149
|
-
const queue = [graph.entryPoint];
|
|
150
|
-
while (queue.length > 0) {
|
|
151
|
-
const nodeId = queue.shift();
|
|
152
|
-
if (reachable.has(nodeId)) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
reachable.add(nodeId);
|
|
156
|
-
const node = graph.nodes.get(nodeId);
|
|
157
|
-
if (!node)
|
|
158
|
-
continue;
|
|
159
|
-
const edges = graph.edges.get(nodeId) || [];
|
|
160
|
-
for (const edge of edges) {
|
|
161
|
-
if (!reachable.has(edge.to)) {
|
|
162
|
-
queue.push(edge.to);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (node.type === WorkflowNodeTypes.PARALLEL_GROUP && node.parallelNodes) {
|
|
166
|
-
for (const parallelNodeId of node.parallelNodes) {
|
|
167
|
-
if (!reachable.has(parallelNodeId)) {
|
|
168
|
-
queue.push(parallelNodeId);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (node.type === WorkflowNodeTypes.MERGE_POINT && node.waitForNodes) {
|
|
173
|
-
for (const waitForNodeId of node.waitForNodes) {
|
|
174
|
-
if (!reachable.has(waitForNodeId)) {
|
|
175
|
-
queue.push(waitForNodeId);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const unreachable = [];
|
|
181
|
-
for (const nodeId of graph.nodes.keys()) {
|
|
182
|
-
if (!reachable.has(nodeId)) {
|
|
183
|
-
unreachable.push(nodeId);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return unreachable;
|
|
187
|
-
}
|
|
188
|
-
export function detectOrphanNodes(graph) {
|
|
189
|
-
const hasOutgoing = new Set();
|
|
190
|
-
const hasIncoming = new Set();
|
|
191
|
-
for (const [fromId, edges] of graph.edges) {
|
|
192
|
-
if (edges.length > 0) {
|
|
193
|
-
hasOutgoing.add(fromId);
|
|
194
|
-
}
|
|
195
|
-
for (const edge of edges) {
|
|
196
|
-
hasIncoming.add(edge.to);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const orphans = [];
|
|
200
|
-
for (const nodeId of graph.nodes.keys()) {
|
|
201
|
-
if (nodeId === graph.entryPoint) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
if (graph.exitPoints && graph.exitPoints.includes(nodeId)) {
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (!hasOutgoing.has(nodeId) && !hasIncoming.has(nodeId)) {
|
|
208
|
-
orphans.push(nodeId);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return orphans;
|
|
212
|
-
}
|
|
213
|
-
export function calculateGraphDepth(graph) {
|
|
214
|
-
if (!graph.entryPoint) {
|
|
215
|
-
return 0;
|
|
216
|
-
}
|
|
217
|
-
const depths = new Map();
|
|
218
|
-
const visited = new Set();
|
|
219
|
-
function dfs(nodeId, depth) {
|
|
220
|
-
if (visited.has(nodeId)) {
|
|
221
|
-
return depths.get(nodeId) || 0;
|
|
222
|
-
}
|
|
223
|
-
visited.add(nodeId);
|
|
224
|
-
depths.set(nodeId, depth);
|
|
225
|
-
const edges = graph.edges.get(nodeId) || [];
|
|
226
|
-
let maxDepth = depth;
|
|
227
|
-
for (const edge of edges) {
|
|
228
|
-
const childDepth = dfs(edge.to, depth + 1);
|
|
229
|
-
maxDepth = Math.max(maxDepth, childDepth);
|
|
230
|
-
}
|
|
231
|
-
return maxDepth;
|
|
232
|
-
}
|
|
233
|
-
return dfs(graph.entryPoint, 0);
|
|
234
|
-
}
|
|
235
|
-
//# sourceMappingURL=validate-workflow-graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-workflow-graph.js","sourceRoot":"","sources":["../../src/utilities/validate-workflow-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAOxE,MAAM,UAAU,qBAAqB,CACnC,KAA6F;IAE7F,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,UAA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MAAM,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC3C,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { WorkflowGraph, EdgeCondition, STABLE_WORKFLOW_PHASE, STABLE_WORKFLOW_BRANCH, ConditionalEvaluationContext } from '../types/index.js';
|
|
2
|
-
export declare class WorkflowGraphBuilder<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
3
|
-
private nodes;
|
|
4
|
-
private edges;
|
|
5
|
-
private entryPointId?;
|
|
6
|
-
private exitPointIds;
|
|
7
|
-
private metadata;
|
|
8
|
-
private enforceDAG;
|
|
9
|
-
addPhase(id: string, phase: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): this;
|
|
10
|
-
addBranch(id: string, branch: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): this;
|
|
11
|
-
addConditional(id: string, evaluate: (context: ConditionalEvaluationContext<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => string | Promise<string>): this;
|
|
12
|
-
addParallelGroup(id: string, nodeIds: string[]): this;
|
|
13
|
-
addMergePoint(id: string, waitForNodes: string[]): this;
|
|
14
|
-
connect(from: string, to: string, options?: {
|
|
15
|
-
condition?: EdgeCondition<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
16
|
-
weight?: number;
|
|
17
|
-
label?: string;
|
|
18
|
-
metadata?: Record<string, any>;
|
|
19
|
-
}): this;
|
|
20
|
-
connectSequence(...nodeIds: string[]): this;
|
|
21
|
-
connectToMany(from: string, toNodes: string[], condition?: EdgeCondition<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): this;
|
|
22
|
-
connectManyTo(fromNodes: string[], to: string, condition?: EdgeCondition<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>): this;
|
|
23
|
-
setEntryPoint(id: string): this;
|
|
24
|
-
addExitPoint(id: string): this;
|
|
25
|
-
setMetadata(metadata: Record<string, any>): this;
|
|
26
|
-
setEnforceDAG(enforce: boolean): this;
|
|
27
|
-
build(): WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
28
|
-
private detectExitPoints;
|
|
29
|
-
clear(): this;
|
|
30
|
-
getNodeCount(): number;
|
|
31
|
-
getEdgeCount(): number;
|
|
32
|
-
hasNode(id: string): boolean;
|
|
33
|
-
removeNode(id: string): this;
|
|
34
|
-
removeEdge(from: string, to: string): this;
|
|
35
|
-
}
|
|
36
|
-
export declare function createLinearWorkflowGraph<T = any, R = any>(phases: STABLE_WORKFLOW_PHASE<T, R>[]): WorkflowGraph<T, R>;
|
|
37
|
-
//# sourceMappingURL=workflow-graph-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-graph-builder.d.ts","sourceRoot":"","sources":["../../src/utilities/workflow-graph-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAGb,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAI3B,qBAAa,oBAAoB,CAAC,eAAe,GAAG,GAAG,EAAE,gBAAgB,GAAG,GAAG,EAAE,gBAAgB,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,kBAAkB,GAAG,GAAG;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