From d07c0b782697cf9d648937b7bb4c7f5ce9d3973f Mon Sep 17 00:00:00 2001 From: lorentz Date: Sat, 11 Jul 2026 09:46:48 -0400 Subject: [PATCH] feat(13-01): dispatch pax8-daily to fullSync with dual guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extend ScheduleConfig.sync_type union with 'pax8-daily' - Add dual-guarded branch in executeScheduledSync: skips with a distinct log when PAX8 is not configured (isPax8Configured()) or when integration_settings.key='pax8' is disabled, otherwise calls getPax8SyncService().fullSync('scheduled') - PAX8-only inline check per D-01 — no shared helper, no changes to getDbDisabledKeys()/applyDisableOverlay() or other switch branches --- lib/services/sync-scheduler.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 {