diff --git a/lib/services/sync-scheduler.ts b/lib/services/sync-scheduler.ts index 09b9382..cd0dac2 100644 --- a/lib/services/sync-scheduler.ts +++ b/lib/services/sync-scheduler.ts @@ -22,7 +22,7 @@ export interface ScheduleConfig { name: string; description: string; cron_expression: string; - sync_type: 'incremental' | 'full' | 'veeam-incremental' | 'veeam-full' | 'veeam-rpo-check' | 'contract-services' | 'engagement-daily' | 'zoom-daily' | 'morning-summary' | 'ticket-digest-daily' | 'ticket-digest-weekly' | 'ticket-digest-monthly' | 'device-link-reconcile' | 'integration-health' | 'qbo' | 'appgate-sessions' | 'appgate-daily' | 'tickets-reconcile'; + sync_type: 'incremental' | 'full' | 'veeam-incremental' | 'veeam-full' | 'veeam-rpo-check' | 'contract-services' | 'engagement-daily' | 'zoom-daily' | 'morning-summary' | 'ticket-digest-daily' | 'ticket-digest-weekly' | 'ticket-digest-monthly' | 'device-link-reconcile' | 'integration-health' | 'qbo' | 'appgate-sessions' | 'appgate-daily' | 'tickets-reconcile' | 'pax8-daily'; years_back?: number; is_enabled: boolean; last_run?: Date; @@ -461,6 +461,22 @@ class SyncScheduler { console.log( `[SCHEDULER] tickets-reconcile: scanned=${result.scanned} updated=${result.updated} flippedComplete=${result.statusFlippedToComplete} softDeleted=${result.softDeleted} errors=${result.errors}` ); + } else if (config.sync_type === 'pax8-daily') { + const { isPax8Configured } = await import('@/lib/services/pax8-factory'); + if (!isPax8Configured()) { + console.log('[SCHEDULER] Skipping pax8-daily — PAX8 not configured'); + } else { + const disabledRes = await postgresClient.query<{ disabled: boolean }>( + `SELECT disabled FROM integration_settings WHERE key = 'pax8'` + ); + const isDisabled = disabledRes.rows[0]?.disabled === true; + if (isDisabled) { + console.log('[SCHEDULER] Skipping pax8-daily — PAX8 disabled via /admin/integrations'); + } else { + const { getPax8SyncService } = await import('@/lib/services/pax8-sync-service'); + await getPax8SyncService().fullSync('scheduled'); + } + } } else if (config.sync_type === 'incremental') { await this.syncService.incrementalSync('scheduled'); } else {