Skip to main content
Glama
ICloudflareD1Repository.ts•2.26 kB
import type { DatabaseSchema } from '../entities/DatabaseSchema'; import type { Index } from '../entities/Index'; import type { TableInfo } from '../entities/TableInfo'; /** * 🎯 SEMANTIC INTENT: Repository port (interface) for database schema access * * WHY: Port defines domain needs without infrastructure coupling * - Abstracts Cloudflare D1 REST API details * - Domain layer depends on this interface * - Infrastructure layer implements this interface * - Enables testing with mocks/fakes * * PORT PATTERN: Interface owned by domain, implemented by infrastructure * DEPENDENCY INVERSION: Infrastructure depends on domain, not vice versa * SEMANTIC CONTRACTS: Methods express domain operations, not technical details */ export interface QueryResult { results: unknown[]; success: boolean; meta?: { duration?: number; rows_read?: number; rows_written?: number; }; } export interface ICloudflareD1Repository { /** * Fetch complete database schema metadata * * Semantic: Get snapshot of all tables, indexes, relationships at current moment * * @param databaseId - D1 database identifier * @returns Complete schema aggregate root */ fetchDatabaseSchema(databaseId: string): Promise<DatabaseSchema>; /** * Fetch detailed information for specific tables * * Semantic: Get table metadata (columns, indexes, foreign keys) * * @param databaseId - D1 database identifier * @param tableName - Optional: specific table to fetch (undefined = all tables) * @returns Array of table metadata */ fetchTableDetails(databaseId: string, tableName?: string): Promise<TableInfo[]>; /** * Fetch index information from database * * Semantic: Get all index definitions for performance analysis * * @param databaseId - D1 database identifier * @returns Array of index metadata */ fetchIndexInformation(databaseId: string): Promise<Index[]>; /** * Execute raw SQL query on database * * Semantic: Direct SQL access for specialized queries * * @param databaseId - D1 database identifier * @param sql - SQL query string * @returns Query result with rows and metadata */ executeSQLQuery(databaseId: string, sql: string): Promise<QueryResult>; }

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