diff --git a/packages/api/prisma/schema.prisma b/packages/api/prisma/schema.prisma index a985d5956..579d94ada 100644 --- a/packages/api/prisma/schema.prisma +++ b/packages/api/prisma/schema.prisma @@ -20,75 +20,23 @@ model api_keys { @@index([id_project], map: "fk_api_keys_projects") } -model crm_contacts { - id_crm_contact String @id(map: "pk_crm_contacts") @db.Uuid - first_name String - last_name String - created_at DateTime @db.Timestamp(6) - modified_at DateTime @db.Timestamp(6) - remote_platform String - remote_id String - id_crm_user String? @db.Uuid - id_event String @db.Uuid - crm_addresses crm_addresses[] - crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23") - events events @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact") - crm_email_addresses crm_email_addresses[] - crm_notes crm_notes[] - crm_phone_numbers crm_phone_numbers[] - - @@index([id_event], map: "crm_contact_id_job") - @@index([id_crm_user], map: "fk_crm_contact_userid") -} - /// 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 jobs_status_history { - id_jobs_status_history String @id(map: "pk_jobs_status_history") @db.Uuid - timestamp DateTime @default(now()) @db.Timestamp(6) - previous_status String - new_status String - id_event String @db.Uuid - events events @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_4") - - @@index([id_event], map: "id_job_jobs_status_history") -} - -model organizations { - id_organization String @id(map: "pk_organizations") @db.Uuid - name String - stripe_customer_id String - projects projects[] - users users[] -} - -model projects { - id_project String @id(map: "pk_projects") @db.Uuid - name String - id_organization String @db.Uuid - sync_mode String - pull_frequency BigInt? - api_keys api_keys[] - connections connections[] - linked_users linked_users[] - organizations organizations @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_6") - - @@index([id_organization], map: "fk_1_projects") -} - -/// 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 users { - id_user String @id(map: "pk_users") @db.Uuid - email String - password_hash String - first_name String - last_name String - created_at DateTime @default(now()) @db.Timestamp(6) - modified_at DateTime @default(now()) @db.Timestamp(6) - id_organization String? @db.Uuid - api_keys api_keys[] - organizations organizations? @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5") +model attribute { + id_attribute String @id(map: "pk_attribute") @db.Uuid + status String + ressource_owner_type String + slug String + description String + data_type String + remote_id String + source String + id_entity String? @db.Uuid + scope String + id_consumer String? @db.Uuid + entity entity? @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_32") + value value[] - @@index([id_organization], map: "fk_1_users") + @@index([id_entity], map: "fk_attribute_entityid") } /// 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 @@ -112,32 +60,6 @@ model connections { @@index([id_linked_user], map: "fk_connections_to_linkedusersid") } -/// 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 linked_users { - id_linked_user String @id(map: "key_id_linked_users") @db.Uuid - linked_user_origin_id String - alias String - id_project String @db.Uuid - connections connections[] - events events[] - invite_links invite_links[] - projects projects @relation(fields: [id_project], references: [id_project], onDelete: NoAction, onUpdate: NoAction, map: "fk_10") - - @@index([id_project], map: "fk_proectid_linked_users") -} - -model crm_users { - id_crm_user String @id(map: "pk_crm_users") @db.Uuid - name String? - email String? - created_at DateTime @db.Timestamp(6) - modified_at DateTime @db.Timestamp(6) - crm_companies crm_companies[] - crm_contacts crm_contacts[] - crm_deals crm_deals[] - crm_tasks crm_tasks[] -} - /// 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_addresses { id_crm_address String @id(map: "pk_crm_addresses") @db.Uuid @@ -182,6 +104,27 @@ model crm_companies { @@index([id_event], map: "fk_crm_company_jobid") } +model crm_contacts { + id_crm_contact String @id(map: "pk_crm_contacts") @db.Uuid + first_name String + last_name String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + remote_platform String + remote_id String + id_crm_user String? @db.Uuid + id_event String @db.Uuid + crm_addresses crm_addresses[] + crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23") + events events @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact") + crm_email_addresses crm_email_addresses[] + crm_notes crm_notes[] + crm_phone_numbers crm_phone_numbers[] + + @@index([id_event], map: "crm_contact_id_job") + @@index([id_crm_user], map: "fk_crm_contact_userid") +} + /// 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_deals { id_crm_deal String @id(map: "pk_crm_deal") @db.Uuid @@ -209,6 +152,23 @@ model crm_deals_stages { crm_deals crm_deals[] } +/// 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_email_addresses { + id_crm_email String @id(map: "pk_crm_contact_email_addresses") @db.Uuid + email_address String + email_address_type String + owner_type String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_company String? @db.Uuid + id_crm_contact String? @db.Uuid + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_16") + 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") + @@index([id_crm_company], map: "fk_contact_email_adress_companyid") +} + model crm_engagement_contacts { id_crm_engagement_contact String @id(map: "pk_crm_engagement_contact") @db.Uuid id_crm_contact String? @db.Uuid @@ -267,6 +227,23 @@ model crm_notes { @@index([id_crm_deal], map: "fk_crm_notes_crm_dealid") } +/// 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_phone_numbers { + id_crm_phone_number String @id(map: "pk_crm_contacts_phone_numbers") @db.Uuid + phone_number String + phone_type String + owner_type String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_company String? @db.Uuid + id_crm_contact String? @db.Uuid + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_17") + crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_phonenumber_crm_contactid") + + @@index([id_crm_contact], map: "crm_contactid_crm_contact_phone_number") + @@index([id_crm_company], map: "fk_phone_number_companyid") +} + model crm_tasks { id_crm_task String @id(map: "pk_crm_task") @db.Uuid subject String? @@ -288,23 +265,16 @@ model crm_tasks { @@index([id_crm_deal], map: "fk_crmtask_dealid") } -/// 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 attribute { - id_attribute String @id(map: "pk_attribute") @db.Uuid - status String - ressource_owner_type String - slug String - description String - data_type String - remote_id String - source String - id_entity String? @db.Uuid - scope String - id_consumer String? @db.Uuid - entity entity? @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_32") - value value[] - - @@index([id_entity], map: "fk_attribute_entityid") +model crm_users { + id_crm_user String @id(map: "pk_crm_users") @db.Uuid + name String? + email String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + crm_companies crm_companies[] + crm_contacts crm_contacts[] + crm_deals crm_deals[] + crm_tasks crm_tasks[] } /// 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 @@ -315,63 +285,6 @@ model entity { value value[] } -/// 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 value { - id_value String @id(map: "pk_value") @db.Uuid - data String - id_entity String @db.Uuid - id_attribute String @db.Uuid - attribute attribute @relation(fields: [id_attribute], references: [id_attribute], onDelete: NoAction, onUpdate: NoAction, map: "fk_33") - entity entity @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_34") - - @@index([id_attribute], map: "fk_value_attributeid") - @@index([id_entity], map: "fk_value_entityid") -} - -/// 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_phone_numbers { - id_crm_phone_number String @id(map: "pk_crm_contacts_phone_numbers") @db.Uuid - phone_number String - phone_type String - owner_type String - created_at DateTime @db.Timestamp(6) - modified_at DateTime @db.Timestamp(6) - id_crm_company String? @db.Uuid - id_crm_contact String? @db.Uuid - crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_17") - crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_phonenumber_crm_contactid") - - @@index([id_crm_contact], map: "crm_contactid_crm_contact_phone_number") - @@index([id_crm_company], map: "fk_phone_number_companyid") -} - -/// 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_email_addresses { - id_crm_email String @id(map: "pk_crm_contact_email_addresses") @db.Uuid - email_address String - email_address_type String - owner_type String - created_at DateTime @db.Timestamp(6) - modified_at DateTime @db.Timestamp(6) - id_crm_company String? @db.Uuid - id_crm_contact String? @db.Uuid - crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_16") - 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") - @@index([id_crm_company], map: "fk_contact_email_adress_companyid") -} - -model invite_links { - id_invite_link String @id(map: "pk_invite_links") @db.Uuid - status String - email String? - id_linked_user String @db.Uuid - linked_users linked_users @relation(fields: [id_linked_user], references: [id_linked_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_37") - - @@index([id_linked_user], map: "fk_invite_link_linkeduserid") -} - /// 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 events { id_event String @id(map: "pk_jobs") @db.Uuid @@ -387,68 +300,81 @@ model events { crm_contacts crm_contacts[] linked_users linked_users @relation(fields: [id_linked_user], references: [id_linked_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_12") jobs_status_history jobs_status_history[] + tcg_comments tcg_comments[] + tcg_contacts tcg_contacts[] + tcg_tickets tcg_tickets[] + tcg_users tcg_users[] webhook_delivery_attempts webhook_delivery_attempts[] @@index([id_linked_user], map: "fk_linkeduserid_projectid") } +model invite_links { + id_invite_link String @id(map: "pk_invite_links") @db.Uuid + status String + email String? + id_linked_user String @db.Uuid + linked_users linked_users @relation(fields: [id_linked_user], references: [id_linked_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_37") + + @@index([id_linked_user], map: "fk_invite_link_linkeduserid") +} + /// 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 remote_data { - id_remote_data String @id(map: "pk_remote_data") @db.Uuid - ressource_owner_id String? @unique(map: "force_unique_ressourceownerid") @db.Uuid - format String? - data String? - created_at DateTime? @db.Timestamp(6) +model jobs_status_history { + id_jobs_status_history String @id(map: "pk_jobs_status_history") @db.Uuid + timestamp DateTime @default(now()) @db.Timestamp(6) + previous_status String + new_status String + id_event String @db.Uuid + events events @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_4") + + @@index([id_event], map: "id_job_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 webhook_endpoints { - id_webhook_endpoint String @id(map: "pk_webhook_endpoint") @db.Uuid - endpoint_description String? - url String - secret String - active Boolean - created_at DateTime @db.Timestamp(6) - scope String? - id_project String @db.Uuid - last_update DateTime? @db.Timestamp(6) - webhook_delivery_attempts webhook_delivery_attempts[] +model linked_users { + id_linked_user String @id(map: "key_id_linked_users") @db.Uuid + linked_user_origin_id String + alias String + id_project String @db.Uuid + connections connections[] + events events[] + invite_links invite_links[] + projects projects @relation(fields: [id_project], references: [id_project], onDelete: NoAction, onUpdate: NoAction, map: "fk_10") + + @@index([id_project], map: "fk_proectid_linked_users") } -model webhooks_payloads { - id_webhooks_payload String @id(map: "pk_webhooks_payload") @db.Uuid - data Json @db.Json - webhook_delivery_attempts webhook_delivery_attempts[] +model organizations { + id_organization String @id(map: "pk_organizations") @db.Uuid + name String + stripe_customer_id String + projects projects[] + users users[] } /// 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 webhook_delivery_attempts { - id_webhook_delivery_attempt String @id(map: "pk_webhook_event") @db.Uuid - timestamp DateTime @db.Timestamp(6) - status String - next_retry DateTime? @db.Timestamp(6) - attempt_count BigInt - id_webhooks_payload String? @db.Uuid - id_webhook_endpoint String? @db.Uuid - id_event String? @db.Uuid - id_webhooks_reponse String? @db.Uuid - webhooks_payloads webhooks_payloads? @relation(fields: [id_webhooks_payload], references: [id_webhooks_payload], onDelete: NoAction, onUpdate: NoAction, map: "fk_38_1") - webhook_endpoints webhook_endpoints? @relation(fields: [id_webhook_endpoint], references: [id_webhook_endpoint], onDelete: NoAction, onUpdate: NoAction, map: "fk_38_2") - events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_39") - webhooks_reponses webhooks_reponses? @relation(fields: [id_webhooks_reponse], references: [id_webhooks_reponse], onDelete: NoAction, onUpdate: NoAction, map: "fk_40") +model projects { + id_project String @id(map: "pk_projects") @db.Uuid + name String + id_organization String @db.Uuid + sync_mode String + pull_frequency BigInt? + api_keys api_keys[] + connections connections[] + linked_users linked_users[] + organizations organizations @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_6") - @@index([id_webhooks_payload], map: "fk_we_payload_webhookid") - @@index([id_webhook_endpoint], map: "fk_we_webhookendpointid") - @@index([id_event], map: "fk_webhook_delivery_attempt_eventid") - @@index([id_webhooks_reponse], map: "fk_webhook_delivery_attempt_webhook_responseid") + @@index([id_organization], map: "fk_1_projects") } /// 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 webhooks_reponses { - id_webhooks_reponse String @id(map: "pk_webhooks_reponse") @db.Uuid - http_response_data String - http_status_code String - webhook_delivery_attempts webhook_delivery_attempts[] +model remote_data { + id_remote_data String @id(map: "pk_remote_data") @db.Uuid + ressource_owner_id String? @unique(map: "force_unique_ressourceownerid") @db.Uuid + format String? + data String? + created_at DateTime? @db.Timestamp(6) } /// 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 @@ -465,13 +391,16 @@ model tcg_comments { id_tcg_ticket String? @db.Uuid id_tcg_contact String? @db.Uuid id_tcg_user String? @db.Uuid + id_event String? @db.Uuid tcg_tickets tcg_tickets? @relation(fields: [id_tcg_ticket], references: [id_tcg_ticket], onDelete: NoAction, onUpdate: NoAction, map: "fk_40_1") tcg_contacts tcg_contacts? @relation(fields: [id_tcg_contact], references: [id_tcg_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_41") tcg_users tcg_users? @relation(fields: [id_tcg_user], references: [id_tcg_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_42") + events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_46") @@index([id_tcg_contact], map: "fk_tcg_comment_tcg_contact") @@index([id_tcg_ticket], map: "fk_tcg_comment_tcg_ticket") @@index([id_tcg_user], map: "fk_tcg_comment_tcg_userid") + @@index([id_event], map: "fk_tcg_comments_eventid") } model tcg_contacts { @@ -484,7 +413,11 @@ model tcg_contacts { modified_at DateTime? @db.Timestamp(6) remote_id String? remote_platform String? + id_event String? @db.Uuid tcg_comments tcg_comments[] + events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_43") + + @@index([id_event], map: "fk_tcg_contact_event_id") } /// 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 @@ -504,7 +437,11 @@ model tcg_tickets { assigned_to String[] remote_id String? remote_platform String? + id_event String? @db.Uuid tcg_comments tcg_comments[] + events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_44") + + @@index([id_event], map: "fk_tcg_tickets_eventid") } /// 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 @@ -516,5 +453,88 @@ model tcg_users { modified_at DateTime? @db.Timestamp(6) remote_id String? remote_platform String? + id_event String? @db.Uuid tcg_comments tcg_comments[] + events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_45") + + @@index([id_event], map: "fk_tcg_users_event_id") +} + +/// 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 users { + id_user String @id(map: "pk_users") @db.Uuid + email String + password_hash String + first_name String + last_name String + created_at DateTime @default(now()) @db.Timestamp(6) + modified_at DateTime @default(now()) @db.Timestamp(6) + id_organization String? @db.Uuid + api_keys api_keys[] + organizations organizations? @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5") + + @@index([id_organization], map: "fk_1_users") +} + +/// 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 value { + id_value String @id(map: "pk_value") @db.Uuid + data String + id_entity String @db.Uuid + id_attribute String @db.Uuid + attribute attribute @relation(fields: [id_attribute], references: [id_attribute], onDelete: NoAction, onUpdate: NoAction, map: "fk_33") + entity entity @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_34") + + @@index([id_attribute], map: "fk_value_attributeid") + @@index([id_entity], map: "fk_value_entityid") +} + +/// 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 webhook_delivery_attempts { + id_webhook_delivery_attempt String @id(map: "pk_webhook_event") @db.Uuid + timestamp DateTime @db.Timestamp(6) + status String + next_retry DateTime? @db.Timestamp(6) + attempt_count BigInt + id_webhooks_payload String? @db.Uuid + id_webhook_endpoint String? @db.Uuid + id_event String? @db.Uuid + id_webhooks_reponse String? @db.Uuid + webhooks_payloads webhooks_payloads? @relation(fields: [id_webhooks_payload], references: [id_webhooks_payload], onDelete: NoAction, onUpdate: NoAction, map: "fk_38_1") + webhook_endpoints webhook_endpoints? @relation(fields: [id_webhook_endpoint], references: [id_webhook_endpoint], onDelete: NoAction, onUpdate: NoAction, map: "fk_38_2") + events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_39") + webhooks_reponses webhooks_reponses? @relation(fields: [id_webhooks_reponse], references: [id_webhooks_reponse], onDelete: NoAction, onUpdate: NoAction, map: "fk_40") + + @@index([id_webhooks_payload], map: "fk_we_payload_webhookid") + @@index([id_webhook_endpoint], map: "fk_we_webhookendpointid") + @@index([id_event], map: "fk_webhook_delivery_attempt_eventid") + @@index([id_webhooks_reponse], map: "fk_webhook_delivery_attempt_webhook_responseid") +} + +/// 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 webhook_endpoints { + id_webhook_endpoint String @id(map: "pk_webhook_endpoint") @db.Uuid + endpoint_description String? + url String + secret String + active Boolean + created_at DateTime @db.Timestamp(6) + scope String? + id_project String @db.Uuid + last_update DateTime? @db.Timestamp(6) + webhook_delivery_attempts webhook_delivery_attempts[] +} + +model webhooks_payloads { + id_webhooks_payload String @id(map: "pk_webhooks_payload") @db.Uuid + data Json @db.Json + webhook_delivery_attempts webhook_delivery_attempts[] +} + +/// 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 webhooks_reponses { + id_webhooks_reponse String @id(map: "pk_webhooks_reponse") @db.Uuid + http_response_data String + http_status_code String + webhook_delivery_attempts webhook_delivery_attempts[] } diff --git a/packages/api/scripts/commonObject.sh b/packages/api/scripts/commonObject.sh new file mode 100755 index 000000000..618bd1466 --- /dev/null +++ b/packages/api/scripts/commonObject.sh @@ -0,0 +1,170 @@ +# Check if object type and Ticketing replacement are provided +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +objectType=$1 +verticalObject=$2 + +capitalize() { + echo "$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}" +} + +ObjectCap=$(capitalize $objectType) +VerticalCap=$(capitalize $verticalObject) +VerticalLow=$(tr '[:upper:]' '[:lower:]' <<< ${verticalObject:0:1})${verticalObject:1} + +baseDir="./$objectType" +directories=("services" "sync" "types" "utils") + +# Create base directory and subdirectories +mkdir -p $baseDir +for dir in "${directories[@]}"; do + mkdir -p "$baseDir/$dir" +done + +# Change to base directory +cd $baseDir + +# Create and fill files +cat > "services/${objectType}.service.ts" < "sync/sync.service.ts" < "types/index.ts" <>; + + sync${ObjectCap}s( + linkedUserId: string, + custom_properties?: string[], + ): Promise>; +} + +export interface I${ObjectCap}Mapper { + desunify( + source: Unified${ObjectCap}Input, + customFieldMappings?: { + slug: string; + remote_id: string; + }[], + ): DesunifyReturnType; + + unify( + source: Original${ObjectCap}Output | Original${ObjectCap}Output[], + customFieldMappings?: { + slug: string; + remote_id: string; + }[], + ): Unified${ObjectCap}Output | Unified${ObjectCap}Output[]; +} + +export class ${ObjectCap}Response { + @ApiProperty({ type: [Unified${ObjectCap}Output] }) + ${objectType}s: Unified${ObjectCap}Output[]; + + @ApiPropertyOptional({ type: [{}] }) + remote_data?: Record[]; // Data in original format +} +EOF + +cat > "types/mappingsTypes.ts" < "types/model.unified.ts" < "utils/index.ts" <