diff --git a/backend/src/services/schemaConfigurationService.ts b/backend/src/services/schemaConfigurationService.ts index f41a9bb..242a29f 100644 --- a/backend/src/services/schemaConfigurationService.ts +++ b/backend/src/services/schemaConfigurationService.ts @@ -10,6 +10,7 @@ import { logger } from './logger.js'; import { normalizedCacheStore } from './normalizedCacheStore.js'; import { config } from '../config/env.js'; import { toPascalCase } from './schemaUtils.js'; +import type { DatabaseAdapter } from './database/interface.js'; export interface JiraSchema { id: number; @@ -62,12 +63,12 @@ class SchemaConfigurationService { schemaName: string; objectTypes: ConfiguredObjectType[]; }>> { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); const rows = await db.query<{ id: number; @@ -141,12 +142,12 @@ class SchemaConfigurationService { * id format: "schemaId:objectTypeId" (e.g., "6:123") */ async setObjectTypeEnabled(id: string, enabled: boolean): Promise { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); // Parse id: "schemaId:objectTypeId" const [schemaIdStr, objectTypeIdStr] = id.split(':'); @@ -226,16 +227,16 @@ class SchemaConfigurationService { * Bulk update enabled status for multiple object types */ async bulkSetObjectTypesEnabled(updates: Array<{ id: string; enabled: boolean }>): Promise { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); const now = new Date().toISOString(); - await db.transaction(async (txDb) => { + await db.transaction(async (txDb: DatabaseAdapter) => { for (const update of updates) { // Parse id: "schemaId:objectTypeId" const [schemaIdStr, objectTypeIdStr] = update.id.split(':'); @@ -321,12 +322,12 @@ class SchemaConfigurationService { objectTypeName: string; displayName: string; }>> { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); // Use parameterized query to avoid boolean/integer comparison issues const rows = await db.query<{ @@ -342,7 +343,12 @@ class SchemaConfigurationService { [db.isPostgres ? true : 1] ); - return rows.map(row => ({ + return rows.map((row: { + jira_schema_id: string; + jira_type_id: number; + type_name: string; + display_name: string; + }) => ({ schemaId: row.jira_schema_id, objectTypeId: row.jira_type_id, objectTypeName: row.type_name, @@ -368,12 +374,12 @@ class SchemaConfigurationService { disabledObjectTypes: number; isConfigured: boolean; }> { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); const totalRow = await db.queryOne<{ count: number }>(` SELECT COUNT(*) as count FROM object_types @@ -410,12 +416,12 @@ class SchemaConfigurationService { schemaName: string; searchEnabled: boolean; }>> { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); const rows = await db.query<{ jira_schema_id: string; @@ -427,7 +433,11 @@ class SchemaConfigurationService { ORDER BY name ASC `); - return rows.map(row => ({ + return rows.map((row: { + jira_schema_id: string; + name: string; + search_enabled: boolean | number; + }) => ({ schemaId: row.jira_schema_id, schemaName: row.name, searchEnabled: typeof row.search_enabled === 'boolean' ? row.search_enabled : row.search_enabled === 1, @@ -438,12 +448,12 @@ class SchemaConfigurationService { * Set search enabled status for a schema */ async setSchemaSearchEnabled(schemaId: string, searchEnabled: boolean): Promise { - const db = (normalizedCacheStore as any).db; + const db: DatabaseAdapter = (normalizedCacheStore as any).db; if (!db) { throw new Error('Database not available'); } - await db.ensureInitialized?.(); + await (db as any).ensureInitialized?.(); const now = new Date().toISOString();