@emmvish/stable-request 2.2.1 → 2.3.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/README.md +77 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/core/stable-api-gateway.js +17 -1
- package/dist/core/stable-api-gateway.js.map +1 -1
- package/dist/core/stable-function.d.ts +9 -1
- package/dist/core/stable-function.d.ts.map +1 -1
- package/dist/core/stable-function.js.map +1 -1
- package/dist/core/stable-request.js.map +1 -1
- package/dist/core/stable-workflow-graph.d.ts +1 -1
- package/dist/core/stable-workflow-graph.d.ts.map +1 -1
- package/dist/core/stable-workflow.d.ts +1 -1
- package/dist/core/stable-workflow.d.ts.map +1 -1
- package/dist/core/stable-workflow.js +20 -3
- package/dist/core/stable-workflow.js.map +1 -1
- package/dist/types/index.d.ts +151 -146
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utilities/execute-branch-workflow.d.ts +1 -1
- package/dist/utilities/execute-branch-workflow.d.ts.map +1 -1
- package/dist/utilities/execute-branch-workflow.js +133 -2
- package/dist/utilities/execute-branch-workflow.js.map +1 -1
- package/dist/utilities/execute-concurrently.d.ts +1 -1
- package/dist/utilities/execute-concurrently.d.ts.map +1 -1
- package/dist/utilities/execute-concurrently.js +128 -6
- package/dist/utilities/execute-concurrently.js.map +1 -1
- package/dist/utilities/execute-gateway-item.d.ts +3 -3
- package/dist/utilities/execute-gateway-item.d.ts.map +1 -1
- package/dist/utilities/execute-gateway-item.js.map +1 -1
- package/dist/utilities/execute-non-linear-workflow.d.ts +1 -1
- package/dist/utilities/execute-non-linear-workflow.d.ts.map +1 -1
- package/dist/utilities/execute-non-linear-workflow.js +14 -4
- package/dist/utilities/execute-non-linear-workflow.js.map +1 -1
- package/dist/utilities/execute-phase.d.ts +1 -1
- package/dist/utilities/execute-phase.d.ts.map +1 -1
- package/dist/utilities/execute-phase.js +14 -0
- package/dist/utilities/execute-phase.js.map +1 -1
- package/dist/utilities/execute-sequentially.d.ts +1 -1
- package/dist/utilities/execute-sequentially.d.ts.map +1 -1
- package/dist/utilities/execute-sequentially.js +4 -6
- package/dist/utilities/execute-sequentially.js.map +1 -1
- package/dist/utilities/execute-workflow-graph.d.ts +1 -1
- package/dist/utilities/execute-workflow-graph.d.ts.map +1 -1
- package/dist/utilities/execute-workflow-graph.js +96 -2
- package/dist/utilities/execute-workflow-graph.js.map +1 -1
- package/dist/utilities/extract-common-request-config-options.d.ts +1 -1
- package/dist/utilities/extract-common-request-config-options.d.ts.map +1 -1
- package/dist/utilities/extract-common-request-config-options.js +3 -2
- package/dist/utilities/extract-common-request-config-options.js.map +1 -1
- package/dist/utilities/metrics-aggregator.d.ts +5 -5
- package/dist/utilities/metrics-aggregator.d.ts.map +1 -1
- package/dist/utilities/metrics-aggregator.js.map +1 -1
- package/dist/utilities/prepare-api-function-options.d.ts +1 -1
- package/dist/utilities/prepare-api-function-options.d.ts.map +1 -1
- package/dist/utilities/prepare-api-function-options.js.map +1 -1
- package/dist/utilities/prepare-api-request-data.d.ts +1 -1
- package/dist/utilities/prepare-api-request-data.d.ts.map +1 -1
- package/dist/utilities/prepare-api-request-data.js.map +1 -1
- package/dist/utilities/prepare-api-request-options.d.ts +1 -1
- package/dist/utilities/prepare-api-request-options.d.ts.map +1 -1
- package/dist/utilities/prepare-api-request-options.js +9 -6
- package/dist/utilities/prepare-api-request-options.js.map +1 -1
- package/dist/utilities/validate-workflow-graph.d.ts +5 -5
- package/dist/utilities/validate-workflow-graph.d.ts.map +1 -1
- package/dist/utilities/validate-workflow-graph.js.map +1 -1
- package/dist/utilities/workflow-graph-builder.d.ts +8 -8
- package/dist/utilities/workflow-graph-builder.d.ts.map +1 -1
- package/dist/utilities/workflow-graph-builder.js.map +1 -1
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -132,26 +132,28 @@ export interface API_GATEWAY_OPTIONS<RequestDataType = any, ResponseDataType = a
|
|
|
132
132
|
commonStatePersistence?: StatePersistenceConfig;
|
|
133
133
|
commonExecutionTimeout?: number;
|
|
134
134
|
commonFunctionHookParams?: FunctionHookParams;
|
|
135
|
-
commonFunctionResponseAnalyzer?:
|
|
135
|
+
commonFunctionResponseAnalyzer?: (options: FunctionResponseAnalysisHookOptions<FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
|
|
136
136
|
commonReturnResult?: boolean;
|
|
137
|
-
commonFinalFunctionErrorAnalyzer?:
|
|
138
|
-
commonHandleFunctionErrors?:
|
|
139
|
-
commonHandleSuccessfulFunctionAttemptData?:
|
|
140
|
-
commonFunctionPreExecution?:
|
|
141
|
-
commonFunctionCache?:
|
|
137
|
+
commonFinalFunctionErrorAnalyzer?: (options: FinalFunctionErrorAnalysisHookOptions<FunctionArgsType>) => boolean | Promise<boolean>;
|
|
138
|
+
commonHandleFunctionErrors?: (options: HandleFunctionErrorHookOptions<FunctionArgsType>) => any | Promise<any>;
|
|
139
|
+
commonHandleSuccessfulFunctionAttemptData?: (options: HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
|
|
140
|
+
commonFunctionPreExecution?: FunctionPreExecutionOptions<FunctionArgsType, FunctionReturnType>;
|
|
141
|
+
commonFunctionCache?: FunctionCacheConfig<FunctionArgsType, FunctionReturnType>;
|
|
142
142
|
concurrentExecution?: boolean;
|
|
143
|
-
requestGroups?: RequestGroup<RequestDataType, ResponseDataType>[];
|
|
143
|
+
requestGroups?: RequestGroup<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
144
144
|
stopOnFirstError?: boolean;
|
|
145
145
|
sharedBuffer?: Record<string, any>;
|
|
146
146
|
maxConcurrentRequests?: number;
|
|
147
147
|
rateLimit?: RateLimitConfig;
|
|
148
|
-
circuitBreaker?: CircuitBreakerConfig;
|
|
148
|
+
circuitBreaker?: CircuitBreakerConfig | CircuitBreaker;
|
|
149
149
|
executionContext?: Partial<ExecutionContext>;
|
|
150
150
|
metricsGuardrails?: MetricsGuardrails;
|
|
151
|
+
enableRacing?: boolean;
|
|
152
|
+
maxTimeout?: number;
|
|
151
153
|
}
|
|
152
|
-
export interface RequestGroup<RequestDataType = any, ResponseDataType = any> {
|
|
154
|
+
export interface RequestGroup<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
153
155
|
id: string;
|
|
154
|
-
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType>, "concurrentExecution" | "stopOnFirstError" | "requestGroups" | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker">;
|
|
156
|
+
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, "concurrentExecution" | "stopOnFirstError" | "requestGroups" | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker" | "maxTimeout" | "executionContext" | "enableRacing" | "metricsGuardrails">;
|
|
155
157
|
}
|
|
156
158
|
export type API_GATEWAY_REQUEST_OPTIONS_TYPE<RequestDataType, ResponseDataType> = Omit<STABLE_REQUEST<RequestDataType, ResponseDataType>, 'reqData'> & {
|
|
157
159
|
reqData?: Partial<STABLE_REQUEST<RequestDataType, ResponseDataType>['reqData']>;
|
|
@@ -161,32 +163,32 @@ export interface API_GATEWAY_REQUEST<RequestDataType = any, ResponseDataType = a
|
|
|
161
163
|
groupId?: string;
|
|
162
164
|
requestOptions: API_GATEWAY_REQUEST_OPTIONS_TYPE<RequestDataType, ResponseDataType>;
|
|
163
165
|
}
|
|
164
|
-
export type API_GATEWAY_FUNCTION_OPTIONS_TYPE<
|
|
165
|
-
fn?: STABLE_FUNCTION<
|
|
166
|
-
args?:
|
|
166
|
+
export type API_GATEWAY_FUNCTION_OPTIONS_TYPE<FunctionArgsType extends any[], FunctionReturnType> = Omit<STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>, 'fn' | 'args'> & {
|
|
167
|
+
fn?: STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>['fn'];
|
|
168
|
+
args?: FunctionArgsType;
|
|
167
169
|
};
|
|
168
|
-
export interface API_GATEWAY_FUNCTION<
|
|
170
|
+
export interface API_GATEWAY_FUNCTION<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
169
171
|
id: string;
|
|
170
172
|
groupId?: string;
|
|
171
|
-
functionOptions: API_GATEWAY_FUNCTION_OPTIONS_TYPE<
|
|
173
|
+
functionOptions: API_GATEWAY_FUNCTION_OPTIONS_TYPE<FunctionArgsType, FunctionReturnType>;
|
|
172
174
|
}
|
|
173
175
|
export type RequestOrFunctionType = RequestOrFunction.REQUEST | RequestOrFunction.FUNCTION;
|
|
174
|
-
export type API_GATEWAY_ITEM<RequestDataType = any, ResponseDataType = any,
|
|
176
|
+
export type API_GATEWAY_ITEM<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> = {
|
|
175
177
|
type: RequestOrFunction.REQUEST;
|
|
176
178
|
request: API_GATEWAY_REQUEST<RequestDataType, ResponseDataType>;
|
|
177
179
|
} | {
|
|
178
180
|
type: RequestOrFunction.FUNCTION;
|
|
179
|
-
function: API_GATEWAY_FUNCTION<
|
|
181
|
+
function: API_GATEWAY_FUNCTION<FunctionArgsType, FunctionReturnType>;
|
|
180
182
|
};
|
|
181
|
-
export interface API_GATEWAY_RESPONSE<ResponseDataType = any> {
|
|
183
|
+
export interface API_GATEWAY_RESPONSE<ResponseDataType = any, FunctionReturnType = any> {
|
|
182
184
|
requestId: string;
|
|
183
185
|
groupId?: string;
|
|
184
186
|
success: boolean;
|
|
185
|
-
data?: ResponseDataType;
|
|
187
|
+
data?: ResponseDataType | FunctionReturnType | boolean;
|
|
186
188
|
error?: string;
|
|
187
189
|
type?: RequestOrFunctionType;
|
|
188
190
|
}
|
|
189
|
-
export interface API_GATEWAY_RESULT<ResponseDataType = any> extends Array<API_GATEWAY_RESPONSE<ResponseDataType>> {
|
|
191
|
+
export interface API_GATEWAY_RESULT<ResponseDataType = any, FunctionReturnType = any> extends Array<API_GATEWAY_RESPONSE<ResponseDataType, FunctionReturnType>> {
|
|
190
192
|
metrics?: {
|
|
191
193
|
totalRequests: number;
|
|
192
194
|
successfulRequests: number;
|
|
@@ -237,13 +239,13 @@ export interface ReqFnResponse<ResponseDataType = any> {
|
|
|
237
239
|
};
|
|
238
240
|
fromCache?: boolean;
|
|
239
241
|
}
|
|
240
|
-
export interface FnExecResponse<
|
|
242
|
+
export interface FnExecResponse<FunctionReturnType = any> {
|
|
241
243
|
ok: boolean;
|
|
242
244
|
isRetryable: boolean;
|
|
243
245
|
timestamp: string;
|
|
244
246
|
executionTime: number;
|
|
245
247
|
error?: string;
|
|
246
|
-
data?:
|
|
248
|
+
data?: FunctionReturnType | {
|
|
247
249
|
trialMode: TRIAL_MODE_OPTIONS;
|
|
248
250
|
};
|
|
249
251
|
fromCache?: boolean;
|
|
@@ -305,43 +307,43 @@ export interface FunctionHookParams {
|
|
|
305
307
|
handleErrorsParams?: any;
|
|
306
308
|
finalErrorAnalyzerParams?: any;
|
|
307
309
|
}
|
|
308
|
-
interface FunctionObservabilityHooksOptions<
|
|
309
|
-
fn: (...args:
|
|
310
|
-
args:
|
|
310
|
+
interface FunctionObservabilityHooksOptions<FunctionArgsType extends any[] = any[]> {
|
|
311
|
+
fn: (...args: FunctionArgsType) => any;
|
|
312
|
+
args: FunctionArgsType;
|
|
311
313
|
params?: any;
|
|
312
314
|
maxSerializableChars?: number;
|
|
313
315
|
preExecutionResult?: any;
|
|
314
316
|
commonBuffer?: Record<string, any>;
|
|
315
317
|
executionContext?: ExecutionContext;
|
|
316
318
|
}
|
|
317
|
-
interface FunctionAnalysisHookOptions<
|
|
319
|
+
interface FunctionAnalysisHookOptions<FunctionArgsType extends any[] = any[]> extends Omit<FunctionObservabilityHooksOptions<FunctionArgsType>, "maxSerializableChars"> {
|
|
318
320
|
trialMode?: TRIAL_MODE_OPTIONS;
|
|
319
321
|
params?: any;
|
|
320
322
|
preExecutionResult?: any;
|
|
321
323
|
executionContext?: ExecutionContext;
|
|
322
324
|
commonBuffer?: Record<string, any>;
|
|
323
325
|
}
|
|
324
|
-
export interface FunctionResponseAnalysisHookOptions<
|
|
325
|
-
data:
|
|
326
|
+
export interface FunctionResponseAnalysisHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends FunctionAnalysisHookOptions<FunctionArgsType> {
|
|
327
|
+
data: FunctionReturnType;
|
|
326
328
|
}
|
|
327
|
-
export interface FinalFunctionErrorAnalysisHookOptions<
|
|
329
|
+
export interface FinalFunctionErrorAnalysisHookOptions<FunctionArgsType extends any[] = any[]> extends FunctionAnalysisHookOptions<FunctionArgsType> {
|
|
328
330
|
error: any;
|
|
329
331
|
}
|
|
330
|
-
export interface HandleFunctionErrorHookOptions<
|
|
332
|
+
export interface HandleFunctionErrorHookOptions<FunctionArgsType extends any[] = any[]> extends FunctionObservabilityHooksOptions<FunctionArgsType> {
|
|
331
333
|
errorLog: FUNCTION_ERROR_LOG;
|
|
332
334
|
}
|
|
333
|
-
export interface HandleSuccessfulFunctionAttemptDataHookOptions<
|
|
334
|
-
successfulAttemptData: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<
|
|
335
|
+
export interface HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends FunctionObservabilityHooksOptions<FunctionArgsType> {
|
|
336
|
+
successfulAttemptData: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType>;
|
|
335
337
|
}
|
|
336
338
|
export interface PreExecutionHookOptions<RequestDataType = any, ResponseDataType = any> {
|
|
337
339
|
inputParams?: any;
|
|
338
340
|
commonBuffer?: Record<string, any>;
|
|
339
341
|
stableRequestOptions: STABLE_REQUEST<RequestDataType, ResponseDataType>;
|
|
340
342
|
}
|
|
341
|
-
export interface FunctionPreExecutionHookOptions<
|
|
343
|
+
export interface FunctionPreExecutionHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
342
344
|
inputParams?: any;
|
|
343
345
|
commonBuffer?: Record<string, any>;
|
|
344
|
-
stableFunctionOptions: STABLE_FUNCTION<
|
|
346
|
+
stableFunctionOptions: STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>;
|
|
345
347
|
}
|
|
346
348
|
interface WorkflowPreExecutionHookOptions {
|
|
347
349
|
params?: any;
|
|
@@ -349,15 +351,15 @@ interface WorkflowPreExecutionHookOptions {
|
|
|
349
351
|
workflowId: string;
|
|
350
352
|
branchId?: string;
|
|
351
353
|
}
|
|
352
|
-
export interface PrePhaseExecutionHookOptions<RequestDataType = any, ResponseDataType = any> extends WorkflowPreExecutionHookOptions {
|
|
354
|
+
export interface PrePhaseExecutionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends WorkflowPreExecutionHookOptions {
|
|
353
355
|
phaseId: string;
|
|
354
356
|
phaseIndex: number;
|
|
355
|
-
phase: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType>;
|
|
357
|
+
phase: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
356
358
|
}
|
|
357
|
-
export interface PreBranchExecutionHookOptions<RequestDataType = any, ResponseDataType = any> extends Omit<WorkflowPreExecutionHookOptions, 'branchId'> {
|
|
359
|
+
export interface PreBranchExecutionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends Omit<WorkflowPreExecutionHookOptions, 'branchId'> {
|
|
358
360
|
branchId: string;
|
|
359
361
|
branchIndex: number;
|
|
360
|
-
branch: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType>;
|
|
362
|
+
branch: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
361
363
|
}
|
|
362
364
|
export interface RequestPreExecutionOptions<RequestDataType = any, ResponseDataType = any> {
|
|
363
365
|
preExecutionHook: (options: PreExecutionHookOptions<RequestDataType, ResponseDataType>) => any | Promise<any>;
|
|
@@ -365,8 +367,8 @@ export interface RequestPreExecutionOptions<RequestDataType = any, ResponseDataT
|
|
|
365
367
|
applyPreExecutionConfigOverride?: boolean;
|
|
366
368
|
continueOnPreExecutionHookFailure?: boolean;
|
|
367
369
|
}
|
|
368
|
-
export interface FunctionPreExecutionOptions<
|
|
369
|
-
preExecutionHook: (options: FunctionPreExecutionHookOptions<
|
|
370
|
+
export interface FunctionPreExecutionOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
371
|
+
preExecutionHook: (options: FunctionPreExecutionHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
|
|
370
372
|
preExecutionHookParams?: any;
|
|
371
373
|
applyPreExecutionConfigOverride?: boolean;
|
|
372
374
|
continueOnPreExecutionHookFailure?: boolean;
|
|
@@ -408,10 +410,10 @@ export interface STABLE_REQUEST<RequestDataType = any, ResponseDataType = any> {
|
|
|
408
410
|
statePersistence?: StatePersistenceConfig;
|
|
409
411
|
metricsGuardrails?: MetricsGuardrails;
|
|
410
412
|
}
|
|
411
|
-
export interface STABLE_FUNCTION<
|
|
412
|
-
fn: (...args:
|
|
413
|
-
args:
|
|
414
|
-
responseAnalyzer?: (options: FunctionResponseAnalysisHookOptions<
|
|
413
|
+
export interface STABLE_FUNCTION<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
414
|
+
fn: (...args: FunctionArgsType) => FunctionReturnType | Promise<FunctionReturnType>;
|
|
415
|
+
args: FunctionArgsType;
|
|
416
|
+
responseAnalyzer?: (options: FunctionResponseAnalysisHookOptions<FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
|
|
415
417
|
returnResult?: boolean;
|
|
416
418
|
attempts?: number;
|
|
417
419
|
performAllAttempts?: boolean;
|
|
@@ -420,16 +422,16 @@ export interface STABLE_FUNCTION<TArgs extends any[] = any[], TReturn = any> {
|
|
|
420
422
|
retryStrategy?: RETRY_STRATEGY_TYPES;
|
|
421
423
|
jitter?: number;
|
|
422
424
|
logAllErrors?: boolean;
|
|
423
|
-
handleErrors?: (options: HandleFunctionErrorHookOptions<
|
|
425
|
+
handleErrors?: (options: HandleFunctionErrorHookOptions<FunctionArgsType>) => any | Promise<any>;
|
|
424
426
|
logAllSuccessfulAttempts?: boolean;
|
|
425
|
-
handleSuccessfulAttemptData?: (options: HandleSuccessfulFunctionAttemptDataHookOptions<
|
|
427
|
+
handleSuccessfulAttemptData?: (options: HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
|
|
426
428
|
maxSerializableChars?: number;
|
|
427
|
-
finalErrorAnalyzer?: (options: FinalFunctionErrorAnalysisHookOptions<
|
|
429
|
+
finalErrorAnalyzer?: (options: FinalFunctionErrorAnalysisHookOptions<FunctionArgsType>) => boolean | Promise<boolean>;
|
|
428
430
|
trialMode?: TRIAL_MODE_OPTIONS;
|
|
429
431
|
hookParams?: FunctionHookParams;
|
|
430
|
-
preExecution?: FunctionPreExecutionOptions<
|
|
432
|
+
preExecution?: FunctionPreExecutionOptions<FunctionArgsType, FunctionReturnType>;
|
|
431
433
|
commonBuffer?: Record<string, any>;
|
|
432
|
-
cache?: FunctionCacheConfig<
|
|
434
|
+
cache?: FunctionCacheConfig<FunctionArgsType, FunctionReturnType>;
|
|
433
435
|
executionContext?: ExecutionContext;
|
|
434
436
|
circuitBreaker?: CircuitBreakerConfig | CircuitBreaker;
|
|
435
437
|
statePersistence?: StatePersistenceConfig;
|
|
@@ -440,7 +442,7 @@ export interface STABLE_FUNCTION<TArgs extends any[] = any[], TReturn = any> {
|
|
|
440
442
|
}
|
|
441
443
|
export interface STABLE_REQUEST_RESULT<ResponseDataType = any> {
|
|
442
444
|
success: boolean;
|
|
443
|
-
data?: ResponseDataType;
|
|
445
|
+
data?: ResponseDataType | boolean;
|
|
444
446
|
error?: string;
|
|
445
447
|
errorLogs?: ERROR_LOG[];
|
|
446
448
|
successfulAttempts?: SUCCESSFUL_ATTEMPT_DATA<ResponseDataType>[];
|
|
@@ -457,12 +459,12 @@ export interface STABLE_REQUEST_RESULT<ResponseDataType = any> {
|
|
|
457
459
|
validation?: MetricsValidationResult;
|
|
458
460
|
};
|
|
459
461
|
}
|
|
460
|
-
export interface STABLE_FUNCTION_RESULT<
|
|
462
|
+
export interface STABLE_FUNCTION_RESULT<FunctionReturnType = any, ReturnResult extends boolean = boolean> {
|
|
461
463
|
success: boolean;
|
|
462
|
-
data?:
|
|
464
|
+
data?: ReturnResult extends true ? FunctionReturnType : boolean;
|
|
463
465
|
error?: string;
|
|
464
466
|
errorLogs?: FUNCTION_ERROR_LOG[];
|
|
465
|
-
successfulAttempts?: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<
|
|
467
|
+
successfulAttempts?: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType>[];
|
|
466
468
|
metrics?: {
|
|
467
469
|
totalAttempts: number;
|
|
468
470
|
successfulAttempts: number;
|
|
@@ -485,11 +487,11 @@ export interface SUCCESSFUL_ATTEMPT_DATA<ResponseDataType = any> {
|
|
|
485
487
|
data: ResponseDataType;
|
|
486
488
|
statusCode: number;
|
|
487
489
|
}
|
|
488
|
-
export interface SUCCESSFUL_FUNCTION_ATTEMPT_DATA<
|
|
490
|
+
export interface SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType = any> {
|
|
489
491
|
attempt: string;
|
|
490
492
|
timestamp: string;
|
|
491
493
|
executionTime: number;
|
|
492
|
-
data:
|
|
494
|
+
data: FunctionReturnType;
|
|
493
495
|
}
|
|
494
496
|
export interface FUNCTION_ERROR_LOG {
|
|
495
497
|
timestamp: string;
|
|
@@ -507,8 +509,8 @@ export type VALID_REQUEST_PROTOCOL_TYPES = VALID_REQUEST_PROTOCOLS.HTTP | VALID_
|
|
|
507
509
|
export interface STABLE_WORKFLOW_PHASE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
508
510
|
id?: string;
|
|
509
511
|
requests?: API_GATEWAY_REQUEST<RequestDataType, ResponseDataType>[];
|
|
510
|
-
functions?: API_GATEWAY_FUNCTION<
|
|
511
|
-
items?: API_GATEWAY_ITEM<RequestDataType, ResponseDataType,
|
|
512
|
+
functions?: API_GATEWAY_FUNCTION<FunctionArgsType, FunctionReturnType>[];
|
|
513
|
+
items?: API_GATEWAY_ITEM<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
512
514
|
concurrentExecution?: boolean;
|
|
513
515
|
stopOnFirstError?: boolean;
|
|
514
516
|
markConcurrentPhase?: boolean;
|
|
@@ -518,35 +520,36 @@ export interface STABLE_WORKFLOW_PHASE<RequestDataType = any, ResponseDataType =
|
|
|
518
520
|
maxReplayCount?: number;
|
|
519
521
|
allowReplay?: boolean;
|
|
520
522
|
allowSkip?: boolean;
|
|
521
|
-
phaseDecisionHook?: (options: PhaseDecisionHookOptions<ResponseDataType>) => PhaseExecutionDecision | Promise<PhaseExecutionDecision
|
|
522
|
-
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker">;
|
|
523
|
+
phaseDecisionHook?: (options: PhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
524
|
+
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker" | "maxTimeout" | "executionContext" | "metricsGuardrails">;
|
|
523
525
|
branchId?: string;
|
|
524
526
|
statePersistence?: StatePersistenceConfig;
|
|
525
527
|
metricsGuardrails?: MetricsGuardrails;
|
|
528
|
+
maxTimeout?: number;
|
|
526
529
|
}
|
|
527
|
-
export interface STABLE_WORKFLOW_OPTIONS<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError'> {
|
|
530
|
+
export interface STABLE_WORKFLOW_OPTIONS<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'commonMaxSerializableChars'> {
|
|
528
531
|
workflowId?: string;
|
|
529
532
|
stopOnFirstPhaseError?: boolean;
|
|
530
533
|
logPhaseResults?: boolean;
|
|
531
534
|
concurrentPhaseExecution?: boolean;
|
|
532
535
|
enableBranchExecution?: boolean;
|
|
533
|
-
|
|
536
|
+
enableBranchRacing?: boolean;
|
|
537
|
+
branches?: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
534
538
|
enableMixedExecution?: boolean;
|
|
535
539
|
enableNonLinearExecution?: boolean;
|
|
536
540
|
maxWorkflowIterations?: number;
|
|
537
541
|
statePersistence?: StatePersistenceConfig;
|
|
538
|
-
handlePhaseCompletion?: (options: HandlePhaseCompletionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
539
|
-
handlePhaseError?: (options: HandlePhaseErrorHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
540
|
-
handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
541
|
-
handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
542
|
-
handleBranchDecision?: (decision: BranchExecutionDecision, branchResult: BranchExecutionResult<ResponseDataType>, maxSerializableChars?: number) => any | Promise<any>;
|
|
543
|
-
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType>>;
|
|
544
|
-
preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType>>;
|
|
542
|
+
handlePhaseCompletion?: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
543
|
+
handlePhaseError?: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
544
|
+
handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
|
|
545
|
+
handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
546
|
+
handleBranchDecision?: (decision: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, branchResult: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>, maxSerializableChars?: number) => any | Promise<any>;
|
|
547
|
+
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
548
|
+
preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
545
549
|
maxSerializableChars?: number;
|
|
546
550
|
workflowHookParams?: WorkflowHookParams;
|
|
547
|
-
metricsGuardrails?: MetricsGuardrails;
|
|
548
551
|
}
|
|
549
|
-
export interface STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType = any> {
|
|
552
|
+
export interface STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
|
|
550
553
|
workflowId: string;
|
|
551
554
|
branchId?: string;
|
|
552
555
|
phaseId: string;
|
|
@@ -557,10 +560,10 @@ export interface STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType = any> {
|
|
|
557
560
|
totalRequests: number;
|
|
558
561
|
successfulRequests: number;
|
|
559
562
|
failedRequests: number;
|
|
560
|
-
responses: API_GATEWAY_RESPONSE<ResponseDataType>[];
|
|
563
|
+
responses: API_GATEWAY_RESPONSE<ResponseDataType, FunctionReturnType>[];
|
|
561
564
|
executionNumber?: number;
|
|
562
565
|
skipped?: boolean;
|
|
563
|
-
decision?: PhaseExecutionDecision
|
|
566
|
+
decision?: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
564
567
|
error?: string;
|
|
565
568
|
metrics?: PhaseMetrics;
|
|
566
569
|
validation?: MetricsValidationResult;
|
|
@@ -571,7 +574,7 @@ export interface STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType = any> {
|
|
|
571
574
|
concurrencyLimiter?: ConcurrencyLimiterDashboardMetrics;
|
|
572
575
|
};
|
|
573
576
|
}
|
|
574
|
-
export interface STABLE_WORKFLOW_RESULT<ResponseDataType = any> {
|
|
577
|
+
export interface STABLE_WORKFLOW_RESULT<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
|
|
575
578
|
workflowId: string;
|
|
576
579
|
success: boolean;
|
|
577
580
|
executionTime: number;
|
|
@@ -581,10 +584,10 @@ export interface STABLE_WORKFLOW_RESULT<ResponseDataType = any> {
|
|
|
581
584
|
totalRequests: number;
|
|
582
585
|
successfulRequests: number;
|
|
583
586
|
failedRequests: number;
|
|
584
|
-
phases: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
585
|
-
executionHistory: PhaseExecutionRecord[];
|
|
586
|
-
branches?: BranchExecutionResult<ResponseDataType>[];
|
|
587
|
-
branchExecutionHistory?: BranchExecutionRecord[];
|
|
587
|
+
phases: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
588
|
+
executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
589
|
+
branches?: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
590
|
+
branchExecutionHistory?: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
588
591
|
terminatedEarly?: boolean;
|
|
589
592
|
terminationReason?: string;
|
|
590
593
|
error?: string;
|
|
@@ -607,20 +610,20 @@ export interface WorkflowHookParams {
|
|
|
607
610
|
preBranchExecutionHookParams?: any;
|
|
608
611
|
statePersistence?: StatePersistenceConfig;
|
|
609
612
|
}
|
|
610
|
-
export interface HandlePhaseCompletionHookOptions<ResponseDataType = any> {
|
|
613
|
+
export interface HandlePhaseCompletionHookOptions<ResponseDataType = any, FunctionReturnType = any> {
|
|
611
614
|
workflowId: string;
|
|
612
615
|
branchId?: string;
|
|
613
|
-
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>;
|
|
616
|
+
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
|
|
614
617
|
maxSerializableChars?: number;
|
|
615
618
|
params?: any;
|
|
616
619
|
sharedBuffer?: Record<string, any>;
|
|
617
620
|
}
|
|
618
|
-
export interface HandlePhaseErrorHookOptions<ResponseDataType = any> extends HandlePhaseCompletionHookOptions<ResponseDataType> {
|
|
621
|
+
export interface HandlePhaseErrorHookOptions<ResponseDataType = any, FunctionReturnType = any> extends HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType> {
|
|
619
622
|
error: any;
|
|
620
623
|
}
|
|
621
|
-
export interface HandlePhaseDecisionHookOptions<ResponseDataType = any> {
|
|
622
|
-
decision: PhaseExecutionDecision
|
|
623
|
-
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>;
|
|
624
|
+
export interface HandlePhaseDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
625
|
+
decision: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
626
|
+
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
|
|
624
627
|
maxSerializableChars?: number;
|
|
625
628
|
}
|
|
626
629
|
export interface RateLimitConfig {
|
|
@@ -658,53 +661,53 @@ export interface CachedResponse<T = any> {
|
|
|
658
661
|
timestamp: number;
|
|
659
662
|
expiresAt: number;
|
|
660
663
|
}
|
|
661
|
-
export interface PhaseExecutionDecision {
|
|
664
|
+
export interface PhaseExecutionDecision<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
662
665
|
action: PHASE_DECISION_ACTIONS;
|
|
663
666
|
targetPhaseId?: string;
|
|
664
667
|
replayCount?: number;
|
|
665
668
|
metadata?: Record<string, any>;
|
|
666
|
-
addPhases?: STABLE_WORKFLOW_PHASE<
|
|
669
|
+
addPhases?: ReadonlyArray<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
667
670
|
}
|
|
668
|
-
export interface PhaseDecisionHookOptions<ResponseDataType = any> {
|
|
671
|
+
export interface PhaseDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
669
672
|
workflowId: string;
|
|
670
673
|
branchId?: string;
|
|
671
|
-
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>;
|
|
674
|
+
phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
|
|
672
675
|
phaseId: string;
|
|
673
676
|
phaseIndex: number;
|
|
674
|
-
executionHistory: PhaseExecutionRecord[];
|
|
677
|
+
executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
675
678
|
sharedBuffer?: Record<string, any>;
|
|
676
679
|
params?: any;
|
|
677
|
-
concurrentPhaseResults?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
680
|
+
concurrentPhaseResults?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>[];
|
|
678
681
|
}
|
|
679
|
-
export interface PhaseExecutionRecord {
|
|
682
|
+
export interface PhaseExecutionRecord<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
680
683
|
phaseId: string;
|
|
681
684
|
phaseIndex: number;
|
|
682
685
|
executionNumber: number;
|
|
683
686
|
timestamp: string;
|
|
684
687
|
success: boolean;
|
|
685
688
|
executionTime: number;
|
|
686
|
-
decision?: PhaseExecutionDecision
|
|
689
|
+
decision?: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
687
690
|
}
|
|
688
|
-
export interface NonLinearWorkflowContext<RequestDataType, ResponseDataType> {
|
|
689
|
-
phases: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType>[];
|
|
691
|
+
export interface NonLinearWorkflowContext<RequestDataType, ResponseDataType, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
692
|
+
phases: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
690
693
|
workflowId: string;
|
|
691
694
|
branchId?: string;
|
|
692
695
|
commonGatewayOptions: any;
|
|
693
696
|
requestGroups: any[];
|
|
694
697
|
logPhaseResults: boolean;
|
|
695
|
-
handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
696
|
-
handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
697
|
-
handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
698
|
-
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType>>;
|
|
698
|
+
handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
699
|
+
handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
700
|
+
handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
|
|
701
|
+
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
699
702
|
maxSerializableChars: number;
|
|
700
703
|
workflowHookParams: any;
|
|
701
704
|
sharedBuffer?: Record<string, any>;
|
|
702
705
|
stopOnFirstPhaseError: boolean;
|
|
703
706
|
maxWorkflowIterations: number;
|
|
704
707
|
}
|
|
705
|
-
export interface EXECUTE_NON_LINEAR_WORKFLOW_RESPONSE<ResponseDataType = any> {
|
|
706
|
-
phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
707
|
-
executionHistory: PhaseExecutionRecord[];
|
|
708
|
+
export interface EXECUTE_NON_LINEAR_WORKFLOW_RESPONSE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
709
|
+
phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
710
|
+
executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
708
711
|
totalRequests: number;
|
|
709
712
|
successfulRequests: number;
|
|
710
713
|
failedRequests: number;
|
|
@@ -718,84 +721,86 @@ export interface STABLE_WORKFLOW_BRANCH<RequestDataType = any, ResponseDataType
|
|
|
718
721
|
allowReplay?: boolean;
|
|
719
722
|
maxReplayCount?: number;
|
|
720
723
|
allowSkip?: boolean;
|
|
721
|
-
branchDecisionHook?: (options: BranchDecisionHookOptions<ResponseDataType>) => BranchExecutionDecision | Promise<BranchExecutionDecision
|
|
724
|
+
branchDecisionHook?: (options: BranchDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
722
725
|
statePersistence?: StatePersistenceConfig;
|
|
723
|
-
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | 'maxConcurrentRequests' | 'rateLimit' | 'circuitBreaker'>;
|
|
726
|
+
commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | 'maxConcurrentRequests' | 'rateLimit' | 'circuitBreaker' | 'maxTimeout' | "executionContext" | "metricsGuardrails">;
|
|
724
727
|
metricsGuardrails?: MetricsGuardrails;
|
|
728
|
+
maxTimeout?: number;
|
|
725
729
|
}
|
|
726
|
-
export interface BranchDecisionHookOptions<ResponseDataType = any> {
|
|
730
|
+
export interface BranchDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
727
731
|
workflowId: string;
|
|
728
|
-
branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
732
|
+
branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
729
733
|
branchId: string;
|
|
730
734
|
branchIndex: number;
|
|
731
735
|
executionNumber: number;
|
|
732
|
-
executionHistory: PhaseExecutionRecord[];
|
|
733
|
-
branchExecutionHistory: BranchExecutionRecord[];
|
|
736
|
+
executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
737
|
+
branchExecutionHistory: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
734
738
|
sharedBuffer?: Record<string, any>;
|
|
735
739
|
params?: any;
|
|
736
|
-
concurrentBranchResults?: BranchExecutionResult<ResponseDataType>[];
|
|
740
|
+
concurrentBranchResults?: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
737
741
|
}
|
|
738
|
-
export interface BranchExecutionDecision {
|
|
742
|
+
export interface BranchExecutionDecision<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
739
743
|
action: PHASE_DECISION_ACTIONS;
|
|
740
744
|
targetBranchId?: string;
|
|
741
745
|
metadata?: Record<string, any>;
|
|
742
|
-
addPhases?: STABLE_WORKFLOW_PHASE<
|
|
743
|
-
addBranches?: STABLE_WORKFLOW_BRANCH<
|
|
746
|
+
addPhases?: ReadonlyArray<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
747
|
+
addBranches?: ReadonlyArray<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
744
748
|
}
|
|
745
|
-
export interface BranchExecutionResult<ResponseDataType = any> {
|
|
749
|
+
export interface BranchExecutionResult<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
|
|
746
750
|
workflowId: string;
|
|
747
751
|
branchId: string;
|
|
748
752
|
branchIndex: number;
|
|
749
753
|
success: boolean;
|
|
750
754
|
executionTime: number;
|
|
751
755
|
completedPhases: number;
|
|
752
|
-
phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
753
|
-
decision?: BranchExecutionDecision
|
|
756
|
+
phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
757
|
+
decision?: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
754
758
|
executionNumber: number;
|
|
755
759
|
skipped?: boolean;
|
|
756
760
|
error?: string;
|
|
757
761
|
metrics?: BranchMetrics;
|
|
758
762
|
validation?: MetricsValidationResult;
|
|
759
763
|
}
|
|
760
|
-
export interface BranchExecutionRecord {
|
|
764
|
+
export interface BranchExecutionRecord<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
761
765
|
branchId: string;
|
|
762
766
|
branchIndex: number;
|
|
763
767
|
executionNumber: number;
|
|
764
768
|
timestamp: string;
|
|
765
769
|
success: boolean;
|
|
766
770
|
executionTime: number;
|
|
767
|
-
decision?: BranchExecutionDecision
|
|
771
|
+
decision?: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
768
772
|
}
|
|
769
|
-
export interface HandleBranchCompletionHookOptions<ResponseDataType = any> {
|
|
773
|
+
export interface HandleBranchCompletionHookOptions<ResponseDataType = any, FunctionReturnType = any> {
|
|
770
774
|
workflowId: string;
|
|
771
775
|
branchId: string;
|
|
772
|
-
branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
776
|
+
branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, any, any[]>[];
|
|
773
777
|
success: boolean;
|
|
774
778
|
maxSerializableChars?: number;
|
|
775
779
|
}
|
|
776
|
-
export interface BranchWorkflowContext<RequestDataType = any, ResponseDataType = any> {
|
|
777
|
-
branches: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType>[];
|
|
780
|
+
export interface BranchWorkflowContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
781
|
+
branches: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
778
782
|
workflowId: string;
|
|
779
783
|
commonGatewayOptions: any;
|
|
780
784
|
requestGroups: any[];
|
|
781
785
|
logPhaseResults: boolean;
|
|
782
|
-
handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
783
|
-
handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
784
|
-
handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType>) => any | Promise<any>;
|
|
785
|
-
handleBranchDecision?: (decision: BranchExecutionDecision, branchResult: BranchExecutionResult<ResponseDataType>, maxSerializableChars?: number) => any | Promise<any>;
|
|
786
|
-
preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType>>;
|
|
787
|
-
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType>>;
|
|
786
|
+
handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
787
|
+
handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
788
|
+
handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
|
|
789
|
+
handleBranchDecision?: (decision: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, branchResult: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>, maxSerializableChars?: number) => any | Promise<any>;
|
|
790
|
+
preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
791
|
+
prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
788
792
|
maxSerializableChars: number;
|
|
789
793
|
workflowHookParams: any;
|
|
790
794
|
sharedBuffer?: Record<string, any>;
|
|
791
795
|
stopOnFirstPhaseError: boolean;
|
|
796
|
+
enableBranchRacing?: boolean;
|
|
792
797
|
maxWorkflowIterations: number;
|
|
793
798
|
}
|
|
794
|
-
export interface EXECUTE_BRANCH_WORKFLOW_RESPONSE<ResponseDataType = any> {
|
|
795
|
-
branchResults: BranchExecutionResult<ResponseDataType>[];
|
|
796
|
-
allPhaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>[];
|
|
797
|
-
executionHistory: PhaseExecutionRecord[];
|
|
798
|
-
branchExecutionHistory: BranchExecutionRecord[];
|
|
799
|
+
export interface EXECUTE_BRANCH_WORKFLOW_RESPONSE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
800
|
+
branchResults: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
801
|
+
allPhaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
|
|
802
|
+
executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
803
|
+
branchExecutionHistory: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
|
|
799
804
|
totalRequests: number;
|
|
800
805
|
successfulRequests: number;
|
|
801
806
|
failedRequests: number;
|
|
@@ -987,7 +992,7 @@ export interface SystemMetrics {
|
|
|
987
992
|
export type WorkflowNodeType = WorkflowNodeTypes.PHASE | WorkflowNodeTypes.BRANCH | WorkflowNodeTypes.CONDITIONAL | WorkflowNodeTypes.PARALLEL_GROUP | WorkflowNodeTypes.MERGE_POINT;
|
|
988
993
|
export interface WorkflowGraph<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
989
994
|
nodes: Map<string, WorkflowNode<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
990
|
-
edges: Map<string, WorkflowEdge[]>;
|
|
995
|
+
edges: Map<string, WorkflowEdge<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[]>;
|
|
991
996
|
entryPoint: string;
|
|
992
997
|
exitPoints?: string[];
|
|
993
998
|
metadata?: Record<string, any>;
|
|
@@ -997,40 +1002,40 @@ export interface WorkflowNode<RequestDataType = any, ResponseDataType = any, Fun
|
|
|
997
1002
|
type: WorkflowNodeType;
|
|
998
1003
|
phase?: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
999
1004
|
branch?: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
1000
|
-
condition?: ConditionalNode<ResponseDataType>;
|
|
1005
|
+
condition?: ConditionalNode<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
1001
1006
|
parallelNodes?: string[];
|
|
1002
1007
|
waitForNodes?: string[];
|
|
1003
1008
|
metadata?: Record<string, any>;
|
|
1004
|
-
phaseDecisionHook?: (context: PhaseDecisionHookOptions<ResponseDataType>) => PhaseExecutionDecision | Promise<PhaseExecutionDecision
|
|
1009
|
+
phaseDecisionHook?: (context: PhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
1005
1010
|
}
|
|
1006
|
-
export interface WorkflowEdge {
|
|
1011
|
+
export interface WorkflowEdge<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
1007
1012
|
from: string;
|
|
1008
1013
|
to: string;
|
|
1009
|
-
condition?: EdgeCondition
|
|
1014
|
+
condition?: EdgeCondition<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
|
|
1010
1015
|
weight?: number;
|
|
1011
1016
|
label?: string;
|
|
1012
1017
|
metadata?: Record<string, any>;
|
|
1013
1018
|
}
|
|
1014
1019
|
export type EdgeConditionType = WorkflowEdgeConditionTypes.SUCCESS | WorkflowEdgeConditionTypes.FAILURE | WorkflowEdgeConditionTypes.CUSTOM | WorkflowEdgeConditionTypes.ALWAYS;
|
|
1015
|
-
export interface EdgeCondition {
|
|
1020
|
+
export interface EdgeCondition<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
1016
1021
|
type: EdgeConditionType;
|
|
1017
|
-
evaluate?: (context: EdgeEvaluationContext) => boolean | Promise<boolean>;
|
|
1022
|
+
evaluate?: (context: EdgeEvaluationContext<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
|
|
1018
1023
|
}
|
|
1019
|
-
export interface EdgeEvaluationContext {
|
|
1020
|
-
results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<
|
|
1024
|
+
export interface EdgeEvaluationContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
1025
|
+
results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>>;
|
|
1021
1026
|
sharedBuffer?: Record<string, any>;
|
|
1022
|
-
executionHistory: PhaseExecutionRecord
|
|
1027
|
+
executionHistory: ReadonlyArray<PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
1023
1028
|
currentNodeId: string;
|
|
1024
1029
|
}
|
|
1025
|
-
export interface ConditionalNode<ResponseDataType = any> {
|
|
1026
|
-
evaluate: (context: ConditionalEvaluationContext<ResponseDataType>) => string | Promise<string>;
|
|
1030
|
+
export interface ConditionalNode<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
1031
|
+
evaluate: (context: ConditionalEvaluationContext<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => string | Promise<string>;
|
|
1027
1032
|
}
|
|
1028
|
-
export interface ConditionalEvaluationContext<ResponseDataType = any> {
|
|
1029
|
-
results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>>;
|
|
1033
|
+
export interface ConditionalEvaluationContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
|
|
1034
|
+
results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>>;
|
|
1030
1035
|
sharedBuffer?: Record<string, any>;
|
|
1031
|
-
executionHistory: PhaseExecutionRecord
|
|
1036
|
+
executionHistory: ReadonlyArray<PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
|
|
1032
1037
|
currentNodeId: string;
|
|
1033
|
-
phaseResult?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType>;
|
|
1038
|
+
phaseResult?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>;
|
|
1034
1039
|
}
|
|
1035
1040
|
export interface WorkflowGraphOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends Omit<STABLE_WORKFLOW_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'branches' | 'enableBranchExecution' | 'concurrentPhaseExecution' | 'enableMixedExecution' | 'enableNonLinearExecution'> {
|
|
1036
1041
|
validateGraph?: boolean;
|