import { pluginHost } from '../../core/plugin-host/host.js';
import { databaseTableSlug } from '../../services/slug.js';
import { databaseTableSerializer } from './serializer.js';
import { databaseTableSystemPrompt } from './system-prompt.js';
import { databaseTablesRouter } from './routes.js';
import { DatabaseTableService } from './services.js';
import { createDatabaseToolsServer } from './mcp-server.js';
export const databaseTableBackendModule = {
    type: 'database-table',
    table: 'database_table',
    label: 'Database Table',
    labelPlural: 'Database Tables',
    displayOrder: 30,
    pathPrefix: '/database-tables',
    slugFrom: (data) => databaseTableSlug(data.name),
    serializer: databaseTableSerializer,
    systemPrompt: databaseTableSystemPrompt,
    backend: {
        mount(ctx) {
            const service = new DatabaseTableService(ctx.db, ctx.tagsService, ctx.versionService);
            ctx.app.use(`/api${databaseTableBackendModule.pathPrefix}`, databaseTablesRouter(service, ctx.referencesService, ctx.ws));
            ctx.registerMcpServer(`${databaseTableBackendModule.type}-tools`, () => createDatabaseToolsServer({
                databaseTableService: service,
                referencesService: ctx.referencesService,
                ws: ctx.ws,
            }));
            ctx.setIdResolver(databaseTableBackendModule.type, (slug) => service.getIdBySlug(slug));
            ctx.registerEntityService(databaseTableBackendModule.type, service);
        },
    },
};
pluginHost.registerBackendModule(databaseTableBackendModule);
//# sourceMappingURL=plugin.js.map