diff --git a/apps/webapp/public/rag/openai.jpg b/apps/webapp/public/rag/openai.jpg deleted file mode 100644 index e42edacbb..000000000 Binary files a/apps/webapp/public/rag/openai.jpg and /dev/null differ diff --git a/apps/webapp/public/rag/openai.png b/apps/webapp/public/rag/openai.png index fc71f647c..e42edacbb 100644 Binary files a/apps/webapp/public/rag/openai.png and b/apps/webapp/public/rag/openai.png differ diff --git a/packages/api/scripts/init.sql b/packages/api/scripts/init.sql index 43efca349..4bdb1db6e 100644 --- a/packages/api/scripts/init.sql +++ b/packages/api/scripts/init.sql @@ -556,6 +556,7 @@ CREATE TABLE connector_sets fs_googledrive boolean NULL, fs_sharepoint boolean NULL, fs_onedrive boolean NULL, + crm_salesforce boolean NULL, CONSTRAINT PK_project_connector PRIMARY KEY ( id_connector_set ) ); diff --git a/packages/api/scripts/seed.sql b/packages/api/scripts/seed.sql index dc087a70d..437665e67 100644 --- a/packages/api/scripts/seed.sql +++ b/packages/api/scripts/seed.sql @@ -2,10 +2,10 @@ INSERT INTO users (id_user, identification_strategy, email, password_hash, first ('0ce39030-2901-4c56-8db0-5e326182ec6b', 'b2c','local@panora.dev', '$2b$10$Y7Q8TWGyGuc5ecdIASbBsuXMo3q/Rs3/cnY.mLZP4tUgfGUOCUBlG', 'local', 'Panora'); -INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedrive, crm_attio, crm_zendesk, crm_close, tcg_zendesk, tcg_gorgias, tcg_front, tcg_jira, tcg_gitlab, fs_box, tcg_github, hris_deel, hris_sage, ats_ashby, crm_microsoftdynamicssales, ecom_webflow, tcg_linear, ecom_shopify, ecom_woocommerce, ecom_amazon, ecom_squarespace, hris_gusto, fs_googledrive, fs_dropbox, fs_sharepoint, fs_onedrive) VALUES - ('1709da40-17f7-4d3a-93a0-96dc5da6ddd7', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), - ('852dfff8-ab63-4530-ae49-e4b2924407f8', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), - ('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); +INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedrive, crm_attio, crm_zendesk, crm_close, tcg_zendesk, tcg_gorgias, tcg_front, tcg_jira, tcg_gitlab, fs_box, tcg_github, hris_deel, hris_sage, ats_ashby, crm_microsoftdynamicssales, ecom_webflow, tcg_linear, ecom_shopify, ecom_woocommerce, ecom_amazon, ecom_squarespace, hris_gusto, fs_googledrive, fs_dropbox, fs_sharepoint, fs_onedrive, crm_salesforce) VALUES + ('1709da40-17f7-4d3a-93a0-96dc5da6ddd7', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), + ('852dfff8-ab63-4530-ae49-e4b2924407f8', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), + ('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); INSERT INTO projects (id_project, name, sync_mode, id_user, id_connector_set) VALUES ('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pull', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'), diff --git a/packages/api/src/@core/sync/sync.service.ts b/packages/api/src/@core/sync/sync.service.ts index 3681361f5..ef3935d60 100644 --- a/packages/api/src/@core/sync/sync.service.ts +++ b/packages/api/src/@core/sync/sync.service.ts @@ -73,9 +73,10 @@ export class CoreSyncService { ? lastSyncEvent.timestamp : new Date(0); - const hoursSinceLastSync = - (now.getTime() - lastSyncTime.getTime()) / (1000 * 60 * 60); - if (interval && hoursSinceLastSync >= interval) { + const secondsSinceLastSync = + Number(now.getTime() - lastSyncTime.getTime()) / 1000; + + if (interval && secondsSinceLastSync >= interval) { await this.prisma.events.create({ data: { id_project: project.id_project, diff --git a/packages/api/src/crm/contact/services/salesforce/index.ts b/packages/api/src/crm/contact/services/salesforce/index.ts index 89d9c6ebe..47904f087 100644 --- a/packages/api/src/crm/contact/services/salesforce/index.ts +++ b/packages/api/src/crm/contact/services/salesforce/index.ts @@ -8,10 +8,7 @@ import { IContactService } from '@crm/contact/types'; import { Injectable } from '@nestjs/common'; import axios from 'axios'; import { ServiceRegistry } from '../registry.service'; -import { - SalesforceContactInput, - SalesforceContactOutput, - } from './types'; +import { SalesforceContactInput, SalesforceContactOutput } from './types'; @Injectable() export class SalesforceService implements IContactService { @@ -77,18 +74,28 @@ export class SalesforceService implements IContactService { }); const instanceUrl = connection.account_url; - let pagingString = `${pageSize ? `ORDER BY Id DESC LIMIT ${pageSize} ` : ''}${ - cursor ? `OFFSET ${cursor}` : '' - }`; + let pagingString = ''; + if (pageSize) { + pagingString += `LIMIT ${pageSize} `; + } + if (cursor) { + pagingString += `OFFSET ${cursor}`; + } if (!pageSize && !cursor) { pagingString = 'LIMIT 200'; } - const fields = custom_properties ? custom_properties.join(',') : 'Id,FirstName,LastName,Email,Phone'; - const query = `SELECT ${fields} FROM Contact ${pagingString}`; + const fields = + custom_properties?.length > 0 + ? custom_properties.join(',') + : 'Id,FirstName,LastName,Email,Phone'; + + const query = `SELECT ${fields} FROM Contact ${pagingString}`.trim(); const resp = await axios.get( - `${instanceUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query)}`, + `${instanceUrl}/services/data/v56.0/query/?q=${encodeURIComponent( + query, + )}`, { headers: { Authorization: `Bearer ${this.cryptoService.decrypt( @@ -106,7 +113,8 @@ export class SalesforceService implements IContactService { statusCode: 200, }; } catch (error) { + this.logger.log(`Error syncing Salesforce contacts: ${error.message}`); throw error; } } -} \ No newline at end of file +} diff --git a/packages/api/src/crm/note/services/salesforce/index.ts b/packages/api/src/crm/note/services/salesforce/index.ts index 18d5b6221..0789f00a5 100644 --- a/packages/api/src/crm/note/services/salesforce/index.ts +++ b/packages/api/src/crm/note/services/salesforce/index.ts @@ -92,21 +92,28 @@ export class SalesforceService implements INoteService { }); const instanceUrl = connection.account_url; - let pagingString = `${pageSize ? `ORDER BY Id DESC LIMIT ${pageSize} ` : ''}${ - cursor ? `OFFSET ${cursor}` : '' - }`; + let pagingString = ''; + if (pageSize) { + pagingString += `LIMIT ${pageSize} `; + } + if (cursor) { + pagingString += `OFFSET ${cursor}`; + } if (!pageSize && !cursor) { pagingString = 'LIMIT 200'; } - const commonPropertyNames = Object.keys(commonNoteSalesforceProperties); - const allProperties = [...commonPropertyNames, ...custom_properties]; - const fields = allProperties.join(','); + const fields = + custom_properties?.length > 0 + ? custom_properties.join(',') + : 'Id,Title,Body,OwnerId,ParentId,CreatedDate,LastModifiedDate'; - const query = `SELECT ${fields} FROM Note ${pagingString}`; + const query = `SELECT ${fields} FROM Note ${pagingString}`.trim(); const resp = await axios.get( - `${instanceUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query)}`, + `${instanceUrl}/services/data/v56.0/query/?q=${encodeURIComponent( + query, + )}`, { headers: { Authorization: `Bearer ${this.cryptoService.decrypt( @@ -124,7 +131,8 @@ export class SalesforceService implements INoteService { statusCode: 200, }; } catch (error) { + this.logger.log(`Error syncing Salesforce notes: ${error.message}`); throw error; } } -} \ No newline at end of file +} diff --git a/packages/shared/src/connectors/metadata.ts b/packages/shared/src/connectors/metadata.ts index 1d1f97396..58d125d07 100644 --- a/packages/shared/src/connectors/metadata.ts +++ b/packages/shared/src/connectors/metadata.ts @@ -272,7 +272,7 @@ export const CONNECTORS_METADATA: ProvidersConfig = { }, logoPath: 'https://logos-world.net/wp-content/uploads/2020/10/Salesforce-Logo.png', description: 'Sync & Create contacts, deals, companies, notes, engagements, stages, tasks and users', - active: false, + active: true, authStrategy: { strategy: AuthStrategy.oauth2, properties: ['domain']