@rilaykit/core
Advanced tools
+21
| MIT License | ||
| Copyright (c) 2025 AND YOU CREATE | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+1192
-429
@@ -1,143 +0,317 @@ | ||
| import React from 'react'; | ||
| import { z } from 'zod'; | ||
| import { StandardSchemaV1 } from '@standard-schema/spec'; | ||
| import * as React$1 from 'react'; | ||
| import React__default from 'react'; | ||
| /** | ||
| * Main configuration class for Rilay form components and workflows | ||
| * Manages component registration, retrieval, and configuration | ||
| * A graph that tracks which fields depend on which other fields for condition evaluation. | ||
| * | ||
| * This enables efficient re-evaluation of conditions when values change: | ||
| * instead of re-evaluating ALL conditions when ANY value changes, | ||
| * we only re-evaluate conditions that depend on the changed value. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const graph = new ConditionDependencyGraph(); | ||
| * | ||
| * // Add field with its conditions | ||
| * graph.addField('dependentField', { | ||
| * visible: when('triggerField').equals('show') | ||
| * }); | ||
| * | ||
| * // When 'triggerField' changes, get affected fields | ||
| * const affected = graph.getAffectedFields('triggerField'); | ||
| * // affected = ['dependentField'] | ||
| * ``` | ||
| */ | ||
| declare class ril { | ||
| private components; | ||
| private formRenderConfig; | ||
| private workflowRenderConfig; | ||
| static create(): ril; | ||
| declare class ConditionDependencyGraph { | ||
| /** | ||
| * Add a component to the configuration | ||
| * @param subType - The component subtype (e.g., 'text', 'email', 'heading') | ||
| * @param config - Component configuration without id and subType | ||
| * @returns The ril instance for chaining | ||
| * Maps field IDs to their dependencies (fields they depend on) | ||
| * fieldId -> Set of field paths it depends on | ||
| */ | ||
| addComponent<TProps = any>(subType: InputType | LayoutType, config: Omit<ComponentConfig<TProps>, 'id' | 'subType'> & { | ||
| id?: string; | ||
| }): this; | ||
| private readonly fieldDependencies; | ||
| /** | ||
| * Set custom row renderer | ||
| * @param renderer - Custom row renderer function | ||
| * @returns The ril instance for chaining | ||
| * Reverse index: maps a field path to all fields that depend on it | ||
| * fieldPath -> Set of field IDs that have conditions depending on this path | ||
| */ | ||
| setRowRenderer(renderer: FormRowRenderer): this; | ||
| private readonly reverseDependencies; | ||
| /** | ||
| * Set custom body renderer | ||
| * @param renderer - Custom body renderer function | ||
| * @returns The ril instance for chaining | ||
| * Adds a field with its conditional behavior to the graph. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @param conditions - The field's conditional behavior (visible, disabled, required, readonly) | ||
| */ | ||
| setBodyRenderer(renderer: FormBodyRenderer): this; | ||
| addField(fieldId: string, conditions?: ConditionalBehavior): void; | ||
| /** | ||
| * Set custom submit button renderer | ||
| * @param renderer - Custom submit button renderer function | ||
| * @returns The ril instance for chaining | ||
| * Removes a field from the graph. | ||
| * | ||
| * @param fieldId - The ID of the field to remove | ||
| */ | ||
| setSubmitButtonRenderer(renderer: FormSubmitButtonRenderer): this; | ||
| removeField(fieldId: string): void; | ||
| /** | ||
| * Set complete form render configuration | ||
| * @param config - Form render configuration | ||
| * @returns The ril instance for chaining | ||
| * Gets all field IDs that have conditions depending on a specific field path. | ||
| * | ||
| * When a value at `changedPath` changes, these are the fields whose | ||
| * conditions need to be re-evaluated. | ||
| * | ||
| * @param changedPath - The field path that changed | ||
| * @returns Array of field IDs that depend on this path | ||
| */ | ||
| setFormRenderConfig(config: FormRenderConfig): this; | ||
| getAffectedFields(changedPath: string): string[]; | ||
| /** | ||
| * Get current form render configuration | ||
| * @returns Current form render configuration | ||
| * Gets all field IDs affected by changes to multiple paths. | ||
| * | ||
| * @param changedPaths - Array of field paths that changed | ||
| * @returns Array of unique field IDs that depend on any of these paths | ||
| */ | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getAffectedFieldsMultiple(changedPaths: string[]): string[]; | ||
| /** | ||
| * Set custom stepper renderer for workflows | ||
| * @param renderer - Custom stepper renderer function | ||
| * @returns The ril instance for chaining | ||
| * Gets the dependencies for a specific field. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @returns Array of field paths this field depends on | ||
| */ | ||
| setStepperRenderer(renderer: WorkflowStepperRenderer): this; | ||
| getDependencies(fieldId: string): string[]; | ||
| /** | ||
| * Set custom workflow navigation renderer | ||
| * @param renderer - Custom workflow navigation renderer function | ||
| * @returns The ril instance for chaining | ||
| * Checks if a field has any dependencies. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @returns True if the field has conditional dependencies | ||
| */ | ||
| setWorkflowNavigationRenderer(renderer: WorkflowNavigationRenderer): this; | ||
| hasDependencies(fieldId: string): boolean; | ||
| /** | ||
| * Set complete workflow render configuration | ||
| * @param config - Workflow render configuration | ||
| * @returns The ril instance for chaining | ||
| * Gets all fields in the graph. | ||
| * | ||
| * @returns Array of all field IDs | ||
| */ | ||
| setWorkflowRenderConfig(config: WorkflowRenderConfig): this; | ||
| getAllFields(): string[]; | ||
| /** | ||
| * Get current workflow render configuration | ||
| * @returns Current workflow render configuration | ||
| * Gets all unique dependency paths in the graph. | ||
| * | ||
| * @returns Array of all field paths that are dependencies | ||
| */ | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| getAllDependencyPaths(): string[]; | ||
| /** | ||
| * @deprecated Use setFormRenderConfig() instead | ||
| * Clears the entire graph. | ||
| */ | ||
| setRenderConfig(config: FormRenderConfig): this; | ||
| clear(): void; | ||
| /** | ||
| * Get a component by its ID | ||
| * @param id - Component ID | ||
| * @returns Component configuration or undefined | ||
| * Gets the size of the graph (number of fields). | ||
| */ | ||
| get size(): number; | ||
| /** | ||
| * Creates a debug representation of the graph. | ||
| * Useful for development and testing. | ||
| */ | ||
| toDebugObject(): { | ||
| fields: Record<string, string[]>; | ||
| reverseDeps: Record<string, string[]>; | ||
| }; | ||
| } | ||
| type ConditionOperator = 'equals' | 'notEquals' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'contains' | 'notContains' | 'in' | 'notIn' | 'matches' | 'exists' | 'notExists'; | ||
| type LogicalOperator = 'and' | 'or'; | ||
| type ConditionValue = string | number | boolean | null | undefined | Array<string | number | boolean>; | ||
| interface ConditionConfig { | ||
| field: string; | ||
| operator: ConditionOperator; | ||
| value?: ConditionValue; | ||
| conditions?: ConditionConfig[]; | ||
| logicalOperator?: LogicalOperator; | ||
| } | ||
| type ConditionEvaluator = (data: Record<string, any>) => boolean; | ||
| interface ConditionBuilder extends ConditionConfig { | ||
| equals(value: ConditionValue): ConditionBuilder; | ||
| notEquals(value: ConditionValue): ConditionBuilder; | ||
| greaterThan(value: number): ConditionBuilder; | ||
| lessThan(value: number): ConditionBuilder; | ||
| greaterThanOrEqual(value: number): ConditionBuilder; | ||
| lessThanOrEqual(value: number): ConditionBuilder; | ||
| contains(value: string): ConditionBuilder; | ||
| notContains(value: string): ConditionBuilder; | ||
| in(values: Array<string | number | boolean>): ConditionBuilder; | ||
| notIn(values: Array<string | number | boolean>): ConditionBuilder; | ||
| matches(pattern: string | RegExp): ConditionBuilder; | ||
| exists(): ConditionBuilder; | ||
| notExists(): ConditionBuilder; | ||
| and(condition: ConditionBuilder | ConditionConfig): ConditionBuilder; | ||
| or(condition: ConditionBuilder | ConditionConfig): ConditionBuilder; | ||
| build(): ConditionConfig; | ||
| evaluate(data: Record<string, any>): boolean; | ||
| } | ||
| declare function when(field: string): ConditionBuilder; | ||
| declare function evaluateCondition(condition: ConditionConfig, data: Record<string, any>): boolean; | ||
| /** | ||
| * Extracts all field paths that a condition depends on. | ||
| * | ||
| * This is useful for building a dependency graph that knows which | ||
| * conditions need to be re-evaluated when a specific field changes. | ||
| * | ||
| * @param condition - The condition to extract dependencies from | ||
| * @returns An array of unique field paths | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const condition = when('field1').equals('value').and(when('field2').exists()); | ||
| * const deps = extractConditionDependencies(condition.build()); | ||
| * // deps = ['field1', 'field2'] | ||
| * | ||
| * const nestedCondition = when('step1.field1').equals('value'); | ||
| * const nestedDeps = extractConditionDependencies(nestedCondition.build()); | ||
| * // nestedDeps = ['step1.field1'] | ||
| * ``` | ||
| */ | ||
| declare function extractConditionDependencies(condition: ConditionConfig | ConditionBuilder | undefined | null): string[]; | ||
| /** | ||
| * Extracts dependencies from multiple conditions (e.g., visible, disabled, required). | ||
| * | ||
| * @param behaviors - Object containing condition configurations | ||
| * @returns An array of unique field paths from all conditions | ||
| */ | ||
| declare function extractAllDependencies(behaviors: Record<string, ConditionConfig | ConditionBuilder | undefined | null>): string[]; | ||
| /** | ||
| * Validation result for async operations | ||
| */ | ||
| interface AsyncValidationResult { | ||
| isValid: boolean; | ||
| errors: string[]; | ||
| warnings?: string[]; | ||
| } | ||
| /** | ||
| * Public interface for Rilay instances | ||
| * Exposes only the methods necessary for the public API | ||
| */ | ||
| interface RilayInstance<C> { | ||
| addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): RilayInstance<C & { | ||
| [K in NewType]: TProps; | ||
| }>; | ||
| configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): RilayInstance<C>; | ||
| getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined; | ||
| getComponent(id: string): ComponentConfig | undefined; | ||
| getAllComponents(): ComponentConfig[]; | ||
| hasComponent(id: string): boolean; | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| getStats(): { | ||
| total: number; | ||
| byType: Record<string, number>; | ||
| hasCustomRenderers: { | ||
| row: boolean; | ||
| body: boolean; | ||
| submitButton: boolean; | ||
| field: boolean; | ||
| stepper: boolean; | ||
| workflowNextButton: boolean; | ||
| workflowPreviousButton: boolean; | ||
| workflowSkipButton: boolean; | ||
| }; | ||
| }; | ||
| validate(): string[]; | ||
| validateAsync(): Promise<AsyncValidationResult>; | ||
| clone(): RilayInstance<C>; | ||
| removeComponent(id: string): RilayInstance<C>; | ||
| clear(): RilayInstance<C>; | ||
| } | ||
| /** | ||
| * Main configuration class for Rilay form components and workflows | ||
| * Manages component registration, retrieval, and configuration with immutable API | ||
| */ | ||
| declare class ril<C> implements RilayInstance<C> { | ||
| private components; | ||
| private formRenderConfig; | ||
| private workflowRenderConfig; | ||
| /** | ||
| * List components by type (input or layout) | ||
| * @param type - Component type | ||
| * @returns Array of matching components | ||
| * Static factory method to create a new ril instance | ||
| */ | ||
| getComponentsByType(type: ComponentType): ComponentConfig[]; | ||
| static create<CT>(): ril<CT>; | ||
| /** | ||
| * List components by sub-type | ||
| * @param subType - Component sub-type | ||
| * @returns Array of matching components | ||
| * Add a component to the configuration (immutable) | ||
| * Returns a new instance with the added component | ||
| * | ||
| * @param type - The component type (e.g., 'text', 'email', 'heading'), used as a unique identifier. | ||
| * @param config - Component configuration without id and type | ||
| * @returns A new ril instance with the added component | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Component with default validation | ||
| * const factory = ril.create() | ||
| * .addComponent('email', { | ||
| * name: 'Email Input', | ||
| * renderer: EmailInput, | ||
| * validation: { | ||
| * validators: [email('Format email invalide')], | ||
| * validateOnBlur: true, | ||
| * } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getComponentsBySubType(subType: InputType | LayoutType): ComponentConfig[]; | ||
| addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): ril<C & { | ||
| [K in NewType]: TProps; | ||
| }>; | ||
| /** | ||
| * Get components by category | ||
| * @param category - Component category | ||
| * @returns Array of matching components | ||
| * Universal configuration method with deep merge support (immutable) | ||
| * | ||
| * This method provides a unified API to configure both form and workflow renderers | ||
| * in a single call, automatically categorizing and applying the appropriate configurations | ||
| * using recursive deep merge. | ||
| * | ||
| * @param config - Configuration object containing renderer settings | ||
| * @returns A new ril instance with the updated configuration | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Configure with nested settings | ||
| * const config = ril.create() | ||
| * .configure({ | ||
| * rowRenderer: CustomRowRenderer, | ||
| * submitButtonRenderer: CustomSubmitButton, | ||
| * // Deep nested configuration example | ||
| * formStyles: { | ||
| * layout: { | ||
| * spacing: 'large', | ||
| * alignment: 'center' | ||
| * } | ||
| * } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getComponentsByCategory(category: string): ComponentConfig[]; | ||
| configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): ril<C>; | ||
| /** | ||
| * List all registered components | ||
| * @returns Array of all components | ||
| * Configuration getters | ||
| */ | ||
| getAllComponents(): ComponentConfig[]; | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| /** | ||
| * Check if a component exists | ||
| * @param id - Component ID | ||
| * @returns True if component exists | ||
| * Component management methods | ||
| */ | ||
| getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined; | ||
| getAllComponents(): ComponentConfig[]; | ||
| hasComponent(id: string): boolean; | ||
| /** | ||
| * Remove a component from the configuration | ||
| * @param id - Component ID | ||
| * @returns True if component was removed | ||
| * Remove a component from the configuration (immutable) | ||
| * Returns a new instance without the specified component | ||
| * | ||
| * @param id - The component ID to remove | ||
| * @returns A new ril instance without the component | ||
| */ | ||
| removeComponent(id: string): boolean; | ||
| removeComponent(id: string): ril<C>; | ||
| /** | ||
| * Clear all components | ||
| * Clear all components from the configuration (immutable) | ||
| * Returns a new instance with no components | ||
| * | ||
| * @returns A new empty ril instance | ||
| */ | ||
| clear(): void; | ||
| clear(): ril<C>; | ||
| /** | ||
| * Export configuration as a plain object | ||
| * @returns Object with component configurations | ||
| * Create a deep copy of the current ril instance | ||
| */ | ||
| export(): Record<string, ComponentConfig>; | ||
| clone(): ril<C>; | ||
| /** | ||
| * Import configuration from a plain object | ||
| * @param config - Object with component configurations | ||
| * @returns The ril instance for chaining | ||
| * Enhanced statistics with more detailed information | ||
| */ | ||
| import(config: Record<string, ComponentConfig>): this; | ||
| /** | ||
| * Get statistics about registered components and renderers | ||
| * @returns Object with comprehensive statistics | ||
| */ | ||
| getStats(): { | ||
| total: number; | ||
| byType: Record<ComponentType, number>; | ||
| bySubType: Record<string, number>; | ||
| byCategory: Record<string, number>; | ||
| byType: Record<string, number>; | ||
| hasCustomRenderers: { | ||
@@ -147,13 +321,213 @@ row: boolean; | ||
| submitButton: boolean; | ||
| field: boolean; | ||
| stepper: boolean; | ||
| workflowNavigation: boolean; | ||
| workflowNextButton: boolean; | ||
| workflowPreviousButton: boolean; | ||
| workflowSkipButton: boolean; | ||
| }; | ||
| }; | ||
| /** | ||
| * Validate the configuration | ||
| * @returns Array of validation errors | ||
| * Synchronous validation using shared utilities | ||
| */ | ||
| validate(): string[]; | ||
| /** | ||
| * Asynchronous validation with structured error handling | ||
| * Ideal for CI/CD pipelines and advanced validation scenarios | ||
| */ | ||
| validateAsync(): Promise<AsyncValidationResult>; | ||
| } | ||
| type ValidationState = 'idle' | 'validating' | 'valid' | 'invalid'; | ||
| /** | ||
| * Field state without actions - used for selectors | ||
| */ | ||
| interface FieldState { | ||
| readonly value: unknown; | ||
| readonly errors: ValidationError[]; | ||
| readonly validationState: ValidationState; | ||
| readonly touched: boolean; | ||
| readonly dirty: boolean; | ||
| } | ||
| /** | ||
| * Field conditions - visibility, disabled, required, readonly | ||
| */ | ||
| interface FieldConditions { | ||
| readonly visible: boolean; | ||
| readonly disabled: boolean; | ||
| readonly required: boolean; | ||
| readonly readonly: boolean; | ||
| } | ||
| /** | ||
| * Field actions - stable references for setValue, validate, etc. | ||
| */ | ||
| interface FieldActions { | ||
| readonly setValue: (value: unknown) => void; | ||
| readonly setTouched: () => void; | ||
| readonly validate: () => Promise<ValidationResult>; | ||
| readonly clearErrors: () => void; | ||
| } | ||
| /** | ||
| * Complete field context - combines state, conditions and actions | ||
| * Used by component renderers for full field access | ||
| */ | ||
| interface FieldContext extends FieldState, FieldConditions { | ||
| readonly id: string; | ||
| readonly componentId: string; | ||
| readonly defaultValue?: unknown; | ||
| readonly actions: FieldActions; | ||
| } | ||
| /** | ||
| * Form state without actions - used for selectors | ||
| */ | ||
| interface FormState { | ||
| readonly values: Record<string, unknown>; | ||
| readonly errors: Record<string, ValidationError[]>; | ||
| readonly validationStates: Record<string, ValidationState>; | ||
| readonly touched: Record<string, boolean>; | ||
| readonly isDirty: boolean; | ||
| readonly isSubmitting: boolean; | ||
| readonly isValid: boolean; | ||
| } | ||
| /** | ||
| * Form actions - stable references | ||
| */ | ||
| interface FormActions { | ||
| readonly setValue: (fieldId: string, value: unknown) => void; | ||
| readonly setTouched: (fieldId: string) => void; | ||
| readonly setErrors: (fieldId: string, errors: ValidationError[]) => void; | ||
| readonly setValidationState: (fieldId: string, state: ValidationState) => void; | ||
| readonly setSubmitting: (isSubmitting: boolean) => void; | ||
| readonly submit: () => Promise<boolean>; | ||
| readonly reset: (values?: Record<string, unknown>) => void; | ||
| readonly validate: () => Promise<ValidationResult>; | ||
| readonly validateField: (fieldId: string, value?: unknown) => Promise<ValidationResult>; | ||
| } | ||
| /** | ||
| * Complete form context - combines state and actions | ||
| */ | ||
| interface FormContextValue extends FormState { | ||
| readonly formId: string; | ||
| readonly actions: FormActions; | ||
| readonly getFieldState: (fieldId: string) => FieldState; | ||
| readonly getFieldConditions: (fieldId: string) => FieldConditions; | ||
| } | ||
| /** | ||
| * Props passed to component renderers (v2) | ||
| * Replaces the old ComponentRenderProps with spread [key: string]: any | ||
| */ | ||
| interface ComponentRenderPropsV2<TProps = unknown> { | ||
| /** Field identifier */ | ||
| readonly id: string; | ||
| /** Component-specific props (label, placeholder, options, etc.) */ | ||
| readonly props: TProps; | ||
| /** Field state (value, errors, touched, etc.) */ | ||
| readonly field: FieldState; | ||
| /** Field conditions (visible, disabled, required, readonly) */ | ||
| readonly conditions: FieldConditions; | ||
| /** Stable action references */ | ||
| readonly actions: FieldActions; | ||
| } | ||
| /** | ||
| * Props passed to field wrapper renderers (v2) | ||
| */ | ||
| interface FieldRendererPropsV2 { | ||
| /** Rendered component content */ | ||
| readonly children: React.ReactNode; | ||
| /** Field identifier */ | ||
| readonly id: string; | ||
| /** Field state */ | ||
| readonly field: FieldState; | ||
| /** Field conditions */ | ||
| readonly conditions: FieldConditions; | ||
| /** Component props (for label, placeholder, helpText, etc.) */ | ||
| readonly componentProps: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Props passed to form submit button renderer (v2) | ||
| */ | ||
| interface FormSubmitButtonRendererPropsV2 { | ||
| /** Whether form is currently submitting */ | ||
| readonly isSubmitting: boolean; | ||
| /** Whether form is valid (no errors) */ | ||
| readonly isValid: boolean; | ||
| /** Whether form has been modified */ | ||
| readonly isDirty: boolean; | ||
| /** Submit handler */ | ||
| readonly onSubmit: () => void; | ||
| /** Reset handler */ | ||
| readonly onReset: () => void; | ||
| /** Form data access (for advanced use cases) */ | ||
| readonly form: { | ||
| readonly values: Record<string, unknown>; | ||
| readonly errors: Record<string, ValidationError[]>; | ||
| }; | ||
| /** Optional className */ | ||
| readonly className?: string; | ||
| /** Optional children */ | ||
| readonly children?: React.ReactNode; | ||
| } | ||
| /** | ||
| * Step state for workflow | ||
| */ | ||
| interface WorkflowStepState { | ||
| readonly stepIndex: number; | ||
| readonly stepId: string; | ||
| readonly isFirst: boolean; | ||
| readonly isLast: boolean; | ||
| readonly isVisible: boolean; | ||
| readonly isSkippable: boolean; | ||
| } | ||
| /** | ||
| * Navigation state for workflow | ||
| */ | ||
| interface WorkflowNavigationState { | ||
| readonly canGoNext: boolean; | ||
| readonly canGoPrevious: boolean; | ||
| readonly canSkip: boolean; | ||
| readonly isTransitioning: boolean; | ||
| } | ||
| /** | ||
| * Progress state for workflow | ||
| */ | ||
| interface WorkflowProgressState { | ||
| readonly totalSteps: number; | ||
| readonly visibleSteps: number; | ||
| readonly currentStepIndex: number; | ||
| readonly visitedSteps: ReadonlySet<string>; | ||
| readonly passedSteps: ReadonlySet<string>; | ||
| } | ||
| /** | ||
| * Complete workflow step context | ||
| */ | ||
| interface WorkflowStepContext { | ||
| readonly step: WorkflowStepState; | ||
| readonly navigation: WorkflowNavigationState; | ||
| readonly progress: WorkflowProgressState; | ||
| readonly stepData: Record<string, unknown>; | ||
| readonly allData: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Props passed to workflow button renderers (v2) | ||
| */ | ||
| interface WorkflowButtonRendererPropsV2 { | ||
| /** Navigation state */ | ||
| readonly navigation: WorkflowNavigationState; | ||
| /** Progress state */ | ||
| readonly progress: WorkflowProgressState; | ||
| /** Current step state */ | ||
| readonly step: WorkflowStepState; | ||
| /** Whether workflow is submitting */ | ||
| readonly isSubmitting: boolean; | ||
| /** Step data */ | ||
| readonly stepData: Record<string, unknown>; | ||
| /** All workflow data */ | ||
| readonly allData: Record<string, unknown>; | ||
| /** Action handler (next/previous/skip/submit) */ | ||
| readonly onAction: () => void; | ||
| /** Optional className */ | ||
| readonly className?: string; | ||
| /** Optional children */ | ||
| readonly children?: React.ReactNode; | ||
| } | ||
| interface RilayLicenseConfig { | ||
@@ -164,37 +538,76 @@ readonly licenseKey?: string; | ||
| } | ||
| type ComponentType = 'input' | 'layout'; | ||
| type InputType = 'text' | 'email' | 'password' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'date'; | ||
| type LayoutType = 'heading' | 'paragraph' | 'container' | 'divider' | 'spacer' | 'alert'; | ||
| interface ValidationError { | ||
| readonly message: string; | ||
| readonly code?: string; | ||
| readonly path?: string; | ||
| } | ||
| interface ValidationResult { | ||
| readonly isValid: boolean; | ||
| readonly errors: ValidationError[]; | ||
| readonly warnings?: ValidationWarning[]; | ||
| readonly value?: any; | ||
| } | ||
| interface ValidationError { | ||
| readonly code: string; | ||
| readonly message: string; | ||
| readonly path?: string[]; | ||
| } | ||
| interface ValidationWarning { | ||
| readonly code: string; | ||
| readonly message: string; | ||
| readonly path?: string[]; | ||
| } | ||
| interface ValidationContext { | ||
| readonly fieldId: string; | ||
| readonly formData: Record<string, any>; | ||
| readonly fieldProps: Record<string, any>; | ||
| readonly touched: boolean; | ||
| readonly dirty: boolean; | ||
| readonly fieldId?: string; | ||
| readonly formId?: string; | ||
| readonly stepId?: string; | ||
| readonly workflowId?: string; | ||
| readonly allFormData?: Record<string, any>; | ||
| readonly stepData?: Record<string, any>; | ||
| readonly workflowData?: Record<string, any>; | ||
| } | ||
| type ValidatorFunction<TProps = any> = (value: any, context: ValidationContext, props: TProps) => ValidationResult | Promise<ValidationResult>; | ||
| interface ValidationConfig<TProps = any> { | ||
| readonly validator?: ValidatorFunction<TProps>; | ||
| readonly debounceMs?: number; | ||
| /** @internal - Use Standard Schema instead */ | ||
| type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>; | ||
| /** @internal - Use Standard Schema instead */ | ||
| type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>; | ||
| type StandardSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>; | ||
| type InferInput<T> = T extends StandardSchema<infer I, any> ? I : unknown; | ||
| type InferOutput<T> = T extends StandardSchema<any, infer O> ? O : unknown; | ||
| interface FieldValidationConfig<T = any> { | ||
| /** | ||
| * Validation rules using Standard Schema interface | ||
| * Accepts: single schema, array of schemas, or any Standard Schema compatible validation | ||
| * | ||
| * @example Single schema | ||
| * validate: z.string().email() | ||
| * | ||
| * @example Built-in validators | ||
| * validate: required() | ||
| * | ||
| * @example Multiple validations | ||
| * validate: [required(), email()] | ||
| * | ||
| * @example Mixed schemas + validators | ||
| * validate: [z.string(), required(), customValidator()] | ||
| */ | ||
| readonly validate?: StandardSchema<T> | StandardSchema<T>[]; | ||
| readonly validateOnChange?: boolean; | ||
| readonly validateOnBlur?: boolean; | ||
| readonly debounceMs?: number; | ||
| } | ||
| interface FormValidationConfig<T extends Record<string, any> = Record<string, any>> { | ||
| /** | ||
| * Form-level validation using Standard Schema interface | ||
| * | ||
| * @example Object schema | ||
| * validate: z.object({ email: z.string().email(), name: z.string() }) | ||
| * | ||
| * @example Custom form validator | ||
| * validate: customFormValidator() | ||
| */ | ||
| readonly validate?: StandardSchema<T> | StandardSchema<T>[]; | ||
| readonly validateOnSubmit?: boolean; | ||
| readonly dependencies?: string[]; | ||
| readonly validateOnStepChange?: boolean; | ||
| } | ||
| type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React.ReactElement; | ||
| type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React__default.ReactElement; | ||
| type RendererChildrenFunction<TProps = any> = (props: TProps) => React__default.ReactNode; | ||
| interface ComponentRendererBaseProps<TProps = any> { | ||
| className?: string; | ||
| children?: React__default.ReactNode | RendererChildrenFunction<TProps>; | ||
| renderAs?: 'default' | 'children' | boolean; | ||
| } | ||
| interface ComponentRendererWrapperProps<TProps = any> extends Omit<ComponentRendererBaseProps<TProps>, 'className'> { | ||
| name: string; | ||
| props: TProps; | ||
| renderer?: RendererChildrenFunction<TProps>; | ||
| } | ||
| interface ComponentRenderProps<TProps = any> { | ||
@@ -206,33 +619,139 @@ id: string; | ||
| onBlur?: () => void; | ||
| disabled?: boolean; | ||
| error?: ValidationError[]; | ||
| warnings?: ValidationWarning[]; | ||
| touched?: boolean; | ||
| disabled?: boolean; | ||
| isValidating?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| interface ComponentOptions<TProps = any> { | ||
| readonly configurable?: Array<{ | ||
| key: keyof TProps; | ||
| type: 'string' | 'number' | 'boolean' | 'select' | 'array'; | ||
| /** | ||
| * Property editor definition for builder property panel | ||
| * Generic and extensible to support any custom editor type | ||
| */ | ||
| interface PropertyEditorDefinition<TValue = any> { | ||
| /** Property key in component props */ | ||
| readonly key: string; | ||
| /** Display label in property panel */ | ||
| readonly label: string; | ||
| /** | ||
| * Editor type - can be any string to support custom editors | ||
| * Built-in types: 'text', 'number', 'boolean', 'select', 'multiselect', 'color', 'textarea', 'json' | ||
| * Custom types: 'phone', 'currency', 'location', 'rating', 'file-upload', etc. | ||
| */ | ||
| readonly editorType: string; | ||
| /** Optional description/help text */ | ||
| readonly helpText?: string; | ||
| /** Default value for this property */ | ||
| readonly defaultValue?: TValue; | ||
| /** Options for select/multiselect editors */ | ||
| readonly options?: Array<{ | ||
| label: string; | ||
| options?: any[]; | ||
| default?: any; | ||
| value: any; | ||
| [key: string]: any; | ||
| }>; | ||
| readonly previewProps?: Partial<TProps>; | ||
| /** Validation function for the property value */ | ||
| readonly validate?: (value: TValue) => boolean | string | Promise<boolean | string>; | ||
| /** Group/section for organizing properties */ | ||
| readonly group?: string; | ||
| /** Whether this property is required */ | ||
| readonly required?: boolean; | ||
| /** Placeholder text for input fields */ | ||
| readonly placeholder?: string; | ||
| /** Custom editor component for advanced use cases */ | ||
| readonly customEditor?: React__default.ComponentType<PropertyEditorProps<TValue>>; | ||
| /** Additional configuration specific to the editor type */ | ||
| readonly editorConfig?: Record<string, any>; | ||
| /** Dependencies - other properties that affect this one */ | ||
| readonly dependencies?: string[]; | ||
| /** Conditional rendering based on other property values */ | ||
| readonly visible?: (props: Record<string, any>) => boolean; | ||
| /** Transform value before saving */ | ||
| readonly transform?: (value: TValue) => any; | ||
| /** Parse value when loading */ | ||
| readonly parse?: (value: any) => TValue; | ||
| } | ||
| /** | ||
| * Props passed to custom property editors | ||
| */ | ||
| interface PropertyEditorProps<TValue = any> { | ||
| /** Current property value */ | ||
| readonly value: TValue; | ||
| /** Callback to update the value */ | ||
| readonly onChange: (value: TValue) => void; | ||
| /** Property definition */ | ||
| readonly definition: PropertyEditorDefinition<TValue>; | ||
| /** All current property values (for dependencies) */ | ||
| readonly allValues: Record<string, any>; | ||
| /** Whether the field is disabled */ | ||
| readonly disabled?: boolean; | ||
| /** Validation errors */ | ||
| readonly errors?: string[]; | ||
| } | ||
| /** | ||
| * Builder metadata for visual editing capabilities | ||
| * This is optional and only used by @rilaykit/builder | ||
| * Fully generic to support any component type and configuration | ||
| */ | ||
| interface ComponentBuilderMetadata<TProps = any> { | ||
| /** Category for grouping in component palette (e.g., 'Input', 'Layout', 'Advanced') */ | ||
| readonly category?: string; | ||
| /** Icon identifier (e.g., 'text', 'email', 'calendar') */ | ||
| readonly icon?: string; | ||
| /** Whether this component should be hidden from the builder palette */ | ||
| readonly hidden?: boolean; | ||
| /** Preview component or description for the palette */ | ||
| readonly preview?: React__default.ReactNode; | ||
| /** Editable properties configuration for property panel */ | ||
| readonly editableProps?: PropertyEditorDefinition[]; | ||
| /** Tags for search and filtering */ | ||
| readonly tags?: string[]; | ||
| /** | ||
| * Custom field schema for advanced type systems | ||
| * Allows defining complex field types with their own validation and structure | ||
| */ | ||
| readonly fieldSchema?: FieldSchemaDefinition<TProps>; | ||
| } | ||
| /** | ||
| * Field schema definition for complex field types | ||
| * Supports defining custom field types with validation, defaults, and metadata | ||
| */ | ||
| interface FieldSchemaDefinition<TProps = any> { | ||
| /** Field type identifier (e.g., 'location', 'phone', 'currency') */ | ||
| readonly type: string; | ||
| /** Schema validation (Zod, Yup, or any Standard Schema) */ | ||
| readonly schema?: any; | ||
| /** Default configuration for this field type */ | ||
| readonly defaultConfig?: Partial<TProps>; | ||
| /** Sub-fields for complex types (e.g., Location has address, city, country) */ | ||
| readonly subFields?: Array<{ | ||
| key: string; | ||
| label: string; | ||
| type: string; | ||
| required?: boolean; | ||
| }>; | ||
| /** Custom serialization for complex data structures */ | ||
| readonly serialize?: (value: any) => any; | ||
| /** Custom deserialization for complex data structures */ | ||
| readonly deserialize?: (value: any) => any; | ||
| } | ||
| interface ComponentConfig<TProps = any> { | ||
| readonly id: string; | ||
| readonly type: ComponentType; | ||
| readonly subType: InputType | LayoutType; | ||
| readonly type: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly category?: string; | ||
| readonly renderer: ComponentRenderer<TProps>; | ||
| readonly options?: ComponentOptions<TProps>; | ||
| readonly validation?: ValidationConfig<TProps>; | ||
| readonly defaultProps?: Partial<TProps>; | ||
| readonly useFieldRenderer?: boolean; | ||
| readonly validation?: FieldValidationConfig; | ||
| /** Optional builder metadata for visual editing (only used by @rilaykit/builder) */ | ||
| readonly builder?: ComponentBuilderMetadata; | ||
| } | ||
| interface ConditionalBehavior { | ||
| readonly visible?: ConditionConfig; | ||
| readonly disabled?: ConditionConfig; | ||
| readonly required?: ConditionConfig; | ||
| readonly readonly?: ConditionConfig; | ||
| } | ||
| interface StepConditionalBehavior { | ||
| readonly visible?: ConditionConfig; | ||
| readonly skippable?: ConditionConfig; | ||
| } | ||
| interface FormFieldConfig { | ||
@@ -242,4 +761,4 @@ readonly id: string; | ||
| readonly props: Record<string, any>; | ||
| readonly validation?: ValidationConfig; | ||
| readonly conditional?: ConditionalConfig; | ||
| readonly validation?: FieldValidationConfig; | ||
| readonly conditions?: ConditionalBehavior; | ||
| } | ||
@@ -250,16 +769,49 @@ interface FormFieldRow { | ||
| readonly maxColumns?: number; | ||
| readonly spacing?: 'tight' | 'normal' | 'loose'; | ||
| readonly alignment?: 'start' | 'center' | 'end' | 'stretch'; | ||
| } | ||
| interface ConditionalConfig { | ||
| readonly condition: (formData: Record<string, any>) => boolean; | ||
| readonly action: 'show' | 'hide' | 'disable' | 'require'; | ||
| interface FormConfiguration<C extends Record<string, any> = Record<string, never>> { | ||
| readonly id: string; | ||
| readonly config: ril<C>; | ||
| readonly rows: FormFieldRow[]; | ||
| readonly allFields: FormFieldConfig[]; | ||
| readonly renderConfig?: FormRenderConfig; | ||
| readonly validation?: FormValidationConfig; | ||
| } | ||
| interface StepLifecycleHooks { | ||
| readonly onBeforeEnter?: (stepData: any, allData: any, context: WorkflowContext) => Promise<void>; | ||
| readonly onAfterLeave?: (stepData: any, allData: any, context: WorkflowContext) => Promise<boolean>; | ||
| readonly onValidate?: (stepData: any, context: WorkflowContext) => Promise<ValidationResult>; | ||
| readonly onTransform?: (stepData: any, context: WorkflowContext) => Promise<any>; | ||
| readonly onError?: (error: Error, context: WorkflowContext) => Promise<void>; | ||
| interface FormRenderConfig { | ||
| readonly rowRenderer?: FormRowRenderer; | ||
| readonly bodyRenderer?: FormBodyRenderer; | ||
| readonly submitButtonRenderer?: FormSubmitButtonRenderer; | ||
| readonly fieldRenderer?: FieldRenderer; | ||
| } | ||
| interface FormComponentRendererProps { | ||
| children: React__default.ReactNode; | ||
| } | ||
| interface FormRowRendererProps { | ||
| row: FormFieldRow; | ||
| children: React__default.ReactNode; | ||
| className?: string; | ||
| } | ||
| interface FormBodyRendererProps { | ||
| formConfig: FormConfiguration; | ||
| children: React__default.ReactNode; | ||
| className?: string; | ||
| } | ||
| interface FormSubmitButtonRendererProps { | ||
| isSubmitting: boolean; | ||
| onSubmit: () => void; | ||
| className?: string; | ||
| children?: React__default.ReactNode; | ||
| } | ||
| interface FieldRendererProps { | ||
| children: React__default.ReactNode; | ||
| id: string; | ||
| disabled?: boolean; | ||
| error?: ValidationError[]; | ||
| isValidating?: boolean; | ||
| touched?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| type FormRowRenderer = RendererChildrenFunction<FormRowRendererProps>; | ||
| type FormBodyRenderer = RendererChildrenFunction<FormBodyRendererProps>; | ||
| type FormSubmitButtonRenderer = RendererChildrenFunction<FormSubmitButtonRendererProps>; | ||
| type FieldRenderer = RendererChildrenFunction<FieldRendererProps>; | ||
| interface WorkflowContext { | ||
@@ -274,24 +826,35 @@ readonly workflowId: string; | ||
| readonly visitedSteps: Set<string>; | ||
| readonly user?: any; | ||
| readonly visibleVisitedSteps: Set<string>; | ||
| readonly passedSteps: Set<string>; | ||
| } | ||
| interface StepPermissions { | ||
| readonly requiredRoles?: string[]; | ||
| readonly requiredPermissions?: string[]; | ||
| readonly customGuard?: (user: any, context: WorkflowContext) => boolean | Promise<boolean>; | ||
| interface StepDataHelper { | ||
| /** | ||
| * Set data for a specific step by step ID | ||
| */ | ||
| setStepData: (stepId: string, data: Record<string, any>) => void; | ||
| /** | ||
| * Set specific field values for a step | ||
| */ | ||
| setStepFields: (stepId: string, fields: Record<string, any>) => void; | ||
| /** | ||
| * Get current data for a specific step | ||
| */ | ||
| getStepData: (stepId: string) => Record<string, any>; | ||
| /** | ||
| * Set field value for the next step | ||
| */ | ||
| setNextStepField: (fieldId: string, value: any) => void; | ||
| /** | ||
| * Set multiple fields for the next step | ||
| */ | ||
| setNextStepFields: (fields: Record<string, any>) => void; | ||
| /** | ||
| * Get all workflow data | ||
| */ | ||
| getAllData: () => Record<string, any>; | ||
| /** | ||
| * Get all step configurations for reference | ||
| */ | ||
| getSteps: () => StepConfig[]; | ||
| } | ||
| interface DynamicStepConfig { | ||
| readonly resolver: (previousData: any, context: WorkflowContext) => Promise<StepConfig[]>; | ||
| readonly cacheKey?: string; | ||
| readonly retryPolicy?: RetryPolicy; | ||
| } | ||
| interface RetryPolicy { | ||
| readonly maxRetries: number; | ||
| readonly delayMs: number; | ||
| readonly backoffMultiplier?: number; | ||
| } | ||
| interface ConditionalBranch { | ||
| readonly condition: (data: any, context: WorkflowContext) => boolean | Promise<boolean>; | ||
| readonly steps: StepConfig[]; | ||
| readonly fallback?: StepConfig[]; | ||
| } | ||
| interface StepConfig { | ||
@@ -302,55 +865,29 @@ readonly id: string; | ||
| readonly formConfig: FormConfiguration; | ||
| readonly validation?: StepValidationConfig; | ||
| readonly conditional?: StepConditionalConfig; | ||
| readonly allowSkip?: boolean; | ||
| readonly requiredToComplete?: boolean; | ||
| readonly hooks?: StepLifecycleHooks; | ||
| readonly permissions?: StepPermissions; | ||
| readonly isDynamic?: boolean; | ||
| readonly dynamicConfig?: DynamicStepConfig; | ||
| readonly renderer?: CustomStepRenderer; | ||
| readonly conditions?: StepConditionalBehavior; | ||
| readonly metadata?: Record<string, any>; | ||
| readonly onAfterValidation?: (stepData: Record<string, any>, helper: StepDataHelper, context: WorkflowContext) => void | Promise<void>; | ||
| } | ||
| interface StepValidationConfig { | ||
| readonly validator?: (stepData: Record<string, any>, allFormData: Record<string, any>, context: WorkflowContext) => ValidationResult | Promise<ValidationResult>; | ||
| readonly validateOnStepChange?: boolean; | ||
| readonly blockNextIfInvalid?: boolean; | ||
| } | ||
| interface StepConditionalConfig { | ||
| readonly condition: (formData: Record<string, any>, context: WorkflowContext) => boolean; | ||
| readonly action: 'show' | 'hide' | 'skip'; | ||
| } | ||
| type CustomStepRenderer = (props: StepConfig) => React.ReactElement; | ||
| interface WorkflowPersistenceData { | ||
| readonly workflowId: string; | ||
| readonly currentStepIndex: number; | ||
| readonly allData: Record<string, any>; | ||
| readonly metadata: { | ||
| readonly timestamp: number; | ||
| readonly version?: string; | ||
| readonly userId?: string; | ||
| readonly sessionId?: string; | ||
| type CustomStepRenderer = (props: StepConfig) => React__default.ReactElement; | ||
| interface WorkflowConfig { | ||
| readonly id: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly steps: StepConfig[]; | ||
| readonly analytics?: WorkflowAnalytics; | ||
| readonly persistence?: { | ||
| adapter: any; | ||
| options?: any; | ||
| userId?: string; | ||
| }; | ||
| readonly plugins?: WorkflowPlugin[]; | ||
| readonly renderConfig?: WorkflowRenderConfig; | ||
| } | ||
| interface PersistenceAdapter { | ||
| readonly name: string; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list?(pattern?: string): Promise<string[]>; | ||
| interface WorkflowRenderConfig { | ||
| readonly stepperRenderer?: WorkflowStepperRenderer; | ||
| readonly nextButtonRenderer?: WorkflowNextButtonRenderer; | ||
| readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer; | ||
| readonly skipButtonRenderer?: WorkflowSkipButtonRenderer; | ||
| } | ||
| interface PersistenceConfig { | ||
| readonly adapter: PersistenceAdapter; | ||
| readonly key?: string; | ||
| readonly debounceMs?: number; | ||
| readonly autoSave?: boolean; | ||
| readonly saveOnStepChange?: boolean; | ||
| readonly encryptionKey?: string; | ||
| readonly maxRetries?: number; | ||
| readonly retryDelayMs?: number; | ||
| readonly onSave?: (data: WorkflowPersistenceData) => Promise<void> | void; | ||
| readonly onLoad?: (data: WorkflowPersistenceData) => Promise<void> | void; | ||
| readonly onError?: (error: Error, operation: 'save' | 'load' | 'remove') => Promise<void> | void; | ||
| readonly onRetry?: (attempt: number, maxRetries: number, error: Error) => Promise<void> | void; | ||
| } | ||
| interface WorkflowAnalytics { | ||
@@ -363,22 +900,4 @@ readonly onWorkflowStart?: (workflowId: string, context: WorkflowContext) => void; | ||
| readonly onStepSkip?: (stepId: string, reason: string, context: WorkflowContext) => void; | ||
| readonly onValidationError?: (stepId: string, errors: ValidationError[], context: WorkflowContext) => void; | ||
| readonly onError?: (error: Error, context: WorkflowContext) => void; | ||
| } | ||
| interface WorkflowOptimizations { | ||
| readonly preloadNextStep?: boolean; | ||
| readonly cacheValidation?: boolean; | ||
| readonly virtualizeSteps?: boolean; | ||
| readonly lazyLoadComponents?: boolean; | ||
| readonly maxConcurrentRequests?: number; | ||
| } | ||
| interface WorkflowVersion { | ||
| readonly version: string; | ||
| readonly migrationStrategy?: (oldData: any, newConfig: any) => any; | ||
| readonly compatibilityMode?: boolean; | ||
| } | ||
| interface WorkflowHooks { | ||
| readonly onStepChange?: (from: string, to: string, context: WorkflowContext) => void; | ||
| readonly onDataChange?: (data: any, context: WorkflowContext) => void; | ||
| readonly onValidation?: (result: ValidationResult, context: WorkflowContext) => void; | ||
| } | ||
| interface WorkflowPlugin { | ||
@@ -388,31 +907,12 @@ readonly name: string; | ||
| readonly install: (workflow: any) => void; | ||
| readonly hooks?: WorkflowHooks; | ||
| readonly dependencies?: string[]; | ||
| } | ||
| interface WorkflowConfig { | ||
| readonly id: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly steps: StepConfig[]; | ||
| readonly branches?: ConditionalBranch[]; | ||
| readonly navigation?: NavigationConfig; | ||
| readonly persistence?: PersistenceConfig; | ||
| readonly completion?: CompletionConfig; | ||
| readonly analytics?: WorkflowAnalytics; | ||
| readonly optimizations?: WorkflowOptimizations; | ||
| readonly version?: WorkflowVersion; | ||
| readonly plugins?: WorkflowPlugin[]; | ||
| readonly renderConfig?: WorkflowRenderConfig; | ||
| interface WorkflowComponentRendererBaseProps { | ||
| children?: React__default.ReactNode; | ||
| className?: string; | ||
| currentStep: StepConfig; | ||
| stepData: Record<string, any>; | ||
| allData: Record<string, any>; | ||
| context: WorkflowContext; | ||
| } | ||
| interface NavigationConfig { | ||
| readonly allowBackNavigation?: boolean; | ||
| readonly allowStepSkipping?: boolean; | ||
| readonly showProgress?: boolean; | ||
| readonly customNavigation?: boolean; | ||
| } | ||
| interface CompletionConfig { | ||
| readonly onComplete?: (formData: Record<string, any>) => void | Promise<void>; | ||
| readonly confirmBeforeSubmit?: boolean; | ||
| readonly customCompletionStep?: any; | ||
| } | ||
| interface WorkflowStepperRendererProps { | ||
@@ -425,222 +925,485 @@ readonly steps: StepConfig[]; | ||
| } | ||
| interface WorkflowNavigationRendererProps { | ||
| readonly currentStep: StepConfig; | ||
| readonly context: WorkflowContext; | ||
| readonly canGoNext: boolean; | ||
| readonly canGoPrevious: boolean; | ||
| readonly canSkip: boolean; | ||
| readonly isSubmitting: boolean; | ||
| readonly onNext: (event?: React.FormEvent) => void; | ||
| readonly onPrevious: (event?: React.FormEvent) => void; | ||
| readonly onSkip: (event?: React.FormEvent) => void; | ||
| readonly onSubmit: (event?: React.FormEvent) => void; | ||
| readonly className?: string; | ||
| type WorkflowNextButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| isLastStep: boolean; | ||
| canGoNext: boolean; | ||
| isSubmitting: boolean; | ||
| onSubmit: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowPreviousButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| canGoPrevious: boolean; | ||
| isSubmitting: boolean; | ||
| onPrevious: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowSkipButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| canSkip: boolean; | ||
| isSubmitting: boolean; | ||
| onSkip: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowStepperRenderer = RendererChildrenFunction<WorkflowStepperRendererProps>; | ||
| type WorkflowNextButtonRenderer = RendererChildrenFunction<WorkflowNextButtonRendererProps>; | ||
| type WorkflowPreviousButtonRenderer = RendererChildrenFunction<WorkflowPreviousButtonRendererProps>; | ||
| type WorkflowSkipButtonRenderer = RendererChildrenFunction<WorkflowSkipButtonRendererProps>; | ||
| interface PerformanceMetrics { | ||
| readonly timestamp: number; | ||
| readonly duration: number; | ||
| readonly memoryUsage?: number; | ||
| readonly renderCount?: number; | ||
| readonly reRenderCount?: number; | ||
| } | ||
| type WorkflowStepperRenderer = (props: WorkflowStepperRendererProps) => React.ReactElement; | ||
| type WorkflowNavigationRenderer = (props: WorkflowNavigationRendererProps) => React.ReactElement; | ||
| interface WorkflowRenderConfig { | ||
| readonly stepperRenderer?: WorkflowStepperRenderer; | ||
| readonly navigationRenderer?: WorkflowNavigationRenderer; | ||
| interface ComponentPerformanceMetrics extends PerformanceMetrics { | ||
| readonly componentId: string; | ||
| readonly componentType: string; | ||
| readonly propsSize?: number; | ||
| readonly childrenCount?: number; | ||
| } | ||
| interface FormRowRendererProps { | ||
| row: FormFieldRow; | ||
| children: React.ReactNode; | ||
| className?: string; | ||
| spacing?: 'tight' | 'normal' | 'loose'; | ||
| alignment?: 'start' | 'center' | 'end' | 'stretch'; | ||
| interface FormPerformanceMetrics extends PerformanceMetrics { | ||
| readonly formId: string; | ||
| readonly fieldCount: number; | ||
| readonly validationDuration: number; | ||
| readonly renderDuration: number; | ||
| readonly validationErrors: number; | ||
| } | ||
| interface FormBodyRendererProps { | ||
| formConfig: FormConfiguration; | ||
| children: React.ReactNode; | ||
| className?: string; | ||
| interface WorkflowPerformanceMetrics extends PerformanceMetrics { | ||
| readonly workflowId: string; | ||
| readonly stepCount: number; | ||
| readonly currentStepIndex: number; | ||
| readonly navigationDuration: number; | ||
| readonly persistenceDuration?: number; | ||
| readonly conditionEvaluationDuration: number; | ||
| } | ||
| interface FormSubmitButtonRendererProps { | ||
| isSubmitting: boolean; | ||
| isValid: boolean; | ||
| isDirty: boolean; | ||
| onSubmit: () => void; | ||
| className?: string; | ||
| children?: React.ReactNode; | ||
| type MonitoringEventType = 'component_render' | 'component_update' | 'form_validation' | 'form_submission' | 'workflow_navigation' | 'workflow_persistence' | 'condition_evaluation' | 'error' | 'performance_warning'; | ||
| interface MonitoringEvent { | ||
| readonly id: string; | ||
| readonly type: MonitoringEventType; | ||
| readonly timestamp: number; | ||
| readonly source: string; | ||
| readonly data: Record<string, any>; | ||
| readonly metrics?: PerformanceMetrics; | ||
| readonly severity?: 'low' | 'medium' | 'high' | 'critical'; | ||
| } | ||
| type FormRowRenderer = (props: FormRowRendererProps) => React.ReactElement; | ||
| type FormBodyRenderer = (props: FormBodyRendererProps) => React.ReactElement; | ||
| type FormSubmitButtonRenderer = (props: FormSubmitButtonRendererProps) => React.ReactElement; | ||
| interface FormRenderConfig { | ||
| readonly rowRenderer?: FormRowRenderer; | ||
| readonly bodyRenderer?: FormBodyRenderer; | ||
| readonly submitButtonRenderer?: FormSubmitButtonRenderer; | ||
| interface ErrorMonitoringEvent extends MonitoringEvent { | ||
| readonly type: 'error'; | ||
| readonly error: Error; | ||
| readonly stack?: string; | ||
| readonly context?: ValidationContext | WorkflowContext; | ||
| } | ||
| interface FormConfiguration { | ||
| readonly id: string; | ||
| readonly schema?: any; | ||
| readonly config: ril; | ||
| readonly rows: FormFieldRow[]; | ||
| readonly allFields: FormFieldConfig[]; | ||
| readonly renderConfig?: FormRenderConfig; | ||
| interface PerformanceWarningEvent extends MonitoringEvent { | ||
| readonly type: 'performance_warning'; | ||
| readonly threshold: number; | ||
| readonly actualValue: number; | ||
| readonly recommendation?: string; | ||
| } | ||
| interface MonitoringConfig { | ||
| readonly enabled: boolean; | ||
| readonly enablePerformanceTracking?: boolean; | ||
| readonly enableErrorTracking?: boolean; | ||
| readonly enableMemoryTracking?: boolean; | ||
| readonly performanceThresholds?: PerformanceThresholds; | ||
| readonly sampleRate?: number; | ||
| readonly bufferSize?: number; | ||
| readonly flushInterval?: number; | ||
| readonly onEvent?: (event: MonitoringEvent) => void; | ||
| readonly onBatch?: (events: MonitoringEvent[]) => void; | ||
| readonly onError?: (error: Error) => void; | ||
| } | ||
| interface PerformanceThresholds { | ||
| readonly componentRenderTime?: number; | ||
| readonly formValidationTime?: number; | ||
| readonly workflowNavigationTime?: number; | ||
| readonly memoryUsage?: number; | ||
| readonly reRenderCount?: number; | ||
| } | ||
| interface MonitoringAdapter { | ||
| readonly name: string; | ||
| readonly version?: string; | ||
| send: (events: MonitoringEvent[]) => Promise<void>; | ||
| flush?: () => Promise<void>; | ||
| configure?: (config: Record<string, any>) => void; | ||
| } | ||
| interface ConsoleMonitoringAdapter extends MonitoringAdapter { | ||
| readonly name: 'console'; | ||
| readonly logLevel?: 'debug' | 'info' | 'warn' | 'error'; | ||
| } | ||
| interface RemoteMonitoringAdapter extends MonitoringAdapter { | ||
| readonly name: 'remote'; | ||
| readonly endpoint: string; | ||
| readonly apiKey?: string; | ||
| readonly headers?: Record<string, string>; | ||
| readonly batchSize?: number; | ||
| readonly retryAttempts?: number; | ||
| } | ||
| interface MonitoringContext { | ||
| readonly sessionId: string; | ||
| readonly userId?: string; | ||
| readonly userAgent?: string; | ||
| readonly url?: string; | ||
| readonly environment: 'development' | 'production' | 'test'; | ||
| readonly version?: string; | ||
| readonly metadata?: Record<string, any>; | ||
| } | ||
| interface PerformanceProfiler { | ||
| start: (label: string, metadata?: Record<string, any>) => void; | ||
| end: (label: string) => PerformanceMetrics | null; | ||
| mark: (name: string) => void; | ||
| measure: (name: string, startMark: string, endMark?: string) => number; | ||
| getMetrics: (label: string) => PerformanceMetrics | null; | ||
| getAllMetrics: () => Record<string, PerformanceMetrics>; | ||
| clear: (label?: string) => void; | ||
| } | ||
| interface EnhancedWorkflowAnalytics extends WorkflowAnalytics { | ||
| readonly monitoring?: MonitoringConfig; | ||
| readonly onPerformanceWarning?: (event: PerformanceWarningEvent) => void; | ||
| readonly onMemoryLeak?: (metrics: ComponentPerformanceMetrics) => void; | ||
| } | ||
| interface EnhancedFormAnalytics { | ||
| readonly onFormRender?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFormValidation?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFormSubmission?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFieldChange?: (fieldId: string, metrics: ComponentPerformanceMetrics) => void; | ||
| readonly monitoring?: MonitoringConfig; | ||
| } | ||
| declare function ComponentRendererWrapper<TProps = any>({ children, renderAs, renderer, name, props: baseProps, }: ComponentRendererWrapperProps<TProps>): React$1.ReactNode; | ||
| /** | ||
| * Create a Zod-based validator | ||
| * @param schema - Zod schema to validate against | ||
| * @returns Validator function | ||
| * Utility for merging partial configurations into existing objects | ||
| * Eliminates repetitive object spread operations | ||
| */ | ||
| declare const createZodValidator: <T>(schema: z.ZodSchema<T>) => ValidatorFunction; | ||
| declare function mergeInto<T>(target: T, partial: Partial<T>): T; | ||
| /** | ||
| * Create a custom validator from a validation function | ||
| * @param validationFn - Function that returns boolean, string, or Promise | ||
| * @returns Validator function | ||
| * Validates uniqueness of identifiers and throws descriptive errors | ||
| */ | ||
| declare const createCustomValidator: (validationFn: (value: any, context: ValidationContext) => boolean | string | Promise<boolean | string>) => ValidatorFunction; | ||
| declare function ensureUnique(ids: string[], entityName: string): void; | ||
| /** | ||
| * Combine multiple validators | ||
| * @param validators - Array of validators to combine | ||
| * @param mode - 'all' (all must pass) or 'any' (at least one must pass) | ||
| * @returns Combined validator function | ||
| * Validates required fields exist in configurations | ||
| */ | ||
| declare const combineValidators: (validators: ValidatorFunction[], mode?: "all" | "any") => ValidatorFunction; | ||
| declare function validateRequired<T>(items: T[], requiredFields: (keyof T)[], entityName: string): void; | ||
| /** | ||
| * Create a conditional validator that only runs when condition is met | ||
| * @param condition - Function to determine if validation should run | ||
| * @param validator - Validator to run when condition is true | ||
| * @returns Conditional validator function | ||
| * Auto-generates IDs when not provided | ||
| */ | ||
| declare const createConditionalValidator: (condition: (value: any, context: ValidationContext) => boolean, validator: ValidatorFunction) => ValidatorFunction; | ||
| declare class IdGenerator { | ||
| private counters; | ||
| next(prefix: string): string; | ||
| reset(prefix?: string): void; | ||
| } | ||
| /** | ||
| * Common validation patterns | ||
| * Polymorphic helper for handling single items or arrays | ||
| */ | ||
| declare const commonValidators: { | ||
| declare function normalizeToArray<T>(input: T | T[]): T[]; | ||
| /** | ||
| * Deep clone utility for configuration objects | ||
| */ | ||
| declare function deepClone<T>(obj: T): T; | ||
| /** | ||
| * Generic configuration merger with type safety | ||
| */ | ||
| declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?: (keyof T)[]): T; | ||
| declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode; | ||
| /** | ||
| * @fileoverview Clean validation utilities for Standard Schema | ||
| * | ||
| * This module provides utility functions for working with validation results | ||
| * and managing validation contexts using Standard Schema exclusively. | ||
| */ | ||
| /** | ||
| * Creates a validation result object | ||
| * | ||
| * @param isValid - Whether the validation passed | ||
| * @param errors - Array of validation errors (empty if valid) | ||
| * @returns A complete ValidationResult object | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = createValidationResult(false, [ | ||
| * { message: 'Email is required', code: 'REQUIRED' } | ||
| * ]); | ||
| * ``` | ||
| */ | ||
| declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult; | ||
| /** | ||
| * Creates a successful validation result | ||
| * | ||
| * @returns A successful ValidationResult with no errors | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const success = createSuccessResult(); | ||
| * ``` | ||
| */ | ||
| declare function createSuccessResult(): ValidationResult; | ||
| /** | ||
| * Creates a failed validation result with a single error | ||
| * | ||
| * @param message - The error message | ||
| * @param code - Optional error code | ||
| * @param path - Optional field path | ||
| * @returns A failed ValidationResult | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const error = createErrorResult('Email is invalid', 'INVALID_EMAIL'); | ||
| * ``` | ||
| */ | ||
| declare function createErrorResult(message: string, code?: string, path?: string): ValidationResult; | ||
| /** | ||
| * Creates a validation context object | ||
| * | ||
| * @param options - Context configuration options | ||
| * @returns A complete ValidationContext object | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const context = createValidationContext({ | ||
| * fieldId: 'email', | ||
| * formId: 'registration', | ||
| * allFormData: { email: 'test@example.com', name: 'John' } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext; | ||
| /** | ||
| * Built-in validators implementing Standard Schema interface | ||
| * All RilayKit validators now implement Standard Schema for consistency | ||
| */ | ||
| /** | ||
| * Required field validator - Standard Schema implementation | ||
| */ | ||
| declare function required(message?: string): StandardSchemaV1<any>; | ||
| /** | ||
| * Email validation - Standard Schema implementation | ||
| */ | ||
| declare function email(message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * URL validation - Standard Schema implementation | ||
| */ | ||
| declare function url(message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Minimum length validation - Standard Schema implementation | ||
| */ | ||
| declare function minLength(min: number, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Maximum length validation - Standard Schema implementation | ||
| */ | ||
| declare function maxLength(max: number, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Pattern validation - Standard Schema implementation | ||
| */ | ||
| declare function pattern(regex: RegExp, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Number validation - Standard Schema implementation | ||
| */ | ||
| declare function number(message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Minimum value validation - Standard Schema implementation | ||
| */ | ||
| declare function min(minValue: number, message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Maximum value validation - Standard Schema implementation | ||
| */ | ||
| declare function max(maxValue: number, message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Custom validator - Standard Schema implementation | ||
| */ | ||
| declare function custom<T>(fn: (value: T) => boolean, message?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Async validator - Standard Schema implementation | ||
| */ | ||
| declare function async<T>(fn: (value: T) => Promise<boolean>, message?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Utility to combine multiple Standard Schema validators | ||
| * This creates a new Standard Schema that runs all validations | ||
| */ | ||
| declare function combine<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>; | ||
| /** | ||
| * Unified validation utilities for Standard Schema only | ||
| * These replace the old validator-based system with a clean Standard Schema approach | ||
| */ | ||
| /** | ||
| * Checks if a value implements the Standard Schema interface | ||
| */ | ||
| declare function isStandardSchema(value: any): value is StandardSchema; | ||
| /** | ||
| * Validates a value using a Standard Schema | ||
| */ | ||
| declare function validateWithStandardSchema<T extends StandardSchema>(schema: T, value: unknown): Promise<ValidationResult>; | ||
| /** | ||
| * Utility to extract input type from Standard Schema at runtime (for debugging) | ||
| */ | ||
| declare function getSchemaInfo(schema: StandardSchema): { | ||
| vendor: string; | ||
| version: number; | ||
| hasTypes: boolean; | ||
| }; | ||
| /** | ||
| * Type guard to check if a schema has type information | ||
| */ | ||
| declare function hasSchemaTypes<T extends StandardSchema>(schema: T): schema is T & { | ||
| '~standard': { | ||
| types: NonNullable<T['~standard']['types']>; | ||
| }; | ||
| }; | ||
| /** | ||
| * Validates a value using unified validation config | ||
| * Handles single schemas, arrays of schemas, and combines results | ||
| */ | ||
| declare function validateWithUnifiedConfig<T>(config: FieldValidationConfig<T>, value: T, _context: ValidationContext): Promise<ValidationResult>; | ||
| /** | ||
| * Validates form data using unified validation config | ||
| */ | ||
| declare function validateFormWithUnifiedConfig<T extends Record<string, any>>(config: FormValidationConfig<T>, formData: T, _context: ValidationContext): Promise<ValidationResult>; | ||
| /** | ||
| * Checks if a field validation config has any validation rules | ||
| */ | ||
| declare function hasUnifiedValidation(config: FieldValidationConfig | FormValidationConfig): boolean; | ||
| /** | ||
| * Combines multiple Standard Schemas into a single schema | ||
| * This is useful for combining built-in validators with external schemas | ||
| */ | ||
| declare function combineSchemas<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>; | ||
| /** | ||
| * Utility to create a Standard Schema from any validation function | ||
| * This helps migrate existing validators to Standard Schema | ||
| */ | ||
| declare function createStandardValidator<T>(validateFn: (value: T, context?: ValidationContext) => ValidationResult | Promise<ValidationResult>, vendor?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Type guard to check if value is a Standard Schema or array of Standard Schemas | ||
| */ | ||
| declare function isValidationRule(value: any): value is StandardSchema | StandardSchema[]; | ||
| /** | ||
| * Normalizes validation config to always return an array of Standard Schemas | ||
| */ | ||
| declare function normalizeValidationRules<T>(validate: StandardSchema<T> | StandardSchema<T>[] | undefined): StandardSchema<T>[]; | ||
| /** | ||
| * Core monitoring system for Rilay | ||
| * Tracks performance metrics, events, and errors across forms and workflows | ||
| */ | ||
| declare class RilayMonitor { | ||
| private config; | ||
| private context; | ||
| private adapters; | ||
| private eventBuffer; | ||
| private flushTimer?; | ||
| private profiler; | ||
| constructor(config: MonitoringConfig, context?: Partial<MonitoringContext>); | ||
| /** | ||
| * Required field validator | ||
| * Add a monitoring adapter | ||
| */ | ||
| required: (message?: string) => ValidatorFunction; | ||
| addAdapter(adapter: MonitoringAdapter): void; | ||
| /** | ||
| * Email validation | ||
| * Remove a monitoring adapter | ||
| */ | ||
| email: (message?: string) => ValidatorFunction; | ||
| removeAdapter(adapterName: string): void; | ||
| /** | ||
| * Minimum length validation | ||
| * Track a monitoring event | ||
| */ | ||
| minLength: (min: number, message?: string) => ValidatorFunction; | ||
| track(type: MonitoringEventType, source: string, data: Record<string, any>, metrics?: PerformanceMetrics, severity?: 'low' | 'medium' | 'high' | 'critical'): void; | ||
| /** | ||
| * Maximum length validation | ||
| * Track an error | ||
| */ | ||
| maxLength: (max: number, message?: string) => ValidatorFunction; | ||
| trackError(error: Error, source: string, context?: any): void; | ||
| /** | ||
| * Pattern/regex validation | ||
| * Get the performance profiler | ||
| */ | ||
| pattern: (regex: RegExp, message?: string) => ValidatorFunction; | ||
| getProfiler(): PerformanceProfiler; | ||
| /** | ||
| * Number range validation | ||
| * Update monitoring context | ||
| */ | ||
| numberRange: (min?: number, max?: number, message?: string) => ValidatorFunction; | ||
| updateContext(updates: Partial<MonitoringContext>): void; | ||
| /** | ||
| * URL validation | ||
| * Flush all buffered events | ||
| */ | ||
| url: (message?: string) => ValidatorFunction; | ||
| flush(): Promise<void>; | ||
| /** | ||
| * Phone number validation (basic) | ||
| * Destroy the monitor and clean up resources | ||
| */ | ||
| phoneNumber: (message?: string) => ValidatorFunction; | ||
| /** | ||
| * Custom async validation with debouncing | ||
| */ | ||
| asyncValidation: (asyncFn: (value: any, context: ValidationContext) => Promise<boolean | string>, debounceMs?: number) => ValidatorFunction; | ||
| }; | ||
| destroy(): Promise<void>; | ||
| private startFlushTimer; | ||
| private checkPerformanceThresholds; | ||
| private createPerformanceWarning; | ||
| } | ||
| /** | ||
| * Utility to create validation result | ||
| * @param isValid - Whether validation passed | ||
| * @param errors - Array of errors (optional) | ||
| * @param warnings - Array of warnings (optional) | ||
| * @returns ValidationResult object | ||
| * Initialize global monitoring | ||
| */ | ||
| declare const createValidationResult: (isValid: boolean, errors?: ValidationError[], warnings?: ValidationError[]) => ValidationResult; | ||
| declare function initializeMonitoring(config: MonitoringConfig, context?: Partial<MonitoringContext>): RilayMonitor; | ||
| /** | ||
| * Utility to create validation error | ||
| * @param code - Error code | ||
| * @param message - Error message | ||
| * @param path - Error path (optional) | ||
| * @returns ValidationError object | ||
| * Get the global monitor instance | ||
| */ | ||
| declare const createValidationError: (code: string, message: string, path?: string[]) => ValidationError; | ||
| declare function getGlobalMonitor(): RilayMonitor | null; | ||
| /** | ||
| * Destroy global monitoring | ||
| */ | ||
| declare function destroyGlobalMonitoring(): Promise<void>; | ||
| /** | ||
| * LocalStorage persistence adapter | ||
| * Perfect for client-side persistence across browser sessions | ||
| * Console monitoring adapter | ||
| * Logs events to the browser console | ||
| */ | ||
| declare class LocalStorageAdapter implements PersistenceAdapter { | ||
| readonly name = "localStorage"; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class ConsoleAdapter implements ConsoleMonitoringAdapter { | ||
| readonly name = "console"; | ||
| readonly logLevel: 'debug' | 'info' | 'warn' | 'error'; | ||
| constructor(logLevel?: 'debug' | 'info' | 'warn' | 'error'); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| private logEvent; | ||
| private shouldLog; | ||
| } | ||
| /** | ||
| * SessionStorage persistence adapter | ||
| * Perfect for temporary persistence within a single browser session | ||
| * Remote monitoring adapter | ||
| * Sends events to a remote endpoint | ||
| */ | ||
| declare class SessionStorageAdapter implements PersistenceAdapter { | ||
| readonly name = "sessionStorage"; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class RemoteAdapter implements RemoteMonitoringAdapter { | ||
| readonly name = "remote"; | ||
| readonly endpoint: string; | ||
| readonly apiKey?: string; | ||
| readonly headers: Record<string, string>; | ||
| readonly batchSize: number; | ||
| readonly retryAttempts: number; | ||
| private eventQueue; | ||
| private isProcessing; | ||
| constructor(config: { | ||
| endpoint: string; | ||
| apiKey?: string; | ||
| headers?: Record<string, string>; | ||
| batchSize?: number; | ||
| retryAttempts?: number; | ||
| }); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| flush(): Promise<void>; | ||
| configure(config: Record<string, any>): void; | ||
| private processQueue; | ||
| private sendBatch; | ||
| private delay; | ||
| } | ||
| /** | ||
| * In-Memory persistence adapter | ||
| * Perfect for testing or temporary workflows | ||
| * Local storage adapter for offline support | ||
| */ | ||
| declare class MemoryAdapter implements PersistenceAdapter { | ||
| readonly name = "memory"; | ||
| private storage; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| clear(): void; | ||
| declare class LocalStorageAdapter implements MonitoringAdapter { | ||
| readonly name = "localStorage"; | ||
| private readonly storageKey; | ||
| private readonly maxEvents; | ||
| constructor(maxEvents?: number); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| flush(): Promise<void>; | ||
| getStoredEvents(): MonitoringEvent[]; | ||
| clearStoredEvents(): void; | ||
| getEventCount(): number; | ||
| } | ||
| /** | ||
| * Composite adapter that can use multiple adapters with fallback | ||
| * Perfect for robust persistence with primary/backup strategies | ||
| * Development adapter that provides detailed logging | ||
| */ | ||
| declare class CompositeAdapter implements PersistenceAdapter { | ||
| private primary; | ||
| private fallbacks; | ||
| readonly name = "composite"; | ||
| constructor(primary: PersistenceAdapter, fallbacks?: PersistenceAdapter[]); | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class DevelopmentAdapter implements MonitoringAdapter { | ||
| readonly name = "development"; | ||
| private readonly console; | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| private logPerformanceSummary; | ||
| private logErrorSummary; | ||
| } | ||
| /** | ||
| * Utility functions to create persistence configurations easily | ||
| */ | ||
| declare const persistence: { | ||
| /** | ||
| * Create a localStorage-based persistence configuration | ||
| */ | ||
| localStorage(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create a sessionStorage-based persistence configuration | ||
| */ | ||
| sessionStorage(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create an in-memory persistence configuration (for testing) | ||
| */ | ||
| memory(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create a custom persistence configuration | ||
| */ | ||
| custom(adapter: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| }; | ||
| /** | ||
| * Utility to create persistence configurations with retry logic | ||
| */ | ||
| declare function createResilientPersistence(primary: PersistenceAdapter, fallback?: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| 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 }; | ||
| 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 }; |
+1192
-429
@@ -1,143 +0,317 @@ | ||
| import React from 'react'; | ||
| import { z } from 'zod'; | ||
| import { StandardSchemaV1 } from '@standard-schema/spec'; | ||
| import * as React$1 from 'react'; | ||
| import React__default from 'react'; | ||
| /** | ||
| * Main configuration class for Rilay form components and workflows | ||
| * Manages component registration, retrieval, and configuration | ||
| * A graph that tracks which fields depend on which other fields for condition evaluation. | ||
| * | ||
| * This enables efficient re-evaluation of conditions when values change: | ||
| * instead of re-evaluating ALL conditions when ANY value changes, | ||
| * we only re-evaluate conditions that depend on the changed value. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const graph = new ConditionDependencyGraph(); | ||
| * | ||
| * // Add field with its conditions | ||
| * graph.addField('dependentField', { | ||
| * visible: when('triggerField').equals('show') | ||
| * }); | ||
| * | ||
| * // When 'triggerField' changes, get affected fields | ||
| * const affected = graph.getAffectedFields('triggerField'); | ||
| * // affected = ['dependentField'] | ||
| * ``` | ||
| */ | ||
| declare class ril { | ||
| private components; | ||
| private formRenderConfig; | ||
| private workflowRenderConfig; | ||
| static create(): ril; | ||
| declare class ConditionDependencyGraph { | ||
| /** | ||
| * Add a component to the configuration | ||
| * @param subType - The component subtype (e.g., 'text', 'email', 'heading') | ||
| * @param config - Component configuration without id and subType | ||
| * @returns The ril instance for chaining | ||
| * Maps field IDs to their dependencies (fields they depend on) | ||
| * fieldId -> Set of field paths it depends on | ||
| */ | ||
| addComponent<TProps = any>(subType: InputType | LayoutType, config: Omit<ComponentConfig<TProps>, 'id' | 'subType'> & { | ||
| id?: string; | ||
| }): this; | ||
| private readonly fieldDependencies; | ||
| /** | ||
| * Set custom row renderer | ||
| * @param renderer - Custom row renderer function | ||
| * @returns The ril instance for chaining | ||
| * Reverse index: maps a field path to all fields that depend on it | ||
| * fieldPath -> Set of field IDs that have conditions depending on this path | ||
| */ | ||
| setRowRenderer(renderer: FormRowRenderer): this; | ||
| private readonly reverseDependencies; | ||
| /** | ||
| * Set custom body renderer | ||
| * @param renderer - Custom body renderer function | ||
| * @returns The ril instance for chaining | ||
| * Adds a field with its conditional behavior to the graph. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @param conditions - The field's conditional behavior (visible, disabled, required, readonly) | ||
| */ | ||
| setBodyRenderer(renderer: FormBodyRenderer): this; | ||
| addField(fieldId: string, conditions?: ConditionalBehavior): void; | ||
| /** | ||
| * Set custom submit button renderer | ||
| * @param renderer - Custom submit button renderer function | ||
| * @returns The ril instance for chaining | ||
| * Removes a field from the graph. | ||
| * | ||
| * @param fieldId - The ID of the field to remove | ||
| */ | ||
| setSubmitButtonRenderer(renderer: FormSubmitButtonRenderer): this; | ||
| removeField(fieldId: string): void; | ||
| /** | ||
| * Set complete form render configuration | ||
| * @param config - Form render configuration | ||
| * @returns The ril instance for chaining | ||
| * Gets all field IDs that have conditions depending on a specific field path. | ||
| * | ||
| * When a value at `changedPath` changes, these are the fields whose | ||
| * conditions need to be re-evaluated. | ||
| * | ||
| * @param changedPath - The field path that changed | ||
| * @returns Array of field IDs that depend on this path | ||
| */ | ||
| setFormRenderConfig(config: FormRenderConfig): this; | ||
| getAffectedFields(changedPath: string): string[]; | ||
| /** | ||
| * Get current form render configuration | ||
| * @returns Current form render configuration | ||
| * Gets all field IDs affected by changes to multiple paths. | ||
| * | ||
| * @param changedPaths - Array of field paths that changed | ||
| * @returns Array of unique field IDs that depend on any of these paths | ||
| */ | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getAffectedFieldsMultiple(changedPaths: string[]): string[]; | ||
| /** | ||
| * Set custom stepper renderer for workflows | ||
| * @param renderer - Custom stepper renderer function | ||
| * @returns The ril instance for chaining | ||
| * Gets the dependencies for a specific field. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @returns Array of field paths this field depends on | ||
| */ | ||
| setStepperRenderer(renderer: WorkflowStepperRenderer): this; | ||
| getDependencies(fieldId: string): string[]; | ||
| /** | ||
| * Set custom workflow navigation renderer | ||
| * @param renderer - Custom workflow navigation renderer function | ||
| * @returns The ril instance for chaining | ||
| * Checks if a field has any dependencies. | ||
| * | ||
| * @param fieldId - The ID of the field | ||
| * @returns True if the field has conditional dependencies | ||
| */ | ||
| setWorkflowNavigationRenderer(renderer: WorkflowNavigationRenderer): this; | ||
| hasDependencies(fieldId: string): boolean; | ||
| /** | ||
| * Set complete workflow render configuration | ||
| * @param config - Workflow render configuration | ||
| * @returns The ril instance for chaining | ||
| * Gets all fields in the graph. | ||
| * | ||
| * @returns Array of all field IDs | ||
| */ | ||
| setWorkflowRenderConfig(config: WorkflowRenderConfig): this; | ||
| getAllFields(): string[]; | ||
| /** | ||
| * Get current workflow render configuration | ||
| * @returns Current workflow render configuration | ||
| * Gets all unique dependency paths in the graph. | ||
| * | ||
| * @returns Array of all field paths that are dependencies | ||
| */ | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| getAllDependencyPaths(): string[]; | ||
| /** | ||
| * @deprecated Use setFormRenderConfig() instead | ||
| * Clears the entire graph. | ||
| */ | ||
| setRenderConfig(config: FormRenderConfig): this; | ||
| clear(): void; | ||
| /** | ||
| * Get a component by its ID | ||
| * @param id - Component ID | ||
| * @returns Component configuration or undefined | ||
| * Gets the size of the graph (number of fields). | ||
| */ | ||
| get size(): number; | ||
| /** | ||
| * Creates a debug representation of the graph. | ||
| * Useful for development and testing. | ||
| */ | ||
| toDebugObject(): { | ||
| fields: Record<string, string[]>; | ||
| reverseDeps: Record<string, string[]>; | ||
| }; | ||
| } | ||
| type ConditionOperator = 'equals' | 'notEquals' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'contains' | 'notContains' | 'in' | 'notIn' | 'matches' | 'exists' | 'notExists'; | ||
| type LogicalOperator = 'and' | 'or'; | ||
| type ConditionValue = string | number | boolean | null | undefined | Array<string | number | boolean>; | ||
| interface ConditionConfig { | ||
| field: string; | ||
| operator: ConditionOperator; | ||
| value?: ConditionValue; | ||
| conditions?: ConditionConfig[]; | ||
| logicalOperator?: LogicalOperator; | ||
| } | ||
| type ConditionEvaluator = (data: Record<string, any>) => boolean; | ||
| interface ConditionBuilder extends ConditionConfig { | ||
| equals(value: ConditionValue): ConditionBuilder; | ||
| notEquals(value: ConditionValue): ConditionBuilder; | ||
| greaterThan(value: number): ConditionBuilder; | ||
| lessThan(value: number): ConditionBuilder; | ||
| greaterThanOrEqual(value: number): ConditionBuilder; | ||
| lessThanOrEqual(value: number): ConditionBuilder; | ||
| contains(value: string): ConditionBuilder; | ||
| notContains(value: string): ConditionBuilder; | ||
| in(values: Array<string | number | boolean>): ConditionBuilder; | ||
| notIn(values: Array<string | number | boolean>): ConditionBuilder; | ||
| matches(pattern: string | RegExp): ConditionBuilder; | ||
| exists(): ConditionBuilder; | ||
| notExists(): ConditionBuilder; | ||
| and(condition: ConditionBuilder | ConditionConfig): ConditionBuilder; | ||
| or(condition: ConditionBuilder | ConditionConfig): ConditionBuilder; | ||
| build(): ConditionConfig; | ||
| evaluate(data: Record<string, any>): boolean; | ||
| } | ||
| declare function when(field: string): ConditionBuilder; | ||
| declare function evaluateCondition(condition: ConditionConfig, data: Record<string, any>): boolean; | ||
| /** | ||
| * Extracts all field paths that a condition depends on. | ||
| * | ||
| * This is useful for building a dependency graph that knows which | ||
| * conditions need to be re-evaluated when a specific field changes. | ||
| * | ||
| * @param condition - The condition to extract dependencies from | ||
| * @returns An array of unique field paths | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const condition = when('field1').equals('value').and(when('field2').exists()); | ||
| * const deps = extractConditionDependencies(condition.build()); | ||
| * // deps = ['field1', 'field2'] | ||
| * | ||
| * const nestedCondition = when('step1.field1').equals('value'); | ||
| * const nestedDeps = extractConditionDependencies(nestedCondition.build()); | ||
| * // nestedDeps = ['step1.field1'] | ||
| * ``` | ||
| */ | ||
| declare function extractConditionDependencies(condition: ConditionConfig | ConditionBuilder | undefined | null): string[]; | ||
| /** | ||
| * Extracts dependencies from multiple conditions (e.g., visible, disabled, required). | ||
| * | ||
| * @param behaviors - Object containing condition configurations | ||
| * @returns An array of unique field paths from all conditions | ||
| */ | ||
| declare function extractAllDependencies(behaviors: Record<string, ConditionConfig | ConditionBuilder | undefined | null>): string[]; | ||
| /** | ||
| * Validation result for async operations | ||
| */ | ||
| interface AsyncValidationResult { | ||
| isValid: boolean; | ||
| errors: string[]; | ||
| warnings?: string[]; | ||
| } | ||
| /** | ||
| * Public interface for Rilay instances | ||
| * Exposes only the methods necessary for the public API | ||
| */ | ||
| interface RilayInstance<C> { | ||
| addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): RilayInstance<C & { | ||
| [K in NewType]: TProps; | ||
| }>; | ||
| configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): RilayInstance<C>; | ||
| getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined; | ||
| getComponent(id: string): ComponentConfig | undefined; | ||
| getAllComponents(): ComponentConfig[]; | ||
| hasComponent(id: string): boolean; | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| getStats(): { | ||
| total: number; | ||
| byType: Record<string, number>; | ||
| hasCustomRenderers: { | ||
| row: boolean; | ||
| body: boolean; | ||
| submitButton: boolean; | ||
| field: boolean; | ||
| stepper: boolean; | ||
| workflowNextButton: boolean; | ||
| workflowPreviousButton: boolean; | ||
| workflowSkipButton: boolean; | ||
| }; | ||
| }; | ||
| validate(): string[]; | ||
| validateAsync(): Promise<AsyncValidationResult>; | ||
| clone(): RilayInstance<C>; | ||
| removeComponent(id: string): RilayInstance<C>; | ||
| clear(): RilayInstance<C>; | ||
| } | ||
| /** | ||
| * Main configuration class for Rilay form components and workflows | ||
| * Manages component registration, retrieval, and configuration with immutable API | ||
| */ | ||
| declare class ril<C> implements RilayInstance<C> { | ||
| private components; | ||
| private formRenderConfig; | ||
| private workflowRenderConfig; | ||
| /** | ||
| * List components by type (input or layout) | ||
| * @param type - Component type | ||
| * @returns Array of matching components | ||
| * Static factory method to create a new ril instance | ||
| */ | ||
| getComponentsByType(type: ComponentType): ComponentConfig[]; | ||
| static create<CT>(): ril<CT>; | ||
| /** | ||
| * List components by sub-type | ||
| * @param subType - Component sub-type | ||
| * @returns Array of matching components | ||
| * Add a component to the configuration (immutable) | ||
| * Returns a new instance with the added component | ||
| * | ||
| * @param type - The component type (e.g., 'text', 'email', 'heading'), used as a unique identifier. | ||
| * @param config - Component configuration without id and type | ||
| * @returns A new ril instance with the added component | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Component with default validation | ||
| * const factory = ril.create() | ||
| * .addComponent('email', { | ||
| * name: 'Email Input', | ||
| * renderer: EmailInput, | ||
| * validation: { | ||
| * validators: [email('Format email invalide')], | ||
| * validateOnBlur: true, | ||
| * } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getComponentsBySubType(subType: InputType | LayoutType): ComponentConfig[]; | ||
| addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): ril<C & { | ||
| [K in NewType]: TProps; | ||
| }>; | ||
| /** | ||
| * Get components by category | ||
| * @param category - Component category | ||
| * @returns Array of matching components | ||
| * Universal configuration method with deep merge support (immutable) | ||
| * | ||
| * This method provides a unified API to configure both form and workflow renderers | ||
| * in a single call, automatically categorizing and applying the appropriate configurations | ||
| * using recursive deep merge. | ||
| * | ||
| * @param config - Configuration object containing renderer settings | ||
| * @returns A new ril instance with the updated configuration | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Configure with nested settings | ||
| * const config = ril.create() | ||
| * .configure({ | ||
| * rowRenderer: CustomRowRenderer, | ||
| * submitButtonRenderer: CustomSubmitButton, | ||
| * // Deep nested configuration example | ||
| * formStyles: { | ||
| * layout: { | ||
| * spacing: 'large', | ||
| * alignment: 'center' | ||
| * } | ||
| * } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getComponentsByCategory(category: string): ComponentConfig[]; | ||
| configure(config: Partial<FormRenderConfig & WorkflowRenderConfig>): ril<C>; | ||
| /** | ||
| * List all registered components | ||
| * @returns Array of all components | ||
| * Configuration getters | ||
| */ | ||
| getAllComponents(): ComponentConfig[]; | ||
| getFormRenderConfig(): FormRenderConfig; | ||
| getWorkflowRenderConfig(): WorkflowRenderConfig; | ||
| /** | ||
| * Check if a component exists | ||
| * @param id - Component ID | ||
| * @returns True if component exists | ||
| * Component management methods | ||
| */ | ||
| getComponent<T extends keyof C & string>(id: T): ComponentConfig<C[T]> | undefined; | ||
| getAllComponents(): ComponentConfig[]; | ||
| hasComponent(id: string): boolean; | ||
| /** | ||
| * Remove a component from the configuration | ||
| * @param id - Component ID | ||
| * @returns True if component was removed | ||
| * Remove a component from the configuration (immutable) | ||
| * Returns a new instance without the specified component | ||
| * | ||
| * @param id - The component ID to remove | ||
| * @returns A new ril instance without the component | ||
| */ | ||
| removeComponent(id: string): boolean; | ||
| removeComponent(id: string): ril<C>; | ||
| /** | ||
| * Clear all components | ||
| * Clear all components from the configuration (immutable) | ||
| * Returns a new instance with no components | ||
| * | ||
| * @returns A new empty ril instance | ||
| */ | ||
| clear(): void; | ||
| clear(): ril<C>; | ||
| /** | ||
| * Export configuration as a plain object | ||
| * @returns Object with component configurations | ||
| * Create a deep copy of the current ril instance | ||
| */ | ||
| export(): Record<string, ComponentConfig>; | ||
| clone(): ril<C>; | ||
| /** | ||
| * Import configuration from a plain object | ||
| * @param config - Object with component configurations | ||
| * @returns The ril instance for chaining | ||
| * Enhanced statistics with more detailed information | ||
| */ | ||
| import(config: Record<string, ComponentConfig>): this; | ||
| /** | ||
| * Get statistics about registered components and renderers | ||
| * @returns Object with comprehensive statistics | ||
| */ | ||
| getStats(): { | ||
| total: number; | ||
| byType: Record<ComponentType, number>; | ||
| bySubType: Record<string, number>; | ||
| byCategory: Record<string, number>; | ||
| byType: Record<string, number>; | ||
| hasCustomRenderers: { | ||
@@ -147,13 +321,213 @@ row: boolean; | ||
| submitButton: boolean; | ||
| field: boolean; | ||
| stepper: boolean; | ||
| workflowNavigation: boolean; | ||
| workflowNextButton: boolean; | ||
| workflowPreviousButton: boolean; | ||
| workflowSkipButton: boolean; | ||
| }; | ||
| }; | ||
| /** | ||
| * Validate the configuration | ||
| * @returns Array of validation errors | ||
| * Synchronous validation using shared utilities | ||
| */ | ||
| validate(): string[]; | ||
| /** | ||
| * Asynchronous validation with structured error handling | ||
| * Ideal for CI/CD pipelines and advanced validation scenarios | ||
| */ | ||
| validateAsync(): Promise<AsyncValidationResult>; | ||
| } | ||
| type ValidationState = 'idle' | 'validating' | 'valid' | 'invalid'; | ||
| /** | ||
| * Field state without actions - used for selectors | ||
| */ | ||
| interface FieldState { | ||
| readonly value: unknown; | ||
| readonly errors: ValidationError[]; | ||
| readonly validationState: ValidationState; | ||
| readonly touched: boolean; | ||
| readonly dirty: boolean; | ||
| } | ||
| /** | ||
| * Field conditions - visibility, disabled, required, readonly | ||
| */ | ||
| interface FieldConditions { | ||
| readonly visible: boolean; | ||
| readonly disabled: boolean; | ||
| readonly required: boolean; | ||
| readonly readonly: boolean; | ||
| } | ||
| /** | ||
| * Field actions - stable references for setValue, validate, etc. | ||
| */ | ||
| interface FieldActions { | ||
| readonly setValue: (value: unknown) => void; | ||
| readonly setTouched: () => void; | ||
| readonly validate: () => Promise<ValidationResult>; | ||
| readonly clearErrors: () => void; | ||
| } | ||
| /** | ||
| * Complete field context - combines state, conditions and actions | ||
| * Used by component renderers for full field access | ||
| */ | ||
| interface FieldContext extends FieldState, FieldConditions { | ||
| readonly id: string; | ||
| readonly componentId: string; | ||
| readonly defaultValue?: unknown; | ||
| readonly actions: FieldActions; | ||
| } | ||
| /** | ||
| * Form state without actions - used for selectors | ||
| */ | ||
| interface FormState { | ||
| readonly values: Record<string, unknown>; | ||
| readonly errors: Record<string, ValidationError[]>; | ||
| readonly validationStates: Record<string, ValidationState>; | ||
| readonly touched: Record<string, boolean>; | ||
| readonly isDirty: boolean; | ||
| readonly isSubmitting: boolean; | ||
| readonly isValid: boolean; | ||
| } | ||
| /** | ||
| * Form actions - stable references | ||
| */ | ||
| interface FormActions { | ||
| readonly setValue: (fieldId: string, value: unknown) => void; | ||
| readonly setTouched: (fieldId: string) => void; | ||
| readonly setErrors: (fieldId: string, errors: ValidationError[]) => void; | ||
| readonly setValidationState: (fieldId: string, state: ValidationState) => void; | ||
| readonly setSubmitting: (isSubmitting: boolean) => void; | ||
| readonly submit: () => Promise<boolean>; | ||
| readonly reset: (values?: Record<string, unknown>) => void; | ||
| readonly validate: () => Promise<ValidationResult>; | ||
| readonly validateField: (fieldId: string, value?: unknown) => Promise<ValidationResult>; | ||
| } | ||
| /** | ||
| * Complete form context - combines state and actions | ||
| */ | ||
| interface FormContextValue extends FormState { | ||
| readonly formId: string; | ||
| readonly actions: FormActions; | ||
| readonly getFieldState: (fieldId: string) => FieldState; | ||
| readonly getFieldConditions: (fieldId: string) => FieldConditions; | ||
| } | ||
| /** | ||
| * Props passed to component renderers (v2) | ||
| * Replaces the old ComponentRenderProps with spread [key: string]: any | ||
| */ | ||
| interface ComponentRenderPropsV2<TProps = unknown> { | ||
| /** Field identifier */ | ||
| readonly id: string; | ||
| /** Component-specific props (label, placeholder, options, etc.) */ | ||
| readonly props: TProps; | ||
| /** Field state (value, errors, touched, etc.) */ | ||
| readonly field: FieldState; | ||
| /** Field conditions (visible, disabled, required, readonly) */ | ||
| readonly conditions: FieldConditions; | ||
| /** Stable action references */ | ||
| readonly actions: FieldActions; | ||
| } | ||
| /** | ||
| * Props passed to field wrapper renderers (v2) | ||
| */ | ||
| interface FieldRendererPropsV2 { | ||
| /** Rendered component content */ | ||
| readonly children: React.ReactNode; | ||
| /** Field identifier */ | ||
| readonly id: string; | ||
| /** Field state */ | ||
| readonly field: FieldState; | ||
| /** Field conditions */ | ||
| readonly conditions: FieldConditions; | ||
| /** Component props (for label, placeholder, helpText, etc.) */ | ||
| readonly componentProps: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Props passed to form submit button renderer (v2) | ||
| */ | ||
| interface FormSubmitButtonRendererPropsV2 { | ||
| /** Whether form is currently submitting */ | ||
| readonly isSubmitting: boolean; | ||
| /** Whether form is valid (no errors) */ | ||
| readonly isValid: boolean; | ||
| /** Whether form has been modified */ | ||
| readonly isDirty: boolean; | ||
| /** Submit handler */ | ||
| readonly onSubmit: () => void; | ||
| /** Reset handler */ | ||
| readonly onReset: () => void; | ||
| /** Form data access (for advanced use cases) */ | ||
| readonly form: { | ||
| readonly values: Record<string, unknown>; | ||
| readonly errors: Record<string, ValidationError[]>; | ||
| }; | ||
| /** Optional className */ | ||
| readonly className?: string; | ||
| /** Optional children */ | ||
| readonly children?: React.ReactNode; | ||
| } | ||
| /** | ||
| * Step state for workflow | ||
| */ | ||
| interface WorkflowStepState { | ||
| readonly stepIndex: number; | ||
| readonly stepId: string; | ||
| readonly isFirst: boolean; | ||
| readonly isLast: boolean; | ||
| readonly isVisible: boolean; | ||
| readonly isSkippable: boolean; | ||
| } | ||
| /** | ||
| * Navigation state for workflow | ||
| */ | ||
| interface WorkflowNavigationState { | ||
| readonly canGoNext: boolean; | ||
| readonly canGoPrevious: boolean; | ||
| readonly canSkip: boolean; | ||
| readonly isTransitioning: boolean; | ||
| } | ||
| /** | ||
| * Progress state for workflow | ||
| */ | ||
| interface WorkflowProgressState { | ||
| readonly totalSteps: number; | ||
| readonly visibleSteps: number; | ||
| readonly currentStepIndex: number; | ||
| readonly visitedSteps: ReadonlySet<string>; | ||
| readonly passedSteps: ReadonlySet<string>; | ||
| } | ||
| /** | ||
| * Complete workflow step context | ||
| */ | ||
| interface WorkflowStepContext { | ||
| readonly step: WorkflowStepState; | ||
| readonly navigation: WorkflowNavigationState; | ||
| readonly progress: WorkflowProgressState; | ||
| readonly stepData: Record<string, unknown>; | ||
| readonly allData: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Props passed to workflow button renderers (v2) | ||
| */ | ||
| interface WorkflowButtonRendererPropsV2 { | ||
| /** Navigation state */ | ||
| readonly navigation: WorkflowNavigationState; | ||
| /** Progress state */ | ||
| readonly progress: WorkflowProgressState; | ||
| /** Current step state */ | ||
| readonly step: WorkflowStepState; | ||
| /** Whether workflow is submitting */ | ||
| readonly isSubmitting: boolean; | ||
| /** Step data */ | ||
| readonly stepData: Record<string, unknown>; | ||
| /** All workflow data */ | ||
| readonly allData: Record<string, unknown>; | ||
| /** Action handler (next/previous/skip/submit) */ | ||
| readonly onAction: () => void; | ||
| /** Optional className */ | ||
| readonly className?: string; | ||
| /** Optional children */ | ||
| readonly children?: React.ReactNode; | ||
| } | ||
| interface RilayLicenseConfig { | ||
@@ -164,37 +538,76 @@ readonly licenseKey?: string; | ||
| } | ||
| type ComponentType = 'input' | 'layout'; | ||
| type InputType = 'text' | 'email' | 'password' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'date'; | ||
| type LayoutType = 'heading' | 'paragraph' | 'container' | 'divider' | 'spacer' | 'alert'; | ||
| interface ValidationError { | ||
| readonly message: string; | ||
| readonly code?: string; | ||
| readonly path?: string; | ||
| } | ||
| interface ValidationResult { | ||
| readonly isValid: boolean; | ||
| readonly errors: ValidationError[]; | ||
| readonly warnings?: ValidationWarning[]; | ||
| readonly value?: any; | ||
| } | ||
| interface ValidationError { | ||
| readonly code: string; | ||
| readonly message: string; | ||
| readonly path?: string[]; | ||
| } | ||
| interface ValidationWarning { | ||
| readonly code: string; | ||
| readonly message: string; | ||
| readonly path?: string[]; | ||
| } | ||
| interface ValidationContext { | ||
| readonly fieldId: string; | ||
| readonly formData: Record<string, any>; | ||
| readonly fieldProps: Record<string, any>; | ||
| readonly touched: boolean; | ||
| readonly dirty: boolean; | ||
| readonly fieldId?: string; | ||
| readonly formId?: string; | ||
| readonly stepId?: string; | ||
| readonly workflowId?: string; | ||
| readonly allFormData?: Record<string, any>; | ||
| readonly stepData?: Record<string, any>; | ||
| readonly workflowData?: Record<string, any>; | ||
| } | ||
| type ValidatorFunction<TProps = any> = (value: any, context: ValidationContext, props: TProps) => ValidationResult | Promise<ValidationResult>; | ||
| interface ValidationConfig<TProps = any> { | ||
| readonly validator?: ValidatorFunction<TProps>; | ||
| readonly debounceMs?: number; | ||
| /** @internal - Use Standard Schema instead */ | ||
| type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>; | ||
| /** @internal - Use Standard Schema instead */ | ||
| type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>; | ||
| type StandardSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>; | ||
| type InferInput<T> = T extends StandardSchema<infer I, any> ? I : unknown; | ||
| type InferOutput<T> = T extends StandardSchema<any, infer O> ? O : unknown; | ||
| interface FieldValidationConfig<T = any> { | ||
| /** | ||
| * Validation rules using Standard Schema interface | ||
| * Accepts: single schema, array of schemas, or any Standard Schema compatible validation | ||
| * | ||
| * @example Single schema | ||
| * validate: z.string().email() | ||
| * | ||
| * @example Built-in validators | ||
| * validate: required() | ||
| * | ||
| * @example Multiple validations | ||
| * validate: [required(), email()] | ||
| * | ||
| * @example Mixed schemas + validators | ||
| * validate: [z.string(), required(), customValidator()] | ||
| */ | ||
| readonly validate?: StandardSchema<T> | StandardSchema<T>[]; | ||
| readonly validateOnChange?: boolean; | ||
| readonly validateOnBlur?: boolean; | ||
| readonly debounceMs?: number; | ||
| } | ||
| interface FormValidationConfig<T extends Record<string, any> = Record<string, any>> { | ||
| /** | ||
| * Form-level validation using Standard Schema interface | ||
| * | ||
| * @example Object schema | ||
| * validate: z.object({ email: z.string().email(), name: z.string() }) | ||
| * | ||
| * @example Custom form validator | ||
| * validate: customFormValidator() | ||
| */ | ||
| readonly validate?: StandardSchema<T> | StandardSchema<T>[]; | ||
| readonly validateOnSubmit?: boolean; | ||
| readonly dependencies?: string[]; | ||
| readonly validateOnStepChange?: boolean; | ||
| } | ||
| type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React.ReactElement; | ||
| type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React__default.ReactElement; | ||
| type RendererChildrenFunction<TProps = any> = (props: TProps) => React__default.ReactNode; | ||
| interface ComponentRendererBaseProps<TProps = any> { | ||
| className?: string; | ||
| children?: React__default.ReactNode | RendererChildrenFunction<TProps>; | ||
| renderAs?: 'default' | 'children' | boolean; | ||
| } | ||
| interface ComponentRendererWrapperProps<TProps = any> extends Omit<ComponentRendererBaseProps<TProps>, 'className'> { | ||
| name: string; | ||
| props: TProps; | ||
| renderer?: RendererChildrenFunction<TProps>; | ||
| } | ||
| interface ComponentRenderProps<TProps = any> { | ||
@@ -206,33 +619,139 @@ id: string; | ||
| onBlur?: () => void; | ||
| disabled?: boolean; | ||
| error?: ValidationError[]; | ||
| warnings?: ValidationWarning[]; | ||
| touched?: boolean; | ||
| disabled?: boolean; | ||
| isValidating?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| interface ComponentOptions<TProps = any> { | ||
| readonly configurable?: Array<{ | ||
| key: keyof TProps; | ||
| type: 'string' | 'number' | 'boolean' | 'select' | 'array'; | ||
| /** | ||
| * Property editor definition for builder property panel | ||
| * Generic and extensible to support any custom editor type | ||
| */ | ||
| interface PropertyEditorDefinition<TValue = any> { | ||
| /** Property key in component props */ | ||
| readonly key: string; | ||
| /** Display label in property panel */ | ||
| readonly label: string; | ||
| /** | ||
| * Editor type - can be any string to support custom editors | ||
| * Built-in types: 'text', 'number', 'boolean', 'select', 'multiselect', 'color', 'textarea', 'json' | ||
| * Custom types: 'phone', 'currency', 'location', 'rating', 'file-upload', etc. | ||
| */ | ||
| readonly editorType: string; | ||
| /** Optional description/help text */ | ||
| readonly helpText?: string; | ||
| /** Default value for this property */ | ||
| readonly defaultValue?: TValue; | ||
| /** Options for select/multiselect editors */ | ||
| readonly options?: Array<{ | ||
| label: string; | ||
| options?: any[]; | ||
| default?: any; | ||
| value: any; | ||
| [key: string]: any; | ||
| }>; | ||
| readonly previewProps?: Partial<TProps>; | ||
| /** Validation function for the property value */ | ||
| readonly validate?: (value: TValue) => boolean | string | Promise<boolean | string>; | ||
| /** Group/section for organizing properties */ | ||
| readonly group?: string; | ||
| /** Whether this property is required */ | ||
| readonly required?: boolean; | ||
| /** Placeholder text for input fields */ | ||
| readonly placeholder?: string; | ||
| /** Custom editor component for advanced use cases */ | ||
| readonly customEditor?: React__default.ComponentType<PropertyEditorProps<TValue>>; | ||
| /** Additional configuration specific to the editor type */ | ||
| readonly editorConfig?: Record<string, any>; | ||
| /** Dependencies - other properties that affect this one */ | ||
| readonly dependencies?: string[]; | ||
| /** Conditional rendering based on other property values */ | ||
| readonly visible?: (props: Record<string, any>) => boolean; | ||
| /** Transform value before saving */ | ||
| readonly transform?: (value: TValue) => any; | ||
| /** Parse value when loading */ | ||
| readonly parse?: (value: any) => TValue; | ||
| } | ||
| /** | ||
| * Props passed to custom property editors | ||
| */ | ||
| interface PropertyEditorProps<TValue = any> { | ||
| /** Current property value */ | ||
| readonly value: TValue; | ||
| /** Callback to update the value */ | ||
| readonly onChange: (value: TValue) => void; | ||
| /** Property definition */ | ||
| readonly definition: PropertyEditorDefinition<TValue>; | ||
| /** All current property values (for dependencies) */ | ||
| readonly allValues: Record<string, any>; | ||
| /** Whether the field is disabled */ | ||
| readonly disabled?: boolean; | ||
| /** Validation errors */ | ||
| readonly errors?: string[]; | ||
| } | ||
| /** | ||
| * Builder metadata for visual editing capabilities | ||
| * This is optional and only used by @rilaykit/builder | ||
| * Fully generic to support any component type and configuration | ||
| */ | ||
| interface ComponentBuilderMetadata<TProps = any> { | ||
| /** Category for grouping in component palette (e.g., 'Input', 'Layout', 'Advanced') */ | ||
| readonly category?: string; | ||
| /** Icon identifier (e.g., 'text', 'email', 'calendar') */ | ||
| readonly icon?: string; | ||
| /** Whether this component should be hidden from the builder palette */ | ||
| readonly hidden?: boolean; | ||
| /** Preview component or description for the palette */ | ||
| readonly preview?: React__default.ReactNode; | ||
| /** Editable properties configuration for property panel */ | ||
| readonly editableProps?: PropertyEditorDefinition[]; | ||
| /** Tags for search and filtering */ | ||
| readonly tags?: string[]; | ||
| /** | ||
| * Custom field schema for advanced type systems | ||
| * Allows defining complex field types with their own validation and structure | ||
| */ | ||
| readonly fieldSchema?: FieldSchemaDefinition<TProps>; | ||
| } | ||
| /** | ||
| * Field schema definition for complex field types | ||
| * Supports defining custom field types with validation, defaults, and metadata | ||
| */ | ||
| interface FieldSchemaDefinition<TProps = any> { | ||
| /** Field type identifier (e.g., 'location', 'phone', 'currency') */ | ||
| readonly type: string; | ||
| /** Schema validation (Zod, Yup, or any Standard Schema) */ | ||
| readonly schema?: any; | ||
| /** Default configuration for this field type */ | ||
| readonly defaultConfig?: Partial<TProps>; | ||
| /** Sub-fields for complex types (e.g., Location has address, city, country) */ | ||
| readonly subFields?: Array<{ | ||
| key: string; | ||
| label: string; | ||
| type: string; | ||
| required?: boolean; | ||
| }>; | ||
| /** Custom serialization for complex data structures */ | ||
| readonly serialize?: (value: any) => any; | ||
| /** Custom deserialization for complex data structures */ | ||
| readonly deserialize?: (value: any) => any; | ||
| } | ||
| interface ComponentConfig<TProps = any> { | ||
| readonly id: string; | ||
| readonly type: ComponentType; | ||
| readonly subType: InputType | LayoutType; | ||
| readonly type: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly category?: string; | ||
| readonly renderer: ComponentRenderer<TProps>; | ||
| readonly options?: ComponentOptions<TProps>; | ||
| readonly validation?: ValidationConfig<TProps>; | ||
| readonly defaultProps?: Partial<TProps>; | ||
| readonly useFieldRenderer?: boolean; | ||
| readonly validation?: FieldValidationConfig; | ||
| /** Optional builder metadata for visual editing (only used by @rilaykit/builder) */ | ||
| readonly builder?: ComponentBuilderMetadata; | ||
| } | ||
| interface ConditionalBehavior { | ||
| readonly visible?: ConditionConfig; | ||
| readonly disabled?: ConditionConfig; | ||
| readonly required?: ConditionConfig; | ||
| readonly readonly?: ConditionConfig; | ||
| } | ||
| interface StepConditionalBehavior { | ||
| readonly visible?: ConditionConfig; | ||
| readonly skippable?: ConditionConfig; | ||
| } | ||
| interface FormFieldConfig { | ||
@@ -242,4 +761,4 @@ readonly id: string; | ||
| readonly props: Record<string, any>; | ||
| readonly validation?: ValidationConfig; | ||
| readonly conditional?: ConditionalConfig; | ||
| readonly validation?: FieldValidationConfig; | ||
| readonly conditions?: ConditionalBehavior; | ||
| } | ||
@@ -250,16 +769,49 @@ interface FormFieldRow { | ||
| readonly maxColumns?: number; | ||
| readonly spacing?: 'tight' | 'normal' | 'loose'; | ||
| readonly alignment?: 'start' | 'center' | 'end' | 'stretch'; | ||
| } | ||
| interface ConditionalConfig { | ||
| readonly condition: (formData: Record<string, any>) => boolean; | ||
| readonly action: 'show' | 'hide' | 'disable' | 'require'; | ||
| interface FormConfiguration<C extends Record<string, any> = Record<string, never>> { | ||
| readonly id: string; | ||
| readonly config: ril<C>; | ||
| readonly rows: FormFieldRow[]; | ||
| readonly allFields: FormFieldConfig[]; | ||
| readonly renderConfig?: FormRenderConfig; | ||
| readonly validation?: FormValidationConfig; | ||
| } | ||
| interface StepLifecycleHooks { | ||
| readonly onBeforeEnter?: (stepData: any, allData: any, context: WorkflowContext) => Promise<void>; | ||
| readonly onAfterLeave?: (stepData: any, allData: any, context: WorkflowContext) => Promise<boolean>; | ||
| readonly onValidate?: (stepData: any, context: WorkflowContext) => Promise<ValidationResult>; | ||
| readonly onTransform?: (stepData: any, context: WorkflowContext) => Promise<any>; | ||
| readonly onError?: (error: Error, context: WorkflowContext) => Promise<void>; | ||
| interface FormRenderConfig { | ||
| readonly rowRenderer?: FormRowRenderer; | ||
| readonly bodyRenderer?: FormBodyRenderer; | ||
| readonly submitButtonRenderer?: FormSubmitButtonRenderer; | ||
| readonly fieldRenderer?: FieldRenderer; | ||
| } | ||
| interface FormComponentRendererProps { | ||
| children: React__default.ReactNode; | ||
| } | ||
| interface FormRowRendererProps { | ||
| row: FormFieldRow; | ||
| children: React__default.ReactNode; | ||
| className?: string; | ||
| } | ||
| interface FormBodyRendererProps { | ||
| formConfig: FormConfiguration; | ||
| children: React__default.ReactNode; | ||
| className?: string; | ||
| } | ||
| interface FormSubmitButtonRendererProps { | ||
| isSubmitting: boolean; | ||
| onSubmit: () => void; | ||
| className?: string; | ||
| children?: React__default.ReactNode; | ||
| } | ||
| interface FieldRendererProps { | ||
| children: React__default.ReactNode; | ||
| id: string; | ||
| disabled?: boolean; | ||
| error?: ValidationError[]; | ||
| isValidating?: boolean; | ||
| touched?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| type FormRowRenderer = RendererChildrenFunction<FormRowRendererProps>; | ||
| type FormBodyRenderer = RendererChildrenFunction<FormBodyRendererProps>; | ||
| type FormSubmitButtonRenderer = RendererChildrenFunction<FormSubmitButtonRendererProps>; | ||
| type FieldRenderer = RendererChildrenFunction<FieldRendererProps>; | ||
| interface WorkflowContext { | ||
@@ -274,24 +826,35 @@ readonly workflowId: string; | ||
| readonly visitedSteps: Set<string>; | ||
| readonly user?: any; | ||
| readonly visibleVisitedSteps: Set<string>; | ||
| readonly passedSteps: Set<string>; | ||
| } | ||
| interface StepPermissions { | ||
| readonly requiredRoles?: string[]; | ||
| readonly requiredPermissions?: string[]; | ||
| readonly customGuard?: (user: any, context: WorkflowContext) => boolean | Promise<boolean>; | ||
| interface StepDataHelper { | ||
| /** | ||
| * Set data for a specific step by step ID | ||
| */ | ||
| setStepData: (stepId: string, data: Record<string, any>) => void; | ||
| /** | ||
| * Set specific field values for a step | ||
| */ | ||
| setStepFields: (stepId: string, fields: Record<string, any>) => void; | ||
| /** | ||
| * Get current data for a specific step | ||
| */ | ||
| getStepData: (stepId: string) => Record<string, any>; | ||
| /** | ||
| * Set field value for the next step | ||
| */ | ||
| setNextStepField: (fieldId: string, value: any) => void; | ||
| /** | ||
| * Set multiple fields for the next step | ||
| */ | ||
| setNextStepFields: (fields: Record<string, any>) => void; | ||
| /** | ||
| * Get all workflow data | ||
| */ | ||
| getAllData: () => Record<string, any>; | ||
| /** | ||
| * Get all step configurations for reference | ||
| */ | ||
| getSteps: () => StepConfig[]; | ||
| } | ||
| interface DynamicStepConfig { | ||
| readonly resolver: (previousData: any, context: WorkflowContext) => Promise<StepConfig[]>; | ||
| readonly cacheKey?: string; | ||
| readonly retryPolicy?: RetryPolicy; | ||
| } | ||
| interface RetryPolicy { | ||
| readonly maxRetries: number; | ||
| readonly delayMs: number; | ||
| readonly backoffMultiplier?: number; | ||
| } | ||
| interface ConditionalBranch { | ||
| readonly condition: (data: any, context: WorkflowContext) => boolean | Promise<boolean>; | ||
| readonly steps: StepConfig[]; | ||
| readonly fallback?: StepConfig[]; | ||
| } | ||
| interface StepConfig { | ||
@@ -302,55 +865,29 @@ readonly id: string; | ||
| readonly formConfig: FormConfiguration; | ||
| readonly validation?: StepValidationConfig; | ||
| readonly conditional?: StepConditionalConfig; | ||
| readonly allowSkip?: boolean; | ||
| readonly requiredToComplete?: boolean; | ||
| readonly hooks?: StepLifecycleHooks; | ||
| readonly permissions?: StepPermissions; | ||
| readonly isDynamic?: boolean; | ||
| readonly dynamicConfig?: DynamicStepConfig; | ||
| readonly renderer?: CustomStepRenderer; | ||
| readonly conditions?: StepConditionalBehavior; | ||
| readonly metadata?: Record<string, any>; | ||
| readonly onAfterValidation?: (stepData: Record<string, any>, helper: StepDataHelper, context: WorkflowContext) => void | Promise<void>; | ||
| } | ||
| interface StepValidationConfig { | ||
| readonly validator?: (stepData: Record<string, any>, allFormData: Record<string, any>, context: WorkflowContext) => ValidationResult | Promise<ValidationResult>; | ||
| readonly validateOnStepChange?: boolean; | ||
| readonly blockNextIfInvalid?: boolean; | ||
| } | ||
| interface StepConditionalConfig { | ||
| readonly condition: (formData: Record<string, any>, context: WorkflowContext) => boolean; | ||
| readonly action: 'show' | 'hide' | 'skip'; | ||
| } | ||
| type CustomStepRenderer = (props: StepConfig) => React.ReactElement; | ||
| interface WorkflowPersistenceData { | ||
| readonly workflowId: string; | ||
| readonly currentStepIndex: number; | ||
| readonly allData: Record<string, any>; | ||
| readonly metadata: { | ||
| readonly timestamp: number; | ||
| readonly version?: string; | ||
| readonly userId?: string; | ||
| readonly sessionId?: string; | ||
| type CustomStepRenderer = (props: StepConfig) => React__default.ReactElement; | ||
| interface WorkflowConfig { | ||
| readonly id: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly steps: StepConfig[]; | ||
| readonly analytics?: WorkflowAnalytics; | ||
| readonly persistence?: { | ||
| adapter: any; | ||
| options?: any; | ||
| userId?: string; | ||
| }; | ||
| readonly plugins?: WorkflowPlugin[]; | ||
| readonly renderConfig?: WorkflowRenderConfig; | ||
| } | ||
| interface PersistenceAdapter { | ||
| readonly name: string; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list?(pattern?: string): Promise<string[]>; | ||
| interface WorkflowRenderConfig { | ||
| readonly stepperRenderer?: WorkflowStepperRenderer; | ||
| readonly nextButtonRenderer?: WorkflowNextButtonRenderer; | ||
| readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer; | ||
| readonly skipButtonRenderer?: WorkflowSkipButtonRenderer; | ||
| } | ||
| interface PersistenceConfig { | ||
| readonly adapter: PersistenceAdapter; | ||
| readonly key?: string; | ||
| readonly debounceMs?: number; | ||
| readonly autoSave?: boolean; | ||
| readonly saveOnStepChange?: boolean; | ||
| readonly encryptionKey?: string; | ||
| readonly maxRetries?: number; | ||
| readonly retryDelayMs?: number; | ||
| readonly onSave?: (data: WorkflowPersistenceData) => Promise<void> | void; | ||
| readonly onLoad?: (data: WorkflowPersistenceData) => Promise<void> | void; | ||
| readonly onError?: (error: Error, operation: 'save' | 'load' | 'remove') => Promise<void> | void; | ||
| readonly onRetry?: (attempt: number, maxRetries: number, error: Error) => Promise<void> | void; | ||
| } | ||
| interface WorkflowAnalytics { | ||
@@ -363,22 +900,4 @@ readonly onWorkflowStart?: (workflowId: string, context: WorkflowContext) => void; | ||
| readonly onStepSkip?: (stepId: string, reason: string, context: WorkflowContext) => void; | ||
| readonly onValidationError?: (stepId: string, errors: ValidationError[], context: WorkflowContext) => void; | ||
| readonly onError?: (error: Error, context: WorkflowContext) => void; | ||
| } | ||
| interface WorkflowOptimizations { | ||
| readonly preloadNextStep?: boolean; | ||
| readonly cacheValidation?: boolean; | ||
| readonly virtualizeSteps?: boolean; | ||
| readonly lazyLoadComponents?: boolean; | ||
| readonly maxConcurrentRequests?: number; | ||
| } | ||
| interface WorkflowVersion { | ||
| readonly version: string; | ||
| readonly migrationStrategy?: (oldData: any, newConfig: any) => any; | ||
| readonly compatibilityMode?: boolean; | ||
| } | ||
| interface WorkflowHooks { | ||
| readonly onStepChange?: (from: string, to: string, context: WorkflowContext) => void; | ||
| readonly onDataChange?: (data: any, context: WorkflowContext) => void; | ||
| readonly onValidation?: (result: ValidationResult, context: WorkflowContext) => void; | ||
| } | ||
| interface WorkflowPlugin { | ||
@@ -388,31 +907,12 @@ readonly name: string; | ||
| readonly install: (workflow: any) => void; | ||
| readonly hooks?: WorkflowHooks; | ||
| readonly dependencies?: string[]; | ||
| } | ||
| interface WorkflowConfig { | ||
| readonly id: string; | ||
| readonly name: string; | ||
| readonly description?: string; | ||
| readonly steps: StepConfig[]; | ||
| readonly branches?: ConditionalBranch[]; | ||
| readonly navigation?: NavigationConfig; | ||
| readonly persistence?: PersistenceConfig; | ||
| readonly completion?: CompletionConfig; | ||
| readonly analytics?: WorkflowAnalytics; | ||
| readonly optimizations?: WorkflowOptimizations; | ||
| readonly version?: WorkflowVersion; | ||
| readonly plugins?: WorkflowPlugin[]; | ||
| readonly renderConfig?: WorkflowRenderConfig; | ||
| interface WorkflowComponentRendererBaseProps { | ||
| children?: React__default.ReactNode; | ||
| className?: string; | ||
| currentStep: StepConfig; | ||
| stepData: Record<string, any>; | ||
| allData: Record<string, any>; | ||
| context: WorkflowContext; | ||
| } | ||
| interface NavigationConfig { | ||
| readonly allowBackNavigation?: boolean; | ||
| readonly allowStepSkipping?: boolean; | ||
| readonly showProgress?: boolean; | ||
| readonly customNavigation?: boolean; | ||
| } | ||
| interface CompletionConfig { | ||
| readonly onComplete?: (formData: Record<string, any>) => void | Promise<void>; | ||
| readonly confirmBeforeSubmit?: boolean; | ||
| readonly customCompletionStep?: any; | ||
| } | ||
| interface WorkflowStepperRendererProps { | ||
@@ -425,222 +925,485 @@ readonly steps: StepConfig[]; | ||
| } | ||
| interface WorkflowNavigationRendererProps { | ||
| readonly currentStep: StepConfig; | ||
| readonly context: WorkflowContext; | ||
| readonly canGoNext: boolean; | ||
| readonly canGoPrevious: boolean; | ||
| readonly canSkip: boolean; | ||
| readonly isSubmitting: boolean; | ||
| readonly onNext: (event?: React.FormEvent) => void; | ||
| readonly onPrevious: (event?: React.FormEvent) => void; | ||
| readonly onSkip: (event?: React.FormEvent) => void; | ||
| readonly onSubmit: (event?: React.FormEvent) => void; | ||
| readonly className?: string; | ||
| type WorkflowNextButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| isLastStep: boolean; | ||
| canGoNext: boolean; | ||
| isSubmitting: boolean; | ||
| onSubmit: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowPreviousButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| canGoPrevious: boolean; | ||
| isSubmitting: boolean; | ||
| onPrevious: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowSkipButtonRendererProps = WorkflowComponentRendererBaseProps & { | ||
| canSkip: boolean; | ||
| isSubmitting: boolean; | ||
| onSkip: (event?: React__default.FormEvent) => void; | ||
| }; | ||
| type WorkflowStepperRenderer = RendererChildrenFunction<WorkflowStepperRendererProps>; | ||
| type WorkflowNextButtonRenderer = RendererChildrenFunction<WorkflowNextButtonRendererProps>; | ||
| type WorkflowPreviousButtonRenderer = RendererChildrenFunction<WorkflowPreviousButtonRendererProps>; | ||
| type WorkflowSkipButtonRenderer = RendererChildrenFunction<WorkflowSkipButtonRendererProps>; | ||
| interface PerformanceMetrics { | ||
| readonly timestamp: number; | ||
| readonly duration: number; | ||
| readonly memoryUsage?: number; | ||
| readonly renderCount?: number; | ||
| readonly reRenderCount?: number; | ||
| } | ||
| type WorkflowStepperRenderer = (props: WorkflowStepperRendererProps) => React.ReactElement; | ||
| type WorkflowNavigationRenderer = (props: WorkflowNavigationRendererProps) => React.ReactElement; | ||
| interface WorkflowRenderConfig { | ||
| readonly stepperRenderer?: WorkflowStepperRenderer; | ||
| readonly navigationRenderer?: WorkflowNavigationRenderer; | ||
| interface ComponentPerformanceMetrics extends PerformanceMetrics { | ||
| readonly componentId: string; | ||
| readonly componentType: string; | ||
| readonly propsSize?: number; | ||
| readonly childrenCount?: number; | ||
| } | ||
| interface FormRowRendererProps { | ||
| row: FormFieldRow; | ||
| children: React.ReactNode; | ||
| className?: string; | ||
| spacing?: 'tight' | 'normal' | 'loose'; | ||
| alignment?: 'start' | 'center' | 'end' | 'stretch'; | ||
| interface FormPerformanceMetrics extends PerformanceMetrics { | ||
| readonly formId: string; | ||
| readonly fieldCount: number; | ||
| readonly validationDuration: number; | ||
| readonly renderDuration: number; | ||
| readonly validationErrors: number; | ||
| } | ||
| interface FormBodyRendererProps { | ||
| formConfig: FormConfiguration; | ||
| children: React.ReactNode; | ||
| className?: string; | ||
| interface WorkflowPerformanceMetrics extends PerformanceMetrics { | ||
| readonly workflowId: string; | ||
| readonly stepCount: number; | ||
| readonly currentStepIndex: number; | ||
| readonly navigationDuration: number; | ||
| readonly persistenceDuration?: number; | ||
| readonly conditionEvaluationDuration: number; | ||
| } | ||
| interface FormSubmitButtonRendererProps { | ||
| isSubmitting: boolean; | ||
| isValid: boolean; | ||
| isDirty: boolean; | ||
| onSubmit: () => void; | ||
| className?: string; | ||
| children?: React.ReactNode; | ||
| type MonitoringEventType = 'component_render' | 'component_update' | 'form_validation' | 'form_submission' | 'workflow_navigation' | 'workflow_persistence' | 'condition_evaluation' | 'error' | 'performance_warning'; | ||
| interface MonitoringEvent { | ||
| readonly id: string; | ||
| readonly type: MonitoringEventType; | ||
| readonly timestamp: number; | ||
| readonly source: string; | ||
| readonly data: Record<string, any>; | ||
| readonly metrics?: PerformanceMetrics; | ||
| readonly severity?: 'low' | 'medium' | 'high' | 'critical'; | ||
| } | ||
| type FormRowRenderer = (props: FormRowRendererProps) => React.ReactElement; | ||
| type FormBodyRenderer = (props: FormBodyRendererProps) => React.ReactElement; | ||
| type FormSubmitButtonRenderer = (props: FormSubmitButtonRendererProps) => React.ReactElement; | ||
| interface FormRenderConfig { | ||
| readonly rowRenderer?: FormRowRenderer; | ||
| readonly bodyRenderer?: FormBodyRenderer; | ||
| readonly submitButtonRenderer?: FormSubmitButtonRenderer; | ||
| interface ErrorMonitoringEvent extends MonitoringEvent { | ||
| readonly type: 'error'; | ||
| readonly error: Error; | ||
| readonly stack?: string; | ||
| readonly context?: ValidationContext | WorkflowContext; | ||
| } | ||
| interface FormConfiguration { | ||
| readonly id: string; | ||
| readonly schema?: any; | ||
| readonly config: ril; | ||
| readonly rows: FormFieldRow[]; | ||
| readonly allFields: FormFieldConfig[]; | ||
| readonly renderConfig?: FormRenderConfig; | ||
| interface PerformanceWarningEvent extends MonitoringEvent { | ||
| readonly type: 'performance_warning'; | ||
| readonly threshold: number; | ||
| readonly actualValue: number; | ||
| readonly recommendation?: string; | ||
| } | ||
| interface MonitoringConfig { | ||
| readonly enabled: boolean; | ||
| readonly enablePerformanceTracking?: boolean; | ||
| readonly enableErrorTracking?: boolean; | ||
| readonly enableMemoryTracking?: boolean; | ||
| readonly performanceThresholds?: PerformanceThresholds; | ||
| readonly sampleRate?: number; | ||
| readonly bufferSize?: number; | ||
| readonly flushInterval?: number; | ||
| readonly onEvent?: (event: MonitoringEvent) => void; | ||
| readonly onBatch?: (events: MonitoringEvent[]) => void; | ||
| readonly onError?: (error: Error) => void; | ||
| } | ||
| interface PerformanceThresholds { | ||
| readonly componentRenderTime?: number; | ||
| readonly formValidationTime?: number; | ||
| readonly workflowNavigationTime?: number; | ||
| readonly memoryUsage?: number; | ||
| readonly reRenderCount?: number; | ||
| } | ||
| interface MonitoringAdapter { | ||
| readonly name: string; | ||
| readonly version?: string; | ||
| send: (events: MonitoringEvent[]) => Promise<void>; | ||
| flush?: () => Promise<void>; | ||
| configure?: (config: Record<string, any>) => void; | ||
| } | ||
| interface ConsoleMonitoringAdapter extends MonitoringAdapter { | ||
| readonly name: 'console'; | ||
| readonly logLevel?: 'debug' | 'info' | 'warn' | 'error'; | ||
| } | ||
| interface RemoteMonitoringAdapter extends MonitoringAdapter { | ||
| readonly name: 'remote'; | ||
| readonly endpoint: string; | ||
| readonly apiKey?: string; | ||
| readonly headers?: Record<string, string>; | ||
| readonly batchSize?: number; | ||
| readonly retryAttempts?: number; | ||
| } | ||
| interface MonitoringContext { | ||
| readonly sessionId: string; | ||
| readonly userId?: string; | ||
| readonly userAgent?: string; | ||
| readonly url?: string; | ||
| readonly environment: 'development' | 'production' | 'test'; | ||
| readonly version?: string; | ||
| readonly metadata?: Record<string, any>; | ||
| } | ||
| interface PerformanceProfiler { | ||
| start: (label: string, metadata?: Record<string, any>) => void; | ||
| end: (label: string) => PerformanceMetrics | null; | ||
| mark: (name: string) => void; | ||
| measure: (name: string, startMark: string, endMark?: string) => number; | ||
| getMetrics: (label: string) => PerformanceMetrics | null; | ||
| getAllMetrics: () => Record<string, PerformanceMetrics>; | ||
| clear: (label?: string) => void; | ||
| } | ||
| interface EnhancedWorkflowAnalytics extends WorkflowAnalytics { | ||
| readonly monitoring?: MonitoringConfig; | ||
| readonly onPerformanceWarning?: (event: PerformanceWarningEvent) => void; | ||
| readonly onMemoryLeak?: (metrics: ComponentPerformanceMetrics) => void; | ||
| } | ||
| interface EnhancedFormAnalytics { | ||
| readonly onFormRender?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFormValidation?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFormSubmission?: (metrics: FormPerformanceMetrics) => void; | ||
| readonly onFieldChange?: (fieldId: string, metrics: ComponentPerformanceMetrics) => void; | ||
| readonly monitoring?: MonitoringConfig; | ||
| } | ||
| declare function ComponentRendererWrapper<TProps = any>({ children, renderAs, renderer, name, props: baseProps, }: ComponentRendererWrapperProps<TProps>): React$1.ReactNode; | ||
| /** | ||
| * Create a Zod-based validator | ||
| * @param schema - Zod schema to validate against | ||
| * @returns Validator function | ||
| * Utility for merging partial configurations into existing objects | ||
| * Eliminates repetitive object spread operations | ||
| */ | ||
| declare const createZodValidator: <T>(schema: z.ZodSchema<T>) => ValidatorFunction; | ||
| declare function mergeInto<T>(target: T, partial: Partial<T>): T; | ||
| /** | ||
| * Create a custom validator from a validation function | ||
| * @param validationFn - Function that returns boolean, string, or Promise | ||
| * @returns Validator function | ||
| * Validates uniqueness of identifiers and throws descriptive errors | ||
| */ | ||
| declare const createCustomValidator: (validationFn: (value: any, context: ValidationContext) => boolean | string | Promise<boolean | string>) => ValidatorFunction; | ||
| declare function ensureUnique(ids: string[], entityName: string): void; | ||
| /** | ||
| * Combine multiple validators | ||
| * @param validators - Array of validators to combine | ||
| * @param mode - 'all' (all must pass) or 'any' (at least one must pass) | ||
| * @returns Combined validator function | ||
| * Validates required fields exist in configurations | ||
| */ | ||
| declare const combineValidators: (validators: ValidatorFunction[], mode?: "all" | "any") => ValidatorFunction; | ||
| declare function validateRequired<T>(items: T[], requiredFields: (keyof T)[], entityName: string): void; | ||
| /** | ||
| * Create a conditional validator that only runs when condition is met | ||
| * @param condition - Function to determine if validation should run | ||
| * @param validator - Validator to run when condition is true | ||
| * @returns Conditional validator function | ||
| * Auto-generates IDs when not provided | ||
| */ | ||
| declare const createConditionalValidator: (condition: (value: any, context: ValidationContext) => boolean, validator: ValidatorFunction) => ValidatorFunction; | ||
| declare class IdGenerator { | ||
| private counters; | ||
| next(prefix: string): string; | ||
| reset(prefix?: string): void; | ||
| } | ||
| /** | ||
| * Common validation patterns | ||
| * Polymorphic helper for handling single items or arrays | ||
| */ | ||
| declare const commonValidators: { | ||
| declare function normalizeToArray<T>(input: T | T[]): T[]; | ||
| /** | ||
| * Deep clone utility for configuration objects | ||
| */ | ||
| declare function deepClone<T>(obj: T): T; | ||
| /** | ||
| * Generic configuration merger with type safety | ||
| */ | ||
| declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?: (keyof T)[]): T; | ||
| declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode; | ||
| /** | ||
| * @fileoverview Clean validation utilities for Standard Schema | ||
| * | ||
| * This module provides utility functions for working with validation results | ||
| * and managing validation contexts using Standard Schema exclusively. | ||
| */ | ||
| /** | ||
| * Creates a validation result object | ||
| * | ||
| * @param isValid - Whether the validation passed | ||
| * @param errors - Array of validation errors (empty if valid) | ||
| * @returns A complete ValidationResult object | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const result = createValidationResult(false, [ | ||
| * { message: 'Email is required', code: 'REQUIRED' } | ||
| * ]); | ||
| * ``` | ||
| */ | ||
| declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult; | ||
| /** | ||
| * Creates a successful validation result | ||
| * | ||
| * @returns A successful ValidationResult with no errors | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const success = createSuccessResult(); | ||
| * ``` | ||
| */ | ||
| declare function createSuccessResult(): ValidationResult; | ||
| /** | ||
| * Creates a failed validation result with a single error | ||
| * | ||
| * @param message - The error message | ||
| * @param code - Optional error code | ||
| * @param path - Optional field path | ||
| * @returns A failed ValidationResult | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const error = createErrorResult('Email is invalid', 'INVALID_EMAIL'); | ||
| * ``` | ||
| */ | ||
| declare function createErrorResult(message: string, code?: string, path?: string): ValidationResult; | ||
| /** | ||
| * Creates a validation context object | ||
| * | ||
| * @param options - Context configuration options | ||
| * @returns A complete ValidationContext object | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const context = createValidationContext({ | ||
| * fieldId: 'email', | ||
| * formId: 'registration', | ||
| * allFormData: { email: 'test@example.com', name: 'John' } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext; | ||
| /** | ||
| * Built-in validators implementing Standard Schema interface | ||
| * All RilayKit validators now implement Standard Schema for consistency | ||
| */ | ||
| /** | ||
| * Required field validator - Standard Schema implementation | ||
| */ | ||
| declare function required(message?: string): StandardSchemaV1<any>; | ||
| /** | ||
| * Email validation - Standard Schema implementation | ||
| */ | ||
| declare function email(message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * URL validation - Standard Schema implementation | ||
| */ | ||
| declare function url(message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Minimum length validation - Standard Schema implementation | ||
| */ | ||
| declare function minLength(min: number, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Maximum length validation - Standard Schema implementation | ||
| */ | ||
| declare function maxLength(max: number, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Pattern validation - Standard Schema implementation | ||
| */ | ||
| declare function pattern(regex: RegExp, message?: string): StandardSchemaV1<string>; | ||
| /** | ||
| * Number validation - Standard Schema implementation | ||
| */ | ||
| declare function number(message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Minimum value validation - Standard Schema implementation | ||
| */ | ||
| declare function min(minValue: number, message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Maximum value validation - Standard Schema implementation | ||
| */ | ||
| declare function max(maxValue: number, message?: string): StandardSchemaV1<number>; | ||
| /** | ||
| * Custom validator - Standard Schema implementation | ||
| */ | ||
| declare function custom<T>(fn: (value: T) => boolean, message?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Async validator - Standard Schema implementation | ||
| */ | ||
| declare function async<T>(fn: (value: T) => Promise<boolean>, message?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Utility to combine multiple Standard Schema validators | ||
| * This creates a new Standard Schema that runs all validations | ||
| */ | ||
| declare function combine<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>; | ||
| /** | ||
| * Unified validation utilities for Standard Schema only | ||
| * These replace the old validator-based system with a clean Standard Schema approach | ||
| */ | ||
| /** | ||
| * Checks if a value implements the Standard Schema interface | ||
| */ | ||
| declare function isStandardSchema(value: any): value is StandardSchema; | ||
| /** | ||
| * Validates a value using a Standard Schema | ||
| */ | ||
| declare function validateWithStandardSchema<T extends StandardSchema>(schema: T, value: unknown): Promise<ValidationResult>; | ||
| /** | ||
| * Utility to extract input type from Standard Schema at runtime (for debugging) | ||
| */ | ||
| declare function getSchemaInfo(schema: StandardSchema): { | ||
| vendor: string; | ||
| version: number; | ||
| hasTypes: boolean; | ||
| }; | ||
| /** | ||
| * Type guard to check if a schema has type information | ||
| */ | ||
| declare function hasSchemaTypes<T extends StandardSchema>(schema: T): schema is T & { | ||
| '~standard': { | ||
| types: NonNullable<T['~standard']['types']>; | ||
| }; | ||
| }; | ||
| /** | ||
| * Validates a value using unified validation config | ||
| * Handles single schemas, arrays of schemas, and combines results | ||
| */ | ||
| declare function validateWithUnifiedConfig<T>(config: FieldValidationConfig<T>, value: T, _context: ValidationContext): Promise<ValidationResult>; | ||
| /** | ||
| * Validates form data using unified validation config | ||
| */ | ||
| declare function validateFormWithUnifiedConfig<T extends Record<string, any>>(config: FormValidationConfig<T>, formData: T, _context: ValidationContext): Promise<ValidationResult>; | ||
| /** | ||
| * Checks if a field validation config has any validation rules | ||
| */ | ||
| declare function hasUnifiedValidation(config: FieldValidationConfig | FormValidationConfig): boolean; | ||
| /** | ||
| * Combines multiple Standard Schemas into a single schema | ||
| * This is useful for combining built-in validators with external schemas | ||
| */ | ||
| declare function combineSchemas<T>(...schemas: StandardSchemaV1<T>[]): StandardSchemaV1<T>; | ||
| /** | ||
| * Utility to create a Standard Schema from any validation function | ||
| * This helps migrate existing validators to Standard Schema | ||
| */ | ||
| declare function createStandardValidator<T>(validateFn: (value: T, context?: ValidationContext) => ValidationResult | Promise<ValidationResult>, vendor?: string): StandardSchemaV1<T>; | ||
| /** | ||
| * Type guard to check if value is a Standard Schema or array of Standard Schemas | ||
| */ | ||
| declare function isValidationRule(value: any): value is StandardSchema | StandardSchema[]; | ||
| /** | ||
| * Normalizes validation config to always return an array of Standard Schemas | ||
| */ | ||
| declare function normalizeValidationRules<T>(validate: StandardSchema<T> | StandardSchema<T>[] | undefined): StandardSchema<T>[]; | ||
| /** | ||
| * Core monitoring system for Rilay | ||
| * Tracks performance metrics, events, and errors across forms and workflows | ||
| */ | ||
| declare class RilayMonitor { | ||
| private config; | ||
| private context; | ||
| private adapters; | ||
| private eventBuffer; | ||
| private flushTimer?; | ||
| private profiler; | ||
| constructor(config: MonitoringConfig, context?: Partial<MonitoringContext>); | ||
| /** | ||
| * Required field validator | ||
| * Add a monitoring adapter | ||
| */ | ||
| required: (message?: string) => ValidatorFunction; | ||
| addAdapter(adapter: MonitoringAdapter): void; | ||
| /** | ||
| * Email validation | ||
| * Remove a monitoring adapter | ||
| */ | ||
| email: (message?: string) => ValidatorFunction; | ||
| removeAdapter(adapterName: string): void; | ||
| /** | ||
| * Minimum length validation | ||
| * Track a monitoring event | ||
| */ | ||
| minLength: (min: number, message?: string) => ValidatorFunction; | ||
| track(type: MonitoringEventType, source: string, data: Record<string, any>, metrics?: PerformanceMetrics, severity?: 'low' | 'medium' | 'high' | 'critical'): void; | ||
| /** | ||
| * Maximum length validation | ||
| * Track an error | ||
| */ | ||
| maxLength: (max: number, message?: string) => ValidatorFunction; | ||
| trackError(error: Error, source: string, context?: any): void; | ||
| /** | ||
| * Pattern/regex validation | ||
| * Get the performance profiler | ||
| */ | ||
| pattern: (regex: RegExp, message?: string) => ValidatorFunction; | ||
| getProfiler(): PerformanceProfiler; | ||
| /** | ||
| * Number range validation | ||
| * Update monitoring context | ||
| */ | ||
| numberRange: (min?: number, max?: number, message?: string) => ValidatorFunction; | ||
| updateContext(updates: Partial<MonitoringContext>): void; | ||
| /** | ||
| * URL validation | ||
| * Flush all buffered events | ||
| */ | ||
| url: (message?: string) => ValidatorFunction; | ||
| flush(): Promise<void>; | ||
| /** | ||
| * Phone number validation (basic) | ||
| * Destroy the monitor and clean up resources | ||
| */ | ||
| phoneNumber: (message?: string) => ValidatorFunction; | ||
| /** | ||
| * Custom async validation with debouncing | ||
| */ | ||
| asyncValidation: (asyncFn: (value: any, context: ValidationContext) => Promise<boolean | string>, debounceMs?: number) => ValidatorFunction; | ||
| }; | ||
| destroy(): Promise<void>; | ||
| private startFlushTimer; | ||
| private checkPerformanceThresholds; | ||
| private createPerformanceWarning; | ||
| } | ||
| /** | ||
| * Utility to create validation result | ||
| * @param isValid - Whether validation passed | ||
| * @param errors - Array of errors (optional) | ||
| * @param warnings - Array of warnings (optional) | ||
| * @returns ValidationResult object | ||
| * Initialize global monitoring | ||
| */ | ||
| declare const createValidationResult: (isValid: boolean, errors?: ValidationError[], warnings?: ValidationError[]) => ValidationResult; | ||
| declare function initializeMonitoring(config: MonitoringConfig, context?: Partial<MonitoringContext>): RilayMonitor; | ||
| /** | ||
| * Utility to create validation error | ||
| * @param code - Error code | ||
| * @param message - Error message | ||
| * @param path - Error path (optional) | ||
| * @returns ValidationError object | ||
| * Get the global monitor instance | ||
| */ | ||
| declare const createValidationError: (code: string, message: string, path?: string[]) => ValidationError; | ||
| declare function getGlobalMonitor(): RilayMonitor | null; | ||
| /** | ||
| * Destroy global monitoring | ||
| */ | ||
| declare function destroyGlobalMonitoring(): Promise<void>; | ||
| /** | ||
| * LocalStorage persistence adapter | ||
| * Perfect for client-side persistence across browser sessions | ||
| * Console monitoring adapter | ||
| * Logs events to the browser console | ||
| */ | ||
| declare class LocalStorageAdapter implements PersistenceAdapter { | ||
| readonly name = "localStorage"; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class ConsoleAdapter implements ConsoleMonitoringAdapter { | ||
| readonly name = "console"; | ||
| readonly logLevel: 'debug' | 'info' | 'warn' | 'error'; | ||
| constructor(logLevel?: 'debug' | 'info' | 'warn' | 'error'); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| private logEvent; | ||
| private shouldLog; | ||
| } | ||
| /** | ||
| * SessionStorage persistence adapter | ||
| * Perfect for temporary persistence within a single browser session | ||
| * Remote monitoring adapter | ||
| * Sends events to a remote endpoint | ||
| */ | ||
| declare class SessionStorageAdapter implements PersistenceAdapter { | ||
| readonly name = "sessionStorage"; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class RemoteAdapter implements RemoteMonitoringAdapter { | ||
| readonly name = "remote"; | ||
| readonly endpoint: string; | ||
| readonly apiKey?: string; | ||
| readonly headers: Record<string, string>; | ||
| readonly batchSize: number; | ||
| readonly retryAttempts: number; | ||
| private eventQueue; | ||
| private isProcessing; | ||
| constructor(config: { | ||
| endpoint: string; | ||
| apiKey?: string; | ||
| headers?: Record<string, string>; | ||
| batchSize?: number; | ||
| retryAttempts?: number; | ||
| }); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| flush(): Promise<void>; | ||
| configure(config: Record<string, any>): void; | ||
| private processQueue; | ||
| private sendBatch; | ||
| private delay; | ||
| } | ||
| /** | ||
| * In-Memory persistence adapter | ||
| * Perfect for testing or temporary workflows | ||
| * Local storage adapter for offline support | ||
| */ | ||
| declare class MemoryAdapter implements PersistenceAdapter { | ||
| readonly name = "memory"; | ||
| private storage; | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| clear(): void; | ||
| declare class LocalStorageAdapter implements MonitoringAdapter { | ||
| readonly name = "localStorage"; | ||
| private readonly storageKey; | ||
| private readonly maxEvents; | ||
| constructor(maxEvents?: number); | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| flush(): Promise<void>; | ||
| getStoredEvents(): MonitoringEvent[]; | ||
| clearStoredEvents(): void; | ||
| getEventCount(): number; | ||
| } | ||
| /** | ||
| * Composite adapter that can use multiple adapters with fallback | ||
| * Perfect for robust persistence with primary/backup strategies | ||
| * Development adapter that provides detailed logging | ||
| */ | ||
| declare class CompositeAdapter implements PersistenceAdapter { | ||
| private primary; | ||
| private fallbacks; | ||
| readonly name = "composite"; | ||
| constructor(primary: PersistenceAdapter, fallbacks?: PersistenceAdapter[]); | ||
| save(key: string, data: WorkflowPersistenceData): Promise<void>; | ||
| load(key: string): Promise<WorkflowPersistenceData | null>; | ||
| remove(key: string): Promise<void>; | ||
| exists(key: string): Promise<boolean>; | ||
| list(pattern?: string): Promise<string[]>; | ||
| declare class DevelopmentAdapter implements MonitoringAdapter { | ||
| readonly name = "development"; | ||
| private readonly console; | ||
| send(events: MonitoringEvent[]): Promise<void>; | ||
| private logPerformanceSummary; | ||
| private logErrorSummary; | ||
| } | ||
| /** | ||
| * Utility functions to create persistence configurations easily | ||
| */ | ||
| declare const persistence: { | ||
| /** | ||
| * Create a localStorage-based persistence configuration | ||
| */ | ||
| localStorage(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create a sessionStorage-based persistence configuration | ||
| */ | ||
| sessionStorage(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create an in-memory persistence configuration (for testing) | ||
| */ | ||
| memory(options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| /** | ||
| * Create a custom persistence configuration | ||
| */ | ||
| custom(adapter: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| }; | ||
| /** | ||
| * Utility to create persistence configurations with retry logic | ||
| */ | ||
| declare function createResilientPersistence(primary: PersistenceAdapter, fallback?: PersistenceAdapter, options?: Partial<PersistenceConfig>): PersistenceConfig; | ||
| 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 }; | ||
| 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 }; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| 'use strict';var zod=require('zod');var y=class o{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new o}addComponent(e,r){let t=r.id||`${r.type}-${e}-${Date.now()}`,n={id:t,subType:e,...r};return this.components.set(t,n),this}setRowRenderer(e){return this.formRenderConfig={...this.formRenderConfig,rowRenderer:e},this}setBodyRenderer(e){return this.formRenderConfig={...this.formRenderConfig,bodyRenderer:e},this}setSubmitButtonRenderer(e){return this.formRenderConfig={...this.formRenderConfig,submitButtonRenderer:e},this}setFormRenderConfig(e){return this.formRenderConfig=e,this}getFormRenderConfig(){return {...this.formRenderConfig}}setStepperRenderer(e){return this.workflowRenderConfig={...this.workflowRenderConfig,stepperRenderer:e},this}setWorkflowNavigationRenderer(e){return this.workflowRenderConfig={...this.workflowRenderConfig,navigationRenderer:e},this}setWorkflowRenderConfig(e){return this.workflowRenderConfig=e,this}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}setRenderConfig(e){return this.setFormRenderConfig(e)}getComponent(e){return this.components.get(e)}getComponentsByType(e){return Array.from(this.components.values()).filter(r=>r.type===e)}getComponentsBySubType(e){return Array.from(this.components.values()).filter(r=>r.subType===e)}getComponentsByCategory(e){return Array.from(this.components.values()).filter(r=>r.category===e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){return this.components.delete(e)}clear(){this.components.clear();}export(){return Object.fromEntries(this.components)}import(e){for(let[r,t]of Object.entries(e))this.components.set(r,t);return this}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),bySubType:e.reduce((r,t)=>(r[t.subType]=(r[t.subType]||0)+1,r),{}),byCategory:e.reduce((r,t)=>{let n=t.category||"uncategorized";return r[n]=(r[n]||0)+1,r},{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNavigation:!!this.workflowRenderConfig.navigationRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(s=>s.id),n=t.filter((s,i)=>t.indexOf(s)!==i);n.length>0&&e.push(`Duplicate component IDs found: ${n.join(", ")}`);let a=r.filter(s=>!s.renderer);return a.length>0&&e.push(`Components without renderer: ${a.map(s=>s.id).join(", ")}`),e}};var m=o=>async e=>{try{return await o.parseAsync(e),{isValid:!0,errors:[]}}catch(r){return r&&typeof r=="object"&&"errors"in r&&Array.isArray(r.errors)?{isValid:false,errors:r.errors.map(t=>({code:t.code,message:t.message,path:t.path?t.path.map(String):[]}))}:{isValid:false,errors:[{code:"unknown",message:r instanceof Error?r.message:"Unknown validation error"}]}}},w=o=>async(e,r,t)=>{try{let n=await o(e,r);return n===!0?{isValid:!0,errors:[]}:n===!1?{isValid:!1,errors:[{code:"validation_failed",message:"Validation failed"}]}:{isValid:!1,errors:[{code:"validation_failed",message:String(n)}]}}catch(n){return {isValid:false,errors:[{code:"validation_error",message:n instanceof Error?n.message:"Validation error"}]}}},b=(o,e="all")=>async(r,t,n)=>{let a=await Promise.all(o.map(l=>l(r,t,n)));if(e==="all"){let l=a.flatMap(u=>u.errors),c=a.flatMap(u=>u.warnings||[]);return {isValid:a.every(u=>u.isValid),errors:l,warnings:c.length>0?c:void 0}}if(a.some(l=>l.isValid)){let l=a.flatMap(c=>c.warnings||[]);return {isValid:true,errors:[],warnings:l.length>0?l:void 0}}return {isValid:false,errors:a.flatMap(l=>l.errors)}},v=(o,e)=>async(r,t,n)=>o(r,t)?e(r,t,n):{isValid:true,errors:[]},P={required:(o="This field is required")=>w(e=>e==null||e===""?o:!0),email:(o="Invalid email format")=>m(zod.z.string().email(o)),minLength:(o,e)=>m(zod.z.string().min(o,e||`Minimum ${o} characters required`)),maxLength:(o,e)=>m(zod.z.string().max(o,e||`Maximum ${o} characters allowed`)),pattern:(o,e="Invalid format")=>m(zod.z.string().regex(o,e)),numberRange:(o,e,r)=>{let t=zod.z.number();return o!==void 0&&(t=t.min(o,r||`Value must be at least ${o}`)),e!==void 0&&(t=t.max(e,r||`Value must be at most ${e}`)),m(t)},url:(o="Invalid URL format")=>m(zod.z.string().url(o)),phoneNumber:(o="Invalid phone number format")=>m(zod.z.string().regex(/^\+?[\d\s\-\(\)]+$/,o)),asyncValidation:(o,e=300)=>{let r=new Map;return (t,n,a)=>new Promise(s=>{let i=`${n.fieldId}-${JSON.stringify(t)}`;r.has(i)&&clearTimeout(r.get(i));let l=setTimeout(async()=>{try{let c=await o(t,n);s(c===!0?{isValid:!0,errors:[]}:{isValid:!1,errors:[{code:"async_validation_failed",message:typeof c=="string"?c:"Async validation failed"}]});}catch(c){s({isValid:false,errors:[{code:"async_validation_error",message:c instanceof Error?c.message:"Async validation error"}]});}finally{r.delete(i);}},e);r.set(i,l);})}},k=(o,e=[],r)=>({isValid:o,errors:e,warnings:r}),V=(o,e,r)=>({code:o,message:e,path:r});var g=class{constructor(){this.name="localStorage";}async save(e,r){try{localStorage.setItem(e,JSON.stringify(r));}catch(t){throw new Error(`Failed to save to localStorage: ${t}`)}}async load(e){try{let r=localStorage.getItem(e);return r?JSON.parse(r):null}catch(r){throw new Error(`Failed to load from localStorage: ${r}`)}}async remove(e){try{localStorage.removeItem(e);}catch(r){throw new Error(`Failed to remove from localStorage: ${r}`)}}async exists(e){return localStorage.getItem(e)!==null}async list(e){let r=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&(!e||n.includes(e))&&r.push(n);}return r}},p=class{constructor(){this.name="sessionStorage";}async save(e,r){try{sessionStorage.setItem(e,JSON.stringify(r));}catch(t){throw new Error(`Failed to save to sessionStorage: ${t}`)}}async load(e){try{let r=sessionStorage.getItem(e);return r?JSON.parse(r):null}catch(r){throw new Error(`Failed to load from sessionStorage: ${r}`)}}async remove(e){try{sessionStorage.removeItem(e);}catch(r){throw new Error(`Failed to remove from sessionStorage: ${r}`)}}async exists(e){return sessionStorage.getItem(e)!==null}async list(e){let r=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n&&(!e||n.includes(e))&&r.push(n);}return r}},f=class{constructor(){this.name="memory";this.storage=new Map;}async save(e,r){this.storage.set(e,{...r});}async load(e){let r=this.storage.get(e);return r?{...r}:null}async remove(e){this.storage.delete(e);}async exists(e){return this.storage.has(e)}async list(e){let r=Array.from(this.storage.keys());return e?r.filter(t=>t.includes(e)):r}clear(){this.storage.clear();}},h=class{constructor(e,r=[]){this.primary=e;this.fallbacks=r;this.name="composite";}async save(e,r){let t=[this.primary,...this.fallbacks];for(let n of t)try{await n.save(e,r);return}catch(a){console.warn(`Failed to save with ${n.name}:`,a);}throw new Error("All persistence adapters failed to save")}async load(e){let r=[this.primary,...this.fallbacks];for(let t of r)try{let n=await t.load(e);if(n)return n}catch(n){console.warn(`Failed to load with ${t.name}:`,n);}return null}async remove(e){let r=[this.primary,...this.fallbacks],t=[];for(let n of r)try{await n.remove(e);}catch(a){t.push(a);}if(t.length===r.length)throw new Error(`All adapters failed to remove: ${t.map(n=>n.message).join(", ")}`)}async exists(e){let r=[this.primary,...this.fallbacks];for(let t of r)try{if(await t.exists(e))return !0}catch(n){console.warn(`Failed to check existence with ${t.name}:`,n);}return false}async list(e){try{return await this.primary.list?.(e)||[]}catch(r){console.warn("Failed to list with primary adapter:",r);for(let t of this.fallbacks)try{return await t.list?.(e)||[]}catch(n){console.warn(`Failed to list with fallback ${t.name}:`,n);}return []}}};var E={localStorage(o={}){return {adapter:new g,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...o}},sessionStorage(o={}){return {adapter:new p,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...o}},memory(o={}){return {adapter:new f,debounceMs:0,autoSave:true,saveOnStepChange:true,...o}},custom(o,e={}){return {adapter:o,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...e}}};function T(o,e,r={}){let t=e||new f;return {adapter:{name:`resilient-${o.name}`,async save(a,s){try{await o.save(a,s);}catch(i){console.warn("Primary persistence failed, using fallback:",i),await t.save(a,s);}},async load(a){try{let s=await o.load(a);if(s)return s}catch(s){console.warn("Primary persistence load failed, trying fallback:",s);}return await t.load(a)},async remove(a){let s=[];try{await o.remove(a);}catch(i){s.push(i);}try{await t.remove(a);}catch(i){s.push(i);}if(s.length===2)throw new Error(`Both adapters failed: ${s.map(i=>i.message).join(", ")}`)},async exists(a){try{if(await o.exists(a))return !0}catch(s){console.warn("Primary persistence exists check failed:",s);}try{return await t.exists(a)}catch(s){return console.warn("Fallback persistence exists check failed:",s),false}},async list(a){try{return await o.list?.(a)||[]}catch(s){console.warn("Primary persistence list failed:",s);try{return await t.list?.(a)||[]}catch(i){return console.warn("Fallback persistence list failed:",i),[]}}}},debounceMs:1e3,autoSave:true,saveOnStepChange:true,maxRetries:3,retryDelayMs:1e3,...r}}exports.CompositeAdapter=h;exports.LocalStorageAdapter=g;exports.MemoryAdapter=f;exports.SessionStorageAdapter=p;exports.combineValidators=b;exports.commonValidators=P;exports.createConditionalValidator=v;exports.createCustomValidator=w;exports.createResilientPersistence=T;exports.createValidationError=V;exports.createValidationResult=k;exports.createZodValidator=m;exports.persistence=E;exports.ril=y; | ||
| 'use strict';function k(n,e){return typeof n=="function"?n(e):n}function fe({children:n,renderAs:e,renderer:r,name:t,props:o}){if(e==="children"||e===true){if(typeof n!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${t}`);return n(o)}if(!r)throw new Error(`No renderer provided for ${t}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${t}`);let a={...o,children:k(n,o)};return r(a)}function me(n,e){return {...n,...e}}function V(n,e){let r=n.filter((t,o)=>n.indexOf(t)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function ge(n,e,r){if(n.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var P=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function ye(n){return Array.isArray(n)?n:[n]}function E(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(Array.isArray(n))return n.map(r=>E(r));let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=E(n[r]));return e}function he(n,e,r){let t={...n};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(t[o]=e[o]);return t}var h=class extends Error{constructor(r,t,o){super(r);this.code=t;this.meta=o;this.name="RilayError";}},g=class extends h{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(n,e){let r={...n};for(let t in e){let o=e[t],i=r[t];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[t]=m(i,o):r[t]=o;}return r}var v=class n{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new n}addComponent(e,r){let t={id:e,type:e,...r},o=new n;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,t),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],t=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[s,u]of Object.entries(e))r.includes(s)?o[s]=u:t.includes(s)&&(i[s]=u);let a=new n;return a.components=new Map(this.components),a.formRenderConfig=m(this.formRenderConfig,o),a.workflowRenderConfig=m(this.workflowRenderConfig,i),a}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new n;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new n;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new n;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(l=>l.id);try{V(t,"component");}catch(l){e.push(l instanceof Error?l.message:String(l));}let o=r.filter(l=>!l.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(l=>l.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),a=Object.keys(this.workflowRenderConfig),s=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],u=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],d=i.filter(l=>!s.includes(l)),y=a.filter(l=>!u.includes(l));return d.length>0&&e.push(`Invalid form renderer keys: ${d.join(", ")}`),y.length>0&&e.push(`Invalid workflow renderer keys: ${y.join(", ")}`),e}async validateAsync(){let e=[],r=[],t=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=t.map(async d=>d.renderer&&typeof d.renderer!="function"&&typeof d.renderer!="object"?`Component "${d.id}" has invalid renderer type: ${typeof d.renderer}`:((d.id.includes(" ")||d.id.includes("-"))&&r.push(`Component "${d.id}" uses non-standard naming (contains spaces or dashes)`),null)),s=(await Promise.all(i)).filter(d=>d!==null);e.push(...s),t.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let u={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!u.isValid)throw new g("Ril configuration validation failed",{errors:e,warnings:r,componentCount:t.length});return u}catch(o){throw o instanceof g?o:new g("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function C(n,e=[]){return {isValid:n,errors:[...e]}}function D(){return C(true,[])}function W(n,e,r){return C(false,[{message:n,code:e,path:r}])}function O(n={}){return {fieldId:n.fieldId,formId:n.formId,stepId:n.stepId,workflowId:n.workflowId,allFormData:n.allFormData||{},stepData:n.stepData||{},workflowData:n.workflowData||{}}}function N(n="This field is required"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>e===""||e==null||Array.isArray(e)&&e.length===0||typeof e=="object"&&Object.keys(e).length===0?{issues:[{message:n,path:void 0}]}:{value:e}}}}function $(n="Please enter a valid email address"){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Email must be a string"}]}:e.test(r)?{value:r}:{issues:[{message:n}]},types:{input:"",output:""}}}}function L(n="Please enter a valid URL"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{if(typeof e!="string")return {issues:[{message:"URL must be a string"}]};try{return new URL(e),{value:e}}catch{return {issues:[{message:n}]}}},types:{input:"",output:""}}}}function q(n,e){let r=`Must be at least ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length>=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function z(n,e){let r=`Must be no more than ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length<=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function U(n,e="Value does not match required pattern"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Value must be a string"}]}:n.test(r)?{value:r}:{issues:[{message:e}]},types:{input:"",output:""}}}}function _(n="Must be a valid number"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?{issues:[{message:n}]}:{value:r}},types:{input:0,output:0}}}}function K(n,e){let r=`Must be at least ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o>=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function j(n,e){let r=`Must be no more than ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o<=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function Q(n,e="Validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>{try{return n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function H(n,e="Async validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:async r=>{try{return await n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function J(...n){return {"~standard":{version:1,vendor:"rilaykit",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function c(n){return n!=null&&typeof n=="object"&&"~standard"in n&&n["~standard"]!==null&&typeof n["~standard"]=="object"&&n["~standard"].version===1&&typeof n["~standard"].vendor=="string"&&typeof n["~standard"].validate=="function"}async function R(n,e){if(!c(n))throw new Error("Invalid Standard Schema: missing ~standard property or invalid structure");try{let r=n["~standard"].validate(e);return r instanceof Promise&&(r=await r),r.issues?{isValid:!1,errors:r.issues.map(o=>({message:o.message,code:"VALIDATION_ERROR",path:G(o.path)}))}:{isValid:!0,errors:[],value:r.value}}catch(r){return {isValid:false,errors:[{message:r instanceof Error?r.message:"Validation failed",code:"VALIDATION_ERROR"}]}}}function G(n){if(!(!n||n.length===0))return n.map(e=>typeof e=="object"&&"key"in e?String(e.key):String(e)).join(".")}function X(n){if(!c(n))throw new Error("Invalid Standard Schema");return {vendor:n["~standard"].vendor,version:n["~standard"].version,hasTypes:!!n["~standard"].types}}function Y(n){return c(n)&&!!n["~standard"].types}async function Z(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let a=await R(i,e);a.isValid||o.push(...a.errors);}catch(a){o.push({message:a instanceof Error?a.message:"Validation error",code:"VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}async function ee(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let a=await R(i,e);a.isValid||o.push(...a.errors);}catch(a){o.push({message:a instanceof Error?a.message:"Form validation error",code:"FORM_VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}function re(n){return !!n.validate}function ne(...n){return {"~standard":{version:1,vendor:"rilaykit-combined",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function te(n,e="rilaykit"){return {"~standard":{version:1,vendor:e,validate:async r=>{try{let t=await n(r,{});return t.isValid?{value:r}:{issues:t.errors.map(i=>({message:i.message,path:i.path?[i.path]:void 0}))}}catch(t){return {issues:[{message:t instanceof Error?t.message:"Validation failed"}]}}}}}}function oe(n){return Array.isArray(n)?n.every(c):c(n)}function ie(n){return n?Array.isArray(n)?n:[n]:[]}var ae=0,M=()=>`event_${Date.now()}_${++ae}`,se=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:se(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new b,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,t,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let a={id:M(),type:e,timestamp:Date.now(),source:r,data:{...t,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(a,o),this.eventBuffer.push(a),this.config.onEvent)try{this.config.onEvent(a);}catch(s){console.error("Error in monitoring event callback:",s);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,t){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:t},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(t){console.error(`Error sending events to adapter ${r.name}:`,t),this.config.onError&&this.config.onError(t);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let t=this.config.performanceThresholds;t.componentRenderTime&&e.type==="component_render"&&r.duration>t.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",t.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),t.formValidationTime&&e.type==="form_validation"&&r.duration>t.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",t.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),t.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>t.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",t.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),t.memoryUsage&&r.memoryUsage&&r.memoryUsage>t.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",t.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),t.reRenderCount&&r.reRenderCount&&r.reRenderCount>t.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",t.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,t,o){let i={id:M(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:t,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(a){console.error("Error in performance warning callback:",a);}}},b=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let t=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:t,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,t){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,t);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,t)=>{e[t]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},f=null;function Ve(n,e){return f&&f.destroy(),f=new w(n,e),f}function Me(){return f}async function Be(){f&&(await f.destroy(),f=null);}var x=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let t=e;console.warn(`[Rilay Performance Warning] ${t.data.message}`,{threshold:t.threshold,actual:t.actualValue,recommendation:t.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],t=r.indexOf(this.logLevel);return r.indexOf(e)>=t}},B=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},t=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(t=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(Math.pow(2,o)*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",t),t}delay(e){return new Promise(r=>setTimeout(r,e))}},F=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},A=class{constructor(){this.name="development";this.console=new x("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(a=>a.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let t=r.reduce((a,s)=>a+(s.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(a=>a.metrics?.duration||0));console.info(`Average duration: ${t.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let a of r)i[a.type]||(i[a.type]=[]),i[a.type].push(a);for(let[a,s]of Object.entries(i)){let u=s.reduce((d,y)=>d+(y.metrics?.duration||0),0)/s.length;console.info(`${a}: ${u.toFixed(2)}ms avg (${s.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let t={};for(let o of r)t[o.source]=(t[o.source]||0)+1;for(let[o,i]of Object.entries(t))console.error(`${o}: ${i} errors`);console.groupEnd();}};var S=class{constructor(){this.fieldDependencies=new Map;this.reverseDependencies=new Map;}addField(e,r){if(!r){this.fieldDependencies.set(e,new Set);return}let t=new Set;if(r.visible)for(let o of p(r.visible))t.add(o);if(r.disabled)for(let o of p(r.disabled))t.add(o);if(r.required)for(let o of p(r.required))t.add(o);if(r.readonly)for(let o of p(r.readonly))t.add(o);this.fieldDependencies.set(e,t);for(let o of t)this.reverseDependencies.has(o)||this.reverseDependencies.set(o,new Set),this.reverseDependencies.get(o).add(e);}removeField(e){let r=this.fieldDependencies.get(e);if(r)for(let t of r){let o=this.reverseDependencies.get(t);o&&(o.delete(e),o.size===0&&this.reverseDependencies.delete(t));}this.fieldDependencies.delete(e);}getAffectedFields(e){let r=this.reverseDependencies.get(e);return r?Array.from(r):[]}getAffectedFieldsMultiple(e){let r=new Set;for(let t of e){let o=this.reverseDependencies.get(t);if(o)for(let i of o)r.add(i);}return Array.from(r)}getDependencies(e){let r=this.fieldDependencies.get(e);return r?Array.from(r):[]}hasDependencies(e){let r=this.fieldDependencies.get(e);return r!==void 0&&r.size>0}getAllFields(){return Array.from(this.fieldDependencies.keys())}getAllDependencyPaths(){return Array.from(this.reverseDependencies.keys())}clear(){this.fieldDependencies.clear(),this.reverseDependencies.clear();}get size(){return this.fieldDependencies.size}toDebugObject(){let e={},r={};for(let[t,o]of this.fieldDependencies)e[t]=Array.from(o);for(let[t,o]of this.reverseDependencies)r[t]=Array.from(o);return {fields:e,reverseDeps:r}}};var T=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return I(this,e)}};function We(n){return new T(n)}function I(n,e){if(n.conditions&&n.conditions.length>0){let t=n.conditions.map(o=>I(o,e));return n.logicalOperator==="or"?t.some(o=>o):t.every(o=>o)}let r=de(e,n.field);switch(n.operator){case "equals":return r===n.value;case "notEquals":return r!==n.value;case "greaterThan":return typeof r=="number"&&typeof n.value=="number"&&r>n.value;case "lessThan":return typeof r=="number"&&typeof n.value=="number"&&r<n.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r>=n.value;case "lessThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r<=n.value;case "contains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?r.includes(n.value):false;case "notContains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?!r.includes(n.value):false;case "in":return Array.isArray(n.value)&&n.value.includes(r);case "notIn":return Array.isArray(n.value)&&!n.value.includes(r);case "matches":return typeof r!="string"||typeof n.value!="string"?false:new RegExp(n.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function de(n,e){let r=e.split("."),t=n;for(let o of r)if(t&&typeof t=="object"&&o in t)t=t[o];else return;return t}function p(n){if(!n)return [];let e="build"in n?n.build():n,r=new Set;function t(o){if(o.field&&o.field.trim()!==""&&r.add(o.field),o.conditions&&o.conditions.length>0)for(let i of o.conditions)t(i);}return t(e),Array.from(r)}function Oe(n){let e=new Set;for(let r of Object.values(n))if(r){let t=p(r);for(let o of t)e.add(o);}return Array.from(e)}exports.ComponentRendererWrapper=fe;exports.ConditionDependencyGraph=S;exports.ConsoleAdapter=x;exports.DevelopmentAdapter=A;exports.IdGenerator=P;exports.LocalStorageAdapter=F;exports.RemoteAdapter=B;exports.RilayMonitor=w;exports.async=H;exports.combine=J;exports.combineSchemas=ne;exports.configureObject=he;exports.createErrorResult=W;exports.createStandardValidator=te;exports.createSuccessResult=D;exports.createValidationContext=O;exports.createValidationResult=C;exports.custom=Q;exports.deepClone=E;exports.destroyGlobalMonitoring=Be;exports.email=$;exports.ensureUnique=V;exports.evaluateCondition=I;exports.extractAllDependencies=Oe;exports.extractConditionDependencies=p;exports.getGlobalMonitor=Me;exports.getSchemaInfo=X;exports.hasSchemaTypes=Y;exports.hasUnifiedValidation=re;exports.initializeMonitoring=Ve;exports.isStandardSchema=c;exports.isValidationRule=oe;exports.max=j;exports.maxLength=z;exports.mergeInto=me;exports.min=K;exports.minLength=q;exports.normalizeToArray=ye;exports.normalizeValidationRules=ie;exports.number=_;exports.pattern=U;exports.required=N;exports.resolveRendererChildren=k;exports.ril=v;exports.url=L;exports.validateFormWithUnifiedConfig=ee;exports.validateRequired=ge;exports.validateWithStandardSchema=R;exports.validateWithUnifiedConfig=Z;exports.when=We; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| import {z}from'zod';var y=class o{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new o}addComponent(e,r){let t=r.id||`${r.type}-${e}-${Date.now()}`,n={id:t,subType:e,...r};return this.components.set(t,n),this}setRowRenderer(e){return this.formRenderConfig={...this.formRenderConfig,rowRenderer:e},this}setBodyRenderer(e){return this.formRenderConfig={...this.formRenderConfig,bodyRenderer:e},this}setSubmitButtonRenderer(e){return this.formRenderConfig={...this.formRenderConfig,submitButtonRenderer:e},this}setFormRenderConfig(e){return this.formRenderConfig=e,this}getFormRenderConfig(){return {...this.formRenderConfig}}setStepperRenderer(e){return this.workflowRenderConfig={...this.workflowRenderConfig,stepperRenderer:e},this}setWorkflowNavigationRenderer(e){return this.workflowRenderConfig={...this.workflowRenderConfig,navigationRenderer:e},this}setWorkflowRenderConfig(e){return this.workflowRenderConfig=e,this}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}setRenderConfig(e){return this.setFormRenderConfig(e)}getComponent(e){return this.components.get(e)}getComponentsByType(e){return Array.from(this.components.values()).filter(r=>r.type===e)}getComponentsBySubType(e){return Array.from(this.components.values()).filter(r=>r.subType===e)}getComponentsByCategory(e){return Array.from(this.components.values()).filter(r=>r.category===e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){return this.components.delete(e)}clear(){this.components.clear();}export(){return Object.fromEntries(this.components)}import(e){for(let[r,t]of Object.entries(e))this.components.set(r,t);return this}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),bySubType:e.reduce((r,t)=>(r[t.subType]=(r[t.subType]||0)+1,r),{}),byCategory:e.reduce((r,t)=>{let n=t.category||"uncategorized";return r[n]=(r[n]||0)+1,r},{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNavigation:!!this.workflowRenderConfig.navigationRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(s=>s.id),n=t.filter((s,i)=>t.indexOf(s)!==i);n.length>0&&e.push(`Duplicate component IDs found: ${n.join(", ")}`);let a=r.filter(s=>!s.renderer);return a.length>0&&e.push(`Components without renderer: ${a.map(s=>s.id).join(", ")}`),e}};var m=o=>async e=>{try{return await o.parseAsync(e),{isValid:!0,errors:[]}}catch(r){return r&&typeof r=="object"&&"errors"in r&&Array.isArray(r.errors)?{isValid:false,errors:r.errors.map(t=>({code:t.code,message:t.message,path:t.path?t.path.map(String):[]}))}:{isValid:false,errors:[{code:"unknown",message:r instanceof Error?r.message:"Unknown validation error"}]}}},w=o=>async(e,r,t)=>{try{let n=await o(e,r);return n===!0?{isValid:!0,errors:[]}:n===!1?{isValid:!1,errors:[{code:"validation_failed",message:"Validation failed"}]}:{isValid:!1,errors:[{code:"validation_failed",message:String(n)}]}}catch(n){return {isValid:false,errors:[{code:"validation_error",message:n instanceof Error?n.message:"Validation error"}]}}},b=(o,e="all")=>async(r,t,n)=>{let a=await Promise.all(o.map(l=>l(r,t,n)));if(e==="all"){let l=a.flatMap(u=>u.errors),c=a.flatMap(u=>u.warnings||[]);return {isValid:a.every(u=>u.isValid),errors:l,warnings:c.length>0?c:void 0}}if(a.some(l=>l.isValid)){let l=a.flatMap(c=>c.warnings||[]);return {isValid:true,errors:[],warnings:l.length>0?l:void 0}}return {isValid:false,errors:a.flatMap(l=>l.errors)}},v=(o,e)=>async(r,t,n)=>o(r,t)?e(r,t,n):{isValid:true,errors:[]},P={required:(o="This field is required")=>w(e=>e==null||e===""?o:!0),email:(o="Invalid email format")=>m(z.string().email(o)),minLength:(o,e)=>m(z.string().min(o,e||`Minimum ${o} characters required`)),maxLength:(o,e)=>m(z.string().max(o,e||`Maximum ${o} characters allowed`)),pattern:(o,e="Invalid format")=>m(z.string().regex(o,e)),numberRange:(o,e,r)=>{let t=z.number();return o!==void 0&&(t=t.min(o,r||`Value must be at least ${o}`)),e!==void 0&&(t=t.max(e,r||`Value must be at most ${e}`)),m(t)},url:(o="Invalid URL format")=>m(z.string().url(o)),phoneNumber:(o="Invalid phone number format")=>m(z.string().regex(/^\+?[\d\s\-\(\)]+$/,o)),asyncValidation:(o,e=300)=>{let r=new Map;return (t,n,a)=>new Promise(s=>{let i=`${n.fieldId}-${JSON.stringify(t)}`;r.has(i)&&clearTimeout(r.get(i));let l=setTimeout(async()=>{try{let c=await o(t,n);s(c===!0?{isValid:!0,errors:[]}:{isValid:!1,errors:[{code:"async_validation_failed",message:typeof c=="string"?c:"Async validation failed"}]});}catch(c){s({isValid:false,errors:[{code:"async_validation_error",message:c instanceof Error?c.message:"Async validation error"}]});}finally{r.delete(i);}},e);r.set(i,l);})}},k=(o,e=[],r)=>({isValid:o,errors:e,warnings:r}),V=(o,e,r)=>({code:o,message:e,path:r});var g=class{constructor(){this.name="localStorage";}async save(e,r){try{localStorage.setItem(e,JSON.stringify(r));}catch(t){throw new Error(`Failed to save to localStorage: ${t}`)}}async load(e){try{let r=localStorage.getItem(e);return r?JSON.parse(r):null}catch(r){throw new Error(`Failed to load from localStorage: ${r}`)}}async remove(e){try{localStorage.removeItem(e);}catch(r){throw new Error(`Failed to remove from localStorage: ${r}`)}}async exists(e){return localStorage.getItem(e)!==null}async list(e){let r=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&(!e||n.includes(e))&&r.push(n);}return r}},p=class{constructor(){this.name="sessionStorage";}async save(e,r){try{sessionStorage.setItem(e,JSON.stringify(r));}catch(t){throw new Error(`Failed to save to sessionStorage: ${t}`)}}async load(e){try{let r=sessionStorage.getItem(e);return r?JSON.parse(r):null}catch(r){throw new Error(`Failed to load from sessionStorage: ${r}`)}}async remove(e){try{sessionStorage.removeItem(e);}catch(r){throw new Error(`Failed to remove from sessionStorage: ${r}`)}}async exists(e){return sessionStorage.getItem(e)!==null}async list(e){let r=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n&&(!e||n.includes(e))&&r.push(n);}return r}},f=class{constructor(){this.name="memory";this.storage=new Map;}async save(e,r){this.storage.set(e,{...r});}async load(e){let r=this.storage.get(e);return r?{...r}:null}async remove(e){this.storage.delete(e);}async exists(e){return this.storage.has(e)}async list(e){let r=Array.from(this.storage.keys());return e?r.filter(t=>t.includes(e)):r}clear(){this.storage.clear();}},h=class{constructor(e,r=[]){this.primary=e;this.fallbacks=r;this.name="composite";}async save(e,r){let t=[this.primary,...this.fallbacks];for(let n of t)try{await n.save(e,r);return}catch(a){console.warn(`Failed to save with ${n.name}:`,a);}throw new Error("All persistence adapters failed to save")}async load(e){let r=[this.primary,...this.fallbacks];for(let t of r)try{let n=await t.load(e);if(n)return n}catch(n){console.warn(`Failed to load with ${t.name}:`,n);}return null}async remove(e){let r=[this.primary,...this.fallbacks],t=[];for(let n of r)try{await n.remove(e);}catch(a){t.push(a);}if(t.length===r.length)throw new Error(`All adapters failed to remove: ${t.map(n=>n.message).join(", ")}`)}async exists(e){let r=[this.primary,...this.fallbacks];for(let t of r)try{if(await t.exists(e))return !0}catch(n){console.warn(`Failed to check existence with ${t.name}:`,n);}return false}async list(e){try{return await this.primary.list?.(e)||[]}catch(r){console.warn("Failed to list with primary adapter:",r);for(let t of this.fallbacks)try{return await t.list?.(e)||[]}catch(n){console.warn(`Failed to list with fallback ${t.name}:`,n);}return []}}};var E={localStorage(o={}){return {adapter:new g,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...o}},sessionStorage(o={}){return {adapter:new p,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...o}},memory(o={}){return {adapter:new f,debounceMs:0,autoSave:true,saveOnStepChange:true,...o}},custom(o,e={}){return {adapter:o,debounceMs:1e3,autoSave:true,saveOnStepChange:true,...e}}};function T(o,e,r={}){let t=e||new f;return {adapter:{name:`resilient-${o.name}`,async save(a,s){try{await o.save(a,s);}catch(i){console.warn("Primary persistence failed, using fallback:",i),await t.save(a,s);}},async load(a){try{let s=await o.load(a);if(s)return s}catch(s){console.warn("Primary persistence load failed, trying fallback:",s);}return await t.load(a)},async remove(a){let s=[];try{await o.remove(a);}catch(i){s.push(i);}try{await t.remove(a);}catch(i){s.push(i);}if(s.length===2)throw new Error(`Both adapters failed: ${s.map(i=>i.message).join(", ")}`)},async exists(a){try{if(await o.exists(a))return !0}catch(s){console.warn("Primary persistence exists check failed:",s);}try{return await t.exists(a)}catch(s){return console.warn("Fallback persistence exists check failed:",s),false}},async list(a){try{return await o.list?.(a)||[]}catch(s){console.warn("Primary persistence list failed:",s);try{return await t.list?.(a)||[]}catch(i){return console.warn("Fallback persistence list failed:",i),[]}}}},debounceMs:1e3,autoSave:true,saveOnStepChange:true,maxRetries:3,retryDelayMs:1e3,...r}}export{h as CompositeAdapter,g as LocalStorageAdapter,f as MemoryAdapter,p as SessionStorageAdapter,b as combineValidators,P as commonValidators,v as createConditionalValidator,w as createCustomValidator,T as createResilientPersistence,V as createValidationError,k as createValidationResult,m as createZodValidator,E as persistence,y as ril}; | ||
| function k(n,e){return typeof n=="function"?n(e):n}function fe({children:n,renderAs:e,renderer:r,name:t,props:o}){if(e==="children"||e===true){if(typeof n!="function")throw new Error(`When renderAs="children" is used, children must be a function that returns React elements for ${t}`);return n(o)}if(!r)throw new Error(`No renderer provided for ${t}`);if(typeof r!="function")throw new Error(`Renderer must be a function for ${t}`);let a={...o,children:k(n,o)};return r(a)}function me(n,e){return {...n,...e}}function V(n,e){let r=n.filter((t,o)=>n.indexOf(t)!==o);if(r.length>0)throw new Error(`Duplicate ${e} IDs: ${r.join(", ")}`)}function ge(n,e,r){if(n.filter(o=>e.some(i=>!o[i])).length>0)throw new Error(`Missing required fields in ${r}: ${e.join(", ")}`)}var P=class{constructor(){this.counters=new Map;}next(e){let r=this.counters.get(e)||0;return this.counters.set(e,r+1),`${e}-${r+1}`}reset(e){e?this.counters.delete(e):this.counters.clear();}};function ye(n){return Array.isArray(n)?n:[n]}function E(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(Array.isArray(n))return n.map(r=>E(r));let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=E(n[r]));return e}function he(n,e,r){let t={...n};for(let o in e)r&&!r.includes(o)||e[o]!==void 0&&(t[o]=e[o]);return t}var h=class extends Error{constructor(r,t,o){super(r);this.code=t;this.meta=o;this.name="RilayError";}},g=class extends h{constructor(e,r){super(e,"VALIDATION_ERROR",r),this.name="ValidationError";}};function m(n,e){let r={...n};for(let t in e){let o=e[t],i=r[t];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?r[t]=m(i,o):r[t]=o;}return r}var v=class n{constructor(){this.components=new Map;this.formRenderConfig={};this.workflowRenderConfig={};}static create(){return new n}addComponent(e,r){let t={id:e,type:e,...r},o=new n;return o.components=new Map(this.components),o.formRenderConfig={...this.formRenderConfig},o.workflowRenderConfig={...this.workflowRenderConfig},o.components.set(e,t),o}configure(e){let r=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],t=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],o={},i={};for(let[s,u]of Object.entries(e))r.includes(s)?o[s]=u:t.includes(s)&&(i[s]=u);let a=new n;return a.components=new Map(this.components),a.formRenderConfig=m(this.formRenderConfig,o),a.workflowRenderConfig=m(this.workflowRenderConfig,i),a}getFormRenderConfig(){return {...this.formRenderConfig}}getWorkflowRenderConfig(){return {...this.workflowRenderConfig}}getComponent(e){return this.components.get(e)}getAllComponents(){return Array.from(this.components.values())}hasComponent(e){return this.components.has(e)}removeComponent(e){let r=new n;return r.components=new Map(this.components),r.formRenderConfig={...this.formRenderConfig},r.workflowRenderConfig={...this.workflowRenderConfig},r.components.delete(e),r}clear(){let e=new n;return e.formRenderConfig={...this.formRenderConfig},e.workflowRenderConfig={...this.workflowRenderConfig},e}clone(){let e=new n;return e.components=new Map(this.components),e.formRenderConfig=m({},this.formRenderConfig),e.workflowRenderConfig=m({},this.workflowRenderConfig),e}getStats(){let e=Array.from(this.components.values());return {total:e.length,byType:e.reduce((r,t)=>(r[t.type]=(r[t.type]||0)+1,r),{}),hasCustomRenderers:{row:!!this.formRenderConfig.rowRenderer,body:!!this.formRenderConfig.bodyRenderer,submitButton:!!this.formRenderConfig.submitButtonRenderer,field:!!this.formRenderConfig.fieldRenderer,stepper:!!this.workflowRenderConfig.stepperRenderer,workflowNextButton:!!this.workflowRenderConfig.nextButtonRenderer,workflowPreviousButton:!!this.workflowRenderConfig.previousButtonRenderer,workflowSkipButton:!!this.workflowRenderConfig.skipButtonRenderer}}}validate(){let e=[],r=Array.from(this.components.values()),t=r.map(l=>l.id);try{V(t,"component");}catch(l){e.push(l instanceof Error?l.message:String(l));}let o=r.filter(l=>!l.renderer);o.length>0&&e.push(`Components without renderer: ${o.map(l=>l.id).join(", ")}`);let i=Object.keys(this.formRenderConfig),a=Object.keys(this.workflowRenderConfig),s=["rowRenderer","bodyRenderer","submitButtonRenderer","fieldRenderer"],u=["stepperRenderer","nextButtonRenderer","previousButtonRenderer","skipButtonRenderer"],d=i.filter(l=>!s.includes(l)),y=a.filter(l=>!u.includes(l));return d.length>0&&e.push(`Invalid form renderer keys: ${d.join(", ")}`),y.length>0&&e.push(`Invalid workflow renderer keys: ${y.join(", ")}`),e}async validateAsync(){let e=[],r=[],t=Array.from(this.components.values());try{let o=this.validate();e.push(...o);let i=t.map(async d=>d.renderer&&typeof d.renderer!="function"&&typeof d.renderer!="object"?`Component "${d.id}" has invalid renderer type: ${typeof d.renderer}`:((d.id.includes(" ")||d.id.includes("-"))&&r.push(`Component "${d.id}" uses non-standard naming (contains spaces or dashes)`),null)),s=(await Promise.all(i)).filter(d=>d!==null);e.push(...s),t.length>50&&r.push("Large number of components detected. Consider splitting configuration.");let u={isValid:e.length===0,errors:e,warnings:r.length>0?r:void 0};if(!u.isValid)throw new g("Ril configuration validation failed",{errors:e,warnings:r,componentCount:t.length});return u}catch(o){throw o instanceof g?o:new g("Unexpected error during async validation",{originalError:o instanceof Error?o.message:String(o)})}}};function C(n,e=[]){return {isValid:n,errors:[...e]}}function D(){return C(true,[])}function W(n,e,r){return C(false,[{message:n,code:e,path:r}])}function O(n={}){return {fieldId:n.fieldId,formId:n.formId,stepId:n.stepId,workflowId:n.workflowId,allFormData:n.allFormData||{},stepData:n.stepData||{},workflowData:n.workflowData||{}}}function N(n="This field is required"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>e===""||e==null||Array.isArray(e)&&e.length===0||typeof e=="object"&&Object.keys(e).length===0?{issues:[{message:n,path:void 0}]}:{value:e}}}}function $(n="Please enter a valid email address"){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Email must be a string"}]}:e.test(r)?{value:r}:{issues:[{message:n}]},types:{input:"",output:""}}}}function L(n="Please enter a valid URL"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{if(typeof e!="string")return {issues:[{message:"URL must be a string"}]};try{return new URL(e),{value:e}}catch{return {issues:[{message:n}]}}},types:{input:"",output:""}}}}function q(n,e){let r=`Must be at least ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length>=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function z(n,e){let r=`Must be no more than ${n} characters long`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>typeof t!="string"?{issues:[{message:"Value must be a string"}]}:t.length<=n?{value:t}:{issues:[{message:e||r}]},types:{input:"",output:""}}}}function U(n,e="Value does not match required pattern"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>typeof r!="string"?{issues:[{message:"Value must be a string"}]}:n.test(r)?{value:r}:{issues:[{message:e}]},types:{input:"",output:""}}}}function _(n="Must be a valid number"){return {"~standard":{version:1,vendor:"rilaykit",validate:e=>{let r=typeof e=="string"?Number(e):e;return typeof r!="number"||Number.isNaN(r)?{issues:[{message:n}]}:{value:r}},types:{input:0,output:0}}}}function K(n,e){let r=`Must be at least ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o>=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function j(n,e){let r=`Must be no more than ${n}`;return {"~standard":{version:1,vendor:"rilaykit",validate:t=>{let o=typeof t=="string"?Number(t):t;return typeof o!="number"||Number.isNaN(o)?{issues:[{message:"Value must be a number"}]}:o<=n?{value:o}:{issues:[{message:e||r}]}},types:{input:0,output:0}}}}function Q(n,e="Validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:r=>{try{return n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function H(n,e="Async validation failed"){return {"~standard":{version:1,vendor:"rilaykit",validate:async r=>{try{return await n(r)?{value:r}:{issues:[{message:e}]}}catch(t){return {issues:[{message:t instanceof Error?t.message:e}]}}}}}}function J(...n){return {"~standard":{version:1,vendor:"rilaykit",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function c(n){return n!=null&&typeof n=="object"&&"~standard"in n&&n["~standard"]!==null&&typeof n["~standard"]=="object"&&n["~standard"].version===1&&typeof n["~standard"].vendor=="string"&&typeof n["~standard"].validate=="function"}async function R(n,e){if(!c(n))throw new Error("Invalid Standard Schema: missing ~standard property or invalid structure");try{let r=n["~standard"].validate(e);return r instanceof Promise&&(r=await r),r.issues?{isValid:!1,errors:r.issues.map(o=>({message:o.message,code:"VALIDATION_ERROR",path:G(o.path)}))}:{isValid:!0,errors:[],value:r.value}}catch(r){return {isValid:false,errors:[{message:r instanceof Error?r.message:"Validation failed",code:"VALIDATION_ERROR"}]}}}function G(n){if(!(!n||n.length===0))return n.map(e=>typeof e=="object"&&"key"in e?String(e.key):String(e)).join(".")}function X(n){if(!c(n))throw new Error("Invalid Standard Schema");return {vendor:n["~standard"].vendor,version:n["~standard"].version,hasTypes:!!n["~standard"].types}}function Y(n){return c(n)&&!!n["~standard"].types}async function Z(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let a=await R(i,e);a.isValid||o.push(...a.errors);}catch(a){o.push({message:a instanceof Error?a.message:"Validation error",code:"VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}async function ee(n,e,r){if(!n.validate)return {isValid:true,errors:[]};let t=Array.isArray(n.validate)?n.validate:[n.validate],o=[];for(let i of t){if(!c(i)){o.push({message:"Invalid validation rule: must implement Standard Schema interface",code:"INVALID_SCHEMA"});continue}try{let a=await R(i,e);a.isValid||o.push(...a.errors);}catch(a){o.push({message:a instanceof Error?a.message:"Form validation error",code:"FORM_VALIDATION_ERROR"});}}return {isValid:o.length===0,errors:o}}function re(n){return !!n.validate}function ne(...n){return {"~standard":{version:1,vendor:"rilaykit-combined",validate:async e=>{let r=[],t=e;for(let o of n){let i=o["~standard"].validate(e);i instanceof Promise&&(i=await i),i.issues?r.push(...i.issues):t=i.value;}return r.length>0?{issues:r}:{value:t}}}}}function te(n,e="rilaykit"){return {"~standard":{version:1,vendor:e,validate:async r=>{try{let t=await n(r,{});return t.isValid?{value:r}:{issues:t.errors.map(i=>({message:i.message,path:i.path?[i.path]:void 0}))}}catch(t){return {issues:[{message:t instanceof Error?t.message:"Validation failed"}]}}}}}}function oe(n){return Array.isArray(n)?n.every(c):c(n)}function ie(n){return n?Array.isArray(n)?n:[n]:[]}var ae=0,M=()=>`event_${Date.now()}_${++ae}`,se=()=>`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=class{constructor(e,r){this.adapters=[];this.eventBuffer=[];this.config={bufferSize:100,flushInterval:5e3,sampleRate:1,enablePerformanceTracking:true,enableErrorTracking:true,enableMemoryTracking:false,...e},this.context={sessionId:se(),environment:"production",userAgent:typeof window<"u"?window.navigator?.userAgent:void 0,url:typeof window<"u"?window.location?.href:void 0,...r},this.profiler=new b,this.config.enabled&&this.startFlushTimer();}addAdapter(e){this.adapters.push(e);}removeAdapter(e){this.adapters=this.adapters.filter(r=>r.name!==e);}track(e,r,t,o,i="low"){if(!this.config.enabled||Math.random()>(this.config.sampleRate||1))return;let a={id:M(),type:e,timestamp:Date.now(),source:r,data:{...t,context:this.context},metrics:o,severity:i};if(o&&this.config.performanceThresholds&&this.checkPerformanceThresholds(a,o),this.eventBuffer.push(a),this.config.onEvent)try{this.config.onEvent(a);}catch(s){console.error("Error in monitoring event callback:",s);}this.eventBuffer.length>=(this.config.bufferSize||100)&&this.flush();}trackError(e,r,t){this.track("error",r,{message:e.message,name:e.name,stack:e.stack,context:t},void 0,"high");}getProfiler(){return this.profiler}updateContext(e){this.context={...this.context,...e};}async flush(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];if(this.eventBuffer=[],this.config.onBatch)try{this.config.onBatch(e);}catch(r){console.error("Error in monitoring batch callback:",r);}await Promise.all(this.adapters.map(async r=>{try{await r.send(e);}catch(t){console.error(`Error sending events to adapter ${r.name}:`,t),this.config.onError&&this.config.onError(t);}}));}async destroy(){this.flushTimer&&clearInterval(this.flushTimer),await this.flush(),await Promise.all(this.adapters.map(async e=>{if(e.flush)try{await e.flush();}catch(r){console.error(`Error flushing adapter ${e.name}:`,r);}}));}startFlushTimer(){this.config.flushInterval&&this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval));}checkPerformanceThresholds(e,r){let t=this.config.performanceThresholds;t.componentRenderTime&&e.type==="component_render"&&r.duration>t.componentRenderTime&&this.createPerformanceWarning("Component render time exceeded threshold",t.componentRenderTime,r.duration,"Consider memoizing component or optimizing render logic"),t.formValidationTime&&e.type==="form_validation"&&r.duration>t.formValidationTime&&this.createPerformanceWarning("Form validation time exceeded threshold",t.formValidationTime,r.duration,"Consider debouncing validation or optimizing validators"),t.workflowNavigationTime&&e.type==="workflow_navigation"&&r.duration>t.workflowNavigationTime&&this.createPerformanceWarning("Workflow navigation time exceeded threshold",t.workflowNavigationTime,r.duration,"Consider optimizing step transitions or condition evaluation"),t.memoryUsage&&r.memoryUsage&&r.memoryUsage>t.memoryUsage&&this.createPerformanceWarning("Memory usage exceeded threshold",t.memoryUsage,r.memoryUsage,"Check for memory leaks or optimize data structures"),t.reRenderCount&&r.reRenderCount&&r.reRenderCount>t.reRenderCount&&this.createPerformanceWarning("Component re-render count exceeded threshold",t.reRenderCount,r.reRenderCount,"Consider using React.memo or optimizing dependencies");}createPerformanceWarning(e,r,t,o){let i={id:M(),type:"performance_warning",timestamp:Date.now(),source:"rilay_monitor",data:{message:e,context:this.context},threshold:r,actualValue:t,recommendation:o,severity:"medium"};if(this.eventBuffer.push(i),this.config.onEvent)try{this.config.onEvent(i);}catch(a){console.error("Error in performance warning callback:",a);}}},b=class{constructor(){this.metrics=new Map;this.startTimes=new Map;}start(e,r={}){this.startTimes.set(e,performance.now()),this.metrics.set(e,{timestamp:Date.now(),duration:0,renderCount:r.renderCount||0,reRenderCount:r.reRenderCount||0,memoryUsage:this.getMemoryUsage()});}end(e){let r=this.startTimes.get(e);if(!r)return null;let t=performance.now()-r,o=this.metrics.get(e);if(!o)return null;let i={...o,duration:t,memoryUsage:this.getMemoryUsage()};return this.metrics.set(e,i),this.startTimes.delete(e),i}mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e);}measure(e,r,t){if(typeof performance<"u"&&performance.measure){performance.measure(e,r,t);let o=performance.getEntriesByName(e,"measure");return o.length>0?o[o.length-1].duration:0}return 0}getMetrics(e){return this.metrics.get(e)||null}getAllMetrics(){let e={};return this.metrics.forEach((r,t)=>{e[t]=r;}),e}clear(e){e?(this.metrics.delete(e),this.startTimes.delete(e)):(this.metrics.clear(),this.startTimes.clear());}getMemoryUsage(){if(typeof performance<"u"&&performance.memory)return performance.memory.usedJSHeapSize}},f=null;function Ve(n,e){return f&&f.destroy(),f=new w(n,e),f}function Me(){return f}async function Be(){f&&(await f.destroy(),f=null);}var x=class{constructor(e="info"){this.name="console";this.logLevel=e;}async send(e){for(let r of e)this.logEvent(r);}logEvent(e){let r={id:e.id,type:e.type,timestamp:new Date(e.timestamp).toISOString(),source:e.source,severity:e.severity,data:e.data,metrics:e.metrics};switch(e.severity){case "critical":case "high":this.shouldLog("error")&&console.error(`[Rilay Monitor] ${e.type}:`,r);break;case "medium":this.shouldLog("warn")&&console.warn(`[Rilay Monitor] ${e.type}:`,r);break;default:this.shouldLog("info")&&console.info(`[Rilay Monitor] ${e.type}:`,r);break}if(e.type==="performance_warning"&&this.shouldLog("warn")){let t=e;console.warn(`[Rilay Performance Warning] ${t.data.message}`,{threshold:t.threshold,actual:t.actualValue,recommendation:t.recommendation});}}shouldLog(e){let r=["debug","info","warn","error"],t=r.indexOf(this.logLevel);return r.indexOf(e)>=t}},B=class{constructor(e){this.name="remote";this.eventQueue=[];this.isProcessing=false;this.endpoint=e.endpoint,this.apiKey=e.apiKey,this.headers={"Content-Type":"application/json",...e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{},...e.headers},this.batchSize=e.batchSize||50,this.retryAttempts=e.retryAttempts||3;}async send(e){this.eventQueue.push(...e),this.isProcessing||await this.processQueue();}async flush(){await this.processQueue();}configure(e){e.headers&&Object.assign(this.headers,e.headers);}async processQueue(){if(!(this.isProcessing||this.eventQueue.length===0)){this.isProcessing=true;try{for(;this.eventQueue.length>0;){let e=this.eventQueue.splice(0,this.batchSize);await this.sendBatch(e);}}finally{this.isProcessing=false;}}}async sendBatch(e){let r={events:e,timestamp:Date.now(),source:"rilay-monitoring"},t=null;for(let o=1;o<=this.retryAttempts;o++)try{let i=await fetch(this.endpoint,{method:"POST",headers:this.headers,body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return}catch(i){if(t=i,i instanceof Error&&i.message.includes("HTTP 4"))break;o<this.retryAttempts&&await this.delay(Math.pow(2,o)*1e3);}throw console.error("Failed to send monitoring events to remote endpoint:",t),t}delay(e){return new Promise(r=>setTimeout(r,e))}},F=class{constructor(e=1e3){this.name="localStorage";this.storageKey="rilay_monitoring_events";this.maxEvents=e;}async send(e){try{let o=[...this.getStoredEvents(),...e].slice(-this.maxEvents);localStorage.setItem(this.storageKey,JSON.stringify(o));}catch(r){console.error("Failed to store monitoring events:",r);}}async flush(){}getStoredEvents(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}catch(e){return console.error("Failed to retrieve stored monitoring events:",e),[]}}clearStoredEvents(){localStorage.removeItem(this.storageKey);}getEventCount(){return this.getStoredEvents().length}},A=class{constructor(){this.name="development";this.console=new x("debug");}async send(e){await this.console.send(e),this.logPerformanceSummary(e),this.logErrorSummary(e);}logPerformanceSummary(e){let r=e.filter(a=>a.metrics);if(r.length===0)return;console.group("[Rilay Performance Summary]");let t=r.reduce((a,s)=>a+(s.metrics?.duration||0),0)/r.length,o=Math.max(...r.map(a=>a.metrics?.duration||0));console.info(`Average duration: ${t.toFixed(2)}ms`),console.info(`Max duration: ${o.toFixed(2)}ms`);let i={};for(let a of r)i[a.type]||(i[a.type]=[]),i[a.type].push(a);for(let[a,s]of Object.entries(i)){let u=s.reduce((d,y)=>d+(y.metrics?.duration||0),0)/s.length;console.info(`${a}: ${u.toFixed(2)}ms avg (${s.length} events)`);}console.groupEnd();}logErrorSummary(e){let r=e.filter(o=>o.type==="error");if(r.length===0)return;console.group("[Rilay Error Summary]"),console.error(`${r.length} errors detected`);let t={};for(let o of r)t[o.source]=(t[o.source]||0)+1;for(let[o,i]of Object.entries(t))console.error(`${o}: ${i} errors`);console.groupEnd();}};var S=class{constructor(){this.fieldDependencies=new Map;this.reverseDependencies=new Map;}addField(e,r){if(!r){this.fieldDependencies.set(e,new Set);return}let t=new Set;if(r.visible)for(let o of p(r.visible))t.add(o);if(r.disabled)for(let o of p(r.disabled))t.add(o);if(r.required)for(let o of p(r.required))t.add(o);if(r.readonly)for(let o of p(r.readonly))t.add(o);this.fieldDependencies.set(e,t);for(let o of t)this.reverseDependencies.has(o)||this.reverseDependencies.set(o,new Set),this.reverseDependencies.get(o).add(e);}removeField(e){let r=this.fieldDependencies.get(e);if(r)for(let t of r){let o=this.reverseDependencies.get(t);o&&(o.delete(e),o.size===0&&this.reverseDependencies.delete(t));}this.fieldDependencies.delete(e);}getAffectedFields(e){let r=this.reverseDependencies.get(e);return r?Array.from(r):[]}getAffectedFieldsMultiple(e){let r=new Set;for(let t of e){let o=this.reverseDependencies.get(t);if(o)for(let i of o)r.add(i);}return Array.from(r)}getDependencies(e){let r=this.fieldDependencies.get(e);return r?Array.from(r):[]}hasDependencies(e){let r=this.fieldDependencies.get(e);return r!==void 0&&r.size>0}getAllFields(){return Array.from(this.fieldDependencies.keys())}getAllDependencyPaths(){return Array.from(this.reverseDependencies.keys())}clear(){this.fieldDependencies.clear(),this.reverseDependencies.clear();}get size(){return this.fieldDependencies.size}toDebugObject(){let e={},r={};for(let[t,o]of this.fieldDependencies)e[t]=Array.from(o);for(let[t,o]of this.reverseDependencies)r[t]=Array.from(o);return {fields:e,reverseDeps:r}}};var T=class{constructor(e){this.field=e,this.operator="exists",this.conditions=[];}equals(e){return this.operator="equals",this.value=e,this}notEquals(e){return this.operator="notEquals",this.value=e,this}greaterThan(e){return this.operator="greaterThan",this.value=e,this}lessThan(e){return this.operator="lessThan",this.value=e,this}greaterThanOrEqual(e){return this.operator="greaterThanOrEqual",this.value=e,this}lessThanOrEqual(e){return this.operator="lessThanOrEqual",this.value=e,this}contains(e){return this.operator="contains",this.value=e,this}notContains(e){return this.operator="notContains",this.value=e,this}in(e){return this.operator="in",this.value=e,this}notIn(e){return this.operator="notIn",this.value=e,this}matches(e){return this.operator="matches",this.value=e instanceof RegExp?e.source:e,this}exists(){return this.operator="exists",this.value=void 0,this}notExists(){return this.operator="notExists",this.value=void 0,this}and(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="and",this}or(e){let r="build"in e?e.build():e,t={field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator};return this.field="",this.operator="exists",this.value=void 0,this.conditions=[t,r],this.logicalOperator="or",this}build(){return {field:this.field,operator:this.operator,value:this.value,conditions:this.conditions,logicalOperator:this.logicalOperator}}evaluate(e){return I(this,e)}};function We(n){return new T(n)}function I(n,e){if(n.conditions&&n.conditions.length>0){let t=n.conditions.map(o=>I(o,e));return n.logicalOperator==="or"?t.some(o=>o):t.every(o=>o)}let r=de(e,n.field);switch(n.operator){case "equals":return r===n.value;case "notEquals":return r!==n.value;case "greaterThan":return typeof r=="number"&&typeof n.value=="number"&&r>n.value;case "lessThan":return typeof r=="number"&&typeof n.value=="number"&&r<n.value;case "greaterThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r>=n.value;case "lessThanOrEqual":return typeof r=="number"&&typeof n.value=="number"&&r<=n.value;case "contains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?r.includes(n.value):false;case "notContains":return typeof r=="string"&&typeof n.value=="string"||Array.isArray(r)?!r.includes(n.value):false;case "in":return Array.isArray(n.value)&&n.value.includes(r);case "notIn":return Array.isArray(n.value)&&!n.value.includes(r);case "matches":return typeof r!="string"||typeof n.value!="string"?false:new RegExp(n.value).test(r);case "exists":return r!=null;case "notExists":return r==null;default:return false}}function de(n,e){let r=e.split("."),t=n;for(let o of r)if(t&&typeof t=="object"&&o in t)t=t[o];else return;return t}function p(n){if(!n)return [];let e="build"in n?n.build():n,r=new Set;function t(o){if(o.field&&o.field.trim()!==""&&r.add(o.field),o.conditions&&o.conditions.length>0)for(let i of o.conditions)t(i);}return t(e),Array.from(r)}function Oe(n){let e=new Set;for(let r of Object.values(n))if(r){let t=p(r);for(let o of t)e.add(o);}return Array.from(e)}export{fe as ComponentRendererWrapper,S as ConditionDependencyGraph,x as ConsoleAdapter,A as DevelopmentAdapter,P as IdGenerator,F as LocalStorageAdapter,B as RemoteAdapter,w as RilayMonitor,H as async,J as combine,ne as combineSchemas,he as configureObject,W as createErrorResult,te as createStandardValidator,D as createSuccessResult,O as createValidationContext,C as createValidationResult,Q as custom,E as deepClone,Be as destroyGlobalMonitoring,$ as email,V as ensureUnique,I as evaluateCondition,Oe as extractAllDependencies,p as extractConditionDependencies,Me as getGlobalMonitor,X as getSchemaInfo,Y as hasSchemaTypes,re as hasUnifiedValidation,Ve as initializeMonitoring,c as isStandardSchema,oe as isValidationRule,j as max,z as maxLength,me as mergeInto,K as min,q as minLength,ye as normalizeToArray,ie as normalizeValidationRules,_ as number,U as pattern,N as required,k as resolveRendererChildren,v as ril,L as url,ee as validateFormWithUnifiedConfig,ge as validateRequired,R as validateWithStandardSchema,Z as validateWithUnifiedConfig,We as when}; |
+22
-8
| { | ||
| "name": "@rilaykit/core", | ||
| "version": "0.1.1-alpha.1", | ||
| "version": "0.1.1", | ||
| "private": false, | ||
| "description": "Core types, configurations, and utilities for the RilayKit form library", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.mjs", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.mjs", | ||
| "require": "./dist/index.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
@@ -17,4 +26,12 @@ "dist" | ||
| ], | ||
| "author": "Rilay Team", | ||
| "author": "AND YOU CREATE <contact@andyoucreate.com>", | ||
| "license": "MIT", | ||
| "homepage": "https://rilay.io", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/andyoucreate/rilay.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/andyoucreate/rilay/issues" | ||
| }, | ||
| "peerDependencies": { | ||
@@ -26,11 +43,8 @@ "react": ">=18.0.0", | ||
| "@types/react": "^18.3.23", | ||
| "react": "^19.1.0", | ||
| "typescript": "^5.3.0" | ||
| "react": "^18.3.1", | ||
| "typescript": "^5.8.3" | ||
| }, | ||
| "dependencies": { | ||
| "zod": "^3.22.4" | ||
| "@standard-schema/spec": "^1.0.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
@@ -37,0 +51,0 @@ "build": "tsup", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
161775
128.92%6
20%1393
119.37%0
-100%3
-25%26
2500%3
Infinity%+ Added
+ Added
- Removed
- Removed