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 {
|
export interface Resource {
|
||||||
id: number;
|
id: number;
|
||||||
|
// Name fields
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
email: string;
|
middleInitial?: string;
|
||||||
userName?: string;
|
namePrefix?: string;
|
||||||
isActive?: boolean;
|
nameSuffix?: string;
|
||||||
title?: string;
|
|
||||||
mobilePhone?: string;
|
// Contact information
|
||||||
|
email?: string;
|
||||||
|
emailAddress?: string;
|
||||||
|
emailAddress2?: string;
|
||||||
|
emailAddress3?: string;
|
||||||
officePhone?: string;
|
officePhone?: string;
|
||||||
|
mobilePhone?: string;
|
||||||
|
homePhone?: string;
|
||||||
officeExtension?: 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 {
|
export interface Ticket {
|
||||||
|
|
|
||||||
|
|
@ -277,21 +277,57 @@ function mapProject(data: any): Record<string, any> {
|
||||||
function mapResource(data: any): Record<string, any> {
|
function mapResource(data: any): Record<string, any> {
|
||||||
return {
|
return {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
first_name: data.first_name,
|
// Name fields
|
||||||
last_name: data.last_name,
|
first_name: data.firstName,
|
||||||
email: data.email || data.email_address,
|
last_name: data.lastName,
|
||||||
user_name: data.user_name || data.username,
|
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,
|
title: data.title,
|
||||||
office_phone: data.office_phone,
|
is_active: data.isActive !== undefined ? data.isActive : true,
|
||||||
mobile_phone: data.mobile_phone,
|
|
||||||
office_extension: data.office_extension,
|
// Employment details
|
||||||
is_active: data.is_active !== undefined ? data.is_active : true,
|
resource_type: data.resourceType,
|
||||||
location_id: data.location_id,
|
payroll_identifier: data.payrollIdentifier,
|
||||||
resource_type: data.resource_type,
|
pay_roll_identifier: data.payrollIdentifier, // Keep for backward compatibility
|
||||||
pay_roll_identifier: data.pay_roll_identifier,
|
payroll_type: data.payrollType,
|
||||||
hire_date: data.hire_date,
|
accounting_reference_id: data.accountingReferenceID,
|
||||||
travel_availability_pct: data.travel_availability_pct,
|
internal_cost: data.internalCost,
|
||||||
survey_resource_rating: data.survey_resource_rating,
|
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,
|
synced_at: data.synced_at,
|
||||||
is_deleted: data.is_deleted || false,
|
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