Commit Graph

781 Commits

Author SHA1 Message Date
Marie
a4e82d643a
Support custom composite field deletion (#6320)
as per title
Fixes #6033 and closes #4841
2024-07-18 15:28:32 +02:00
martmull
47ddc7be83
6181 workflows create a custom code executor (#6235)
Closes #6181

## Testing
- download Altair graphql dev tool https://altairgraphql.dev/#download
- create a file locally `test.ts` containing:
```
export const handler = async (event: object, context: object) => {
  return { test: 'toto', data: event['data'] };
}
```
- play those requests in Altair:
mutation UpsertFunction($file: Upload!) {
  upsertFunction(name: "toto", file: $file)
}

mutation ExecFunction {
  executeFunction(name:"toto", payload: {data: "titi"})
}
- it will run the local driver, add those env variable to test with
lambda driver
```
CUSTOM_CODE_ENGINE_DRIVER_TYPE=lambda
LAMBDA_REGION=eu-west-2
LAMBDA_ROLE=<ASK_ME>
```
2024-07-17 17:53:01 +02:00
Marie
1bfc6aeba0
Bump version to v0.22.0 (#6292) 2024-07-16 17:14:35 +02:00
Marie
9711a430de
Fix command for sync stage enum (#6291)
We were missing the default value for syncStage, while it is expected
since indicated in the metadata
2024-07-16 16:50:39 +02:00
Weiko
8eb021531d
Add missing commands to 0.22 (#6286) 2024-07-16 16:14:20 +02:00
bosiraphael
3566e0bdc2
Create command to migrate message channel sync stage enum (#6280)
Create command to migrate message channel sync stage enum
2024-07-16 13:21:40 +02:00
Marie
26bffce23b
[Fix] Remove usage of deprecated FieldMetadata type probability (#6279)
Bad timing between merge of
364caf0fdf
and
c0f6f52669
a few minutes apart caused issues. Fixing it here !
2024-07-16 11:36:10 +02:00
Thomas Trompette
34cbba5fd8
Add interceptors for auto-resolvers (#6270)
Services exceptions are not catch when the endpoint comes from an
auto-resolver.
We want to remove auto-resolver but it requires to implement pagination
by ourselves.

As a quick fix, here are interceptors that will trigger the exception
handler.
I had a hard time making it generic so I finally added one interceptor
for each since this is not supposed to stay
2024-07-16 10:49:18 +02:00
bosiraphael
d216bfdd4e
6254 double creation of contacts when updating calendar event participants (#6269)
Closes #6254
2024-07-16 10:47:18 +02:00
Siddhant Rai
364caf0fdf
fix: remove usage of probability field (#5877)
- fixes #5735

---------

Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
2024-07-16 10:24:35 +02:00
martmull
c0f6f52669
Bug return multi select fields in rest api response (#6253)
Fixes
https://discord.com/channels/1130383047699738754/1258194870703493141/1258194870703493141

## Before

![image](https://github.com/user-attachments/assets/49aaed36-6106-47f7-9d55-a4a2fed138e0)

## After

![image](https://github.com/user-attachments/assets/19343d60-f47e-4ebb-b2d4-3bcc7674e64b)
2024-07-16 10:08:31 +02:00
Marie
aed0bf41ce
Forbid default value nullification for non-nullable field (#6258)
as per title 


https://github.com/user-attachments/assets/ce07d437-eeeb-488c-8dfa-3fc07316f485
2024-07-15 14:22:15 +02:00
gitstart-twenty
12c68fd77f
Improve performance of demo workspace (#6201)
### Description

1. We've created another PR
[here](https://github.com/twentyhq/placeholder-images/pull/1) here that
adds the placeholder images to the `placeholder-images` repo

2. For now,
[pages](https://github.com/twentyhq/placeholder-images/settings/pages)
is deploying to the `TWNTY-3514` on `placeholder-images`. If the PR is
merged, we'll need to update
[pages](https://github.com/twentyhq/placeholder-images/settings/pages)
to deploy from `main`

### Refs

- #3514
- https://github.com/twentyhq/placeholder-images/pull/1

### Demo


https://github.com/twentyhq/twenty/assets/140154534/88fa6cc1-a84d-48d4-9b17-e3a29bd9d1d0

Fixes #3514

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: RubensRafael <rubensrafael2@live.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-12 21:34:39 +02:00
bosiraphael
11da718482
Refactor connected account module (#6225)
- Refactor connected account module
- Move blocklist into it's own module
- Move contact-creation-manager into it's own module

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-12 20:15:33 +02:00
bosiraphael
c8a889995f
Add error handling service for calendar import (#6203)
Add error handling service for calendar import

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-12 18:56:45 +02:00
bosiraphael
52aa9abd73
Remove old message channel sync statuses and create migration command (#6177)
Remove old message channel sync statuses and create migration command

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-12 18:36:42 +02:00
Weiko
1dff5bf957
Fix custom errors thrown as 500 (#6238)
We call convertExceptionToGraphQLError in the exception handler for http
exceptions but we don't take into account those that already are
graphqlErrors and because of that the logic of convertExceptionToGraphql
is to fallback to a 500.
Now if the exception is a BaseGraphqlError (custom graphql error we
throw in the code), we throw them directly.

BEFORE
<img width="957" alt="Screenshot 2024-07-12 at 15 33 03"
src="https://github.com/user-attachments/assets/22ddae13-4996-4ad3-8f86-dd17c2922ca8">


AFTER
<img width="923" alt="Screenshot 2024-07-12 at 15 32 01"
src="https://github.com/user-attachments/assets/d3d6db93-6d28-495c-a4b4-ba4e47d45abd">

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-12 17:56:21 +02:00
Marie
a44249287f
Forbid creation of link field type (#6237)
This is the first step of Link field type deprecation
(https://github.com/twentyhq/twenty/issues/5909).
Forbid creation of link field type in product and api. Update to this
type is not a concern as we do not allow the update of field type.
2024-07-12 15:28:17 +02:00
Marie
ad5d0905cc
Improve add field to view script to handle errors (#6232)
Adding logs and catching errors to continue not to block the script
execution if the command fails for one workspace
2024-07-12 10:22:51 +02:00
bosiraphael
faf462ffe4
Fix address field in raw query (#6226)
The old address field has been deprecated but the raw query in
company.repository hasn't been updated accordingly
2024-07-11 19:48:15 +02:00
Marie
5ad287baf5
Add option to synchronize all active workspaces at once (#6221)
In the longer term, we want to improve the efficiency and reliability of
the sync-metadata command, by choosing an error handling strategy and
paying greater attention to health checks.
In the meantime, this PR adds an option to run the sync-metadata command
on all active workspaces at once.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-11 19:48:07 +02:00
Marie
5ebde33f5f
Deprecate Probability field on Opportunity (#6207)
Closes #5735.
The field probability on opportunity will -
- stop being created for new workspaces (after this PR is merged)
- have "isCustom" value set to true and be displayed as such in the
settings (after this PR is merged + sync-metadata is run on workspace)
- still show in the views (all the time)

This field is deprecated as a standard field but not replaced by another
one, so we are not adding the `(deprecated)` suffix in the label.
2024-07-11 14:50:33 +02:00
Marie
8e25a107fd
Add new Address field to views containing deprecated address (#6205)
as per title, following introduction of new Address field, we want to
display the new field next to the deprecated field, for users to notice
the new field.

<img width="983" alt="Capture d’écran 2024-07-10 à 17 44 25"
src="https://github.com/twentyhq/twenty/assets/51697796/7b5309b4-b22d-4f32-8054-68bc7b0f3bb3">
2024-07-11 14:39:38 +02:00
Félix Malfait
70f46242b4
Fix database reset after address deprecation (#6216)
Fix a small bug introduced in
https://github.com/twentyhq/twenty/pull/6087 preventing database reset
2024-07-11 11:02:42 +02:00
Marie
34d13a7b58
Deprecate address standard field (#6087)
Closes #5916

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-07-10 18:07:18 +02:00
Charles Bochet
b14918c4b5
Remove featureFlag on connectedAccount.handleAliases (#6202)
Removing the gating on connectedAccount handleAlias as the feature has
been tested for a week
2024-07-10 14:49:22 +02:00
Marie
ef5657c353
Update boolean command to update existing null values (#6198)
as per title
2024-07-10 13:09:44 +02:00
Marie
02e5c5ea97
Update boolean field command to skip workspace instead of throwing (#6196)
as per title
2024-07-10 11:56:30 +02:00
bosiraphael
28387003d2
Fix contact creation and rename email aliases to handle aliases (#6176)
Fix contact creation (linked to #6162) and rename email aliases to
handle aliases
2024-07-09 17:49:03 +02:00
Weiko
881613e8a1
Fix wrong standard id for objectMetadataId in auditLog (#6180)
Add a new command to delete objectMetadataId fieldMetadata that have a
wrong standard-id. This is because we have fixed the missing
objectMetadataId column but one already exists in the fieldMetadataId
with the wrong table. We should run this command before run the
sync-metadata.

Introduced a new module and command to run all the command associated
with the upgrade to 0.22. Not exactly sure with this structure but
ideally we would like to have only 1 command for version upgrades so
this is a first step.
2024-07-09 17:48:10 +02:00
martmull
de51e653fc
Authorize 0 depth (#6171)
Authorize depth 0


![image](https://github.com/twentyhq/twenty/assets/29927851/2e82eaba-01b4-440f-8412-d2878007a3b1)

![image](https://github.com/twentyhq/twenty/assets/29927851/f0137671-20dc-4e44-97b8-7a8e4c583493)

## Edit
### Depth = 0
```
{
  "data": {
    "people": [
      {
        "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
        "email": "christoph.calisto@linkedin.com",
        "jobTitle": "",
        "phone": "+33789012345",
        "city": "Seattle",
        "avatarUrl": "",
        "position": 1,
        "createdAt": "2024-07-08T16:08:50.011Z",
        "updatedAt": "2024-07-08T16:08:50.011Z",
        "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
        "name": {
          "firstName": "Christoph",
          "lastName": "Callisto"
        },
        "linkedinLink": {
          "label": "",
          "url": ""
        },
        "xLink": {
          "label": "",
          "url": ""
        }
      },
...
]}
```

### Depth = 1
```
{
  "data": {
    "people": [
      {
        "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
        "email": "christoph.calisto@linkedin.com",
        "jobTitle": "",
        "phone": "+33789012345",
        "city": "Seattle",
        "avatarUrl": "",
        "position": 1,
        "createdAt": "2024-07-08T16:08:50.011Z",
        "updatedAt": "2024-07-08T16:08:50.011Z",
        "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
        "name": {
          "firstName": "Christoph",
          "lastName": "Callisto"
        },
        "linkedinLink": {
          "label": "",
          "url": ""
        },
        "xLink": {
          "label": "",
          "url": ""
        },
        "activityTargets": [],
        "favorites": [],
        "attachments": [],
        "timelineActivities": [],
        "company": {
          "id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
          "name": "Linkedin",
          "domainName": "linkedin.com",
          "address": "",
          "employees": null,
          "idealCustomerProfile": false,
          "position": 1,
          "createdAt": "2024-07-08T16:08:50.011Z",
          "updatedAt": "2024-07-08T16:08:50.011Z",
          "accountOwnerId": null,
          "linkedinLink": {
            "label": "",
            "url": ""
          },
          "xLink": {
            "label": "",
            "url": ""
          },
          "annualRecurringRevenue": {
            "amountMicros": null,
            "currencyCode": ""
          }
        },
        "messageParticipants": [
          {
            "id": "20202020-0f2a-49d8-8aa2-ec8786153a0b",
            "role": "from",
            "handle": "outgoing",
            "displayName": "Christoph",
            "createdAt": "2024-07-08T16:08:50.028Z",
            "updatedAt": "2024-07-08T16:08:50.028Z",
            "messageId": "20202020-2b8a-405d-8f42-e820ca921421",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7"
          },
          {
            "id": "20202020-fc7d-4ad8-9aea-b78bcbf79cdd",
            "role": "from",
            "handle": "outgoing",
            "displayName": "Christoph",
            "createdAt": "2024-07-08T16:08:50.028Z",
            "updatedAt": "2024-07-08T16:08:50.028Z",
            "messageId": "20202020-04c8-4f24-93f2-764948e95014",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7"
          }
        ],
        "calendarEventParticipants": [
          {
            "id": "da8f47c3-8055-49ad-b7e4-9c9d5bbc1ecc",
            "handle": "christoph.calisto@linkedin.com",
            "displayName": "Christoph Calisto",
            "isOrganizer": true,
            "responseStatus": "ACCEPTED",
            "createdAt": "2024-07-08T16:08:50.011Z",
            "updatedAt": "2024-07-08T16:08:50.011Z",
            "calendarEventId": "86083141-1c0e-494c-a1b6-85b1c6fefaa5",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": null
          }
        ],
        "pointOfContactForOpportunities": [
          {
            "id": "20202020-be10-412b-a663-16bd3c2228e1",
            "name": "Opportunity 1",
            "closeDate": "2024-07-08T16:08:50.018Z",
            "probability": "0.5",
            "stage": "NEW",
            "position": 1,
            "createdAt": "2024-07-08T16:08:50.011Z",
            "updatedAt": "2024-07-08T16:08:50.011Z",
            "pointOfContactId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
            "amount": {
              "amountMicros": 100000,
              "currencyCode": "USD"
            }
          }
        ]
      },
...
]}
```
### Depth = 2
```
{
  "data": {
    "people": [
      {
        "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
        "email": "christoph.calisto@linkedin.com",
        "jobTitle": "",
        "phone": "+33789012345",
        "city": "Seattle",
        "avatarUrl": "",
        "position": 1,
        "createdAt": "2024-07-08T16:08:50.011Z",
        "updatedAt": "2024-07-08T16:08:50.011Z",
        "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
        "name": {
          "firstName": "Christoph",
          "lastName": "Callisto"
        },
        "linkedinLink": {
          "label": "",
          "url": ""
        },
        "xLink": {
          "label": "",
          "url": ""
        },
        "activityTargets": [],
        "favorites": [],
        "attachments": [],
        "timelineActivities": [],
        "company": {
          "id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
          "name": "Linkedin",
          "domainName": "linkedin.com",
          "address": "",
          "employees": null,
          "idealCustomerProfile": false,
          "position": 1,
          "createdAt": "2024-07-08T16:08:50.011Z",
          "updatedAt": "2024-07-08T16:08:50.011Z",
          "accountOwnerId": null,
          "accountOwner": null,
          "linkedinLink": {
            "label": "",
            "url": ""
          },
          "xLink": {
            "label": "",
            "url": ""
          },
          "annualRecurringRevenue": {
            "amountMicros": null,
            "currencyCode": ""
          },
          "activityTargets": [],
          "favorites": [],
          "attachments": [],
          "timelineActivities": [],
          "people": [
            {
              "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "email": "christoph.calisto@linkedin.com",
              "jobTitle": "",
              "phone": "+33789012345",
              "city": "Seattle",
              "avatarUrl": "",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Christoph",
                "lastName": "Callisto"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            },
            {
              "id": "20202020-ac73-4797-824e-87a1f5aea9e0",
              "email": "sylvie.palmer@linkedin.com",
              "jobTitle": "",
              "phone": "+33780123456",
              "city": "Los Angeles",
              "avatarUrl": "",
              "position": 2,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Sylvie",
                "lastName": "Palmer"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            }
          ],
          "opportunities": [
            {
              "id": "20202020-be10-412b-a663-16bd3c2228e1",
              "name": "Opportunity 1",
              "closeDate": "2024-07-08T16:08:50.018Z",
              "probability": "0.5",
              "stage": "NEW",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "pointOfContactId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "amount": {
                "amountMicros": 100000,
                "currencyCode": "USD"
              }
            }
          ]
        },
        "pointOfContactForOpportunities": [
          {
            "id": "20202020-be10-412b-a663-16bd3c2228e1",
            "name": "Opportunity 1",
            "closeDate": "2024-07-08T16:08:50.018Z",
            "probability": "0.5",
            "stage": "NEW",
            "position": 1,
            "createdAt": "2024-07-08T16:08:50.011Z",
            "updatedAt": "2024-07-08T16:08:50.011Z",
            "pointOfContactId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
            "amount": {
              "amountMicros": 100000,
              "currencyCode": "USD"
            },
            "favorites": [],
            "activityTargets": [],
            "attachments": [],
            "timelineActivities": [],
            "pointOfContact": {
              "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "email": "christoph.calisto@linkedin.com",
              "jobTitle": "",
              "phone": "+33789012345",
              "city": "Seattle",
              "avatarUrl": "",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Christoph",
                "lastName": "Callisto"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            },
            "company": {
              "id": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": "Linkedin",
              "domainName": "linkedin.com",
              "address": "",
              "employees": null,
              "idealCustomerProfile": false,
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "accountOwnerId": null,
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              },
              "annualRecurringRevenue": {
                "amountMicros": null,
                "currencyCode": ""
              }
            }
          }
        ],
        "messageParticipants": [
          {
            "id": "20202020-0f2a-49d8-8aa2-ec8786153a0b",
            "role": "from",
            "handle": "outgoing",
            "displayName": "Christoph",
            "createdAt": "2024-07-08T16:08:50.028Z",
            "updatedAt": "2024-07-08T16:08:50.028Z",
            "messageId": "20202020-2b8a-405d-8f42-e820ca921421",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
            "message": {
              "id": "20202020-2b8a-405d-8f42-e820ca921421",
              "headerMessageId": "99ef24a8-2b8a-405d-8f42-e820ca921421",
              "direction": "outgoing",
              "subject": "Meeting Request",
              "text": "Hello, \n I hope this email finds you well. I am writing to request a meeting. I believe it would be beneficial for both parties to collaborate and explore potential opportunities. Would you be available for a meeting sometime next week? Please let me know your availability, and I will arrange a suitable time. \n Looking forward to your response.\n Best regards",
              "receivedAt": "2024-07-08T16:08:50.022Z",
              "createdAt": "2024-07-08T16:08:50.022Z",
              "updatedAt": "2024-07-08T16:08:50.022Z",
              "messageThreadId": "20202020-8bfa-453b-b99b-bc435a7d4da8"
            },
            "person": {
              "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "email": "christoph.calisto@linkedin.com",
              "jobTitle": "",
              "phone": "+33789012345",
              "city": "Seattle",
              "avatarUrl": "",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Christoph",
                "lastName": "Callisto"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            },
            "workspaceMember": {
              "id": "20202020-0687-4c41-b707-ed1bfca972a7",
              "colorScheme": "Light",
              "locale": "en",
              "avatarUrl": "",
              "userEmail": "tim@apple.dev",
              "userId": "20202020-9e3b-46d4-a556-88b9ddc2b034",
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "name": {
                "firstName": "Tim",
                "lastName": "Apple"
              }
            }
          },
          {
            "id": "20202020-fc7d-4ad8-9aea-b78bcbf79cdd",
            "role": "from",
            "handle": "outgoing",
            "displayName": "Christoph",
            "createdAt": "2024-07-08T16:08:50.028Z",
            "updatedAt": "2024-07-08T16:08:50.028Z",
            "messageId": "20202020-04c8-4f24-93f2-764948e95014",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": "20202020-0687-4c41-b707-ed1bfca972a7",
            "message": {
              "id": "20202020-04c8-4f24-93f2-764948e95014",
              "headerMessageId": "8f804a9a-04c8-4f24-93f2-764948e95014",
              "direction": "outgoing",
              "subject": "Inquiry Regarding Topic",
              "text": "Good Morning,\n I am writing to inquire about information. Could you please provide me with details regarding this topic? \n Your assistance in this matter would be greatly appreciated. Thank you in advance for your prompt response. \n Best regards,Tim",
              "receivedAt": "2024-07-08T16:08:50.022Z",
              "createdAt": "2024-07-08T16:08:50.022Z",
              "updatedAt": "2024-07-08T16:08:50.022Z",
              "messageThreadId": "20202020-634a-4fde-aa7c-28a0eaf203ca"
            },
            "person": {
              "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "email": "christoph.calisto@linkedin.com",
              "jobTitle": "",
              "phone": "+33789012345",
              "city": "Seattle",
              "avatarUrl": "",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Christoph",
                "lastName": "Callisto"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            },
            "workspaceMember": {
              "id": "20202020-0687-4c41-b707-ed1bfca972a7",
              "colorScheme": "Light",
              "locale": "en",
              "avatarUrl": "",
              "userEmail": "tim@apple.dev",
              "userId": "20202020-9e3b-46d4-a556-88b9ddc2b034",
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "name": {
                "firstName": "Tim",
                "lastName": "Apple"
              }
            }
          }
        ],
        "calendarEventParticipants": [
          {
            "id": "da8f47c3-8055-49ad-b7e4-9c9d5bbc1ecc",
            "handle": "christoph.calisto@linkedin.com",
            "displayName": "Christoph Calisto",
            "isOrganizer": true,
            "responseStatus": "ACCEPTED",
            "createdAt": "2024-07-08T16:08:50.011Z",
            "updatedAt": "2024-07-08T16:08:50.011Z",
            "calendarEventId": "86083141-1c0e-494c-a1b6-85b1c6fefaa5",
            "personId": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
            "workspaceMemberId": null,
            "workspaceMember": null,
            "calendarEvent": {
              "id": "86083141-1c0e-494c-a1b6-85b1c6fefaa5",
              "title": "Meeting with Christoph",
              "isCanceled": false,
              "isFullDay": false,
              "startsAt": "2024-07-08T08:00:50.030Z",
              "endsAt": "2024-07-08T09:00:50.030Z",
              "externalCreatedAt": "2024-07-08T16:08:50.030Z",
              "externalUpdatedAt": "2024-07-08T16:08:50.030Z",
              "description": "Discuss project progress",
              "location": "Seattle",
              "iCalUID": "event1@calendar.com",
              "conferenceSolution": "Zoom",
              "recurringEventExternalId": "recurring1",
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "conferenceLink": {
                "label": "https://zoom.us/j/1234567890",
                "url": "https://zoom.us/j/1234567890"
              }
            },
            "person": {
              "id": "20202020-1c0e-494c-a1b6-85b1c6fefaa5",
              "email": "christoph.calisto@linkedin.com",
              "jobTitle": "",
              "phone": "+33789012345",
              "city": "Seattle",
              "avatarUrl": "",
              "position": 1,
              "createdAt": "2024-07-08T16:08:50.011Z",
              "updatedAt": "2024-07-08T16:08:50.011Z",
              "companyId": "20202020-3ec3-4fe3-8997-b76aa0bfa408",
              "name": {
                "firstName": "Christoph",
                "lastName": "Callisto"
              },
              "linkedinLink": {
                "label": "",
                "url": ""
              },
              "xLink": {
                "label": "",
                "url": ""
              }
            }
          }
        ]
      },
...
]}
```
2024-07-09 14:55:05 +02:00
Weiko
6af1bcd55c
[Flexible Schema] Create indexes for join columns (#6165)
## Context
We want to add an index on our foreign keys since PG does not do it for
us. An index can sometimes be expensive and not always meaningful
depending on different usages but in our case we decided to apply an
index for every foreign keys.

```typescript
  @WorkspaceIndex()
  @WorkspaceJoinColumn('author')
  authorId: string;
```
This syntax is valid but since we want to apply it to every join column
I've decided to update the code of WorkspaceJoinColumn so it properly
registers a new index at the same time which is less error-prone.

Note: We had a bug on index name generation since postgres index names
are unique per schema and not table, the object metadata id (hashed) has
been added to the formula that generates the name of the index

## Test
Sync metadata. We have 45 join columns as of today per workspace, we
should see 45 rows inside IndexMetadata table
2024-07-09 14:51:24 +02:00
bosiraphael
37fb88c533
Modify messaging message channel sync status monitoring cron pattern (#6173)
Change from every hour to every 10 minutes, starting at 2 minutes past
the hour
2024-07-09 14:42:57 +02:00
Weiko
3249c52767
Add missing objectMetadataId column in auditLog (#6164)
Insert inside AuditLog table are all failing due to objectMetadataId
column missing.
The FieldMetadata was sharing the same standard-id with another one
(objectName) so it was skipped during the comparison step of the
sync-metadata.

Running a sync-metadata again should fix this issue. Note that this
column is non-nullable so if the table contains existing records, it
will fail. However, since the insert was failing I'm assuming the table
is empty anyway.
2024-07-09 13:26:09 +02:00
Charles Bochet
7aa903aa53
Update render deploy configuration (#6167) 2024-07-09 00:27:07 +02:00
Charles Bochet
3e453054b7 Fix contactCreation ignoring connectedAccount mainHandle 2024-07-08 18:13:10 +02:00
bosiraphael
5638af4385
Fix wrong email direction (#6163)
Closes #6162
2024-07-08 17:55:49 +02:00
bosiraphael
f458322303
Refactor calendar to use new sync statuses and stages (#6141)
- Refactor calendar modules and some messaging modules to better
organize them by business rules and decouple them
- Work toward a common architecture for the different calendar providers
by introducing interfaces for the drivers
- Modify cron job to use the new sync statuses and stages
2024-07-08 17:01:06 +02:00
Charles Bochet
1c3ea9b106
Bump version to 0.21 (#6161) 2024-07-08 16:57:35 +02:00
Charles Bochet
9ba211055a
Add message import granulary on non-pro emails, group emails and received contact creation (#6156)
1) Remove featureFlag
2) Base contactCreation on messageChannel.autoContactCreationPolicy
4) add excludeProfessionalEmails + excludeGroupEmails logic
2024-07-08 14:33:48 +02:00
Marie
b33b468679
Add command to update boolean fields null values (#6113)
We have recently decided that boolean fields should only accept truthy
or falsy value, with users deciding of a default value at creation.

This command helps cleaning the existing data, by
1. updating all boolean fields default values from null to false
2. updating all boolean fields values for records from null to false

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-07-05 12:27:12 +02:00
Marie
6cd154aac6
Forbid names above 63 characters to comply with pg identifier limit (#6095)
Fixes #6032.

Pg has a char limit on identifiers (= table, columns, enum names) of 63
bytes.
Let's limit the metadata names that will be converted to identifiers
(objects names, fields names, relation names, enum values) to 63 chars.
For the sake of simplicity in the FE we will limit the input length of
labels.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-04 15:32:42 +02:00
Jérémy M
5df0ea6466
fix: message queue injection issue (#6126) 2024-07-04 12:22:58 +02:00
Félix Malfait
5b4d2d989a
Hotfix tests after AI PR (#6124)
I merged https://github.com/twentyhq/twenty/pull/5788 too quickly and
didn't noticed it was broken with
https://github.com/twentyhq/twenty/pull/6069
2024-07-04 10:21:33 +02:00
ad-elias
4c642a0bb8
Text-to-SQL proof of concept (#5788)
Added:
- An "Ask AI" command to the command menu.
- A simple GraphQL resolver that converts the user's question into a
relevant SQL query using an LLM, runs the query, and returns the result.

<img width="428" alt="Screenshot 2024-06-09 at 20 53 09"
src="https://github.com/twentyhq/twenty/assets/171685816/57127f37-d4a6-498d-b253-733ffa0d209f">

No security concerns have been addressed, this is only a
proof-of-concept and not intended to be enabled in production.

All changes are behind a feature flag called `IS_ASK_AI_ENABLED`.

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-07-04 08:57:26 +02:00
Charles Bochet
25fce27fe3 Improve performance/robustness of worker 2024-07-03 22:54:39 +02:00
Charles Bochet
14cd6f8b6b Decrease messaging import batch size 2024-07-03 22:24:21 +02:00
Jérémy M
921b311c65
fix: small PR fixes workspace-sync-fields (#6107)
Small fixes of PR #6069
2024-07-03 19:19:37 +02:00
Charles Bochet
c2da7c4c6e
Fix workspace sync issue (#6121)
Fixing an issue with typeORM not fetching existing metadata collection
while syncing fields and relations
2024-07-03 19:18:57 +02:00
Charles Bochet
4c57e838ca
Fix pg-boss worker not working with dynamic injection (#6119) 2024-07-03 19:17:29 +02:00
Thomas Trompette
4183e5460d
Use return await to catch exceptions (#6109)
So the exceptions are handled properly and filtered in sentry
2024-07-03 11:14:28 +02:00
Jérémy M
5b26452649
feat: refactor workspace sync fields (#6069)
This PR was first here to fix the issue related to ticket #5004, after
some testing it seems that changing the name of a relation is actually
properly working, if we rename `ONE-TO-MANY` side, the only things that
is going to be updated is the FieldMetadata as the `joinColumn` is
stored on the opposite object.
For `MANY-TO-ONE` relations, the `joinColumn` migration is properly
generated. We need to take care that if we rename a side of a relation,
sometimes the opposite side doesn't have `inverseSideFieldKey`
implemented and used by default the name of the opposite object, so this
is going to throw an error as the field can't be found in the object.

---------

Co-authored-by: Marie <51697796+ijreilly@users.noreply.github.com>
2024-07-02 17:21:13 +02:00
bosiraphael
a163ccced6
Fix calendar import cron job (#6096)
An error was introduced in the calendar cron job because we tried to
inject the workspace context inside the calendarChannelRepository where
we didn't have access to that context.
2024-07-02 16:51:10 +02:00
Charles Bochet
f8dd2cc733
Reorganise calendar module (#6089)
Refactor Calendar into functional sub modules
<img width="437" alt="image"
src="https://github.com/twentyhq/twenty/assets/12035771/d9de3285-a226-4fe8-b3ef-2d8a21def2a5">

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
2024-07-02 13:55:11 +02:00
Charles Bochet
88915291d9
Fix Active Workspaces check (#6084)
We have recently deprecated our subscriptionStatus on workspace to
replace it by a check on existing subscription (+ freeAccess
featureFlag) but the logic was not properly implemented
2024-07-01 16:45:56 +02:00
Thomas Trompette
bb627a91e2
Use invalid field input error for invalid object metadata input (#6083)
As title
2024-07-01 16:33:48 +02:00
Charles Bochet
fbbcdb20e5 Fix demo seed script by using usage of deprecated sub status 2024-07-01 15:13:31 +02:00
Charles Bochet
b371c77284 Change Messaging import frequency 2024-07-01 14:22:31 +02:00
bosiraphael
8c33d91734
5748 Create contacts for emails sent and received by email aliases (#5855)
Closes #5748
- Create feature flag
- Add scope `https://www.googleapis.com/auth/profile.emails.read` when
connecting an account
- Get email aliases with google people API, store them in
connectedAccount and refresh them before each message-import
- Update the contact creation logic accordingly
- Refactor

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-01 14:21:34 +02:00
Thomas Trompette
a15884ea0a
Add exceptions for metadata modules (#6070)
Class exception for each metadata module + handler to map on graphql
error

TODO left :
- find a way to call handler on auto-resolvers nestjs query (probably
interceptors)
- discuss what should be done for pre-hooks errors
- discuss what should be done for Unauthorized exception
2024-07-01 13:49:17 +02:00
Jérémy M
632e34fc7b
fix: message cleaner find operator (#6080)
This PR fix an issue with the `IsNull()` find operator applied on
one-to-many relation, this one is not supported by TypeORM.
We can instead filter by an empty array to retrieve object with empty
relations.
2024-07-01 11:23:22 +02:00
Jérémy M
13f213a05e
feat: message cleaner drop repository (#6052)
This PR use the new `TwentyORM` for the message-cleaner module by using
the new injection system with `@InjectWorkspaceRepository`.
2024-06-30 21:57:18 +02:00
brendanlaschke
afb3f4b7b7
Allow s3 credentials via env (#6066)
closes #5072
2024-06-30 21:47:51 +02:00
martmull
cce9bf5730
Improve use set next onboarding state (#6076)
querying workspaceMembers may be slow leads to wrong
setNextOnboardingStatus value. So we added a resolved field in workspace
to get workspaceMemberCount directly
2024-06-30 21:00:20 +02:00
martmull
b8f33f6f59
5095 move onboardingstatus computation from frontend to backend (#5954)
- move front `onboardingStatus` computing to server side
- add logic to `useSetNextOnboardingStatus`
- update some missing redirections in
`usePageChangeEffectNavigateLocation`
- separate subscriptionStatus from onboardingStatus
2024-06-28 17:32:02 +02:00
bosiraphael
1a66db5bff
Refactor messaging refresh access token (#6034)
- Put error handling outside of `refreshAndSaveAccessToken`
- return after failing to refresh access token in
`processMessageBatchImport`
- remove unnecessary token refresh in `processMessageListFetch`
2024-06-27 17:07:45 +02:00
bosiraphael
4f9527c860
5901 refactor email and calendar auto contact creation to create them by batch (#6038)
Closes #5901
2024-06-27 16:37:34 +02:00
bosiraphael
d1bb0fb822
Change messaging batch size and cron pattern (#6063)
Change messaging batch size and cron pattern to accelerate messages
import
2024-06-27 16:23:47 +02:00
bosiraphael
ac7d905c84
Create fields for calendar and messaging settings v2 (#6049)
Create fields for calendar and messaging settings v2
2024-06-27 16:23:25 +02:00
bosiraphael
845fcb65ce
Replace ObjectRecord<MessageChannelWorkspaceEntity> with MessageChannelWorkspaceEntity (#6059)
Replace ObjectRecord<MessageChannelWorkspaceEntity> with
MessageChannelWorkspaceEntity
2024-06-27 14:35:25 +02:00
Jérémy M
95c5602a4e
feat: manually implement joinColumn (#6022)
This PR introduce a new decorator named `@WorkspaceJoinColumn`, the goal
of this one is to manually declare the join columns inside the workspace
entities, so we don't have to rely on `ObjectRecord` type.

This decorator can be used that way:

```typescript
  @WorkspaceRelation({
    standardId: ACTIVITY_TARGET_STANDARD_FIELD_IDS.company,
    type: RelationMetadataType.MANY_TO_ONE,
    label: 'Company',
    description: 'ActivityTarget company',
    icon: 'IconBuildingSkyscraper',
    inverseSideTarget: () => CompanyWorkspaceEntity,
    inverseSideFieldKey: 'activityTargets',
  })
  @WorkspaceIsNullable()
  company: Relation<CompanyWorkspaceEntity> | null;

  // The argument is the name of the relation above
  @WorkspaceJoinColumn('company')
  companyId: string | null;
```
2024-06-27 11:41:22 +02:00
bosiraphael
97822533db
Fix cache flush in messaging-channel-sync-status.service (#6024)
Fix cache flush in messaging-channel-sync-status.service
2024-06-27 09:58:37 +02:00
bosiraphael
03b00c49d5
Improve gmail error handling by catching and throttling for 400 failedPrecondition (#6044)
Closes #5897
2024-06-27 09:57:19 +02:00
Weiko
1eb9c582f3
Rename mutation maximum affected records (#6042)
As per my last comment on https://github.com/twentyhq/twenty/pull/6039,
we decided to rename this var
2024-06-26 18:00:25 +02:00
Weiko
6599bc136e
Add mutationMaximumRecordAffected to clientConfig (#6039)
We are exposing the server mutationMaximumRecordAffected value via
clientConfig so it can be used by the FE.

This is a first step for https://github.com/twentyhq/twenty/issues/6025

<img width="610" alt="Screenshot 2024-06-26 at 14 58 26"
src="https://github.com/twentyhq/twenty/assets/1834158/9d192976-fd22-45d2-bdaa-a8ff6bb90ca2">
2024-06-26 15:21:13 +02:00
Félix Malfait
cf67ed09d0
Upsert endpoint and CSV import upsert (#5970)
This PR introduces an `upsert` parameter (along the existing `data`
param) for `createOne` and `createMany` mutations.

When upsert is set to `true`, the function will look for records with
the same id if an id was passed. If not id was passed, it will leverage
the existing duplicate check mechanism to find a duplicate. If a record
is found, then the function will perform an update instead of a create.

Unfortunately I had to remove some nice tests that existing on the args
factory. Those tests where mostly testing the duplication rule
generation logic but through a GraphQL angle. Since I moved the
duplication rule logic to a dedicated service, if I kept the tests but
mocked the service we wouldn't really be testing anything useful. The
right path would be to create new tests for this service that compare
the JSON output and not the GraphQL output but I chose not to work on
this as it's equivalent to rewriting the tests from scratch and I have
other competing priorities.
2024-06-26 11:39:16 +02:00
Charles Bochet
1736aee7ff
Remove message-import cache when connectedAccount is removed (#6021) 2024-06-26 11:23:08 +02:00
Weiko
78865ee73e
Fix billing signup when workspace does not exist (#6018) 2024-06-25 15:51:01 +02:00
Jérémy M
7c2e745b45
feat: Dynamic hook registration for WorkspaceQueryHooks (#6008)
#### Overview

This PR introduces a new API for dynamically registering and executing
pre and post query hooks in the Workspace Query Hook system using the
`@WorkspaceQueryHook` decorator. This approach eliminates the need for
manual provider registration, and fix the issue of `undefined` or `null`
repository using `@InjectWorkspaceRepository`.

#### New API

**Define a Hook**

Use the `@WorkspaceQueryHook` decorator to define pre or post hooks:

```typescript
@WorkspaceQueryHook({
  key: `calendarEvent.findMany`,
  scope: Scope.REQUEST,
})
export class CalendarEventFindManyPreQueryHook implements WorkspaceQueryHookInstance {
  async execute(userId: string, workspaceId: string, payload: FindManyResolverArgs): Promise<void> {
    if (!payload?.filter?.id?.eq) {
      throw new BadRequestException('id filter is required');
    }

    // Implement hook logic here
  }
}
```

This API simplifies the registration and execution of query hooks,
providing a more flexible and maintainable approach.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-06-25 12:41:46 +02:00
bosiraphael
4dfca45fd3
5615 create messageongoingstalecron (#6005)
Closes #5615
2024-06-25 11:57:02 +02:00
Charles Bochet
f8c057deea
Fix sign up broken because of missing workspace schema (#6013)
Allow workspace datasource factory to return null if the workspace
schema has not been created yet
2024-06-25 10:59:07 +02:00
martmull
7fb5c9b60f
Remove useless api position parameter (#6010)
- remove buggy addition of position parameter
- check created records are in first position by default
2024-06-25 10:30:19 +02:00
bosiraphael
a001bf1514
5951 create a command to trigger the import of a single message (#5962)
Closes #5951

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-06-24 18:01:22 +02:00
bosiraphael
f3701281e9
Create new sync statuses and stages for calendar (#5997)
Create fields:
- syncStatus
- syncStage
- syncStageStartedAt
2024-06-24 16:39:56 +02:00
Charles Bochet
ad61efe6ed
Remove multi select usage (#6004)
As per title!

Also, I'm removing an incorrect logic in the enum migration runner that
takes care of the case where we have no defaultValue but non nullable
which is not a valid business case.
2024-06-24 16:39:17 +02:00
bosiraphael
77f9f6473b
Create feature flag for calendar V2 (#5998)
Create feature flag for calendar V2
2024-06-24 13:54:52 +02:00
Charles Bochet
158e7a31f4
Improve tests (#5994)
Our tests on FE are red, which is a threat to code quality. I'm adding a
few unit tests to improve the coverage and lowering a bit the lines
coverage threshold
2024-06-23 20:12:18 +02:00
Weiko
e13dc7a1fc
[FlexibleSchema] Add IndexMetadata decorator (#5981)
## Context
Our Flexible Schema engine dynamically generates entities/tables/APIs
for us but was not flexible enough to build indexes in the DB. With more
and more features involving heavy queries such as Messaging, we are now
adding a new WorkspaceIndex() decorator for our standard objects (will
come later for custom objects). This decorator will give enough
information to the workspace sync metadata manager to generate the
proper migrations that will create or drop indexes on demand.
To be aligned with the rest of the engine, we are adding 2 new tables:
IndexMetadata and IndexFieldMetadata, that will store the info of our
indexes.

## Implementation

```typescript
@WorkspaceEntity({
  standardId: STANDARD_OBJECT_IDS.person,
  namePlural: 'people',
  labelSingular: 'Person',
  labelPlural: 'People',
  description: 'A person',
  icon: 'IconUser',
})
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
  @WorkspaceField({
    standardId: PERSON_STANDARD_FIELD_IDS.email,
    type: FieldMetadataType.EMAIL,
    label: 'Email',
    description: 'Contact’s Email',
    icon: 'IconMail',
  })
  @WorkspaceIndex()
  email: string;
```
By simply adding the WorkspaceIndex decorator, sync-metadata command
will create a new index for that column.
We can also add composite indexes, note that the order is important for
PSQL.
```typescript
@WorkspaceEntity({
  standardId: STANDARD_OBJECT_IDS.person,
  namePlural: 'people',
  labelSingular: 'Person',
  labelPlural: 'People',
  description: 'A person',
  icon: 'IconUser',
})
@WorkspaceIndex(['phone', 'email'])
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```

Currently composite fields and relation fields are not handled by
@WorkspaceIndex() and you will need to use this notation instead
```typescript
@WorkspaceIndex(['companyId', 'nameFirstName'])
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```
<img width="700" alt="Screenshot 2024-06-21 at 15 15 45"
src="https://github.com/twentyhq/twenty/assets/1834158/ac6da1d9-d315-40a4-9ba6-6ab9ae4709d4">

Next step: We might need to implement more complex index expressions,
this is why we have an expression column in IndexMetadata.
What I had in mind for the decorator, still open to discussion
```typescript
@WorkspaceIndex(['nameFirstName', 'nameLastName'], { expression: "$1 || ' ' || $2"})
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-06-22 12:39:57 +02:00
Jérémy M
0b4bfce324
feat: drop calendar repository (#5824)
This PR is replacing and removing all the raw queries and repositories
with the new `TwentyORM` and injection system using
`@InjectWorkspaceRepository`.
Some logic that was contained inside repositories has been moved to the
services.
In this PR we're only replacing repositories for calendar feature.

---------

Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-06-22 09:26:58 +02:00
Pacifique LINJANJA
9228667a57
Add the support of Empty and Non-Empty filter (#5773) 2024-06-20 18:18:12 +02:00
bosiraphael
86f95c0870
5898 Create a cron to monitor messageChannelSyncStatus (#5933)
Closes #5898
2024-06-19 16:04:01 +02:00
bosiraphael
016132ecf6
Fix reconnect google account bug (#5905)
Update syncStage to FULL_MESSAGE_LIST_FETCH_PENDING when reconnecting
the account to trigger a full sync on the next cron iteration.
2024-06-19 16:00:39 +02:00
Thomas Trompette
96da777107
Handle no concurrency option (#5952)
Fix error in local `teamConcurrency must be an integer between 1 and
1000`
2024-06-19 11:54:11 +02:00
Thomas Trompette
d045bcbb94
Add http status to graphql errors (#5896)
Graphql errors are not properly filtered by our handler. We still
receive errors like `NOT_FOUND` in sentry while they should be filtered.
Example
[here](https://twenty-v7.sentry.io/issues/5490383016/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=6).

We associate statuses with errors in our map
`graphQLPredefinedExceptions` but we cannot retrieve the status from the
error.

This PR lists the codes that should be filtered.

To test:
- call `findDuplicates` with an invalid id
- before, server would breaks
- now the error is simply returned
2024-06-19 10:39:09 +02:00
martmull
6fd8dab552
5582 get httpsapitwentycomrestmetadata objects filters dont work (#5906)
- Remove filters from metadata rest api
- add limite before and after parameters for metadata
- remove update from metadata relations
- fix typing issue
- fix naming
- fix before parameter

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-06-18 18:55:13 +02:00
Thomas Trompette
de2b0527a3
Fix secondaryLinks field input (#5911)
PR https://github.com/twentyhq/twenty/pull/5785/files broke links
update.

Also, dropdown "Add link" will be displayed only if a link is already
added. Otherwise, it should be a normal input.
2024-06-17 18:09:46 +02:00
martmull
1ba7037fdc
5581 get httpsapitwentycomrestmetadata relations not working (#5867)
Filtering relations is not allowed
(see`packages/twenty-server/src/engine/metadata-modules/relation-metadata/dtos/relation-metadata.dto.ts`)
so we remove filtering for find many relation

we also fixed some bug in result structure and metadata open-api schema
2024-06-17 10:59:29 +02:00
Jérémy M
d99b9d1d6b
feat: Enhancements to MessageQueue Module with Decorators (#5657)
### Overview

This PR introduces significant enhancements to the MessageQueue module
by integrating `@Processor`, `@Process`, and `@InjectMessageQueue`
decorators. These changes streamline the process of defining and
managing queue processors and job handlers, and also allow for
request-scoped handlers, improving compatibility with services that rely
on scoped providers like TwentyORM repositories.

### Key Features

1. **Decorator-based Job Handling**: Use `@Processor` and `@Process`
decorators to define job handlers declaratively.
2. **Request Scope Support**: Job handlers can be scoped per request,
enhancing integration with request-scoped services.

### Usage

#### Defining Processors and Job Handlers

The `@Processor` decorator is used to define a class that processes jobs
for a specific queue. The `@Process` decorator is applied to methods
within this class to define specific job handlers.

##### Example 1: Specific Job Handlers

```typescript
import { Processor, Process, InjectMessageQueue } from 'src/engine/integrations/message-queue';

@Processor('taskQueue')
export class TaskProcessor {

  @Process('taskA')
  async handleTaskA(job: { id: string, data: any }) {
    console.log(`Handling task A with data:`, job.data);
    // Logic for task A
  }

  @Process('taskB')
  async handleTaskB(job: { id: string, data: any }) {
    console.log(`Handling task B with data:`, job.data);
    // Logic for task B
  }
}
```

In the example above, `TaskProcessor` is responsible for processing jobs
in the `taskQueue`. The `handleTaskA` method will only be called for
jobs with the name `taskA`, while `handleTaskB` will be called for
`taskB` jobs.

##### Example 2: General Job Handler

```typescript
import { Processor, Process, InjectMessageQueue } from 'src/engine/integrations/message-queue';

@Processor('generalQueue')
export class GeneralProcessor {

  @Process()
  async handleAnyJob(job: { id: string, name: string, data: any }) {
    console.log(`Handling job ${job.name} with data:`, job.data);
    // Logic for any job
  }
}
```

In this example, `GeneralProcessor` handles all jobs in the
`generalQueue`, regardless of the job name. The `handleAnyJob` method
will be invoked for every job added to the `generalQueue`.

#### Adding Jobs to a Queue

You can use the `@InjectMessageQueue` decorator to inject a queue into a
service and add jobs to it.

##### Example:

```typescript
import { Injectable } from '@nestjs/common';
import { InjectMessageQueue, MessageQueue } from 'src/engine/integrations/message-queue';

@Injectable()
export class TaskService {
  constructor(
    @InjectMessageQueue('taskQueue') private readonly taskQueue: MessageQueue,
  ) {}

  async addTaskA(data: any) {
    await this.taskQueue.add('taskA', data);
  }

  async addTaskB(data: any) {
    await this.taskQueue.add('taskB', data);
  }
}
```

In this example, `TaskService` adds jobs to the `taskQueue`. The
`addTaskA` and `addTaskB` methods add jobs named `taskA` and `taskB`,
respectively, to the queue.

#### Using Scoped Job Handlers

To utilize request-scoped job handlers, specify the scope in the
`@Processor` decorator. This is particularly useful for services that
use scoped repositories like those in TwentyORM.

##### Example:

```typescript
import { Processor, Process, InjectMessageQueue, Scope } from 'src/engine/integrations/message-queue';

@Processor({ name: 'scopedQueue', scope: Scope.REQUEST })
export class ScopedTaskProcessor {

  @Process('scopedTask')
  async handleScopedTask(job: { id: string, data: any }) {
    console.log(`Handling scoped task with data:`, job.data);
    // Logic for scoped task, which might use request-scoped services
  }
}
```

Here, the `ScopedTaskProcessor` is associated with `scopedQueue` and
operates with request scope. This setup is essential when the job
handler relies on services that need to be instantiated per request,
such as scoped repositories.

### Migration Notes

- **Decorators**: Refactor job handlers to use `@Processor` and
`@Process` decorators.
- **Request Scope**: Utilize the scope option in `@Processor` if your
job handlers depend on request-scoped services.

Fix #5628

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-06-17 09:49:37 +02:00
martmull
be18ee4d7d
Fix sentry error (#5848)
Fixes
https://twenty-v7.sentry.io/issues/5363536663/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=0

- handle error properly in twenty-server
- display backend error message
2024-06-14 12:41:55 +02:00
bosiraphael
82741d3b04
Fix error log on message import (#5866)
Modify #5863 to log the connected account id rather than the message
channel id to be consistent with the other logs and stringify the error.
2024-06-14 12:38:35 +02:00