Skip to content

Commit

Permalink
Merge pull request #34 from panoratech/feat/freshsales-integration-cr…
Browse files Browse the repository at this point in the history
…m-contact

feat: started add-contact integration
  • Loading branch information
naelob authored Nov 1, 2023
2 parents 8f17772 + 04189f1 commit 2e40a75
Show file tree
Hide file tree
Showing 22 changed files with 321 additions and 182 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
run: pnpm install --no-frozen-lockfile
working-directory: packages/api

- name: Set script permissions
run: chmod +x ./scripts/pull-database.sh
working-directory: packages/api

- name: Lint, Build & Test
run: pnpm run ci
working-directory: packages/api
15 changes: 0 additions & 15 deletions packages/api/db_update_prisma.sh

This file was deleted.

7 changes: 4 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "prisma migrate reset --force && npx prisma migrate dev --name init && nest build",
"build": "./scripts/pull-database.sh && nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
Expand All @@ -18,7 +18,7 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"ci": "pnpm run lint && pnpm run build && pnpm run test"
"ci": "pnpm run lint && pnpm run build"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
Expand All @@ -29,7 +29,8 @@
"@prisma/client": "^5.4.2",
"axios": "^1.5.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"uuid": "^9.0.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down

This file was deleted.

97 changes: 0 additions & 97 deletions packages/api/prisma/migrations/20231024140507_init/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions packages/api/prisma/migrations/migration_lock.toml

This file was deleted.

93 changes: 60 additions & 33 deletions packages/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,83 @@ datasource db {
url = env("DATABASE_URL")
}

model applications {
id BigInt @id
uuid_project String
model crm_contact_email_addresses {
id_crm_contact_email BigInt @id(map: "pk_crm_contact_email_addresses") @default(autoincrement())
email_address String
email_address_type String
id_crm_contact BigInt
crm_contacts crm_contacts @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_3")
@@index([id_crm_contact], map: "crm_contactid_crm_contact_email_address")
}

model connections {
id BigInt @id
model crm_contacts {
id_crm_contact BigInt @id(map: "pk_crm_contacts") @default(autoincrement())
first_name String
last_name String
id_job BigInt
crm_contact_email_addresses crm_contact_email_addresses[]
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact")
crm_contacts_phone_numbers crm_contacts_phone_numbers[]
@@index([id_job], map: "crm_contact_id_job")
}

model crm_contact_email_addresses {
id_crm_contact_email BigInt @id
uuid_crm_contact_email String @unique(map: "crm_contact_email_addresses_uuid_crm_contact_email_unique")
uuid_crm_contact String
email_address String
email_address_type String
model crm_contacts_phone_numbers {
id_crm_contacts_phone_number BigInt @id(map: "pk_crm_contacts_phone_numbers") @default(autoincrement())
phone_number String
phone_type String
id_crm_contact BigInt
crm_contacts crm_contacts @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_2")
@@index([id_crm_contact], map: "crm_contactid_crm_contact_phone_number")
}

model crm_contacts {
id_crm_contact BigInt @id
uuid_crm_contact String @unique(map: "crm_contacts_uuid_crm_contact_unique")
first_name String
last_name String
model jobs {
id_job BigInt @id(map: "pk_jobs") @default(autoincrement())
status String
timestamp DateTime @db.Timestamp(6)
crm_contacts crm_contacts[]
jobs_status_history jobs_status_history[]
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model crm_contacts_phone_numbers {
id_crm_contacts_phone_number BigInt @id
uuid_crm_contacts_phone_number String @unique(map: "crm_contacts_phone_numbers_uuid_crm_contacts_phone_number_uniqu")
uuid_crm_contact String
phone String
phone_type String
model jobs_status_history {
id BigInt @id(map: "pk_1") @default(autoincrement())
timestamp DateTime @db.Timestamp(6)
previous_status String
new_status String
id_job BigInt
jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "fk_4")
@@index([id_job], map: "id_job_jobs_status_history")
}

model organizations {
id_organization BigInt @id
id_organization BigInt @id(map: "pk_organizations") @default(autoincrement())
name String
stripe_customer_id String
timezone String
projects projects[]
users users[]
}

model projects {
id_project BigInt @id
name String
id_project BigInt @id(map: "pk_projects") @default(autoincrement())
name String
id_organization BigInt
organizations organizations @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_6")
@@index([id_organization], map: "fk_1_projects")
}

model users {
id_user BigInt @id
uuid_user String @unique(map: "users_uuid_user_unique")
email String
password String
first_name String
last_name String
uuid_organization String
id_user BigInt @id(map: "pk_users") @default(autoincrement())
email String
password String
first_name String
last_name String
id_organization BigInt
organizations organizations @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5")
@@index([id_organization], map: "fk_1_users")
}
9 changes: 9 additions & 0 deletions packages/api/scripts/pull-database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SCRIPT TO USE IF YOU WANT TO UPDATE YOUR PRISMA MODEL BASED ON YOUR DB
# it pulls changes from your database to your Prisma schema
# DB => PRISMA MODEL

# Check if there are any new migrations and run them.
npx prisma db pull

# Generate Prisma Client
npx prisma generate
6 changes: 4 additions & 2 deletions packages/api/src/crm/contact/dto/create-contact.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Email, Phone } from '../types';

export class CreateContactDto {
first_name: string;
last_name: string;
email_addresses: string[];
phone_numbers: string[];
email_addresses: Email[];
phone_numbers: Phone[];
}
Loading

0 comments on commit 2e40a75

Please sign in to comment.