Skip to main content
Glama
Index.js•2.46 kB
"use strict"; /** * 🎯 SEMANTIC INTENT: Index represents database index metadata * * WHY: Indexes are semantic performance optimization markers * - name: Observable identifier * - tableName: Table being indexed * - columns: Indexed columns (order matters for composite indexes) * - isUnique: Semantic uniqueness constraint * - isPrimaryKey: Indicates if this is a primary key index * * OBSERVABLE PROPERTIES: Directly observable from sqlite_master * SEMANTIC ANCHORING: Indexes indicate intentional query optimization * IMMUTABILITY: Frozen to preserve schema semantics */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Index = void 0; class Index { name; tableName; columns; isUnique; isPrimaryKey; constructor(name, tableName, columns, isUnique = false, isPrimaryKey = false) { if (!name || name.trim().length === 0) { throw new Error('Index name cannot be empty'); } if (!tableName || tableName.trim().length === 0) { throw new Error('Table name cannot be empty'); } if (!columns || columns.length === 0) { throw new Error('Index must have at least one column'); } if (columns.some((col) => !col || col.trim().length === 0)) { throw new Error('Index column names cannot be empty'); } this.name = name.trim(); this.tableName = tableName.trim(); this.columns = Object.freeze([...columns.map((col) => col.trim())]); this.isUnique = isUnique; this.isPrimaryKey = isPrimaryKey; Object.freeze(this); } /** * Check if this is a composite index (multiple columns) * * Semantic: Composite indexes optimize multi-column queries */ isComposite() { return this.columns.length > 1; } /** * Check if index covers a specific column * * Observable: Column coverage is directly observable */ coversColumn(columnName) { return this.columns.includes(columnName); } /** * Check if index is the first column (most selective) * * Semantic: First column in composite index can be used alone */ hasColumnAsPrefix(columnName) { return this.columns[0] === columnName; } /** * Get index column count */ getColumnCount() { return this.columns.length; } } exports.Index = Index; //# sourceMappingURL=Index.js.map

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/semanticintent/semantic-d1-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server