Commit Graph

895 Commits

Author SHA1 Message Date
Weiko
676c902731
Fix timelineActivity updated fields (#6494)
## Context
We recently introduced the new twenty ORM and used it in the update
methods in the query runner.
Initially we were using pg_graphql to fetch the record before updating
it allowing us to compare the before and the after and create a diff.
This diff is then used for the timeline activity creation. Now,
twentyORM is doing the fetch and pg_graphql is still doing the update
and their responses are not exactly the same, which means the diff is
not working as intended (e.g date types were always in the diff due to
one being in Date format and the other as a string)

This PR introduces a updatedFields property to the update event which
comes from the input. This is not ideal as this won't work for API users
that send the whole payload but will be sufficient enough for our FE
that only sends modified fields. We then compare only those fields in
the diff.
2024-08-01 18:41:28 +02:00
rostaklein
a424c63476
file storage workspace id prefix (#6230)
closes https://github.com/twentyhq/twenty/issues/6155

just an idea, i guess this could work well, but im open for discussion

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-01 18:07:22 +02:00
Charles Bochet
5c92ab937e
Leverage workspace activationStatus to decide if a workspace is activated or not (#6497)
An ACTIVE workspace is a workspace that has a complete workspaceSchema
and is authorized to be browsed by users.

In this PR, I'm:
- introducing a new activationStatus: PENDING_CREATION (existing ACTIVE
/ INACTIVE)
- removing workspaceService.isWorkspaceActivated (based on
workspaceSchema existence which is not robust and checking
activationStatus.ACTIVE instead)
- removing dynamic activationStatus field on worksapce resolver (we can
use the postgres column directly now that data has been migrated)
- on user sign up creating the workspace in PENDING_CREATION, and on
workspace activation setting it to ACTIVE
- only re-activating a workspace if the current activationStatus is
INACTIVE through billing webhooks (a PENDING_CREATION should stay
PENDING and ACTIVE should stay ACTIVE)
2024-08-01 17:05:15 +02:00
Thomas Trompette
8c8f192765
Trigger workflow on database event (#6480)
- Add global listener on database event
- Fetch event listener associated
- Trigger associated workflow

Also updated the runner so it expects the input to be in the payload
rather than the trigger
2024-08-01 11:57:44 +02:00
martmull
ae423f5e75
Improve typing definition (#6481)
- added typing for workflow-runner results
- fix workflow typing
- add a `workflow-action-runner` submodule that contains factories for
action runners
- added code-action-runner
- simplified code
2024-08-01 11:38:31 +02:00
gitstart-app[bot]
d9dcd63a1c
Expose duplicate check on REST API and enable batch duplicate checks (#6328)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-5472](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-5472).
This ticket was imported from:
[TWNTY-5472](https://github.com/twentyhq/twenty/issues/5472)

 --- 

### Description:
- Following what is already done in the code, we create a REST endpoint
that generates the Graphql query and returns its result.

### Refs: #5472


### Demo:

<https://www.loom.com/share/e0b1030f056945a0bf93bdd88ea01d8f?sid=6f128e8c-370b-4079-958e-0ea2d073a241>

FIxes #5472

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: gitstart-twenty <140154534+gitstart-twenty@users.noreply.github.com>
Co-authored-by: martmull <martmull@hotmail.fr>
2024-08-01 10:08:22 +02:00
pereira0x
c3417ddba1
Share an email thread to workspace members chip and dropdown (#4199) (#5640)
# Feature: Email thread members visibility

For this feature we implemented a chip and a dropdown menu that allows
users to check which workspace members can see an email thread, as
depicted on issue (#4199).

## Implementations

- create a new database table (messageThreadMember)
- relations between `messageThreadMembers` and the relevant existing
tables (`MessageThread` and `WorkspaceMembers`)
- added a new column to the `MessageThread table`: `everyone` - to
indicate that all workspace members can see the email thread
- create a new repository for the new table, including new queries
- edit the queries so that the new fields could be fetched from the
frontend
- created a component `MultiChip`, that shows a group of user avatars,
instead of just one
- created a component, `ShareDropdownMenu`, that shows up once the
`EmailThreadMembersChip` is clicked. On this menu you can see which
workspace members can view the email thread.

## Screenshots

Here are some screenshots of the frontend components that were created:

Chip with everyone in the workspace being part of the message thread:

![image](https://github.com/twentyhq/twenty/assets/26422084/80d75cdc-656f-490d-9eb1-a07346aad75c)

Chip with just one member of the workspace (the owner) being part of the
message thread:

![image](https://github.com/twentyhq/twenty/assets/26422084/c26677c6-ab93-4149-8201-b110d7346a28)

Chip with some members of the workspace being part of the message
thread:

![image](https://github.com/twentyhq/twenty/assets/26422084/9eccf5f8-134c-4c62-9145-5d5aa2346071)

How the chip looks in a message thread:

![image](https://github.com/twentyhq/twenty/assets/26422084/a9de981d-7288-4aed-8616-c1cb7de524e2)

Dropdown that opens when you click on the chip:

![image](https://github.com/twentyhq/twenty/assets/26422084/a1bb9cd4-01bb-45c5-bf8b-b31c2f3d85e0)

## Testing and Mock data

We also added mock data (TypeORM seeds), focusing on adding mock data
related to message thread members.

## Conclusion

As some of the changes that we needed to do, regarding the change of
visibility of the message thread, were not covered by the existing
documentation, we were told to open a PR and ask for feedback on this
part of the implementation. Right now, our implementation is focused on
displaying who is part of an email thread.

Feel free to let us know which steps we should follow next :)

---------

Co-authored-by: Simão Sanguinho <simao.sanguinho@tecnico.ulisboa.pt>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-07-31 18:50:27 +02:00
Charles Bochet
ae7821ce70
Fast follows on new task/note behaviors (#6477)
In this PR, I'm fixing two issues that we have faced:
- computing a rich text first line in case of the first block content is
not a text
- migrating existing timelineActivities tied to tasks / notes to
linked-tasks / linked-notes during migration command
2024-07-31 17:49:56 +02:00
Félix Malfait
80c0fc7ff1
Activity as standard object (#6219)
In this PR I layout the first steps to migrate Activity to a traditional
Standard objects

Since this is a big transition, I'd rather split it into several
deployments / PRs

<img width="1512" alt="image"
src="https://github.com/user-attachments/assets/012e2bbf-9d1b-4723-aaf6-269ef588b050">

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
Co-authored-by: bosiraphael <71827178+bosiraphael@users.noreply.github.com>
Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: Faisal-imtiyaz123 <142205282+Faisal-imtiyaz123@users.noreply.github.com>
Co-authored-by: Prateek Jain <prateekj1171998@gmail.com>
2024-07-31 15:36:11 +02:00
Marie
64763fb70c
Revert update of workspaceMember standard id (#6475) 2024-07-31 15:04:26 +02:00
martmull
424225943c
Add missing break (#6474) 2024-07-31 14:01:18 +02:00
martmull
6b4c79ff0d
Add workflow runner (#6458)
- add workflow runner module
- add an endpoint to trigger a workflow via api
- improve error handling for serverless functions

## Testing
- create 2 serverless functions
- create a workflow
- create this workflow Version
```
{
  "type": "MANUAL",
  "input": {"b": "bb"},
  "nextAction": {
    "name": "step_1",
    "displayName": "Code",
    "type": "CODE",
    "valid": true,
    "settings": {
      "serverlessFunctionId": "Serverless function 1 Id",
      "errorHandlingOptions": {
        "retryOnFailure": {
          "value": false
        },
        "continueOnFailure": {
          "value": false
        }
      }
    },
    "nextAction": {
      "name": "step_1",
      "displayName": "Code",
      "type": "CODE",
      "valid": true,
      "settings": {
        "serverlessFunctionId": "Serverless function 1 Id",
        "errorHandlingOptions": {
          "retryOnFailure": {
            "value": false
          },
          "continueOnFailure": {
            "value": false
          }
        }
      },
      "nextAction": {
        "name": "step_1",
        "displayName": "Code",
        "type": "CODE",
        "valid": true,
        "settings": {
          "serverlessFunctionId": "Serverless function 2 Id",
          "errorHandlingOptions": {
            "retryOnFailure": {
              "value": false
            },
            "continueOnFailure": {
              "value": false
            }
          }
        }
      }
    }
  }
}

`
``
- call 
```
mutation Trigger {
  triggerWorkflow(workflowVersionId: "WORKFLOW_VERSION_ID") {
    result
  }
}
```
- try when errors are injected in serverless function
2024-07-31 12:48:33 +02:00
Marie
b8496d22b6
Do not add 'https' prefix while migrating domainName if source url is empty (#6471) 2024-07-31 12:03:49 +02:00
Marie
7fe00b163e
Add logs and fix timestamps in migrate domain command (#6468) 2024-07-31 11:23:19 +02:00
AbdulQader Qassab
50f1cd352d
Add description for Developers/webhook page (#6327)
- Add optional description field to webhook page in developer settings.

Fix https://github.com/twentyhq/twenty/issues/6236

---------

Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
2024-07-31 10:59:30 +02:00
bosiraphael
77152a10b1
Fix company creation duplicate on email sync after introducing links type (#6460)
- Introduce `extractDomainFromLink`
- Use is inside `create-company.service`
2024-07-30 18:10:36 +02:00
Weiko
b85ae7e1ac
Fix googleApisSetRequestExtraParams (#6455) 2024-07-30 16:08:59 +02:00
Thomas Trompette
68e3730be1
Fix base graphql error message (#6457)
Display error message instead of name

<img width="762" alt="Capture d’écran 2024-07-30 à 15 51 07"
src="https://github.com/user-attachments/assets/a6b49254-a99e-42fc-8704-089f38bf8e7b">
2024-07-30 15:55:57 +02:00
Marie
3a37dfc7d5
Fix domainName seeds (#6454) 2024-07-30 15:14:36 +02:00
Lucas Bordeau
ccf4d1eeec
Date formatting per workspace member settings (#6408)
Implement date formatting per workspace member settings

We'll need another round to maybe initialize all workspaces on the
default settings.

For now the default behavior is to take system settings if nothing is
found in DB.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-07-30 14:52:10 +02:00
Charles Bochet
45ebb0b824 Seed workspaces as active 2024-07-30 14:49:14 +02:00
Thomas Trompette
e3496a19b5
Move folder (#6451)
Fix folder mistake
2024-07-30 14:16:23 +02:00
Thomas Trompette
ee14f25996
Add enable workflow trigger endpoint (#6443)
Basic endpoint that only returns a boolean currently and overrides the
previous listener.
2024-07-30 14:00:37 +02:00
bosiraphael
cd4263f7fd
6431 create new field activationStatus inside workspace table (#6439)
Closes #6431 
- create new field `activationStatus`
- create migration commands
- add logic to update `activationStatus` on workspace activation and on
stripe subscriptionStatus change

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-30 12:36:39 +02:00
Marie
8e35edad30
Migrate domainName field from text type to links type (#6410)
Closes #5759.
2024-07-30 11:47:37 +02:00
martmull
fb0fd99a38
Fix error handling in serverless service (#6442)
- narrowing error handling in aws sdk usage
- updating dto to authorize null descriptions
2024-07-29 18:51:57 +02:00
Thomas Trompette
515d6fb1c5
Filter out by error code + invert filtering (#6432)
As title

Instance of not working well.

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-29 16:18:23 +02:00
gitstart-app[bot]
fed12ddfcd
Improve performance of demo workspace - Rename getImageAbsoluteURIOrBase64 function (#6282)
### Description

1. This PR is a continuation of a previous PR:
https://github.com/twentyhq/twenty/pull/6201#pullrequestreview-2175601222

2. One test case was removed here:
`packages/twenty-front/src/utils/image/__tests__/getImageAbsoluteURI.test.ts`
because since we are not handling base64 images anymore, the result is
the same of the last test case. Would you rather we update the test
instead?


### Refs

- #3514
- https://github.com/twentyhq/twenty/pull/6201

### Demo


https://www.loom.com/share/4f32b535c77a4d418e319b095d09452c?sid=df34adf8-b013-44ef-b794-d54846f52d2d

Fixes #3514

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
2024-07-29 14:07:21 +02:00
martmull
00fea17920
Serverless function UI (#6388)
https://www.figma.com/design/xt8O9mFeLl46C5InWwoMrN/Twenty?node-id=36235-120877

Did not do the file manager part. A Function is defined using one unique
file at the moment

Feature protected by featureFlag `IS_FUNCTION_SETTINGS_ENABLED`

## Demo


https://github.com/user-attachments/assets/0acb8291-47b4-4521-a6fa-a88b9198609b
2024-07-29 13:03:09 +02:00
Charles Bochet
936279f895 Fix incorrect fetch of userVars when users are part of multi-workspaces 2024-07-28 11:58:10 +02:00
Charles Bochet
dcb8c7c03a Fix incorrect fetch of userVars when userId is not specified 2024-07-28 11:30:14 +02:00
bosiraphael
6728e40256
5899 display a banner to alert users which need to reconnect their account (#6301)
Closes #5899

<img width="1280" alt="Index - banner"
src="https://github.com/twentyhq/twenty/assets/71827178/313cf20d-eb34-496a-8c7c-7589fbd55954">

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-27 18:34:52 +02:00
bosiraphael
d0db3b765f
6255 move services from messaging common module into the correct module and refactor them (#6409)
Closes #6255 

- Move files from `messaging/common` into the correct module
- Remove common module between calendar and messaging
`calendar-messaging-participant-manager`
- Update and fix massaging and calendar participant matching
- Create `MatchParticipantModule`

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-27 12:29:02 +02:00
Thomas Trompette
3060eb4e1e
Handle query runner errors (#6424)
- Throw service error from query runner
- Catch in resolver factories 
- Map to graphql errors

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-27 12:27:04 +02:00
Thomas Trompette
368f142f3a
Delete cache version on reset db (#6426)
As title
2024-07-27 11:54:03 +02:00
Charles Bochet
5a1835e9e0 Improve datasource creation resilience to missing cache 2024-07-27 11:35:47 +02:00
Aakarshan Thapa
1529148c04
Updated MessageChannelSyncStatus enum: changed COMPLETED to ACTIVE (#5965)
Fixes #5961

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-25 21:17:55 +02:00
Charles Bochet
7b943457c8 Update sync-metadata to use feature-flag core module 2024-07-25 20:47:38 +02:00
Charles Bochet
8083175432
Fix object metadata not found (#6416) 2024-07-25 20:34:50 +02:00
Charles Bochet
4cb83e050f
Put workfows behind a feature flag (#6417)
We have recently merged
[#workflow](https://github.com/twentyhq/twenty/pull/6412) but we should
put the workflow standard object behind a feature flag for now

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
2024-07-25 20:33:31 +02:00
Charles Bochet
515bf666cf Do not create identifier for remote object 2024-07-25 18:39:08 +02:00
Thomas Trompette
ce68f8ac79
Add workflow and version as standard object (#6412)
As title

Hidden behind a feature flag.
2024-07-25 18:33:11 +02:00
Charles Bochet
d022837b5b
Display command logs on boot error (#6414)
As per title
2024-07-25 17:53:57 +02:00
Charles Bochet
d073ebff43
Prevent field with null standardId to be considered as field identifier (#6407)
Otherwise, any custom field will be considered as image/label identifier
by the sync-metadata scripts
2024-07-25 13:28:10 +02:00
Jérémy M
d0201e17ac
Fix: query runner orm (#6397)
Fix WorkspaceQueryRunner events using TwentyORM

Fix #6057

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-25 13:21:57 +02:00
martmull
b9c8d607aa
Test revert crm integration (#6321)
PR to test revert integration in production
2024-07-25 09:38:55 +02:00
martmull
7c6ca0e841
Fix api timeout (#6401) 2024-07-25 08:38:05 +02:00
Marie
082d55beac
[fix] Migrated links field should be standard (#6387)
Fixing script + ading logs to sync-metadata
2024-07-24 12:16:14 +02:00
Marie
001e698bbe
Use LinksMetadata right type for Links fields (#6380) 2024-07-24 10:48:15 +02:00
Pacifique LINJANJA
6785a2b92c
chore: remove the passwordResetToken field from the database (#6377)
# This PR

- Fix #6305
2024-07-24 10:44:11 +02:00
Charles Bochet
2cc0597ee4 Update seed links format 2024-07-23 14:48:26 +02:00
Charles Bochet
6c34ef9a14
Simplify ORM (#6373)
This PR refactors the ORM-Manager to simplify and unify the datasource
creation. I'm deprecating all usages if InjectWorkspaceDatasource and
InjectWorkspaceRepository as we can't be sure they are up-to-date
2024-07-23 14:13:16 +02:00
Marie
794e73eeb6
Migrate conferenceLink to type Links (#6372) 2024-07-23 14:09:52 +02:00
Marie
8d33264a7d
Migrate fields of deprecated type LINK to type LINKS (#6332)
Closes #5909.

Adding a command to migrate fields of type Link to fields of type Links,
including their data.
2024-07-23 09:57:30 +02:00
Charles Bochet
c69d665114
Fix reset PasswordToken (#6366)
## Bug Description

We are facing a bug in case recaptcha is enabled.
To reproduce:
- Create your recaptcha: https://www.google.com/recaptcha/about/
- update your server .env with the following variables:

```
CAPTCHA_SECRET_KEY=REPLACE_ME
CAPTCHA_SITE_KEY=REPLACE_ME
CAPTCHA_DRIVER=google-recaptcha
```

- Go to the login page, enter an existing user email and hit 'Reset your
password'.

- Add a console.log in emailPasswordResetLink in auth.resolver.ts to get
the token that would be sent by email if you don't have the mailer setup

- Browse: /reset-password/{passwordToken}

- Update the password:
<img width="1446" alt="image"
src="https://github.com/user-attachments/assets/dd5b077f-293e-451a-8630-22d24ac66c42">

- See that the token is invalid

You should see two calls in your developer network tab. A successful one
to update the password and another to log you in. This 2nd call
(Challenge) does not have the captcha token provided. It should be

## Fix

- Refreshing the token on page load
- providing it to the Challenge graphql call
2024-07-22 17:36:31 +02:00
Charles Bochet
d212aedf81
Fix ORM (#6363)
This PR fixes a few bugs on TwentyORM:
- fix many to one relations that were not properly queries
- fix many to one relations that were not properly parsed
- compute datasource (or use from cache) at run-time and do not use
injected one that could be outdated

We still need to refactor it to simplify, I feel the API are too complex
and we have too many cache layers. Also the relation computation part is
very complex and bug prone
2024-07-22 15:07:35 +02:00
brendanlaschke
936994ff44
Fix demo opportunities name (#6347)
closes #5129
2024-07-22 12:22:32 +02:00
Charles Bochet
d8cadad0fa
Deprecate inject workspace repo (#6353) 2024-07-20 00:43:29 +02:00
Charles Bochet
2e38c3bbc1
Refactor raw queries to use prepared query to avoid security vuln. (#6348)
As per title, we should avoid at all cost using non-prepared query and
NEVER use them whenever the input come from the user.
2024-07-19 22:32:40 +02:00
Jérémy M
de20c564c7
feat: add eslint rule for enforcing WorkspaceService naming convention (#6308)
### Description

This PR introduces a custom ESLint rule named
`inject-workspace-repository`. The purpose of this rule is to enforce
naming conventions for files and classes that use the
`@InjectWorkspaceRepository` decorator or include services ending with
`WorkspaceService` in their constructors.

### Rule Overview

The new ESLint rule checks for the following conditions:

1. **File Naming**:
- Only file ending with `.service.ts` or `.workspace-service.ts` are
checked.
- If a file contains a class using the `@InjectWorkspaceRepository`
decorator or a service ending with `WorkspaceService` in the
constructor, the file name must end with `.workspace-service.ts`.

2. **Class Naming**:
- Classes that use the `@InjectWorkspaceRepository` decorator or include
services ending with `WorkspaceService` in their constructors must have
names that end with `WorkspaceService`.

### How It Works

The rule inspects each TypeScript file to ensure that the naming
conventions are adhered to. It specifically looks for:

- Constructor parameters with the `@InjectWorkspaceRepository`
decorator.
- Constructor parameters with a type annotation ending with
`WorkspaceService`.

When such parameters are found, it checks the class name and the file
name to ensure they conform to the expected patterns.

### Example Code

#### Valid Cases

1. **Correct File and Class Name with Decorator**:
    ```typescript
    // Filename: my.workspace-service.ts
    class MyWorkspaceService {
      constructor(@InjectWorkspaceRepository() private repository) {}
    }
    ```

2. **Service Dependency**:
    ```typescript
    // Filename: another.workspace-service.ts
    class AnotherWorkspaceService {
      constructor(private myWorkspaceService: MyWorkspaceService) {}
    }
    ```

#### Invalid Cases

1. **Incorrect Class Name**:
    ```typescript
    // Filename: my.workspace-service.ts
    class MyService {
      constructor(@InjectWorkspaceRepository() private repository) {}
    }
    // Error: Class name should end with 'WorkspaceService'.
    ```

2. **Incorrect File Name**:
    ```typescript
    // Filename: my.service.ts
    class MyWorkspaceService {
      constructor(@InjectWorkspaceRepository() private repository) {}
    }
    // Error: File name should end with '.workspace-service.ts'.
    ```

3. **Incorrect File and Class Name**:
    ```typescript
    // Filename: my.service.ts
    class MyService {
      constructor(@InjectWorkspaceRepository() private repository) {}
    }
    // Error: Class name should end with 'WorkspaceService'.
    // Error: File name should end with '.workspace-service.ts'.
    ```

4. **Incorrect File Type**:
    ```typescript
    // Filename: another.service.ts
    class AnotherService {
      constructor(private myWorkspaceService: MyWorkspaceService) {}
    }
    // Error: Class name should end with 'WorkspaceService'.
    // Error: File name should end with '.workspace-service.ts'.

    ```

5. **Incorrect Class Name with Dependency**:
    ```typescript
    // Filename: another.workspace-service.ts
    class AnotherService {
      constructor(private myWorkspaceService: MyWorkspaceService) {}
    }
    // Error: Class name should end with 'WorkspaceService'.
    ```

### First step

This rule is only a warning for now, and then we'll migrate all the code
that need to be migrated and move from `warn` to `error`.

Fix #6309

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-19 19:17:57 +02:00
Jérémy M
088d061b3e
feat: twenty orm for standard and custom objects (#6178)
### Overview

This PR builds upon #5153, adding the ability to get a repository for
custom objects. The `entitySchema` is now generated for both standard
and custom objects based on metadata stored in the database instead of
the decorated `WorkspaceEntity` in the code. This change ensures that
standard objects with custom fields and relations can also support
custom objects.

### Implementation Details

#### Key Changes:

- **Dynamic Schema Generation:** The `entitySchema` for standard and
custom objects is now dynamically generated from the metadata stored in
the database. This shift allows for greater flexibility and
adaptability, particularly for standard objects with custom fields and
relations.
  
- **Custom Object Repository Retrieval:** A repository for a custom
object can be retrieved using `TwentyORMManager` based on the object's
name. Here's an example of how this can be achieved:

  ```typescript
const repository = await this.twentyORMManager.getRepository('custom');
  /*
* `repository` variable will be typed as follows, ensuring that standard
fields and relations are properly typed:
   * const repository: WorkspaceRepository<CustomWorkspaceEntity & {
   *    [key: string]: any;
   * }>
   */
  const res = await repository.find({});
  ```

Fix #6179

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
Co-authored-by: Weiko <corentin@twenty.com>
2024-07-19 18:23:52 +02:00
Weiko
a374922902
Cannot delete label identifier associated field (#6340)
## Context
An object should always have a labelIdentifier (would be its primary key
at least). If the associated field is deleted by a user, it will break
the app. Ideally we should handle that on the DB level but we don't have
a FK for this column yet.
In the meantime I'm adding the validation check in the backend, note
that this is already handle on the FE side since the "archive/delete"
buttons don't appear for such fields so you need to reassign it to
another field first which is the desired behaviour.
2024-07-19 15:57:40 +02:00
Weiko
67e2d5c73a
Add label identifier to object decorator (#6227)
## Context
LabelIdentifier and ImageIdentifier are metadata info attached to
objectMetadata that are used to display a record in a more readable way.
Those columns point to existing fields that are part of the object.
For example, for a relation picker of a person, we will show a record
using the "name" labelIdentifier and the "avatarUrl" imageIdentifier.
<img width="215" alt="Screenshot 2024-07-11 at 18 45 51"
src="https://github.com/twentyhq/twenty/assets/1834158/488f8294-0d7c-4209-b763-2499716ef29d">

Currently, the FE has a specific logic for company and people objects
and we have a way to update this value via the API for custom objects,
but the code is not flexible enough to change other standard objects.

This PR updates the WorkspaceEntity API so we can now provide the
labelIdentifier and imageIdentifier in the WorkspaceEntity decorator.

Example:
```typescript
@WorkspaceEntity({
  standardId: STANDARD_OBJECT_IDS.activity,
  namePlural: 'activities',
  labelSingular: 'Activity',
  labelPlural: 'Activities',
  description: 'An activity',
  icon: 'IconCheckbox',
  labelIdentifierStandardId: ACTIVITY_STANDARD_FIELD_IDS.title,
})
@WorkspaceIsSystem()
export class ActivityWorkspaceEntity extends BaseWorkspaceEntity {
  @WorkspaceField({
    standardId: ACTIVITY_STANDARD_FIELD_IDS.title,
    type: FieldMetadataType.TEXT,
    label: 'Title',
    description: 'Activity title',
    icon: 'IconNotes',
  })
  title: string;
...
```
2024-07-19 14:24:04 +02:00
Weiko
65e8503da8
Fix Metadata GQL server hook (#6323)
## Context
We've created a yoga (gql server) hook that catches requests and cache
them when needed. In practice we use it on the "objects" query because
this is often queried on the FE and it should never return something
different unless the schema has been intentionally changed by the user
when editing their data model (updating objects, fields, etc).

The issue here is we always cache the response regardless of its result,
even when it fails. This PR fixes that behaviour by only caching the
query response if it is successful.

I'm also fixing the cache key because the signature let users put
multiple operations and the cache key was not taking this into account
(we always use it on only one operation but we might have issues in the
future because another operation response could have erased the cached
response of another). Now the cache key contains the name of the
operation as well.

## Test
tested locally by manually throwing an error in the JWT auth guard
2024-07-18 16:51:50 +02:00
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