@rilaykit/core 0.1.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.
@@ -0,0 +1,1399 @@
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import * as React$1 from 'react';
3
+ import React__default from 'react';
4
+
5
+ /**
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
+ * ```
25
+ */
26
+ declare class ConditionDependencyGraph {
27
+ /**
28
+ * Maps field IDs to their dependencies (fields they depend on)
29
+ * fieldId -> Set of field paths it depends on
30
+ */
31
+ private readonly fieldDependencies;
32
+ /**
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
35
+ */
36
+ private readonly reverseDependencies;
37
+ /**
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)
42
+ */
43
+ addField(fieldId: string, conditions?: ConditionalBehavior): void;
44
+ /**
45
+ * Removes a field from the graph.
46
+ *
47
+ * @param fieldId - The ID of the field to remove
48
+ */
49
+ removeField(fieldId: string): void;
50
+ /**
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
58
+ */
59
+ getAffectedFields(changedPath: string): string[];
60
+ /**
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
65
+ */
66
+ getAffectedFieldsMultiple(changedPaths: string[]): string[];
67
+ /**
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
72
+ */
73
+ getDependencies(fieldId: string): string[];
74
+ /**
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
79
+ */
80
+ hasDependencies(fieldId: string): boolean;
81
+ /**
82
+ * Gets all fields in the graph.
83
+ *
84
+ * @returns Array of all field IDs
85
+ */
86
+ getAllFields(): string[];
87
+ /**
88
+ * Gets all unique dependency paths in the graph.
89
+ *
90
+ * @returns Array of all field paths that are dependencies
91
+ */
92
+ getAllDependencyPaths(): string[];
93
+ /**
94
+ * Clears the entire graph.
95
+ */
96
+ clear(): void;
97
+ /**
98
+ * Gets the size of the graph (number of fields).
99
+ */
100
+ get size(): number;
101
+ /**
102
+ * Creates a debug representation of the graph.
103
+ * Useful for development and testing.
104
+ */
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;
224
+ /**
225
+ * Static factory method to create a new ril instance
226
+ */
227
+ static create<CT>(): ril<CT>;
228
+ /**
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
+ * ```
249
+ */
250
+ addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): ril<C & {
251
+ [K in NewType]: TProps;
252
+ }>;
253
+ /**
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
+ * ```
279
+ */
280
+ configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): ril<C>;
281
+ /**
282
+ * Configuration getters
283
+ */
284
+ getFormRenderConfig(): FormRenderConfig;
285
+ getWorkflowRenderConfig(): WorkflowRenderConfig;
286
+ /**
287
+ * Component management methods
288
+ */
289
+ getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined;
290
+ getAllComponents(): ComponentConfig[];
291
+ hasComponent(id: string): boolean;
292
+ /**
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
298
+ */
299
+ removeComponent(id: string): ril<C>;
300
+ /**
301
+ * Clear all components from the configuration (immutable)
302
+ * Returns a new instance with no components
303
+ *
304
+ * @returns A new empty ril instance
305
+ */
306
+ clear(): ril<C>;
307
+ /**
308
+ * Create a deep copy of the current ril instance
309
+ */
310
+ clone(): ril<C>;
311
+ /**
312
+ * Enhanced statistics with more detailed information
313
+ */
314
+ getStats(): {
315
+ total: number;
316
+ byType: Record<string, number>;
317
+ hasCustomRenderers: {
318
+ row: boolean;
319
+ body: boolean;
320
+ submitButton: boolean;
321
+ field: boolean;
322
+ stepper: boolean;
323
+ workflowNextButton: boolean;
324
+ workflowPreviousButton: boolean;
325
+ workflowSkipButton: boolean;
326
+ };
327
+ };
328
+ /**
329
+ * Synchronous validation using shared utilities
330
+ */
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;
530
+ }
531
+
532
+ interface RilayLicenseConfig {
533
+ readonly licenseKey?: string;
534
+ readonly environment?: 'development' | 'production';
535
+ readonly allowTrial?: boolean;
536
+ }
537
+ interface ValidationError {
538
+ readonly message: string;
539
+ readonly code?: string;
540
+ readonly path?: string;
541
+ }
542
+ interface ValidationResult {
543
+ readonly isValid: boolean;
544
+ readonly errors: ValidationError[];
545
+ readonly value?: any;
546
+ }
547
+ interface ValidationContext {
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>;
555
+ }
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>[];
581
+ readonly validateOnChange?: boolean;
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>[];
596
+ readonly validateOnSubmit?: boolean;
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>;
610
+ }
611
+ interface ComponentRenderProps<TProps = any> {
612
+ id: string;
613
+ props: TProps;
614
+ value?: any;
615
+ onChange?: (value: any) => void;
616
+ onBlur?: () => void;
617
+ disabled?: boolean;
618
+ error?: ValidationError[];
619
+ isValidating?: boolean;
620
+ [key: string]: any;
621
+ }
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<{
643
+ label: string;
644
+ value: any;
645
+ [key: string]: any;
646
+ }>;
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') */
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 */
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;
731
+ }
732
+ interface ComponentConfig<TProps = any> {
733
+ readonly id: string;
734
+ readonly type: string;
735
+ readonly name: string;
736
+ readonly description?: string;
737
+ readonly renderer: ComponentRenderer<TProps>;
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;
753
+ }
754
+ interface FormFieldConfig {
755
+ readonly id: string;
756
+ readonly componentId: string;
757
+ readonly props: Record<string, any>;
758
+ readonly validation?: FieldValidationConfig;
759
+ readonly conditions?: ConditionalBehavior;
760
+ }
761
+ interface FormFieldRow {
762
+ readonly id: string;
763
+ readonly fields: FormFieldConfig[];
764
+ readonly maxColumns?: number;
765
+ }
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;
779
+ }
780
+ interface FormComponentRendererProps {
781
+ children: React__default.ReactNode;
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>;
812
+ interface WorkflowContext {
813
+ readonly workflowId: string;
814
+ readonly currentStepIndex: number;
815
+ readonly totalSteps: number;
816
+ readonly allData: Record<string, any>;
817
+ readonly stepData: Record<string, any>;
818
+ readonly isFirstStep: boolean;
819
+ readonly isLastStep: boolean;
820
+ readonly visitedSteps: Set<string>;
821
+ readonly visibleVisitedSteps: Set<string>;
822
+ readonly passedSteps: Set<string>;
823
+ }
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[];
853
+ }
854
+ interface StepConfig {
855
+ readonly id: string;
856
+ readonly title: string;
857
+ readonly description?: string;
858
+ readonly formConfig: FormConfiguration;
859
+ readonly allowSkip?: boolean;
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>;
864
+ }
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;
876
+ };
877
+ readonly plugins?: WorkflowPlugin[];
878
+ readonly renderConfig?: WorkflowRenderConfig;
879
+ }
880
+ interface WorkflowRenderConfig {
881
+ readonly stepperRenderer?: WorkflowStepperRenderer;
882
+ readonly nextButtonRenderer?: WorkflowNextButtonRenderer;
883
+ readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer;
884
+ readonly skipButtonRenderer?: WorkflowSkipButtonRenderer;
885
+ }
886
+ interface WorkflowAnalytics {
887
+ readonly onWorkflowStart?: (workflowId: string, context: WorkflowContext) => void;
888
+ readonly onWorkflowComplete?: (workflowId: string, duration: number, data: any) => void;
889
+ readonly onWorkflowAbandon?: (workflowId: string, currentStep: string, data: any) => void;
890
+ readonly onStepStart?: (stepId: string, timestamp: number, context: WorkflowContext) => void;
891
+ readonly onStepComplete?: (stepId: string, duration: number, data: any, context: WorkflowContext) => void;
892
+ readonly onStepSkip?: (stepId: string, reason: string, context: WorkflowContext) => void;
893
+ readonly onError?: (error: Error, context: WorkflowContext) => void;
894
+ }
895
+ interface WorkflowPlugin {
896
+ readonly name: string;
897
+ readonly version?: string;
898
+ readonly install: (workflow: any) => void;
899
+ readonly dependencies?: string[];
900
+ }
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;
908
+ }
909
+ interface WorkflowStepperRendererProps {
910
+ readonly steps: StepConfig[];
911
+ readonly currentStepIndex: number;
912
+ readonly visitedSteps: Set<string>;
913
+ readonly onStepClick?: (stepIndex: number) => void;
914
+ readonly className?: string;
915
+ }
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;
942
+ }
943
+ interface ComponentPerformanceMetrics extends PerformanceMetrics {
944
+ readonly componentId: string;
945
+ readonly componentType: string;
946
+ readonly propsSize?: number;
947
+ readonly childrenCount?: number;
948
+ }
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;
955
+ }
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;
963
+ }
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';
973
+ }
974
+ interface ErrorMonitoringEvent extends MonitoringEvent {
975
+ readonly type: 'error';
976
+ readonly error: Error;
977
+ readonly stack?: string;
978
+ readonly context?: ValidationContext | WorkflowContext;
979
+ }
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;
1054
+ }
1055
+
1056
+ declare function ComponentRendererWrapper<TProps = any>({ children, renderAs, renderer, name, props: baseProps, }: ComponentRendererWrapperProps<TProps>): React$1.ReactNode;
1057
+
1058
+ /**
1059
+ * Utility for merging partial configurations into existing objects
1060
+ * Eliminates repetitive object spread operations
1061
+ */
1062
+ declare function mergeInto<T>(target: T, partial: Partial<T>): T;
1063
+ /**
1064
+ * Validates uniqueness of identifiers and throws descriptive errors
1065
+ */
1066
+ declare function ensureUnique(ids: string[], entityName: string): void;
1067
+ /**
1068
+ * Validates required fields exist in configurations
1069
+ */
1070
+ declare function validateRequired<T>(items: T[], requiredFields: (keyof T)[], entityName: string): void;
1071
+ /**
1072
+ * Auto-generates IDs when not provided
1073
+ */
1074
+ declare class IdGenerator {
1075
+ private counters;
1076
+ next(prefix: string): string;
1077
+ reset(prefix?: string): void;
1078
+ }
1079
+ /**
1080
+ * Polymorphic helper for handling single items or arrays
1081
+ */
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>);
1286
+ /**
1287
+ * Add a monitoring adapter
1288
+ */
1289
+ addAdapter(adapter: MonitoringAdapter): void;
1290
+ /**
1291
+ * Remove a monitoring adapter
1292
+ */
1293
+ removeAdapter(adapterName: string): void;
1294
+ /**
1295
+ * Track a monitoring event
1296
+ */
1297
+ track(type: MonitoringEventType, source: string, data: Record<string, any>, metrics?: PerformanceMetrics, severity?: 'low' | 'medium' | 'high' | 'critical'): void;
1298
+ /**
1299
+ * Track an error
1300
+ */
1301
+ trackError(error: Error, source: string, context?: any): void;
1302
+ /**
1303
+ * Get the performance profiler
1304
+ */
1305
+ getProfiler(): PerformanceProfiler;
1306
+ /**
1307
+ * Update monitoring context
1308
+ */
1309
+ updateContext(updates: Partial<MonitoringContext>): void;
1310
+ /**
1311
+ * Flush all buffered events
1312
+ */
1313
+ flush(): Promise<void>;
1314
+ /**
1315
+ * Destroy the monitor and clean up resources
1316
+ */
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;
1326
+ /**
1327
+ * Get the global monitor instance
1328
+ */
1329
+ declare function getGlobalMonitor(): RilayMonitor | null;
1330
+ /**
1331
+ * Destroy global monitoring
1332
+ */
1333
+ declare function destroyGlobalMonitoring(): Promise<void>;
1334
+
1335
+ /**
1336
+ * Console monitoring adapter
1337
+ * Logs events to the browser console
1338
+ */
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;
1346
+ }
1347
+ /**
1348
+ * Remote monitoring adapter
1349
+ * Sends events to a remote endpoint
1350
+ */
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;
1373
+ }
1374
+ /**
1375
+ * Local storage adapter for offline support
1376
+ */
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
+ }
1388
+ /**
1389
+ * Development adapter that provides detailed logging
1390
+ */
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
+ }
1398
+
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 };