UNPKG

@mindmakr/gs-websdk

Version:

Web SDK for Guru SaaS System - Complete JavaScript/TypeScript SDK for building applications with dynamic schema management

61 lines (60 loc) 2.14 kB
/** * Schema Helper Utilities * Provides utility functions for working with JSON schemas and form generation */ import { SchemaTemplate } from '../types'; /** * Generate UI schema from JSON schema for better form rendering */ export declare function generateUISchemaFromJSONSchema(jsonSchema: Record<string, any>): Record<string, any>; /** * Create schema with UI schema information embedded */ export declare function createSchemaWithUISchema(jsonSchema: Record<string, any>, uiSchema: Record<string, any>): Record<string, any>; /** * Convert schema template to a format suitable for form rendering */ export declare function convertSchemaToFormConfig(template: SchemaTemplate): { schema: Record<string, any>; uiSchema: Record<string, any>; formData?: Record<string, any>; }; /** * Generate default form data from schema */ export declare function generateDefaultFormData(schema: Record<string, any>): Record<string, any>; /** * Validate form data against schema */ export declare function validateFormData(formData: Record<string, any>, schema: Record<string, any>): { isValid: boolean; errors: Array<{ field: string; message: string; type: string; }>; }; /** * Extract field keys from schema in order */ export declare function extractFieldKeys(schema: Record<string, any>): string[]; /** * Get field configuration from schema */ export declare function getFieldConfig(schema: Record<string, any>, fieldKey: string): any; /** * Check if field is required */ export declare function isFieldRequired(schema: Record<string, any>, fieldKey: string): boolean; /** * Generate field type from JSON schema property */ export declare function getFieldTypeFromSchema(fieldSchema: any): string; /** * Merge schemas (useful for composition) */ export declare function mergeSchemas(baseSchema: Record<string, any>, extendingSchema: Record<string, any>, strategy?: 'override' | 'merge'): Record<string, any>; /** * Clean schema by removing UI-specific properties for storage */ export declare function cleanSchemaForStorage(schema: Record<string, any>): Record<string, any>;