Commit Graph

920 Commits

Author SHA1 Message Date
Thomas Trompette
b1cb8998f8
Backfill workspace favorites (#7122)
- command to backfill workspace favorites
- create workspace favorites on workspace activation
- create workspace favorites on demo seed

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-18 18:26:55 +02:00
Charles Bochet
759eb3070e
Improve demo seed (#7125)
We have a few issues on demo seeding:
- redis metdata cache was not flushed
- server ram graphql schema cache was not cleared on metadata version
increment
2024-09-18 17:35:08 +02:00
Thomas Trompette
741a969cc1
Add fail on metadata cache miss (#7118)
- avoid failing when missing cache (used for command)
- remove unused load cache function. Cache will be always re-created
when trying to fetch if not existing
2024-09-18 15:40:24 +02:00
Weiko
999974893c
Fix race condition with datasource creation (#7106)
## Context
We currently have a race condition when dealing with datasource
creation. This happen when multiple queries arrive at the same time (for
example graphql dataloaders) and the datasource is not created yet.
Since the datasource is stored in memory this can happen more often as
well and they were all triggering the datasource creation at the same
time.

I'm trying to fix the issue with promise memoization. Now, instead of
caching the datasource only, we also want to cache the promise of the
datasource creation and make the creation itself synchronous.

More info about promise memoization in this article for example:
https://www.jonmellman.com/posts/promise-memoization

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
2024-09-18 14:01:55 +02:00
Charles Bochet
9c885861a3 Add logs to troubleshoot performances issues 2024-09-18 00:10:35 +02:00
Raphaël Bosi
7cdf2dc4ec
7092 destroy connected account instead of soft deleting it (#7099)
- Create `destroyOne` endpoint
- Call `destroyOne` when removing a `connectedAccount`
2024-09-17 18:30:40 +02:00
Marie
dcac832616
[Emails migration] Fix email field migration (#7065)
Fix email field migration

- Remove deprecated field of type Email
- Add standard emails field on person to person views in position 4
2024-09-16 19:35:13 +02:00
Raphaël Bosi
f1264fda76
Fix: Set sync stage started at when starting sync (#7046)
Fix:`syncStageStartedAt` was not set correctly after refactoring
2024-09-16 15:10:53 +02:00
Raphaël Bosi
833832525c
Create command to set stale message sync back to pending (#7048)
Some message channels are stuck in an ongoing `syncStage` because
`syncStartedAt` was not set correctly at the beginning of the sync.
This command resets message channels with an ongoing `syncStage` and
`syncStartedAt` set to null.
2024-09-16 15:10:42 +02:00
gitstart-app[bot]
8208a3e976
Introduce ARRAY field type (#6862)
This PR was created by \[GitStart\](<https://gitstart.com/>) to address
the requirements from this ticket:
\[TWNTY-6447\](<https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6447>).

This ticket was imported from:
<https://github.com/twentyhq/twenty/issues/6447>

### Description

\- We added a new field type

### Refs

#6447

### Demo

<https://jam.dev/c/2b4d7853-ea89-4e9d-a561-6edcb4fdb34b>

Fixes #6447

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-16 14:07:55 +02:00
Weiko
bc99cfec98
0-30-set-custom-object-is-soft-deletable.command (#7045)
This command was supposed to set all custom objects as softDeletable.
After some discussion we realised this bool was not used as intended so
we are removing it all together until we find a better usage (remote
objects for example). This PR removes the command which won't be needed
anymore
2024-09-16 13:53:27 +02:00
Weiko
31dea498e9 Remove objectMetadata isSoftDeletable 2024-09-16 13:40:10 +02:00
Weiko
37d85a716a
[flexible-schema] Add createOne/createMany with upsert to graphql query runner (#7041)
## Context
This PR introduces createOne/createMany through the new graphql query
runner.
Trying to use twentyOrm wrapper as much as possible, in this case here
the args are already converted from "metadata-like" structure (including
composite fields) as graphql input to typeorm / raw columns (I had to
introduce a little fix there).

Keep in mind that I'm not using the new graphql query runner parsing
classes here, especially the selected-fields part, because typeorm
already returns all the record columns in the InsertResult object
(including default values such as id, createdAt, ...). That also means
relation objects will be returned as NULL in the gql response but we
don't handle nested creation for the moment so it should be fine.

Note: also removing the feature flag from findOne/findMany
2024-09-16 12:20:04 +02:00
Charles Bochet
872f52990a
Optimize migrate-email-fields-command (#7035)
Quick follow up to prepare for 0.30 release
2024-09-15 13:13:35 +02:00
Charles Bochet
f54eea0227
Optimize sync, reset, seed commands to flush cache and to use less memory (#7034)
In this PR:
- removing ugprade-0.24 commands as we are releasing 0.30
- introducing cache:flush command
- refactoring upgrade command and sync-metadata command to use the
ActiveWorkspacesCommand so they consistently run on all workspaces or
selected workspaces

Fixes:
- clear localStorage on sign out
- fix missing workspaceMember in verify resolver
- do not throw on datasource already destroyed exception which can
happen with race condition when several resolvers are resolving in
parallel
2024-09-15 12:47:45 +02:00
Charles Bochet
a18b998bed Fix emailThread not loading and rest batch api forbidden 2024-09-14 02:34:40 +02:00
Charles Bochet
8588612cee Fix billing services not accepting new subscriptions 2024-09-13 20:01:18 +02:00
Charles Bochet
523df5398a Optimize metadata queries (#7013)
In this PR:

1. Refactor guards to avoid duplicated queries: WorkspaceAuthGuard and
UserAuthGuard only check for existence of workspace and user in the
request without querying the database
2024-09-13 19:42:22 +02:00
Weiko
7fd86a860c
[metadata] fix soft delete for standard objects missing deletedAt fieldMetadata (#7017)
This https://github.com/twentyhq/twenty/pull/7006 introduced a
regression.

The goal was to set "isSoftDeletable" to all standard objects but it was
done at the wrong level, meaning it was setting the boolean correctly
but not creating the corresponding fieldMetadata.

I took the occasion to update the new graphql query runner to use that
boolean and automatically add a filter on soft delete in case it's true.

Also adding **IsQueryRunnerTwentyORMEnabled** by default in the seeds
2024-09-13 12:03:27 +02:00
gitstart-app[bot]
31c02202bd
Handle migration of Email to Emails fields (#6885)
This is the second PR on TWNTY-6261 which handlesdata migration of Email
field to Emails field.\
\
How to Test?\
Firstly make sure that you have completed the testing steps on first PR
then follow the below steps:

- Checkout to TWNTY-6261-emails-migrations branch
- Rebuild typescript using "npx nx build twenty-server"
- Run command "yarn command:prod upgrade-0.25" to do migration\
  \
  Loom Video:\

<https://www.loom.com/share/f82b8d29f8f64f92abe3c59c01147b45?sid=9f8ccc05-aa38-4c49-b139-fd0823066273>

**Testing Messaging Sync functionality:**

Please watch the below video to see that the synchronization of contacts
is working fine after migrating Email field to Emails field:\

<https://www.loom.com/share/400949464b244272b78c25e338cc6ab2?sid=103f6625-5933-4b99-9825-0fed33782f36>

**Question to the client**

should we rename email to emails here? in the DomainName PR, the name
did not change.

```typescript
  @WorkspaceField({
    standardId: PERSON_STANDARD_FIELD_IDS.email,
    type: FieldMetadataType.EMAILS,
    label: 'Email',
    description: 'Contact’s Email',
    icon: 'IconMail',
  })
  email: EmailsMetadata;
```

**Test Messaging Sync**

This pr will update messaging sync files so the changes shouldn't break
existing functionality of importing people and companies in the app.\
To test messaging sync you should follow the below steps:\
1. you need to connect a google account to see the importing
functionality. For this purpose you

have to create a project inside Google Cloud. But to make things easier
you can use the below credentials of an already created project. Put
them in .env of twenty-server package:

```properties
MESSAGING_PROVIDER_GMAIL_ENABLED=true
CALENDAR_PROVIDER_GOOGLE_ENABLED=true
AUTH_GOOGLE_ENABLED=true
AUTH_GOOGLE_CLIENT_ID=951231465939-h61tg6nkpkv1821qi899fjbj9looquto.apps.googleusercontent.com
AUTH_GOOGLE_CLIENT_SECRET=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
AUTH_GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/redirect
AUTH_GOOGLE_APIS_CALLBACK_URL=http://localhost:3000/auth/google-apis/get-access-token
MESSAGE_QUEUE_TYPE=bull-mq
```

Alternative env

```properties
MESSAGING_PROVIDER_GMAIL_ENABLED=true
CALENDAR_PROVIDER_GOOGLE_ENABLED=true
AUTH_GOOGLE_ENABLED=true
AUTH_GOOGLE_CLIENT_ID=622006708006-dc4n3vrtf3cs2h6k7hgbborudme7ku9l.apps.googleusercontent.com
AUTH_GOOGLE_CLIENT_SECRET=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
AUTH_GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/redirect
AUTH_GOOGLE_APIS_CALLBACK_URL=http://localhost:3000/auth/google-apis/get-access-token
MESSAGE_QUEUE_TYPE=bull-mq
```

1. Launch your worker with `npx nx run twenty-server:worker`
2. npx nx run twenty-server:command cron:messaging:messages-import
3. npx nx run twenty-server:command cron:messaging:message-list-fetch
4. npx nx run twenty-server:command
cron📆calendar-event-list-fetch
5. Run the app and navigate to Settings/Accounts then connect your
Google account

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
Co-authored-by: Weiko <corentin@twenty.com>
2024-09-12 18:31:11 +02:00
Baptiste Devessier
3548751be2
Scaffold empty workflow (#6926)
- Create a workflow version when the user visits an empty workflow.
- If the trigger is not defined yet and the user selects either the
standard object type or the event type first, we automatically select
the first option of the other value. Indeed, every state update is
automatically saved on the backend and we need both standard object and
event types to save the event name.
- Introduces a change in the backend. I removed the assertions that
throw when a workflow version is not complete, that is, when it doesn't
have a defined trigger, which is the case when scaffolding a new
workflow with a first empty workflow version.
- We should keep validating the workflow versions, at least when we
publish them. That should be done in a second step.
2024-09-12 17:01:10 +02:00
Charles Bochet
3c4168759a Refactor metadata caching (#7011)
This PR introduces the following changes:
- add the metadataVersion to all our metadata cache keys to ease
troubleshooting:
<img width="1146" alt="image"
src="https://github.com/user-attachments/assets/8427805b-e07f-465e-9e69-1403652c8b12">
- introduce a cache recompute lock to avoid overloading the database to
recompute the cache many time
2024-09-12 16:06:19 +02:00
Weiko
9b46e8c663
Set all standard objects soft deletable (#7006) 2024-09-12 13:44:48 +02:00
martmull
3190f4a87b
6658 workflows add a first twenty piece email sender (#6965) 2024-09-12 11:00:25 +02:00
Félix Malfait
f8e5b333d9
Add relations to notes/tasks list view (#6971)
<img width="664" alt="Screenshot 2024-09-10 at 17 00 11"
src="https://github.com/user-attachments/assets/37132805-ff67-4d28-b664-b03da680e166">

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-09-12 10:50:49 +02:00
Weiko
725ee837f9
Refactor graphql query runner + fix nested or (#6986) 2024-09-11 14:22:33 +02:00
Weiko
1317e1c4f2
[Flexible-schema] Add findOne and fix findMany pagination + soft-delete for graphql-query-runner (#6978) 2024-09-11 11:29:56 +02:00
gitstart-app[bot]
846953b0f4
Support for multiple values in the Phone field (#6882)
### Description

- This is the first PR on Phones field;


- We are introducing new field type(Phones)


- We are Forbidding creation of Phone field


- We Added support for filtering and sorting on Phones field


- We are using the same display mode as used on the Links field type
(chips), check the Domain field of the Company object


- We are also using the same logic of the link when editing the field

**How to Test**

1. Checkout to TWNTY-6260 branch
2. Reset database using "npx nx database:reset twenty-server" command
3. Add custom field of type Phones in settings/data-model

**Loom Video:**\

<https://www.loom.com/share/3c981260be254dcf851256d020a20ab0?sid=58507361-3a3b-452c-9de8-b5b1abda70ac>

### Refs

#6260

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
2024-09-11 11:15:04 +02:00
Weiko
ace0f7b515
Bump version to 0.24.2 (#6955) 2024-09-09 18:45:45 +02:00
Thomas Trompette
78d8df6a68
Add workspace favorites behind feature flag (#6904)
- make member nullable on favorites
- add potential relation with view entity
- add a new type of favorite list in front : workspace favorite
- build a new component for retrieving workspace favorite to display +
refacto the existing one

Bonus:
- removing activities seed since this is deprecated
2024-09-05 16:41:06 +02:00
Félix Malfait
bc8c961e30
Fix restore event sent to webhooks (#6905)
We were sending the wrong event when restoring a record (delete instead
of create)
2024-09-05 14:21:14 +02:00
martmull
c55dfbde6e
Fix unauthorized error handling (#6835)
from @BOHEUS comments in #6640
- fix bad 500 error when authentication invalid 
- remove "id", "createdAt", "updatedAt", etc from creation and update
paths schema
- improve error message 
- remove "id" from test body
- improve secondaryLink schema description
- improve depth parameter description
- remove required from response body
- improve examples
- improve error message formatting
- fix filter by position
- answered to negative float position @BOHEUS comment

Also:
- fix secondary field openapi field description
- remove schema display in playground

Screenshots

![image](https://github.com/user-attachments/assets/a5d52afd-ab10-49f3-8806-ee41b04bc775)

![image](https://github.com/user-attachments/assets/33f985bb-ff75-42f6-a0bb-741bd32a1d08)
2024-09-04 17:25:59 +02:00
PB Borel
0c2657eea6
fix(6423): add username and password for redis connection (#6745)
Co-authored-by: pbb <pierre-bertrand.borel_ext@michelin.com>
2024-09-04 16:56:37 +02:00
Thomas Trompette
44ff55f550
Enable payload without status update (#6881)
As title
2024-09-03 17:24:29 +02:00
Thomas Trompette
50a65ef46b
Add workflow query hooks (#6876)
Workflow version :
- prevent status to be update manually
- prevent creation / deletion in another status than draft
- prevent creation if a draft already exists

Workflow:
- prevent statuses to set manually

WorkflowRun:
- prevent all manual operations
2024-09-03 17:07:22 +02:00
Weiko
612428eeb3
update refresh token expires in (#6879)
Fixes https://github.com/twentyhq/twenty/issues/6598

Updating the refresh token default value to a much more common
threshold, this can still be overridden with env variables when needed.

Example of the refresh token mechanism from the fronted side
<img width="679" alt="Screenshot 2024-09-03 at 16 05 12"
src="https://github.com/user-attachments/assets/7e618ab1-12b9-48cb-a93e-e27974ad2425">
<img width="673" alt="Screenshot 2024-09-03 at 16 05 22"
src="https://github.com/user-attachments/assets/f4d08315-1f5b-4f4a-a86a-a9cd9cdf9b01">
2024-09-03 17:00:19 +02:00
Nabhag Motivaras
6e7cb27af2
fix: securing tasks and notes all view (#6869)
ISSUE 

- Closes #6863
2024-09-03 09:16:42 +02:00
Thomas Trompette
329e7364a4
Prevent workflow version from bad update (#6848)
Closes https://github.com/twentyhq/twenty/issues/6840

- Add query-hooks folder in common. Will be followed by hooks for
workflows and runs
- When updating a version, ensure the status is draft and that the
status is not manually updated
2024-09-02 16:20:20 +02:00
martmull
7e03419c16
Serverless function improvements (#6769)
- add layer for lambda execution
- add layer for local execution
- add package resolve for the monaco editor
- add route to get installed package for serverless functions
- add layer versioning
2024-09-02 15:25:20 +02:00
Marie
96d659cf56 Make custom objects soft deletable by default (#6768)
Fixes #6766
2024-08-31 18:02:41 +02:00
Weiko
7df5f91dc5
Add set custom object is soft deletable command (#6788)
## Context
Custom object were not automatically created as softDeletable, this has
been fixed in a recent PR.
This PR adds a command to backfill existing custom objects.

We also introduce a baseCommandRunner and ActiveWorkspacesCommandRunner
to put some boilerplate and simplify future commands.

## Test
```bash
yarn command:prod upgrade-0-24:set-custom-object-is-soft-deletable
[Nest] 75852  - 08/29/2024, 5:16:41 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Running command on 2 workspaces
query: UPDATE "metadata"."objectMetadata" SET "isSoftDeletable" = $1, "updatedAt" = CURRENT_TIMESTAMP WHERE ("workspaceId" IN ($2, $3) AND "isCustom" = $4 AND "isSoftDeletable" = $5) -- PARAMETERS: [true,"3b8e6458-5fc1-4e63-8563-008ccddaa6db","20202020-1c25-4d02-bf25-6aeccf7ea419",true,false]
[Nest] 75852  - 08/29/2024, 5:16:41 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Updated 1 entities
[Nest] 75852  - 08/29/2024, 5:16:41 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Command completed!
```

```bash
yarn command:prod upgrade-0-24:set-custom-object-is-soft-deletable -d
[Nest] 75424  - 08/29/2024, 5:16:14 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Running command on 2 workspaces
[Nest] 75424  - 08/29/2024, 5:16:14 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Dry run mode: No changes will be applied
query: SELECT "ObjectMetadataEntity"."id" AS "ObjectMetadataEntity_id" FROM "metadata"."objectMetadata" "ObjectMetadataEntity" WHERE (("ObjectMetadataEntity"."workspaceId" IN ($1, $2)) AND ("ObjectMetadataEntity"."isCustom" = $3) AND ("ObjectMetadataEntity"."isSoftDeletable" = $4)) -- PARAMETERS: ["3b8e6458-5fc1-4e63-8563-008ccddaa6db","20202020-1c25-4d02-bf25-6aeccf7ea419",true,false]
[Nest] 75424  - 08/29/2024, 5:16:14 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Dry run: 1 entities would be updated
[Nest] 75424  - 08/29/2024, 5:16:14 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Command completed!
```

```bash
yarn command:prod upgrade-0-24:set-custom-object-is-soft-deletable -w 20202020-1c25-4d02-bf25-6aeccf7ea419 -w 20202020-1c25-4d02-bf25-6aeccf7ea419
query: UPDATE "metadata"."objectMetadata" SET "isSoftDeletable" = $1, "updatedAt" = CURRENT_TIMESTAMP WHERE ("workspaceId" IN ($2, $3) AND "isCustom" = $4) -- PARAMETERS: [true,"20202020-1c25-4d02-bf25-6aeccf7ea419","20202020-1c25-4d02-bf25-6aeccf7ea419",true]
[Nest] 70588  - 08/29/2024, 5:11:31 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Updated 2 entities
[Nest] 70588  - 08/29/2024, 5:11:31 PM     LOG [SetCustomObjectIsSoftDeletableCommand] Command completed!
```

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-31 17:49:12 +02:00
Raphaël Bosi
cd66ea74a2
6657 Refactor and fix blocklist (#6803)
Closes #6657
- Fix listeners
- Refactor jobs to take array of events
- Fix calendar events and messages deletion

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-31 16:38:47 +02:00
Thomas Trompette
a3ea0acd1a
Set statuses on workflows (#6792)
Add listener to keep status on workflows up to date:
- version draft => statuses should contain draft
- version active => statuses should contain active
- version deactivated => if no version active, statuses should contain
deactivated

Renaming also the endpoints because it was not reflecting the full
behaviour.

Finally, adding a new status Archived for versions. Will be used when a
version is deactivated, but is not the last published version anymore.
It means this version cannot be re-activated.
2024-08-30 18:06:04 +02:00
Thomas Trompette
8982a5833c
Bump version to 0.24 (#6789)
As title
2024-08-29 18:22:48 +02:00
Antoine Moreaux
cd06ae20e8
chore(*): remove unused code (#6781)
The code removed in the PR was flagged as unused by the JetBrains
inspector.

I did a QA on the dev environment but other checks are highly
recommended.

There is one commit by scope to make the review easier.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-29 18:16:50 +02:00
gitstart-app[bot]
7a9a43b85c
Add composite Emails field and forbid creation of Email field type (#6689)
### Description

1. 
   - We are introducing new field type(Emails)


   - We are Forbiding creation of Email field


   - We Added support for filtering and sorting on Emails field


- We are using the same display mode as used on the Links field type
(chips), check the Domain field of the Company object


   - We are also using the same logic of the link when editing the field

   \
   How To Test\
   Follow the below steps for testing locally:\
   1. Checkout to TWENTY-6261\
2. Reset database using "npx nx database:reset twenty-server" command\
   3. Run both the backend and frontend app\
4. Go to Settings/Data model and choose one of the standard objects like
people\
   5. Click on Add Field button and choose Emails as the field type

   \
   ### Refs

   #6261\
   \
   ### Demo

    \

<https://www.loom.com/share/22979acac8134ed390fef93cc56fe07c?sid=adafba94-840d-4f01-872c-dc9ec256d987>

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
2024-08-29 11:42:24 +02:00
Weiko
c87ccfa3c7
refactor graphql query runner connection mapper (#6771) 2024-08-28 19:02:45 +02:00
Raphaël Bosi
e7bbc7ddfc
Fix participant listeners (#6767)
Fixes a bug where all the messagesParticipants and the
calendarEventParticipants were linked to a contact after its
restoration.
2024-08-28 16:26:08 +02:00
Thomas Trompette
ff1adb06b2
Add workflow statuses (#6765)
Following figma updates
https://www.figma.com/design/PNBfTgOVraw557OXChYagk/Explo?node-id=21872-7929&t=DOUzd6rzwr6lprcs-0

- No activity targets for workflow entities for now
- Adding a direct relation between workflow run et workflow
- Adding a status on the version (draft, active, deactivated)
- Adding a list of statuses on workflow 
- publishedVersionId => lastPublishedVersionId

Also adding:
- the endpoint to deactivate a version
2024-08-28 14:53:25 +02:00
Raphaël Bosi
da23ca3c23
Fix message direction seeds (#6760)
Direction is now on mcma and no longer on message
2024-08-28 13:03:00 +02:00