@rilaykit/workflow 3.0.0 → 4.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 +449 -110
- package/dist/index.d.ts +449 -110
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ril, FormConfiguration, StepLifecycleHooks, StepPermissions, CustomStepRenderer, DynamicStepConfig, NavigationConfig, PersistenceConfig,
|
|
1
|
+
import { ril, FormConfiguration, StepLifecycleHooks, StepPermissions, CustomStepRenderer, DynamicStepConfig, NavigationConfig, PersistenceConfig, CompletionConfig, WorkflowAnalytics, WorkflowPlugin, StepConfig, WorkflowConfig, WorkflowContext, ValidationError, ValidationResult, RendererChildrenFunction, WorkflowNextButtonRendererProps, WorkflowPreviousButtonRendererProps, WorkflowSkipButtonRendererProps, WorkflowStepperRendererProps } from '@rilaykit/core';
|
|
2
2
|
export * from '@rilaykit/core';
|
|
3
3
|
export { createZodValidator, ril } from '@rilaykit/core';
|
|
4
4
|
import { form } from '@rilaykit/forms';
|
|
@@ -7,21 +7,120 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default from 'react';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced step configuration interface for better type safety and simplicity
|
|
12
|
+
*
|
|
13
|
+
* This interface defines the structure for creating workflow steps with all
|
|
14
|
+
* necessary configuration options. It provides a clean API for step definition
|
|
15
|
+
* while maintaining flexibility for complex workflows.
|
|
16
|
+
*
|
|
17
|
+
* @interface StepDefinition
|
|
18
|
+
*/
|
|
10
19
|
interface StepDefinition {
|
|
11
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Unique identifier for the step
|
|
22
|
+
* If not provided, will be auto-generated using the internal ID generator
|
|
23
|
+
*/
|
|
24
|
+
id?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Display title for the step
|
|
27
|
+
* This will be shown to users in the workflow interface
|
|
28
|
+
*/
|
|
12
29
|
title: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional description providing additional context about the step
|
|
32
|
+
* Useful for complex workflows where steps need explanation
|
|
33
|
+
*/
|
|
13
34
|
description?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Form configuration for the step
|
|
37
|
+
* Can be either a built FormConfiguration or a form builder instance
|
|
38
|
+
*/
|
|
14
39
|
formConfig: FormConfiguration | form;
|
|
40
|
+
/**
|
|
41
|
+
* Whether users can skip this step
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
15
44
|
allowSkip?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether this step is required to complete the workflow
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
16
49
|
requiredToComplete?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Lifecycle hooks for step events
|
|
52
|
+
* Allows custom logic at different points in the step lifecycle
|
|
53
|
+
*/
|
|
17
54
|
hooks?: StepLifecycleHooks;
|
|
55
|
+
/**
|
|
56
|
+
* Permission configuration for step access control
|
|
57
|
+
* Defines who can view, edit, or complete this step
|
|
58
|
+
*/
|
|
18
59
|
permissions?: StepPermissions;
|
|
60
|
+
/**
|
|
61
|
+
* Custom renderer for the step
|
|
62
|
+
* Allows complete customization of step presentation
|
|
63
|
+
*/
|
|
19
64
|
renderer?: CustomStepRenderer;
|
|
65
|
+
/**
|
|
66
|
+
* Dynamic step configuration
|
|
67
|
+
* Enables conditional step behavior based on previous step data
|
|
68
|
+
*/
|
|
20
69
|
dynamicConfig?: DynamicStepConfig;
|
|
21
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration options for workflow behavior and features
|
|
73
|
+
*
|
|
74
|
+
* This interface consolidates all workflow-level configuration options
|
|
75
|
+
* into a single, easy-to-use structure for the configure() method.
|
|
76
|
+
*
|
|
77
|
+
* @interface WorkflowOptions
|
|
78
|
+
*/
|
|
79
|
+
interface WorkflowOptions {
|
|
80
|
+
/** Navigation behavior configuration */
|
|
81
|
+
navigation?: NavigationConfig;
|
|
82
|
+
/** Data persistence settings */
|
|
83
|
+
persistence?: PersistenceConfig;
|
|
84
|
+
/** Workflow completion handling */
|
|
85
|
+
completion?: CompletionConfig;
|
|
86
|
+
/** Analytics and tracking configuration */
|
|
87
|
+
analytics?: WorkflowAnalytics;
|
|
88
|
+
}
|
|
22
89
|
/**
|
|
23
90
|
* Workflow builder class for creating complex multi-step workflows
|
|
24
|
-
*
|
|
91
|
+
*
|
|
92
|
+
* The flow class provides a comprehensive API for building multi-step workflows
|
|
93
|
+
* with form-based steps. It follows the builder pattern with method chaining
|
|
94
|
+
* and includes advanced features like dynamic steps, plugins, and analytics.
|
|
95
|
+
*
|
|
96
|
+
* Key Features:
|
|
97
|
+
* - Polymorphic step addition (single or multiple steps)
|
|
98
|
+
* - Plugin system for extensibility
|
|
99
|
+
* - Built-in validation and error handling
|
|
100
|
+
* - Clone and export/import functionality
|
|
101
|
+
* - Comprehensive statistics and analytics
|
|
102
|
+
* - Type-safe configuration management
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const workflow = flow.create(rilConfig, 'user-onboarding', 'User Onboarding')
|
|
107
|
+
* .addStep({
|
|
108
|
+
* title: 'Personal Information',
|
|
109
|
+
* formConfig: personalInfoForm
|
|
110
|
+
* })
|
|
111
|
+
* .addStep({
|
|
112
|
+
* title: 'Account Setup',
|
|
113
|
+
* formConfig: accountForm,
|
|
114
|
+
* allowSkip: true
|
|
115
|
+
* })
|
|
116
|
+
* .configure({
|
|
117
|
+
* navigation: { allowBackNavigation: true },
|
|
118
|
+
* persistence: { saveOnStepComplete: true }
|
|
119
|
+
* })
|
|
120
|
+
* .build();
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @class flow
|
|
25
124
|
*/
|
|
26
125
|
declare class flow {
|
|
27
126
|
private config;
|
|
@@ -34,86 +133,415 @@ declare class flow {
|
|
|
34
133
|
private completion?;
|
|
35
134
|
private analytics?;
|
|
36
135
|
private plugins;
|
|
136
|
+
private idGenerator;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a new workflow builder instance
|
|
139
|
+
*
|
|
140
|
+
* @param config - The ril configuration instance
|
|
141
|
+
* @param workflowId - Unique identifier for the workflow
|
|
142
|
+
* @param workflowName - Display name for the workflow
|
|
143
|
+
* @param description - Optional description of the workflow purpose
|
|
144
|
+
*/
|
|
37
145
|
constructor(config: ril, workflowId: string, workflowName: string, description?: string);
|
|
146
|
+
/**
|
|
147
|
+
* Static factory method to create a new workflow builder
|
|
148
|
+
*
|
|
149
|
+
* This is the preferred way to create workflow builders as it provides
|
|
150
|
+
* better type inference and follows the factory pattern.
|
|
151
|
+
*
|
|
152
|
+
* @param config - The ril configuration instance
|
|
153
|
+
* @param workflowId - Unique identifier for the workflow
|
|
154
|
+
* @param workflowName - Display name for the workflow
|
|
155
|
+
* @param description - Optional description of the workflow purpose
|
|
156
|
+
* @returns A new flow builder instance
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const workflow = flow.create(rilConfig, 'checkout', 'Checkout Process');
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
38
163
|
static create(config: ril, workflowId: string, workflowName: string, description?: string): flow;
|
|
39
164
|
/**
|
|
40
165
|
* Helper method to create a step configuration from StepDefinition
|
|
166
|
+
*
|
|
167
|
+
* This internal method handles the conversion from the user-friendly
|
|
168
|
+
* StepDefinition interface to the internal StepConfig structure,
|
|
169
|
+
* including ID generation and form configuration processing.
|
|
170
|
+
*
|
|
171
|
+
* @private
|
|
172
|
+
* @param stepDef - The step definition to convert
|
|
173
|
+
* @returns A complete StepConfig object
|
|
41
174
|
*/
|
|
42
175
|
private createStepFromDefinition;
|
|
43
176
|
/**
|
|
44
|
-
*
|
|
177
|
+
* Universal add method - handles single steps or multiple steps
|
|
178
|
+
*
|
|
179
|
+
* This polymorphic method provides a clean API for adding steps to the workflow.
|
|
180
|
+
* It can handle both single step definitions and arrays of step definitions,
|
|
181
|
+
* making it easy to build workflows programmatically.
|
|
182
|
+
*
|
|
183
|
+
* @param stepDefinition - Single step definition
|
|
184
|
+
* @returns The flow instance for method chaining
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* // Add a single step
|
|
189
|
+
* workflow.addStep({
|
|
190
|
+
* title: 'User Details',
|
|
191
|
+
* formConfig: userForm
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
45
194
|
*/
|
|
46
195
|
addStep(stepDefinition: StepDefinition): this;
|
|
196
|
+
/**
|
|
197
|
+
* Universal add method - handles single steps or multiple steps
|
|
198
|
+
*
|
|
199
|
+
* @param stepDefinitions - Array of step definitions
|
|
200
|
+
* @returns The flow instance for method chaining
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // Add multiple steps at once
|
|
205
|
+
* workflow.addStep([
|
|
206
|
+
* { title: 'Step 1', formConfig: form1 },
|
|
207
|
+
* { title: 'Step 2', formConfig: form2 }
|
|
208
|
+
* ]);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
addStep(stepDefinitions: StepDefinition[]): this;
|
|
47
212
|
/**
|
|
48
213
|
* Add a dynamic step using StepDefinition with dynamicConfig
|
|
214
|
+
*
|
|
215
|
+
* Dynamic steps can change their behavior, visibility, or configuration
|
|
216
|
+
* based on data from previous steps. This method is a convenience wrapper
|
|
217
|
+
* around addStep() with enhanced type safety for dynamic configurations.
|
|
218
|
+
*
|
|
219
|
+
* @param stepDefinition - Step definition with required dynamicConfig
|
|
220
|
+
* @returns The flow instance for method chaining
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* workflow.addDynamicStep({
|
|
225
|
+
* title: 'Conditional Step',
|
|
226
|
+
* formConfig: conditionalForm,
|
|
227
|
+
* dynamicConfig: {
|
|
228
|
+
* condition: (data) => data.userType === 'premium',
|
|
229
|
+
* generator: (data) => generatePremiumForm(data)
|
|
230
|
+
* }
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
49
233
|
*/
|
|
50
234
|
addDynamicStep(stepDefinition: StepDefinition & {
|
|
51
235
|
dynamicConfig: DynamicStepConfig;
|
|
52
236
|
}): this;
|
|
53
237
|
/**
|
|
54
|
-
*
|
|
238
|
+
* Universal configuration method for all workflow options
|
|
239
|
+
*
|
|
240
|
+
* This method replaces individual setter methods with a single consolidated API
|
|
241
|
+
* for configuring all aspects of workflow behavior. It uses deep merging to
|
|
242
|
+
* preserve existing configurations while applying new settings.
|
|
243
|
+
*
|
|
244
|
+
* @param options - Configuration options to apply
|
|
245
|
+
* @returns The flow instance for method chaining
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* workflow.configure({
|
|
250
|
+
* navigation: {
|
|
251
|
+
* allowBackNavigation: true,
|
|
252
|
+
* showProgressBar: true
|
|
253
|
+
* },
|
|
254
|
+
* persistence: {
|
|
255
|
+
* saveOnStepComplete: true,
|
|
256
|
+
* storageKey: 'my-workflow'
|
|
257
|
+
* },
|
|
258
|
+
* analytics: {
|
|
259
|
+
* trackStepCompletion: true,
|
|
260
|
+
* trackFieldInteractions: false
|
|
261
|
+
* }
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
55
264
|
*/
|
|
56
|
-
|
|
265
|
+
configure(options: WorkflowOptions): this;
|
|
57
266
|
/**
|
|
58
|
-
*
|
|
267
|
+
* Plugin management with enhanced validation
|
|
268
|
+
*
|
|
269
|
+
* Installs a plugin into the workflow with dependency validation.
|
|
270
|
+
* Plugins can extend workflow functionality, add custom renderers,
|
|
271
|
+
* or integrate with external services.
|
|
272
|
+
*
|
|
273
|
+
* @param plugin - The plugin to install
|
|
274
|
+
* @returns The flow instance for method chaining
|
|
275
|
+
* @throws Error if plugin installation fails or dependencies are missing
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* workflow.use(customPlugin)
|
|
280
|
+
* .use(anotherPlugin);
|
|
281
|
+
* ```
|
|
59
282
|
*/
|
|
60
|
-
|
|
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;
|
|
283
|
+
use(plugin: WorkflowPlugin): this;
|
|
66
284
|
/**
|
|
67
|
-
*
|
|
285
|
+
* Validates plugin dependencies before installation
|
|
286
|
+
*
|
|
287
|
+
* @private
|
|
288
|
+
* @param plugin - The plugin to validate
|
|
289
|
+
* @throws Error if required dependencies are missing
|
|
68
290
|
*/
|
|
69
|
-
use(plugin: WorkflowPlugin): this;
|
|
70
291
|
private validatePluginDependencies;
|
|
292
|
+
/**
|
|
293
|
+
* Remove a plugin from the workflow
|
|
294
|
+
*
|
|
295
|
+
* @param pluginName - Name of the plugin to remove
|
|
296
|
+
* @returns The flow instance for method chaining
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* workflow.removePlugin('analytics-plugin');
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
71
303
|
removePlugin(pluginName: string): this;
|
|
72
304
|
/**
|
|
73
|
-
*
|
|
305
|
+
* Update an existing step configuration
|
|
306
|
+
*
|
|
307
|
+
* Allows modification of step properties after the step has been added.
|
|
308
|
+
* Useful for dynamic workflows or configuration updates based on user input.
|
|
309
|
+
*
|
|
310
|
+
* @param stepId - ID of the step to update
|
|
311
|
+
* @param updates - Partial step configuration updates
|
|
312
|
+
* @returns The flow instance for method chaining
|
|
313
|
+
* @throws Error if step with given ID is not found
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* workflow.updateStep('step-1', {
|
|
318
|
+
* title: 'Updated Title',
|
|
319
|
+
* allowSkip: true
|
|
320
|
+
* });
|
|
321
|
+
* ```
|
|
74
322
|
*/
|
|
75
323
|
updateStep(stepId: string, updates: Partial<Omit<StepConfig, 'id'>>): this;
|
|
324
|
+
/**
|
|
325
|
+
* Remove a step from the workflow
|
|
326
|
+
*
|
|
327
|
+
* @param stepId - ID of the step to remove
|
|
328
|
+
* @returns The flow instance for method chaining
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* workflow.removeStep('optional-step');
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
76
335
|
removeStep(stepId: string): this;
|
|
336
|
+
/**
|
|
337
|
+
* Get a specific step by ID
|
|
338
|
+
*
|
|
339
|
+
* @param stepId - ID of the step to retrieve
|
|
340
|
+
* @returns The step configuration or undefined if not found
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* const step = workflow.getStep('user-details');
|
|
345
|
+
* if (step) {
|
|
346
|
+
* console.log(step.title);
|
|
347
|
+
* }
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
77
350
|
getStep(stepId: string): StepConfig | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* Get all steps in the workflow
|
|
353
|
+
*
|
|
354
|
+
* Returns a copy of the steps array to prevent external modification.
|
|
355
|
+
*
|
|
356
|
+
* @returns Array of all step configurations
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const allSteps = workflow.getSteps();
|
|
361
|
+
* console.log(`Workflow has ${allSteps.length} steps`);
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
78
364
|
getSteps(): StepConfig[];
|
|
365
|
+
/**
|
|
366
|
+
* Clear all steps from the workflow
|
|
367
|
+
*
|
|
368
|
+
* Removes all steps and resets the ID generator. Useful for rebuilding
|
|
369
|
+
* workflows or creating templates.
|
|
370
|
+
*
|
|
371
|
+
* @returns The flow instance for method chaining
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* workflow.clearSteps()
|
|
376
|
+
* .addStep(newStep1)
|
|
377
|
+
* .addStep(newStep2);
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
79
380
|
clearSteps(): this;
|
|
80
381
|
/**
|
|
81
382
|
* Clone the workflow builder
|
|
383
|
+
*
|
|
384
|
+
* Creates a deep copy of the workflow builder with optional new ID and name.
|
|
385
|
+
* All configuration, steps, and plugins are copied to the new instance.
|
|
386
|
+
*
|
|
387
|
+
* @param newWorkflowId - Optional new workflow ID
|
|
388
|
+
* @param newWorkflowName - Optional new workflow name
|
|
389
|
+
* @returns A new flow instance with copied configuration
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const template = workflow.clone('new-workflow', 'New Workflow');
|
|
394
|
+
* template.addStep(additionalStep);
|
|
395
|
+
* ```
|
|
82
396
|
*/
|
|
83
397
|
clone(newWorkflowId?: string, newWorkflowName?: string): flow;
|
|
84
398
|
/**
|
|
85
|
-
*
|
|
399
|
+
* Enhanced validation using shared utilities
|
|
400
|
+
*
|
|
401
|
+
* Performs comprehensive validation of the workflow configuration,
|
|
402
|
+
* checking for common issues like missing steps, duplicate IDs,
|
|
403
|
+
* and plugin dependency problems.
|
|
404
|
+
*
|
|
405
|
+
* @returns Array of validation error messages (empty if valid)
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```typescript
|
|
409
|
+
* const errors = workflow.validate();
|
|
410
|
+
* if (errors.length > 0) {
|
|
411
|
+
* console.error('Validation errors:', errors);
|
|
412
|
+
* }
|
|
413
|
+
* ```
|
|
86
414
|
*/
|
|
87
415
|
validate(): string[];
|
|
88
416
|
/**
|
|
89
|
-
* Get workflow statistics
|
|
417
|
+
* Get comprehensive workflow statistics
|
|
418
|
+
*
|
|
419
|
+
* Provides detailed analytics about the workflow structure and configuration.
|
|
420
|
+
* Useful for monitoring, optimization, and reporting purposes.
|
|
421
|
+
*
|
|
422
|
+
* @returns Object containing various workflow statistics
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```typescript
|
|
426
|
+
* const stats = workflow.getStats();
|
|
427
|
+
* console.log(`Workflow has ${stats.totalSteps} steps`);
|
|
428
|
+
* console.log(`Estimated ${stats.estimatedFields} total fields`);
|
|
429
|
+
* ```
|
|
90
430
|
*/
|
|
91
431
|
getStats(): {
|
|
432
|
+
/** Total number of steps in the workflow */
|
|
92
433
|
totalSteps: number;
|
|
434
|
+
/** Number of dynamic steps */
|
|
93
435
|
dynamicSteps: number;
|
|
436
|
+
/** Number of installed plugins */
|
|
94
437
|
pluginsInstalled: number;
|
|
438
|
+
/** Estimated total number of form fields across all steps */
|
|
95
439
|
estimatedFields: number;
|
|
440
|
+
/** Whether persistence is configured */
|
|
96
441
|
hasPersistence: boolean;
|
|
442
|
+
/** Whether analytics is configured */
|
|
97
443
|
hasAnalytics: boolean;
|
|
444
|
+
/** Whether back navigation is allowed */
|
|
98
445
|
allowBackNavigation: boolean;
|
|
99
446
|
};
|
|
100
447
|
/**
|
|
101
448
|
* Build the final workflow configuration
|
|
449
|
+
*
|
|
450
|
+
* Validates the workflow and creates the final configuration object
|
|
451
|
+
* that can be used by the workflow runtime. This method should be
|
|
452
|
+
* called after all configuration is complete.
|
|
453
|
+
*
|
|
454
|
+
* @returns Complete workflow configuration
|
|
455
|
+
* @throws Error if validation fails
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```typescript
|
|
459
|
+
* try {
|
|
460
|
+
* const workflowConfig = workflow.build();
|
|
461
|
+
* // Use workflowConfig with workflow runtime
|
|
462
|
+
* } catch (error) {
|
|
463
|
+
* console.error('Workflow build failed:', error.message);
|
|
464
|
+
* }
|
|
465
|
+
* ```
|
|
102
466
|
*/
|
|
103
467
|
build(): WorkflowConfig;
|
|
104
468
|
/**
|
|
105
|
-
* Export
|
|
469
|
+
* Export workflow configuration to JSON
|
|
470
|
+
*
|
|
471
|
+
* Serializes the workflow configuration to a JSON-compatible object.
|
|
472
|
+
* Useful for saving workflows, creating templates, or transferring
|
|
473
|
+
* configurations between systems.
|
|
474
|
+
*
|
|
475
|
+
* @returns JSON-serializable workflow configuration
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* const json = workflow.toJSON();
|
|
480
|
+
* localStorage.setItem('workflow-template', JSON.stringify(json));
|
|
481
|
+
* ```
|
|
106
482
|
*/
|
|
107
483
|
toJSON(): any;
|
|
484
|
+
/**
|
|
485
|
+
* Import workflow configuration from JSON
|
|
486
|
+
*
|
|
487
|
+
* Loads workflow configuration from a JSON object. This method
|
|
488
|
+
* performs partial updates, only modifying properties that are
|
|
489
|
+
* present in the JSON object.
|
|
490
|
+
*
|
|
491
|
+
* @param json - JSON object containing workflow configuration
|
|
492
|
+
* @returns The flow instance for method chaining
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* const json = JSON.parse(localStorage.getItem('workflow-template'));
|
|
497
|
+
* workflow.fromJSON(json);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
108
500
|
fromJSON(json: any): this;
|
|
109
501
|
}
|
|
110
502
|
/**
|
|
111
503
|
* Factory function to create a workflow builder directly
|
|
504
|
+
*
|
|
505
|
+
* This is a convenience function that provides an alternative to using
|
|
506
|
+
* the class constructor or static create method. It's particularly useful
|
|
507
|
+
* for functional programming styles or when you prefer function calls
|
|
508
|
+
* over class instantiation.
|
|
509
|
+
*
|
|
510
|
+
* @param config - The ril configuration instance
|
|
511
|
+
* @param workflowId - Unique identifier for the workflow
|
|
512
|
+
* @param workflowName - Display name for the workflow
|
|
513
|
+
* @param description - Optional description of the workflow purpose
|
|
514
|
+
* @returns A new flow builder instance
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```typescript
|
|
518
|
+
* const workflow = createFlow(rilConfig, 'onboarding', 'User Onboarding');
|
|
519
|
+
* ```
|
|
112
520
|
*/
|
|
113
521
|
declare function createFlow(config: ril, workflowId: string, workflowName: string, description?: string): flow;
|
|
522
|
+
/**
|
|
523
|
+
* Module augmentation to add createFlow method to ril instances
|
|
524
|
+
*
|
|
525
|
+
* This declaration extends the ril interface to include the createFlow
|
|
526
|
+
* method, allowing for a more integrated API experience where workflows
|
|
527
|
+
* can be created directly from ril configuration instances.
|
|
528
|
+
*/
|
|
114
529
|
declare module '@rilaykit/core' {
|
|
115
530
|
interface ril {
|
|
116
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Creates a new workflow builder using this ril configuration
|
|
533
|
+
*
|
|
534
|
+
* @param workflowId - Unique identifier for the workflow
|
|
535
|
+
* @param workflowName - Display name for the workflow
|
|
536
|
+
* @param description - Optional description of the workflow purpose
|
|
537
|
+
* @returns A new flow builder instance
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* const workflow = rilConfig.createFlow('checkout', 'Checkout Process');
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
flow(workflowId: string, workflowName: string, description?: string): flow;
|
|
117
545
|
}
|
|
118
546
|
}
|
|
119
547
|
|
|
@@ -276,93 +704,4 @@ declare class RilayLicenseManager {
|
|
|
276
704
|
}>;
|
|
277
705
|
}
|
|
278
706
|
|
|
279
|
-
|
|
280
|
-
providers: {
|
|
281
|
-
googleAnalytics?: {
|
|
282
|
-
trackingId: string;
|
|
283
|
-
customDimensions?: Record<string, string>;
|
|
284
|
-
};
|
|
285
|
-
mixpanel?: {
|
|
286
|
-
token: string;
|
|
287
|
-
options?: any;
|
|
288
|
-
};
|
|
289
|
-
amplitude?: {
|
|
290
|
-
apiKey: string;
|
|
291
|
-
options?: any;
|
|
292
|
-
};
|
|
293
|
-
custom?: {
|
|
294
|
-
endpoint: string;
|
|
295
|
-
headers?: Record<string, string>;
|
|
296
|
-
};
|
|
297
|
-
};
|
|
298
|
-
eventMapping?: {
|
|
299
|
-
workflowStart?: string;
|
|
300
|
-
workflowComplete?: string;
|
|
301
|
-
stepStart?: string;
|
|
302
|
-
stepComplete?: string;
|
|
303
|
-
stepSkip?: string;
|
|
304
|
-
validationError?: string;
|
|
305
|
-
};
|
|
306
|
-
includeUserContext?: boolean;
|
|
307
|
-
includeFormData?: boolean;
|
|
308
|
-
enablePerformanceTracking?: boolean;
|
|
309
|
-
}
|
|
310
|
-
declare class AnalyticsPlugin implements WorkflowPlugin {
|
|
311
|
-
name: string;
|
|
312
|
-
version: string;
|
|
313
|
-
private config;
|
|
314
|
-
private performanceData;
|
|
315
|
-
constructor(config: AnalyticsPluginConfig);
|
|
316
|
-
install(workflowBuilder: any): void;
|
|
317
|
-
private track;
|
|
318
|
-
private trackGoogleAnalytics;
|
|
319
|
-
private trackMixpanel;
|
|
320
|
-
private trackAmplitude;
|
|
321
|
-
private trackCustom;
|
|
322
|
-
private getContextData;
|
|
323
|
-
private calculateCompletionPercentage;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
interface ValidationPluginConfig {
|
|
327
|
-
schema?: {
|
|
328
|
-
type: 'zod' | 'yup' | 'custom';
|
|
329
|
-
schema?: any;
|
|
330
|
-
};
|
|
331
|
-
rules: {
|
|
332
|
-
required?: string[];
|
|
333
|
-
email?: string[];
|
|
334
|
-
phone?: string[];
|
|
335
|
-
minLength?: Record<string, number>;
|
|
336
|
-
maxLength?: Record<string, number>;
|
|
337
|
-
pattern?: Record<string, RegExp>;
|
|
338
|
-
custom?: Record<string, (value: any, context: WorkflowContext) => ValidationResult | Promise<ValidationResult>>;
|
|
339
|
-
};
|
|
340
|
-
crossFieldValidation?: Array<{
|
|
341
|
-
fields: string[];
|
|
342
|
-
validator: (values: Record<string, any>, context: WorkflowContext) => ValidationResult | Promise<ValidationResult>;
|
|
343
|
-
message: string;
|
|
344
|
-
}>;
|
|
345
|
-
asyncRules?: Record<string, {
|
|
346
|
-
url: string;
|
|
347
|
-
debounceMs?: number;
|
|
348
|
-
method?: 'GET' | 'POST';
|
|
349
|
-
headers?: Record<string, string>;
|
|
350
|
-
}>;
|
|
351
|
-
onValidationComplete?: (result: ValidationResult, context: WorkflowContext) => void;
|
|
352
|
-
}
|
|
353
|
-
declare class ValidationPlugin implements WorkflowPlugin {
|
|
354
|
-
name: string;
|
|
355
|
-
version: string;
|
|
356
|
-
dependencies: never[];
|
|
357
|
-
private config;
|
|
358
|
-
private debounceTimers;
|
|
359
|
-
constructor(config: ValidationPluginConfig);
|
|
360
|
-
install(workflowBuilder: any): void;
|
|
361
|
-
private validateStep;
|
|
362
|
-
private validateWithSchema;
|
|
363
|
-
private validateWithRules;
|
|
364
|
-
private validateCrossField;
|
|
365
|
-
private validateAsync;
|
|
366
|
-
}
|
|
367
|
-
|
|
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 };
|
|
707
|
+
export { type LicensePayload, type LicensePlan, type LicenseResult, RilayLicenseManager, type StepDefinition, Workflow, WorkflowBody, type WorkflowContextValue, WorkflowNextButton, type WorkflowNextButtonProps, WorkflowPreviousButton, type WorkflowPreviousButtonProps, WorkflowProvider, type WorkflowProviderProps, WorkflowSkipButton, type WorkflowSkipButtonProps, WorkflowStepper, type WorkflowStepperProps, createFlow, flow, useWorkflowContext };
|