From eb8ec3a91ac48d364c533d23d7ab2960daad3b79 Mon Sep 17 00:00:00 2001 From: nael Date: Wed, 17 Apr 2024 21:17:23 +0200 Subject: [PATCH] :bug: Fixes --- .env.example | 45 ++++++----- apps/client-ts/.env.example | 12 --- apps/magic-link/.env.example | 1 - packages/api/.env.example | 48 ----------- packages/api/scripts/connectorUpdate.sh | 102 ++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 83 deletions(-) delete mode 100644 apps/client-ts/.env.example delete mode 100644 apps/magic-link/.env.example delete mode 100644 packages/api/.env.example create mode 100644 packages/api/scripts/connectorUpdate.sh diff --git a/.env.example b/.env.example index 06902e310..8c906bb4c 100644 --- a/.env.example +++ b/.env.example @@ -22,42 +22,43 @@ POSTGRES_USER=my_user POSTGRES_DB=panora_db POSTGRES_HOST=postgres +# Each Provider is of form PROVIDER_TICKETING_SOFTWAREMODE_ATTRIBUTE # ================================================ # Integration Providers # ================================================ # CRM # Hubspot -HUBSPOT_CRM_CLIENT_ID= -HUBSPOT_CRM_CLIENT_SECRET= +HUBSPOT_CRM_CLOUD_CLIENT_ID= +HUBSPOT_CRM_CLOUD_CLIENT_SECRET= # Zoho -ZOHO_CRM_CLIENT_ID= -ZOHO_CRM_CLIENT_SECRET= +ZOHO_CRM_CLOUD_CLIENT_ID= +ZOHO_CRM_CLOUD_CLIENT_SECRET= # Pipedrive -PIPEDRIVE_CRM_CLIENT_ID= -PIPEDRIVE_CRM_CLIENT_SECRET= +PIPEDRIVE_CRM_CLOUD_CLIENT_ID= +PIPEDRIVE_CRM_CLOUD_CLIENT_SECRET= # Zendesk -ZENDESK_CRM_CLIENT_ID= -ZENDESK_CRM_CLIENT_SECRET= +ZENDESK_CRM_CLOUD_CLIENT_ID= +ZENDESK_CRM_CLOUD_CLIENT_SECRET= # Freshsales -FRESHSALES_CRM_CLIENT_ID= -FRESHSALES_CRM_CLIENT_SECRET= +FRESHSALES_CRM_CLOUD_CLIENT_ID= +FRESHSALES_CRM_CLOUD_CLIENT_SECRET= # Attio -ATTIO_CRM_CLIENT_ID= -ATTIO_CRM_CLIENT_SECRET= +ATTIO_CRM_CLOUD_CLIENT_ID= +ATTIO_CRM_CLOUD_CLIENT_SECRET= # ================================================ # Ticketing # ================================================ # Zendesk -ZENDESK_TICKETING_CLIENT_ID= -ZENDESK_TICKETING_CLIENT_SECRET= -ZENDESK_TICKETING_SUBDOMAIN= -JIRA_TICKETING_CLIENT_ID= -JIRA_TICKETING_CLIENT_SECRET= -GORGIAS_TICKETING_CLIENT_ID= -GORGIAS_TICKETING_CLIENT_SECRET= -GORGIAS_TICKETING_SUBDOMAIN= -FRONT_TICKETING_CLIENT_ID= -FRONT_TICKETING_CLIENT_SECRET= +ZENDESK_TICKETING_CLOUD_CLIENT_ID= +ZENDESK_TICKETING_CLOUD_CLIENT_SECRET= +ZENDESK_TICKETING_CLOUD_SUBDOMAIN= +JIRA_TICKETING_CLOUD_CLIENT_ID= +JIRA_TICKETING_CLOUD_CLIENT_SECRET= +GORGIAS_TICKETING_CLOUD_CLIENT_ID= +GORGIAS_TICKETING_CLOUD_CLIENT_SECRET= +GORGIAS_TICKETING_CLOUD_SUBDOMAIN= +FRONT_TICKETING_CLOUD_CLIENT_ID= +FRONT_TICKETING_CLOUD_CLIENT_SECRET= # ================================================ # Webapp settings diff --git a/apps/client-ts/.env.example b/apps/client-ts/.env.example deleted file mode 100644 index e251c141f..000000000 --- a/apps/client-ts/.env.example +++ /dev/null @@ -1,12 +0,0 @@ -NEXT_PUBLIC_BACKEND_DOMAIN=http://localhost:3000 #https://api-dev.panora.dev/ -NEXT_PUBLIC_MAGIC_LINK_DOMAIN=http://127.0.0.1:5173 -NEXT_PUBLIC_POSTHOG_KEY= -NEXT_PUBLIC_POSTHOG_HOST= -NEXT_PUBLIC_DISTRIBUTION="managed" #managed or self-host - -NEXT_PUBLIC_STYTCH_PROJECT_ID="" -NEXT_PUBLIC_STYTCH_SECRET="" -NEXT_PUBLIC_STYTCH_PROJECT_ENV="test" -NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN="" - -NEXT_PUBLIC_WEBAPP_DOMAIN="http://localhost:8090" \ No newline at end of file diff --git a/apps/magic-link/.env.example b/apps/magic-link/.env.example deleted file mode 100644 index 0efbe469b..000000000 --- a/apps/magic-link/.env.example +++ /dev/null @@ -1 +0,0 @@ -VITE_BACKEND_DOMAIN=http://localhost:3000 diff --git a/packages/api/.env.example b/packages/api/.env.example deleted file mode 100644 index fe051b6f0..000000000 --- a/packages/api/.env.example +++ /dev/null @@ -1,48 +0,0 @@ -ENV=dev -DISTRIBUTION=managed # could be "self-host" if you want to run it locally -DATABASE_URL= -JWT_SECRET="SECRET" - -# Sentry for logging errors -SENTRY_DSN=your_sentry_dsn_here - -# INTEGRATIONS PROVIDER CREDENTIALS FOR PANORA -# CRM -HUBSPOT_CLIENT_ID= -HUBSPOT_CLIENT_SECRET= -ZOHOCRM_CLIENT_ID= -ZOHOCRM_CLIENT_SECRET= -PIPEDRIVE_CLIENT_ID= -PIPEDRIVE_CLIENT_SECRET= -FRESHSALES_CLIENT_ID= -FRESHSALES_CLIENT_SECRET= -ZENDESK_SELL_CLIENT_ID= -ZENDESK_SELL_CLIENT_SECRET= -ATTIO_CLIENT_ID= -ATTIO_CLIENT_SECRET= - -# TICKETING -ZENDESK_TICKETING_CLIENT_ID= -ZENDESK_TICKETING_CLIENT_SECRET= -FRONT_CLIENT_ID= -FRONT_CLIENT_SECRET= -GORGIAS_CLIENT_ID= -GORGIAS_CLIENT_SECRET= -JIRA_CLIENT_ID= -JIRA_CLIENT_SECRET= -JIRA_SERVICE_MGMT_CLIENT_ID= -JIRA_SERVICE_MGMT_CLIENT_SECRET= -LINEAR_CLIENT_ID= -LINEAR_CLIENT_SECRET= -GITLAB_CLIENT_ID= -GITLAB_CLIENT_SECRET= -CLICKUP_CLIENT_ID= -CLICKUP_CLIENT_SECRET= - -OAUTH_REDIRECT_BASE='https://api-staging.panora.dev/' - -ENCRYPT_CRYPTO_SECRET_KEY= # key for encrypting tokens ! NEVER SHARE -REDIS_HOST= - -THROTTLER_TTL= -THROTTLER_LIMIT= \ No newline at end of file diff --git a/packages/api/scripts/connectorUpdate.sh b/packages/api/scripts/connectorUpdate.sh new file mode 100644 index 000000000..86b3db66b --- /dev/null +++ b/packages/api/scripts/connectorUpdate.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +# Make the script executable +# chmod +x connectorUpdate.sh + +# Run the script with (vertical) and (provider) +# ./connectorUpdate.sh crm contact + +# Calculate the directory where the script resides +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BASE_DIR="$(cd "$SCRIPT_DIR" && cd ../../.. && pwd)" # Adjust the path as necessary based on your directory structure + +# Function to scan directories for new services +scanDirectory() { + local dir=$1 + find "$dir" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; +} + +# Function to replace relative paths +replaceRelativePaths() { + local path=$1 + echo "${path//..\/src\//@}" +} + +# Function to generate import statements for new services +generateImportStatements() { + local basePath=$1 + local objectType=$2 + local serviceNames=("$@") + shift 2 + local importStatements=() + for serviceName in "${serviceNames[@]}"; do + local importPath="${basePath}/${serviceName}/types" + local replacedPath=$(replaceRelativePaths "$importPath") + local name="$(tr '[:lower:]' '[:upper:]' <<< "${serviceName:0:1}")${serviceName:1}$objectType" + importStatements+=("import { ${name}Input, ${name}Output } from '${replacedPath}';") + done + printf "%s\n" "${importStatements[@]}" +} + +# Function to append import statements and update type definitions +updateTargetFile() { + local file=$1 + local imports=$2 + local serviceNames=("$@") + shift 2 + + # Append import statements to the file + printf "%s\n\n" "$imports" >> "$file" + + # Update type definitions + for serviceName in "${serviceNames[@]}"; do + local typeName="$(tr '[:lower:]' '[:upper:]' <<< "${serviceName:0:1}")${serviceName:1}$OBJECT_TYPE" + sed -i "/export type Original${OBJECT_TYPE}Input =/a \ | ${typeName}Input" "$file" + sed -i "/export type Original${OBJECT_TYPE}Output =/a \ | ${typeName}Output" "$file" + done +} + +# Function to update mappings and module files +updateMappingsAndModules() { + local vertical=$1 + local objectType=$2 + local serviceDirs=("$@") + shift 2 + local mappingsPath="${MAPPINGS_FILE}/${vertical}/${objectType}/types/mappingsTypes.ts" + local modulePath="${BASE_DIR}/src/${vertical}/${objectType}/${objectType}.module.ts" + + # Update module and mapping files + for service in "${serviceDirs[@]}"; do + local serviceClass="${service^}Service" + if ! grep -q "$serviceClass" "$modulePath"; then + echo "import { $serviceClass } from './services/${service}';" >> "$modulePath" + fi + done +} + +# Main execution block +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +VERTICAL=$1 +OBJECT_TYPE=$2 + +# Define paths based on input +TARGET_FILE="${BASE_DIR}/src/@core/utils/types/original/original${VERTICAL}.ts" +SERVICES_DIR="${BASE_DIR}/src/${VERTICAL}/${OBJECT_TYPE}/services" + +# Scan for new services +newServices=($(scanDirectory "$SERVICES_DIR")) + +# Generate import statements +imports=$(generateImportStatements "$SERVICES_DIR" "$OBJECT_TYPE" "${newServices[@]}") + +# Update the target file +updateTargetFile "$TARGET_FILE" "$imports" "${newServices[@]}" + +# Update mappings and module files +updateMappingsAndModules "$VERTICAL" "$OBJECT_TYPE" "${newServices[@]}" + +echo "Update process completed for $VERTICAL $OBJECT_TYPE."