adba
Version:
Any DataBase to API
35 lines (34 loc) • 1.27 kB
TypeScript
import { Model, JSONSchema } from "objection";
/**
* Retrieve an Objection model by its table name.
*
* @param tableName - Name of the table to search for.
* @param models - Object containing available models.
* @returns The matching model or undefined.
*
* @example
* const User = getModelByTableName("users", allModels);
*/
export declare function getModelByTableName(tableName: string, models: Record<string, typeof Model>): typeof Model | undefined;
/**
* Converts a string into PascalCase, suitable for class names.
* Handles strings in kebab-case or snake_case.
* @param str - The input string.
* @returns The converted PascalCase string.
*/
export declare function className(str: string): string;
export interface ITableColumn {
name: string;
label: string;
type?: string;
format?: string;
required?: boolean;
}
/**
* Converts JSON schema properties to the column format expected by the Table component.
*
* @param schemaProperties - Properties section of a JSON schema.
* @param required - List of required property names.
* @returns Columns in the Table component format.
*/
export declare function jsonSchemaToColumns(schemaProperties: Record<string, JSONSchema>, required?: string[]): Record<string, ITableColumn>;