feat: add Autotask tags sync (tag groups, tags, ticket tag associations)

- Migration 057: autotask_tag_groups, autotask_tags, and junction tables
  (ticket_tags, company_tags, configuration_item_tags, contact_tags)
- Add TAG_GROUPS and TAGS to EntityType enum and dependency map
- Add mapTagGroup() and mapTag() entity mapper functions
- Add syncTagGroups(), syncTags(), syncTicketTagAssociations() methods
- Wire TicketTagAssociations bulk sync into full/incremental sync flow
- Add 'exist' operator to QueryFilter type
- No FK on ticket_id (tagged tickets may be outside 2yr sync window)

Synced: 26 tag groups, 7299 tags, 10141 ticket-tag associations
This commit is contained in:
lorentz 2026-03-20 09:22:40 -04:00
parent fe9f806c50
commit ff9e34cafe
8 changed files with 238 additions and 3 deletions

View file

@ -72,6 +72,12 @@ export function mapAutotaskToDatabase(
case EntityType.WORK_TYPES:
mapped = mapPicklist(data);
break;
case EntityType.TAG_GROUPS:
mapped = mapTagGroup(data);
break;
case EntityType.TAGS:
mapped = mapTag(data);
break;
default:
// Fallback: auto-convert camelCase to snake_case
mapped = {};
@ -724,6 +730,35 @@ function mapTimeEntry(data: any): Record<string, any> {
};
}
/**
* Map TagGroup entity
*/
function mapTagGroup(data: any): Record<string, any> {
return {
id: data.id,
label: data.label,
display_color: data.displayColor,
is_active: data.isActive !== undefined ? data.isActive : true,
is_system: data.isSystem || false,
};
}
/**
* Map Tag entity
*/
function mapTag(data: any): Record<string, any> {
return {
id: data.id,
label: data.label,
tag_group_id: data.tagGroupID,
is_active: data.isActive !== undefined ? data.isActive : true,
is_system: data.isSystem || false,
is_excluded_from_automatic_tagging: data.isExcludedFromAutomaticTagging || false,
create_date_time: data.createDateTime,
last_modified_date_time: data.lastModifiedDateTime,
};
}
/**
* Map Picklist entity (statuses, issue types, etc.)
*/