@rilaykit/workflow 1.2.0 → 2.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.mts CHANGED
@@ -1,17 +1,127 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import react__default from 'react';
4
- import { WorkflowConfig, WorkflowContext, ValidationError, StepConfig, FormConfiguration, ValidationResult, ril, StepLifecycleHooks, StepPermissions, CustomStepRenderer, DynamicStepConfig, ConditionalBranch, NavigationConfig, PersistenceConfig, WorkflowAnalytics, WorkflowOptimizations, WorkflowVersion, CompletionConfig, WorkflowPlugin } from '@rilaykit/core';
1
+ import { ril, FormConfiguration, StepLifecycleHooks, StepPermissions, CustomStepRenderer, DynamicStepConfig, NavigationConfig, PersistenceConfig, WorkflowAnalytics, CompletionConfig, WorkflowPlugin, StepConfig, WorkflowConfig, WorkflowContext, ValidationError, ValidationResult, RendererChildrenFunction, WorkflowNextButtonRendererProps, WorkflowPreviousButtonRendererProps, WorkflowSkipButtonRendererProps, WorkflowStepperRendererProps } from '@rilaykit/core';
5
2
  export * from '@rilaykit/core';
6
3
  export { createZodValidator, ril } from '@rilaykit/core';
4
+ import { form } from '@rilaykit/forms';
7
5
  export { form } from '@rilaykit/forms';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
+ import * as react from 'react';
8
+ import react__default from 'react';
9
+
10
+ interface StepDefinition {
11
+ id: string;
12
+ title: string;
13
+ description?: string;
14
+ formConfig: FormConfiguration | form;
15
+ allowSkip?: boolean;
16
+ requiredToComplete?: boolean;
17
+ hooks?: StepLifecycleHooks;
18
+ permissions?: StepPermissions;
19
+ renderer?: CustomStepRenderer;
20
+ dynamicConfig?: DynamicStepConfig;
21
+ }
22
+ /**
23
+ * Workflow builder class for creating complex multi-step workflows
24
+ * Simplified API with auto-build capability
25
+ */
26
+ declare class flow {
27
+ private config;
28
+ private workflowId;
29
+ private workflowName;
30
+ private workflowDescription?;
31
+ private steps;
32
+ private navigation;
33
+ private persistence?;
34
+ private completion?;
35
+ private analytics?;
36
+ private plugins;
37
+ constructor(config: ril, workflowId: string, workflowName: string, description?: string);
38
+ static create(config: ril, workflowId: string, workflowName: string, description?: string): flow;
39
+ /**
40
+ * Helper method to create a step configuration from StepDefinition
41
+ */
42
+ private createStepFromDefinition;
43
+ /**
44
+ * Add a step using simplified StepDefinition object
45
+ */
46
+ addStep(stepDefinition: StepDefinition): this;
47
+ /**
48
+ * Add a dynamic step using StepDefinition with dynamicConfig
49
+ */
50
+ addDynamicStep(stepDefinition: StepDefinition & {
51
+ dynamicConfig: DynamicStepConfig;
52
+ }): this;
53
+ /**
54
+ * Add multiple steps at once
55
+ */
56
+ addSteps(stepDefinitions: StepDefinition[]): this;
57
+ /**
58
+ * Configuration setters with fluent interface
59
+ */
60
+ setNavigation(navigation: NavigationConfig): this;
61
+ enableBackNavigation(enabled?: boolean): this;
62
+ enableStepSkipping(enabled?: boolean): this;
63
+ setPersistence(persistence: PersistenceConfig): this;
64
+ setAnalytics(analytics: WorkflowAnalytics): this;
65
+ setCompletion(completion: CompletionConfig): this;
66
+ /**
67
+ * Plugin management
68
+ */
69
+ use(plugin: WorkflowPlugin): this;
70
+ private validatePluginDependencies;
71
+ removePlugin(pluginName: string): this;
72
+ /**
73
+ * Step management
74
+ */
75
+ updateStep(stepId: string, updates: Partial<Omit<StepConfig, 'id'>>): this;
76
+ removeStep(stepId: string): this;
77
+ getStep(stepId: string): StepConfig | undefined;
78
+ getSteps(): StepConfig[];
79
+ clearSteps(): this;
80
+ /**
81
+ * Clone the workflow builder
82
+ */
83
+ clone(newWorkflowId?: string, newWorkflowName?: string): flow;
84
+ /**
85
+ * Validate the workflow configuration
86
+ */
87
+ validate(): string[];
88
+ /**
89
+ * Get workflow statistics
90
+ */
91
+ getStats(): {
92
+ totalSteps: number;
93
+ dynamicSteps: number;
94
+ pluginsInstalled: number;
95
+ estimatedFields: number;
96
+ hasPersistence: boolean;
97
+ hasAnalytics: boolean;
98
+ allowBackNavigation: boolean;
99
+ };
100
+ /**
101
+ * Build the final workflow configuration
102
+ */
103
+ build(): WorkflowConfig;
104
+ /**
105
+ * Export/Import functionality
106
+ */
107
+ toJSON(): any;
108
+ fromJSON(json: any): this;
109
+ }
110
+ /**
111
+ * Factory function to create a workflow builder directly
112
+ */
113
+ declare function createFlow(config: ril, workflowId: string, workflowName: string, description?: string): flow;
114
+ declare module '@rilaykit/core' {
115
+ interface ril {
116
+ createFlow(workflowId: string, workflowName: string, description?: string): flow;
117
+ }
118
+ }
8
119
 
9
120
  interface WorkflowState {
10
121
  currentStepIndex: number;
11
122
  allData: Record<string, any>;
12
123
  stepData: Record<string, any>;
13
124
  errors: Record<string, ValidationError[]>;
14
- warnings: Record<string, ValidationError[]>;
15
125
  touched: Set<string>;
16
126
  isValidating: Set<string>;
17
127
  visitedSteps: Set<string>;
@@ -48,16 +158,20 @@ interface WorkflowProviderProps {
48
158
  className?: string;
49
159
  user?: any;
50
160
  }
161
+ declare function WorkflowProvider({ children, workflowConfig, defaultValues, onStepChange, onWorkflowComplete, className, user, }: WorkflowProviderProps): react_jsx_runtime.JSX.Element;
162
+ declare function useWorkflowContext(): WorkflowContextValue;
51
163
 
52
- type WorkflowProps = Omit<WorkflowProviderProps, 'children'> & {
164
+ type WorkflowProps = Omit<WorkflowProviderProps, 'children' | 'workflowConfig'> & {
53
165
  children: react__default.ReactNode;
166
+ workflowConfig: WorkflowConfig | flow;
54
167
  };
55
168
  /**
56
169
  * A wrapper component for the Rilay workflow system.
57
170
  * It simplifies the API by wrapping the WorkflowProvider and providing a clean,
58
171
  * component-based interface for building workflows.
172
+ * Accepts both WorkflowConfig and flow builder instances.
59
173
  */
60
- declare function Workflow({ children, ...props }: WorkflowProps): react_jsx_runtime.JSX.Element;
174
+ declare function Workflow({ children, workflowConfig, ...props }: WorkflowProps): react_jsx_runtime.JSX.Element;
61
175
 
62
176
  /**
63
177
  * Renders the main content of the current workflow step.
@@ -65,232 +179,101 @@ declare function Workflow({ children, ...props }: WorkflowProps): react_jsx_runt
65
179
  */
66
180
  declare function WorkflowBody(): react_jsx_runtime.JSX.Element | null;
67
181
 
68
- interface WorkflowNavigationProps {
69
- className?: string;
70
- }
71
- declare function WorkflowNavigation({ className }: WorkflowNavigationProps): react_jsx_runtime.JSX.Element;
72
-
73
182
  interface WorkflowNextButtonProps {
74
183
  className?: string;
75
- children?: React.ReactNode;
184
+ children?: React.ReactNode | RendererChildrenFunction<WorkflowNextButtonRendererProps>;
185
+ renderAs?: 'default' | 'children' | boolean;
76
186
  }
77
- declare function WorkflowNextButton({ className, children }: WorkflowNextButtonProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
187
+ declare function WorkflowNextButton({ className, children, renderAs }: WorkflowNextButtonProps): react.ReactNode;
78
188
 
79
189
  interface WorkflowPreviousButtonProps {
80
190
  className?: string;
81
- children?: React.ReactNode;
191
+ children?: React.ReactNode | RendererChildrenFunction<WorkflowPreviousButtonRendererProps>;
192
+ renderAs?: 'default' | 'children' | boolean;
82
193
  }
83
- declare function WorkflowPreviousButton({ className, children }: WorkflowPreviousButtonProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
194
+ declare function WorkflowPreviousButton({ className, children, renderAs, }: WorkflowPreviousButtonProps): react.ReactNode;
84
195
 
85
196
  interface WorkflowSkipButtonProps {
86
197
  className?: string;
87
- children?: React.ReactNode;
198
+ children?: React.ReactNode | RendererChildrenFunction<WorkflowSkipButtonRendererProps>;
199
+ renderAs?: 'default' | 'children' | boolean;
88
200
  }
89
- declare function WorkflowSkipButton({ className, children }: WorkflowSkipButtonProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
201
+ declare function WorkflowSkipButton({ className, children, renderAs }: WorkflowSkipButtonProps): react.ReactNode;
90
202
 
91
203
  interface WorkflowStepperProps {
92
204
  onStepClick?: (stepIndex: number) => void;
93
205
  className?: string;
206
+ children?: React.ReactNode | RendererChildrenFunction<WorkflowStepperRendererProps>;
207
+ renderAs?: 'default' | 'children' | boolean;
94
208
  }
95
- declare function WorkflowStepper({ onStepClick, className }: WorkflowStepperProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
209
+ declare function WorkflowStepper({ onStepClick, className, children, renderAs, }: WorkflowStepperProps): react.ReactNode;
210
+
211
+ interface LicensePayload {
212
+ plan: 'ARCHITECT' | 'FOUNDRY';
213
+ company: string;
214
+ customerId: string;
215
+ expiry: number;
216
+ iat: number;
217
+ }
218
+ interface LicenseResult {
219
+ valid: boolean;
220
+ data?: LicensePayload;
221
+ error?: 'EXPIRED' | 'INVALID' | 'MISSING' | 'FORMAT_INVALID' | 'SIGNATURE_INVALID';
222
+ }
223
+ type LicensePlan = 'ARCHITECT' | 'FOUNDRY';
96
224
 
97
225
  /**
98
- * Workflow builder class for creating complex multi-step workflows
99
- * Supports async hooks, dynamic steps, conditional branches, and much more
226
+ * Enhanced Rilay License Manager with Ed25519 cryptographic validation
227
+ * Uses @noble/ed25519 for secure and fast signature verification
100
228
  */
101
- declare class flow {
102
- private config;
103
- private workflowId;
104
- private workflowName;
105
- private workflowDescription?;
106
- private steps;
107
- private branches;
108
- private navigation;
109
- private persistence?;
110
- private completion?;
111
- private analytics?;
112
- private optimizations?;
113
- private version?;
114
- private plugins;
115
- constructor(config: ril, workflowId: string, workflowName: string, description?: string);
116
- static create(config: ril, workflowId: string, workflowName: string, description?: string): flow;
117
- /**
118
- * Add a standard step to the workflow
119
- * @param stepId - Unique step identifier
120
- * @param title - Step title
121
- * @param formConfig - Complete form configuration for this step
122
- * @param options - Additional step options
123
- * @returns flow instance for chaining
124
- */
125
- addStep(stepId: string, title: string, formConfig: FormConfiguration, options?: {
126
- description?: string;
127
- allowSkip?: boolean;
128
- requiredToComplete?: boolean;
129
- hooks?: StepLifecycleHooks;
130
- permissions?: StepPermissions;
131
- renderer?: CustomStepRenderer;
132
- }): this;
133
- /**
134
- * Add a dynamic step that resolves form config based on previous data
135
- * @param stepId - Unique step identifier
136
- * @param title - Step title
137
- * @param dynamicConfig - Configuration for dynamic step resolution
138
- * @param fallbackFormConfig - Fallback form configuration if dynamic resolution fails
139
- * @param options - Additional step options
140
- * @returns flow instance for chaining
141
- */
142
- addDynamicStep(stepId: string, title: string, dynamicConfig: DynamicStepConfig, fallbackFormConfig: FormConfiguration, options?: {
143
- description?: string;
144
- allowSkip?: boolean;
145
- requiredToComplete?: boolean;
146
- hooks?: StepLifecycleHooks;
147
- permissions?: StepPermissions;
148
- }): this;
149
- /**
150
- * Add multiple steps at once
151
- * @param stepConfigs - Array of step configurations
152
- * @returns flow instance for chaining
153
- */
154
- addSteps(stepConfigs: Array<{
155
- stepId: string;
156
- title: string;
157
- formConfig: FormConfiguration;
158
- description?: string;
159
- allowSkip?: boolean;
160
- requiredToComplete?: boolean;
161
- hooks?: StepLifecycleHooks;
162
- permissions?: StepPermissions;
163
- }>): this;
164
- /**
165
- * Add a conditional branch to the workflow
166
- * @param branch - Conditional branch configuration
167
- * @returns flow instance for chaining
168
- */
169
- addConditionalBranch(branch: ConditionalBranch): this;
170
- /**
171
- * Add multiple conditional branches
172
- * @param branches - Array of conditional branches
173
- * @returns flow instance for chaining
174
- */
175
- addConditionalBranches(branches: ConditionalBranch[]): this;
176
- /**
177
- * Set navigation configuration
178
- * @param navigation - Navigation configuration
179
- * @returns flow instance for chaining
180
- */
181
- setNavigation(navigation: NavigationConfig): this;
182
- /**
183
- * Set persistence strategy
184
- * @param persistence - Persistence configuration
185
- * @returns flow instance for chaining
186
- */
187
- setPersistence(persistence: PersistenceConfig): this;
188
- /**
189
- * Set analytics configuration
190
- * @param analytics - Analytics configuration
191
- * @returns flow instance for chaining
192
- */
193
- setAnalytics(analytics: WorkflowAnalytics): this;
194
- /**
195
- * Set performance optimizations
196
- * @param optimizations - Optimization configuration
197
- * @returns flow instance for chaining
198
- */
199
- setOptimizations(optimizations: WorkflowOptimizations): this;
200
- /**
201
- * Set workflow version
202
- * @param version - Version configuration
203
- * @returns flow instance for chaining
204
- */
205
- setVersion(version: WorkflowVersion): this;
206
- /**
207
- * Set completion configuration
208
- * @param completion - Completion configuration
209
- * @returns flow instance for chaining
210
- */
211
- setCompletion(completion: CompletionConfig): this;
212
- /**
213
- * Add a plugin to the workflow
214
- * @param plugin - Plugin to add
215
- * @returns flow instance for chaining
216
- */
217
- use(plugin: WorkflowPlugin): this;
218
- /**
219
- * Remove a plugin from the workflow
220
- * @param pluginName - Name of the plugin to remove
221
- * @returns flow instance for chaining
222
- */
223
- removePlugin(pluginName: string): this;
224
- /**
225
- * Update step configuration
226
- * @param stepId - Step identifier
227
- * @param updates - Updates to apply
228
- * @returns flow instance for chaining
229
- */
230
- updateStep(stepId: string, updates: Partial<Omit<StepConfig, 'id'>>): this;
229
+ declare class RilayLicenseManager {
230
+ private static licenseKey;
231
+ private static licenseResult;
232
+ private static isInitialized;
231
233
  /**
232
- * Remove a step from the workflow
233
- * @param stepId - Step identifier
234
- * @returns flow instance for chaining
234
+ * Initialize with a license key and Ed25519 public key
235
235
  */
236
- removeStep(stepId: string): this;
236
+ static setLicenseKey(licenseKey?: string): Promise<void>;
237
237
  /**
238
- * Get step configuration by ID
239
- * @param stepId - Step identifier
240
- * @returns Step configuration or undefined
238
+ * Validate license using Ed25519 signature verification
241
239
  */
242
- getStep(stepId: string): StepConfig | undefined;
240
+ private static validateLicense;
243
241
  /**
244
- * Get all steps
245
- * @returns Array of step configurations
242
+ * Convert compressed payload to full payload
246
243
  */
247
- getSteps(): StepConfig[];
244
+ private static decompressPayload;
248
245
  /**
249
- * Clear all steps
250
- * @returns flow instance for chaining
246
+ * Convert hex string to Uint8Array
251
247
  */
252
- clearSteps(): this;
248
+ private static hexToBytes;
253
249
  /**
254
- * Clone the workflow builder
255
- * @param newWorkflowId - ID for the cloned workflow
256
- * @param newWorkflowName - Name for the cloned workflow
257
- * @returns New flow instance
250
+ * Convert base64 string to text (browser-compatible)
258
251
  */
259
- clone(newWorkflowId?: string, newWorkflowName?: string): flow;
252
+ private static base64ToString;
260
253
  /**
261
- * Validate the workflow configuration
262
- * @returns Array of validation errors
254
+ * Get license validation result
263
255
  */
264
- validate(): string[];
256
+ static getLicenseResult(): LicenseResult;
265
257
  /**
266
- * Get workflow statistics
267
- * @returns Object with workflow statistics
258
+ * Check if watermark should be displayed
268
259
  */
269
- getStats(): {
270
- totalSteps: number;
271
- dynamicSteps: number;
272
- conditionalBranches: number;
273
- pluginsInstalled: number;
274
- estimatedFields: number;
275
- hasPersistence: boolean;
276
- hasAnalytics: boolean;
277
- };
260
+ static shouldDisplayWatermark(): boolean;
278
261
  /**
279
- * Build the final workflow configuration
280
- * @returns Complete workflow configuration
262
+ * Get watermark message
281
263
  */
282
- build(): WorkflowConfig;
264
+ static getWatermarkMessage(): string;
283
265
  /**
284
- * Export workflow configuration as JSON
285
- * @returns JSON representation of the workflow
266
+ * Display license status in console
286
267
  */
287
- toJSON(): any;
268
+ static logLicenseStatus(): void;
288
269
  /**
289
- * Import workflow configuration from JSON
290
- * @param json - JSON representation of the workflow
291
- * @returns flow instance for chaining
270
+ * Get license info
292
271
  */
293
- fromJSON(json: any): this;
272
+ static getLicenseInfo(): Promise<{
273
+ plan?: string;
274
+ company?: string;
275
+ expiryDate?: string;
276
+ }>;
294
277
  }
295
278
 
296
279
  interface AnalyticsPluginConfig {
@@ -382,71 +365,4 @@ declare class ValidationPlugin implements WorkflowPlugin {
382
365
  private validateAsync;
383
366
  }
384
367
 
385
- interface LicensePayload {
386
- plan: 'ARCHITECT' | 'FOUNDRY';
387
- company: string;
388
- customerId: string;
389
- expiry: number;
390
- iat: number;
391
- }
392
- interface LicenseResult {
393
- valid: boolean;
394
- data?: LicensePayload;
395
- error?: 'EXPIRED' | 'INVALID' | 'MISSING' | 'FORMAT_INVALID' | 'SIGNATURE_INVALID';
396
- }
397
-
398
- /**
399
- * Enhanced Rilay License Manager with Ed25519 cryptographic validation
400
- * Uses @noble/ed25519 for secure and fast signature verification
401
- */
402
- declare class RilayLicenseManager {
403
- private static licenseKey;
404
- private static licenseResult;
405
- private static isInitialized;
406
- /**
407
- * Initialize with a license key and Ed25519 public key
408
- */
409
- static setLicenseKey(licenseKey?: string): Promise<void>;
410
- /**
411
- * Validate license using Ed25519 signature verification
412
- */
413
- private static validateLicense;
414
- /**
415
- * Convert compressed payload to full payload
416
- */
417
- private static decompressPayload;
418
- /**
419
- * Convert hex string to Uint8Array
420
- */
421
- private static hexToBytes;
422
- /**
423
- * Convert base64 string to text (browser-compatible)
424
- */
425
- private static base64ToString;
426
- /**
427
- * Get license validation result
428
- */
429
- static getLicenseResult(): LicenseResult;
430
- /**
431
- * Check if watermark should be displayed
432
- */
433
- static shouldDisplayWatermark(): boolean;
434
- /**
435
- * Get watermark message
436
- */
437
- static getWatermarkMessage(): string;
438
- /**
439
- * Display license status in console
440
- */
441
- static logLicenseStatus(): void;
442
- /**
443
- * Get license info
444
- */
445
- static getLicenseInfo(): Promise<{
446
- plan?: string;
447
- company?: string;
448
- expiryDate?: string;
449
- }>;
450
- }
451
-
452
- export { AnalyticsPlugin, RilayLicenseManager, ValidationPlugin, Workflow, WorkflowBody, flow as WorkflowBuilder, type WorkflowContextValue, WorkflowNavigation, type WorkflowNavigationProps, WorkflowNextButton, type WorkflowNextButtonProps, WorkflowPreviousButton, type WorkflowPreviousButtonProps, type WorkflowProviderProps, WorkflowSkipButton, type WorkflowSkipButtonProps, WorkflowStepper, type WorkflowStepperProps, flow };
368
+ export { AnalyticsPlugin, type LicensePayload, type LicensePlan, type LicenseResult, RilayLicenseManager, type StepDefinition, ValidationPlugin, Workflow, WorkflowBody, type WorkflowContextValue, WorkflowNextButton, type WorkflowNextButtonProps, WorkflowPreviousButton, type WorkflowPreviousButtonProps, WorkflowProvider, type WorkflowProviderProps, WorkflowSkipButton, type WorkflowSkipButtonProps, WorkflowStepper, type WorkflowStepperProps, createFlow, flow, useWorkflowContext };