From 3db50d8531a5d110cabc2d207fe5ea23c2198788 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Jan 2026 10:29:31 -0500 Subject: [PATCH] fix: correct SyncService initialization in sync-scheduler Fixed TypeScript errors in sync-scheduler: - Added constructor to initialize SyncService with AutotaskClient - Fixed AutotaskConfig property names (password, apiIntegrationCode) - Changed method calls to match SyncService API (incrementalSync, fullSync) - Fixed syncService references to use this.syncService This resolves build errors preventing Docker image creation. --- lib/services/sync-scheduler.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/services/sync-scheduler.ts b/lib/services/sync-scheduler.ts index 18f02a5..3dc58b6 100644 --- a/lib/services/sync-scheduler.ts +++ b/lib/services/sync-scheduler.ts @@ -4,8 +4,9 @@ */ import cron, { ScheduledTask } from 'node-cron'; -import { syncService } from './sync-service'; +import { SyncService, createSyncService } from './sync-service'; import { postgresClient } from './postgres-client'; +import { AutotaskClient } from './autotask-client'; export interface ScheduleConfig { id: string; @@ -34,6 +35,18 @@ class SyncScheduler { private tasks: Map = new Map(); private runningJobs: Set = new Set(); private initialized = false; + private syncService: SyncService; + + constructor() { + // Create sync service instance + const autotaskClient = new AutotaskClient({ + apiUrl: process.env.AUTOTASK_API_URL || '', + username: process.env.AUTOTASK_USERNAME || '', + password: process.env.AUTOTASK_SECRET || '', + apiIntegrationCode: process.env.AUTOTASK_INTEGRATION_CODE || '', + }); + this.syncService = createSyncService(autotaskClient); + } /** * Initialize the scheduler and load schedules from database @@ -228,9 +241,9 @@ class SyncScheduler { // Execute the sync if (config.sync_type === 'incremental') { - await syncService.startIncrementalSync('scheduled'); + await this.syncService.incrementalSync('scheduled'); } else { - await syncService.startFullSync('scheduled', config.years_back || 2); + await this.syncService.fullSync('scheduled', config.years_back || 2); } // Update success status