Skip to content

Commit

Permalink
🐛 Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Apr 17, 2024
1 parent c9b996a commit eb8ec3a
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 83 deletions.
45 changes: 23 additions & 22 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions apps/client-ts/.env.example

This file was deleted.

1 change: 0 additions & 1 deletion apps/magic-link/.env.example

This file was deleted.

48 changes: 0 additions & 48 deletions packages/api/.env.example

This file was deleted.

102 changes: 102 additions & 0 deletions packages/api/scripts/connectorUpdate.sh
Original file line number Diff line number Diff line change
@@ -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 <vertical> <objectType>"
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."

0 comments on commit eb8ec3a

Please sign in to comment.