fix: disable incremental sync for Companies and Resources

Companies and Resources entities in Autotask API do not support
date-based filtering for incremental syncs. When attempting incremental
sync, Autotask returns errors:
- Companies: 'Unable to find lastTrackedModificationDateTime'
- Resources: 'Unable to find lastModifiedDate'

Solution:
- Skip incremental sync for these entities
- Always perform full sync for Companies and Resources
- Log informational message when falling back to full sync
- Other entities continue to support incremental sync normally

This prevents sync failures while maintaining data freshness for
Companies and Resources through full syncs.
This commit is contained in:
root 2026-01-26 12:07:52 -05:00
parent 43e8c74074
commit fc284aba85

View file

@ -85,7 +85,10 @@ export class EntitySyncService {
let params: any = {};
// For incremental sync, filter by last sync time
if (isIncremental) {
// Note: Companies and Resources don't support date-based filtering in Autotask API
const supportsIncremental = entity !== EntityType.COMPANIES && entity !== EntityType.RESOURCES;
if (isIncremental && supportsIncremental) {
try {
const lastSyncTime = await getLastSyncTime(entity);
if (lastSyncTime) {
@ -99,6 +102,8 @@ export class EntitySyncService {
entityLogger.error('Failed to get last sync time', {}, err);
throw new Error(`Failed to determine sync time: ${err.message}`);
}
} else if (isIncremental && !supportsIncremental) {
entityLogger.info(`${entity} does not support incremental sync, performing full sync instead`);
} else {
// For full sync, build filters
const filters: Array<{ field: string; op: string; value: any }> = [];