Define crm schema

This commit is contained in:
Fendy Heryanto
2025-12-24 08:03:30 +00:00
parent a91cc61313
commit 34a7f61c63
3 changed files with 526 additions and 0 deletions

View File

@@ -6,6 +6,9 @@ export * from './sync';
export * from './auth';
export * from './ai';
export { SCHEMA_TICKETING } from './sync/schema-ticketing';
export { SCHEMA_HRIS } from './sync/schema-hris';
export { SCHEMA_CRM } from './sync/schema-crm';
export { SCHEMA_FILE_STORAGE } from './sync/schema-filestorage';
export type {
TicketingTicketRecord,
TicketingUserRecord,

View File

@@ -0,0 +1,246 @@
import { UITypes, TARGET_TABLES, TARGET_TABLES_META } from 'nocodb-sdk';
import { SyncSchema, SyncRecord, SyncValue } from './types';
export const SCHEMA_CRM: SyncSchema = {
[TARGET_TABLES.CRM_ACCOUNT]: {
title: TARGET_TABLES_META[TARGET_TABLES.CRM_ACCOUNT].label,
columns: [
{ title: 'Name', uidt: UITypes.SingleLineText, pv: true },
{ title: 'Description', uidt: UITypes.SingleLineText },
{ title: 'Industry', uidt: UITypes.SingleSelect },
{ title: 'Website', uidt: UITypes.URL },
{ title: 'Number Of Employees', uidt: UITypes.Number },
{ title: 'Addresses', uidt: UITypes.SingleLineText },
{ title: 'Phone Numbers', uidt: UITypes.PhoneNumber },
{ title: 'Remote Fields', uidt: UITypes.JSON },
],
relations: [
{
columnTitle: 'Owner',
relatedTable: TARGET_TABLES.CRM_USER,
relatedTableColumnTitle: 'Accounts'
}
],
},
// [TARGET_TABLES.CRM_ASSOCIATION]: {
// title: TARGET_TABLES_META.crm_association.label,
// columns: [
// { title: 'Source Object', uidt: UITypes.SingleLineText },
// { title: 'Target Object', uidt: UITypes.SingleLineText },
// { title: 'Association Type', uidt: UITypes.SingleLineText },
// ],
// relations: [],
// },
// [TARGET_TABLES.CRM_ASSOCIATION_TYPE]: {
// title: TARGET_TABLES_META.crm_association_type.label,
// columns: [
// { title: 'Source Object Class', uidt: UITypes.SingleLineText },
// { title: 'Target Object Classes', uidt: UITypes.SingleLineText },
// { title: 'Remote Key Name', uidt: UITypes.SingleLineText },
// { title: 'Display Name', uidt: UITypes.SingleLineText },
// { title: 'Cardinality', uidt: UITypes.SingleLineText },
// { title: 'Is Required', uidt: UITypes.Checkbox },
// ],
// relations: [],
// },
[TARGET_TABLES.CRM_CONTACT]: {
title: TARGET_TABLES_META[TARGET_TABLES.CRM_CONTACT].label,
columns: [
{ title: 'First Name', uidt: UITypes.SingleLineText },
{ title: 'Last Name', uidt: UITypes.SingleLineText },
{ title: 'Addresses', uidt: UITypes.SingleLineText },
{ title: 'Email Addresses', uidt: UITypes.Email },
{ title: 'Phone Numbers', uidt: UITypes.PhoneNumber },
{ title: 'Last Activity At', uidt: UITypes.Date },
{ title: 'Remote Fields', uidt: UITypes.JSON },
],
relations: [
{
columnTitle: 'Account',
relatedTable: TARGET_TABLES.CRM_ACCOUNT,
relatedTableColumnTitle: 'Contacts'
},
{
columnTitle: 'Owner',
relatedTable: TARGET_TABLES.CRM_USER,
relatedTableColumnTitle: 'Contacts'
}
],
},
// [TARGET_TABLES.CRM_ENGAGEMENT]: {
// title: TARGET_TABLES_META.crm_engagement.label,
// columns: [
// { title: 'Owner', uidt: UITypes.SingleLineText },
// { title: 'Content', uidt: UITypes.LongText },
// { title: 'Subject', uidt: UITypes.SingleLineText },
// { title: 'Direction', uidt: UITypes.SingleSelect },
// { title: 'Engagement Type', uidt: UITypes.SingleSelect },
// { title: 'Start Time', uidt: UITypes.DateTime },
// { title: 'End Time', uidt: UITypes.DateTime },
// { title: 'Contacts', uidt: UITypes.SingleLineText },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [
// {
// columnTitle: 'Account',
// relatedTable: TARGET_TABLES.CRM_ACCOUNT,
// relatedTableColumnTitle: 'Engagements'
// }
// ],
// },
// [TARGET_TABLES.CRM_ENGAGEMENT_TYPE]: {
// title: TARGET_TABLES_META.crm_engagement_type.label,
// columns: [
// { title: 'Name', uidt: UITypes.SingleLineText, pv: true },
// { title: 'Activity Type', uidt: UITypes.SingleSelect },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [],
// },
// FIXME: cannot access lead feature on hubspot atm
// [TARGET_TABLES.CRM_LEAD]: {
// title: TARGET_TABLES_META[TARGET_TABLES.CRM_LEAD].label,
// columns: [
// { title: 'Owner', uidt: UITypes.SingleLineText },
// { title: 'Lead Source', uidt: UITypes.SingleSelect },
// { title: 'Title', uidt: UITypes.SingleLineText },
// { title: 'Company', uidt: UITypes.SingleLineText },
// { title: 'First Name', uidt: UITypes.SingleLineText },
// { title: 'Last Name', uidt: UITypes.SingleLineText },
// { title: 'Addresses', uidt: UITypes.SingleLineText },
// { title: 'Email Addresses', uidt: UITypes.Email },
// { title: 'Phone Numbers', uidt: UITypes.PhoneNumber },
// { title: 'Converted Date', uidt: UITypes.DateTime },
// { title: 'Converted Contact', uidt: UITypes.SingleLineText },
// { title: 'Status', uidt: UITypes.SingleSelect },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [
// {
// columnTitle: 'Converted_Account',
// relatedTable: TARGET_TABLES.CRM_ACCOUNT,
// relatedTableColumnTitle: 'Leads'
// },
// {
// columnTitle: 'Converted_Contact',
// relatedTable: TARGET_TABLES.CRM_CONTACT,
// relatedTableColumnTitle: 'Leads'
// }
// ],
// },
// [TARGET_TABLES.CRM_NOTE]: {
// title: TARGET_TABLES_META.crm_note.label,
// columns: [
// { title: 'Content', uidt: UITypes.LongText, pv: true },
// { title: 'Owner', uidt: UITypes.SingleLineText },
// { title: 'Opportunity', uidt: UITypes.SingleLineText },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [
// {
// columnTitle: 'Account',
// relatedTable: TARGET_TABLES.CRM_ACCOUNT,
// relatedTableColumnTitle: 'Notes'
// },
// {
// columnTitle: 'Contacts',
// relatedTable: TARGET_TABLES.CRM_CONTACT,
// relatedTableColumnTitle: 'Notes'
// }
// ],
// },
// [TARGET_TABLES.CRM_OPPORTUNITY]: {
// title: TARGET_TABLES_META.crm_opportunity.label,
// columns: [
// { title: 'Name', uidt: UITypes.SingleLineText },
// { title: 'Description', uidt: UITypes.SingleLineText },
// { title: 'Amount', uidt: UITypes.Decimal },
// { title: 'Owner', uidt: UITypes.SingleLineText },
// { title: 'Status', uidt: UITypes.SingleSelect },
// { title: 'Last Activity At', uidt: UITypes.DateTime },
// { title: 'Close Date', uidt: UITypes.DateTime },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [
// {
// columnTitle: 'Stage',
// relatedTable: TARGET_TABLES.CRM_STAGE,
// relatedTableColumnTitle: 'Opportunities'
// },
// {
// columnTitle: 'Account',
// relatedTable: TARGET_TABLES.CRM_ACCOUNT,
// relatedTableColumnTitle: 'Opportunities'
// }
// ],
// },
// [TARGET_TABLES.CRM_TASK]: {
// title: TARGET_TABLES_META.crm_task.label,
// columns: [
// { title: 'Subject', uidt: UITypes.SingleLineText },
// { title: 'Content', uidt: UITypes.SingleLineText },
// { title: 'Owner', uidt: UITypes.SingleLineText },
// { title: 'Opportunity', uidt: UITypes.SingleLineText },
// { title: 'Contact', uidt: UITypes.SingleLineText },
// { title: 'Completed Date', uidt: UITypes.SingleLineText },
// { title: 'Due Date', uidt: UITypes.SingleLineText },
// { title: 'Status', uidt: UITypes.SingleSelect },
// { title: 'Remote Fields', uidt: UITypes.SingleLineText },
// ],
// relations: [
// {
// columnTitle: 'Account',
// relatedTable: TARGET_TABLES.CRM_ACCOUNT,
// relatedTableColumnTitle: 'Tasks'
// }
// ],
// },
[TARGET_TABLES.CRM_USER]: {
title: TARGET_TABLES_META[TARGET_TABLES.CRM_USER].label,
columns: [
{ title: 'Name', uidt: UITypes.SingleLineText },
{ title: 'Email', uidt: UITypes.Email },
{ title: 'Is Active', uidt: UITypes.Checkbox },
{ title: 'Remote Fields', uidt: UITypes.JSON },
],
relations: [],
},
};
// [TARGET_TABLES.CRM_CustomObject]: {
// title: TARGET_TABLES_META.crm_custom_object.label,
// columns: [
// { title: 'remote_id', uidt: UITypes.SingleLineText },
// { title: 'created_at', uidt: UITypes.SingleLineText },
// { title: 'modified_at', uidt: UITypes.SingleLineText },
// { title: 'object_class', uidt: UITypes.SingleLineText },
// { title: 'fields', uidt: UITypes.SingleLineText },
// { title: 'remote_fields', uidt: UITypes.SingleLineText },
// ],
// relations: [],
// },
// [TARGET_TABLES.CustomObjectClass]: {
// title: TARGET_TABLES_META.crm_custom_object_class.label,
// columns: [
// { title: 'remote_id', uidt: UITypes.SingleLineText },
// { title: 'created_at', uidt: UITypes.SingleLineText },
// { title: 'modified_at', uidt: UITypes.SingleLineText },
// { title: 'name', uidt: UITypes.SingleLineText },
// { title: 'description', uidt: UITypes.SingleLineText },
// { title: 'labels', uidt: UITypes.SingleLineText },
// { title: 'fields', uidt: UITypes.SingleLineText },
// { title: 'association_types', uidt: UITypes.SingleLineText },
// ],
// relations: [],
// },

View File

@@ -97,6 +97,42 @@ export enum TARGET_TABLES {
TICKETING_USER = 'ticketing_user',
TICKETING_COMMENT = 'ticketing_comment',
TICKETING_TEAM = 'ticketing_team',
HRIS_EMPLOYEE = 'hris_employee',
// one by one will be enabled
// HRIS_BANK_INFO = 'hris_bank_info',
// HRIS_BENEFIT = 'hris_benefit',
// HRIS_COMPANY = 'hris_company',
// HRIS_DEPENDENT = 'hris_dependent',
// HRIS_EMPLOYEE_PAYROLL_RUN = 'hris_employee_payroll_run',
HRIS_EMPLOYMENT = 'hris_employment',
// HRIS_GROUP = 'hris_group',
HRIS_LOCATION = 'hris_location',
// HRIS_PAYROLL_RUN = 'hris_payroll_run',
// HRIS_TIME_OFF = 'hris_time_off',
// HRIS_TIME_OFF_BALANCE = 'hris_time_off_balance',
// HRIS_TIMESHEET_ENTRY = 'hris_timesheet_entry',
// some not prioritized HRIS tables are commented
// HRIS_EMPLOYER_BENEFIT = 'hris_employer_benefit',
FILE_STORAGE_FILE = 'fs_file',
FILE_STORAGE_FOLDER = 'fs_folder',
CRM_ACCOUNT = 'crm_account',
// CRM_ASSOCIATION = 'crm_association',
// CRM_ASSOCIATION_TYPE = 'crm_association_type',
CRM_CONTACT = 'crm_contact',
// CRM_CUSTOM_OBJECT = 'crm_custom_object',
// CRM_CUSTOM_OBJECT_CLASS = 'crm_custom_object_class',
// CRM_ENGAGEMENT = 'crm_engagement',
// CRM_ENGAGEMENT_TYPE = 'crm_engagement_type',
// CRM_LEAD = 'crm_lead',
// CRM_NOTE = 'crm_note',
// CRM_OPPORTUNITY = 'crm_opportunity',
// CRM_STAGE = 'crm_stage',
// CRM_TASK = 'crm_task',
CRM_USER = 'crm_user',
}
export const TARGET_TABLES_META = {
@@ -132,4 +168,245 @@ export const TARGET_TABLES_META = {
description: 'Sync all teams from the source',
required: false,
},
[TARGET_TABLES.HRIS_EMPLOYEE]: {
category: SyncCategory.HRIS,
value: TARGET_TABLES.HRIS_EMPLOYEE,
icon: 'ncUsers',
label: 'HR_Employee',
description: 'Represents human resources employee data.',
required: true,
},
[TARGET_TABLES.FILE_STORAGE_FILE]: {
category: SyncCategory.FILE_STORAGE,
value: TARGET_TABLES.FILE_STORAGE_FILE,
icon: 'file',
label: 'FS_File',
description: 'Represents file storage file metadata.',
required: false,
},
[TARGET_TABLES.FILE_STORAGE_FOLDER]: {
category: SyncCategory.FILE_STORAGE,
value: TARGET_TABLES.FILE_STORAGE_FOLDER,
icon: 'ncFolder',
label: 'FS_Folder',
description: 'Represents file storage folder metadata.',
required: false,
},
// [TARGET_TABLES.HRIS_BANK_INFO]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_BANK_INFO,
// icon: 'ncDatabase',
// label: 'HR_Bank Info',
// description: 'Represents human resources bank information data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_BENEFIT]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_BENEFIT,
// icon: 'ncDatabase',
// label: 'HR_Benefit',
// description: 'Represents human resources benefit data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_COMPANY]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_COMPANY,
// icon: 'ncDatabase',
// label: 'HR_Company',
// description: 'Represents human resources company data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_DEPENDENT]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_DEPENDENT,
// icon: 'ncUsers',
// label: 'HR_Dependent',
// description: 'Represents human resources dependent data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_EMPLOYEE_PAYROLL_RUN]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_EMPLOYEE_PAYROLL_RUN,
// icon: 'ncDatabase',
// label: 'HR_Employee Payroll Run',
// description: 'Represents human resources employee payroll run data.',
// required: false,
// },
[TARGET_TABLES.HRIS_EMPLOYMENT]: {
category: SyncCategory.HRIS,
value: TARGET_TABLES.HRIS_EMPLOYMENT,
icon: 'ncDatabase',
label: 'HR_Employment',
description: 'Represents human resources employment data.',
required: false,
},
// [TARGET_TABLES.HRIS_GROUP]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_GROUP,
// icon: 'ncUsers',
// label: 'HR_Group',
// description: 'Represents human resources group data.',
// required: false,
// },
[TARGET_TABLES.HRIS_LOCATION]: {
category: SyncCategory.HRIS,
value: TARGET_TABLES.HRIS_LOCATION,
icon: 'ncDatabase',
label: 'HR_Location',
description: 'Represents human resources location data.',
required: false,
},
// [TARGET_TABLES.HRIS_PAYROLL_RUN]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_PAYROLL_RUN,
// icon: 'ncDatabase',
// label: 'HR - Payroll Run',
// description: 'Represents human resources payroll run data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_TIME_OFF]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_TIME_OFF,
// icon: 'ncDatabase',
// label: 'HR - Time Off',
// description: 'Represents human resources time off data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_TIME_OFF_BALANCE]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_TIME_OFF_BALANCE,
// icon: 'ncDatabase',
// label: 'HR - Time Off Balance',
// description: 'Represents human resources time off balance data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_TIMESHEET_ENTRY]: {
// category: SyncCategory.HRIS,
// value: TARGET_TABLES.HRIS_TIMESHEET_ENTRY,
// icon: 'ncDatabase',
// label: 'HR - Timesheet Entry',
// description: 'Represents human resources timesheet entry data.',
// required: false,
// },
// [TARGET_TABLES.HRIS_EMPLOYER_BENEFIT]: {
// category: SyncCategory.CUSTOM,
// value: TARGET_TABLES.HRIS_EMPLOYER_BENEFIT,
// icon: 'ncDatabase',
// label: 'HR - Employer Benefit',
// description: 'Represents human resources employer benefit data.',
// required: false,
// },
[TARGET_TABLES.CRM_ACCOUNT]: {
category: SyncCategory.CRM,
value: TARGET_TABLES.CRM_ACCOUNT,
icon: 'ncUsers',
label: 'CRM_Account',
description: 'Represents crm account data.',
required: true,
},
// [TARGET_TABLES.CRM_ASSOCIATION]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_ASSOCIATION,
// icon: 'link2',
// label: 'CRM_Association',
// description: 'Represents crm association data.',
// required: false,
// },
// [TARGET_TABLES.CRM_ASSOCIATION_TYPE]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_ASSOCIATION_TYPE,
// icon: 'label',
// label: 'CRM_Association_type',
// description: 'Represents crm association types data.',
// required: false,
// },
[TARGET_TABLES.CRM_CONTACT]: {
category: SyncCategory.CRM,
value: TARGET_TABLES.CRM_CONTACT,
icon: 'ncUsers',
label: 'CRM_Contact',
description: 'Represents crm contact data.',
required: true,
},
// [TARGET_TABLES.CRM_CUSTOM_OBJECT]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_CUSTOM_OBJECT,
// icon: 'box',
// label: 'CRM_Custom_Object',
// description: 'Represents crm custom object data.',
// required: false,
// },
// [TARGET_TABLES.CRM_CUSTOM_OBJECT_CLASS]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_CUSTOM_OBJECT_CLASS,
// icon: 'layers',
// label: 'CRM_Custom_Object_Class',
// description: 'Represents crm custom object class data.',
// required: false,
// },
// [TARGET_TABLES.CRM_ENGAGEMENT]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_ENGAGEMENT,
// icon: 'message-square',
// label: 'CRM_Engagement',
// description: 'Represents crm engagement data.',
// required: false,
// },
// [TARGET_TABLES.CRM_ENGAGEMENT_TYPE]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_ENGAGEMENT_TYPE,
// icon: 'tag',
// label: 'CRM_Engagement_Type',
// description: 'Represents crm engagement type data.',
// required: false,
// },
// [TARGET_TABLES.CRM_LEAD]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_LEAD,
// icon: 'user-plus',
// label: 'CRM_Lead',
// description: 'Represents crm lead data.',
// required: true,
// },
// [TARGET_TABLES.CRM_NOTE]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_NOTE,
// icon: 'file-text',
// label: 'CRM_Note',
// description: 'Represents crm note data.',
// required: false,
// },
// [TARGET_TABLES.CRM_OPPORTUNITY]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_OPPORTUNITY,
// icon: 'trending-up',
// label: 'CRM_Opportunity',
// description: 'Represents crm opportunity data.',
// required: false,
// },
// [TARGET_TABLES.CRM_STAGE]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_STAGE,
// icon: 'sliders',
// label: 'CRM_Stage',
// description: 'Represents crm stage data.',
// required: false,
// },
// [TARGET_TABLES.CRM_TASK]: {
// category: SyncCategory.CRM,
// value: TARGET_TABLES.CRM_TASK,
// icon: 'check-square',
// label: 'CRM_Task',
// description: 'Represents crm task data.',
// required: false,
// },
[TARGET_TABLES.CRM_USER]: {
category: SyncCategory.CRM,
value: TARGET_TABLES.CRM_USER,
icon: 'user',
label: 'CRM_User',
description: 'Represents crm user data.',
required: true,
},
};