UNPKG

@msugiura/rawsql-prisma

Version:

Prisma integration for rawsql-ts - Dynamic SQL generation with type safety and hierarchical JSON serialization

110 lines (109 loc) 3.57 kB
import { TableColumnResolver } from 'rawsql-ts'; import { PrismaSchemaInfo, PrismaModelInfo } from '../types'; /** * Prisma-specific table and column resolver * * This resolver uses Prisma schema information to resolve table and column names * for SQL generation and validation. */ export declare class PrismaTableColumnResolver { private readonly schemaInfo; constructor(schemaInfo: PrismaSchemaInfo); /** * Create a TableColumnResolver function for rawsql-ts * * @returns TableColumnResolver function */ createTableColumnResolver(): TableColumnResolver; /** * Get all available table names * * @returns Array of table names */ getTableNames(): string[]; /** * Get all column names for a specific table * * @param tableName - The table name * @returns Array of column names, or undefined if table not found */ getColumnNames(tableName: string): string[] | undefined; /** * Check if a table exists in the schema * * @param tableName - The table name to check * @returns true if table exists, false otherwise */ hasTable(tableName: string): boolean; /** * Check if a column exists in a specific table * * @param tableName - The table name * @param columnName - The column name to check * @returns true if column exists, false otherwise */ hasColumn(tableName: string, columnName: string): boolean; /** * Get the primary key columns for a table * * @param tableName - The table name * @returns Array of primary key column names, or undefined if table not found */ getPrimaryKeyColumns(tableName: string): string[] | undefined; /** * Get the unique constraints for a table * * @param tableName - The table name * @returns Array of unique constraint column arrays, or undefined if table not found */ getUniqueConstraints(tableName: string): string[][] | undefined; /** * Get column type information * * @param tableName - The table name * @param columnName - The column name * @returns Column type information, or undefined if not found */ getColumnType(tableName: string, columnName: string): string | undefined; /** * Check if a column is nullable * * @param tableName - The table name * @param columnName - The column name * @returns true if column is nullable, false if not nullable, undefined if not found */ isColumnNullable(tableName: string, columnName: string): boolean | undefined; /** * Get relation information for a table * * @param tableName - The table name * @returns Array of relation information, or undefined if table not found */ getRelations(tableName: string): Array<{ name: string; relatedTable: string; type: string; foreignKeys: string[]; referencedKeys: string[]; }> | undefined; /** * Find model by table name * * @param tableName - The table name to search for * @returns Model information if found, undefined otherwise */ private findModelByTableName; /** * Get model information by model name * * @param modelName - The Prisma model name * @returns Model information if found, undefined otherwise */ getModelInfo(modelName: string): PrismaModelInfo | undefined; /** * Get all model names * * @returns Array of model names */ getModelNames(): string[]; }