feat: expand Resources entity to include all Autotask API fields
Add comprehensive field support for Resources entity including: - Name fields: middleInitial, namePrefix, nameSuffix - Contact: emailAddress2, emailAddress3, homePhone - Employment: accountingReferenceID, payrollType, internalCost - System: emailTypeCode, numberFormat, timeFormat, dateFormat - Demographics: gender - Security: licenseType, securityLevel - Location: defaultServiceDeskRoleID Changes: - Migration 015: Add new columns to resources table - Updated entity mapper to map all Autotask Resource fields - Expanded TypeScript Resource interface with all fields - Maintains backward compatibility with existing field names This ensures all data exposed by the Autotask Resources API is now captured and stored in the database.
This commit is contained in:
parent
a1e50a7161
commit
8e0ca0a63b
3 changed files with 131 additions and 19 deletions
|
|
@ -30,15 +30,54 @@ export interface QueryParams {
|
|||
|
||||
export interface Resource {
|
||||
id: number;
|
||||
// Name fields
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
userName?: string;
|
||||
isActive?: boolean;
|
||||
title?: string;
|
||||
mobilePhone?: string;
|
||||
middleInitial?: string;
|
||||
namePrefix?: string;
|
||||
nameSuffix?: string;
|
||||
|
||||
// Contact information
|
||||
email?: string;
|
||||
emailAddress?: string;
|
||||
emailAddress2?: string;
|
||||
emailAddress3?: string;
|
||||
officePhone?: string;
|
||||
mobilePhone?: string;
|
||||
homePhone?: string;
|
||||
officeExtension?: string;
|
||||
|
||||
// System fields
|
||||
userName?: string;
|
||||
title?: string;
|
||||
isActive?: boolean;
|
||||
|
||||
// Employment details
|
||||
resourceType?: number;
|
||||
payrollIdentifier?: string;
|
||||
payrollType?: number;
|
||||
accountingReferenceID?: string;
|
||||
internalCost?: number;
|
||||
hireDate?: string;
|
||||
|
||||
// Location and availability
|
||||
locationID?: number;
|
||||
travelAvailabilityPct?: number;
|
||||
defaultServiceDeskRoleID?: number;
|
||||
|
||||
// System preferences
|
||||
emailTypeCode?: number;
|
||||
numberFormat?: string;
|
||||
timeFormat?: string;
|
||||
dateFormat?: string;
|
||||
|
||||
// Demographics and security
|
||||
gender?: number;
|
||||
licenseType?: number;
|
||||
securityLevel?: number;
|
||||
|
||||
// Ratings
|
||||
surveyResourceRating?: number;
|
||||
}
|
||||
|
||||
export interface Ticket {
|
||||
|
|
|
|||
|
|
@ -277,21 +277,57 @@ function mapProject(data: any): Record<string, any> {
|
|||
function mapResource(data: any): Record<string, any> {
|
||||
return {
|
||||
id: data.id,
|
||||
first_name: data.first_name,
|
||||
last_name: data.last_name,
|
||||
email: data.email || data.email_address,
|
||||
user_name: data.user_name || data.username,
|
||||
// Name fields
|
||||
first_name: data.firstName,
|
||||
last_name: data.lastName,
|
||||
middle_initial: data.middleInitial,
|
||||
name_prefix: data.namePrefix,
|
||||
name_suffix: data.nameSuffix,
|
||||
|
||||
// Contact information
|
||||
email: data.email || data.emailAddress,
|
||||
email_address: data.emailAddress,
|
||||
email_address2: data.emailAddress2,
|
||||
email_address3: data.emailAddress3,
|
||||
office_phone: data.officePhone,
|
||||
mobile_phone: data.mobilePhone,
|
||||
home_phone: data.homePhone,
|
||||
office_extension: data.officeExtension,
|
||||
|
||||
// System fields
|
||||
user_name: data.userName,
|
||||
title: data.title,
|
||||
office_phone: data.office_phone,
|
||||
mobile_phone: data.mobile_phone,
|
||||
office_extension: data.office_extension,
|
||||
is_active: data.is_active !== undefined ? data.is_active : true,
|
||||
location_id: data.location_id,
|
||||
resource_type: data.resource_type,
|
||||
pay_roll_identifier: data.pay_roll_identifier,
|
||||
hire_date: data.hire_date,
|
||||
travel_availability_pct: data.travel_availability_pct,
|
||||
survey_resource_rating: data.survey_resource_rating,
|
||||
is_active: data.isActive !== undefined ? data.isActive : true,
|
||||
|
||||
// Employment details
|
||||
resource_type: data.resourceType,
|
||||
payroll_identifier: data.payrollIdentifier,
|
||||
pay_roll_identifier: data.payrollIdentifier, // Keep for backward compatibility
|
||||
payroll_type: data.payrollType,
|
||||
accounting_reference_id: data.accountingReferenceID,
|
||||
internal_cost: data.internalCost,
|
||||
hire_date: data.hireDate,
|
||||
|
||||
// Location and availability
|
||||
location_id: data.locationID,
|
||||
travel_availability_pct: data.travelAvailabilityPct,
|
||||
default_service_desk_role_id: data.defaultServiceDeskRoleID,
|
||||
|
||||
// System preferences
|
||||
email_type_code: data.emailTypeCode,
|
||||
number_format: data.numberFormat,
|
||||
time_format: data.timeFormat,
|
||||
date_format: data.dateFormat,
|
||||
|
||||
// Demographics and security
|
||||
gender: data.gender,
|
||||
license_type: data.licenseType,
|
||||
security_level: data.securityLevel,
|
||||
|
||||
// Ratings
|
||||
survey_resource_rating: data.surveyResourceRating,
|
||||
|
||||
// Audit fields
|
||||
synced_at: data.synced_at,
|
||||
is_deleted: data.is_deleted || false,
|
||||
};
|
||||
|
|
|
|||
37
migrations/015_expand_resources_fields.sql
Normal file
37
migrations/015_expand_resources_fields.sql
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-- Add comprehensive fields to resources table based on Autotask Resources API
|
||||
-- Reference: https://autotask.net/help/developerhelp/Content/APIs/REST/Entities/ResourcesEntity.htm
|
||||
|
||||
ALTER TABLE resources
|
||||
-- Name fields
|
||||
ADD COLUMN IF NOT EXISTS middle_initial VARCHAR(10),
|
||||
ADD COLUMN IF NOT EXISTS name_prefix VARCHAR(20),
|
||||
ADD COLUMN IF NOT EXISTS name_suffix VARCHAR(20),
|
||||
|
||||
-- Contact information
|
||||
ADD COLUMN IF NOT EXISTS email_address VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS email_address2 VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS email_address3 VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS home_phone VARCHAR(50),
|
||||
|
||||
-- Employment details
|
||||
ADD COLUMN IF NOT EXISTS accounting_reference_id VARCHAR(100),
|
||||
ADD COLUMN IF NOT EXISTS payroll_identifier VARCHAR(100),
|
||||
ADD COLUMN IF NOT EXISTS payroll_type INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS internal_cost DECIMAL(15,2),
|
||||
|
||||
-- Location and availability
|
||||
ADD COLUMN IF NOT EXISTS default_service_desk_role_id BIGINT,
|
||||
|
||||
-- System fields
|
||||
ADD COLUMN IF NOT EXISTS email_type_code INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS gender INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS license_type INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS number_format VARCHAR(50),
|
||||
ADD COLUMN IF NOT EXISTS time_format VARCHAR(50),
|
||||
ADD COLUMN IF NOT EXISTS date_format VARCHAR(50),
|
||||
|
||||
-- Security
|
||||
ADD COLUMN IF NOT EXISTS security_level INTEGER;
|
||||
|
||||
-- Add comment to track migration
|
||||
COMMENT ON TABLE resources IS 'Expanded with all Autotask API fields - Migration 015';
|
||||
Loading…
Add table
Add a link
Reference in a new issue