@rilaykit/core 0.1.1-alpha.1 → 0.1.1

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,158 +1,532 @@
1
- import React from 'react';
2
- import { z } from 'zod';
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import * as React$1 from 'react';
3
+ import React__default from 'react';
3
4
 
4
5
  /**
5
- * Main configuration class for Rilay form components and workflows
6
- * Manages component registration, retrieval, and configuration
6
+ * A graph that tracks which fields depend on which other fields for condition evaluation.
7
+ *
8
+ * This enables efficient re-evaluation of conditions when values change:
9
+ * instead of re-evaluating ALL conditions when ANY value changes,
10
+ * we only re-evaluate conditions that depend on the changed value.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const graph = new ConditionDependencyGraph();
15
+ *
16
+ * // Add field with its conditions
17
+ * graph.addField('dependentField', {
18
+ * visible: when('triggerField').equals('show')
19
+ * });
20
+ *
21
+ * // When 'triggerField' changes, get affected fields
22
+ * const affected = graph.getAffectedFields('triggerField');
23
+ * // affected = ['dependentField']
24
+ * ```
7
25
  */
8
- declare class ril {
9
- private components;
10
- private formRenderConfig;
11
- private workflowRenderConfig;
12
- static create(): ril;
26
+ declare class ConditionDependencyGraph {
13
27
  /**
14
- * Add a component to the configuration
15
- * @param subType - The component subtype (e.g., 'text', 'email', 'heading')
16
- * @param config - Component configuration without id and subType
17
- * @returns The ril instance for chaining
28
+ * Maps field IDs to their dependencies (fields they depend on)
29
+ * fieldId -> Set of field paths it depends on
18
30
  */
19
- addComponent<TProps = any>(subType: InputType | LayoutType, config: Omit<ComponentConfig<TProps>, 'id' | 'subType'> & {
20
- id?: string;
21
- }): this;
31
+ private readonly fieldDependencies;
22
32
  /**
23
- * Set custom row renderer
24
- * @param renderer - Custom row renderer function
25
- * @returns The ril instance for chaining
33
+ * Reverse index: maps a field path to all fields that depend on it
34
+ * fieldPath -> Set of field IDs that have conditions depending on this path
26
35
  */
27
- setRowRenderer(renderer: FormRowRenderer): this;
36
+ private readonly reverseDependencies;
28
37
  /**
29
- * Set custom body renderer
30
- * @param renderer - Custom body renderer function
31
- * @returns The ril instance for chaining
38
+ * Adds a field with its conditional behavior to the graph.
39
+ *
40
+ * @param fieldId - The ID of the field
41
+ * @param conditions - The field's conditional behavior (visible, disabled, required, readonly)
32
42
  */
33
- setBodyRenderer(renderer: FormBodyRenderer): this;
43
+ addField(fieldId: string, conditions?: ConditionalBehavior): void;
34
44
  /**
35
- * Set custom submit button renderer
36
- * @param renderer - Custom submit button renderer function
37
- * @returns The ril instance for chaining
45
+ * Removes a field from the graph.
46
+ *
47
+ * @param fieldId - The ID of the field to remove
38
48
  */
39
- setSubmitButtonRenderer(renderer: FormSubmitButtonRenderer): this;
49
+ removeField(fieldId: string): void;
40
50
  /**
41
- * Set complete form render configuration
42
- * @param config - Form render configuration
43
- * @returns The ril instance for chaining
51
+ * Gets all field IDs that have conditions depending on a specific field path.
52
+ *
53
+ * When a value at `changedPath` changes, these are the fields whose
54
+ * conditions need to be re-evaluated.
55
+ *
56
+ * @param changedPath - The field path that changed
57
+ * @returns Array of field IDs that depend on this path
44
58
  */
45
- setFormRenderConfig(config: FormRenderConfig): this;
59
+ getAffectedFields(changedPath: string): string[];
46
60
  /**
47
- * Get current form render configuration
48
- * @returns Current form render configuration
61
+ * Gets all field IDs affected by changes to multiple paths.
62
+ *
63
+ * @param changedPaths - Array of field paths that changed
64
+ * @returns Array of unique field IDs that depend on any of these paths
49
65
  */
50
- getFormRenderConfig(): FormRenderConfig;
66
+ getAffectedFieldsMultiple(changedPaths: string[]): string[];
51
67
  /**
52
- * Set custom stepper renderer for workflows
53
- * @param renderer - Custom stepper renderer function
54
- * @returns The ril instance for chaining
68
+ * Gets the dependencies for a specific field.
69
+ *
70
+ * @param fieldId - The ID of the field
71
+ * @returns Array of field paths this field depends on
55
72
  */
56
- setStepperRenderer(renderer: WorkflowStepperRenderer): this;
73
+ getDependencies(fieldId: string): string[];
57
74
  /**
58
- * Set custom workflow navigation renderer
59
- * @param renderer - Custom workflow navigation renderer function
60
- * @returns The ril instance for chaining
75
+ * Checks if a field has any dependencies.
76
+ *
77
+ * @param fieldId - The ID of the field
78
+ * @returns True if the field has conditional dependencies
61
79
  */
62
- setWorkflowNavigationRenderer(renderer: WorkflowNavigationRenderer): this;
80
+ hasDependencies(fieldId: string): boolean;
63
81
  /**
64
- * Set complete workflow render configuration
65
- * @param config - Workflow render configuration
66
- * @returns The ril instance for chaining
82
+ * Gets all fields in the graph.
83
+ *
84
+ * @returns Array of all field IDs
67
85
  */
68
- setWorkflowRenderConfig(config: WorkflowRenderConfig): this;
86
+ getAllFields(): string[];
69
87
  /**
70
- * Get current workflow render configuration
71
- * @returns Current workflow render configuration
88
+ * Gets all unique dependency paths in the graph.
89
+ *
90
+ * @returns Array of all field paths that are dependencies
72
91
  */
73
- getWorkflowRenderConfig(): WorkflowRenderConfig;
92
+ getAllDependencyPaths(): string[];
74
93
  /**
75
- * @deprecated Use setFormRenderConfig() instead
94
+ * Clears the entire graph.
76
95
  */
77
- setRenderConfig(config: FormRenderConfig): this;
96
+ clear(): void;
78
97
  /**
79
- * Get a component by its ID
80
- * @param id - Component ID
81
- * @returns Component configuration or undefined
98
+ * Gets the size of the graph (number of fields).
82
99
  */
83
- getComponent(id: string): ComponentConfig | undefined;
100
+ get size(): number;
84
101
  /**
85
- * List components by type (input or layout)
86
- * @param type - Component type
87
- * @returns Array of matching components
102
+ * Creates a debug representation of the graph.
103
+ * Useful for development and testing.
88
104
  */
89
- getComponentsByType(type: ComponentType): ComponentConfig[];
105
+ toDebugObject(): {
106
+ fields: Record<string, string[]>;
107
+ reverseDeps: Record<string, string[]>;
108
+ };
109
+ }
110
+
111
+ type ConditionOperator = 'equals' | 'notEquals' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'contains' | 'notContains' | 'in' | 'notIn' | 'matches' | 'exists' | 'notExists';
112
+ type LogicalOperator = 'and' | 'or';
113
+ type ConditionValue = string | number | boolean | null | undefined | Array<string | number | boolean>;
114
+ interface ConditionConfig {
115
+ field: string;
116
+ operator: ConditionOperator;
117
+ value?: ConditionValue;
118
+ conditions?: ConditionConfig[];
119
+ logicalOperator?: LogicalOperator;
120
+ }
121
+ type ConditionEvaluator = (data: Record<string, any>) => boolean;
122
+ interface ConditionBuilder extends ConditionConfig {
123
+ equals(value: ConditionValue): ConditionBuilder;
124
+ notEquals(value: ConditionValue): ConditionBuilder;
125
+ greaterThan(value: number): ConditionBuilder;
126
+ lessThan(value: number): ConditionBuilder;
127
+ greaterThanOrEqual(value: number): ConditionBuilder;
128
+ lessThanOrEqual(value: number): ConditionBuilder;
129
+ contains(value: string): ConditionBuilder;
130
+ notContains(value: string): ConditionBuilder;
131
+ in(values: Array<string | number | boolean>): ConditionBuilder;
132
+ notIn(values: Array<string | number | boolean>): ConditionBuilder;
133
+ matches(pattern: string | RegExp): ConditionBuilder;
134
+ exists(): ConditionBuilder;
135
+ notExists(): ConditionBuilder;
136
+ and(condition: ConditionBuilder | ConditionConfig): ConditionBuilder;
137
+ or(condition: ConditionBuilder | ConditionConfig): ConditionBuilder;
138
+ build(): ConditionConfig;
139
+ evaluate(data: Record<string, any>): boolean;
140
+ }
141
+ declare function when(field: string): ConditionBuilder;
142
+ declare function evaluateCondition(condition: ConditionConfig, data: Record<string, any>): boolean;
143
+
144
+ /**
145
+ * Extracts all field paths that a condition depends on.
146
+ *
147
+ * This is useful for building a dependency graph that knows which
148
+ * conditions need to be re-evaluated when a specific field changes.
149
+ *
150
+ * @param condition - The condition to extract dependencies from
151
+ * @returns An array of unique field paths
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const condition = when('field1').equals('value').and(when('field2').exists());
156
+ * const deps = extractConditionDependencies(condition.build());
157
+ * // deps = ['field1', 'field2']
158
+ *
159
+ * const nestedCondition = when('step1.field1').equals('value');
160
+ * const nestedDeps = extractConditionDependencies(nestedCondition.build());
161
+ * // nestedDeps = ['step1.field1']
162
+ * ```
163
+ */
164
+ declare function extractConditionDependencies(condition: ConditionConfig | ConditionBuilder | undefined | null): string[];
165
+ /**
166
+ * Extracts dependencies from multiple conditions (e.g., visible, disabled, required).
167
+ *
168
+ * @param behaviors - Object containing condition configurations
169
+ * @returns An array of unique field paths from all conditions
170
+ */
171
+ declare function extractAllDependencies(behaviors: Record<string, ConditionConfig | ConditionBuilder | undefined | null>): string[];
172
+
173
+ /**
174
+ * Validation result for async operations
175
+ */
176
+ interface AsyncValidationResult {
177
+ isValid: boolean;
178
+ errors: string[];
179
+ warnings?: string[];
180
+ }
181
+ /**
182
+ * Public interface for Rilay instances
183
+ * Exposes only the methods necessary for the public API
184
+ */
185
+ interface RilayInstance<C> {
186
+ addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): RilayInstance<C & {
187
+ [K in NewType]: TProps;
188
+ }>;
189
+ configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): RilayInstance<C>;
190
+ getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined;
191
+ getComponent(id: string): ComponentConfig | undefined;
192
+ getAllComponents(): ComponentConfig[];
193
+ hasComponent(id: string): boolean;
194
+ getFormRenderConfig(): FormRenderConfig;
195
+ getWorkflowRenderConfig(): WorkflowRenderConfig;
196
+ getStats(): {
197
+ total: number;
198
+ byType: Record<string, number>;
199
+ hasCustomRenderers: {
200
+ row: boolean;
201
+ body: boolean;
202
+ submitButton: boolean;
203
+ field: boolean;
204
+ stepper: boolean;
205
+ workflowNextButton: boolean;
206
+ workflowPreviousButton: boolean;
207
+ workflowSkipButton: boolean;
208
+ };
209
+ };
210
+ validate(): string[];
211
+ validateAsync(): Promise<AsyncValidationResult>;
212
+ clone(): RilayInstance<C>;
213
+ removeComponent(id: string): RilayInstance<C>;
214
+ clear(): RilayInstance<C>;
215
+ }
216
+ /**
217
+ * Main configuration class for Rilay form components and workflows
218
+ * Manages component registration, retrieval, and configuration with immutable API
219
+ */
220
+ declare class ril<C> implements RilayInstance<C> {
221
+ private components;
222
+ private formRenderConfig;
223
+ private workflowRenderConfig;
90
224
  /**
91
- * List components by sub-type
92
- * @param subType - Component sub-type
93
- * @returns Array of matching components
225
+ * Static factory method to create a new ril instance
94
226
  */
95
- getComponentsBySubType(subType: InputType | LayoutType): ComponentConfig[];
227
+ static create<CT>(): ril<CT>;
96
228
  /**
97
- * Get components by category
98
- * @param category - Component category
99
- * @returns Array of matching components
229
+ * Add a component to the configuration (immutable)
230
+ * Returns a new instance with the added component
231
+ *
232
+ * @param type - The component type (e.g., 'text', 'email', 'heading'), used as a unique identifier.
233
+ * @param config - Component configuration without id and type
234
+ * @returns A new ril instance with the added component
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // Component with default validation
239
+ * const factory = ril.create()
240
+ * .addComponent('email', {
241
+ * name: 'Email Input',
242
+ * renderer: EmailInput,
243
+ * validation: {
244
+ * validators: [email('Format email invalide')],
245
+ * validateOnBlur: true,
246
+ * }
247
+ * });
248
+ * ```
100
249
  */
101
- getComponentsByCategory(category: string): ComponentConfig[];
250
+ addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): ril<C & {
251
+ [K in NewType]: TProps;
252
+ }>;
102
253
  /**
103
- * List all registered components
104
- * @returns Array of all components
254
+ * Universal configuration method with deep merge support (immutable)
255
+ *
256
+ * This method provides a unified API to configure both form and workflow renderers
257
+ * in a single call, automatically categorizing and applying the appropriate configurations
258
+ * using recursive deep merge.
259
+ *
260
+ * @param config - Configuration object containing renderer settings
261
+ * @returns A new ril instance with the updated configuration
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * // Configure with nested settings
266
+ * const config = ril.create()
267
+ * .configure({
268
+ * rowRenderer: CustomRowRenderer,
269
+ * submitButtonRenderer: CustomSubmitButton,
270
+ * // Deep nested configuration example
271
+ * formStyles: {
272
+ * layout: {
273
+ * spacing: 'large',
274
+ * alignment: 'center'
275
+ * }
276
+ * }
277
+ * });
278
+ * ```
105
279
  */
106
- getAllComponents(): ComponentConfig[];
280
+ configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): ril<C>;
107
281
  /**
108
- * Check if a component exists
109
- * @param id - Component ID
110
- * @returns True if component exists
282
+ * Configuration getters
111
283
  */
112
- hasComponent(id: string): boolean;
284
+ getFormRenderConfig(): FormRenderConfig;
285
+ getWorkflowRenderConfig(): WorkflowRenderConfig;
113
286
  /**
114
- * Remove a component from the configuration
115
- * @param id - Component ID
116
- * @returns True if component was removed
287
+ * Component management methods
117
288
  */
118
- removeComponent(id: string): boolean;
289
+ getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined;
290
+ getAllComponents(): ComponentConfig[];
291
+ hasComponent(id: string): boolean;
119
292
  /**
120
- * Clear all components
293
+ * Remove a component from the configuration (immutable)
294
+ * Returns a new instance without the specified component
295
+ *
296
+ * @param id - The component ID to remove
297
+ * @returns A new ril instance without the component
121
298
  */
122
- clear(): void;
299
+ removeComponent(id: string): ril<C>;
123
300
  /**
124
- * Export configuration as a plain object
125
- * @returns Object with component configurations
301
+ * Clear all components from the configuration (immutable)
302
+ * Returns a new instance with no components
303
+ *
304
+ * @returns A new empty ril instance
126
305
  */
127
- export(): Record<string, ComponentConfig>;
306
+ clear(): ril<C>;
128
307
  /**
129
- * Import configuration from a plain object
130
- * @param config - Object with component configurations
131
- * @returns The ril instance for chaining
308
+ * Create a deep copy of the current ril instance
132
309
  */
133
- import(config: Record<string, ComponentConfig>): this;
310
+ clone(): ril<C>;
134
311
  /**
135
- * Get statistics about registered components and renderers
136
- * @returns Object with comprehensive statistics
312
+ * Enhanced statistics with more detailed information
137
313
  */
138
314
  getStats(): {
139
315
  total: number;
140
- byType: Record<ComponentType, number>;
141
- bySubType: Record<string, number>;
142
- byCategory: Record<string, number>;
316
+ byType: Record<string, number>;
143
317
  hasCustomRenderers: {
144
318
  row: boolean;
145
319
  body: boolean;
146
320
  submitButton: boolean;
321
+ field: boolean;
147
322
  stepper: boolean;
148
- workflowNavigation: boolean;
323
+ workflowNextButton: boolean;
324
+ workflowPreviousButton: boolean;
325
+ workflowSkipButton: boolean;
149
326
  };
150
327
  };
151
328
  /**
152
- * Validate the configuration
153
- * @returns Array of validation errors
329
+ * Synchronous validation using shared utilities
154
330
  */
155
331
  validate(): string[];
332
+ /**
333
+ * Asynchronous validation with structured error handling
334
+ * Ideal for CI/CD pipelines and advanced validation scenarios
335
+ */
336
+ validateAsync(): Promise<AsyncValidationResult>;
337
+ }
338
+
339
+ type ValidationState = 'idle' | 'validating' | 'valid' | 'invalid';
340
+ /**
341
+ * Field state without actions - used for selectors
342
+ */
343
+ interface FieldState {
344
+ readonly value: unknown;
345
+ readonly errors: ValidationError[];
346
+ readonly validationState: ValidationState;
347
+ readonly touched: boolean;
348
+ readonly dirty: boolean;
349
+ }
350
+ /**
351
+ * Field conditions - visibility, disabled, required, readonly
352
+ */
353
+ interface FieldConditions {
354
+ readonly visible: boolean;
355
+ readonly disabled: boolean;
356
+ readonly required: boolean;
357
+ readonly readonly: boolean;
358
+ }
359
+ /**
360
+ * Field actions - stable references for setValue, validate, etc.
361
+ */
362
+ interface FieldActions {
363
+ readonly setValue: (value: unknown) => void;
364
+ readonly setTouched: () => void;
365
+ readonly validate: () => Promise<ValidationResult>;
366
+ readonly clearErrors: () => void;
367
+ }
368
+ /**
369
+ * Complete field context - combines state, conditions and actions
370
+ * Used by component renderers for full field access
371
+ */
372
+ interface FieldContext extends FieldState, FieldConditions {
373
+ readonly id: string;
374
+ readonly componentId: string;
375
+ readonly defaultValue?: unknown;
376
+ readonly actions: FieldActions;
377
+ }
378
+ /**
379
+ * Form state without actions - used for selectors
380
+ */
381
+ interface FormState {
382
+ readonly values: Record<string, unknown>;
383
+ readonly errors: Record<string, ValidationError[]>;
384
+ readonly validationStates: Record<string, ValidationState>;
385
+ readonly touched: Record<string, boolean>;
386
+ readonly isDirty: boolean;
387
+ readonly isSubmitting: boolean;
388
+ readonly isValid: boolean;
389
+ }
390
+ /**
391
+ * Form actions - stable references
392
+ */
393
+ interface FormActions {
394
+ readonly setValue: (fieldId: string, value: unknown) => void;
395
+ readonly setTouched: (fieldId: string) => void;
396
+ readonly setErrors: (fieldId: string, errors: ValidationError[]) => void;
397
+ readonly setValidationState: (fieldId: string, state: ValidationState) => void;
398
+ readonly setSubmitting: (isSubmitting: boolean) => void;
399
+ readonly submit: () => Promise<boolean>;
400
+ readonly reset: (values?: Record<string, unknown>) => void;
401
+ readonly validate: () => Promise<ValidationResult>;
402
+ readonly validateField: (fieldId: string, value?: unknown) => Promise<ValidationResult>;
403
+ }
404
+ /**
405
+ * Complete form context - combines state and actions
406
+ */
407
+ interface FormContextValue extends FormState {
408
+ readonly formId: string;
409
+ readonly actions: FormActions;
410
+ readonly getFieldState: (fieldId: string) => FieldState;
411
+ readonly getFieldConditions: (fieldId: string) => FieldConditions;
412
+ }
413
+ /**
414
+ * Props passed to component renderers (v2)
415
+ * Replaces the old ComponentRenderProps with spread [key: string]: any
416
+ */
417
+ interface ComponentRenderPropsV2<TProps = unknown> {
418
+ /** Field identifier */
419
+ readonly id: string;
420
+ /** Component-specific props (label, placeholder, options, etc.) */
421
+ readonly props: TProps;
422
+ /** Field state (value, errors, touched, etc.) */
423
+ readonly field: FieldState;
424
+ /** Field conditions (visible, disabled, required, readonly) */
425
+ readonly conditions: FieldConditions;
426
+ /** Stable action references */
427
+ readonly actions: FieldActions;
428
+ }
429
+ /**
430
+ * Props passed to field wrapper renderers (v2)
431
+ */
432
+ interface FieldRendererPropsV2 {
433
+ /** Rendered component content */
434
+ readonly children: React.ReactNode;
435
+ /** Field identifier */
436
+ readonly id: string;
437
+ /** Field state */
438
+ readonly field: FieldState;
439
+ /** Field conditions */
440
+ readonly conditions: FieldConditions;
441
+ /** Component props (for label, placeholder, helpText, etc.) */
442
+ readonly componentProps: Record<string, unknown>;
443
+ }
444
+ /**
445
+ * Props passed to form submit button renderer (v2)
446
+ */
447
+ interface FormSubmitButtonRendererPropsV2 {
448
+ /** Whether form is currently submitting */
449
+ readonly isSubmitting: boolean;
450
+ /** Whether form is valid (no errors) */
451
+ readonly isValid: boolean;
452
+ /** Whether form has been modified */
453
+ readonly isDirty: boolean;
454
+ /** Submit handler */
455
+ readonly onSubmit: () => void;
456
+ /** Reset handler */
457
+ readonly onReset: () => void;
458
+ /** Form data access (for advanced use cases) */
459
+ readonly form: {
460
+ readonly values: Record<string, unknown>;
461
+ readonly errors: Record<string, ValidationError[]>;
462
+ };
463
+ /** Optional className */
464
+ readonly className?: string;
465
+ /** Optional children */
466
+ readonly children?: React.ReactNode;
467
+ }
468
+ /**
469
+ * Step state for workflow
470
+ */
471
+ interface WorkflowStepState {
472
+ readonly stepIndex: number;
473
+ readonly stepId: string;
474
+ readonly isFirst: boolean;
475
+ readonly isLast: boolean;
476
+ readonly isVisible: boolean;
477
+ readonly isSkippable: boolean;
478
+ }
479
+ /**
480
+ * Navigation state for workflow
481
+ */
482
+ interface WorkflowNavigationState {
483
+ readonly canGoNext: boolean;
484
+ readonly canGoPrevious: boolean;
485
+ readonly canSkip: boolean;
486
+ readonly isTransitioning: boolean;
487
+ }
488
+ /**
489
+ * Progress state for workflow
490
+ */
491
+ interface WorkflowProgressState {
492
+ readonly totalSteps: number;
493
+ readonly visibleSteps: number;
494
+ readonly currentStepIndex: number;
495
+ readonly visitedSteps: ReadonlySet<string>;
496
+ readonly passedSteps: ReadonlySet<string>;
497
+ }
498
+ /**
499
+ * Complete workflow step context
500
+ */
501
+ interface WorkflowStepContext {
502
+ readonly step: WorkflowStepState;
503
+ readonly navigation: WorkflowNavigationState;
504
+ readonly progress: WorkflowProgressState;
505
+ readonly stepData: Record<string, unknown>;
506
+ readonly allData: Record<string, unknown>;
507
+ }
508
+ /**
509
+ * Props passed to workflow button renderers (v2)
510
+ */
511
+ interface WorkflowButtonRendererPropsV2 {
512
+ /** Navigation state */
513
+ readonly navigation: WorkflowNavigationState;
514
+ /** Progress state */
515
+ readonly progress: WorkflowProgressState;
516
+ /** Current step state */
517
+ readonly step: WorkflowStepState;
518
+ /** Whether workflow is submitting */
519
+ readonly isSubmitting: boolean;
520
+ /** Step data */
521
+ readonly stepData: Record<string, unknown>;
522
+ /** All workflow data */
523
+ readonly allData: Record<string, unknown>;
524
+ /** Action handler (next/previous/skip/submit) */
525
+ readonly onAction: () => void;
526
+ /** Optional className */
527
+ readonly className?: string;
528
+ /** Optional children */
529
+ readonly children?: React.ReactNode;
156
530
  }
157
531
 
158
532
  interface RilayLicenseConfig {
@@ -160,103 +534,281 @@ interface RilayLicenseConfig {
160
534
  readonly environment?: 'development' | 'production';
161
535
  readonly allowTrial?: boolean;
162
536
  }
163
- type ComponentType = 'input' | 'layout';
164
- type InputType = 'text' | 'email' | 'password' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'date';
165
- type LayoutType = 'heading' | 'paragraph' | 'container' | 'divider' | 'spacer' | 'alert';
166
- interface ValidationResult {
167
- readonly isValid: boolean;
168
- readonly errors: ValidationError[];
169
- readonly warnings?: ValidationWarning[];
170
- }
171
537
  interface ValidationError {
172
- readonly code: string;
173
538
  readonly message: string;
174
- readonly path?: string[];
539
+ readonly code?: string;
540
+ readonly path?: string;
175
541
  }
176
- interface ValidationWarning {
177
- readonly code: string;
178
- readonly message: string;
179
- readonly path?: string[];
542
+ interface ValidationResult {
543
+ readonly isValid: boolean;
544
+ readonly errors: ValidationError[];
545
+ readonly value?: any;
180
546
  }
181
547
  interface ValidationContext {
182
- readonly fieldId: string;
183
- readonly formData: Record<string, any>;
184
- readonly fieldProps: Record<string, any>;
185
- readonly touched: boolean;
186
- readonly dirty: boolean;
548
+ readonly fieldId?: string;
549
+ readonly formId?: string;
550
+ readonly stepId?: string;
551
+ readonly workflowId?: string;
552
+ readonly allFormData?: Record<string, any>;
553
+ readonly stepData?: Record<string, any>;
554
+ readonly workflowData?: Record<string, any>;
187
555
  }
188
- type ValidatorFunction<TProps = any> = (value: any, context: ValidationContext, props: TProps) => ValidationResult | Promise<ValidationResult>;
189
- interface ValidationConfig<TProps = any> {
190
- readonly validator?: ValidatorFunction<TProps>;
191
- readonly debounceMs?: number;
556
+ /** @internal - Use Standard Schema instead */
557
+ type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
558
+ /** @internal - Use Standard Schema instead */
559
+ type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
560
+ type StandardSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
561
+ type InferInput<T> = T extends StandardSchema<infer I, any> ? I : unknown;
562
+ type InferOutput<T> = T extends StandardSchema<any, infer O> ? O : unknown;
563
+ interface FieldValidationConfig<T = any> {
564
+ /**
565
+ * Validation rules using Standard Schema interface
566
+ * Accepts: single schema, array of schemas, or any Standard Schema compatible validation
567
+ *
568
+ * @example Single schema
569
+ * validate: z.string().email()
570
+ *
571
+ * @example Built-in validators
572
+ * validate: required()
573
+ *
574
+ * @example Multiple validations
575
+ * validate: [required(), email()]
576
+ *
577
+ * @example Mixed schemas + validators
578
+ * validate: [z.string(), required(), customValidator()]
579
+ */
580
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
192
581
  readonly validateOnChange?: boolean;
193
582
  readonly validateOnBlur?: boolean;
583
+ readonly debounceMs?: number;
584
+ }
585
+ interface FormValidationConfig<T extends Record<string, any> = Record<string, any>> {
586
+ /**
587
+ * Form-level validation using Standard Schema interface
588
+ *
589
+ * @example Object schema
590
+ * validate: z.object({ email: z.string().email(), name: z.string() })
591
+ *
592
+ * @example Custom form validator
593
+ * validate: customFormValidator()
594
+ */
595
+ readonly validate?: StandardSchema<T> | StandardSchema<T>[];
194
596
  readonly validateOnSubmit?: boolean;
195
- readonly dependencies?: string[];
597
+ readonly validateOnStepChange?: boolean;
598
+ }
599
+ type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React__default.ReactElement;
600
+ type RendererChildrenFunction<TProps = any> = (props: TProps) => React__default.ReactNode;
601
+ interface ComponentRendererBaseProps<TProps = any> {
602
+ className?: string;
603
+ children?: React__default.ReactNode | RendererChildrenFunction<TProps>;
604
+ renderAs?: 'default' | 'children' | boolean;
605
+ }
606
+ interface ComponentRendererWrapperProps<TProps = any> extends Omit<ComponentRendererBaseProps<TProps>, 'className'> {
607
+ name: string;
608
+ props: TProps;
609
+ renderer?: RendererChildrenFunction<TProps>;
196
610
  }
197
- type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React.ReactElement;
198
611
  interface ComponentRenderProps<TProps = any> {
199
612
  id: string;
200
613
  props: TProps;
201
614
  value?: any;
202
615
  onChange?: (value: any) => void;
203
616
  onBlur?: () => void;
204
- error?: ValidationError[];
205
- warnings?: ValidationWarning[];
206
- touched?: boolean;
207
617
  disabled?: boolean;
618
+ error?: ValidationError[];
208
619
  isValidating?: boolean;
209
620
  [key: string]: any;
210
621
  }
211
- interface ComponentOptions<TProps = any> {
212
- readonly configurable?: Array<{
213
- key: keyof TProps;
214
- type: 'string' | 'number' | 'boolean' | 'select' | 'array';
622
+ /**
623
+ * Property editor definition for builder property panel
624
+ * Generic and extensible to support any custom editor type
625
+ */
626
+ interface PropertyEditorDefinition<TValue = any> {
627
+ /** Property key in component props */
628
+ readonly key: string;
629
+ /** Display label in property panel */
630
+ readonly label: string;
631
+ /**
632
+ * Editor type - can be any string to support custom editors
633
+ * Built-in types: 'text', 'number', 'boolean', 'select', 'multiselect', 'color', 'textarea', 'json'
634
+ * Custom types: 'phone', 'currency', 'location', 'rating', 'file-upload', etc.
635
+ */
636
+ readonly editorType: string;
637
+ /** Optional description/help text */
638
+ readonly helpText?: string;
639
+ /** Default value for this property */
640
+ readonly defaultValue?: TValue;
641
+ /** Options for select/multiselect editors */
642
+ readonly options?: Array<{
215
643
  label: string;
216
- options?: any[];
217
- default?: any;
644
+ value: any;
645
+ [key: string]: any;
218
646
  }>;
219
- readonly previewProps?: Partial<TProps>;
647
+ /** Validation function for the property value */
648
+ readonly validate?: (value: TValue) => boolean | string | Promise<boolean | string>;
649
+ /** Group/section for organizing properties */
650
+ readonly group?: string;
651
+ /** Whether this property is required */
652
+ readonly required?: boolean;
653
+ /** Placeholder text for input fields */
654
+ readonly placeholder?: string;
655
+ /** Custom editor component for advanced use cases */
656
+ readonly customEditor?: React__default.ComponentType<PropertyEditorProps<TValue>>;
657
+ /** Additional configuration specific to the editor type */
658
+ readonly editorConfig?: Record<string, any>;
659
+ /** Dependencies - other properties that affect this one */
660
+ readonly dependencies?: string[];
661
+ /** Conditional rendering based on other property values */
662
+ readonly visible?: (props: Record<string, any>) => boolean;
663
+ /** Transform value before saving */
664
+ readonly transform?: (value: TValue) => any;
665
+ /** Parse value when loading */
666
+ readonly parse?: (value: any) => TValue;
667
+ }
668
+ /**
669
+ * Props passed to custom property editors
670
+ */
671
+ interface PropertyEditorProps<TValue = any> {
672
+ /** Current property value */
673
+ readonly value: TValue;
674
+ /** Callback to update the value */
675
+ readonly onChange: (value: TValue) => void;
676
+ /** Property definition */
677
+ readonly definition: PropertyEditorDefinition<TValue>;
678
+ /** All current property values (for dependencies) */
679
+ readonly allValues: Record<string, any>;
680
+ /** Whether the field is disabled */
681
+ readonly disabled?: boolean;
682
+ /** Validation errors */
683
+ readonly errors?: string[];
684
+ }
685
+ /**
686
+ * Builder metadata for visual editing capabilities
687
+ * This is optional and only used by @rilaykit/builder
688
+ * Fully generic to support any component type and configuration
689
+ */
690
+ interface ComponentBuilderMetadata<TProps = any> {
691
+ /** Category for grouping in component palette (e.g., 'Input', 'Layout', 'Advanced') */
692
+ readonly category?: string;
693
+ /** Icon identifier (e.g., 'text', 'email', 'calendar') */
220
694
  readonly icon?: string;
695
+ /** Whether this component should be hidden from the builder palette */
696
+ readonly hidden?: boolean;
697
+ /** Preview component or description for the palette */
698
+ readonly preview?: React__default.ReactNode;
699
+ /** Editable properties configuration for property panel */
700
+ readonly editableProps?: PropertyEditorDefinition[];
701
+ /** Tags for search and filtering */
221
702
  readonly tags?: string[];
703
+ /**
704
+ * Custom field schema for advanced type systems
705
+ * Allows defining complex field types with their own validation and structure
706
+ */
707
+ readonly fieldSchema?: FieldSchemaDefinition<TProps>;
708
+ }
709
+ /**
710
+ * Field schema definition for complex field types
711
+ * Supports defining custom field types with validation, defaults, and metadata
712
+ */
713
+ interface FieldSchemaDefinition<TProps = any> {
714
+ /** Field type identifier (e.g., 'location', 'phone', 'currency') */
715
+ readonly type: string;
716
+ /** Schema validation (Zod, Yup, or any Standard Schema) */
717
+ readonly schema?: any;
718
+ /** Default configuration for this field type */
719
+ readonly defaultConfig?: Partial<TProps>;
720
+ /** Sub-fields for complex types (e.g., Location has address, city, country) */
721
+ readonly subFields?: Array<{
722
+ key: string;
723
+ label: string;
724
+ type: string;
725
+ required?: boolean;
726
+ }>;
727
+ /** Custom serialization for complex data structures */
728
+ readonly serialize?: (value: any) => any;
729
+ /** Custom deserialization for complex data structures */
730
+ readonly deserialize?: (value: any) => any;
222
731
  }
223
732
  interface ComponentConfig<TProps = any> {
224
733
  readonly id: string;
225
- readonly type: ComponentType;
226
- readonly subType: InputType | LayoutType;
734
+ readonly type: string;
227
735
  readonly name: string;
228
736
  readonly description?: string;
229
- readonly category?: string;
230
737
  readonly renderer: ComponentRenderer<TProps>;
231
- readonly options?: ComponentOptions<TProps>;
232
- readonly validation?: ValidationConfig<TProps>;
233
738
  readonly defaultProps?: Partial<TProps>;
739
+ readonly useFieldRenderer?: boolean;
740
+ readonly validation?: FieldValidationConfig;
741
+ /** Optional builder metadata for visual editing (only used by @rilaykit/builder) */
742
+ readonly builder?: ComponentBuilderMetadata;
743
+ }
744
+ interface ConditionalBehavior {
745
+ readonly visible?: ConditionConfig;
746
+ readonly disabled?: ConditionConfig;
747
+ readonly required?: ConditionConfig;
748
+ readonly readonly?: ConditionConfig;
749
+ }
750
+ interface StepConditionalBehavior {
751
+ readonly visible?: ConditionConfig;
752
+ readonly skippable?: ConditionConfig;
234
753
  }
235
754
  interface FormFieldConfig {
236
755
  readonly id: string;
237
756
  readonly componentId: string;
238
757
  readonly props: Record<string, any>;
239
- readonly validation?: ValidationConfig;
240
- readonly conditional?: ConditionalConfig;
758
+ readonly validation?: FieldValidationConfig;
759
+ readonly conditions?: ConditionalBehavior;
241
760
  }
242
761
  interface FormFieldRow {
243
762
  readonly id: string;
244
763
  readonly fields: FormFieldConfig[];
245
764
  readonly maxColumns?: number;
246
- readonly spacing?: 'tight' | 'normal' | 'loose';
247
- readonly alignment?: 'start' | 'center' | 'end' | 'stretch';
248
765
  }
249
- interface ConditionalConfig {
250
- readonly condition: (formData: Record<string, any>) => boolean;
251
- readonly action: 'show' | 'hide' | 'disable' | 'require';
766
+ interface FormConfiguration<C extends Record<string, any> = Record<string, never>> {
767
+ readonly id: string;
768
+ readonly config: ril<C>;
769
+ readonly rows: FormFieldRow[];
770
+ readonly allFields: FormFieldConfig[];
771
+ readonly renderConfig?: FormRenderConfig;
772
+ readonly validation?: FormValidationConfig;
773
+ }
774
+ interface FormRenderConfig {
775
+ readonly rowRenderer?: FormRowRenderer;
776
+ readonly bodyRenderer?: FormBodyRenderer;
777
+ readonly submitButtonRenderer?: FormSubmitButtonRenderer;
778
+ readonly fieldRenderer?: FieldRenderer;
252
779
  }
253
- interface StepLifecycleHooks {
254
- readonly onBeforeEnter?: (stepData: any, allData: any, context: WorkflowContext) => Promise<void>;
255
- readonly onAfterLeave?: (stepData: any, allData: any, context: WorkflowContext) => Promise<boolean>;
256
- readonly onValidate?: (stepData: any, context: WorkflowContext) => Promise<ValidationResult>;
257
- readonly onTransform?: (stepData: any, context: WorkflowContext) => Promise<any>;
258
- readonly onError?: (error: Error, context: WorkflowContext) => Promise<void>;
780
+ interface FormComponentRendererProps {
781
+ children: React__default.ReactNode;
259
782
  }
783
+ interface FormRowRendererProps {
784
+ row: FormFieldRow;
785
+ children: React__default.ReactNode;
786
+ className?: string;
787
+ }
788
+ interface FormBodyRendererProps {
789
+ formConfig: FormConfiguration;
790
+ children: React__default.ReactNode;
791
+ className?: string;
792
+ }
793
+ interface FormSubmitButtonRendererProps {
794
+ isSubmitting: boolean;
795
+ onSubmit: () => void;
796
+ className?: string;
797
+ children?: React__default.ReactNode;
798
+ }
799
+ interface FieldRendererProps {
800
+ children: React__default.ReactNode;
801
+ id: string;
802
+ disabled?: boolean;
803
+ error?: ValidationError[];
804
+ isValidating?: boolean;
805
+ touched?: boolean;
806
+ [key: string]: any;
807
+ }
808
+ type FormRowRenderer = RendererChildrenFunction<FormRowRendererProps>;
809
+ type FormBodyRenderer = RendererChildrenFunction<FormBodyRendererProps>;
810
+ type FormSubmitButtonRenderer = RendererChildrenFunction<FormSubmitButtonRendererProps>;
811
+ type FieldRenderer = RendererChildrenFunction<FieldRendererProps>;
260
812
  interface WorkflowContext {
261
813
  readonly workflowId: string;
262
814
  readonly currentStepIndex: number;
@@ -266,85 +818,70 @@ interface WorkflowContext {
266
818
  readonly isFirstStep: boolean;
267
819
  readonly isLastStep: boolean;
268
820
  readonly visitedSteps: Set<string>;
269
- readonly user?: any;
270
- }
271
- interface StepPermissions {
272
- readonly requiredRoles?: string[];
273
- readonly requiredPermissions?: string[];
274
- readonly customGuard?: (user: any, context: WorkflowContext) => boolean | Promise<boolean>;
275
- }
276
- interface DynamicStepConfig {
277
- readonly resolver: (previousData: any, context: WorkflowContext) => Promise<StepConfig[]>;
278
- readonly cacheKey?: string;
279
- readonly retryPolicy?: RetryPolicy;
280
- }
281
- interface RetryPolicy {
282
- readonly maxRetries: number;
283
- readonly delayMs: number;
284
- readonly backoffMultiplier?: number;
821
+ readonly visibleVisitedSteps: Set<string>;
822
+ readonly passedSteps: Set<string>;
285
823
  }
286
- interface ConditionalBranch {
287
- readonly condition: (data: any, context: WorkflowContext) => boolean | Promise<boolean>;
288
- readonly steps: StepConfig[];
289
- readonly fallback?: StepConfig[];
824
+ interface StepDataHelper {
825
+ /**
826
+ * Set data for a specific step by step ID
827
+ */
828
+ setStepData: (stepId: string, data: Record<string, any>) => void;
829
+ /**
830
+ * Set specific field values for a step
831
+ */
832
+ setStepFields: (stepId: string, fields: Record<string, any>) => void;
833
+ /**
834
+ * Get current data for a specific step
835
+ */
836
+ getStepData: (stepId: string) => Record<string, any>;
837
+ /**
838
+ * Set field value for the next step
839
+ */
840
+ setNextStepField: (fieldId: string, value: any) => void;
841
+ /**
842
+ * Set multiple fields for the next step
843
+ */
844
+ setNextStepFields: (fields: Record<string, any>) => void;
845
+ /**
846
+ * Get all workflow data
847
+ */
848
+ getAllData: () => Record<string, any>;
849
+ /**
850
+ * Get all step configurations for reference
851
+ */
852
+ getSteps: () => StepConfig[];
290
853
  }
291
854
  interface StepConfig {
292
855
  readonly id: string;
293
856
  readonly title: string;
294
857
  readonly description?: string;
295
858
  readonly formConfig: FormConfiguration;
296
- readonly validation?: StepValidationConfig;
297
- readonly conditional?: StepConditionalConfig;
298
859
  readonly allowSkip?: boolean;
299
- readonly requiredToComplete?: boolean;
300
- readonly hooks?: StepLifecycleHooks;
301
- readonly permissions?: StepPermissions;
302
- readonly isDynamic?: boolean;
303
- readonly dynamicConfig?: DynamicStepConfig;
304
860
  readonly renderer?: CustomStepRenderer;
861
+ readonly conditions?: StepConditionalBehavior;
862
+ readonly metadata?: Record<string, any>;
863
+ readonly onAfterValidation?: (stepData: Record<string, any>, helper: StepDataHelper, context: WorkflowContext) => void | Promise<void>;
305
864
  }
306
- interface StepValidationConfig {
307
- readonly validator?: (stepData: Record<string, any>, allFormData: Record<string, any>, context: WorkflowContext) => ValidationResult | Promise<ValidationResult>;
308
- readonly validateOnStepChange?: boolean;
309
- readonly blockNextIfInvalid?: boolean;
310
- }
311
- interface StepConditionalConfig {
312
- readonly condition: (formData: Record<string, any>, context: WorkflowContext) => boolean;
313
- readonly action: 'show' | 'hide' | 'skip';
314
- }
315
- type CustomStepRenderer = (props: StepConfig) => React.ReactElement;
316
- interface WorkflowPersistenceData {
317
- readonly workflowId: string;
318
- readonly currentStepIndex: number;
319
- readonly allData: Record<string, any>;
320
- readonly metadata: {
321
- readonly timestamp: number;
322
- readonly version?: string;
323
- readonly userId?: string;
324
- readonly sessionId?: string;
865
+ type CustomStepRenderer = (props: StepConfig) => React__default.ReactElement;
866
+ interface WorkflowConfig {
867
+ readonly id: string;
868
+ readonly name: string;
869
+ readonly description?: string;
870
+ readonly steps: StepConfig[];
871
+ readonly analytics?: WorkflowAnalytics;
872
+ readonly persistence?: {
873
+ adapter: any;
874
+ options?: any;
875
+ userId?: string;
325
876
  };
877
+ readonly plugins?: WorkflowPlugin[];
878
+ readonly renderConfig?: WorkflowRenderConfig;
326
879
  }
327
- interface PersistenceAdapter {
328
- readonly name: string;
329
- save(key: string, data: WorkflowPersistenceData): Promise<void>;
330
- load(key: string): Promise<WorkflowPersistenceData | null>;
331
- remove(key: string): Promise<void>;
332
- exists(key: string): Promise<boolean>;
333
- list?(pattern?: string): Promise<string[]>;
334
- }
335
- interface PersistenceConfig {
336
- readonly adapter: PersistenceAdapter;
337
- readonly key?: string;
338
- readonly debounceMs?: number;
339
- readonly autoSave?: boolean;
340
- readonly saveOnStepChange?: boolean;
341
- readonly encryptionKey?: string;
342
- readonly maxRetries?: number;
343
- readonly retryDelayMs?: number;
344
- readonly onSave?: (data: WorkflowPersistenceData) => Promise<void> | void;
345
- readonly onLoad?: (data: WorkflowPersistenceData) => Promise<void> | void;
346
- readonly onError?: (error: Error, operation: 'save' | 'load' | 'remove') => Promise<void> | void;
347
- readonly onRetry?: (attempt: number, maxRetries: number, error: Error) => Promise<void> | void;
880
+ interface WorkflowRenderConfig {
881
+ readonly stepperRenderer?: WorkflowStepperRenderer;
882
+ readonly nextButtonRenderer?: WorkflowNextButtonRenderer;
883
+ readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer;
884
+ readonly skipButtonRenderer?: WorkflowSkipButtonRenderer;
348
885
  }
349
886
  interface WorkflowAnalytics {
350
887
  readonly onWorkflowStart?: (workflowId: string, context: WorkflowContext) => void;
@@ -353,58 +890,21 @@ interface WorkflowAnalytics {
353
890
  readonly onStepStart?: (stepId: string, timestamp: number, context: WorkflowContext) => void;
354
891
  readonly onStepComplete?: (stepId: string, duration: number, data: any, context: WorkflowContext) => void;
355
892
  readonly onStepSkip?: (stepId: string, reason: string, context: WorkflowContext) => void;
356
- readonly onValidationError?: (stepId: string, errors: ValidationError[], context: WorkflowContext) => void;
357
893
  readonly onError?: (error: Error, context: WorkflowContext) => void;
358
894
  }
359
- interface WorkflowOptimizations {
360
- readonly preloadNextStep?: boolean;
361
- readonly cacheValidation?: boolean;
362
- readonly virtualizeSteps?: boolean;
363
- readonly lazyLoadComponents?: boolean;
364
- readonly maxConcurrentRequests?: number;
365
- }
366
- interface WorkflowVersion {
367
- readonly version: string;
368
- readonly migrationStrategy?: (oldData: any, newConfig: any) => any;
369
- readonly compatibilityMode?: boolean;
370
- }
371
- interface WorkflowHooks {
372
- readonly onStepChange?: (from: string, to: string, context: WorkflowContext) => void;
373
- readonly onDataChange?: (data: any, context: WorkflowContext) => void;
374
- readonly onValidation?: (result: ValidationResult, context: WorkflowContext) => void;
375
- }
376
895
  interface WorkflowPlugin {
377
896
  readonly name: string;
378
897
  readonly version?: string;
379
898
  readonly install: (workflow: any) => void;
380
- readonly hooks?: WorkflowHooks;
381
899
  readonly dependencies?: string[];
382
900
  }
383
- interface WorkflowConfig {
384
- readonly id: string;
385
- readonly name: string;
386
- readonly description?: string;
387
- readonly steps: StepConfig[];
388
- readonly branches?: ConditionalBranch[];
389
- readonly navigation?: NavigationConfig;
390
- readonly persistence?: PersistenceConfig;
391
- readonly completion?: CompletionConfig;
392
- readonly analytics?: WorkflowAnalytics;
393
- readonly optimizations?: WorkflowOptimizations;
394
- readonly version?: WorkflowVersion;
395
- readonly plugins?: WorkflowPlugin[];
396
- readonly renderConfig?: WorkflowRenderConfig;
397
- }
398
- interface NavigationConfig {
399
- readonly allowBackNavigation?: boolean;
400
- readonly allowStepSkipping?: boolean;
401
- readonly showProgress?: boolean;
402
- readonly customNavigation?: boolean;
403
- }
404
- interface CompletionConfig {
405
- readonly onComplete?: (formData: Record<string, any>) => void | Promise<void>;
406
- readonly confirmBeforeSubmit?: boolean;
407
- readonly customCompletionStep?: any;
901
+ interface WorkflowComponentRendererBaseProps {
902
+ children?: React__default.ReactNode;
903
+ className?: string;
904
+ currentStep: StepConfig;
905
+ stepData: Record<string, any>;
906
+ allData: Record<string, any>;
907
+ context: WorkflowContext;
408
908
  }
409
909
  interface WorkflowStepperRendererProps {
410
910
  readonly steps: StepConfig[];
@@ -413,224 +913,487 @@ interface WorkflowStepperRendererProps {
413
913
  readonly onStepClick?: (stepIndex: number) => void;
414
914
  readonly className?: string;
415
915
  }
416
- interface WorkflowNavigationRendererProps {
417
- readonly currentStep: StepConfig;
418
- readonly context: WorkflowContext;
419
- readonly canGoNext: boolean;
420
- readonly canGoPrevious: boolean;
421
- readonly canSkip: boolean;
422
- readonly isSubmitting: boolean;
423
- readonly onNext: (event?: React.FormEvent) => void;
424
- readonly onPrevious: (event?: React.FormEvent) => void;
425
- readonly onSkip: (event?: React.FormEvent) => void;
426
- readonly onSubmit: (event?: React.FormEvent) => void;
427
- readonly className?: string;
916
+ type WorkflowNextButtonRendererProps = WorkflowComponentRendererBaseProps & {
917
+ isLastStep: boolean;
918
+ canGoNext: boolean;
919
+ isSubmitting: boolean;
920
+ onSubmit: (event?: React__default.FormEvent) => void;
921
+ };
922
+ type WorkflowPreviousButtonRendererProps = WorkflowComponentRendererBaseProps & {
923
+ canGoPrevious: boolean;
924
+ isSubmitting: boolean;
925
+ onPrevious: (event?: React__default.FormEvent) => void;
926
+ };
927
+ type WorkflowSkipButtonRendererProps = WorkflowComponentRendererBaseProps & {
928
+ canSkip: boolean;
929
+ isSubmitting: boolean;
930
+ onSkip: (event?: React__default.FormEvent) => void;
931
+ };
932
+ type WorkflowStepperRenderer = RendererChildrenFunction<WorkflowStepperRendererProps>;
933
+ type WorkflowNextButtonRenderer = RendererChildrenFunction<WorkflowNextButtonRendererProps>;
934
+ type WorkflowPreviousButtonRenderer = RendererChildrenFunction<WorkflowPreviousButtonRendererProps>;
935
+ type WorkflowSkipButtonRenderer = RendererChildrenFunction<WorkflowSkipButtonRendererProps>;
936
+ interface PerformanceMetrics {
937
+ readonly timestamp: number;
938
+ readonly duration: number;
939
+ readonly memoryUsage?: number;
940
+ readonly renderCount?: number;
941
+ readonly reRenderCount?: number;
428
942
  }
429
- type WorkflowStepperRenderer = (props: WorkflowStepperRendererProps) => React.ReactElement;
430
- type WorkflowNavigationRenderer = (props: WorkflowNavigationRendererProps) => React.ReactElement;
431
- interface WorkflowRenderConfig {
432
- readonly stepperRenderer?: WorkflowStepperRenderer;
433
- readonly navigationRenderer?: WorkflowNavigationRenderer;
943
+ interface ComponentPerformanceMetrics extends PerformanceMetrics {
944
+ readonly componentId: string;
945
+ readonly componentType: string;
946
+ readonly propsSize?: number;
947
+ readonly childrenCount?: number;
434
948
  }
435
- interface FormRowRendererProps {
436
- row: FormFieldRow;
437
- children: React.ReactNode;
438
- className?: string;
439
- spacing?: 'tight' | 'normal' | 'loose';
440
- alignment?: 'start' | 'center' | 'end' | 'stretch';
949
+ interface FormPerformanceMetrics extends PerformanceMetrics {
950
+ readonly formId: string;
951
+ readonly fieldCount: number;
952
+ readonly validationDuration: number;
953
+ readonly renderDuration: number;
954
+ readonly validationErrors: number;
441
955
  }
442
- interface FormBodyRendererProps {
443
- formConfig: FormConfiguration;
444
- children: React.ReactNode;
445
- className?: string;
956
+ interface WorkflowPerformanceMetrics extends PerformanceMetrics {
957
+ readonly workflowId: string;
958
+ readonly stepCount: number;
959
+ readonly currentStepIndex: number;
960
+ readonly navigationDuration: number;
961
+ readonly persistenceDuration?: number;
962
+ readonly conditionEvaluationDuration: number;
446
963
  }
447
- interface FormSubmitButtonRendererProps {
448
- isSubmitting: boolean;
449
- isValid: boolean;
450
- isDirty: boolean;
451
- onSubmit: () => void;
452
- className?: string;
453
- children?: React.ReactNode;
964
+ type MonitoringEventType = 'component_render' | 'component_update' | 'form_validation' | 'form_submission' | 'workflow_navigation' | 'workflow_persistence' | 'condition_evaluation' | 'error' | 'performance_warning';
965
+ interface MonitoringEvent {
966
+ readonly id: string;
967
+ readonly type: MonitoringEventType;
968
+ readonly timestamp: number;
969
+ readonly source: string;
970
+ readonly data: Record<string, any>;
971
+ readonly metrics?: PerformanceMetrics;
972
+ readonly severity?: 'low' | 'medium' | 'high' | 'critical';
454
973
  }
455
- type FormRowRenderer = (props: FormRowRendererProps) => React.ReactElement;
456
- type FormBodyRenderer = (props: FormBodyRendererProps) => React.ReactElement;
457
- type FormSubmitButtonRenderer = (props: FormSubmitButtonRendererProps) => React.ReactElement;
458
- interface FormRenderConfig {
459
- readonly rowRenderer?: FormRowRenderer;
460
- readonly bodyRenderer?: FormBodyRenderer;
461
- readonly submitButtonRenderer?: FormSubmitButtonRenderer;
974
+ interface ErrorMonitoringEvent extends MonitoringEvent {
975
+ readonly type: 'error';
976
+ readonly error: Error;
977
+ readonly stack?: string;
978
+ readonly context?: ValidationContext | WorkflowContext;
462
979
  }
463
- interface FormConfiguration {
464
- readonly id: string;
465
- readonly schema?: any;
466
- readonly config: ril;
467
- readonly rows: FormFieldRow[];
468
- readonly allFields: FormFieldConfig[];
469
- readonly renderConfig?: FormRenderConfig;
980
+ interface PerformanceWarningEvent extends MonitoringEvent {
981
+ readonly type: 'performance_warning';
982
+ readonly threshold: number;
983
+ readonly actualValue: number;
984
+ readonly recommendation?: string;
985
+ }
986
+ interface MonitoringConfig {
987
+ readonly enabled: boolean;
988
+ readonly enablePerformanceTracking?: boolean;
989
+ readonly enableErrorTracking?: boolean;
990
+ readonly enableMemoryTracking?: boolean;
991
+ readonly performanceThresholds?: PerformanceThresholds;
992
+ readonly sampleRate?: number;
993
+ readonly bufferSize?: number;
994
+ readonly flushInterval?: number;
995
+ readonly onEvent?: (event: MonitoringEvent) => void;
996
+ readonly onBatch?: (events: MonitoringEvent[]) => void;
997
+ readonly onError?: (error: Error) => void;
998
+ }
999
+ interface PerformanceThresholds {
1000
+ readonly componentRenderTime?: number;
1001
+ readonly formValidationTime?: number;
1002
+ readonly workflowNavigationTime?: number;
1003
+ readonly memoryUsage?: number;
1004
+ readonly reRenderCount?: number;
1005
+ }
1006
+ interface MonitoringAdapter {
1007
+ readonly name: string;
1008
+ readonly version?: string;
1009
+ send: (events: MonitoringEvent[]) => Promise<void>;
1010
+ flush?: () => Promise<void>;
1011
+ configure?: (config: Record<string, any>) => void;
1012
+ }
1013
+ interface ConsoleMonitoringAdapter extends MonitoringAdapter {
1014
+ readonly name: 'console';
1015
+ readonly logLevel?: 'debug' | 'info' | 'warn' | 'error';
1016
+ }
1017
+ interface RemoteMonitoringAdapter extends MonitoringAdapter {
1018
+ readonly name: 'remote';
1019
+ readonly endpoint: string;
1020
+ readonly apiKey?: string;
1021
+ readonly headers?: Record<string, string>;
1022
+ readonly batchSize?: number;
1023
+ readonly retryAttempts?: number;
1024
+ }
1025
+ interface MonitoringContext {
1026
+ readonly sessionId: string;
1027
+ readonly userId?: string;
1028
+ readonly userAgent?: string;
1029
+ readonly url?: string;
1030
+ readonly environment: 'development' | 'production' | 'test';
1031
+ readonly version?: string;
1032
+ readonly metadata?: Record<string, any>;
1033
+ }
1034
+ interface PerformanceProfiler {
1035
+ start: (label: string, metadata?: Record<string, any>) => void;
1036
+ end: (label: string) => PerformanceMetrics | null;
1037
+ mark: (name: string) => void;
1038
+ measure: (name: string, startMark: string, endMark?: string) => number;
1039
+ getMetrics: (label: string) => PerformanceMetrics | null;
1040
+ getAllMetrics: () => Record<string, PerformanceMetrics>;
1041
+ clear: (label?: string) => void;
1042
+ }
1043
+ interface EnhancedWorkflowAnalytics extends WorkflowAnalytics {
1044
+ readonly monitoring?: MonitoringConfig;
1045
+ readonly onPerformanceWarning?: (event: PerformanceWarningEvent) => void;
1046
+ readonly onMemoryLeak?: (metrics: ComponentPerformanceMetrics) => void;
1047
+ }
1048
+ interface EnhancedFormAnalytics {
1049
+ readonly onFormRender?: (metrics: FormPerformanceMetrics) => void;
1050
+ readonly onFormValidation?: (metrics: FormPerformanceMetrics) => void;
1051
+ readonly onFormSubmission?: (metrics: FormPerformanceMetrics) => void;
1052
+ readonly onFieldChange?: (fieldId: string, metrics: ComponentPerformanceMetrics) => void;
1053
+ readonly monitoring?: MonitoringConfig;
470
1054
  }
471
1055
 
1056
+ declare function ComponentRendererWrapper<TProps = any>({ children, renderAs, renderer, name, props: baseProps, }: ComponentRendererWrapperProps<TProps>): React$1.ReactNode;
1057
+
472
1058
  /**
473
- * Create a Zod-based validator
474
- * @param schema - Zod schema to validate against
475
- * @returns Validator function
1059
+ * Utility for merging partial configurations into existing objects
1060
+ * Eliminates repetitive object spread operations
476
1061
  */
477
- declare const createZodValidator: <T>(schema: z.ZodSchema<T>) => ValidatorFunction;
1062
+ declare function mergeInto<T>(target: T, partial: Partial<T>): T;
478
1063
  /**
479
- * Create a custom validator from a validation function
480
- * @param validationFn - Function that returns boolean, string, or Promise
481
- * @returns Validator function
1064
+ * Validates uniqueness of identifiers and throws descriptive errors
482
1065
  */
483
- declare const createCustomValidator: (validationFn: (value: any, context: ValidationContext) => boolean | string | Promise<boolean | string>) => ValidatorFunction;
1066
+ declare function ensureUnique(ids: string[], entityName: string): void;
484
1067
  /**
485
- * Combine multiple validators
486
- * @param validators - Array of validators to combine
487
- * @param mode - 'all' (all must pass) or 'any' (at least one must pass)
488
- * @returns Combined validator function
1068
+ * Validates required fields exist in configurations
489
1069
  */
490
- declare const combineValidators: (validators: ValidatorFunction[], mode?: "all" | "any") => ValidatorFunction;
1070
+ declare function validateRequired<T>(items: T[], requiredFields: (keyof T)[], entityName: string): void;
491
1071
  /**
492
- * Create a conditional validator that only runs when condition is met
493
- * @param condition - Function to determine if validation should run
494
- * @param validator - Validator to run when condition is true
495
- * @returns Conditional validator function
1072
+ * Auto-generates IDs when not provided
496
1073
  */
497
- declare const createConditionalValidator: (condition: (value: any, context: ValidationContext) => boolean, validator: ValidatorFunction) => ValidatorFunction;
1074
+ declare class IdGenerator {
1075
+ private counters;
1076
+ next(prefix: string): string;
1077
+ reset(prefix?: string): void;
1078
+ }
498
1079
  /**
499
- * Common validation patterns
1080
+ * Polymorphic helper for handling single items or arrays
500
1081
  */
501
- declare const commonValidators: {
502
- /**
503
- * Required field validator
504
- */
505
- required: (message?: string) => ValidatorFunction;
1082
+ declare function normalizeToArray<T>(input: T | T[]): T[];
1083
+ /**
1084
+ * Deep clone utility for configuration objects
1085
+ */
1086
+ declare function deepClone<T>(obj: T): T;
1087
+ /**
1088
+ * Generic configuration merger with type safety
1089
+ */
1090
+ declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?: (keyof T)[]): T;
1091
+
1092
+ declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode;
1093
+
1094
+ /**
1095
+ * @fileoverview Clean validation utilities for Standard Schema
1096
+ *
1097
+ * This module provides utility functions for working with validation results
1098
+ * and managing validation contexts using Standard Schema exclusively.
1099
+ */
1100
+
1101
+ /**
1102
+ * Creates a validation result object
1103
+ *
1104
+ * @param isValid - Whether the validation passed
1105
+ * @param errors - Array of validation errors (empty if valid)
1106
+ * @returns A complete ValidationResult object
1107
+ *
1108
+ * @example
1109
+ * ```typescript
1110
+ * const result = createValidationResult(false, [
1111
+ * { message: 'Email is required', code: 'REQUIRED' }
1112
+ * ]);
1113
+ * ```
1114
+ */
1115
+ declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult;
1116
+ /**
1117
+ * Creates a successful validation result
1118
+ *
1119
+ * @returns A successful ValidationResult with no errors
1120
+ *
1121
+ * @example
1122
+ * ```typescript
1123
+ * const success = createSuccessResult();
1124
+ * ```
1125
+ */
1126
+ declare function createSuccessResult(): ValidationResult;
1127
+ /**
1128
+ * Creates a failed validation result with a single error
1129
+ *
1130
+ * @param message - The error message
1131
+ * @param code - Optional error code
1132
+ * @param path - Optional field path
1133
+ * @returns A failed ValidationResult
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * const error = createErrorResult('Email is invalid', 'INVALID_EMAIL');
1138
+ * ```
1139
+ */
1140
+ declare function createErrorResult(message: string, code?: string, path?: string): ValidationResult;
1141
+ /**
1142
+ * Creates a validation context object
1143
+ *
1144
+ * @param options - Context configuration options
1145
+ * @returns A complete ValidationContext object
1146
+ *
1147
+ * @example
1148
+ * ```typescript
1149
+ * const context = createValidationContext({
1150
+ * fieldId: 'email',
1151
+ * formId: 'registration',
1152
+ * allFormData: { email: 'test@example.com', name: 'John' }
1153
+ * });
1154
+ * ```
1155
+ */
1156
+ declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext;
1157
+
1158
+ /**
1159
+ * Built-in validators implementing Standard Schema interface
1160
+ * All RilayKit validators now implement Standard Schema for consistency
1161
+ */
1162
+
1163
+ /**
1164
+ * Required field validator - Standard Schema implementation
1165
+ */
1166
+ declare function required(message?: string): StandardSchemaV1<any>;
1167
+ /**
1168
+ * Email validation - Standard Schema implementation
1169
+ */
1170
+ declare function email(message?: string): StandardSchemaV1<string>;
1171
+ /**
1172
+ * URL validation - Standard Schema implementation
1173
+ */
1174
+ declare function url(message?: string): StandardSchemaV1<string>;
1175
+ /**
1176
+ * Minimum length validation - Standard Schema implementation
1177
+ */
1178
+ declare function minLength(min: number, message?: string): StandardSchemaV1<string>;
1179
+ /**
1180
+ * Maximum length validation - Standard Schema implementation
1181
+ */
1182
+ declare function maxLength(max: number, message?: string): StandardSchemaV1<string>;
1183
+ /**
1184
+ * Pattern validation - Standard Schema implementation
1185
+ */
1186
+ declare function pattern(regex: RegExp, message?: string): StandardSchemaV1<string>;
1187
+ /**
1188
+ * Number validation - Standard Schema implementation
1189
+ */
1190
+ declare function number(message?: string): StandardSchemaV1<number>;
1191
+ /**
1192
+ * Minimum value validation - Standard Schema implementation
1193
+ */
1194
+ declare function min(minValue: number, message?: string): StandardSchemaV1<number>;
1195
+ /**
1196
+ * Maximum value validation - Standard Schema implementation
1197
+ */
1198
+ declare function max(maxValue: number, message?: string): StandardSchemaV1<number>;
1199
+ /**
1200
+ * Custom validator - Standard Schema implementation
1201
+ */
1202
+ declare function custom<T>(fn: (value: T) => boolean, message?: string): StandardSchemaV1<T>;
1203
+ /**
1204
+ * Async validator - Standard Schema implementation
1205
+ */
1206
+ declare function async<T>(fn: (value: T) => Promise<boolean>, message?: string): StandardSchemaV1<T>;
1207
+ /**
1208
+ * Utility to combine multiple Standard Schema validators
1209
+ * This creates a new Standard Schema that runs all validations
1210
+ */
1211
+ declare function combine<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
1212
+
1213
+ /**
1214
+ * Unified validation utilities for Standard Schema only
1215
+ * These replace the old validator-based system with a clean Standard Schema approach
1216
+ */
1217
+
1218
+ /**
1219
+ * Checks if a value implements the Standard Schema interface
1220
+ */
1221
+ declare function isStandardSchema(value: any): value is StandardSchema;
1222
+ /**
1223
+ * Validates a value using a Standard Schema
1224
+ */
1225
+ declare function validateWithStandardSchema<T extends StandardSchema>(schema: T, value: unknown): Promise<ValidationResult>;
1226
+ /**
1227
+ * Utility to extract input type from Standard Schema at runtime (for debugging)
1228
+ */
1229
+ declare function getSchemaInfo(schema: StandardSchema): {
1230
+ vendor: string;
1231
+ version: number;
1232
+ hasTypes: boolean;
1233
+ };
1234
+ /**
1235
+ * Type guard to check if a schema has type information
1236
+ */
1237
+ declare function hasSchemaTypes<T extends StandardSchema>(schema: T): schema is T & {
1238
+ '~standard': {
1239
+ types: NonNullable<T['~standard']['types']>;
1240
+ };
1241
+ };
1242
+ /**
1243
+ * Validates a value using unified validation config
1244
+ * Handles single schemas, arrays of schemas, and combines results
1245
+ */
1246
+ declare function validateWithUnifiedConfig<T>(config: FieldValidationConfig<T>, value: T, _context: ValidationContext): Promise<ValidationResult>;
1247
+ /**
1248
+ * Validates form data using unified validation config
1249
+ */
1250
+ declare function validateFormWithUnifiedConfig<T extends Record<string, any>>(config: FormValidationConfig<T>, formData: T, _context: ValidationContext): Promise<ValidationResult>;
1251
+ /**
1252
+ * Checks if a field validation config has any validation rules
1253
+ */
1254
+ declare function hasUnifiedValidation(config: FieldValidationConfig | FormValidationConfig): boolean;
1255
+ /**
1256
+ * Combines multiple Standard Schemas into a single schema
1257
+ * This is useful for combining built-in validators with external schemas
1258
+ */
1259
+ declare function combineSchemas<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>;
1260
+ /**
1261
+ * Utility to create a Standard Schema from any validation function
1262
+ * This helps migrate existing validators to Standard Schema
1263
+ */
1264
+ declare function createStandardValidator<T>(validateFn: (value: T, context?: ValidationContext) => ValidationResult | Promise<ValidationResult>, vendor?: string): StandardSchemaV1<T>;
1265
+ /**
1266
+ * Type guard to check if value is a Standard Schema or array of Standard Schemas
1267
+ */
1268
+ declare function isValidationRule(value: any): value is StandardSchema | StandardSchema[];
1269
+ /**
1270
+ * Normalizes validation config to always return an array of Standard Schemas
1271
+ */
1272
+ declare function normalizeValidationRules<T>(validate: StandardSchema<T> | StandardSchema<T>[] | undefined): StandardSchema<T>[];
1273
+
1274
+ /**
1275
+ * Core monitoring system for Rilay
1276
+ * Tracks performance metrics, events, and errors across forms and workflows
1277
+ */
1278
+ declare class RilayMonitor {
1279
+ private config;
1280
+ private context;
1281
+ private adapters;
1282
+ private eventBuffer;
1283
+ private flushTimer?;
1284
+ private profiler;
1285
+ constructor(config: MonitoringConfig, context?: Partial<MonitoringContext>);
506
1286
  /**
507
- * Email validation
1287
+ * Add a monitoring adapter
508
1288
  */
509
- email: (message?: string) => ValidatorFunction;
1289
+ addAdapter(adapter: MonitoringAdapter): void;
510
1290
  /**
511
- * Minimum length validation
1291
+ * Remove a monitoring adapter
512
1292
  */
513
- minLength: (min: number, message?: string) => ValidatorFunction;
1293
+ removeAdapter(adapterName: string): void;
514
1294
  /**
515
- * Maximum length validation
1295
+ * Track a monitoring event
516
1296
  */
517
- maxLength: (max: number, message?: string) => ValidatorFunction;
1297
+ track(type: MonitoringEventType, source: string, data: Record<string, any>, metrics?: PerformanceMetrics, severity?: 'low' | 'medium' | 'high' | 'critical'): void;
518
1298
  /**
519
- * Pattern/regex validation
1299
+ * Track an error
520
1300
  */
521
- pattern: (regex: RegExp, message?: string) => ValidatorFunction;
1301
+ trackError(error: Error, source: string, context?: any): void;
522
1302
  /**
523
- * Number range validation
1303
+ * Get the performance profiler
524
1304
  */
525
- numberRange: (min?: number, max?: number, message?: string) => ValidatorFunction;
1305
+ getProfiler(): PerformanceProfiler;
526
1306
  /**
527
- * URL validation
1307
+ * Update monitoring context
528
1308
  */
529
- url: (message?: string) => ValidatorFunction;
1309
+ updateContext(updates: Partial<MonitoringContext>): void;
530
1310
  /**
531
- * Phone number validation (basic)
1311
+ * Flush all buffered events
532
1312
  */
533
- phoneNumber: (message?: string) => ValidatorFunction;
1313
+ flush(): Promise<void>;
534
1314
  /**
535
- * Custom async validation with debouncing
1315
+ * Destroy the monitor and clean up resources
536
1316
  */
537
- asyncValidation: (asyncFn: (value: any, context: ValidationContext) => Promise<boolean | string>, debounceMs?: number) => ValidatorFunction;
538
- };
1317
+ destroy(): Promise<void>;
1318
+ private startFlushTimer;
1319
+ private checkPerformanceThresholds;
1320
+ private createPerformanceWarning;
1321
+ }
1322
+ /**
1323
+ * Initialize global monitoring
1324
+ */
1325
+ declare function initializeMonitoring(config: MonitoringConfig, context?: Partial<MonitoringContext>): RilayMonitor;
539
1326
  /**
540
- * Utility to create validation result
541
- * @param isValid - Whether validation passed
542
- * @param errors - Array of errors (optional)
543
- * @param warnings - Array of warnings (optional)
544
- * @returns ValidationResult object
1327
+ * Get the global monitor instance
545
1328
  */
546
- declare const createValidationResult: (isValid: boolean, errors?: ValidationError[], warnings?: ValidationError[]) => ValidationResult;
1329
+ declare function getGlobalMonitor(): RilayMonitor | null;
547
1330
  /**
548
- * Utility to create validation error
549
- * @param code - Error code
550
- * @param message - Error message
551
- * @param path - Error path (optional)
552
- * @returns ValidationError object
1331
+ * Destroy global monitoring
553
1332
  */
554
- declare const createValidationError: (code: string, message: string, path?: string[]) => ValidationError;
1333
+ declare function destroyGlobalMonitoring(): Promise<void>;
555
1334
 
556
1335
  /**
557
- * LocalStorage persistence adapter
558
- * Perfect for client-side persistence across browser sessions
1336
+ * Console monitoring adapter
1337
+ * Logs events to the browser console
559
1338
  */
560
- declare class LocalStorageAdapter implements PersistenceAdapter {
561
- readonly name = "localStorage";
562
- save(key: string, data: WorkflowPersistenceData): Promise<void>;
563
- load(key: string): Promise<WorkflowPersistenceData | null>;
564
- remove(key: string): Promise<void>;
565
- exists(key: string): Promise<boolean>;
566
- list(pattern?: string): Promise<string[]>;
567
- }
568
- /**
569
- * SessionStorage persistence adapter
570
- * Perfect for temporary persistence within a single browser session
571
- */
572
- declare class SessionStorageAdapter implements PersistenceAdapter {
573
- readonly name = "sessionStorage";
574
- save(key: string, data: WorkflowPersistenceData): Promise<void>;
575
- load(key: string): Promise<WorkflowPersistenceData | null>;
576
- remove(key: string): Promise<void>;
577
- exists(key: string): Promise<boolean>;
578
- list(pattern?: string): Promise<string[]>;
579
- }
580
- /**
581
- * In-Memory persistence adapter
582
- * Perfect for testing or temporary workflows
583
- */
584
- declare class MemoryAdapter implements PersistenceAdapter {
585
- readonly name = "memory";
586
- private storage;
587
- save(key: string, data: WorkflowPersistenceData): Promise<void>;
588
- load(key: string): Promise<WorkflowPersistenceData | null>;
589
- remove(key: string): Promise<void>;
590
- exists(key: string): Promise<boolean>;
591
- list(pattern?: string): Promise<string[]>;
592
- clear(): void;
1339
+ declare class ConsoleAdapter implements ConsoleMonitoringAdapter {
1340
+ readonly name = "console";
1341
+ readonly logLevel: 'debug' | 'info' | 'warn' | 'error';
1342
+ constructor(logLevel?: 'debug' | 'info' | 'warn' | 'error');
1343
+ send(events: MonitoringEvent[]): Promise<void>;
1344
+ private logEvent;
1345
+ private shouldLog;
593
1346
  }
594
1347
  /**
595
- * Composite adapter that can use multiple adapters with fallback
596
- * Perfect for robust persistence with primary/backup strategies
1348
+ * Remote monitoring adapter
1349
+ * Sends events to a remote endpoint
597
1350
  */
598
- declare class CompositeAdapter implements PersistenceAdapter {
599
- private primary;
600
- private fallbacks;
601
- readonly name = "composite";
602
- constructor(primary: PersistenceAdapter, fallbacks?: PersistenceAdapter[]);
603
- save(key: string, data: WorkflowPersistenceData): Promise<void>;
604
- load(key: string): Promise<WorkflowPersistenceData | null>;
605
- remove(key: string): Promise<void>;
606
- exists(key: string): Promise<boolean>;
607
- list(pattern?: string): Promise<string[]>;
1351
+ declare class RemoteAdapter implements RemoteMonitoringAdapter {
1352
+ readonly name = "remote";
1353
+ readonly endpoint: string;
1354
+ readonly apiKey?: string;
1355
+ readonly headers: Record<string, string>;
1356
+ readonly batchSize: number;
1357
+ readonly retryAttempts: number;
1358
+ private eventQueue;
1359
+ private isProcessing;
1360
+ constructor(config: {
1361
+ endpoint: string;
1362
+ apiKey?: string;
1363
+ headers?: Record<string, string>;
1364
+ batchSize?: number;
1365
+ retryAttempts?: number;
1366
+ });
1367
+ send(events: MonitoringEvent[]): Promise<void>;
1368
+ flush(): Promise<void>;
1369
+ configure(config: Record<string, any>): void;
1370
+ private processQueue;
1371
+ private sendBatch;
1372
+ private delay;
608
1373
  }
609
-
610
1374
  /**
611
- * Utility functions to create persistence configurations easily
1375
+ * Local storage adapter for offline support
612
1376
  */
613
- declare const persistence: {
614
- /**
615
- * Create a localStorage-based persistence configuration
616
- */
617
- localStorage(options?: Partial<PersistenceConfig>): PersistenceConfig;
618
- /**
619
- * Create a sessionStorage-based persistence configuration
620
- */
621
- sessionStorage(options?: Partial<PersistenceConfig>): PersistenceConfig;
622
- /**
623
- * Create an in-memory persistence configuration (for testing)
624
- */
625
- memory(options?: Partial<PersistenceConfig>): PersistenceConfig;
626
- /**
627
- * Create a custom persistence configuration
628
- */
629
- custom(adapter: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig;
630
- };
1377
+ declare class LocalStorageAdapter implements MonitoringAdapter {
1378
+ readonly name = "localStorage";
1379
+ private readonly storageKey;
1380
+ private readonly maxEvents;
1381
+ constructor(maxEvents?: number);
1382
+ send(events: MonitoringEvent[]): Promise<void>;
1383
+ flush(): Promise<void>;
1384
+ getStoredEvents(): MonitoringEvent[];
1385
+ clearStoredEvents(): void;
1386
+ getEventCount(): number;
1387
+ }
631
1388
  /**
632
- * Utility to create persistence configurations with retry logic
1389
+ * Development adapter that provides detailed logging
633
1390
  */
634
- declare function createResilientPersistence(primary: PersistenceAdapter, fallback?: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig;
1391
+ declare class DevelopmentAdapter implements MonitoringAdapter {
1392
+ readonly name = "development";
1393
+ private readonly console;
1394
+ send(events: MonitoringEvent[]): Promise<void>;
1395
+ private logPerformanceSummary;
1396
+ private logErrorSummary;
1397
+ }
635
1398
 
636
- export { type CompletionConfig, type ComponentConfig, type ComponentOptions, type ComponentRenderProps, type ComponentRenderer, type ComponentType, CompositeAdapter, type ConditionalBranch, type ConditionalConfig, type CustomStepRenderer, type DynamicStepConfig, type FormBodyRenderer, type FormBodyRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type InputType, type LayoutType, LocalStorageAdapter, MemoryAdapter, type NavigationConfig, type PersistenceAdapter, type PersistenceConfig, type RetryPolicy, type RilayLicenseConfig, SessionStorageAdapter, type StepConditionalConfig, type StepConfig, type StepLifecycleHooks, type StepPermissions, type StepValidationConfig, type ValidationConfig, type ValidationContext, type ValidationError, type ValidationResult, type ValidationWarning, type ValidatorFunction, type WorkflowAnalytics, type WorkflowConfig, type WorkflowContext, type WorkflowHooks, type WorkflowNavigationRenderer, type WorkflowNavigationRendererProps, type WorkflowOptimizations, type WorkflowPersistenceData, type WorkflowPlugin, type WorkflowRenderConfig, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, type WorkflowVersion, combineValidators, commonValidators, createConditionalValidator, createCustomValidator, createResilientPersistence, createValidationError, createValidationResult, createZodValidator, persistence, ril };
1399
+ export { type ComponentBuilderMetadata, type ComponentConfig, type ComponentPerformanceMetrics, type ComponentRenderProps, type ComponentRenderPropsV2, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type ConditionBuilder as Condition, type ConditionBuilder, type ConditionConfig, ConditionDependencyGraph, type ConditionEvaluator, type ConditionOperator, type ConditionValue, type ConditionalBehavior, ConsoleAdapter, type ConsoleMonitoringAdapter, type CustomStepRenderer, DevelopmentAdapter, type EnhancedFormAnalytics, type EnhancedWorkflowAnalytics, type ErrorMonitoringEvent, type FieldActions, type FieldConditions, type FieldContext, type FieldRenderer, type FieldRendererProps, type FieldRendererPropsV2, type FieldSchemaDefinition, type FieldState, type FieldValidationConfig, type FieldValidator, type FormActions, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormContextValue, type FormFieldConfig, type FormFieldRow, type FormPerformanceMetrics, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormState, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormSubmitButtonRendererPropsV2, type FormValidationConfig, type FormValidator, IdGenerator, type InferInput, type InferOutput, LocalStorageAdapter, type LogicalOperator, type MonitoringAdapter, type MonitoringConfig, type MonitoringContext, type MonitoringEvent, type MonitoringEventType, type PerformanceMetrics, type PerformanceProfiler, type PerformanceThresholds, type PerformanceWarningEvent, type PropertyEditorDefinition, type PropertyEditorProps, RemoteAdapter, type RemoteMonitoringAdapter, type RendererChildrenFunction, type RilayInstance, type RilayLicenseConfig, RilayMonitor, type StandardSchema, type StepConditionalBehavior, type StepConfig, type StepDataHelper, type ValidationContext, type ValidationError, type ValidationResult, type ValidationState, type WorkflowAnalytics, type WorkflowButtonRendererPropsV2, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNavigationState, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPerformanceMetrics, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowProgressState, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepContext, type WorkflowStepState, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combine, combineSchemas, configureObject, createErrorResult, createStandardValidator, createSuccessResult, createValidationContext, createValidationResult, custom, deepClone, destroyGlobalMonitoring, email, ensureUnique, evaluateCondition, extractAllDependencies, extractConditionDependencies, getGlobalMonitor, getSchemaInfo, hasSchemaTypes, hasUnifiedValidation, initializeMonitoring, isStandardSchema, isValidationRule, max, maxLength, mergeInto, min, minLength, normalizeToArray, normalizeValidationRules, number, pattern, required, resolveRendererChildren, ril, url, validateFormWithUnifiedConfig, validateRequired, validateWithStandardSchema, validateWithUnifiedConfig, when };