@rilaykit/workflow 5.2.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { ril, FormConfiguration, CustomStepRenderer, StepDataHelper, WorkflowContext, WorkflowAnalytics, WorkflowPlugin, StepConfig, WorkflowConfig, ComponentRendererBaseProps, WorkflowNextButtonRendererProps, WorkflowPreviousButtonRendererProps, WorkflowSkipButtonRendererProps, WorkflowStepperRendererProps } from '@rilaykit/core';
1
+ import { ril, FormConfiguration, CustomStepRenderer, StepConditionalBehavior, StepDataHelper, WorkflowContext, WorkflowAnalytics, WorkflowPlugin, StepConfig, WorkflowConfig, ConditionalBehavior, ComponentRendererBaseProps, WorkflowNextButtonRendererProps, WorkflowPreviousButtonRendererProps, WorkflowSkipButtonRendererProps, WorkflowStepperRendererProps } from '@rilaykit/core';
2
2
  export * from '@rilaykit/core';
3
3
  import { form } from '@rilaykit/forms';
4
4
  export { form } from '@rilaykit/forms';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import React from 'react';
6
+ import React$1 from 'react';
7
7
 
8
8
  /**
9
9
  * Enhanced step configuration interface for better type safety and simplicity
@@ -50,6 +50,11 @@ interface StepDefinition {
50
50
  * Allows complete customization of step presentation
51
51
  */
52
52
  renderer?: CustomStepRenderer;
53
+ /**
54
+ * Conditional behavior configuration for this step
55
+ * Controls visibility and skippable state
56
+ */
57
+ conditions?: StepConditionalBehavior;
53
58
  /**
54
59
  * Callback function that executes after successful validation and before moving to next step
55
60
  * Provides clean helper methods for modifying workflow data and pre-filling subsequent steps
@@ -300,6 +305,26 @@ declare class flow {
300
305
  * ```
301
306
  */
302
307
  updateStep(stepId: string, updates: Partial<Omit<StepConfig, 'id'>>): this;
308
+ /**
309
+ * Adds conditions to a specific step by ID
310
+ *
311
+ * This method allows adding conditional behavior to a step after it has been created,
312
+ * useful for dynamic conditional requirements.
313
+ *
314
+ * @param stepId - The ID of the step to add conditions to
315
+ * @param conditions - Conditional behavior configuration
316
+ * @returns The flow instance for method chaining
317
+ * @throws Error if the step with the specified ID is not found
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * workflow.addStepConditions('payment-step', {
322
+ * visible: when('hasPayment').equals(true).build(),
323
+ * skippable: when('balance').equals(0).build()
324
+ * });
325
+ * ```
326
+ */
327
+ addStepConditions(stepId: string, conditions: StepConditionalBehavior): this;
303
328
  /**
304
329
  * Remove a step from the workflow
305
330
  *
@@ -516,6 +541,163 @@ declare module '@rilaykit/core' {
516
541
  }
517
542
  }
518
543
 
544
+ interface ConditionEvaluationResult {
545
+ visible: boolean;
546
+ disabled: boolean;
547
+ required: boolean;
548
+ readonly: boolean;
549
+ }
550
+ /**
551
+ * Hook to evaluate conditional behaviors based on workflow data
552
+ *
553
+ * @param conditions - The conditional behavior configuration
554
+ * @param workflowData - Current workflow data to evaluate against
555
+ * @param defaultState - Default state when no conditions are provided
556
+ * @returns Evaluated condition results
557
+ */
558
+ declare function useConditionEvaluation(conditions?: ConditionalBehavior, workflowData?: Record<string, any>, defaultState?: Partial<ConditionEvaluationResult>): ConditionEvaluationResult;
559
+ /**
560
+ * Hook to evaluate multiple field conditions at once
561
+ *
562
+ * @param fieldsWithConditions - Map of field IDs to their conditional behaviors
563
+ * @param workflowData - Current workflow data to evaluate against
564
+ * @returns Map of field IDs to their evaluated conditions
565
+ */
566
+ declare function useMultipleConditionEvaluation(fieldsWithConditions: Record<string, ConditionalBehavior | undefined>, workflowData?: Record<string, any>): Record<string, ConditionEvaluationResult>;
567
+ /**
568
+ * Hook to evaluate multiple step conditions at once using numeric indices
569
+ *
570
+ * @param stepsWithConditions - Map of step indices to their conditional behaviors
571
+ * @param workflowData - Current workflow data to evaluate against
572
+ * @returns Map of step indices to their evaluated conditions
573
+ */
574
+ declare function useMultipleStepConditionEvaluation(stepsWithConditions: Record<number, ConditionalBehavior | undefined>, workflowData?: Record<string, any>): Record<number, ConditionEvaluationResult>;
575
+
576
+ /**
577
+ * @fileoverview Persistence system types for Rilay workflows
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
584
+ *
585
+ * The system is designed to be type-safe and extensible while maintaining
586
+ * a simple API for common use cases.
587
+ */
588
+
589
+ /**
590
+ * Persistent workflow data that gets saved/loaded
591
+ */
592
+ interface PersistedWorkflowData {
593
+ /** Unique identifier for the workflow */
594
+ workflowId: string;
595
+ /** Current step index in the workflow */
596
+ currentStepIndex: number;
597
+ /** All collected data across steps */
598
+ allData: Record<string, any>;
599
+ /** Currently active step data */
600
+ stepData: Record<string, any>;
601
+ /** Set of visited step IDs */
602
+ visitedSteps: string[];
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>;
620
+ }
621
+ /**
622
+ * Core persistence adapter interface
623
+ *
624
+ * All persistence implementations must implement this interface.
625
+ * It provides a consistent API regardless of the underlying storage mechanism.
626
+ */
627
+ interface WorkflowPersistenceAdapter {
628
+ /**
629
+ * Save workflow data
630
+ * @param key - Unique identifier for the stored data
631
+ * @param data - Workflow data to persist
632
+ * @returns Promise that resolves when save is complete
633
+ */
634
+ save(key: string, data: PersistedWorkflowData): Promise<void>;
635
+ /**
636
+ * Load workflow data
637
+ * @param key - Unique identifier for the stored data
638
+ * @returns Promise that resolves to persisted data or null if not found
639
+ */
640
+ load(key: string): Promise<PersistedWorkflowData | null>;
641
+ /**
642
+ * Remove persisted workflow data
643
+ * @param key - Unique identifier for the stored data
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
685
+ */
686
+ interface UsePersistenceReturn {
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
+
519
701
  interface WorkflowState {
520
702
  currentStepIndex: number;
521
703
  allData: Record<string, any>;
@@ -524,23 +706,175 @@ interface WorkflowState {
524
706
  isSubmitting: boolean;
525
707
  isTransitioning: boolean;
526
708
  }
527
- interface WorkflowContextValue {
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): {
528
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
+ };
768
+
769
+ interface UseWorkflowAnalyticsProps {
770
+ workflowConfig: WorkflowConfig;
771
+ workflowState: WorkflowState;
772
+ workflowContext: WorkflowContext;
773
+ }
774
+ interface UseWorkflowAnalyticsReturn {
775
+ analyticsStartTime: React.MutableRefObject<number>;
776
+ trackStepSkip: (stepId: string, reason: string) => void;
777
+ trackError: (error: Error) => void;
778
+ }
779
+ declare function useWorkflowAnalytics({ workflowConfig, workflowState, workflowContext, }: UseWorkflowAnalyticsProps): UseWorkflowAnalyticsReturn;
780
+
781
+ interface UseWorkflowConditionsProps {
782
+ workflowConfig: WorkflowConfig;
783
+ workflowState: WorkflowState;
784
+ currentStep: StepConfig;
785
+ }
786
+ /**
787
+ * Result of step condition evaluation - only relevant properties for workflow steps
788
+ */
789
+ interface StepConditionResult {
790
+ visible: boolean;
791
+ skippable: boolean;
792
+ }
793
+ interface UseWorkflowConditionsReturn {
794
+ stepConditions: StepConditionResult;
795
+ fieldConditions: Record<string, ConditionEvaluationResult>;
796
+ allStepConditions: Record<number, StepConditionResult>;
797
+ isStepVisible: (stepIndex: number) => boolean;
798
+ isStepSkippable: (stepIndex: number) => boolean;
799
+ isFieldVisible: (fieldId: string) => boolean;
800
+ isFieldDisabled: (fieldId: string) => boolean;
801
+ isFieldRequired: (fieldId: string) => boolean;
802
+ isFieldReadonly: (fieldId: string) => boolean;
803
+ }
804
+ /**
805
+ * Hook to manage conditional behaviors for workflow steps and fields
806
+ *
807
+ * This hook evaluates conditions for steps and form fields within a workflow,
808
+ * providing convenient methods to check step and field states based on conditions.
809
+ *
810
+ * Steps have different condition types than fields:
811
+ * - Steps: visible, skippable
812
+ * - Fields: visible, disabled, required, readonly
813
+ */
814
+ declare function useWorkflowConditions({ workflowConfig, workflowState, currentStep, }: UseWorkflowConditionsProps): UseWorkflowConditionsReturn;
815
+
816
+ interface UseWorkflowNavigationProps {
817
+ workflowConfig: WorkflowConfig;
818
+ workflowState: WorkflowState;
819
+ workflowContext: WorkflowContext;
820
+ conditionsHelpers: UseWorkflowConditionsReturn;
821
+ setCurrentStep: (stepIndex: number) => void;
822
+ setTransitioning: (isTransitioning: boolean) => void;
823
+ markStepVisited: (stepIndex: number, stepId: string) => void;
824
+ setStepData: (data: Record<string, any>, stepId: string) => void;
825
+ onStepChange?: (fromStep: number, toStep: number, context: WorkflowContext) => void;
826
+ }
827
+ interface UseWorkflowNavigationReturn {
828
+ goToStep: (stepIndex: number) => Promise<boolean>;
829
+ goNext: () => Promise<boolean>;
830
+ goPrevious: () => Promise<boolean>;
831
+ skipStep: () => Promise<boolean>;
832
+ canGoToStep: (stepIndex: number) => boolean;
833
+ canGoNext: () => boolean;
834
+ canGoPrevious: () => boolean;
835
+ canSkipCurrentStep: () => boolean;
836
+ }
837
+ declare function useWorkflowNavigation({ workflowConfig, workflowState, workflowContext, conditionsHelpers, setCurrentStep, setTransitioning, markStepVisited, setStepData, onStepChange, }: UseWorkflowNavigationProps): UseWorkflowNavigationReturn;
838
+
839
+ interface UseWorkflowSubmissionProps {
840
+ workflowConfig: WorkflowConfig;
841
+ workflowState: WorkflowState;
842
+ workflowContext: WorkflowContext;
843
+ setSubmitting: (isSubmitting: boolean) => void;
844
+ onWorkflowComplete?: (data: Record<string, any>) => void | Promise<void>;
845
+ analyticsStartTime: React.MutableRefObject<number>;
846
+ }
847
+ interface UseWorkflowSubmissionReturn {
848
+ submitWorkflow: () => Promise<void>;
849
+ isSubmitting: boolean;
850
+ canSubmit: boolean;
851
+ }
852
+ declare function useWorkflowSubmission({ workflowConfig, workflowState, workflowContext, setSubmitting, onWorkflowComplete, analyticsStartTime, }: UseWorkflowSubmissionProps): UseWorkflowSubmissionReturn;
853
+
854
+ interface WorkflowContextValue {
855
+ workflowState: ReturnType<typeof useWorkflowState>['workflowState'];
529
856
  workflowConfig: WorkflowConfig;
530
857
  currentStep: StepConfig;
531
858
  context: WorkflowContext;
532
859
  formConfig?: FormConfiguration;
860
+ conditionsHelpers: UseWorkflowConditionsReturn;
533
861
  goToStep: (stepIndex: number) => Promise<boolean>;
534
862
  goNext: () => Promise<boolean>;
535
863
  goPrevious: () => Promise<boolean>;
536
864
  skipStep: () => Promise<boolean>;
865
+ canGoToStep: (stepIndex: number) => boolean;
866
+ canGoNext: () => boolean;
867
+ canGoPrevious: () => boolean;
868
+ canSkipCurrentStep: () => boolean;
537
869
  setValue: (fieldId: string, value: any) => void;
538
870
  setStepData: (data: Record<string, any>) => void;
539
- submitWorkflow: () => Promise<void>;
540
871
  resetWorkflow: () => void;
872
+ submitWorkflow: () => Promise<void>;
873
+ isSubmitting: boolean;
874
+ canSubmit: boolean;
541
875
  }
542
876
  interface WorkflowProviderProps {
543
- children: React.ReactNode;
877
+ children: React$1.ReactNode;
544
878
  workflowConfig: WorkflowConfig;
545
879
  defaultValues?: Record<string, any>;
546
880
  onStepChange?: (fromStep: number, toStep: number, context: WorkflowContext) => void;
@@ -551,7 +885,7 @@ declare function WorkflowProvider({ children, workflowConfig, defaultValues, onS
551
885
  declare function useWorkflowContext(): WorkflowContextValue;
552
886
 
553
887
  type WorkflowProps = Omit<WorkflowProviderProps, 'children' | 'workflowConfig'> & {
554
- children: React.ReactNode;
888
+ children: React$1.ReactNode;
555
889
  workflowConfig: WorkflowConfig | flow;
556
890
  };
557
891
  /**
@@ -579,6 +913,169 @@ interface WorkflowStepperProps extends ComponentRendererBaseProps<WorkflowSteppe
579
913
  }
580
914
  declare function WorkflowStepper({ onStepClick, className, ...props }: WorkflowStepperProps): react_jsx_runtime.JSX.Element;
581
915
 
916
+ /**
917
+ * @fileoverview LocalStorage persistence adapter for Rilay workflows
918
+ *
919
+ * This adapter provides browser localStorage-based persistence for workflow data.
920
+ * It includes features like data compression, expiration handling, and error recovery.
921
+ *
922
+ * Key features:
923
+ * - Automatic data expiration based on maxAge
924
+ * - Optional data compression for large workflows
925
+ * - Graceful handling of localStorage quota exceeded
926
+ * - Type-safe serialization/deserialization
927
+ */
928
+
929
+ /**
930
+ * LocalStorage-based persistence adapter
931
+ *
932
+ * Provides a robust localStorage implementation with features like:
933
+ * - Automatic cleanup of expired data
934
+ * - Configurable key prefixes for namespace isolation
935
+ * - Error handling for quota exceeded scenarios
936
+ * - Optional data compression
937
+ *
938
+ * @example
939
+ * ```typescript
940
+ * const adapter = new LocalStorageAdapter({
941
+ * keyPrefix: 'myapp_workflow_',
942
+ * maxAge: 24 * 60 * 60 * 1000, // 24 hours
943
+ * compress: true
944
+ * });
945
+ * ```
946
+ */
947
+ declare class LocalStorageAdapter implements WorkflowPersistenceAdapter {
948
+ private readonly keyPrefix;
949
+ private readonly compress;
950
+ private readonly maxAge?;
951
+ private readonly version;
952
+ constructor(config?: LocalStorageAdapterConfig);
953
+ /**
954
+ * Save workflow data to localStorage
955
+ */
956
+ save(key: string, data: PersistedWorkflowData): Promise<void>;
957
+ /**
958
+ * Load workflow data from localStorage
959
+ */
960
+ load(key: string): Promise<PersistedWorkflowData | null>;
961
+ /**
962
+ * Remove workflow data from localStorage
963
+ */
964
+ remove(key: string): Promise<void>;
965
+ /**
966
+ * Check if data exists for the given key
967
+ */
968
+ exists(key: string): Promise<boolean>;
969
+ /**
970
+ * List all available keys
971
+ */
972
+ listKeys(): Promise<string[]>;
973
+ /**
974
+ * Clear all workflow data
975
+ */
976
+ clear(): Promise<void>;
977
+ /**
978
+ * Get the full storage key with prefix
979
+ */
980
+ private getStorageKey;
981
+ /**
982
+ * Check if localStorage is available
983
+ */
984
+ private isLocalStorageAvailable;
985
+ /**
986
+ * Simple data compression using basic string compression
987
+ * Note: In production, you might want to use a proper compression library
988
+ */
989
+ private compressData;
990
+ /**
991
+ * Decompress data
992
+ */
993
+ private decompressData;
994
+ /**
995
+ * Clear expired data entries
996
+ */
997
+ private clearExpiredData;
998
+ }
999
+
1000
+ /**
1001
+ * @fileoverview Persistence utilities for Rilay workflows
1002
+ *
1003
+ * This module provides utility functions for working with workflow persistence,
1004
+ * including data transformation, validation, and helper functions for
1005
+ * converting between different data formats.
1006
+ */
1007
+
1008
+ /**
1009
+ * Convert WorkflowState to PersistedWorkflowData format
1010
+ */
1011
+ declare function workflowStateToPersisted(workflowId: string, state: WorkflowState, metadata?: Record<string, any>): PersistedWorkflowData;
1012
+ /**
1013
+ * Convert PersistedWorkflowData to WorkflowState format
1014
+ */
1015
+ declare function persistedToWorkflowState(data: PersistedWorkflowData): Partial<WorkflowState>;
1016
+ /**
1017
+ * Validate persisted workflow data structure
1018
+ */
1019
+ declare function validatePersistedData(data: any): data is PersistedWorkflowData;
1020
+ /**
1021
+ * Generate a storage key for a workflow
1022
+ */
1023
+ declare function generateStorageKey(workflowId: string, userId?: string): string;
1024
+ /**
1025
+ * Debounce function for auto-persistence
1026
+ */
1027
+ declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
1028
+ /**
1029
+ * Merge persisted data with current state, handling conflicts
1030
+ */
1031
+ declare function mergePersistedState(currentState: WorkflowState, persistedData: PersistedWorkflowData, strategy?: 'persist' | 'current' | 'merge'): Partial<WorkflowState>;
1032
+
1033
+ /**
1034
+ * @fileoverview Persistence hook for Rilay workflows
1035
+ *
1036
+ * This hook provides workflow persistence functionality with automatic
1037
+ * debounced saving, error handling, and flexible adapter support.
1038
+ * It integrates seamlessly with the existing workflow state management.
1039
+ */
1040
+
1041
+ interface UsePersistenceProps {
1042
+ /** Unique workflow identifier */
1043
+ workflowId: string;
1044
+ /** Current workflow state */
1045
+ workflowState: WorkflowState;
1046
+ /** Persistence adapter to use */
1047
+ adapter: WorkflowPersistenceAdapter;
1048
+ /** Persistence options */
1049
+ options?: PersistenceOptions;
1050
+ /** Optional user ID for multi-user scenarios */
1051
+ userId?: string;
1052
+ }
1053
+ /**
1054
+ * Hook for managing workflow persistence
1055
+ *
1056
+ * Provides automatic persistence with debouncing, manual save/load operations,
1057
+ * and comprehensive error handling. Integrates with any persistence adapter
1058
+ * that implements the WorkflowPersistenceAdapter interface.
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * const persistence = usePersistence({
1063
+ * workflowId: 'user-onboarding',
1064
+ * workflowState,
1065
+ * adapter: new LocalStorageAdapter(),
1066
+ * options: {
1067
+ * autoPersist: true,
1068
+ * debounceMs: 1000
1069
+ * }
1070
+ * });
1071
+ *
1072
+ * if (persistence.persistenceError) {
1073
+ * console.error('Persistence error:', persistence.persistenceError);
1074
+ * }
1075
+ * ```
1076
+ */
1077
+ declare function usePersistence({ workflowId, workflowState, adapter, options, userId, }: UsePersistenceProps): UsePersistenceReturn;
1078
+
582
1079
  interface LicensePayload {
583
1080
  plan: 'ARCHITECT' | 'FOUNDRY';
584
1081
  company: string;
@@ -647,4 +1144,4 @@ declare class RilayLicenseManager {
647
1144
  }>;
648
1145
  }
649
1146
 
650
- export { type LicensePayload, type LicensePlan, type LicenseResult, RilayLicenseManager, type StepDefinition, Workflow, WorkflowBody, type WorkflowContextValue, WorkflowNextButton, WorkflowPreviousButton, WorkflowProvider, WorkflowSkipButton, WorkflowStepper, createFlow, flow, useWorkflowContext };
1147
+ export { type ConditionEvaluationResult, type LicensePayload, type LicensePlan, type LicenseResult, LocalStorageAdapter, type LocalStorageAdapterConfig, type PersistedWorkflowData, type PersistenceOptions, RilayLicenseManager, type StepConditionResult, type StepDefinition, type UsePersistenceProps, type UsePersistenceReturn, type UseWorkflowAnalyticsProps, type UseWorkflowAnalyticsReturn, type UseWorkflowConditionsProps, type UseWorkflowConditionsReturn, type UseWorkflowNavigationProps, type UseWorkflowNavigationReturn, type UseWorkflowStateProps, type UseWorkflowSubmissionProps, type UseWorkflowSubmissionReturn, Workflow, type WorkflowAction, WorkflowBody, type WorkflowContextValue, WorkflowNextButton, type WorkflowPersistenceAdapter, WorkflowPersistenceError, WorkflowPreviousButton, WorkflowProvider, WorkflowSkipButton, type WorkflowState, WorkflowStepper, createFlow, debounce, flow, generateStorageKey, mergePersistedState, persistedToWorkflowState, useConditionEvaluation, useMultipleConditionEvaluation, useMultipleStepConditionEvaluation, usePersistence, useWorkflowAnalytics, useWorkflowConditions, useWorkflowContext, useWorkflowNavigation, useWorkflowState, useWorkflowSubmission, validatePersistedData, workflowStateToPersisted };