@rilaykit/workflow 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +72 -0
- package/dist/index.d.mts +1339 -0
- package/dist/index.d.ts +1339 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
import { ril, FormConfiguration, CustomStepRenderer, StepConditionalBehavior, StepDataHelper, WorkflowContext, WorkflowAnalytics, WorkflowPlugin, StepConfig, WorkflowConfig, ConditionalBehavior, ComponentRendererBaseProps, WorkflowNextButtonRendererProps, WorkflowPreviousButtonRendererProps, WorkflowSkipButtonRendererProps, WorkflowStepperRendererProps } from '@rilaykit/core';
|
|
2
|
+
import { form } from '@rilaykit/forms';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
import React__default from 'react';
|
|
6
|
+
import * as zustand from 'zustand';
|
|
7
|
+
|
|
8
|
+
interface WorkflowState {
|
|
9
|
+
currentStepIndex: number;
|
|
10
|
+
allData: Record<string, any>;
|
|
11
|
+
stepData: Record<string, any>;
|
|
12
|
+
visitedSteps: Set<string>;
|
|
13
|
+
passedSteps: Set<string>;
|
|
14
|
+
isSubmitting: boolean;
|
|
15
|
+
isTransitioning: boolean;
|
|
16
|
+
isInitializing: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface UseWorkflowStateProps {
|
|
19
|
+
defaultValues?: Record<string, any>;
|
|
20
|
+
defaultStepIndex?: number;
|
|
21
|
+
workflowSteps?: Array<{
|
|
22
|
+
id: string;
|
|
23
|
+
}>;
|
|
24
|
+
persistence?: {
|
|
25
|
+
workflowId: string;
|
|
26
|
+
adapter?: WorkflowPersistenceAdapter;
|
|
27
|
+
options?: PersistenceOptions;
|
|
28
|
+
userId?: string;
|
|
29
|
+
autoLoad?: boolean;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
declare function useWorkflowState({ defaultValues, defaultStepIndex, workflowSteps, persistence, }: UseWorkflowStateProps): {
|
|
33
|
+
workflowState: WorkflowState;
|
|
34
|
+
setCurrentStep: (stepIndex: number) => void;
|
|
35
|
+
setStepData: (data: Record<string, any>, stepId: string) => void;
|
|
36
|
+
setFieldValue: (fieldId: string, value: any, stepId: string) => void;
|
|
37
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
38
|
+
setTransitioning: (isTransitioning: boolean) => void;
|
|
39
|
+
markStepVisited: (stepIndex: number, stepId: string) => void;
|
|
40
|
+
markStepPassed: (stepId: string) => void;
|
|
41
|
+
resetWorkflow: () => void;
|
|
42
|
+
loadPersistedState: () => Promise<boolean>;
|
|
43
|
+
persistence: {
|
|
44
|
+
isPersisting: boolean;
|
|
45
|
+
persistenceError: WorkflowPersistenceError | null;
|
|
46
|
+
persistNow: () => Promise<void>;
|
|
47
|
+
clearPersistedData: () => Promise<void>;
|
|
48
|
+
hasPersistedData: () => Promise<boolean>;
|
|
49
|
+
} | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @fileoverview Persistence system types for Rilay workflows
|
|
54
|
+
*
|
|
55
|
+
* This module defines the core interfaces and types for the workflow persistence system.
|
|
56
|
+
* It provides a flexible adapter pattern allowing different persistence strategies:
|
|
57
|
+
* - localStorage persistence
|
|
58
|
+
* - API-based persistence
|
|
59
|
+
* - Custom persistence implementations
|
|
60
|
+
*
|
|
61
|
+
* The system is designed to be type-safe and extensible while maintaining
|
|
62
|
+
* a simple API for common use cases.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Persistent workflow data that gets saved/loaded
|
|
67
|
+
*/
|
|
68
|
+
interface PersistedWorkflowData {
|
|
69
|
+
/** Unique identifier for the workflow */
|
|
70
|
+
workflowId: string;
|
|
71
|
+
/** Current step index in the workflow */
|
|
72
|
+
currentStepIndex: number;
|
|
73
|
+
/** All collected data across steps */
|
|
74
|
+
allData: Record<string, any>;
|
|
75
|
+
/** Currently active step data */
|
|
76
|
+
stepData: Record<string, any>;
|
|
77
|
+
/** Set of visited step IDs */
|
|
78
|
+
visitedSteps: string[];
|
|
79
|
+
/** Set of passed/validated step IDs */
|
|
80
|
+
passedSteps?: string[];
|
|
81
|
+
/** When this data was last saved */
|
|
82
|
+
lastSaved: number;
|
|
83
|
+
/** Optional metadata for custom persistence needs */
|
|
84
|
+
metadata?: Record<string, any>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for persistence operations
|
|
88
|
+
*/
|
|
89
|
+
interface PersistenceOptions {
|
|
90
|
+
/** Whether to automatically persist on state changes */
|
|
91
|
+
autoPersist?: boolean;
|
|
92
|
+
/** Debounce delay in ms for auto-persistence (default: 500ms) */
|
|
93
|
+
debounceMs?: number;
|
|
94
|
+
/** Custom key for storage (overrides default) */
|
|
95
|
+
storageKey?: string;
|
|
96
|
+
/** Additional metadata to include in persisted data */
|
|
97
|
+
metadata?: Record<string, any>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Core persistence adapter interface
|
|
101
|
+
*
|
|
102
|
+
* All persistence implementations must implement this interface.
|
|
103
|
+
* It provides a consistent API regardless of the underlying storage mechanism.
|
|
104
|
+
*/
|
|
105
|
+
interface WorkflowPersistenceAdapter {
|
|
106
|
+
/**
|
|
107
|
+
* Save workflow data
|
|
108
|
+
* @param key - Unique identifier for the stored data
|
|
109
|
+
* @param data - Workflow data to persist
|
|
110
|
+
* @returns Promise that resolves when save is complete
|
|
111
|
+
*/
|
|
112
|
+
save(key: string, data: PersistedWorkflowData): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Load workflow data
|
|
115
|
+
* @param key - Unique identifier for the stored data
|
|
116
|
+
* @returns Promise that resolves to persisted data or null if not found
|
|
117
|
+
*/
|
|
118
|
+
load(key: string): Promise<PersistedWorkflowData | null>;
|
|
119
|
+
/**
|
|
120
|
+
* Remove persisted workflow data
|
|
121
|
+
* @param key - Unique identifier for the stored data
|
|
122
|
+
* @returns Promise that resolves when deletion is complete
|
|
123
|
+
*/
|
|
124
|
+
remove(key: string): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Check if data exists for the given key
|
|
127
|
+
* @param key - Unique identifier to check
|
|
128
|
+
* @returns Promise that resolves to true if data exists
|
|
129
|
+
*/
|
|
130
|
+
exists(key: string): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* List all available keys (optional, for debugging/admin)
|
|
133
|
+
* @returns Promise that resolves to array of available keys
|
|
134
|
+
*/
|
|
135
|
+
listKeys?(): Promise<string[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Clear all persisted data (optional, for cleanup)
|
|
138
|
+
* @returns Promise that resolves when all data is cleared
|
|
139
|
+
*/
|
|
140
|
+
clear?(): Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Configuration for localStorage persistence adapter
|
|
144
|
+
*/
|
|
145
|
+
interface LocalStorageAdapterConfig {
|
|
146
|
+
/** Prefix for localStorage keys (default: 'rilay_workflow_') */
|
|
147
|
+
keyPrefix?: string;
|
|
148
|
+
/** Whether to compress data before storage */
|
|
149
|
+
compress?: boolean;
|
|
150
|
+
/** Maximum age in ms before data expires (optional) */
|
|
151
|
+
maxAge?: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Error types for persistence operations
|
|
155
|
+
*/
|
|
156
|
+
declare class WorkflowPersistenceError extends Error {
|
|
157
|
+
readonly code: string;
|
|
158
|
+
readonly cause?: Error | undefined;
|
|
159
|
+
constructor(message: string, code: string, cause?: Error | undefined);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Persistence hook return type
|
|
163
|
+
*/
|
|
164
|
+
interface UsePersistenceReturn {
|
|
165
|
+
/** Whether persistence is currently saving */
|
|
166
|
+
isPersisting: boolean;
|
|
167
|
+
/** Last persistence error (if any) */
|
|
168
|
+
persistenceError: WorkflowPersistenceError | null;
|
|
169
|
+
/** Manually trigger a save operation */
|
|
170
|
+
persistNow: () => Promise<void>;
|
|
171
|
+
/** Load data from persistence */
|
|
172
|
+
loadPersistedData: () => Promise<PersistedWorkflowData | null>;
|
|
173
|
+
/** Clear persisted data */
|
|
174
|
+
clearPersistedData: () => Promise<void>;
|
|
175
|
+
/** Whether persisted data exists */
|
|
176
|
+
hasPersistedData: () => Promise<boolean>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Enhanced step configuration interface for better type safety and simplicity
|
|
181
|
+
*
|
|
182
|
+
* This interface defines the structure for creating workflow steps with all
|
|
183
|
+
* necessary configuration options. It provides a clean API for step definition
|
|
184
|
+
* while maintaining flexibility for complex workflows.
|
|
185
|
+
*
|
|
186
|
+
* @interface StepDefinition
|
|
187
|
+
*/
|
|
188
|
+
interface StepDefinition {
|
|
189
|
+
/**
|
|
190
|
+
* Unique identifier for the step
|
|
191
|
+
* If not provided, will be auto-generated using the internal ID generator
|
|
192
|
+
*/
|
|
193
|
+
id?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Display title for the step
|
|
196
|
+
* This will be shown to users in the workflow interface
|
|
197
|
+
*/
|
|
198
|
+
title: string;
|
|
199
|
+
/**
|
|
200
|
+
* Optional description providing additional context about the step
|
|
201
|
+
* Useful for complex workflows where steps need explanation
|
|
202
|
+
*/
|
|
203
|
+
description?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Form configuration for the step
|
|
206
|
+
* Can be either a built FormConfiguration or a form builder instance
|
|
207
|
+
*/
|
|
208
|
+
formConfig: FormConfiguration<any> | form<any>;
|
|
209
|
+
/**
|
|
210
|
+
* Whether users can skip this step
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
allowSkip?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Whether this step is required to complete the workflow
|
|
216
|
+
* @default true
|
|
217
|
+
*/
|
|
218
|
+
requiredToComplete?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Custom renderer for the step
|
|
221
|
+
* Allows complete customization of step presentation
|
|
222
|
+
*/
|
|
223
|
+
renderer?: CustomStepRenderer;
|
|
224
|
+
/**
|
|
225
|
+
* Conditional behavior configuration for this step
|
|
226
|
+
* Controls visibility and skippable state
|
|
227
|
+
*/
|
|
228
|
+
conditions?: StepConditionalBehavior;
|
|
229
|
+
/**
|
|
230
|
+
* Custom metadata for this step
|
|
231
|
+
* Allows storing arbitrary information that can be accessed via hooks and context
|
|
232
|
+
*
|
|
233
|
+
* This is useful for:
|
|
234
|
+
* - UI customization (icons, colors, themes)
|
|
235
|
+
* - Analytics tracking (categories, priorities, custom events)
|
|
236
|
+
* - Business logic flags (feature flags, permissions, workflow rules)
|
|
237
|
+
* - Integration data (external IDs, API endpoints, configuration)
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* {
|
|
242
|
+
* metadata: {
|
|
243
|
+
* icon: 'user-circle',
|
|
244
|
+
* category: 'personal-info',
|
|
245
|
+
* analytics: { trackCompletion: true, priority: 'high' },
|
|
246
|
+
* ui: { theme: 'primary', showProgress: true },
|
|
247
|
+
* business: { requiresApproval: false, estimatedTime: 120 }
|
|
248
|
+
* }
|
|
249
|
+
* }
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
metadata?: Record<string, any>;
|
|
253
|
+
/**
|
|
254
|
+
* Callback function that executes after successful validation and before moving to next step
|
|
255
|
+
* Provides clean helper methods for modifying workflow data and pre-filling subsequent steps
|
|
256
|
+
*
|
|
257
|
+
* @param stepData - The validated data from the current step
|
|
258
|
+
* @param helper - Helper object with methods to modify workflow data cleanly
|
|
259
|
+
* @param context - Full workflow context for reference
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* onAfterValidation: async (stepData, helper, context) => {
|
|
264
|
+
* // API call based on current step data
|
|
265
|
+
* const companyInfo = await fetchCompanyBySiren(stepData.siren);
|
|
266
|
+
*
|
|
267
|
+
* // Pre-fill next step with clean helper methods
|
|
268
|
+
* helper.setNextStepFields({
|
|
269
|
+
* companyName: companyInfo.name,
|
|
270
|
+
* address: companyInfo.address,
|
|
271
|
+
* industry: companyInfo.sector
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* // Or set data for a specific step
|
|
275
|
+
* helper.setStepFields('company-details', {
|
|
276
|
+
* legalForm: companyInfo.legalForm,
|
|
277
|
+
* foundedYear: companyInfo.creation_date
|
|
278
|
+
* });
|
|
279
|
+
* }
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
onAfterValidation?: (stepData: Record<string, any>, helper: StepDataHelper, context: WorkflowContext) => void | Promise<void>;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Configuration options for workflow behavior and features
|
|
286
|
+
*
|
|
287
|
+
* This interface consolidates all workflow-level configuration options
|
|
288
|
+
* into a single, easy-to-use structure for the configure() method.
|
|
289
|
+
*
|
|
290
|
+
* @interface WorkflowOptions
|
|
291
|
+
*/
|
|
292
|
+
interface WorkflowOptions {
|
|
293
|
+
/** Analytics and tracking configuration */
|
|
294
|
+
analytics?: WorkflowAnalytics;
|
|
295
|
+
/** Persistence configuration */
|
|
296
|
+
persistence?: {
|
|
297
|
+
adapter: WorkflowPersistenceAdapter;
|
|
298
|
+
options?: PersistenceOptions;
|
|
299
|
+
userId?: string;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Workflow builder class for creating complex multi-step workflows
|
|
304
|
+
*
|
|
305
|
+
* The flow class provides a comprehensive API for building multi-step workflows
|
|
306
|
+
* with form-based steps. It follows the builder pattern with method chaining
|
|
307
|
+
* and includes advanced features like dynamic steps, plugins, and analytics.
|
|
308
|
+
*
|
|
309
|
+
* Key Features:
|
|
310
|
+
* - Polymorphic step addition (single or multiple steps)
|
|
311
|
+
* - Plugin system for extensibility
|
|
312
|
+
* - Built-in validation and error handling
|
|
313
|
+
* - Clone and export/import functionality
|
|
314
|
+
* - Comprehensive statistics and analytics
|
|
315
|
+
* - Type-safe configuration management
|
|
316
|
+
*
|
|
317
|
+
* DX Notes:
|
|
318
|
+
* - Recommended: use the explicit factory `flow.create(rilConfig, id, name)`; we do not augment ril with `.flow()`.
|
|
319
|
+
* - Steps accept either a built `FormConfiguration` or a `form` builder; builders are built internally.
|
|
320
|
+
* - Use `when('path')...build()` for step-level conditions in `StepConditionalBehavior`.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const workflow = flow.create(rilConfig, 'user-onboarding', 'User Onboarding')
|
|
325
|
+
* .addStep({
|
|
326
|
+
* title: 'Personal Information',
|
|
327
|
+
* formConfig: personalInfoForm
|
|
328
|
+
* })
|
|
329
|
+
* .addStep({
|
|
330
|
+
* title: 'Account Setup',
|
|
331
|
+
* formConfig: accountForm,
|
|
332
|
+
* allowSkip: true
|
|
333
|
+
* })
|
|
334
|
+
* .configure({
|
|
335
|
+
* navigation: { allowBackNavigation: true },
|
|
336
|
+
* persistence: { saveOnStepComplete: true }
|
|
337
|
+
* })
|
|
338
|
+
* .build();
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @class flow
|
|
342
|
+
*/
|
|
343
|
+
declare class flow {
|
|
344
|
+
private config;
|
|
345
|
+
private workflowId;
|
|
346
|
+
private workflowName;
|
|
347
|
+
private workflowDescription?;
|
|
348
|
+
private steps;
|
|
349
|
+
private analytics?;
|
|
350
|
+
private persistenceConfig?;
|
|
351
|
+
private plugins;
|
|
352
|
+
private idGenerator;
|
|
353
|
+
/**
|
|
354
|
+
* Creates a new workflow builder instance
|
|
355
|
+
*
|
|
356
|
+
* @param config - The ril configuration instance
|
|
357
|
+
* @param workflowId - Unique identifier for the workflow
|
|
358
|
+
* @param workflowName - Display name for the workflow
|
|
359
|
+
* @param description - Optional description of the workflow purpose
|
|
360
|
+
*/
|
|
361
|
+
constructor(config: ril<any>, workflowId: string, workflowName: string, description?: string);
|
|
362
|
+
/**
|
|
363
|
+
* Static factory method to create a new workflow builder
|
|
364
|
+
*
|
|
365
|
+
* This is the preferred way to create workflow builders as it provides
|
|
366
|
+
* better type inference and follows the factory pattern.
|
|
367
|
+
*
|
|
368
|
+
* DX Note: Prefer using this factory over `new flow(...)` for clarity and consistency.
|
|
369
|
+
*
|
|
370
|
+
* @param config - The ril configuration instance
|
|
371
|
+
* @param workflowId - Unique identifier for the workflow
|
|
372
|
+
* @param workflowName - Display name for the workflow
|
|
373
|
+
* @param description - Optional description of the workflow purpose
|
|
374
|
+
* @returns A new flow builder instance
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* const workflow = flow.create(rilConfig, 'checkout', 'Checkout Process');
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
static create(config: ril<any>, workflowId: string, workflowName: string, description?: string): flow;
|
|
382
|
+
/**
|
|
383
|
+
* Helper method to create a step configuration from StepDefinition
|
|
384
|
+
*
|
|
385
|
+
* This internal method handles the conversion from the user-friendly
|
|
386
|
+
* StepDefinition interface to the internal StepConfig structure,
|
|
387
|
+
* including ID generation, form configuration processing, and validation setup.
|
|
388
|
+
*
|
|
389
|
+
* @private
|
|
390
|
+
* @param stepDef - The step definition to convert
|
|
391
|
+
* @returns A complete StepConfig object
|
|
392
|
+
*/
|
|
393
|
+
private createStepFromDefinition;
|
|
394
|
+
/**
|
|
395
|
+
* Universal add method - handles single steps or multiple steps
|
|
396
|
+
*
|
|
397
|
+
* This polymorphic method provides a clean API for adding steps to the workflow.
|
|
398
|
+
* It can handle both single step definitions and arrays of step definitions,
|
|
399
|
+
* making it easy to build workflows programmatically.
|
|
400
|
+
*
|
|
401
|
+
* @param stepDefinition - Single step definition
|
|
402
|
+
* @returns The flow instance for method chaining
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* // Add a single step
|
|
407
|
+
* workflow.addStep({
|
|
408
|
+
* title: 'User Details',
|
|
409
|
+
* formConfig: userForm
|
|
410
|
+
* });
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
addStep(stepDefinition: StepDefinition): this;
|
|
414
|
+
/**
|
|
415
|
+
* Universal add method - handles single steps or multiple steps
|
|
416
|
+
*
|
|
417
|
+
* @param stepDefinitions - Array of step definitions
|
|
418
|
+
* @returns The flow instance for method chaining
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* // Add multiple steps at once
|
|
423
|
+
* workflow.addStep([
|
|
424
|
+
* { title: 'Step 1', formConfig: form1 },
|
|
425
|
+
* { title: 'Step 2', formConfig: form2 }
|
|
426
|
+
* ]);
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
addStep(stepDefinitions: StepDefinition[]): this;
|
|
430
|
+
/**
|
|
431
|
+
* Universal configuration method for all workflow options
|
|
432
|
+
*
|
|
433
|
+
* This method replaces individual setter methods with a single consolidated API
|
|
434
|
+
* for configuring all aspects of workflow behavior. It uses deep merging to
|
|
435
|
+
* preserve existing configurations while applying new settings.
|
|
436
|
+
*
|
|
437
|
+
* @param options - Configuration options to apply
|
|
438
|
+
* @returns The flow instance for method chaining
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* workflow.configure({
|
|
443
|
+
* analytics: {
|
|
444
|
+
* trackStepCompletion: true,
|
|
445
|
+
* trackFieldInteractions: false
|
|
446
|
+
* },
|
|
447
|
+
* persistence: {
|
|
448
|
+
* adapter: new LocalStorageAdapter(),
|
|
449
|
+
* options: { autoPersist: true, debounceMs: 1000 },
|
|
450
|
+
* userId: 'user123'
|
|
451
|
+
* }
|
|
452
|
+
* });
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
configure(options: WorkflowOptions): this;
|
|
456
|
+
/**
|
|
457
|
+
* Plugin management with enhanced validation
|
|
458
|
+
*
|
|
459
|
+
* Installs a plugin into the workflow with dependency validation.
|
|
460
|
+
* Plugins can extend workflow functionality, add custom renderers,
|
|
461
|
+
* or integrate with external services.
|
|
462
|
+
*
|
|
463
|
+
* @param plugin - The plugin to install
|
|
464
|
+
* @returns The flow instance for method chaining
|
|
465
|
+
* @throws Error if plugin installation fails or dependencies are missing
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* ```typescript
|
|
469
|
+
* workflow.use(customPlugin)
|
|
470
|
+
* .use(anotherPlugin);
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
use(plugin: WorkflowPlugin): this;
|
|
474
|
+
/**
|
|
475
|
+
* Validates plugin dependencies before installation
|
|
476
|
+
*
|
|
477
|
+
* @private
|
|
478
|
+
* @param plugin - The plugin to validate
|
|
479
|
+
* @throws Error if required dependencies are missing
|
|
480
|
+
*/
|
|
481
|
+
private validatePluginDependencies;
|
|
482
|
+
/**
|
|
483
|
+
* Remove a plugin from the workflow
|
|
484
|
+
*
|
|
485
|
+
* @param pluginName - Name of the plugin to remove
|
|
486
|
+
* @returns The flow instance for method chaining
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```typescript
|
|
490
|
+
* workflow.removePlugin('analytics-plugin');
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
removePlugin(pluginName: string): this;
|
|
494
|
+
/**
|
|
495
|
+
* Update an existing step configuration
|
|
496
|
+
*
|
|
497
|
+
* Allows modification of step properties after the step has been added.
|
|
498
|
+
* Useful for dynamic workflows or configuration updates based on user input.
|
|
499
|
+
*
|
|
500
|
+
* @param stepId - ID of the step to update
|
|
501
|
+
* @param updates - Partial step configuration updates
|
|
502
|
+
* @returns The flow instance for method chaining
|
|
503
|
+
* @throws Error if step with given ID is not found
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
* workflow.updateStep('step-1', {
|
|
508
|
+
* title: 'Updated Title',
|
|
509
|
+
* allowSkip: true
|
|
510
|
+
* });
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
updateStep(stepId: string, updates: Partial<Omit<StepConfig, 'id'>>): this;
|
|
514
|
+
/**
|
|
515
|
+
* Adds conditions to a specific step by ID
|
|
516
|
+
*
|
|
517
|
+
* This method allows adding conditional behavior to a step after it has been created,
|
|
518
|
+
* useful for dynamic conditional requirements.
|
|
519
|
+
*
|
|
520
|
+
* @param stepId - The ID of the step to add conditions to
|
|
521
|
+
* @param conditions - Conditional behavior configuration
|
|
522
|
+
* @returns The flow instance for method chaining
|
|
523
|
+
* @throws Error if the step with the specified ID is not found
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* workflow.addStepConditions('payment-step', {
|
|
528
|
+
* visible: when('hasPayment').equals(true).build(),
|
|
529
|
+
* skippable: when('balance').equals(0).build()
|
|
530
|
+
* });
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
addStepConditions(stepId: string, conditions: StepConditionalBehavior): this;
|
|
534
|
+
/**
|
|
535
|
+
* Remove a step from the workflow
|
|
536
|
+
*
|
|
537
|
+
* @param stepId - ID of the step to remove
|
|
538
|
+
* @returns The flow instance for method chaining
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* workflow.removeStep('optional-step');
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
removeStep(stepId: string): this;
|
|
546
|
+
/**
|
|
547
|
+
* Get a specific step by ID
|
|
548
|
+
*
|
|
549
|
+
* @param stepId - ID of the step to retrieve
|
|
550
|
+
* @returns The step configuration or undefined if not found
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```typescript
|
|
554
|
+
* const step = workflow.getStep('user-details');
|
|
555
|
+
* if (step) {
|
|
556
|
+
* console.log(step.title);
|
|
557
|
+
* }
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
getStep(stepId: string): StepConfig | undefined;
|
|
561
|
+
/**
|
|
562
|
+
* Get all steps in the workflow
|
|
563
|
+
*
|
|
564
|
+
* Returns a copy of the steps array to prevent external modification.
|
|
565
|
+
*
|
|
566
|
+
* @returns Array of all step configurations
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* ```typescript
|
|
570
|
+
* const allSteps = workflow.getSteps();
|
|
571
|
+
* console.log(`Workflow has ${allSteps.length} steps`);
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
getSteps(): StepConfig[];
|
|
575
|
+
/**
|
|
576
|
+
* Clear all steps from the workflow
|
|
577
|
+
*
|
|
578
|
+
* Removes all steps and resets the ID generator. Useful for rebuilding
|
|
579
|
+
* workflows or creating templates.
|
|
580
|
+
*
|
|
581
|
+
* @returns The flow instance for method chaining
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* workflow.clearSteps()
|
|
586
|
+
* .addStep(newStep1)
|
|
587
|
+
* .addStep(newStep2);
|
|
588
|
+
* ```
|
|
589
|
+
*/
|
|
590
|
+
clearSteps(): this;
|
|
591
|
+
/**
|
|
592
|
+
* Clone the workflow builder
|
|
593
|
+
*
|
|
594
|
+
* Creates a deep copy of the workflow builder with optional new ID and name.
|
|
595
|
+
* All configuration, steps, and plugins are copied to the new instance.
|
|
596
|
+
*
|
|
597
|
+
* @param newWorkflowId - Optional new workflow ID
|
|
598
|
+
* @param newWorkflowName - Optional new workflow name
|
|
599
|
+
* @returns A new flow instance with copied configuration
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```typescript
|
|
603
|
+
* const template = workflow.clone('new-workflow', 'New Workflow');
|
|
604
|
+
* template.addStep(additionalStep);
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
clone(newWorkflowId?: string, newWorkflowName?: string): flow;
|
|
608
|
+
/**
|
|
609
|
+
* Enhanced validation using shared utilities
|
|
610
|
+
*
|
|
611
|
+
* Performs comprehensive validation of the workflow configuration,
|
|
612
|
+
* checking for common issues like missing steps, duplicate IDs,
|
|
613
|
+
* and plugin dependency problems.
|
|
614
|
+
*
|
|
615
|
+
* @returns Array of validation error messages (empty if valid)
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const errors = workflow.validate();
|
|
620
|
+
* if (errors.length > 0) {
|
|
621
|
+
* console.error('Validation errors:', errors);
|
|
622
|
+
* }
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
validate(): string[];
|
|
626
|
+
/**
|
|
627
|
+
* Get comprehensive workflow statistics
|
|
628
|
+
*
|
|
629
|
+
* Provides detailed analytics about the workflow structure and configuration.
|
|
630
|
+
* Useful for monitoring, optimization, and reporting purposes.
|
|
631
|
+
*
|
|
632
|
+
* @returns Object containing various workflow statistics
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* ```typescript
|
|
636
|
+
* const stats = workflow.getStats();
|
|
637
|
+
* console.log(`Workflow has ${stats.totalSteps} steps`);
|
|
638
|
+
* console.log(`Estimated ${stats.estimatedFields} total fields`);
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
getStats(): {
|
|
642
|
+
totalSteps: number;
|
|
643
|
+
totalFields: number;
|
|
644
|
+
averageFieldsPerStep: number;
|
|
645
|
+
maxFieldsInStep: number;
|
|
646
|
+
minFieldsInStep: number;
|
|
647
|
+
hasAnalytics: boolean;
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* Build the final workflow configuration
|
|
651
|
+
*
|
|
652
|
+
* Validates the workflow and creates the final configuration object
|
|
653
|
+
* that can be used by the workflow runtime. This method should be
|
|
654
|
+
* called after all configuration is complete.
|
|
655
|
+
*
|
|
656
|
+
* @returns Complete workflow configuration
|
|
657
|
+
* @throws Error if validation fails
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```typescript
|
|
661
|
+
* try {
|
|
662
|
+
* const workflowConfig = workflow.build();
|
|
663
|
+
* // Use workflowConfig with workflow runtime
|
|
664
|
+
* } catch (error) {
|
|
665
|
+
* console.error('Workflow build failed:', error.message);
|
|
666
|
+
* }
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
build(): WorkflowConfig;
|
|
670
|
+
/**
|
|
671
|
+
* Export workflow configuration to JSON
|
|
672
|
+
*
|
|
673
|
+
* Serializes the workflow configuration to a JSON-compatible object.
|
|
674
|
+
* Useful for saving workflows, creating templates, or transferring
|
|
675
|
+
* configurations between systems.
|
|
676
|
+
*
|
|
677
|
+
* @returns JSON-serializable workflow configuration
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* const json = workflow.toJSON();
|
|
682
|
+
* localStorage.setItem('workflow-template', JSON.stringify(json));
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
toJSON(): any;
|
|
686
|
+
/**
|
|
687
|
+
* Import workflow configuration from JSON
|
|
688
|
+
*
|
|
689
|
+
* Loads workflow configuration from a JSON object. This method
|
|
690
|
+
* performs partial updates, only modifying properties that are
|
|
691
|
+
* present in the JSON object.
|
|
692
|
+
*
|
|
693
|
+
* @param json - JSON object containing workflow configuration
|
|
694
|
+
* @returns The flow instance for method chaining
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```typescript
|
|
698
|
+
* const json = JSON.parse(localStorage.getItem('workflow-template'));
|
|
699
|
+
* workflow.fromJSON(json);
|
|
700
|
+
* ```
|
|
701
|
+
*/
|
|
702
|
+
fromJSON(json: any): this;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
interface ConditionEvaluationResult {
|
|
706
|
+
visible: boolean;
|
|
707
|
+
disabled: boolean;
|
|
708
|
+
required: boolean;
|
|
709
|
+
readonly: boolean;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Hook to evaluate conditional behaviors based on workflow data
|
|
713
|
+
*
|
|
714
|
+
* @param conditions - The conditional behavior configuration
|
|
715
|
+
* @param workflowData - Current workflow data to evaluate against
|
|
716
|
+
* @param defaultState - Default state when no conditions are provided
|
|
717
|
+
* @returns Evaluated condition results
|
|
718
|
+
*/
|
|
719
|
+
declare function useConditionEvaluation(conditions?: ConditionalBehavior, workflowData?: Record<string, any>, defaultState?: Partial<ConditionEvaluationResult>): ConditionEvaluationResult;
|
|
720
|
+
|
|
721
|
+
interface UseWorkflowConditionsProps {
|
|
722
|
+
workflowConfig: WorkflowConfig;
|
|
723
|
+
workflowState: WorkflowState;
|
|
724
|
+
currentStep: StepConfig;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Result of step condition evaluation - only relevant properties for workflow steps
|
|
728
|
+
*/
|
|
729
|
+
interface StepConditionResult {
|
|
730
|
+
visible: boolean;
|
|
731
|
+
skippable: boolean;
|
|
732
|
+
}
|
|
733
|
+
interface UseWorkflowConditionsReturn {
|
|
734
|
+
stepConditions: StepConditionResult;
|
|
735
|
+
fieldConditions: Record<string, ConditionEvaluationResult>;
|
|
736
|
+
allStepConditions: Record<number, StepConditionResult>;
|
|
737
|
+
isStepVisible: (stepIndex: number) => boolean;
|
|
738
|
+
isStepSkippable: (stepIndex: number) => boolean;
|
|
739
|
+
isFieldVisible: (fieldId: string) => boolean;
|
|
740
|
+
isFieldDisabled: (fieldId: string) => boolean;
|
|
741
|
+
isFieldRequired: (fieldId: string) => boolean;
|
|
742
|
+
isFieldReadonly: (fieldId: string) => boolean;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Hook to manage conditional behaviors for workflow steps and fields
|
|
746
|
+
*
|
|
747
|
+
* This hook evaluates conditions for steps and form fields within a workflow,
|
|
748
|
+
* providing convenient methods to check step and field states based on conditions.
|
|
749
|
+
*
|
|
750
|
+
* Steps have different condition types than fields:
|
|
751
|
+
* - Steps: visible, skippable
|
|
752
|
+
* - Fields: visible, disabled, required, readonly
|
|
753
|
+
*/
|
|
754
|
+
declare function useWorkflowConditions({ workflowConfig, workflowState, currentStep, }: UseWorkflowConditionsProps): UseWorkflowConditionsReturn;
|
|
755
|
+
|
|
756
|
+
interface WorkflowContextValue {
|
|
757
|
+
workflowState: {
|
|
758
|
+
currentStepIndex: number;
|
|
759
|
+
allData: Record<string, unknown>;
|
|
760
|
+
stepData: Record<string, unknown>;
|
|
761
|
+
visitedSteps: Set<string>;
|
|
762
|
+
passedSteps: Set<string>;
|
|
763
|
+
isSubmitting: boolean;
|
|
764
|
+
isTransitioning: boolean;
|
|
765
|
+
isInitializing: boolean;
|
|
766
|
+
};
|
|
767
|
+
workflowConfig: WorkflowConfig;
|
|
768
|
+
currentStep: StepConfig;
|
|
769
|
+
context: WorkflowContext;
|
|
770
|
+
formConfig?: FormConfiguration;
|
|
771
|
+
conditionsHelpers: UseWorkflowConditionsReturn;
|
|
772
|
+
currentStepMetadata?: Record<string, unknown>;
|
|
773
|
+
goToStep: (stepIndex: number) => Promise<boolean>;
|
|
774
|
+
goNext: () => Promise<boolean>;
|
|
775
|
+
goPrevious: () => Promise<boolean>;
|
|
776
|
+
skipStep: () => Promise<boolean>;
|
|
777
|
+
canGoToStep: (stepIndex: number) => boolean;
|
|
778
|
+
canGoNext: () => boolean;
|
|
779
|
+
canGoPrevious: () => boolean;
|
|
780
|
+
canSkipCurrentStep: () => boolean;
|
|
781
|
+
setValue: (fieldId: string, value: unknown) => void;
|
|
782
|
+
setStepData: (data: Record<string, unknown>) => void;
|
|
783
|
+
resetWorkflow: () => void;
|
|
784
|
+
submitWorkflow: () => Promise<void>;
|
|
785
|
+
isSubmitting: boolean;
|
|
786
|
+
canSubmit: boolean;
|
|
787
|
+
persistNow?: () => Promise<void>;
|
|
788
|
+
isPersisting?: boolean;
|
|
789
|
+
persistenceError?: Error | null;
|
|
790
|
+
}
|
|
791
|
+
interface WorkflowProviderProps {
|
|
792
|
+
children: React__default.ReactNode;
|
|
793
|
+
workflowConfig: WorkflowConfig;
|
|
794
|
+
defaultValues?: Record<string, unknown>;
|
|
795
|
+
defaultStep?: string;
|
|
796
|
+
onStepChange?: (fromStep: number, toStep: number, context: WorkflowContext) => void;
|
|
797
|
+
onWorkflowComplete?: (data: Record<string, unknown>) => void | Promise<void>;
|
|
798
|
+
className?: string;
|
|
799
|
+
}
|
|
800
|
+
declare function WorkflowProvider({ children, workflowConfig, defaultValues, defaultStep, onStepChange, onWorkflowComplete, className, }: WorkflowProviderProps): react_jsx_runtime.JSX.Element;
|
|
801
|
+
declare function useWorkflowContext(): WorkflowContextValue;
|
|
802
|
+
|
|
803
|
+
type WorkflowProps = Omit<WorkflowProviderProps, 'children' | 'workflowConfig'> & {
|
|
804
|
+
children: React__default.ReactNode;
|
|
805
|
+
workflowConfig: WorkflowConfig | flow;
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* A wrapper component for the Rilay workflow system.
|
|
809
|
+
* It simplifies the API by wrapping the WorkflowProvider and providing a clean,
|
|
810
|
+
* component-based interface for building workflows.
|
|
811
|
+
* Accepts both WorkflowConfig and flow builder instances.
|
|
812
|
+
*/
|
|
813
|
+
declare function Workflow({ children, workflowConfig, ...props }: WorkflowProps): react_jsx_runtime.JSX.Element;
|
|
814
|
+
|
|
815
|
+
interface WorkflowBodyProps {
|
|
816
|
+
stepId?: string;
|
|
817
|
+
children?: React__default.ReactNode;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Renders the main content of the current workflow step.
|
|
821
|
+
* Simple component that renders either the children or FormBody by default.
|
|
822
|
+
*/
|
|
823
|
+
declare const WorkflowBody: React__default.NamedExoticComponent<WorkflowBodyProps>;
|
|
824
|
+
|
|
825
|
+
interface WorkflowNextButtonProps extends ComponentRendererBaseProps<WorkflowNextButtonRendererProps> {
|
|
826
|
+
/**
|
|
827
|
+
* Override the isSubmitting state from workflow/form context
|
|
828
|
+
* If provided, this value will be used instead of the computed isSubmitting state
|
|
829
|
+
*/
|
|
830
|
+
isSubmitting?: boolean;
|
|
831
|
+
}
|
|
832
|
+
declare const WorkflowNextButton: React__default.NamedExoticComponent<WorkflowNextButtonProps>;
|
|
833
|
+
|
|
834
|
+
interface WorkflowPreviousButtonProps extends ComponentRendererBaseProps<WorkflowPreviousButtonRendererProps> {
|
|
835
|
+
/**
|
|
836
|
+
* Override the isSubmitting state from workflow/form context
|
|
837
|
+
* If provided, this value will be used instead of the computed isSubmitting state
|
|
838
|
+
*/
|
|
839
|
+
isSubmitting?: boolean;
|
|
840
|
+
}
|
|
841
|
+
declare const WorkflowPreviousButton: React__default.NamedExoticComponent<WorkflowPreviousButtonProps>;
|
|
842
|
+
|
|
843
|
+
interface WorkflowSkipButtonProps extends ComponentRendererBaseProps<WorkflowSkipButtonRendererProps> {
|
|
844
|
+
/**
|
|
845
|
+
* Override the isSubmitting state from workflow/form context
|
|
846
|
+
* If provided, this value will be used instead of the computed isSubmitting state
|
|
847
|
+
*/
|
|
848
|
+
isSubmitting?: boolean;
|
|
849
|
+
}
|
|
850
|
+
declare const WorkflowSkipButton: React__default.NamedExoticComponent<WorkflowSkipButtonProps>;
|
|
851
|
+
|
|
852
|
+
interface WorkflowStepperProps extends ComponentRendererBaseProps<WorkflowStepperRendererProps> {
|
|
853
|
+
onStepClick?: (stepIndex: number) => void;
|
|
854
|
+
}
|
|
855
|
+
declare const WorkflowStepper: React__default.NamedExoticComponent<WorkflowStepperProps>;
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* @fileoverview Persistence hook for Rilay workflows
|
|
859
|
+
*
|
|
860
|
+
* This hook provides workflow persistence functionality with automatic
|
|
861
|
+
* debounced saving, error handling, and flexible adapter support.
|
|
862
|
+
* It integrates seamlessly with the existing workflow state management.
|
|
863
|
+
*/
|
|
864
|
+
|
|
865
|
+
interface UsePersistenceProps {
|
|
866
|
+
/** Unique workflow identifier */
|
|
867
|
+
workflowId: string;
|
|
868
|
+
/** Current workflow state */
|
|
869
|
+
workflowState: WorkflowState;
|
|
870
|
+
/** Persistence adapter to use */
|
|
871
|
+
adapter: WorkflowPersistenceAdapter;
|
|
872
|
+
/** Persistence options */
|
|
873
|
+
options?: PersistenceOptions;
|
|
874
|
+
/** Optional user ID for multi-user scenarios */
|
|
875
|
+
userId?: string;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Hook for managing workflow persistence
|
|
879
|
+
*
|
|
880
|
+
* Provides automatic persistence with debouncing, manual save/load operations,
|
|
881
|
+
* and comprehensive error handling. Integrates with any persistence adapter
|
|
882
|
+
* that implements the WorkflowPersistenceAdapter interface.
|
|
883
|
+
*
|
|
884
|
+
* @example
|
|
885
|
+
* ```typescript
|
|
886
|
+
* const persistence = usePersistence({
|
|
887
|
+
* workflowId: 'user-onboarding',
|
|
888
|
+
* workflowState,
|
|
889
|
+
* adapter: new LocalStorageAdapter(),
|
|
890
|
+
* options: {
|
|
891
|
+
* autoPersist: true,
|
|
892
|
+
* debounceMs: 1000
|
|
893
|
+
* }
|
|
894
|
+
* });
|
|
895
|
+
*
|
|
896
|
+
* if (persistence.persistenceError) {
|
|
897
|
+
* console.error('Persistence error:', persistence.persistenceError);
|
|
898
|
+
* }
|
|
899
|
+
* ```
|
|
900
|
+
*/
|
|
901
|
+
declare function usePersistence({ workflowId, workflowState, adapter, options, userId, }: UsePersistenceProps): UsePersistenceReturn;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Hook return type for step metadata access
|
|
905
|
+
*/
|
|
906
|
+
interface UseStepMetadataReturn {
|
|
907
|
+
/**
|
|
908
|
+
* Metadata for the current step
|
|
909
|
+
*/
|
|
910
|
+
current: Record<string, any> | undefined;
|
|
911
|
+
/**
|
|
912
|
+
* Get metadata for a specific step by ID
|
|
913
|
+
* @param stepId - The ID of the step to get metadata for
|
|
914
|
+
* @returns The metadata object or undefined if step not found
|
|
915
|
+
*/
|
|
916
|
+
getByStepId: (stepId: string) => Record<string, any> | undefined;
|
|
917
|
+
/**
|
|
918
|
+
* Get metadata for a specific step by index
|
|
919
|
+
* @param stepIndex - The index of the step to get metadata for
|
|
920
|
+
* @returns The metadata object or undefined if step not found
|
|
921
|
+
*/
|
|
922
|
+
getByStepIndex: (stepIndex: number) => Record<string, any> | undefined;
|
|
923
|
+
/**
|
|
924
|
+
* Check if current step has specific metadata key
|
|
925
|
+
* @param key - The metadata key to check for
|
|
926
|
+
* @returns True if the key exists in current step metadata
|
|
927
|
+
*/
|
|
928
|
+
hasCurrentKey: (key: string) => boolean;
|
|
929
|
+
/**
|
|
930
|
+
* Get specific metadata value from current step
|
|
931
|
+
* @param key - The metadata key to retrieve
|
|
932
|
+
* @param defaultValue - Default value if key doesn't exist
|
|
933
|
+
* @returns The metadata value or default value
|
|
934
|
+
*/
|
|
935
|
+
getCurrentValue: <T = any>(key: string, defaultValue?: T) => T;
|
|
936
|
+
/**
|
|
937
|
+
* Get all steps with their metadata
|
|
938
|
+
* @returns Array of objects containing step info and metadata
|
|
939
|
+
*/
|
|
940
|
+
getAllStepsMetadata: () => Array<{
|
|
941
|
+
id: string;
|
|
942
|
+
title: string;
|
|
943
|
+
index: number;
|
|
944
|
+
metadata: Record<string, any> | undefined;
|
|
945
|
+
}>;
|
|
946
|
+
/**
|
|
947
|
+
* Find steps by metadata criteria
|
|
948
|
+
* @param predicate - Function to test each step's metadata
|
|
949
|
+
* @returns Array of step IDs that match the criteria
|
|
950
|
+
*/
|
|
951
|
+
findStepsByMetadata: (predicate: (metadata: Record<string, any> | undefined, stepId: string, stepIndex: number) => boolean) => string[];
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Hook to access and work with step metadata in workflows
|
|
955
|
+
*
|
|
956
|
+
* This hook provides convenient methods to access metadata for the current step
|
|
957
|
+
* or any other step in the workflow. It's useful for UI customization, analytics,
|
|
958
|
+
* business logic, and integration scenarios.
|
|
959
|
+
*
|
|
960
|
+
* @returns Object containing metadata access methods and current step metadata
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* ```typescript
|
|
964
|
+
* function MyComponent() {
|
|
965
|
+
* const {
|
|
966
|
+
* current,
|
|
967
|
+
* getCurrentValue,
|
|
968
|
+
* hasCurrentKey,
|
|
969
|
+
* getByStepId,
|
|
970
|
+
* findStepsByMetadata
|
|
971
|
+
* } = useStepMetadata();
|
|
972
|
+
*
|
|
973
|
+
* // Access current step metadata
|
|
974
|
+
* const stepIcon = getCurrentValue('icon', 'default-icon');
|
|
975
|
+
* const hasAnalytics = hasCurrentKey('analytics');
|
|
976
|
+
*
|
|
977
|
+
* // Find steps with specific metadata
|
|
978
|
+
* const importantSteps = findStepsByMetadata(
|
|
979
|
+
* (metadata) => metadata?.priority === 'high'
|
|
980
|
+
* );
|
|
981
|
+
*
|
|
982
|
+
* // Get metadata from specific step
|
|
983
|
+
* const paymentStepMeta = getByStepId('payment-step');
|
|
984
|
+
*
|
|
985
|
+
* return (
|
|
986
|
+
* <div>
|
|
987
|
+
* <Icon name={stepIcon} />
|
|
988
|
+
* {hasAnalytics && <AnalyticsTracker />}
|
|
989
|
+
* <p>Important steps: {importantSteps.length}</p>
|
|
990
|
+
* </div>
|
|
991
|
+
* );
|
|
992
|
+
* }
|
|
993
|
+
* ```
|
|
994
|
+
*/
|
|
995
|
+
declare function useStepMetadata(): UseStepMetadataReturn;
|
|
996
|
+
|
|
997
|
+
interface UseWorkflowAnalyticsProps {
|
|
998
|
+
workflowConfig: WorkflowConfig;
|
|
999
|
+
workflowState: WorkflowState;
|
|
1000
|
+
workflowContext: WorkflowContext;
|
|
1001
|
+
}
|
|
1002
|
+
interface UseWorkflowAnalyticsReturn {
|
|
1003
|
+
analyticsStartTime: React.MutableRefObject<number>;
|
|
1004
|
+
trackStepSkip: (stepId: string, reason: string) => void;
|
|
1005
|
+
trackError: (error: Error) => void;
|
|
1006
|
+
trackNavigation: (fromStep: number, toStep: number, duration: number) => void;
|
|
1007
|
+
trackConditionEvaluation: (duration: number, conditionsCount: number) => void;
|
|
1008
|
+
}
|
|
1009
|
+
declare function useWorkflowAnalytics({ workflowConfig, workflowState, workflowContext, }: UseWorkflowAnalyticsProps): UseWorkflowAnalyticsReturn;
|
|
1010
|
+
|
|
1011
|
+
interface UseWorkflowNavigationProps {
|
|
1012
|
+
workflowConfig: WorkflowConfig;
|
|
1013
|
+
workflowState: WorkflowState;
|
|
1014
|
+
workflowContext: WorkflowContext;
|
|
1015
|
+
conditionsHelpers: UseWorkflowConditionsReturn;
|
|
1016
|
+
setCurrentStep: (stepIndex: number) => void;
|
|
1017
|
+
setTransitioning: (isTransitioning: boolean) => void;
|
|
1018
|
+
markStepVisited: (stepIndex: number, stepId: string) => void;
|
|
1019
|
+
markStepPassed: (stepId: string) => void;
|
|
1020
|
+
setStepData: (data: Record<string, any>, stepId: string) => void;
|
|
1021
|
+
onStepChange?: (fromStep: number, toStep: number, context: WorkflowContext) => void;
|
|
1022
|
+
}
|
|
1023
|
+
interface UseWorkflowNavigationReturn {
|
|
1024
|
+
goToStep: (stepIndex: number) => Promise<boolean>;
|
|
1025
|
+
goNext: () => Promise<boolean>;
|
|
1026
|
+
goPrevious: () => Promise<boolean>;
|
|
1027
|
+
skipStep: () => Promise<boolean>;
|
|
1028
|
+
canGoToStep: (stepIndex: number) => boolean;
|
|
1029
|
+
canGoNext: () => boolean;
|
|
1030
|
+
canGoPrevious: () => boolean;
|
|
1031
|
+
canSkipCurrentStep: () => boolean;
|
|
1032
|
+
}
|
|
1033
|
+
declare function useWorkflowNavigation({ workflowConfig, workflowState, workflowContext, conditionsHelpers, setCurrentStep, setTransitioning, markStepVisited, markStepPassed, setStepData, onStepChange, }: UseWorkflowNavigationProps): UseWorkflowNavigationReturn;
|
|
1034
|
+
|
|
1035
|
+
interface UseWorkflowSubmissionProps {
|
|
1036
|
+
workflowConfig: WorkflowConfig;
|
|
1037
|
+
workflowState: WorkflowState;
|
|
1038
|
+
workflowContext: WorkflowContext;
|
|
1039
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
1040
|
+
onWorkflowComplete?: (data: Record<string, any>) => void | Promise<void>;
|
|
1041
|
+
analyticsStartTime: React.MutableRefObject<number>;
|
|
1042
|
+
}
|
|
1043
|
+
interface UseWorkflowSubmissionReturn {
|
|
1044
|
+
submitWorkflow: () => Promise<void>;
|
|
1045
|
+
isSubmitting: boolean;
|
|
1046
|
+
canSubmit: boolean;
|
|
1047
|
+
}
|
|
1048
|
+
declare function useWorkflowSubmission({ workflowConfig, workflowState, workflowContext, setSubmitting, onWorkflowComplete, analyticsStartTime, }: UseWorkflowSubmissionProps): UseWorkflowSubmissionReturn;
|
|
1049
|
+
|
|
1050
|
+
interface WorkflowStoreState {
|
|
1051
|
+
currentStepIndex: number;
|
|
1052
|
+
isTransitioning: boolean;
|
|
1053
|
+
isInitializing: boolean;
|
|
1054
|
+
allData: Record<string, unknown>;
|
|
1055
|
+
stepData: Record<string, unknown>;
|
|
1056
|
+
visitedSteps: Set<string>;
|
|
1057
|
+
passedSteps: Set<string>;
|
|
1058
|
+
isSubmitting: boolean;
|
|
1059
|
+
_defaultValues: Record<string, unknown>;
|
|
1060
|
+
_defaultStepIndex: number;
|
|
1061
|
+
_setCurrentStep: (stepIndex: number) => void;
|
|
1062
|
+
_setStepData: (data: Record<string, unknown>, stepId: string) => void;
|
|
1063
|
+
_setAllData: (data: Record<string, unknown>) => void;
|
|
1064
|
+
_setFieldValue: (fieldId: string, value: unknown, stepId: string) => void;
|
|
1065
|
+
_setSubmitting: (isSubmitting: boolean) => void;
|
|
1066
|
+
_setTransitioning: (isTransitioning: boolean) => void;
|
|
1067
|
+
_setInitializing: (isInitializing: boolean) => void;
|
|
1068
|
+
_markStepVisited: (stepId: string) => void;
|
|
1069
|
+
_markStepPassed: (stepId: string) => void;
|
|
1070
|
+
_reset: () => void;
|
|
1071
|
+
_loadPersistedState: (state: Partial<WorkflowStoreState>) => void;
|
|
1072
|
+
}
|
|
1073
|
+
type WorkflowStore = ReturnType<typeof createWorkflowStore>;
|
|
1074
|
+
interface CreateWorkflowStoreOptions {
|
|
1075
|
+
defaultValues?: Record<string, unknown>;
|
|
1076
|
+
defaultStepIndex?: number;
|
|
1077
|
+
initialVisitedSteps?: Set<string>;
|
|
1078
|
+
initialPassedSteps?: Set<string>;
|
|
1079
|
+
}
|
|
1080
|
+
declare function createWorkflowStore(options?: CreateWorkflowStoreOptions): Omit<zustand.StoreApi<WorkflowStoreState>, "subscribe"> & {
|
|
1081
|
+
subscribe: {
|
|
1082
|
+
(listener: (selectedState: WorkflowStoreState, previousSelectedState: WorkflowStoreState) => void): () => void;
|
|
1083
|
+
<U>(selector: (state: WorkflowStoreState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
1084
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
1085
|
+
fireImmediately?: boolean;
|
|
1086
|
+
} | undefined): () => void;
|
|
1087
|
+
};
|
|
1088
|
+
};
|
|
1089
|
+
declare const WorkflowStoreContext: React$1.Context<(Omit<zustand.StoreApi<WorkflowStoreState>, "subscribe"> & {
|
|
1090
|
+
subscribe: {
|
|
1091
|
+
(listener: (selectedState: WorkflowStoreState, previousSelectedState: WorkflowStoreState) => void): () => void;
|
|
1092
|
+
<U>(selector: (state: WorkflowStoreState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
1093
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
1094
|
+
fireImmediately?: boolean;
|
|
1095
|
+
} | undefined): () => void;
|
|
1096
|
+
};
|
|
1097
|
+
}) | null>;
|
|
1098
|
+
/**
|
|
1099
|
+
* Get the workflow store from context
|
|
1100
|
+
* @throws Error if used outside of WorkflowProvider
|
|
1101
|
+
*/
|
|
1102
|
+
declare function useWorkflowStore(): WorkflowStore;
|
|
1103
|
+
/**
|
|
1104
|
+
* Select current step index - re-renders only when step changes
|
|
1105
|
+
*/
|
|
1106
|
+
declare function useCurrentStepIndex(): number;
|
|
1107
|
+
/**
|
|
1108
|
+
* Select transitioning state
|
|
1109
|
+
*/
|
|
1110
|
+
declare function useWorkflowTransitioning(): boolean;
|
|
1111
|
+
/**
|
|
1112
|
+
* Select initializing state
|
|
1113
|
+
*/
|
|
1114
|
+
declare function useWorkflowInitializing(): boolean;
|
|
1115
|
+
/**
|
|
1116
|
+
* Select submitting state
|
|
1117
|
+
*/
|
|
1118
|
+
declare function useWorkflowSubmitting(): boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* Select all workflow data
|
|
1121
|
+
*/
|
|
1122
|
+
declare function useWorkflowAllData(): Record<string, unknown>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Select current step data
|
|
1125
|
+
*/
|
|
1126
|
+
declare function useWorkflowStepData(): Record<string, unknown>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Select data for a specific step
|
|
1129
|
+
*/
|
|
1130
|
+
declare function useStepDataById(stepId: string): Record<string, unknown> | undefined;
|
|
1131
|
+
/**
|
|
1132
|
+
* Select visited steps
|
|
1133
|
+
*/
|
|
1134
|
+
declare function useVisitedSteps(): Set<string>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Select passed steps
|
|
1137
|
+
*/
|
|
1138
|
+
declare function usePassedSteps(): Set<string>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Check if a specific step is visited
|
|
1141
|
+
*/
|
|
1142
|
+
declare function useIsStepVisited(stepId: string): boolean;
|
|
1143
|
+
/**
|
|
1144
|
+
* Check if a specific step is passed
|
|
1145
|
+
*/
|
|
1146
|
+
declare function useIsStepPassed(stepId: string): boolean;
|
|
1147
|
+
/**
|
|
1148
|
+
* Select navigation state for buttons - minimal re-renders
|
|
1149
|
+
*/
|
|
1150
|
+
declare function useWorkflowNavigationState(): {
|
|
1151
|
+
currentStepIndex: number;
|
|
1152
|
+
isTransitioning: boolean;
|
|
1153
|
+
isSubmitting: boolean;
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* Select submit state for workflow - minimal re-renders
|
|
1157
|
+
*/
|
|
1158
|
+
declare function useWorkflowSubmitState(): {
|
|
1159
|
+
isSubmitting: boolean;
|
|
1160
|
+
isTransitioning: boolean;
|
|
1161
|
+
isInitializing: boolean;
|
|
1162
|
+
};
|
|
1163
|
+
interface UseWorkflowActionsResult {
|
|
1164
|
+
setCurrentStep: (stepIndex: number) => void;
|
|
1165
|
+
setStepData: (data: Record<string, unknown>, stepId: string) => void;
|
|
1166
|
+
setAllData: (data: Record<string, unknown>) => void;
|
|
1167
|
+
setFieldValue: (fieldId: string, value: unknown, stepId: string) => void;
|
|
1168
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
1169
|
+
setTransitioning: (isTransitioning: boolean) => void;
|
|
1170
|
+
setInitializing: (isInitializing: boolean) => void;
|
|
1171
|
+
markStepVisited: (stepId: string) => void;
|
|
1172
|
+
markStepPassed: (stepId: string) => void;
|
|
1173
|
+
reset: () => void;
|
|
1174
|
+
loadPersistedState: (state: Partial<WorkflowStoreState>) => void;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Get stable action references for workflow
|
|
1178
|
+
* Actions don't cause re-renders
|
|
1179
|
+
*/
|
|
1180
|
+
declare function useWorkflowActions(): UseWorkflowActionsResult;
|
|
1181
|
+
/**
|
|
1182
|
+
* Get the raw store for advanced use cases
|
|
1183
|
+
*/
|
|
1184
|
+
declare function useWorkflowStoreApi(): WorkflowStore;
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* @fileoverview LocalStorage persistence adapter for Rilay workflows
|
|
1188
|
+
*
|
|
1189
|
+
* This adapter provides browser localStorage-based persistence for workflow data.
|
|
1190
|
+
* It includes features like data compression, expiration handling, and error recovery.
|
|
1191
|
+
*
|
|
1192
|
+
* Key features:
|
|
1193
|
+
* - Automatic data expiration based on maxAge
|
|
1194
|
+
* - Optional data compression for large workflows
|
|
1195
|
+
* - Graceful handling of localStorage quota exceeded
|
|
1196
|
+
* - Type-safe serialization/deserialization
|
|
1197
|
+
*/
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* LocalStorage-based persistence adapter
|
|
1201
|
+
*
|
|
1202
|
+
* Provides a robust localStorage implementation with features like:
|
|
1203
|
+
* - Automatic cleanup of expired data
|
|
1204
|
+
* - Configurable key prefixes for namespace isolation
|
|
1205
|
+
* - Error handling for quota exceeded scenarios
|
|
1206
|
+
* - Optional data compression
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* ```typescript
|
|
1210
|
+
* const adapter = new LocalStorageAdapter({
|
|
1211
|
+
* keyPrefix: 'myapp_workflow_',
|
|
1212
|
+
* maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
|
1213
|
+
* compress: true
|
|
1214
|
+
* });
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
declare class LocalStorageAdapter implements WorkflowPersistenceAdapter {
|
|
1218
|
+
private readonly keyPrefix;
|
|
1219
|
+
private readonly compress;
|
|
1220
|
+
private readonly maxAge?;
|
|
1221
|
+
private readonly version;
|
|
1222
|
+
private readonly _isAvailable;
|
|
1223
|
+
constructor(config?: LocalStorageAdapterConfig);
|
|
1224
|
+
/**
|
|
1225
|
+
* Save workflow data to localStorage
|
|
1226
|
+
*/
|
|
1227
|
+
save(key: string, data: PersistedWorkflowData): Promise<void>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Load workflow data from localStorage
|
|
1230
|
+
*/
|
|
1231
|
+
load(key: string): Promise<PersistedWorkflowData | null>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Remove workflow data from localStorage
|
|
1234
|
+
*/
|
|
1235
|
+
remove(key: string): Promise<void>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Check if data exists for the given key
|
|
1238
|
+
*/
|
|
1239
|
+
exists(key: string): Promise<boolean>;
|
|
1240
|
+
/**
|
|
1241
|
+
* List all available keys
|
|
1242
|
+
*/
|
|
1243
|
+
listKeys(): Promise<string[]>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Clear all workflow data
|
|
1246
|
+
*/
|
|
1247
|
+
clear(): Promise<void>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Get the full storage key with prefix
|
|
1250
|
+
*/
|
|
1251
|
+
private getStorageKey;
|
|
1252
|
+
/**
|
|
1253
|
+
* Check if localStorage is available
|
|
1254
|
+
*/
|
|
1255
|
+
private isLocalStorageAvailable;
|
|
1256
|
+
/**
|
|
1257
|
+
* Simple data compression using basic string compression
|
|
1258
|
+
* Note: In production, you might want to use a proper compression library
|
|
1259
|
+
*/
|
|
1260
|
+
private compressData;
|
|
1261
|
+
/**
|
|
1262
|
+
* Decompress data
|
|
1263
|
+
*/
|
|
1264
|
+
private decompressData;
|
|
1265
|
+
/**
|
|
1266
|
+
* Clear expired data entries
|
|
1267
|
+
*/
|
|
1268
|
+
private clearExpiredData;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* @fileoverview Persistence utilities for Rilay workflows
|
|
1273
|
+
*
|
|
1274
|
+
* This module provides utility functions for working with workflow persistence,
|
|
1275
|
+
* including data transformation, validation, and helper functions for
|
|
1276
|
+
* converting between different data formats.
|
|
1277
|
+
*/
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Convert WorkflowState to PersistedWorkflowData format
|
|
1281
|
+
*/
|
|
1282
|
+
declare function workflowStateToPersisted(workflowId: string, state: WorkflowState, metadata?: Record<string, any>): PersistedWorkflowData;
|
|
1283
|
+
/**
|
|
1284
|
+
* Convert PersistedWorkflowData to WorkflowState format
|
|
1285
|
+
*/
|
|
1286
|
+
declare function persistedToWorkflowState(data: PersistedWorkflowData): Partial<WorkflowState>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Validate persisted workflow data structure
|
|
1289
|
+
*/
|
|
1290
|
+
declare function validatePersistedData(data: any): data is PersistedWorkflowData;
|
|
1291
|
+
/**
|
|
1292
|
+
* Generate a storage key for a workflow
|
|
1293
|
+
*/
|
|
1294
|
+
declare function generateStorageKey(workflowId: string, userId?: string): string;
|
|
1295
|
+
/**
|
|
1296
|
+
* Debounce function for auto-persistence
|
|
1297
|
+
*/
|
|
1298
|
+
declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
1299
|
+
/**
|
|
1300
|
+
* Merge persisted data with current state, handling conflicts
|
|
1301
|
+
*/
|
|
1302
|
+
declare function mergePersistedState(currentState: WorkflowState, persistedData: PersistedWorkflowData, strategy?: 'persist' | 'current' | 'merge'): Partial<WorkflowState>;
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Utility functions for handling nested data structures in workflows
|
|
1306
|
+
* and making them compatible with condition evaluation
|
|
1307
|
+
*/
|
|
1308
|
+
/**
|
|
1309
|
+
* Flattens a nested object into a flat object with dot-notation keys
|
|
1310
|
+
*
|
|
1311
|
+
* @param obj - The nested object to flatten
|
|
1312
|
+
* @param prefix - The prefix to use for keys (used internally for recursion)
|
|
1313
|
+
* @returns A flattened object with dot-notation keys
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```typescript
|
|
1317
|
+
* const nested = {
|
|
1318
|
+
* products: { requestedProducts: ['health'] },
|
|
1319
|
+
* user: { profile: { name: 'John' } }
|
|
1320
|
+
* };
|
|
1321
|
+
*
|
|
1322
|
+
* const flat = flattenObject(nested);
|
|
1323
|
+
* // Result: {
|
|
1324
|
+
* // 'products.requestedProducts': ['health'],
|
|
1325
|
+
* // 'user.profile.name': 'John'
|
|
1326
|
+
* // }
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
declare function flattenObject(obj: Record<string, any>, prefix?: string): Record<string, any>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Combines workflow data from different sources and flattens them for condition evaluation
|
|
1332
|
+
*
|
|
1333
|
+
* @param allData - Global workflow data (usually from defaultValues)
|
|
1334
|
+
* @param stepData - Step-specific data
|
|
1335
|
+
* @returns Combined and flattened data ready for condition evaluation
|
|
1336
|
+
*/
|
|
1337
|
+
declare function combineWorkflowDataForConditions(allData: Record<string, any>, stepData: Record<string, any>): Record<string, any>;
|
|
1338
|
+
|
|
1339
|
+
export { type CreateWorkflowStoreOptions, LocalStorageAdapter, type LocalStorageAdapterConfig, type PersistedWorkflowData, type PersistenceOptions, type StepDefinition, type UsePersistenceProps, type UsePersistenceReturn, type UseWorkflowActionsResult, Workflow, WorkflowBody, type WorkflowContextValue, WorkflowNextButton, type WorkflowPersistenceAdapter, WorkflowPersistenceError, WorkflowPreviousButton, WorkflowProvider, WorkflowSkipButton, WorkflowStepper, type WorkflowStore, WorkflowStoreContext, type WorkflowStoreState, combineWorkflowDataForConditions, createWorkflowStore, debounce, flattenObject, flow, generateStorageKey, mergePersistedState, persistedToWorkflowState, useConditionEvaluation, useCurrentStepIndex, useIsStepPassed, useIsStepVisited, usePassedSteps, usePersistence, useStepDataById, useStepMetadata, useVisitedSteps, useWorkflowActions, useWorkflowAllData, useWorkflowAnalytics, useWorkflowConditions, useWorkflowContext, useWorkflowInitializing, useWorkflowNavigation, useWorkflowNavigationState, useWorkflowState, useWorkflowStepData, useWorkflowStore, useWorkflowStoreApi, useWorkflowSubmission, useWorkflowSubmitState, useWorkflowSubmitting, useWorkflowTransitioning, validatePersistedData, workflowStateToPersisted };
|