@emmvish/stable-infra 1.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.
Files changed (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2520 -0
  3. package/dist/constants/index.d.ts +15 -0
  4. package/dist/constants/index.d.ts.map +1 -0
  5. package/dist/constants/index.js +136 -0
  6. package/dist/constants/index.js.map +1 -0
  7. package/dist/core/index.d.ts +8 -0
  8. package/dist/core/index.d.ts.map +1 -0
  9. package/dist/core/index.js +8 -0
  10. package/dist/core/index.js.map +1 -0
  11. package/dist/core/stable-api-gateway.d.ts +4 -0
  12. package/dist/core/stable-api-gateway.d.ts.map +1 -0
  13. package/dist/core/stable-api-gateway.js +146 -0
  14. package/dist/core/stable-api-gateway.js.map +1 -0
  15. package/dist/core/stable-buffer.d.ts +23 -0
  16. package/dist/core/stable-buffer.d.ts.map +1 -0
  17. package/dist/core/stable-buffer.js +127 -0
  18. package/dist/core/stable-buffer.js.map +1 -0
  19. package/dist/core/stable-function.d.ts +11 -0
  20. package/dist/core/stable-function.d.ts.map +1 -0
  21. package/dist/core/stable-function.js +355 -0
  22. package/dist/core/stable-function.js.map +1 -0
  23. package/dist/core/stable-request.d.ts +3 -0
  24. package/dist/core/stable-request.d.ts.map +1 -0
  25. package/dist/core/stable-request.js +313 -0
  26. package/dist/core/stable-request.js.map +1 -0
  27. package/dist/core/stable-scheduler.d.ts +71 -0
  28. package/dist/core/stable-scheduler.d.ts.map +1 -0
  29. package/dist/core/stable-scheduler.js +782 -0
  30. package/dist/core/stable-scheduler.js.map +1 -0
  31. package/dist/core/stable-workflow-graph.d.ts +3 -0
  32. package/dist/core/stable-workflow-graph.d.ts.map +1 -0
  33. package/dist/core/stable-workflow-graph.js +5 -0
  34. package/dist/core/stable-workflow-graph.js.map +1 -0
  35. package/dist/core/stable-workflow.d.ts +3 -0
  36. package/dist/core/stable-workflow.d.ts.map +1 -0
  37. package/dist/core/stable-workflow.js +374 -0
  38. package/dist/core/stable-workflow.js.map +1 -0
  39. package/dist/enums/index.d.ts +84 -0
  40. package/dist/enums/index.d.ts.map +1 -0
  41. package/dist/enums/index.js +99 -0
  42. package/dist/enums/index.js.map +1 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +4 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/stable-runner/index.d.ts +2 -0
  48. package/dist/stable-runner/index.d.ts.map +1 -0
  49. package/dist/stable-runner/index.js +324 -0
  50. package/dist/stable-runner/index.js.map +1 -0
  51. package/dist/types/index.d.ts +1482 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/index.js +2 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/dist/utilities/buffer-utils.d.ts +4 -0
  56. package/dist/utilities/buffer-utils.d.ts.map +1 -0
  57. package/dist/utilities/buffer-utils.js +13 -0
  58. package/dist/utilities/buffer-utils.js.map +1 -0
  59. package/dist/utilities/cache-manager.d.ts +54 -0
  60. package/dist/utilities/cache-manager.d.ts.map +1 -0
  61. package/dist/utilities/cache-manager.js +288 -0
  62. package/dist/utilities/cache-manager.js.map +1 -0
  63. package/dist/utilities/circuit-breaker.d.ts +78 -0
  64. package/dist/utilities/circuit-breaker.d.ts.map +1 -0
  65. package/dist/utilities/circuit-breaker.js +350 -0
  66. package/dist/utilities/circuit-breaker.js.map +1 -0
  67. package/dist/utilities/concurrency-limiter.d.ts +46 -0
  68. package/dist/utilities/concurrency-limiter.d.ts.map +1 -0
  69. package/dist/utilities/concurrency-limiter.js +172 -0
  70. package/dist/utilities/concurrency-limiter.js.map +1 -0
  71. package/dist/utilities/delay.d.ts +2 -0
  72. package/dist/utilities/delay.d.ts.map +1 -0
  73. package/dist/utilities/delay.js +8 -0
  74. package/dist/utilities/delay.js.map +1 -0
  75. package/dist/utilities/execute-branch-workflow.d.ts +3 -0
  76. package/dist/utilities/execute-branch-workflow.d.ts.map +1 -0
  77. package/dist/utilities/execute-branch-workflow.js +736 -0
  78. package/dist/utilities/execute-branch-workflow.js.map +1 -0
  79. package/dist/utilities/execute-concurrently.d.ts +3 -0
  80. package/dist/utilities/execute-concurrently.d.ts.map +1 -0
  81. package/dist/utilities/execute-concurrently.js +258 -0
  82. package/dist/utilities/execute-concurrently.js.map +1 -0
  83. package/dist/utilities/execute-gateway-item.d.ts +6 -0
  84. package/dist/utilities/execute-gateway-item.d.ts.map +1 -0
  85. package/dist/utilities/execute-gateway-item.js +129 -0
  86. package/dist/utilities/execute-gateway-item.js.map +1 -0
  87. package/dist/utilities/execute-non-linear-workflow.d.ts +3 -0
  88. package/dist/utilities/execute-non-linear-workflow.d.ts.map +1 -0
  89. package/dist/utilities/execute-non-linear-workflow.js +486 -0
  90. package/dist/utilities/execute-non-linear-workflow.js.map +1 -0
  91. package/dist/utilities/execute-phase.d.ts +3 -0
  92. package/dist/utilities/execute-phase.d.ts.map +1 -0
  93. package/dist/utilities/execute-phase.js +132 -0
  94. package/dist/utilities/execute-phase.js.map +1 -0
  95. package/dist/utilities/execute-sequentially.d.ts +3 -0
  96. package/dist/utilities/execute-sequentially.d.ts.map +1 -0
  97. package/dist/utilities/execute-sequentially.js +49 -0
  98. package/dist/utilities/execute-sequentially.js.map +1 -0
  99. package/dist/utilities/execute-with-persistence.d.ts +3 -0
  100. package/dist/utilities/execute-with-persistence.d.ts.map +1 -0
  101. package/dist/utilities/execute-with-persistence.js +60 -0
  102. package/dist/utilities/execute-with-persistence.js.map +1 -0
  103. package/dist/utilities/execute-with-timeout.d.ts +6 -0
  104. package/dist/utilities/execute-with-timeout.d.ts.map +1 -0
  105. package/dist/utilities/execute-with-timeout.js +28 -0
  106. package/dist/utilities/execute-with-timeout.js.map +1 -0
  107. package/dist/utilities/execute-workflow-graph.d.ts +3 -0
  108. package/dist/utilities/execute-workflow-graph.d.ts.map +1 -0
  109. package/dist/utilities/execute-workflow-graph.js +439 -0
  110. package/dist/utilities/execute-workflow-graph.js.map +1 -0
  111. package/dist/utilities/extract-common-request-config-options.d.ts +3 -0
  112. package/dist/utilities/extract-common-request-config-options.d.ts.map +1 -0
  113. package/dist/utilities/extract-common-request-config-options.js +12 -0
  114. package/dist/utilities/extract-common-request-config-options.js.map +1 -0
  115. package/dist/utilities/fn-exec.d.ts +3 -0
  116. package/dist/utilities/fn-exec.d.ts.map +1 -0
  117. package/dist/utilities/fn-exec.js +66 -0
  118. package/dist/utilities/fn-exec.js.map +1 -0
  119. package/dist/utilities/format-log-context.d.ts +3 -0
  120. package/dist/utilities/format-log-context.d.ts.map +1 -0
  121. package/dist/utilities/format-log-context.js +19 -0
  122. package/dist/utilities/format-log-context.js.map +1 -0
  123. package/dist/utilities/function-cache-manager.d.ts +32 -0
  124. package/dist/utilities/function-cache-manager.d.ts.map +1 -0
  125. package/dist/utilities/function-cache-manager.js +172 -0
  126. package/dist/utilities/function-cache-manager.js.map +1 -0
  127. package/dist/utilities/generate-axios-request-config.d.ts +12 -0
  128. package/dist/utilities/generate-axios-request-config.d.ts.map +1 -0
  129. package/dist/utilities/generate-axios-request-config.js +14 -0
  130. package/dist/utilities/generate-axios-request-config.js.map +1 -0
  131. package/dist/utilities/get-new-delay-time.d.ts +3 -0
  132. package/dist/utilities/get-new-delay-time.d.ts.map +1 -0
  133. package/dist/utilities/get-new-delay-time.js +26 -0
  134. package/dist/utilities/get-new-delay-time.js.map +1 -0
  135. package/dist/utilities/hash-utils.d.ts +4 -0
  136. package/dist/utilities/hash-utils.d.ts.map +1 -0
  137. package/dist/utilities/hash-utils.js +24 -0
  138. package/dist/utilities/hash-utils.js.map +1 -0
  139. package/dist/utilities/index.d.ts +37 -0
  140. package/dist/utilities/index.d.ts.map +1 -0
  141. package/dist/utilities/index.js +37 -0
  142. package/dist/utilities/index.js.map +1 -0
  143. package/dist/utilities/infrastructure-persistence.d.ts +14 -0
  144. package/dist/utilities/infrastructure-persistence.d.ts.map +1 -0
  145. package/dist/utilities/infrastructure-persistence.js +87 -0
  146. package/dist/utilities/infrastructure-persistence.js.map +1 -0
  147. package/dist/utilities/is-retryable-error.d.ts +4 -0
  148. package/dist/utilities/is-retryable-error.d.ts.map +1 -0
  149. package/dist/utilities/is-retryable-error.js +22 -0
  150. package/dist/utilities/is-retryable-error.js.map +1 -0
  151. package/dist/utilities/metrics-aggregator.d.ts +19 -0
  152. package/dist/utilities/metrics-aggregator.d.ts.map +1 -0
  153. package/dist/utilities/metrics-aggregator.js +300 -0
  154. package/dist/utilities/metrics-aggregator.js.map +1 -0
  155. package/dist/utilities/metrics-validator.d.ts +98 -0
  156. package/dist/utilities/metrics-validator.d.ts.map +1 -0
  157. package/dist/utilities/metrics-validator.js +324 -0
  158. package/dist/utilities/metrics-validator.js.map +1 -0
  159. package/dist/utilities/prepare-api-function-options.d.ts +3 -0
  160. package/dist/utilities/prepare-api-function-options.d.ts.map +1 -0
  161. package/dist/utilities/prepare-api-function-options.js +51 -0
  162. package/dist/utilities/prepare-api-function-options.js.map +1 -0
  163. package/dist/utilities/prepare-api-request-data.d.ts +3 -0
  164. package/dist/utilities/prepare-api-request-data.d.ts.map +1 -0
  165. package/dist/utilities/prepare-api-request-data.js +15 -0
  166. package/dist/utilities/prepare-api-request-data.js.map +1 -0
  167. package/dist/utilities/prepare-api-request-options.d.ts +3 -0
  168. package/dist/utilities/prepare-api-request-options.d.ts.map +1 -0
  169. package/dist/utilities/prepare-api-request-options.js +22 -0
  170. package/dist/utilities/prepare-api-request-options.js.map +1 -0
  171. package/dist/utilities/rate-limiter.d.ts +49 -0
  172. package/dist/utilities/rate-limiter.d.ts.map +1 -0
  173. package/dist/utilities/rate-limiter.js +197 -0
  174. package/dist/utilities/rate-limiter.js.map +1 -0
  175. package/dist/utilities/req-fn.d.ts +4 -0
  176. package/dist/utilities/req-fn.d.ts.map +1 -0
  177. package/dist/utilities/req-fn.js +94 -0
  178. package/dist/utilities/req-fn.js.map +1 -0
  179. package/dist/utilities/safely-execute-unknown-function.d.ts +2 -0
  180. package/dist/utilities/safely-execute-unknown-function.d.ts.map +1 -0
  181. package/dist/utilities/safely-execute-unknown-function.js +8 -0
  182. package/dist/utilities/safely-execute-unknown-function.js.map +1 -0
  183. package/dist/utilities/safely-stringify.d.ts +4 -0
  184. package/dist/utilities/safely-stringify.d.ts.map +1 -0
  185. package/dist/utilities/safely-stringify.js +13 -0
  186. package/dist/utilities/safely-stringify.js.map +1 -0
  187. package/dist/utilities/stable-buffer-replay.d.ts +3 -0
  188. package/dist/utilities/stable-buffer-replay.d.ts.map +1 -0
  189. package/dist/utilities/stable-buffer-replay.js +94 -0
  190. package/dist/utilities/stable-buffer-replay.js.map +1 -0
  191. package/dist/utilities/validate-trial-mode-probabilities.d.ts +3 -0
  192. package/dist/utilities/validate-trial-mode-probabilities.d.ts.map +1 -0
  193. package/dist/utilities/validate-trial-mode-probabilities.js +13 -0
  194. package/dist/utilities/validate-trial-mode-probabilities.js.map +1 -0
  195. package/dist/utilities/validate-workflow-graph.d.ts +7 -0
  196. package/dist/utilities/validate-workflow-graph.d.ts.map +1 -0
  197. package/dist/utilities/validate-workflow-graph.js +235 -0
  198. package/dist/utilities/validate-workflow-graph.js.map +1 -0
  199. package/dist/utilities/workflow-graph-builder.d.ts +37 -0
  200. package/dist/utilities/workflow-graph-builder.d.ts.map +1 -0
  201. package/dist/utilities/workflow-graph-builder.js +225 -0
  202. package/dist/utilities/workflow-graph-builder.js.map +1 -0
  203. package/package.json +63 -0
@@ -0,0 +1,1482 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { PHASE_DECISION_ACTIONS, REQUEST_METHODS, RESPONSE_ERRORS, RETRY_STRATEGIES, VALID_REQUEST_PROTOCOLS, WorkflowEdgeConditionTypes, WorkflowNodeTypes, RequestOrFunction, AnomalySeverity, ViolationType, PersistenceStage, RunnerJobs, ScheduleTypes, CircuitBreakerState } from '../enums/index.js';
3
+ import { CircuitBreaker, RateLimiter, ConcurrencyLimiter, CacheManager } from '../utilities/index.js';
4
+ export type CreateHash = (algorithm: string) => {
5
+ update: (data: string) => {
6
+ digest: (encoding: 'hex') => string;
7
+ };
8
+ };
9
+ export type NodeCryptoLike = {
10
+ createHash?: CreateHash;
11
+ };
12
+ export interface MetricGuardrail {
13
+ min?: number;
14
+ max?: number;
15
+ expected?: number;
16
+ tolerance?: number;
17
+ }
18
+ export interface MetricsGuardrailsRequest {
19
+ totalAttempts?: MetricGuardrail;
20
+ successfulAttempts?: MetricGuardrail;
21
+ failedAttempts?: MetricGuardrail;
22
+ totalExecutionTime?: MetricGuardrail;
23
+ averageAttemptTime?: MetricGuardrail;
24
+ }
25
+ export interface MetricsGuardrailsApiGateway {
26
+ totalRequests?: MetricGuardrail;
27
+ successfulRequests?: MetricGuardrail;
28
+ failedRequests?: MetricGuardrail;
29
+ successRate?: MetricGuardrail;
30
+ failureRate?: MetricGuardrail;
31
+ executionTime?: MetricGuardrail;
32
+ throughput?: MetricGuardrail;
33
+ averageRequestDuration?: MetricGuardrail;
34
+ }
35
+ export interface MetricsGuardrailsWorkflow {
36
+ totalPhases?: MetricGuardrail;
37
+ completedPhases?: MetricGuardrail;
38
+ failedPhases?: MetricGuardrail;
39
+ totalRequests?: MetricGuardrail;
40
+ successfulRequests?: MetricGuardrail;
41
+ failedRequests?: MetricGuardrail;
42
+ requestSuccessRate?: MetricGuardrail;
43
+ requestFailureRate?: MetricGuardrail;
44
+ executionTime?: MetricGuardrail;
45
+ averagePhaseExecutionTime?: MetricGuardrail;
46
+ throughput?: MetricGuardrail;
47
+ phaseCompletionRate?: MetricGuardrail;
48
+ }
49
+ export interface MetricsGuardrailsPhase {
50
+ totalRequests?: MetricGuardrail;
51
+ successfulRequests?: MetricGuardrail;
52
+ failedRequests?: MetricGuardrail;
53
+ requestSuccessRate?: MetricGuardrail;
54
+ requestFailureRate?: MetricGuardrail;
55
+ executionTime?: MetricGuardrail;
56
+ }
57
+ export interface MetricsGuardrailsBranch {
58
+ totalPhases?: MetricGuardrail;
59
+ completedPhases?: MetricGuardrail;
60
+ failedPhases?: MetricGuardrail;
61
+ totalRequests?: MetricGuardrail;
62
+ successfulRequests?: MetricGuardrail;
63
+ failedRequests?: MetricGuardrail;
64
+ requestSuccessRate?: MetricGuardrail;
65
+ requestFailureRate?: MetricGuardrail;
66
+ executionTime?: MetricGuardrail;
67
+ phaseCompletionRate?: MetricGuardrail;
68
+ }
69
+ export interface MetricsGuardrailsCircuitBreaker {
70
+ failureRate?: MetricGuardrail;
71
+ totalRequests?: MetricGuardrail;
72
+ failedRequests?: MetricGuardrail;
73
+ }
74
+ export interface MetricsGuardrailsCache {
75
+ hitRate?: MetricGuardrail;
76
+ missRate?: MetricGuardrail;
77
+ utilizationPercentage?: MetricGuardrail;
78
+ evictionRate?: MetricGuardrail;
79
+ }
80
+ export interface MetricsGuardrailsRateLimiter {
81
+ throttleRate?: MetricGuardrail;
82
+ queueLength?: MetricGuardrail;
83
+ utilizationPercentage?: MetricGuardrail;
84
+ averageQueueWaitTime?: MetricGuardrail;
85
+ }
86
+ export interface MetricsGuardrailsConcurrencyLimiter {
87
+ utilizationPercentage?: MetricGuardrail;
88
+ queueLength?: MetricGuardrail;
89
+ averageQueueWaitTime?: MetricGuardrail;
90
+ }
91
+ export interface MetricsGuardrailsInfrastructure {
92
+ circuitBreaker?: MetricsGuardrailsCircuitBreaker;
93
+ cache?: MetricsGuardrailsCache;
94
+ rateLimiter?: MetricsGuardrailsRateLimiter;
95
+ concurrencyLimiter?: MetricsGuardrailsConcurrencyLimiter;
96
+ }
97
+ export interface MetricsGuardrailsCommon {
98
+ successRate?: MetricGuardrail;
99
+ failureRate?: MetricGuardrail;
100
+ executionTime?: MetricGuardrail;
101
+ throughput?: MetricGuardrail;
102
+ }
103
+ export interface MetricsGuardrailsScheduler {
104
+ totalJobs?: MetricGuardrail;
105
+ queued?: MetricGuardrail;
106
+ running?: MetricGuardrail;
107
+ completed?: MetricGuardrail;
108
+ failed?: MetricGuardrail;
109
+ dropped?: MetricGuardrail;
110
+ totalRuns?: MetricGuardrail;
111
+ successRate?: MetricGuardrail;
112
+ failureRate?: MetricGuardrail;
113
+ throughput?: MetricGuardrail;
114
+ averageExecutionTime?: MetricGuardrail;
115
+ averageQueueDelay?: MetricGuardrail;
116
+ }
117
+ export interface MetricsGuardrailsStableBuffer {
118
+ totalTransactions?: MetricGuardrail;
119
+ averageQueueWaitMs?: MetricGuardrail;
120
+ }
121
+ export interface MetricsGuardrails {
122
+ request?: MetricsGuardrailsRequest;
123
+ apiGateway?: MetricsGuardrailsApiGateway;
124
+ workflow?: MetricsGuardrailsWorkflow;
125
+ phase?: MetricsGuardrailsPhase;
126
+ branch?: MetricsGuardrailsBranch;
127
+ infrastructure?: MetricsGuardrailsInfrastructure;
128
+ common?: MetricsGuardrailsCommon;
129
+ scheduler?: MetricsGuardrailsScheduler;
130
+ stableBuffer?: MetricsGuardrailsStableBuffer;
131
+ }
132
+ export interface MetricAnomaly {
133
+ metricName: string;
134
+ metricValue: number;
135
+ guardrail: MetricGuardrail;
136
+ severity: AnomalySeverity;
137
+ reason: string;
138
+ violationType: ViolationType;
139
+ }
140
+ export interface MetricsValidationResult {
141
+ isValid: boolean;
142
+ anomalies: MetricAnomaly[];
143
+ validatedAt: string;
144
+ }
145
+ export interface SchedulerInfrastructureMetrics {
146
+ circuitBreaker?: {
147
+ state: string;
148
+ totalRequests: number;
149
+ failedRequests: number;
150
+ successfulRequests: number;
151
+ failurePercentage: number;
152
+ };
153
+ rateLimiter?: {
154
+ totalRequests: number;
155
+ throttledRequests: number;
156
+ throttleRate: number;
157
+ queueLength: number;
158
+ averageQueueWaitTime: number;
159
+ };
160
+ concurrencyLimiter?: {
161
+ totalRequests: number;
162
+ completedRequests: number;
163
+ queuedRequests: number;
164
+ queueLength: number;
165
+ averageQueueWaitTime: number;
166
+ utilizationPercentage: number;
167
+ };
168
+ cacheManager?: {
169
+ hits: number;
170
+ misses: number;
171
+ hitRate: number;
172
+ missRate: number;
173
+ utilizationPercentage: number;
174
+ evictions: number;
175
+ };
176
+ }
177
+ export interface SchedulerMetrics {
178
+ totalJobs: number;
179
+ queued: number;
180
+ running: number;
181
+ completed: number;
182
+ failed: number;
183
+ dropped: number;
184
+ totalRuns: number;
185
+ successRate: number;
186
+ failureRate: number;
187
+ throughput: number;
188
+ averageExecutionTime: number;
189
+ averageQueueDelay: number;
190
+ startedAt?: string;
191
+ lastUpdated: string;
192
+ infrastructure?: SchedulerInfrastructureMetrics;
193
+ }
194
+ export interface StableBufferMetrics {
195
+ totalTransactions: number;
196
+ averageQueueWaitMs: number;
197
+ validation?: MetricsValidationResult;
198
+ }
199
+ export interface StableBufferTransactionOptions extends ExecutionContext {
200
+ activity?: string;
201
+ hookName?: string;
202
+ hookParams?: any;
203
+ }
204
+ export interface StableBufferTransactionLog extends StableBufferTransactionOptions {
205
+ transactionId: string;
206
+ queuedAt: string;
207
+ startedAt: string;
208
+ finishedAt: string;
209
+ durationMs: number;
210
+ queueWaitMs: number;
211
+ success: boolean;
212
+ errorMessage?: string;
213
+ stateBefore: Record<string, any>;
214
+ stateAfter: Record<string, any>;
215
+ }
216
+ export type StableBufferTransactionLogger = (log: StableBufferTransactionLog) => void | Promise<void>;
217
+ export type StableBufferReplayHandler = (state: Record<string, any>, log: StableBufferTransactionLog) => void | Promise<void>;
218
+ export interface StableBufferReplayOptions {
219
+ logs: StableBufferTransactionLog[];
220
+ handlers: Record<string, StableBufferReplayHandler>;
221
+ buffer?: BufferLike;
222
+ initialState?: Record<string, any>;
223
+ sort?: boolean;
224
+ dedupe?: boolean;
225
+ allowUnknownHooks?: boolean;
226
+ activityFilter?: (log: StableBufferTransactionLog) => boolean;
227
+ onApply?: (log: StableBufferTransactionLog) => void;
228
+ onSkip?: (log: StableBufferTransactionLog, reason: 'filtered' | 'duplicate' | 'missing-handler') => void;
229
+ onError?: (log: StableBufferTransactionLog, error: unknown) => void;
230
+ }
231
+ export interface StableBufferReplayResult {
232
+ buffer: StableBufferInstance;
233
+ applied: number;
234
+ skipped: number;
235
+ errors: Array<{
236
+ log: StableBufferTransactionLog;
237
+ error: unknown;
238
+ }>;
239
+ }
240
+ export type TransactionLogsLoader = (context: ExecutionContext) => StableBufferTransactionLog[] | Promise<StableBufferTransactionLog[]>;
241
+ export interface ExecutionContext {
242
+ workflowId?: string;
243
+ branchId?: string;
244
+ phaseId?: string;
245
+ requestId?: string;
246
+ }
247
+ export interface StableBufferInstance {
248
+ run<T>(fn: (state: Record<string, any>) => T | Promise<T>, options?: StableBufferTransactionOptions): Promise<T>;
249
+ read(): Record<string, any>;
250
+ getState(): Record<string, any>;
251
+ setState(state: Record<string, any>): void;
252
+ }
253
+ export type BufferLike = Record<string, any> | StableBufferInstance;
254
+ export interface API_GATEWAY_OPTIONS<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
255
+ commonRequestData?: Partial<REQUEST_DATA<RequestDataType>>;
256
+ commonAttempts?: number;
257
+ commonHookParams?: HookParams;
258
+ commonPerformAllAttempts?: boolean;
259
+ commonWait?: number;
260
+ commonMaxAllowedWait?: number;
261
+ commonRetryStrategy?: RETRY_STRATEGY_TYPES;
262
+ commonJitter?: number;
263
+ commonLogAllErrors?: boolean;
264
+ commonLogAllSuccessfulAttempts?: boolean;
265
+ commonMaxSerializableChars?: number;
266
+ commonTrialMode?: TRIAL_MODE_OPTIONS;
267
+ commonResponseAnalyzer?: (options: ResponseAnalysisHookOptions<RequestDataType, ResponseDataType>) => boolean | Promise<boolean>;
268
+ commonResReq?: boolean;
269
+ commonFinalErrorAnalyzer?: (options: FinalErrorAnalysisHookOptions<RequestDataType>) => boolean | Promise<boolean>;
270
+ commonHandleErrors?: (options: HandleErrorHookOptions<RequestDataType>) => any | Promise<any>;
271
+ commonHandleSuccessfulAttemptData?: (options: HandleSuccessfulAttemptDataHookOptions<RequestDataType, ResponseDataType>) => any | Promise<any>;
272
+ commonPreExecution?: RequestPreExecutionOptions;
273
+ commonCache?: CacheConfig;
274
+ commonStatePersistence?: StatePersistenceConfig;
275
+ commonExecutionTimeout?: number;
276
+ commonFunctionHookParams?: FunctionHookParams;
277
+ commonFunctionResponseAnalyzer?: (options: FunctionResponseAnalysisHookOptions<FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
278
+ commonReturnResult?: boolean;
279
+ commonFinalFunctionErrorAnalyzer?: (options: FinalFunctionErrorAnalysisHookOptions<FunctionArgsType>) => boolean | Promise<boolean>;
280
+ commonHandleFunctionErrors?: (options: HandleFunctionErrorHookOptions<FunctionArgsType>) => any | Promise<any>;
281
+ commonHandleSuccessfulFunctionAttemptData?: (options: HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
282
+ commonFunctionPreExecution?: FunctionPreExecutionOptions<FunctionArgsType, FunctionReturnType>;
283
+ commonFunctionCache?: FunctionCacheConfig<FunctionArgsType, FunctionReturnType>;
284
+ concurrentExecution?: boolean;
285
+ requestGroups?: RequestGroup<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
286
+ stopOnFirstError?: boolean;
287
+ sharedBuffer?: BufferLike;
288
+ maxConcurrentRequests?: number;
289
+ rateLimit?: RateLimitConfig;
290
+ circuitBreaker?: CircuitBreakerConfig | CircuitBreaker;
291
+ executionContext?: Partial<ExecutionContext>;
292
+ metricsGuardrails?: MetricsGuardrails;
293
+ enableRacing?: boolean;
294
+ maxTimeout?: number;
295
+ loadTransactionLogs?: TransactionLogsLoader;
296
+ transactionLogs?: StableBufferTransactionLog[];
297
+ }
298
+ export interface RequestGroup<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
299
+ id: string;
300
+ commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, "concurrentExecution" | "stopOnFirstError" | "requestGroups" | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker" | "maxTimeout" | "executionContext" | "enableRacing" | "metricsGuardrails">;
301
+ }
302
+ export type API_GATEWAY_REQUEST_OPTIONS_TYPE<RequestDataType, ResponseDataType> = Omit<STABLE_REQUEST<RequestDataType, ResponseDataType>, 'reqData'> & {
303
+ reqData?: Partial<STABLE_REQUEST<RequestDataType, ResponseDataType>['reqData']>;
304
+ };
305
+ export interface API_GATEWAY_REQUEST<RequestDataType = any, ResponseDataType = any> {
306
+ id: string;
307
+ groupId?: string;
308
+ requestOptions: API_GATEWAY_REQUEST_OPTIONS_TYPE<RequestDataType, ResponseDataType>;
309
+ }
310
+ export type API_GATEWAY_FUNCTION_OPTIONS_TYPE<FunctionArgsType extends any[], FunctionReturnType> = Omit<STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>, 'fn' | 'args'> & {
311
+ fn?: STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>['fn'];
312
+ args?: FunctionArgsType;
313
+ };
314
+ export interface API_GATEWAY_FUNCTION<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
315
+ id: string;
316
+ groupId?: string;
317
+ functionOptions: API_GATEWAY_FUNCTION_OPTIONS_TYPE<FunctionArgsType, FunctionReturnType>;
318
+ }
319
+ export type RequestOrFunctionType = RequestOrFunction.REQUEST | RequestOrFunction.FUNCTION;
320
+ export type API_GATEWAY_ITEM<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> = {
321
+ type: RequestOrFunction.REQUEST;
322
+ request: API_GATEWAY_REQUEST<RequestDataType, ResponseDataType>;
323
+ } | {
324
+ type: RequestOrFunction.FUNCTION;
325
+ function: API_GATEWAY_FUNCTION<FunctionArgsType, FunctionReturnType>;
326
+ };
327
+ export interface API_GATEWAY_RESPONSE<ResponseDataType = any, FunctionReturnType = any> {
328
+ requestId: string;
329
+ groupId?: string;
330
+ success: boolean;
331
+ data?: ResponseDataType | FunctionReturnType | boolean;
332
+ error?: string;
333
+ type?: RequestOrFunctionType;
334
+ }
335
+ export interface ApiGatewayInfrastructureMetrics {
336
+ circuitBreaker?: CircuitBreakerDashboardMetrics;
337
+ cache?: CacheDashboardMetrics;
338
+ rateLimiter?: RateLimiterDashboardMetrics;
339
+ concurrencyLimiter?: ConcurrencyLimiterDashboardMetrics;
340
+ }
341
+ export interface ApiGatewayMetrics {
342
+ totalRequests: number;
343
+ successfulRequests: number;
344
+ failedRequests: number;
345
+ successRate: number;
346
+ failureRate: number;
347
+ executionTime: number;
348
+ timestamp: string;
349
+ throughput: number;
350
+ averageRequestDuration: number;
351
+ requestGroups?: RequestGroupMetrics[];
352
+ infrastructureMetrics?: ApiGatewayInfrastructureMetrics;
353
+ validation?: MetricsValidationResult;
354
+ }
355
+ export interface API_GATEWAY_RESULT<ResponseDataType = any, FunctionReturnType = any> extends Array<API_GATEWAY_RESPONSE<ResponseDataType, FunctionReturnType>> {
356
+ metrics?: ApiGatewayMetrics;
357
+ }
358
+ export type ApiRequestOptionsMapping = {
359
+ localKey: string;
360
+ commonKey: string;
361
+ groupCommonKey: string;
362
+ targetKey: string;
363
+ };
364
+ export type CONCURRENT_REQUEST_EXECUTION_OPTIONS<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> = Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, "concurrentExecution"> & {
365
+ executionContext?: Partial<ExecutionContext>;
366
+ transactionLogs?: StableBufferTransactionLog[];
367
+ };
368
+ export interface ERROR_LOG {
369
+ timestamp: string;
370
+ executionTime: number;
371
+ statusCode: number;
372
+ attempt: string;
373
+ error: string;
374
+ type: RESPONSE_ERROR_TYPES;
375
+ isRetryable: boolean;
376
+ }
377
+ export interface ReqFnResponse<ResponseDataType = any> {
378
+ ok: boolean;
379
+ isRetryable: boolean;
380
+ timestamp: string;
381
+ executionTime: number;
382
+ error?: string;
383
+ statusCode: number;
384
+ data?: ResponseDataType | {
385
+ trialMode: TRIAL_MODE_OPTIONS;
386
+ };
387
+ fromCache?: boolean;
388
+ }
389
+ export interface FnExecResponse<FunctionReturnType = any> {
390
+ ok: boolean;
391
+ isRetryable: boolean;
392
+ timestamp: string;
393
+ executionTime: number;
394
+ error?: string;
395
+ data?: FunctionReturnType | {
396
+ trialMode: TRIAL_MODE_OPTIONS;
397
+ };
398
+ fromCache?: boolean;
399
+ }
400
+ export type REQUEST_METHOD_TYPES = REQUEST_METHODS.GET | REQUEST_METHODS.POST | REQUEST_METHODS.DELETE | REQUEST_METHODS.PATCH | REQUEST_METHODS.PUT;
401
+ export interface REQUEST_DATA<RequestDataType = any> {
402
+ hostname: string;
403
+ protocol?: VALID_REQUEST_PROTOCOL_TYPES;
404
+ method?: REQUEST_METHOD_TYPES;
405
+ path?: `/${string}`;
406
+ port?: number;
407
+ headers?: Record<string, any>;
408
+ body?: RequestDataType;
409
+ query?: Record<string, any>;
410
+ timeout?: number;
411
+ signal?: AbortSignal;
412
+ }
413
+ type RESPONSE_ERROR_TYPES = RESPONSE_ERRORS.HTTP_ERROR | RESPONSE_ERRORS.INVALID_CONTENT;
414
+ export type RETRY_STRATEGY_TYPES = RETRY_STRATEGIES.FIXED | RETRY_STRATEGIES.LINEAR | RETRY_STRATEGIES.EXPONENTIAL;
415
+ export type SEQUENTIAL_REQUEST_EXECUTION_OPTIONS<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> = Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, "concurrentExecution"> & {
416
+ executionContext?: Partial<ExecutionContext>;
417
+ transactionLogs?: StableBufferTransactionLog[];
418
+ };
419
+ interface ObservabilityHooksOptions<RequestDataType = any> {
420
+ reqData: AxiosRequestConfig<RequestDataType>;
421
+ params?: any;
422
+ maxSerializableChars?: number;
423
+ preExecutionResult?: any;
424
+ commonBuffer?: Record<string, any>;
425
+ executionContext?: ExecutionContext;
426
+ transactionLogs?: StableBufferTransactionLog[];
427
+ }
428
+ interface AnalysisHookOptions<RequestDataType = any> extends Omit<ObservabilityHooksOptions<RequestDataType>, "maxSerializableChars"> {
429
+ trialMode?: TRIAL_MODE_OPTIONS;
430
+ params?: any;
431
+ preExecutionResult?: any;
432
+ executionContext?: ExecutionContext;
433
+ commonBuffer?: Record<string, any>;
434
+ transactionLogs?: StableBufferTransactionLog[];
435
+ }
436
+ export interface ResponseAnalysisHookOptions<RequestDataType = any, ResponseDataType = any> extends AnalysisHookOptions<RequestDataType> {
437
+ data: ResponseDataType;
438
+ }
439
+ export interface FinalErrorAnalysisHookOptions<RequestDataType = any> extends AnalysisHookOptions<RequestDataType> {
440
+ error: any;
441
+ }
442
+ export interface HandleErrorHookOptions<RequestDataType = any> extends ObservabilityHooksOptions<RequestDataType> {
443
+ errorLog: ERROR_LOG;
444
+ }
445
+ export interface HandleSuccessfulAttemptDataHookOptions<RequestDataType = any, ResponseDataType = any> extends ObservabilityHooksOptions<RequestDataType> {
446
+ successfulAttemptData: SUCCESSFUL_ATTEMPT_DATA<ResponseDataType>;
447
+ }
448
+ export interface HookParams {
449
+ responseAnalyzerParams?: any;
450
+ handleSuccessfulAttemptDataParams?: any;
451
+ handleErrorsParams?: any;
452
+ finalErrorAnalyzerParams?: any;
453
+ }
454
+ export interface FunctionHookParams {
455
+ responseAnalyzerParams?: any;
456
+ handleSuccessfulAttemptDataParams?: any;
457
+ handleErrorsParams?: any;
458
+ finalErrorAnalyzerParams?: any;
459
+ }
460
+ interface FunctionObservabilityHooksOptions<FunctionArgsType extends any[] = any[]> {
461
+ fn: (...args: FunctionArgsType) => any;
462
+ args: FunctionArgsType;
463
+ params?: any;
464
+ maxSerializableChars?: number;
465
+ preExecutionResult?: any;
466
+ commonBuffer?: Record<string, any>;
467
+ executionContext?: ExecutionContext;
468
+ transactionLogs?: StableBufferTransactionLog[];
469
+ }
470
+ interface FunctionAnalysisHookOptions<FunctionArgsType extends any[] = any[]> extends Omit<FunctionObservabilityHooksOptions<FunctionArgsType>, "maxSerializableChars"> {
471
+ trialMode?: TRIAL_MODE_OPTIONS;
472
+ params?: any;
473
+ preExecutionResult?: any;
474
+ executionContext?: ExecutionContext;
475
+ commonBuffer?: Record<string, any>;
476
+ transactionLogs?: StableBufferTransactionLog[];
477
+ }
478
+ export interface FunctionResponseAnalysisHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends FunctionAnalysisHookOptions<FunctionArgsType> {
479
+ data: FunctionReturnType;
480
+ }
481
+ export interface FinalFunctionErrorAnalysisHookOptions<FunctionArgsType extends any[] = any[]> extends FunctionAnalysisHookOptions<FunctionArgsType> {
482
+ error: any;
483
+ }
484
+ export interface HandleFunctionErrorHookOptions<FunctionArgsType extends any[] = any[]> extends FunctionObservabilityHooksOptions<FunctionArgsType> {
485
+ errorLog: FUNCTION_ERROR_LOG;
486
+ }
487
+ export interface HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends FunctionObservabilityHooksOptions<FunctionArgsType> {
488
+ successfulAttemptData: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType>;
489
+ }
490
+ export interface PreExecutionHookOptions<RequestDataType = any, ResponseDataType = any> {
491
+ inputParams?: any;
492
+ commonBuffer?: Record<string, any>;
493
+ stableRequestOptions: STABLE_REQUEST<RequestDataType, ResponseDataType>;
494
+ transactionLogs?: StableBufferTransactionLog[];
495
+ }
496
+ export interface FunctionPreExecutionHookOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
497
+ inputParams?: any;
498
+ commonBuffer?: Record<string, any>;
499
+ stableFunctionOptions: STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>;
500
+ transactionLogs?: StableBufferTransactionLog[];
501
+ }
502
+ interface WorkflowPreExecutionHookOptions {
503
+ params?: any;
504
+ sharedBuffer?: Record<string, any>;
505
+ workflowId: string;
506
+ branchId?: string;
507
+ transactionLogs?: StableBufferTransactionLog[];
508
+ }
509
+ export interface PrePhaseExecutionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends WorkflowPreExecutionHookOptions {
510
+ phaseId: string;
511
+ phaseIndex: number;
512
+ phase: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
513
+ }
514
+ export interface PreBranchExecutionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> extends Omit<WorkflowPreExecutionHookOptions, 'branchId'> {
515
+ branchId: string;
516
+ branchIndex: number;
517
+ branch: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
518
+ }
519
+ export interface RequestPreExecutionOptions<RequestDataType = any, ResponseDataType = any> {
520
+ preExecutionHook: (options: PreExecutionHookOptions<RequestDataType, ResponseDataType>) => any | Promise<any>;
521
+ preExecutionHookParams?: any;
522
+ applyPreExecutionConfigOverride?: boolean;
523
+ continueOnPreExecutionHookFailure?: boolean;
524
+ }
525
+ export interface FunctionPreExecutionOptions<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
526
+ preExecutionHook: (options: FunctionPreExecutionHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
527
+ preExecutionHookParams?: any;
528
+ applyPreExecutionConfigOverride?: boolean;
529
+ continueOnPreExecutionHookFailure?: boolean;
530
+ }
531
+ export interface StatePersistenceOptions {
532
+ executionContext: ExecutionContext;
533
+ persistenceStage: PersistenceStage;
534
+ params?: any;
535
+ buffer: Record<string, any>;
536
+ }
537
+ export interface StatePersistenceConfig {
538
+ persistenceFunction: (options: StatePersistenceOptions) => Promise<Record<string, any>> | Record<string, any>;
539
+ persistenceParams?: any;
540
+ loadBeforeHooks?: boolean;
541
+ storeAfterHooks?: boolean;
542
+ }
543
+ export interface STABLE_REQUEST<RequestDataType = any, ResponseDataType = any> {
544
+ reqData: REQUEST_DATA<RequestDataType>;
545
+ responseAnalyzer?: (options: ResponseAnalysisHookOptions<RequestDataType, ResponseDataType>) => boolean | Promise<boolean>;
546
+ resReq?: boolean;
547
+ attempts?: number;
548
+ performAllAttempts?: boolean;
549
+ wait?: number;
550
+ maxAllowedWait?: number;
551
+ retryStrategy?: RETRY_STRATEGY_TYPES;
552
+ jitter?: number;
553
+ logAllErrors?: boolean;
554
+ handleErrors?: (options: HandleErrorHookOptions<RequestDataType>) => any | Promise<any>;
555
+ logAllSuccessfulAttempts?: boolean;
556
+ handleSuccessfulAttemptData?: (options: HandleSuccessfulAttemptDataHookOptions<RequestDataType, ResponseDataType>) => any | Promise<any>;
557
+ maxSerializableChars?: number;
558
+ finalErrorAnalyzer?: (options: FinalErrorAnalysisHookOptions<RequestDataType>) => boolean | Promise<boolean>;
559
+ trialMode?: TRIAL_MODE_OPTIONS;
560
+ hookParams?: HookParams;
561
+ preExecution?: RequestPreExecutionOptions;
562
+ commonBuffer?: BufferLike;
563
+ cache?: CacheConfig;
564
+ executionContext?: ExecutionContext;
565
+ circuitBreaker?: CircuitBreakerConfig | CircuitBreaker;
566
+ statePersistence?: StatePersistenceConfig;
567
+ metricsGuardrails?: MetricsGuardrails;
568
+ throwOnFailedErrorAnalysis?: boolean;
569
+ loadTransactionLogs?: TransactionLogsLoader;
570
+ transactionLogs?: StableBufferTransactionLog[];
571
+ }
572
+ export interface STABLE_FUNCTION<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
573
+ fn: (...args: FunctionArgsType) => FunctionReturnType | Promise<FunctionReturnType>;
574
+ args: FunctionArgsType;
575
+ responseAnalyzer?: (options: FunctionResponseAnalysisHookOptions<FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
576
+ returnResult?: boolean;
577
+ attempts?: number;
578
+ performAllAttempts?: boolean;
579
+ wait?: number;
580
+ maxAllowedWait?: number;
581
+ retryStrategy?: RETRY_STRATEGY_TYPES;
582
+ jitter?: number;
583
+ logAllErrors?: boolean;
584
+ handleErrors?: (options: HandleFunctionErrorHookOptions<FunctionArgsType>) => any | Promise<any>;
585
+ logAllSuccessfulAttempts?: boolean;
586
+ handleSuccessfulAttemptData?: (options: HandleSuccessfulFunctionAttemptDataHookOptions<FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
587
+ maxSerializableChars?: number;
588
+ finalErrorAnalyzer?: (options: FinalFunctionErrorAnalysisHookOptions<FunctionArgsType>) => boolean | Promise<boolean>;
589
+ trialMode?: TRIAL_MODE_OPTIONS;
590
+ hookParams?: FunctionHookParams;
591
+ preExecution?: FunctionPreExecutionOptions<FunctionArgsType, FunctionReturnType>;
592
+ commonBuffer?: BufferLike;
593
+ cache?: FunctionCacheConfig<FunctionArgsType, FunctionReturnType>;
594
+ executionContext?: ExecutionContext;
595
+ circuitBreaker?: CircuitBreakerConfig | CircuitBreaker;
596
+ statePersistence?: StatePersistenceConfig;
597
+ rateLimit?: RateLimitConfig;
598
+ maxConcurrentRequests?: number;
599
+ metricsGuardrails?: MetricsGuardrails;
600
+ throwOnFailedErrorAnalysis?: boolean;
601
+ executionTimeout?: number;
602
+ loadTransactionLogs?: TransactionLogsLoader;
603
+ transactionLogs?: StableBufferTransactionLog[];
604
+ }
605
+ export interface StableRequestInfrastructureMetrics {
606
+ circuitBreaker?: CircuitBreakerDashboardMetrics;
607
+ cache?: CacheDashboardMetrics;
608
+ }
609
+ export interface StableRequestMetrics {
610
+ totalAttempts: number;
611
+ successfulAttempts: number;
612
+ failedAttempts: number;
613
+ totalExecutionTime: number;
614
+ averageAttemptTime: number;
615
+ infrastructureMetrics?: StableRequestInfrastructureMetrics;
616
+ validation?: MetricsValidationResult;
617
+ }
618
+ export interface StableFunctionInfrastructureMetrics {
619
+ circuitBreaker?: CircuitBreakerDashboardMetrics;
620
+ cache?: CacheDashboardMetrics;
621
+ rateLimiter?: RateLimiterDashboardMetrics;
622
+ concurrencyLimiter?: ConcurrencyLimiterDashboardMetrics;
623
+ }
624
+ export interface StableFunctionMetrics {
625
+ totalAttempts: number;
626
+ successfulAttempts: number;
627
+ failedAttempts: number;
628
+ totalExecutionTime: number;
629
+ averageAttemptTime: number;
630
+ infrastructureMetrics?: StableFunctionInfrastructureMetrics;
631
+ validation?: MetricsValidationResult;
632
+ }
633
+ export interface STABLE_REQUEST_RESULT<ResponseDataType = any> {
634
+ success: boolean;
635
+ data?: ResponseDataType | boolean;
636
+ error?: string;
637
+ errorLogs?: ERROR_LOG[];
638
+ successfulAttempts?: SUCCESSFUL_ATTEMPT_DATA<ResponseDataType>[];
639
+ metrics?: StableRequestMetrics;
640
+ }
641
+ export interface STABLE_FUNCTION_RESULT<FunctionReturnType = any, ReturnResult extends boolean = boolean> {
642
+ success: boolean;
643
+ data?: ReturnResult extends true ? FunctionReturnType : boolean;
644
+ error?: string;
645
+ errorLogs?: FUNCTION_ERROR_LOG[];
646
+ successfulAttempts?: SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType>[];
647
+ metrics?: StableFunctionMetrics;
648
+ }
649
+ export interface SUCCESSFUL_ATTEMPT_DATA<ResponseDataType = any> {
650
+ attempt: string;
651
+ timestamp: string;
652
+ executionTime: number;
653
+ data: ResponseDataType;
654
+ statusCode: number;
655
+ }
656
+ export interface SUCCESSFUL_FUNCTION_ATTEMPT_DATA<FunctionReturnType = any> {
657
+ attempt: string;
658
+ timestamp: string;
659
+ executionTime: number;
660
+ data: FunctionReturnType;
661
+ }
662
+ export interface FUNCTION_ERROR_LOG {
663
+ timestamp: string;
664
+ executionTime: number;
665
+ attempt: string;
666
+ error: string;
667
+ isRetryable: boolean;
668
+ }
669
+ export interface TRIAL_MODE_OPTIONS {
670
+ enabled: boolean;
671
+ reqFailureProbability?: number;
672
+ retryFailureProbability?: number;
673
+ }
674
+ export type VALID_REQUEST_PROTOCOL_TYPES = VALID_REQUEST_PROTOCOLS.HTTP | VALID_REQUEST_PROTOCOLS.HTTPS;
675
+ export interface STABLE_WORKFLOW_PHASE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
676
+ id?: string;
677
+ requests?: API_GATEWAY_REQUEST<RequestDataType, ResponseDataType>[];
678
+ functions?: API_GATEWAY_FUNCTION<FunctionArgsType, FunctionReturnType>[];
679
+ items?: API_GATEWAY_ITEM<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
680
+ concurrentExecution?: boolean;
681
+ stopOnFirstError?: boolean;
682
+ markConcurrentPhase?: boolean;
683
+ maxConcurrentRequests?: number;
684
+ rateLimit?: RateLimitConfig;
685
+ circuitBreaker?: CircuitBreakerConfig;
686
+ maxReplayCount?: number;
687
+ allowReplay?: boolean;
688
+ allowSkip?: boolean;
689
+ phaseDecisionHook?: (options: PhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
690
+ commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | "maxConcurrentRequests" | "rateLimit" | "circuitBreaker" | "maxTimeout" | "executionContext" | "metricsGuardrails">;
691
+ branchId?: string;
692
+ statePersistence?: StatePersistenceConfig;
693
+ metricsGuardrails?: MetricsGuardrails;
694
+ maxTimeout?: number;
695
+ }
696
+ 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'> {
697
+ workflowId?: string;
698
+ startPhaseIndex?: number;
699
+ stopOnFirstPhaseError?: boolean;
700
+ logPhaseResults?: boolean;
701
+ concurrentPhaseExecution?: boolean;
702
+ enableBranchExecution?: boolean;
703
+ enableBranchRacing?: boolean;
704
+ branches?: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
705
+ enableMixedExecution?: boolean;
706
+ enableNonLinearExecution?: boolean;
707
+ maxWorkflowIterations?: number;
708
+ statePersistence?: StatePersistenceConfig;
709
+ handlePhaseCompletion?: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
710
+ handlePhaseError?: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
711
+ handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
712
+ handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
713
+ handleBranchDecision?: (decision: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, branchResult: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>, maxSerializableChars?: number, transactionLogs?: StableBufferTransactionLog[]) => any | Promise<any>;
714
+ prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
715
+ preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
716
+ maxSerializableChars?: number;
717
+ workflowHookParams?: WorkflowHookParams;
718
+ loadTransactionLogs?: TransactionLogsLoader;
719
+ transactionLogs?: StableBufferTransactionLog[];
720
+ }
721
+ export interface WorkflowInfrastructureMetrics {
722
+ circuitBreaker?: CircuitBreakerDashboardMetrics;
723
+ cache?: CacheDashboardMetrics;
724
+ rateLimiter?: RateLimiterDashboardMetrics;
725
+ concurrencyLimiter?: ConcurrencyLimiterDashboardMetrics;
726
+ }
727
+ export interface STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
728
+ workflowId: string;
729
+ branchId?: string;
730
+ phaseId: string;
731
+ phaseIndex: number;
732
+ success: boolean;
733
+ executionTime: number;
734
+ timestamp: string;
735
+ totalRequests: number;
736
+ successfulRequests: number;
737
+ failedRequests: number;
738
+ responses: API_GATEWAY_RESPONSE<ResponseDataType, FunctionReturnType>[];
739
+ executionNumber?: number;
740
+ skipped?: boolean;
741
+ decision?: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
742
+ error?: string;
743
+ metrics?: PhaseMetrics;
744
+ validation?: MetricsValidationResult;
745
+ infrastructureMetrics?: WorkflowInfrastructureMetrics;
746
+ }
747
+ export interface STABLE_WORKFLOW_RESULT<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
748
+ workflowId: string;
749
+ success: boolean;
750
+ executionTime: number;
751
+ timestamp: string;
752
+ totalPhases: number;
753
+ completedPhases: number;
754
+ totalRequests: number;
755
+ successfulRequests: number;
756
+ failedRequests: number;
757
+ phases: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
758
+ executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
759
+ branches?: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
760
+ branchExecutionHistory?: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
761
+ terminatedEarly?: boolean;
762
+ terminationReason?: string;
763
+ error?: string;
764
+ metrics?: WorkflowMetrics;
765
+ validation?: MetricsValidationResult;
766
+ requestGroupMetrics?: RequestGroupMetrics[];
767
+ infrastructureMetrics?: WorkflowInfrastructureMetrics;
768
+ }
769
+ export interface WorkflowHookParams {
770
+ handlePhaseCompletionParams?: any;
771
+ handlePhaseErrorParams?: any;
772
+ handlePhaseDecisionParams?: any;
773
+ handleBranchDecisionParams?: any;
774
+ prePhaseExecutionHookParams?: any;
775
+ preBranchExecutionHookParams?: any;
776
+ statePersistence?: StatePersistenceConfig;
777
+ }
778
+ export interface HandlePhaseCompletionHookOptions<ResponseDataType = any, FunctionReturnType = any> {
779
+ workflowId: string;
780
+ branchId?: string;
781
+ phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
782
+ maxSerializableChars?: number;
783
+ params?: any;
784
+ sharedBuffer?: Record<string, any>;
785
+ transactionLogs?: StableBufferTransactionLog[];
786
+ }
787
+ export interface HandlePhaseErrorHookOptions<ResponseDataType = any, FunctionReturnType = any> extends HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType> {
788
+ error: any;
789
+ }
790
+ export interface HandlePhaseDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
791
+ decision: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
792
+ phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
793
+ maxSerializableChars?: number;
794
+ transactionLogs?: StableBufferTransactionLog[];
795
+ }
796
+ export type InfrastructurePersistenceOperationType = 'load' | 'store';
797
+ export interface InfrastructurePersistenceOperation<TState> {
798
+ operationId: string;
799
+ type: InfrastructurePersistenceOperationType;
800
+ timestamp: number;
801
+ state?: TState;
802
+ }
803
+ export type InfrastructurePersistenceTransactionResult<TState> = {
804
+ state?: TState | null;
805
+ skipped?: boolean;
806
+ } | TState | null | undefined | void;
807
+ export interface InfrastructurePersistence<TState> {
808
+ load?: () => TState | null | undefined | Promise<TState | null | undefined>;
809
+ store?: (state: TState) => void | Promise<void>;
810
+ transaction?: (operation: InfrastructurePersistenceOperation<TState>) => InfrastructurePersistenceTransactionResult<TState> | Promise<InfrastructurePersistenceTransactionResult<TState>>;
811
+ buffer?: BufferLike;
812
+ }
813
+ export interface CircuitBreakerPersistedState {
814
+ state: CircuitBreakerState;
815
+ totalRequests: number;
816
+ failedRequests: number;
817
+ successfulRequests: number;
818
+ totalAttempts: number;
819
+ failedAttempts: number;
820
+ successfulAttempts: number;
821
+ lastFailureTime: number;
822
+ halfOpenRequests: number;
823
+ halfOpenSuccesses: number;
824
+ halfOpenFailures: number;
825
+ stateTransitions: number;
826
+ lastStateChangeTime: number;
827
+ openCount: number;
828
+ halfOpenCount: number;
829
+ totalOpenDuration: number;
830
+ lastOpenTime: number;
831
+ recoveryAttempts: number;
832
+ successfulRecoveries: number;
833
+ failedRecoveries: number;
834
+ }
835
+ export interface RateLimiterPersistedState {
836
+ tokens: number;
837
+ lastRefillTime: number;
838
+ totalRequests: number;
839
+ throttledRequests: number;
840
+ completedRequests: number;
841
+ peakQueueLength: number;
842
+ totalQueueWaitTime: number;
843
+ peakRequestRate: number;
844
+ requestsInCurrentWindow: number;
845
+ windowStartTime: number;
846
+ }
847
+ export interface ConcurrencyLimiterPersistedState {
848
+ totalRequests: number;
849
+ completedRequests: number;
850
+ failedRequests: number;
851
+ queuedRequests: number;
852
+ peakConcurrency: number;
853
+ peakQueueLength: number;
854
+ totalQueueWaitTime: number;
855
+ totalExecutionTime: number;
856
+ }
857
+ export interface CacheManagerPersistedState {
858
+ entries: Array<{
859
+ key: string;
860
+ value: CachedResponse;
861
+ }>;
862
+ accessOrder: string[];
863
+ hits: number;
864
+ misses: number;
865
+ sets: number;
866
+ evictions: number;
867
+ expirations: number;
868
+ }
869
+ export interface FunctionCacheManagerPersistedState {
870
+ entries: Array<{
871
+ key: string;
872
+ value: CachedFunctionResponse;
873
+ }>;
874
+ stats: {
875
+ hits: number;
876
+ misses: number;
877
+ sets: number;
878
+ evictions: number;
879
+ };
880
+ }
881
+ export interface RateLimitConfig {
882
+ maxRequests: number;
883
+ windowMs: number;
884
+ persistence?: InfrastructurePersistence<RateLimiterPersistedState>;
885
+ }
886
+ export interface ConcurrencyLimiterConfig {
887
+ limit: number;
888
+ persistence?: InfrastructurePersistence<ConcurrencyLimiterPersistedState>;
889
+ }
890
+ export interface CircuitBreakerConfig {
891
+ failureThresholdPercentage: number;
892
+ minimumRequests: number;
893
+ recoveryTimeoutMs: number;
894
+ successThresholdPercentage?: number;
895
+ halfOpenMaxRequests?: number;
896
+ trackIndividualAttempts?: boolean;
897
+ persistence?: InfrastructurePersistence<CircuitBreakerPersistedState>;
898
+ }
899
+ export interface CacheConfig {
900
+ enabled: boolean;
901
+ ttl?: number;
902
+ respectCacheControl?: boolean;
903
+ cacheableStatusCodes?: number[];
904
+ maxSize?: number;
905
+ excludeMethods?: REQUEST_METHODS[];
906
+ keyGenerator?: (config: AxiosRequestConfig) => string;
907
+ persistence?: InfrastructurePersistence<CacheManagerPersistedState>;
908
+ }
909
+ export interface FunctionCacheConfig<TArgs extends any[] = any[], TReturn = any> {
910
+ enabled: boolean;
911
+ ttl?: number;
912
+ maxSize?: number;
913
+ keyGenerator?: (fn: (...args: TArgs) => any, args: TArgs) => string;
914
+ persistence?: InfrastructurePersistence<FunctionCacheManagerPersistedState>;
915
+ }
916
+ export interface CachedResponse<T = any> {
917
+ data: T;
918
+ status: number;
919
+ statusText: string;
920
+ headers: Record<string, any>;
921
+ timestamp: number;
922
+ expiresAt: number;
923
+ }
924
+ export interface CachedFunctionResponse<T = any> {
925
+ data: T;
926
+ timestamp: number;
927
+ expiresAt: number;
928
+ }
929
+ export interface PhaseExecutionDecision<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
930
+ action: PHASE_DECISION_ACTIONS;
931
+ targetPhaseId?: string;
932
+ replayCount?: number;
933
+ metadata?: Record<string, any>;
934
+ addPhases?: ReadonlyArray<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
935
+ }
936
+ export interface PhaseDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
937
+ workflowId: string;
938
+ branchId?: string;
939
+ phaseResult: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>;
940
+ phaseId: string;
941
+ phaseIndex: number;
942
+ executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
943
+ sharedBuffer?: Record<string, any>;
944
+ params?: any;
945
+ concurrentPhaseResults?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType>[];
946
+ transactionLogs?: StableBufferTransactionLog[];
947
+ }
948
+ export interface PhaseExecutionRecord<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
949
+ phaseId: string;
950
+ phaseIndex: number;
951
+ executionNumber: number;
952
+ timestamp: string;
953
+ success: boolean;
954
+ executionTime: number;
955
+ decision?: PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
956
+ }
957
+ export interface NonLinearWorkflowContext<RequestDataType, ResponseDataType, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
958
+ phases: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
959
+ startPhaseIndex?: number;
960
+ workflowId: string;
961
+ branchId?: string;
962
+ commonGatewayOptions: any;
963
+ requestGroups: any[];
964
+ logPhaseResults: boolean;
965
+ handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
966
+ handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
967
+ handlePhaseDecision?: (options: HandlePhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => any | Promise<any>;
968
+ prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
969
+ maxSerializableChars: number;
970
+ workflowHookParams: any;
971
+ sharedBuffer?: Record<string, any>;
972
+ stopOnFirstPhaseError: boolean;
973
+ maxWorkflowIterations: number;
974
+ transactionLogs?: StableBufferTransactionLog[];
975
+ }
976
+ export interface EXECUTE_NON_LINEAR_WORKFLOW_RESPONSE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
977
+ phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
978
+ executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
979
+ totalRequests: number;
980
+ successfulRequests: number;
981
+ failedRequests: number;
982
+ terminatedEarly: boolean;
983
+ terminationReason?: string;
984
+ }
985
+ export interface STABLE_WORKFLOW_BRANCH<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
986
+ id: string;
987
+ phases: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
988
+ markConcurrentBranch?: boolean;
989
+ allowReplay?: boolean;
990
+ maxReplayCount?: number;
991
+ allowSkip?: boolean;
992
+ branchDecisionHook?: (options: BranchDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
993
+ statePersistence?: StatePersistenceConfig;
994
+ commonConfig?: Omit<API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, 'concurrentExecution' | 'stopOnFirstError' | 'requestGroups' | 'maxConcurrentRequests' | 'rateLimit' | 'circuitBreaker' | 'maxTimeout' | "executionContext" | "metricsGuardrails">;
995
+ metricsGuardrails?: MetricsGuardrails;
996
+ maxTimeout?: number;
997
+ }
998
+ export interface BranchDecisionHookOptions<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
999
+ workflowId: string;
1000
+ branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
1001
+ branchId: string;
1002
+ branchIndex: number;
1003
+ executionNumber: number;
1004
+ executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1005
+ branchExecutionHistory: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1006
+ sharedBuffer?: Record<string, any>;
1007
+ params?: any;
1008
+ concurrentBranchResults?: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
1009
+ transactionLogs?: StableBufferTransactionLog[];
1010
+ }
1011
+ export interface BranchExecutionDecision<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1012
+ action: PHASE_DECISION_ACTIONS;
1013
+ targetBranchId?: string;
1014
+ metadata?: Record<string, any>;
1015
+ addPhases?: ReadonlyArray<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1016
+ addBranches?: ReadonlyArray<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1017
+ }
1018
+ export interface BranchExecutionResult<ResponseDataType = any, FunctionReturnType = any, RequestDataType = any, FunctionArgsType extends any[] = any[]> {
1019
+ workflowId: string;
1020
+ branchId: string;
1021
+ branchIndex: number;
1022
+ success: boolean;
1023
+ executionTime: number;
1024
+ completedPhases: number;
1025
+ phaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
1026
+ decision?: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1027
+ executionNumber: number;
1028
+ skipped?: boolean;
1029
+ error?: string;
1030
+ metrics?: BranchMetrics;
1031
+ validation?: MetricsValidationResult;
1032
+ }
1033
+ export interface BranchExecutionRecord<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1034
+ branchId: string;
1035
+ branchIndex: number;
1036
+ executionNumber: number;
1037
+ timestamp: string;
1038
+ success: boolean;
1039
+ executionTime: number;
1040
+ decision?: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1041
+ }
1042
+ export interface HandleBranchCompletionHookOptions<ResponseDataType = any, FunctionReturnType = any> {
1043
+ workflowId: string;
1044
+ branchId: string;
1045
+ branchResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, any, any[]>[];
1046
+ success: boolean;
1047
+ maxSerializableChars?: number;
1048
+ transactionLogs?: StableBufferTransactionLog[];
1049
+ }
1050
+ export interface BranchWorkflowContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1051
+ branches: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1052
+ workflowId: string;
1053
+ commonGatewayOptions: any;
1054
+ requestGroups: any[];
1055
+ logPhaseResults: boolean;
1056
+ handlePhaseCompletion: (options: HandlePhaseCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
1057
+ handlePhaseError: (options: HandlePhaseErrorHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
1058
+ handleBranchCompletion?: (options: HandleBranchCompletionHookOptions<ResponseDataType, FunctionReturnType>) => any | Promise<any>;
1059
+ handleBranchDecision?: (decision: BranchExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>, branchResult: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>, maxSerializableChars?: number, transactionLogs?: StableBufferTransactionLog[]) => any | Promise<any>;
1060
+ preBranchExecutionHook?: (options: PreBranchExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1061
+ prePhaseExecutionHook?: (options: PrePhaseExecutionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1062
+ maxSerializableChars: number;
1063
+ workflowHookParams: any;
1064
+ sharedBuffer?: Record<string, any>;
1065
+ stopOnFirstPhaseError: boolean;
1066
+ enableBranchRacing?: boolean;
1067
+ maxWorkflowIterations: number;
1068
+ transactionLogs?: StableBufferTransactionLog[];
1069
+ }
1070
+ export interface EXECUTE_BRANCH_WORKFLOW_RESPONSE<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1071
+ branchResults: BranchExecutionResult<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
1072
+ allPhaseResults: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>[];
1073
+ executionHistory: PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1074
+ branchExecutionHistory: BranchExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1075
+ totalRequests: number;
1076
+ successfulRequests: number;
1077
+ failedRequests: number;
1078
+ terminatedEarly: boolean;
1079
+ terminationReason?: string;
1080
+ }
1081
+ export interface WorkflowMetrics {
1082
+ workflowId: string;
1083
+ success: boolean;
1084
+ executionTime: number;
1085
+ timestamp: string;
1086
+ totalPhases: number;
1087
+ completedPhases: number;
1088
+ skippedPhases: number;
1089
+ failedPhases: number;
1090
+ phaseCompletionRate: number;
1091
+ averagePhaseExecutionTime: number;
1092
+ totalRequests: number;
1093
+ successfulRequests: number;
1094
+ failedRequests: number;
1095
+ requestSuccessRate: number;
1096
+ requestFailureRate: number;
1097
+ terminatedEarly: boolean;
1098
+ terminationReason?: string;
1099
+ totalPhaseReplays: number;
1100
+ totalPhaseSkips: number;
1101
+ totalBranches?: number;
1102
+ completedBranches?: number;
1103
+ failedBranches?: number;
1104
+ branchSuccessRate?: number;
1105
+ throughput: number;
1106
+ averageRequestDuration?: number;
1107
+ }
1108
+ export interface BranchMetrics {
1109
+ branchId: string;
1110
+ branchIndex: number;
1111
+ executionNumber: number;
1112
+ success: boolean;
1113
+ executionTime: number;
1114
+ skipped: boolean;
1115
+ totalPhases: number;
1116
+ completedPhases: number;
1117
+ failedPhases: number;
1118
+ phaseCompletionRate: number;
1119
+ totalRequests: number;
1120
+ successfulRequests: number;
1121
+ failedRequests: number;
1122
+ requestSuccessRate: number;
1123
+ hasDecision: boolean;
1124
+ decisionAction?: string;
1125
+ error?: string;
1126
+ }
1127
+ export interface PhaseMetrics {
1128
+ phaseId: string;
1129
+ phaseIndex: number;
1130
+ workflowId: string;
1131
+ branchId?: string;
1132
+ executionNumber: number;
1133
+ success: boolean;
1134
+ skipped: boolean;
1135
+ executionTime: number;
1136
+ timestamp: string;
1137
+ totalRequests: number;
1138
+ successfulRequests: number;
1139
+ failedRequests: number;
1140
+ requestSuccessRate: number;
1141
+ requestFailureRate: number;
1142
+ hasDecision: boolean;
1143
+ decisionAction?: string;
1144
+ targetPhaseId?: string;
1145
+ replayCount?: number;
1146
+ error?: string;
1147
+ }
1148
+ export interface RequestGroupMetrics {
1149
+ groupId: string;
1150
+ totalRequests: number;
1151
+ successfulRequests: number;
1152
+ failedRequests: number;
1153
+ successRate: number;
1154
+ failureRate: number;
1155
+ requestIds: string[];
1156
+ }
1157
+ export interface RequestMetrics {
1158
+ requestId: string;
1159
+ groupId?: string;
1160
+ success: boolean;
1161
+ hasError: boolean;
1162
+ errorMessage?: string;
1163
+ }
1164
+ export interface CircuitBreakerDashboardMetrics {
1165
+ state: string;
1166
+ isHealthy: boolean;
1167
+ totalRequests: number;
1168
+ successfulRequests: number;
1169
+ failedRequests: number;
1170
+ failurePercentage: number;
1171
+ stateTransitions: number;
1172
+ lastStateChangeTime: number;
1173
+ timeSinceLastStateChange: number;
1174
+ openCount: number;
1175
+ totalOpenDuration: number;
1176
+ averageOpenDuration: number;
1177
+ isCurrentlyOpen: boolean;
1178
+ openUntil: number | null;
1179
+ timeUntilRecovery: number | null;
1180
+ recoveryAttempts: number;
1181
+ successfulRecoveries: number;
1182
+ failedRecoveries: number;
1183
+ recoverySuccessRate: number;
1184
+ config: Required<Omit<CircuitBreakerConfig, 'persistence'>>;
1185
+ }
1186
+ export interface CacheDashboardMetrics {
1187
+ isEnabled: boolean;
1188
+ currentSize: number;
1189
+ maxSize: number;
1190
+ validEntries: number;
1191
+ expiredEntries: number;
1192
+ utilizationPercentage: number;
1193
+ totalRequests: number;
1194
+ hits: number;
1195
+ misses: number;
1196
+ hitRate: number;
1197
+ missRate: number;
1198
+ sets: number;
1199
+ evictions: number;
1200
+ expirations: number;
1201
+ averageGetTime: number;
1202
+ averageSetTime: number;
1203
+ averageCacheAge: number;
1204
+ oldestEntryAge: number | null;
1205
+ newestEntryAge: number | null;
1206
+ networkRequestsSaved: number;
1207
+ cacheEfficiency: number;
1208
+ }
1209
+ export interface RateLimiterDashboardMetrics {
1210
+ maxRequests: number;
1211
+ windowMs: number;
1212
+ availableTokens: number;
1213
+ queueLength: number;
1214
+ requestsInCurrentWindow: number;
1215
+ totalRequests: number;
1216
+ completedRequests: number;
1217
+ throttledRequests: number;
1218
+ throttleRate: number;
1219
+ currentRequestRate: number;
1220
+ peakRequestRate: number;
1221
+ averageRequestRate: number;
1222
+ peakQueueLength: number;
1223
+ averageQueueWaitTime: number;
1224
+ isThrottling: boolean;
1225
+ utilizationPercentage: number;
1226
+ }
1227
+ export interface ConcurrencyLimiterDashboardMetrics {
1228
+ limit: number;
1229
+ running: number;
1230
+ queueLength: number;
1231
+ utilizationPercentage: number;
1232
+ totalRequests: number;
1233
+ completedRequests: number;
1234
+ failedRequests: number;
1235
+ queuedRequests: number;
1236
+ successRate: number;
1237
+ peakConcurrency: number;
1238
+ averageConcurrency: number;
1239
+ concurrencyUtilization: number;
1240
+ peakQueueLength: number;
1241
+ averageQueueWaitTime: number;
1242
+ averageExecutionTime: number;
1243
+ isAtCapacity: boolean;
1244
+ hasQueuedRequests: boolean;
1245
+ }
1246
+ export interface SystemMetrics {
1247
+ workflow?: WorkflowMetrics;
1248
+ branches: BranchMetrics[];
1249
+ phases: PhaseMetrics[];
1250
+ requestGroups: RequestGroupMetrics[];
1251
+ requests: RequestMetrics[];
1252
+ circuitBreaker?: CircuitBreakerDashboardMetrics;
1253
+ cache?: CacheDashboardMetrics;
1254
+ rateLimiter?: RateLimiterDashboardMetrics;
1255
+ concurrencyLimiter?: ConcurrencyLimiterDashboardMetrics;
1256
+ }
1257
+ export type WorkflowNodeType = WorkflowNodeTypes.PHASE | WorkflowNodeTypes.BRANCH | WorkflowNodeTypes.CONDITIONAL | WorkflowNodeTypes.PARALLEL_GROUP | WorkflowNodeTypes.MERGE_POINT;
1258
+ export interface WorkflowGraph<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1259
+ nodes: Map<string, WorkflowNode<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1260
+ edges: Map<string, WorkflowEdge<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[]>;
1261
+ entryPoint: string;
1262
+ exitPoints?: string[];
1263
+ metadata?: Record<string, any>;
1264
+ }
1265
+ export interface WorkflowNode<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1266
+ id: string;
1267
+ type: WorkflowNodeType;
1268
+ phase?: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1269
+ branch?: STABLE_WORKFLOW_BRANCH<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1270
+ condition?: ConditionalNode<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1271
+ parallelNodes?: string[];
1272
+ waitForNodes?: string[];
1273
+ metadata?: Record<string, any>;
1274
+ phaseDecisionHook?: (context: PhaseDecisionHookOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType> | Promise<PhaseExecutionDecision<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1275
+ }
1276
+ export interface WorkflowEdge<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1277
+ from: string;
1278
+ to: string;
1279
+ condition?: EdgeCondition<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1280
+ weight?: number;
1281
+ label?: string;
1282
+ metadata?: Record<string, any>;
1283
+ }
1284
+ export type EdgeConditionType = WorkflowEdgeConditionTypes.SUCCESS | WorkflowEdgeConditionTypes.FAILURE | WorkflowEdgeConditionTypes.CUSTOM | WorkflowEdgeConditionTypes.ALWAYS;
1285
+ export interface EdgeCondition<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1286
+ type: EdgeConditionType;
1287
+ evaluate?: (context: EdgeEvaluationContext<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => boolean | Promise<boolean>;
1288
+ }
1289
+ export interface EdgeEvaluationContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1290
+ results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>>;
1291
+ sharedBuffer?: Record<string, any>;
1292
+ executionHistory: ReadonlyArray<PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1293
+ currentNodeId: string;
1294
+ }
1295
+ export interface ConditionalNode<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1296
+ evaluate: (context: ConditionalEvaluationContext<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>) => string | Promise<string>;
1297
+ }
1298
+ export interface ConditionalEvaluationContext<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1299
+ results: Map<string, STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>>;
1300
+ sharedBuffer?: Record<string, any>;
1301
+ executionHistory: ReadonlyArray<PhaseExecutionRecord<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>>;
1302
+ currentNodeId: string;
1303
+ phaseResult?: STABLE_WORKFLOW_PHASE_RESULT<ResponseDataType, FunctionReturnType, RequestDataType, FunctionArgsType>;
1304
+ }
1305
+ 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'> {
1306
+ validateGraph?: boolean;
1307
+ optimizeExecution?: boolean;
1308
+ maxGraphDepth?: number;
1309
+ }
1310
+ export interface WorkflowGraphValidationResult {
1311
+ valid: boolean;
1312
+ errors: string[];
1313
+ warnings: string[];
1314
+ cycles?: string[][];
1315
+ unreachableNodes?: string[];
1316
+ orphanNodes?: string[];
1317
+ }
1318
+ export interface WorkflowGraphExecutionPlan {
1319
+ orderedNodes: string[];
1320
+ parallelGroups: string[][];
1321
+ dependencies: Map<string, string[]>;
1322
+ estimatedDepth: number;
1323
+ }
1324
+ export type SchedulerSchedule = {
1325
+ type: ScheduleTypes.CRON;
1326
+ expression: string;
1327
+ timezone?: string;
1328
+ } | {
1329
+ type: ScheduleTypes.INTERVAL;
1330
+ everyMs: number;
1331
+ startAt?: string | number;
1332
+ } | {
1333
+ type: ScheduleTypes.TIMESTAMP;
1334
+ at: string | number;
1335
+ } | {
1336
+ type: ScheduleTypes.TIMESTAMPS;
1337
+ at: Array<string | number>;
1338
+ };
1339
+ export interface SchedulerRetryConfig {
1340
+ maxAttempts?: number;
1341
+ delayMs?: number;
1342
+ backoffMultiplier?: number;
1343
+ maxDelayMs?: number;
1344
+ }
1345
+ export interface SchedulerPersistence<TJob = unknown> {
1346
+ enabled?: boolean;
1347
+ saveState?: (state: SchedulerState<TJob>) => Promise<void> | void;
1348
+ loadState?: () => Promise<SchedulerState<TJob> | null> | SchedulerState<TJob> | null;
1349
+ persistenceDebounceMs?: number;
1350
+ }
1351
+ export interface SchedulerSharedInfrastructure {
1352
+ circuitBreaker?: CircuitBreaker;
1353
+ rateLimiter?: RateLimiter;
1354
+ concurrencyLimiter?: ConcurrencyLimiter;
1355
+ cacheManager?: CacheManager;
1356
+ }
1357
+ export interface SchedulerConfig<TJob = unknown> {
1358
+ maxParallel?: number;
1359
+ tickIntervalMs?: number;
1360
+ queueLimit?: number;
1361
+ timezone?: string;
1362
+ persistence?: SchedulerPersistence<TJob>;
1363
+ retry?: SchedulerRetryConfig;
1364
+ executionTimeoutMs?: number;
1365
+ metricsGuardrails?: MetricsGuardrails;
1366
+ sharedBuffer?: BufferLike;
1367
+ sharedInfrastructure?: SchedulerSharedInfrastructure;
1368
+ loadTransactionLogs?: TransactionLogsLoader;
1369
+ }
1370
+ export interface SchedulerRunContext {
1371
+ runId: string;
1372
+ jobId: string;
1373
+ scheduledAt: string;
1374
+ startedAt: string;
1375
+ schedule?: SchedulerSchedule;
1376
+ sharedBuffer?: Record<string, any>;
1377
+ sharedInfrastructure?: SchedulerSharedInfrastructure;
1378
+ transactionLogs?: StableBufferTransactionLog[];
1379
+ }
1380
+ export interface SchedulerJobState<TJob> {
1381
+ id: string;
1382
+ job: TJob;
1383
+ schedule?: SchedulerSchedule;
1384
+ nextRunAt: number | null;
1385
+ lastRunAt: number | null;
1386
+ remainingTimestamps: number[] | null;
1387
+ runOnce: boolean;
1388
+ isRunning: boolean;
1389
+ retryAttempts: number;
1390
+ }
1391
+ export interface SchedulerState<TJob> {
1392
+ jobs: SchedulerJobState<TJob>[];
1393
+ queue: string[];
1394
+ stats: {
1395
+ completed: number;
1396
+ failed: number;
1397
+ dropped: number;
1398
+ sequence: number;
1399
+ };
1400
+ sharedBuffer?: BufferLike;
1401
+ }
1402
+ export type SchedulerJobHandler<TJob> = (job: TJob, context: SchedulerRunContext) => Promise<unknown>;
1403
+ export type ScheduledJob<TJob extends {
1404
+ id?: string;
1405
+ schedule?: SchedulerSchedule;
1406
+ }> = {
1407
+ id: string;
1408
+ job: TJob;
1409
+ schedule?: SchedulerSchedule;
1410
+ nextRunAt: number | null;
1411
+ lastRunAt: number | null;
1412
+ remainingTimestamps: number[] | null;
1413
+ runOnce: boolean;
1414
+ isRunning: boolean;
1415
+ retryAttempts: number;
1416
+ };
1417
+ export interface InternalSchedulerConfig<TJob = any> {
1418
+ maxParallel: number;
1419
+ tickIntervalMs: number;
1420
+ queueLimit: number;
1421
+ timezone?: string;
1422
+ persistence: {
1423
+ enabled: boolean;
1424
+ saveState?: (state: SchedulerState<TJob>) => Promise<void> | void;
1425
+ loadState?: () => Promise<SchedulerState<TJob> | null> | SchedulerState<TJob> | null;
1426
+ persistenceDebounceMs?: number;
1427
+ };
1428
+ retry?: SchedulerRetryConfig;
1429
+ executionTimeoutMs?: number;
1430
+ metricsGuardrails?: SchedulerConfig<TJob>['metricsGuardrails'];
1431
+ sharedBuffer?: BufferLike;
1432
+ sharedInfrastructure?: SchedulerSharedInfrastructure;
1433
+ loadTransactionLogs?: TransactionLogsLoader;
1434
+ }
1435
+ export interface RunnerRequestJob<RequestDataType = any, ResponseDataType = any> {
1436
+ kind: RunnerJobs.STABLE_REQUEST;
1437
+ options: STABLE_REQUEST<RequestDataType, ResponseDataType>;
1438
+ }
1439
+ export interface RunnerFunctionJob<FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1440
+ kind: RunnerJobs.STABLE_FUNCTION;
1441
+ options: STABLE_FUNCTION<FunctionArgsType, FunctionReturnType>;
1442
+ }
1443
+ export interface RunnerApiGatewayJob<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1444
+ kind: RunnerJobs.STABLE_API_GATEWAY;
1445
+ requests: API_GATEWAY_REQUEST<RequestDataType, ResponseDataType>[] | API_GATEWAY_ITEM<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1446
+ options: API_GATEWAY_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1447
+ functions?: API_GATEWAY_FUNCTION<FunctionArgsType, FunctionReturnType>[];
1448
+ }
1449
+ export interface RunnerWorkflowJob<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1450
+ kind: RunnerJobs.STABLE_WORKFLOW;
1451
+ phases: STABLE_WORKFLOW_PHASE<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>[];
1452
+ options?: STABLE_WORKFLOW_OPTIONS<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1453
+ }
1454
+ export interface RunnerWorkflowGraphJob<RequestDataType = any, ResponseDataType = any, FunctionArgsType extends any[] = any[], FunctionReturnType = any> {
1455
+ kind: RunnerJobs.STABLE_WORKFLOW_GRAPH;
1456
+ graph: WorkflowGraph<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1457
+ options?: WorkflowGraphOptions<RequestDataType, ResponseDataType, FunctionArgsType, FunctionReturnType>;
1458
+ }
1459
+ export type RunnerJob = RunnerRequestJob | RunnerFunctionJob | RunnerApiGatewayJob | RunnerWorkflowJob | RunnerWorkflowGraphJob;
1460
+ export type RunnerScheduledJob<T extends RunnerJob = RunnerJob> = T & {
1461
+ id?: string;
1462
+ schedule?: SchedulerSchedule;
1463
+ retry?: SchedulerRetryConfig;
1464
+ executionTimeoutMs?: number;
1465
+ };
1466
+ export type RunnerConfig<T extends RunnerJob = RunnerJob> = {
1467
+ outputPath?: string;
1468
+ jobId?: string;
1469
+ job?: T;
1470
+ jobs?: RunnerScheduledJob<T>[];
1471
+ scheduler?: SchedulerConfig;
1472
+ };
1473
+ export type StableBufferState = Record<string, any>;
1474
+ export interface StableBufferOptions {
1475
+ initialState?: StableBufferState;
1476
+ clone?: (state: StableBufferState) => StableBufferState;
1477
+ metricsGuardrails?: MetricsGuardrailsStableBuffer;
1478
+ transactionTimeoutMs?: number;
1479
+ logTransaction?: StableBufferTransactionLogger;
1480
+ }
1481
+ export {};
1482
+ //# sourceMappingURL=index.d.ts.map