@hechtcarmel/vertica-mcp
Version:
MCP (Model Context Protocol) server for readonly Vertica database operations
40 lines • 1.56 kB
JavaScript
import { TABLE_TYPES } from "../constants/index.js";
export function determineTableType(flags) {
const { is_temp_table, is_system_table, is_flextable } = flags;
if (is_temp_table === "t" || is_temp_table === true) {
return TABLE_TYPES.TEMPORARY_TABLE;
}
if (is_system_table === "t" || is_system_table === true) {
return TABLE_TYPES.SYSTEM_TABLE;
}
if (is_flextable === "t" || is_flextable === true) {
return TABLE_TYPES.FLEX_TABLE;
}
return TABLE_TYPES.TABLE;
}
export function resolveSchemaName(schemaName, defaultSchema) {
return schemaName || defaultSchema || "public";
}
export function validateTableName(tableName) {
if (!tableName || typeof tableName !== "string") {
throw new Error("Table name must be a non-empty string");
}
if (tableName.trim() !== tableName) {
throw new Error("Table name cannot have leading or trailing whitespace");
}
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(tableName)) {
throw new Error("Table name must be a valid SQL identifier");
}
}
export function validateSchemaName(schemaName) {
if (!schemaName || typeof schemaName !== "string") {
throw new Error("Schema name must be a non-empty string");
}
if (schemaName.trim() !== schemaName) {
throw new Error("Schema name cannot have leading or trailing whitespace");
}
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(schemaName)) {
throw new Error("Schema name must be a valid SQL identifier");
}
}
//# sourceMappingURL=table-helpers.js.map