mockingjar-lib
Version:
A TypeScript library for AI-powered JSON mock data generation using schema-based configuration
30 lines (29 loc) • 1.96 kB
TypeScript
import { JsonSchema, SchemaField } from '@/types/schema';
export interface GenerateSchemaPreviewOptions {
collapsedFields?: Set<string>;
forPreview?: boolean;
}
export declare const convertSchemaFieldToJson: (field: SchemaField, configs?: GenerateSchemaPreviewOptions) => unknown;
export declare const convertSchemaToJson: (schema: JsonSchema, configs?: GenerateSchemaPreviewOptions) => Record<string, unknown>;
export declare const convertJsonToSchema: (json: Record<string, unknown>, schemaName?: string) => JsonSchema;
/**
* Find and update a field by ID anywhere in the nested structure
*/
export declare const findAndUpdateField: (fields: SchemaField[], targetId: string, updater: (field: SchemaField) => SchemaField) => SchemaField[];
/**
* Find and remove a field by ID anywhere in the nested structure
*/
export declare const findAndRemoveField: (fields: SchemaField[], targetId: string) => SchemaField[];
/**
*
* UI Utilities for Schema Fields
* These functions are used to create, update, and manipulate schema fields in the UI.
*/
export declare const addField: (schema: JsonSchema) => JsonSchema;
export declare const addObjectField: (targetId: string, schema: JsonSchema) => JsonSchema;
export declare const addArrayItemObjectField: (targetId: string, schema: JsonSchema) => JsonSchema;
export declare const handleSchemaSelected: (targetId: string, schema: JsonSchema, selectedSchema: JsonSchema) => JsonSchema;
export declare const updateField: (targetId: string, updates: Partial<SchemaField>, schema: JsonSchema) => JsonSchema;
export declare const updateFieldType: (targetId: string, newType: SchemaField["type"], schema: JsonSchema, selectedSchema?: JsonSchema) => JsonSchema;
export declare const updateArrayItemFieldType: (targetId: string, newItemType: SchemaField["type"], schema: JsonSchema, selectedSchema?: JsonSchema) => JsonSchema;
export declare const deleteField: (targetId: string, schema: JsonSchema) => JsonSchema;