Commit Graph

958 Commits

Author SHA1 Message Date
Charles Bochet
c543716381
Various fixes: profilePicture / logo upload, imageIdentifiers (#6530)
In this PR:
- refactoring auth module to extract a jwt module that can be re-used
from other part of the app (avoiding circular dependencies file module
=> auth => file (file and auth both need jwt actually)
- activating imageIdentfier on person on workspace creation (this will
put back the images on people)
- fixing picture upload (we were missing some fileToken)
2024-08-04 15:08:25 +02:00
Charles Bochet
e787215e15
Add createdBy field on custom object creation (#6529)
In this PR, I'm:
- adding createdBy field (type ACTOR) on custom objects when created
- moving `name` and `position` default column to the set of columns
automatically creation on object creation
- fixing a bug on mutations (update / create), if the targetted object
has a 'data' custom field, it was conflicting with the payload ==> I
feel we need to refactor this part of the code but we can keep this for
a bit later as we plan to move out of pg_graphql

<img width="1198" alt="image"
src="https://github.com/user-attachments/assets/891c4a97-bab1-415c-8551-dabd5996a794">
2024-08-04 13:12:24 +02:00
Charles Bochet
e2b42ee6c9 Allow free access for configuration using billing 2024-08-04 01:37:53 +02:00
Charles Bochet
76185c2f68
Add command to backfill new onboarding user vars (#6526)
As per our guideline to maintain a smooth migration to the new minor
versions, this command is backfilling existing workspaces with the 3
userVars used to keep track of user onboarding:
```
  ONBOARDING_CONNECT_ACCOUNT_COMPLETE = 'ONBOARDING_CONNECT_ACCOUNT_COMPLETE',
  ONBOARDING_INVITE_TEAM_COMPLETE = 'ONBOARDING_INVITE_TEAM_COMPLETE',
  ONBOARDING_CREATE_PROFILE_COMPLETE = 'ONBOARDING_CREATE_PROFILE_COMPLETE',
```
2024-08-04 01:04:13 +02:00
martmull
7cd5427589
Fix onboarding status performance issues (#6512)
Updated the onboardingStatus computation to improve performances

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-04 00:33:33 +02:00
Marie
e01d3fd0be
Do not override value for composite types address and links when entering input (#6502)
Closes #6434.

We don't want to override the values of the records' address or links as
they are composite field and it is costly to loose the data.
We will need a more unified behaviour here - maybe introduce a Ctrl+Z
option.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-03 20:12:31 +02:00
Marie
6e0c1b4c73
Fallback to default value when migrating value from enum (#6517)
When migrating the option values of a select type, if the field is non
nullable (for now, only available for opportunity's "stage" standard
field), we fallback to the (potentially updated) default value instead
of nullifying the value to avoid getting a database error.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-03 17:53:01 +02:00
Jérémy M
6432ad39b9
feat: add new ACTOR field type and createdBy standard fields (#6324)
This pull request introduces a new `FieldMetadataType` called `ACTOR`.
The primary objective of this new type is to add an extra column to the
following objects: `person`, `company`, `opportunity`, `note`, `task`,
and all custom objects.

This composite type contains three properties:

- `source`
    ```typescript
    export enum FieldActorSource {
      EMAIL = 'EMAIL',
      CALENDAR = 'CALENDAR',
      API = 'API',
      IMPORT = 'IMPORT',
      MANUAL = 'MANUAL',
    }
    ```
- `workspaceMemberId`
- This property can be `undefined` in some cases and refers to the
member who created the record.
- `name`
- Serves as a fallback if the `workspaceMember` is deleted and is used
for other source types like `API`.

### Functionality

The pre-hook system has been updated to allow real-time argument
updates. When a record is created, a pre-hook can now compute and update
the arguments accordingly. This enhancement enables the `createdBy`
field to be populated with the correct values based on the
`authContext`.

The `authContext` now includes:
- An optional User entity
- An optional ApiKey entity
- The workspace entity

This provides access to the necessary data for the `createdBy` field.

In the GraphQL API, only the `source` can be specified in the
`createdBy` input. This allows the front-end to specify the source when
creating records from a CSV file.

### Front-End Handling

On the front-end, `orderBy` and `filter` are only applied to the name
property of the `ACTOR` composite type. Currently, we are unable to
apply these operations to the workspace member relation. This means that
if a workspace member changes their first name or last name, there may
be a mismatch because the name will differ from the new one. The name
displayed on the screen is based on the workspace member entity when
available.

### Missing Components

Currently, this PR does not include a `createdBy` value for the `MAIL`
and `CALENDAR` sources. These records are created in a job, and at
present, we only have access to the workspaceId within the job. To
address this, we should use a function similar to
`loadServiceWithContext`, which was recently removed from `TwentyORM`.
This function would allow us to pass the `authContext` to the jobs
without disrupting existing jobs.
Another PR will be created to handle these cases.

### Related Issues

Fixes issue #5155.

### Additional Notes

This PR doesn't include the migrations of the current records and views.
Everything works properly when the database is reset but this part is
still missing for now. We'll add that in another PR.

- There is a minor issue: front-end tests are broken since this commit:
[80c0fc7ff1).

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-03 15:43:31 +02:00
Weiko
9cf08d912a
Fix migration search path (#6520) 2024-08-02 21:34:20 +02:00
Weiko
c5d95dc4c8
Add logs to migration runner (#6518) 2024-08-02 19:13:39 +02:00
Thomas Trompette
277c51d58e
Add note and task target relation creation for customs (#6515)
As title

Urgent bug to fix, I will take the time to refacto this code next week

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-08-02 18:04:32 +02:00
Weiko
5870979bfa
Fix missing encoding in workspace-logo, members, person (#6510) 2024-08-02 15:18:48 +02:00
Félix Malfait
0dcdda3928
Add updated at column (#6506)
Introduced `updatedAt` column. and fix an existing bug where the field
edition page was crashing because we were trying to compute Date('now')
(param coming from the default value)
2024-08-02 10:03:36 +02:00
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
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
martmull
28202cc9e0
Fix workspaceLogo in invite-email (#5865)
## Fixes wrong image url in email 

![image](https://github.com/twentyhq/twenty/assets/29927851/5fb1524b-874d-4723-8450-0284382bbeb3)

## Done
- duplicates and adapt `getImageAbsoluteURIOrBase64` from `twenty-front`
in `twenty-email`
- send `SERVER_URL` to email builder
2024-06-14 12:36:24 +02:00
Aditya Pimpalkar
4603999d1c
Support orderBy as array (#5681)
closes: #4301

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-06-14 11:23:37 +02:00
Charles Bochet
85fd801480
Add log for errors on message import (#5863)
As per title :)
2024-06-14 09:36:39 +02:00
Marie
582653f9df
Bump to version 0.20.0 (#5857) 2024-06-13 17:39:46 +02:00
Weiko
93c17a8a5b
Remove timelineActivity featureFlag (#5856) 2024-06-13 17:39:31 +02:00
Weiko
81c4939812
Fix timeline activity missing updated fields (#5854)
## Before
<img width="883" alt="Screenshot 2024-06-13 at 14 48 05"
src="https://github.com/twentyhq/twenty/assets/1834158/0e72ead1-2d59-4ee3-af3b-dfdd593b7f2e">


## After
<img width="908" alt="Screenshot 2024-06-13 at 14 48 14"
src="https://github.com/twentyhq/twenty/assets/1834158/00e32ddf-e40d-4cc9-a80a-9f5b76bd377a">
2024-06-13 15:22:15 +02:00
bosiraphael
f825bea071
5629 update blocklist for messaging v2 (#5756)
Closes #5629 

- Add subdomain support in blocklist (if @example.com is blocked, every
subdomain will be blocked)
2024-06-13 07:53:28 +02:00
Félix Malfait
374237a988
Refacto rest api, fix graphl playground, improve analytics (#5844)
- Improve the rest api by introducing startingAfter/endingBefore (we
previously had lastCursor), and moving pageInfo/totalCount outside of
the data object.
- Fix broken GraphQL playground on website
- Improve analytics by sending server url
2024-06-12 21:54:33 +02:00
Jérémy M
04edf2bf7b
feat: add resolve absolute path util (#5836)
Add a new util called `resolveAbsolutePath` to allow providing absolute
path for environment variable like `STORAGE_LOCAL_PATH`.
If the path in the env start with `/` we'll not prefix it with
`process.cwd()`.

Also we're using a static path for the old `db_initialized` file now
named `db_status` and stop using the env variable for this file as this
one shouldn't ne stored in the `STORAGE_LOCAL_PATH`.

Fix #4794

---------

Co-authored-by: Quentin Galliano <qgalliano@gmail.com>
2024-06-12 21:17:31 +02:00
martmull
3986824017
5623 add an inviteteam onboarding step (#5769)
## Changes
- add a new invite Team onboarding step
- update currentUser.state to currentUser.onboardingStep

## Edge cases
We will never display invite team onboarding step 
- if number of workspaceMember > 1
- if a workspaceMember as been deleted

## Important changes
Update typeorm package version to 0.3.20 because we needed a fix on
`indexPredicates` pushed in 0.3.20 version
(https://github.com/typeorm/typeorm/issues/10191)

## Result
<img width="844" alt="image"
src="https://github.com/twentyhq/twenty/assets/29927851/0dab54cf-7c66-4c64-b0c9-b0973889a148">



https://github.com/twentyhq/twenty/assets/29927851/13268d0a-cfa7-42a4-84c6-9e1fbbe48912
2024-06-12 21:13:18 +02:00
martmull
30d3ebc68a
Fix missing cursor on rest api (#5841)
## Before

![image](https://github.com/twentyhq/twenty/assets/29927851/fc3bad2d-5238-4afa-b528-409fbff3902c)

## After

![image](https://github.com/twentyhq/twenty/assets/29927851/418174c1-aafb-4ea2-a936-50c03ea17764)

![image](https://github.com/twentyhq/twenty/assets/29927851/03439033-db6b-44b0-9613-f766babc1d2d)

![image](https://github.com/twentyhq/twenty/assets/29927851/f0e5e998-3c61-437d-863f-7289609d0d30)
2024-06-12 16:25:04 +02:00
Félix Malfait
bd22bfce2e
Push event for user signup (#5837)
Need to setup Twenty as a CRM for Twenty the Twenty team
2024-06-12 12:35:46 +02:00
Charles Bochet
5ec98b5ac3 Fix not possible to read message from other workspaceMember 2024-06-12 08:21:35 +02:00
Félix Malfait
a0d9fdb3de
Fix bugs and telemetry (#5832)
Bugfix 1:
<img width="491" alt="Screenshot 2024-06-12 at 07 19 42"
src="https://github.com/twentyhq/twenty/assets/6399865/e3ad2771-4edd-453d-9d85-f429177dfd15">

Bugfix 2:
<img width="259" alt="Screenshot 2024-06-12 at 07 47 02"
src="https://github.com/twentyhq/twenty/assets/6399865/2f82c90e-2180-4290-b12e-e72910fb108c">

Change 3:
I remove the "telemetry anonymization enabled" parameter as it was
misleading, we were anonymization ids but still forwarding the workspace
name which is imo more sensitive than an ID
2024-06-12 08:11:48 +02:00
Weiko
be96c68416
POC timeline activity (#5697)
TODO: 
- remove WorkspaceIsNotAuditLogged decorators on activity/activityTarget
to log task/note creations
- handle attachments
-  fix css and remove unnecessary styled components or duplicates
2024-06-11 18:53:28 +02:00
bosiraphael
64b8e4ec4d
Fix access token refresh (#5825)
In `messaging-gmail-messages-import.service`, we were refreshing the
access token before each query but we were passing the old access token
to `fetchAllMessages`.
I modified the function to query the updated connectedAccount with the
new access token.
This will solve the 401 errors we were getting in production.
2024-06-11 18:52:38 +02:00
brendanlaschke
4994a9c3a9
Api docs remove Relations from Post & Patch (#5817)
* Remove relations where they cannot be used
* Removed duplicated schema for findMany
* Reuse schema for Relation variant to reduce size of sent json object

closes #5778

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: martmull <martmull@hotmail.fr>
2024-06-11 15:31:48 +02:00
Kyriaki Darivaki
58fb86f2c3
Added support for Links filtering (#5785)
References #5741

---------

Co-authored-by: kiridarivaki <k.darivaki03@gmail.com>
2024-06-11 15:24:34 +02:00
martmull
5c15fcd249
5805 typing issue in rest api (#5818)
Fixed types for:
- uuid
- email
- datetime
- date
- number
- currency.amountMicros
- select
- multiSelect

## Before

![image](https://github.com/twentyhq/twenty/assets/29927851/4bfa3a6d-a26f-47e4-a46f-7a5582825482)


## After

![image](https://github.com/twentyhq/twenty/assets/29927851/0bbab32f-4172-4525-91d1-76c37f299ac0)
2024-06-11 14:54:02 +02:00
Charles Bochet
3c5a4ba692
Handle Network errors in messaging sync (#5795)
In this PR, I'm doing 2 things:
- refresh connectedAccount token on message-list-fetch. It's currently
only refresh while doing the messages-import. However messages-import
stage are only triggered if new messages are detected (which could take
days or week depending of the messageChannel activity). We should also
refresh it while trying to fetch the list
- handle Unhandled Gmail error code 500 with reason "backendError".
These can occur on gmail side. In this case, we just retry later.
2024-06-09 22:46:11 +02:00
Charles Bochet
01c0378b7a Handle Network errors in messaging sync 2024-06-09 09:59:55 +02:00
Charles Bochet
e4a4499b79 Fix messaging sharing inconsitency 2024-06-09 01:27:43 +02:00
Charles Bochet
9ebf7a61ab Remove threadId defined assertion as it could not be in messaging sync 2024-06-09 00:56:59 +02:00