Commit Graph

838 Commits

Author SHA1 Message Date
Raphaël Bosi
08c7947b3b
Use twentyORM in Timeline messaging (#6595)
- Remove raw queries and replace them by using `twentyORM`
- Refactor into services and utils

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-15 10:15:32 +02:00
Thomas Trompette
6927f46e1c
Migrate to workspace services (#6628)
As title
2024-08-14 18:46:36 +02:00
Thomas Trompette
9e7714e627
Add workflow run entity (#6622)
- create a workflow run every time a workflow is triggered in
not_started status. This status will be helpful later for once workflows
will be scheduled
- update run status once workflow starts running
- complete status once the workflow finished running
- add a failed status if an error occurs
2024-08-14 18:27:32 +02:00
Thomas Trompette
0f75e14ab2
Create default view for workflows + fix task and note targets (#6620)
As title
2024-08-14 12:04:41 +02:00
Raphaël Bosi
d1c278d6b2
6430 Part 1: remove all raw queries from the messaging and calendar modules (#6572)
Part 1 of #6430
- Remove all repositories which contained raw queries in `messaging`
module
- Replace them using `twentyORMManager`
2024-08-13 19:40:50 +02:00
Raphaël Bosi
40bbee8d9f
5x Fix cache performance issues (#6616)
Calling `getObjectMetadata` from `WorkspaceCacheStorageService` in every
query was causing big performance issues. The `objectMetadataCollection`
is now part of the `WorkspaceInternalContext` so we only instance it
once in the `WorkspaceDatasourceFactory`.
Queries are now much faster, for instance for TimelineCalendar, it went
from ~450ms to 80ms.
2024-08-13 17:54:55 +02:00
BOHEUS
65a961ff3e
Fix for #6597 Created by field can't have null value (#6614)
Fix for #6597
2024-08-13 09:07:50 +02:00
Félix Malfait
d5350e11a3
Remove some dead code (#6611)
We could remove a lot more than this, this is just a start.

There are various tools to help with this, knip is a good one
2024-08-11 20:43:18 +02:00
Weiko
bdac4c81f7
Improve QueryFailedError message in sync-metadata (#6591)
Adding more logs with Typeorm QueryFailedError in sync-metadata command

Example with a unicity constraint violation, to identify which column is
affected
<img width="841" alt="Screenshot 2024-08-09 at 14 56 05"
src="https://github.com/user-attachments/assets/c47fbb1d-77ee-4d7a-87e7-dbe54a6aa941">

In this case, this should help self-hosting users to know which key is a
duplicate during syncs after a version upgrade for example
2024-08-09 16:23:14 +02:00
Weiko
6792056b73
Fix query runner exceptions not being handled properly (#6593)
## Context

We recently introduced a try catch in the different resolvers of the
query runner to handle exceptions via
workspaceQueryRunnerGraphqlApiExceptionHandler and convert them to
proper errors. However this was never called as expected because query
runner methods were async.
This is a regression from https://github.com/twentyhq/twenty/pull/6324

## Before

<img width="938" alt="Screenshot 2024-08-09 at 15 34 02"
src="https://github.com/user-attachments/assets/3607c7ed-ea91-4729-a4e4-ede7761347e2">


## After

<img width="905" alt="Screenshot 2024-08-09 at 15 33 46"
src="https://github.com/user-attachments/assets/51bcbfa1-9b0b-4c7c-84a2-7c8effeadddd">
2024-08-09 16:07:58 +02:00
Weiko
b1aa115d28
Fix auth exceptions (#6590)
A regression has been introduced in
https://github.com/twentyhq/twenty/pull/6459/files#diff-0a06bf2b624f77f1b7ded0fcc4ce266d1a56f4329222b46d1cf4d76a18000c97L505
where 401 have been changed to 403. However the renew token logic on the
FE expects a 401, see here
https://github.com/twentyhq/twenty/blob/main/packages/twenty-front/src/modules/apollo/services/apollo.factory.ts#L100

I've also introduced a fix with a proxy class in
GraphQLHydrateRequestFromTokenMiddleware since this middleware calls
validateToken from tokenService which are never converted back to
graphqlErrors so handleExceptionAndConvertToGraphQLError below will
receive an AuthException and will send capture it and return it as a 500

both issues have been fixed and should resolve the renewToken logic 

## Test
tested locally by playing with token expiration dates in the env

<img width="635" alt="Screenshot 2024-08-09 at 12 47 05"
src="https://github.com/user-attachments/assets/e93d5741-29b7-4699-b882-ee8f4fee6e6e">
2024-08-09 14:09:26 +02:00
Félix Malfait
7e01843aaf
Remove dead code linked to quick actions (#6587)
Removing dead code, we'll take another approach to build this
2024-08-09 11:09:26 +02:00
gitstart-app[bot]
a2a5ab488c
When exporting a kanban we should export the kanban's main field (#6444)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-6046](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6046).
This ticket was imported from:
[TWNTY-6046](https://github.com/twentyhq/twenty/issues/6046)

 --- 

### Description

- We are getting the `kanbanFieldMetadataNameState` , get the column
data, and if there is data and the use is on the Kanban view we add the
data to the result

### Refs

#6046

### Demo

<https://jam.dev/c/96f16211-40e4-4b49-a6f5-88f0692fb47a>

Fixes #6046

---------

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: Félix Malfait <felix.malfait@gmail.com>
2024-08-09 10:23:06 +02:00
Félix Malfait
f2cc385710
Fix frontend tests (#6585)
Fix a few broken tests
2024-08-09 08:38:01 +02:00
Faisal-imtiyaz123
b4e2ada3b0
Fixes Empty Label Identifer Preview in Settings/DataModel/Object/Edit (#6370)
fixes #6143

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-08-08 18:30:02 +02:00
Thomas Trompette
12e55fd5b7
Bump version to 0.23.1 (#6567)
As title

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-07 17:09:30 +02:00
martmull
10817c5388
Fix onboarding status refacto (#6533)
see comments in
https://github.com/twentyhq/twenty/pull/6531#pullrequestreview-2217807413
- rename method
- add check before setting create profile pending user var
2024-08-07 17:09:11 +02:00
Jérémy M
11a41b3d97
feat: created by email calendar (#6536)
This PR is a followup of #6324 to add support of EMAIL and CALENDAR
source for the created by composite field.
2024-08-07 15:03:06 +02:00
Weiko
dce5a64ec5
Fix images in note rich text (#6550)
## Before
<img width="439" alt="Screenshot 2024-08-06 at 11 20 06"
src="https://github.com/user-attachments/assets/d2aa9411-cdf4-4457-8997-7cbecb8fe7e3">

## After
<img width="501" alt="Screenshot 2024-08-06 at 11 20 09"
src="https://github.com/user-attachments/assets/a5a68fff-1542-4b62-939c-50070f15b692">
2024-08-07 11:45:17 +02:00
bosiraphael
5a72b949d7
6382 create a command to add a uservar in the key value pair table for every account which needs to reconnect (#6553)
Closes #6382

Create SetUserVarsAccountsToReconnectCommand.
This command loops on all workspaces and:
- deletes all user vars with deprecated key `ACCOUNTS_TO_RECONNECT`
- creates a key value pair of type `USER_VAR` with a key of
`ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS` for all connect
accounts with a message channel or calendar channel with status
`FAILED_INSUFFICIENT_PERMISSIONS`
2024-08-07 11:43:18 +02:00
Thomas Trompette
2abb6adb61
Build exceptions and handler (#6459)
Adding exceptions and handler for auth services.

Tested with:
- Workspace creation
- Workspace signup
- Workspace invitation
- Reset password
- Adding email account
- Impersonation

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-07 11:42:49 +02:00
bosiraphael
018b8220dc
Remove message thread id from mcma and update scripts (#6500)
- Remove `messageThreadId` from `messageChannelMessageAssociation`
- Update thread merging
- Update all queries which were dependent on this field
- Update some raw queries by using `twentyORM` instead

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-06 18:19:59 +02:00
Weiko
48d0a3649d
Remove fileService getFileStream fallback after completed migration (#6558)
To merge once the command has been executed.
2024-08-06 18:19:50 +02:00
Félix Malfait
4157a67bf8
Fix permissions for serverless functions (#6555)
Fixes #6525

(@martmull fyi it was not related to AWS but linked to the fact that we
recently enforced passing a token to access files)
2024-08-06 15:31:22 +02:00
Charles Bochet
1b9d2c8151
Release 0.23 (#6547)
Here we go!
https://twenty.com/releases
2024-08-05 23:18:44 +02:00
Charles Bochet
8373dfdc26
Webhook wip (#6371)
This PR introduces the following changes:
- Add the ability to filter webhooks by objectSingularName and Actions
- Refactor SettingsWebhookDetails edition to not use react-hook-form
(which will be deprecated on the whole project)
- Updating the tests with a complex set of mock (we just need to fix ~30
of them now :D)

<img width="1053" alt="image"
src="https://github.com/user-attachments/assets/4e56d972-f129-4789-8d1c-4b5797a8ffd7">
2024-08-05 23:14:29 +02:00
Prateek Jain
48f4e41148
Add custom field types on seed (#6505)
Fixes #6364

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-05 18:19:19 +02:00
bosiraphael
2073d8e6e1
6446 improve information banner component to make it scale better (#6545)
Closes #6446
2024-08-05 16:00:52 +02:00
Charles Bochet
2b311b5f7b
Update standard fields (#6532)
In this PR:
- adding Favorites to Tasks and Notes
- fixing inconsistencies between custom object creation and sync of
standard fields of custom objects
- fixing workspaceCacheVersion not used to invalidate existing
datasource
2024-08-04 23:22:41 +02:00
Charles Bochet
03204021cb
Refactor onboarding user vars to be absent when user is fully onboarded (#6531)
In this PR:
- take feedbacks from: https://github.com/twentyhq/twenty/pull/6530 /
https://github.com/twentyhq/twenty/pull/6529 /
https://github.com/twentyhq/twenty/pull/6526 /
https://github.com/twentyhq/twenty/pull/6512
- refactor onboarding uservars to be absent when the user is fully
onboarded: isStepComplete ==> isStepIncomplete
- introduce a new workspace.activationStatus: CREATION_ONGOING

I'm retesting the whole flow:
- with/without BILLING
- sign in with/without SSO
- sign up with/without SSO
- another workspaceMembers join the team
- subscriptionCanceled
- access to billingPortal
2024-08-04 20:37:36 +02:00
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