@rilaykit/workflow 7.1.0 → 7.2.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/dist/index.d.mts +247 -237
- package/dist/index.d.ts +247 -237
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,202 @@ export { form } from '@rilaykit/forms';
|
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import React$1 from 'react';
|
|
7
7
|
|
|
8
|
+
interface WorkflowState {
|
|
9
|
+
currentStepIndex: number;
|
|
10
|
+
allData: Record<string, any>;
|
|
11
|
+
stepData: Record<string, any>;
|
|
12
|
+
visitedSteps: Set<string>;
|
|
13
|
+
isSubmitting: boolean;
|
|
14
|
+
isTransitioning: boolean;
|
|
15
|
+
isInitializing: boolean;
|
|
16
|
+
}
|
|
17
|
+
type WorkflowAction = {
|
|
18
|
+
type: 'SET_CURRENT_STEP';
|
|
19
|
+
stepIndex: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'SET_STEP_DATA';
|
|
22
|
+
data: Record<string, any>;
|
|
23
|
+
stepId: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'SET_ALL_DATA';
|
|
26
|
+
data: Record<string, any>;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'SET_FIELD_VALUE';
|
|
29
|
+
fieldId: string;
|
|
30
|
+
value: any;
|
|
31
|
+
stepId: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'SET_SUBMITTING';
|
|
34
|
+
isSubmitting: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'SET_TRANSITIONING';
|
|
37
|
+
isTransitioning: boolean;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'MARK_STEP_VISITED';
|
|
40
|
+
stepIndex: number;
|
|
41
|
+
stepId: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'RESET_WORKFLOW';
|
|
44
|
+
} | {
|
|
45
|
+
type: 'LOAD_PERSISTED_STATE';
|
|
46
|
+
state: Partial<WorkflowState>;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'SET_INITIALIZATION_COMPLETE';
|
|
49
|
+
};
|
|
50
|
+
interface UseWorkflowStateProps {
|
|
51
|
+
defaultValues?: Record<string, any>;
|
|
52
|
+
persistence?: {
|
|
53
|
+
workflowId: string;
|
|
54
|
+
adapter?: WorkflowPersistenceAdapter;
|
|
55
|
+
options?: PersistenceOptions;
|
|
56
|
+
userId?: string;
|
|
57
|
+
autoLoad?: boolean;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
declare function useWorkflowState({ defaultValues, persistence }: UseWorkflowStateProps): {
|
|
61
|
+
workflowState: WorkflowState;
|
|
62
|
+
setCurrentStep: (stepIndex: number) => void;
|
|
63
|
+
setStepData: (data: Record<string, any>, stepId: string) => void;
|
|
64
|
+
setFieldValue: (fieldId: string, value: any, stepId: string) => void;
|
|
65
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
66
|
+
setTransitioning: (isTransitioning: boolean) => void;
|
|
67
|
+
markStepVisited: (stepIndex: number, stepId: string) => void;
|
|
68
|
+
resetWorkflow: () => void;
|
|
69
|
+
loadPersistedState: () => Promise<boolean>;
|
|
70
|
+
persistence: {
|
|
71
|
+
isPersisting: boolean;
|
|
72
|
+
persistenceError: WorkflowPersistenceError | null;
|
|
73
|
+
persistNow: () => Promise<void>;
|
|
74
|
+
clearPersistedData: () => Promise<void>;
|
|
75
|
+
hasPersistedData: () => Promise<boolean>;
|
|
76
|
+
} | null;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @fileoverview Persistence system types for Rilay workflows
|
|
81
|
+
*
|
|
82
|
+
* This module defines the core interfaces and types for the workflow persistence system.
|
|
83
|
+
* It provides a flexible adapter pattern allowing different persistence strategies:
|
|
84
|
+
* - localStorage persistence
|
|
85
|
+
* - API-based persistence
|
|
86
|
+
* - Custom persistence implementations
|
|
87
|
+
*
|
|
88
|
+
* The system is designed to be type-safe and extensible while maintaining
|
|
89
|
+
* a simple API for common use cases.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Persistent workflow data that gets saved/loaded
|
|
94
|
+
*/
|
|
95
|
+
interface PersistedWorkflowData {
|
|
96
|
+
/** Unique identifier for the workflow */
|
|
97
|
+
workflowId: string;
|
|
98
|
+
/** Current step index in the workflow */
|
|
99
|
+
currentStepIndex: number;
|
|
100
|
+
/** All collected data across steps */
|
|
101
|
+
allData: Record<string, any>;
|
|
102
|
+
/** Currently active step data */
|
|
103
|
+
stepData: Record<string, any>;
|
|
104
|
+
/** Set of visited step IDs */
|
|
105
|
+
visitedSteps: string[];
|
|
106
|
+
/** When this data was last saved */
|
|
107
|
+
lastSaved: number;
|
|
108
|
+
/** Optional metadata for custom persistence needs */
|
|
109
|
+
metadata?: Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for persistence operations
|
|
113
|
+
*/
|
|
114
|
+
interface PersistenceOptions {
|
|
115
|
+
/** Whether to automatically persist on state changes */
|
|
116
|
+
autoPersist?: boolean;
|
|
117
|
+
/** Debounce delay in ms for auto-persistence (default: 500ms) */
|
|
118
|
+
debounceMs?: number;
|
|
119
|
+
/** Custom key for storage (overrides default) */
|
|
120
|
+
storageKey?: string;
|
|
121
|
+
/** Additional metadata to include in persisted data */
|
|
122
|
+
metadata?: Record<string, any>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Core persistence adapter interface
|
|
126
|
+
*
|
|
127
|
+
* All persistence implementations must implement this interface.
|
|
128
|
+
* It provides a consistent API regardless of the underlying storage mechanism.
|
|
129
|
+
*/
|
|
130
|
+
interface WorkflowPersistenceAdapter {
|
|
131
|
+
/**
|
|
132
|
+
* Save workflow data
|
|
133
|
+
* @param key - Unique identifier for the stored data
|
|
134
|
+
* @param data - Workflow data to persist
|
|
135
|
+
* @returns Promise that resolves when save is complete
|
|
136
|
+
*/
|
|
137
|
+
save(key: string, data: PersistedWorkflowData): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Load workflow data
|
|
140
|
+
* @param key - Unique identifier for the stored data
|
|
141
|
+
* @returns Promise that resolves to persisted data or null if not found
|
|
142
|
+
*/
|
|
143
|
+
load(key: string): Promise<PersistedWorkflowData | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Remove persisted workflow data
|
|
146
|
+
* @param key - Unique identifier for the stored data
|
|
147
|
+
* @returns Promise that resolves when deletion is complete
|
|
148
|
+
*/
|
|
149
|
+
remove(key: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Check if data exists for the given key
|
|
152
|
+
* @param key - Unique identifier to check
|
|
153
|
+
* @returns Promise that resolves to true if data exists
|
|
154
|
+
*/
|
|
155
|
+
exists(key: string): Promise<boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* List all available keys (optional, for debugging/admin)
|
|
158
|
+
* @returns Promise that resolves to array of available keys
|
|
159
|
+
*/
|
|
160
|
+
listKeys?(): Promise<string[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Clear all persisted data (optional, for cleanup)
|
|
163
|
+
* @returns Promise that resolves when all data is cleared
|
|
164
|
+
*/
|
|
165
|
+
clear?(): Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Configuration for localStorage persistence adapter
|
|
169
|
+
*/
|
|
170
|
+
interface LocalStorageAdapterConfig {
|
|
171
|
+
/** Prefix for localStorage keys (default: 'rilay_workflow_') */
|
|
172
|
+
keyPrefix?: string;
|
|
173
|
+
/** Whether to compress data before storage */
|
|
174
|
+
compress?: boolean;
|
|
175
|
+
/** Maximum age in ms before data expires (optional) */
|
|
176
|
+
maxAge?: number;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Error types for persistence operations
|
|
180
|
+
*/
|
|
181
|
+
declare class WorkflowPersistenceError extends Error {
|
|
182
|
+
readonly code: string;
|
|
183
|
+
readonly cause?: Error | undefined;
|
|
184
|
+
constructor(message: string, code: string, cause?: Error | undefined);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Persistence hook return type
|
|
188
|
+
*/
|
|
189
|
+
interface UsePersistenceReturn {
|
|
190
|
+
/** Whether persistence is currently saving */
|
|
191
|
+
isPersisting: boolean;
|
|
192
|
+
/** Last persistence error (if any) */
|
|
193
|
+
persistenceError: WorkflowPersistenceError | null;
|
|
194
|
+
/** Manually trigger a save operation */
|
|
195
|
+
persistNow: () => Promise<void>;
|
|
196
|
+
/** Load data from persistence */
|
|
197
|
+
loadPersistedData: () => Promise<PersistedWorkflowData | null>;
|
|
198
|
+
/** Clear persisted data */
|
|
199
|
+
clearPersistedData: () => Promise<void>;
|
|
200
|
+
/** Whether persisted data exists */
|
|
201
|
+
hasPersistedData: () => Promise<boolean>;
|
|
202
|
+
}
|
|
203
|
+
|
|
8
204
|
/**
|
|
9
205
|
* Enhanced step configuration interface for better type safety and simplicity
|
|
10
206
|
*
|
|
@@ -97,6 +293,12 @@ interface StepDefinition {
|
|
|
97
293
|
interface WorkflowOptions {
|
|
98
294
|
/** Analytics and tracking configuration */
|
|
99
295
|
analytics?: WorkflowAnalytics;
|
|
296
|
+
/** Persistence configuration */
|
|
297
|
+
persistence?: {
|
|
298
|
+
adapter: WorkflowPersistenceAdapter;
|
|
299
|
+
options?: PersistenceOptions;
|
|
300
|
+
userId?: string;
|
|
301
|
+
};
|
|
100
302
|
}
|
|
101
303
|
/**
|
|
102
304
|
* Workflow builder class for creating complex multi-step workflows
|
|
@@ -141,6 +343,7 @@ declare class flow {
|
|
|
141
343
|
private workflowDescription?;
|
|
142
344
|
private steps;
|
|
143
345
|
private analytics?;
|
|
346
|
+
private persistenceConfig?;
|
|
144
347
|
private plugins;
|
|
145
348
|
private idGenerator;
|
|
146
349
|
/**
|
|
@@ -231,17 +434,14 @@ declare class flow {
|
|
|
231
434
|
* @example
|
|
232
435
|
* ```typescript
|
|
233
436
|
* workflow.configure({
|
|
234
|
-
* navigation: {
|
|
235
|
-
* allowBackNavigation: true,
|
|
236
|
-
* showProgressBar: true
|
|
237
|
-
* },
|
|
238
|
-
* persistence: {
|
|
239
|
-
* saveOnStepComplete: true,
|
|
240
|
-
* storageKey: 'my-workflow'
|
|
241
|
-
* },
|
|
242
437
|
* analytics: {
|
|
243
438
|
* trackStepCompletion: true,
|
|
244
439
|
* trackFieldInteractions: false
|
|
440
|
+
* },
|
|
441
|
+
* persistence: {
|
|
442
|
+
* adapter: new LocalStorageAdapter(),
|
|
443
|
+
* options: { autoPersist: true, debounceMs: 1000 },
|
|
444
|
+
* userId: 'user123'
|
|
245
445
|
* }
|
|
246
446
|
* });
|
|
247
447
|
* ```
|
|
@@ -574,197 +774,50 @@ declare function useMultipleConditionEvaluation(fieldsWithConditions: Record<str
|
|
|
574
774
|
declare function useMultipleStepConditionEvaluation(stepsWithConditions: Record<number, ConditionalBehavior | undefined>, workflowData?: Record<string, any>): Record<number, ConditionEvaluationResult>;
|
|
575
775
|
|
|
576
776
|
/**
|
|
577
|
-
* @fileoverview Persistence
|
|
578
|
-
*
|
|
579
|
-
* This module defines the core interfaces and types for the workflow persistence system.
|
|
580
|
-
* It provides a flexible adapter pattern allowing different persistence strategies:
|
|
581
|
-
* - localStorage persistence
|
|
582
|
-
* - API-based persistence
|
|
583
|
-
* - Custom persistence implementations
|
|
777
|
+
* @fileoverview Persistence hook for Rilay workflows
|
|
584
778
|
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
779
|
+
* This hook provides workflow persistence functionality with automatic
|
|
780
|
+
* debounced saving, error handling, and flexible adapter support.
|
|
781
|
+
* It integrates seamlessly with the existing workflow state management.
|
|
587
782
|
*/
|
|
588
783
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
*/
|
|
592
|
-
interface PersistedWorkflowData {
|
|
593
|
-
/** Unique identifier for the workflow */
|
|
784
|
+
interface UsePersistenceProps {
|
|
785
|
+
/** Unique workflow identifier */
|
|
594
786
|
workflowId: string;
|
|
595
|
-
/** Current
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
|
|
603
|
-
/** When this data was last saved */
|
|
604
|
-
lastSaved: number;
|
|
605
|
-
/** Optional metadata for custom persistence needs */
|
|
606
|
-
metadata?: Record<string, any>;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Options for persistence operations
|
|
610
|
-
*/
|
|
611
|
-
interface PersistenceOptions {
|
|
612
|
-
/** Whether to automatically persist on state changes */
|
|
613
|
-
autoPersist?: boolean;
|
|
614
|
-
/** Debounce delay in ms for auto-persistence (default: 500ms) */
|
|
615
|
-
debounceMs?: number;
|
|
616
|
-
/** Custom key for storage (overrides default) */
|
|
617
|
-
storageKey?: string;
|
|
618
|
-
/** Additional metadata to include in persisted data */
|
|
619
|
-
metadata?: Record<string, any>;
|
|
787
|
+
/** Current workflow state */
|
|
788
|
+
workflowState: WorkflowState;
|
|
789
|
+
/** Persistence adapter to use */
|
|
790
|
+
adapter: WorkflowPersistenceAdapter;
|
|
791
|
+
/** Persistence options */
|
|
792
|
+
options?: PersistenceOptions;
|
|
793
|
+
/** Optional user ID for multi-user scenarios */
|
|
794
|
+
userId?: string;
|
|
620
795
|
}
|
|
621
796
|
/**
|
|
622
|
-
*
|
|
797
|
+
* Hook for managing workflow persistence
|
|
623
798
|
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
* @returns Promise that resolves when deletion is complete
|
|
645
|
-
*/
|
|
646
|
-
remove(key: string): Promise<void>;
|
|
647
|
-
/**
|
|
648
|
-
* Check if data exists for the given key
|
|
649
|
-
* @param key - Unique identifier to check
|
|
650
|
-
* @returns Promise that resolves to true if data exists
|
|
651
|
-
*/
|
|
652
|
-
exists(key: string): Promise<boolean>;
|
|
653
|
-
/**
|
|
654
|
-
* List all available keys (optional, for debugging/admin)
|
|
655
|
-
* @returns Promise that resolves to array of available keys
|
|
656
|
-
*/
|
|
657
|
-
listKeys?(): Promise<string[]>;
|
|
658
|
-
/**
|
|
659
|
-
* Clear all persisted data (optional, for cleanup)
|
|
660
|
-
* @returns Promise that resolves when all data is cleared
|
|
661
|
-
*/
|
|
662
|
-
clear?(): Promise<void>;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Configuration for localStorage persistence adapter
|
|
666
|
-
*/
|
|
667
|
-
interface LocalStorageAdapterConfig {
|
|
668
|
-
/** Prefix for localStorage keys (default: 'rilay_workflow_') */
|
|
669
|
-
keyPrefix?: string;
|
|
670
|
-
/** Whether to compress data before storage */
|
|
671
|
-
compress?: boolean;
|
|
672
|
-
/** Maximum age in ms before data expires (optional) */
|
|
673
|
-
maxAge?: number;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Error types for persistence operations
|
|
677
|
-
*/
|
|
678
|
-
declare class WorkflowPersistenceError extends Error {
|
|
679
|
-
readonly code: string;
|
|
680
|
-
readonly cause?: Error | undefined;
|
|
681
|
-
constructor(message: string, code: string, cause?: Error | undefined);
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Persistence hook return type
|
|
799
|
+
* Provides automatic persistence with debouncing, manual save/load operations,
|
|
800
|
+
* and comprehensive error handling. Integrates with any persistence adapter
|
|
801
|
+
* that implements the WorkflowPersistenceAdapter interface.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```typescript
|
|
805
|
+
* const persistence = usePersistence({
|
|
806
|
+
* workflowId: 'user-onboarding',
|
|
807
|
+
* workflowState,
|
|
808
|
+
* adapter: new LocalStorageAdapter(),
|
|
809
|
+
* options: {
|
|
810
|
+
* autoPersist: true,
|
|
811
|
+
* debounceMs: 1000
|
|
812
|
+
* }
|
|
813
|
+
* });
|
|
814
|
+
*
|
|
815
|
+
* if (persistence.persistenceError) {
|
|
816
|
+
* console.error('Persistence error:', persistence.persistenceError);
|
|
817
|
+
* }
|
|
818
|
+
* ```
|
|
685
819
|
*/
|
|
686
|
-
|
|
687
|
-
/** Whether persistence is currently saving */
|
|
688
|
-
isPersisting: boolean;
|
|
689
|
-
/** Last persistence error (if any) */
|
|
690
|
-
persistenceError: WorkflowPersistenceError | null;
|
|
691
|
-
/** Manually trigger a save operation */
|
|
692
|
-
persistNow: () => Promise<void>;
|
|
693
|
-
/** Load data from persistence */
|
|
694
|
-
loadPersistedData: () => Promise<PersistedWorkflowData | null>;
|
|
695
|
-
/** Clear persisted data */
|
|
696
|
-
clearPersistedData: () => Promise<void>;
|
|
697
|
-
/** Whether persisted data exists */
|
|
698
|
-
hasPersistedData: () => Promise<boolean>;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
interface WorkflowState {
|
|
702
|
-
currentStepIndex: number;
|
|
703
|
-
allData: Record<string, any>;
|
|
704
|
-
stepData: Record<string, any>;
|
|
705
|
-
visitedSteps: Set<string>;
|
|
706
|
-
isSubmitting: boolean;
|
|
707
|
-
isTransitioning: boolean;
|
|
708
|
-
}
|
|
709
|
-
type WorkflowAction = {
|
|
710
|
-
type: 'SET_CURRENT_STEP';
|
|
711
|
-
stepIndex: number;
|
|
712
|
-
} | {
|
|
713
|
-
type: 'SET_STEP_DATA';
|
|
714
|
-
data: Record<string, any>;
|
|
715
|
-
stepId: string;
|
|
716
|
-
} | {
|
|
717
|
-
type: 'SET_ALL_DATA';
|
|
718
|
-
data: Record<string, any>;
|
|
719
|
-
} | {
|
|
720
|
-
type: 'SET_FIELD_VALUE';
|
|
721
|
-
fieldId: string;
|
|
722
|
-
value: any;
|
|
723
|
-
stepId: string;
|
|
724
|
-
} | {
|
|
725
|
-
type: 'SET_SUBMITTING';
|
|
726
|
-
isSubmitting: boolean;
|
|
727
|
-
} | {
|
|
728
|
-
type: 'SET_TRANSITIONING';
|
|
729
|
-
isTransitioning: boolean;
|
|
730
|
-
} | {
|
|
731
|
-
type: 'MARK_STEP_VISITED';
|
|
732
|
-
stepIndex: number;
|
|
733
|
-
stepId: string;
|
|
734
|
-
} | {
|
|
735
|
-
type: 'RESET_WORKFLOW';
|
|
736
|
-
} | {
|
|
737
|
-
type: 'LOAD_PERSISTED_STATE';
|
|
738
|
-
state: Partial<WorkflowState>;
|
|
739
|
-
};
|
|
740
|
-
interface UseWorkflowStateProps {
|
|
741
|
-
defaultValues?: Record<string, any>;
|
|
742
|
-
persistence?: {
|
|
743
|
-
workflowId: string;
|
|
744
|
-
adapter?: WorkflowPersistenceAdapter;
|
|
745
|
-
options?: PersistenceOptions;
|
|
746
|
-
userId?: string;
|
|
747
|
-
autoLoad?: boolean;
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
declare function useWorkflowState({ defaultValues, persistence }: UseWorkflowStateProps): {
|
|
751
|
-
workflowState: WorkflowState;
|
|
752
|
-
setCurrentStep: (stepIndex: number) => void;
|
|
753
|
-
setStepData: (data: Record<string, any>, stepId: string) => void;
|
|
754
|
-
setFieldValue: (fieldId: string, value: any, stepId: string) => void;
|
|
755
|
-
setSubmitting: (isSubmitting: boolean) => void;
|
|
756
|
-
setTransitioning: (isTransitioning: boolean) => void;
|
|
757
|
-
markStepVisited: (stepIndex: number, stepId: string) => void;
|
|
758
|
-
resetWorkflow: () => void;
|
|
759
|
-
loadPersistedState: () => Promise<boolean>;
|
|
760
|
-
persistence: {
|
|
761
|
-
isPersisting: boolean;
|
|
762
|
-
persistenceError: WorkflowPersistenceError | null;
|
|
763
|
-
persistNow: () => Promise<void>;
|
|
764
|
-
clearPersistedData: () => Promise<void>;
|
|
765
|
-
hasPersistedData: () => Promise<boolean>;
|
|
766
|
-
} | null;
|
|
767
|
-
};
|
|
820
|
+
declare function usePersistence({ workflowId, workflowState, adapter, options, userId, }: UsePersistenceProps): UsePersistenceReturn;
|
|
768
821
|
|
|
769
822
|
interface UseWorkflowAnalyticsProps {
|
|
770
823
|
workflowConfig: WorkflowConfig;
|
|
@@ -872,6 +925,9 @@ interface WorkflowContextValue {
|
|
|
872
925
|
submitWorkflow: () => Promise<void>;
|
|
873
926
|
isSubmitting: boolean;
|
|
874
927
|
canSubmit: boolean;
|
|
928
|
+
persistNow?: () => Promise<void>;
|
|
929
|
+
isPersisting?: boolean;
|
|
930
|
+
persistenceError?: Error | null;
|
|
875
931
|
}
|
|
876
932
|
interface WorkflowProviderProps {
|
|
877
933
|
children: React$1.ReactNode;
|
|
@@ -1031,52 +1087,6 @@ declare function debounce<T extends (...args: any[]) => any>(func: T, wait: numb
|
|
|
1031
1087
|
*/
|
|
1032
1088
|
declare function mergePersistedState(currentState: WorkflowState, persistedData: PersistedWorkflowData, strategy?: 'persist' | 'current' | 'merge'): Partial<WorkflowState>;
|
|
1033
1089
|
|
|
1034
|
-
/**
|
|
1035
|
-
* @fileoverview Persistence hook for Rilay workflows
|
|
1036
|
-
*
|
|
1037
|
-
* This hook provides workflow persistence functionality with automatic
|
|
1038
|
-
* debounced saving, error handling, and flexible adapter support.
|
|
1039
|
-
* It integrates seamlessly with the existing workflow state management.
|
|
1040
|
-
*/
|
|
1041
|
-
|
|
1042
|
-
interface UsePersistenceProps {
|
|
1043
|
-
/** Unique workflow identifier */
|
|
1044
|
-
workflowId: string;
|
|
1045
|
-
/** Current workflow state */
|
|
1046
|
-
workflowState: WorkflowState;
|
|
1047
|
-
/** Persistence adapter to use */
|
|
1048
|
-
adapter: WorkflowPersistenceAdapter;
|
|
1049
|
-
/** Persistence options */
|
|
1050
|
-
options?: PersistenceOptions;
|
|
1051
|
-
/** Optional user ID for multi-user scenarios */
|
|
1052
|
-
userId?: string;
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Hook for managing workflow persistence
|
|
1056
|
-
*
|
|
1057
|
-
* Provides automatic persistence with debouncing, manual save/load operations,
|
|
1058
|
-
* and comprehensive error handling. Integrates with any persistence adapter
|
|
1059
|
-
* that implements the WorkflowPersistenceAdapter interface.
|
|
1060
|
-
*
|
|
1061
|
-
* @example
|
|
1062
|
-
* ```typescript
|
|
1063
|
-
* const persistence = usePersistence({
|
|
1064
|
-
* workflowId: 'user-onboarding',
|
|
1065
|
-
* workflowState,
|
|
1066
|
-
* adapter: new LocalStorageAdapter(),
|
|
1067
|
-
* options: {
|
|
1068
|
-
* autoPersist: true,
|
|
1069
|
-
* debounceMs: 1000
|
|
1070
|
-
* }
|
|
1071
|
-
* });
|
|
1072
|
-
*
|
|
1073
|
-
* if (persistence.persistenceError) {
|
|
1074
|
-
* console.error('Persistence error:', persistence.persistenceError);
|
|
1075
|
-
* }
|
|
1076
|
-
* ```
|
|
1077
|
-
*/
|
|
1078
|
-
declare function usePersistence({ workflowId, workflowState, adapter, options, userId, }: UsePersistenceProps): UsePersistenceReturn;
|
|
1079
|
-
|
|
1080
1090
|
interface LicensePayload {
|
|
1081
1091
|
plan: 'ARCHITECT' | 'FOUNDRY';
|
|
1082
1092
|
company: string;
|