diff --git a/docs/open-source/contributors.mdx b/docs/open-source/contributors.mdx index 4766d8826..560a2f624 100644 --- a/docs/open-source/contributors.mdx +++ b/docs/open-source/contributors.mdx @@ -25,10 +25,10 @@ We made a docker file that builds Panora from sources, specifically to help you You have the option to manage a custom 3rd party OAuth App. - **Each custom 3rd party environment variable must be of the form `PROVIDER_VERTICAL_SOFTWAREMODE_ATTRIBUTE` where** + **Each custom 3rd party environment variable must be of the form `PROVIDER_category_SOFTWAREMODE_ATTRIBUTE` where** - `PROVIDER` is any 3rd party name - - `VERTICAL` is for example [CRM, TICKETING, MARKETINGAUTOMATION, ...] + - `category` is for example [CRM, TICKETING, MARKETINGAUTOMATION, ...] - `SOFTWAREMODE` is [ CLOUD, ONPREMISE ] - `ATTRIBUTE` is for example [ CLIENT_ID, CLIENT_SECRET, SUBDOMAIN, ... ] @@ -64,7 +64,7 @@ Make sure you are inside `packages/api/src` where the server lives ! _Ie: Slack, Hubspot, Jira, Shopify ..._ -First choose wisely which vertical the 3rd party belongs to among these: +First choose wisely which category the 3rd party belongs to among these: - `crm` - `ticketing` @@ -74,14 +74,16 @@ First choose wisely which vertical the 3rd party belongs to among these: - `hris` - `marketingautomation` +You can find all categories inside [`packages/shared/src/categories.ts`](https://github.com/panoratech/Panora/blob/main/packages/shared/src/categories.ts). + For the sake of the guide, now on we'll consider adding a 3rd party belonging - to the `crm` vertical. + to the `crm` category. # Step 1: Ensure 3rd party metadata is set -Look into the `packages/shared/src/utils.ts` file and check if the provider you want to build has its metadata set inside the `CONNECTORS_METADATA` object. +Look into the `packages/shared/src/connectors/metadata.ts` file and check if the provider you want to build has its metadata set inside the `CONNECTORS_METADATA` object. It should be available (if not [contact us](https://app.cal.com/rflih/30)) with `active` field set to `false` meaning the integration has not been built. @@ -96,7 +98,7 @@ Actually an integration is built in 2 parts : _Ie: Contact, Ticket, Deal, Company ..._ -For the sake of this guide, let's map the common object `contact` under `crm` vertical to _my3rdParty_ (in reality it would be a real 3rd party name). +For the sake of this guide, let's map the common object `contact` under `crm` category to _my3rdParty_ (in reality it would be a real 3rd party name). **An integration is considered valid when all common objects have been mapped. @@ -229,7 +231,7 @@ For the sake of this guide, let's map the common object `contact` under `crm` ve We built a script that does it in seconds. You can execute the given command from the root directory of Panora. ```bash - cd packages/api && pnpm install && pnpm run validate-connectors --vertical="crm" --objectType="contact" + cd packages/api && pnpm install && pnpm run validate-connectors --category="crm" --objectType="contact" ``` The script will automatically scan the `/crm/contact/services` folder and detect any new service folder so all dependencies and imports are updated across the codebase. diff --git a/packages/api/src/@core/connections-strategies/connections-strategies.service.ts b/packages/api/src/@core/connections-strategies/connections-strategies.service.ts index c31ab961b..a31451f1d 100644 --- a/packages/api/src/@core/connections-strategies/connections-strategies.service.ts +++ b/packages/api/src/@core/connections-strategies/connections-strategies.service.ts @@ -30,7 +30,7 @@ export class ConnectionsStrategiesService { private prisma: PrismaService, private crypto: EncryptionService, private configService: ConfigService, - ) { } + ) {} async isCustomCredentials(projectId: string, type: string) { const res = await this.prisma.connection_strategies.findFirst({ @@ -230,8 +230,9 @@ export class ConnectionsStrategiesService { data = { ...data, SCOPE: - CONNECTORS_METADATA[vertical.toLowerCase()][provider.toLowerCase()] - .scopes, + CONNECTORS_METADATA[vertical.toLowerCase()][ + provider.toLowerCase() + ].scopes, }; } /*const isSubdomain = needsSubdomain( @@ -337,7 +338,7 @@ export class ConnectionsStrategiesService { values: string[], ) { try { - console.log("In updateAPI xzx") + console.log('In updateAPI xzx'); const cs = await this.prisma.connection_strategies.findFirst({ where: { id_connection_strategy: id_cs, @@ -382,8 +383,8 @@ export class ConnectionsStrategiesService { } return cs; } catch (error) { - console.log("Error xzx") - console.log(error) + console.log('Error xzx'); + console.log(error); throw new Error('Update Failed'); } } diff --git a/packages/api/src/@core/projects/projects.service.ts b/packages/api/src/@core/projects/projects.service.ts index 86900fe23..a8ec87667 100644 --- a/packages/api/src/@core/projects/projects.service.ts +++ b/packages/api/src/@core/projects/projects.service.ts @@ -4,6 +4,12 @@ import { LoggerService } from '../logger/logger.service'; import { CreateProjectDto } from './dto/create-project.dto'; import { v4 as uuidv4 } from 'uuid'; import { handleServiceError } from '@@core/utils/errors'; +import { + ConnectorCategory, + CONNECTORS_METADATA, + providersArray, + slugFromCategory, +} from '@panora/shared'; @Injectable() export class ProjectsService { @@ -43,6 +49,27 @@ export class ProjectsService { //id_organization: id_organization, }, }); + + const ACTIVE_CONNECTORS = providersArray(); + // update project-connectors table for the project + const updateData: any = { + id_project_connector: uuidv4(), + id_project: res.id_project, + }; + + ACTIVE_CONNECTORS.forEach((connector) => { + if (connector.vertical) { + // Construct the property name using the vertical name + const propertyName = `${slugFromCategory( + connector.vertical as ConnectorCategory, + )}_`; + // Add the property to updateData with a value of true + updateData[propertyName + connector.name] = true; + } + }); + await this.prisma.project_connectors.create({ + data: updateData, + }); return res; } catch (error) { handleServiceError(error, this.logger);