Commit Graph

990 Commits

Author SHA1 Message Date
Félix Malfait
8d496902b7
Fix linter (#7191)
Fix linter
2024-09-21 07:02:40 +02:00
Subham Sharma
4ed1eb581a
Set a unique constraint on email table in users #7180 (#7184)
Link to issue - https://github.com/twentyhq/twenty/issues/7180

File changed -
twenty/packages/twenty-server/src/engine/core-modules/user/user.entity.ts

---------

Co-authored-by: subham sharma <subham.sharma@smartbear.com>
Co-authored-by: Félix Malfait <felix@twenty.com>
2024-09-21 06:37:55 +02:00
Félix Malfait
6d5d73fbe8
Improve snackbar and fix sentry (#7181)
- Improve snackbar to enable displaying multi-line message (so far we
only displayed the first few words which was very frustrating)

- Followup on previous issue to enable tim@apple.dev on the demo
workspace (prefilled automatically)

- Fix sentry tracing which had been broken when migrating from v7 to v8
2024-09-21 06:33:15 +02:00
Raphaël Bosi
20d06b3c0f
7182 person avatar is not the same color in emails and calendar (#7185)
Fixes #7182 and displayName in calendar
2024-09-21 00:35:39 +02:00
Weiko
bebeb1515b
Add indexes to custom relations (#7156)
TODO: command to retro-actively create indexes to existing custom
objects
2024-09-20 15:06:26 +02:00
Félix Malfait
f845187f8e
Change demo account email (#7177)
Change the demo account's email to be able to set SIGN_IN_PREFIL = true
on demo.twenty.com
2024-09-20 13:55:46 +02:00
Jérémy M
eef7f1661d
feat: add integration tests (#6923)
### Summary

This PR introduces several integration tests, a mix of manually written
tests and those generated using the `generate-integration-tests` Python
script located in the `scripts` folder.

### Tests Added:
- **Authentication tests**: Validating login, registration, and token
handling.
- **FindMany queries**: Fetching multiple records for all existing
entities that do not require input arguments.

### How the Integration Tests Work:
- A `setupTest` function is called during the Jest test run. This
function initializes a test instance of the application and exposes it
on a dedicated port.
- Since tests are executed in isolated workers, they do not have direct
access to the in-memory app instance. Instead, the tests query the
application through the exposed port.
- A static accessToken is used, this one as a big expiration time so it
will never expire (365 years)
- The queries are executed, and the results are validated against
expected outcomes.

### Current State and Next Steps:
- These tests currently run using the existing development seed data. We
plan to introduce more comprehensive test data using `faker` to improve
coverage.
- At the moment, the only mutation tests implemented are for
authentication. Future updates should include broader mutation testing
for other entities.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-20 11:02:52 +02:00
Charles Bochet
7781d70bb8
Fix CSV export missing last page (#7167) 2024-09-20 05:42:59 +02:00
Weiko
b1889e4569
Fix nested relations (#7158)
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-20 05:16:13 +02:00
Raphaël Bosi
6a5f9492d3
7142 make messaging full message list fetch idempotent (#7148)
- Add message deletion and thread cleaning during full message list
fetch
- Add thread cleaning  during partial message list fetch
- Delete provider from cache key
2024-09-19 18:32:25 +02:00
Thomas Trompette
8964d26d5b
Clean views without object metadata (#7153)
Add command for cleaning + clean on object deletion
2024-09-19 18:13:07 +02:00
Félix Malfait
3025ac346c
Upgrade sentry (#7145)
Upgrave Sentry to v8 and add Sentry Cron monitoring

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-19 18:09:24 +02:00
gitstart-app[bot]
b3ed6cb903
[Bug] Select options names can't start with a number (#7079)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-6980](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6980).
This ticket was imported from:
[TWNTY-6980](https://github.com/twentyhq/twenty/issues/6980)

 --- 

### Description

- **fix**: added a transformation step that prefixes the newly added
option with an underscore before the Graphql enum is generated so it
saves successfully and passes the default GraphQL validation.

### Demo

- <https://www.loom.com/share/feda2198ed8b4e558f96520a0d051725>

### Refs

#6980

Fixes #6980

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Weiko <corentin@twenty.com>
2024-09-19 14:05:28 +02:00
Weiko
e0ada0a8ee
Add deletedAt to foreignKey indexes (#7133)
We had to remove soft-deletion on default filters due to the missing
indexes. We now generate composite indexes with the foreign key
containing the deletedAt column as well which should improve
performances
2024-09-19 11:23:40 +02:00
Antoine Moreaux
89c97993e3
feat(invitation): Improve invitation flow - Milestone 2 (#6804)
From PR: #6626 
Resolves #6763 
Resolves #6055 
Resolves #6782

## GTK
I retain the 'Invite by link' feature to prevent any breaking changes.
We could make the invitation by link optional through an admin setting,
allowing users to rely solely on personal invitations.

## Todo
- [x] Add an expiration date to an invitation
- [x] Allow to renew an invitation to postpone the expiration date
- [x] Refresh the UI
- [x] Add the new personal token in the link sent to new user
- [x] Display an error if a user tries to use an expired invitation
- [x] Display an error if a user uses another mail than the one in the
invitation

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-18 23:27:31 +02:00
Weiko
ad18c44f25
Improve perf during repository creation in nested relations (#7132) 2024-09-18 21:54:22 +02:00
Weiko
210c336ccf
Fix performance (#7131) 2024-09-18 21:15:30 +02:00
Weiko
41fe8f7fea
Fix nested relations with large dataset in find queries (#7127)
## Before
<img width="920" alt="before"
src="https://github.com/user-attachments/assets/4809556f-0459-4f56-a716-b969a943d492">

## After
<img width="920" alt="after"
src="https://github.com/user-attachments/assets/504186b2-d002-482d-bc3e-2dda45c314b1">
2024-09-18 20:06:04 +02:00
Raphaël Bosi
1d56ace2af
Fix sync statuses on the fe (#7117)
Follows #6685
2024-09-18 18:46:39 +02:00
Weiko
02618b3e6a Fix graphql query createMany resolver with nested relations (#7061)
Looks like insert() does not return foreign keys. We could eventually
call findMany after but it seems that's what save() is doing so I'm
replacing insert with save.
```typescript
/**
 * Flag to determine whether the entity that is being persisted
 * should be reloaded during the persistence operation.
 *
 * It will work only on databases which does not support RETURNING / OUTPUT statement.
 * Enabled by default.
 */
reload?: boolean;
```

Note: save() also does an upsert by default with no way to configure
that so if we want to keep that behaviour we will need to add a check
before
```typescript
if (args.upsert) {
    const existingRecords = await repository.findBy({
      id: Any(args.data.map((record) => record.id)),
    });
    ...
```

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-18 18:45:52 +02:00
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
Charles Bochet
8dd772aee2 Fix post merge conflicts on messaging services 2024-08-27 19:30:25 +02:00
Raphaël Bosi
e6a55f270b
5617 Create CalendarOngoingStaleCron Job (#6748)
Closes #5617

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-27 19:13:15 +02:00
Raphaël Bosi
e771793626
6655 remove field direction in message and add it in mcma (#6743)
Closes #6655 
- Remove direction from message
- Add direction do mcma
- Create migration command
- Create upgrade 0.24
2024-08-27 19:11:04 +02:00
Thomas Trompette
9f69383aa2
Add function execution throttler (#6742)
Add throttler service to limit the number of function execution
2024-08-27 18:56:47 +02:00
Raphaël Bosi
81fa3f0c41
6256 refactor messaging module to remove all provider specific code and put it inside the drivers folders (#6721)
Closes #6256 
Closes #6257 
+ Create custom exceptions

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-27 18:14:45 +02:00
Weiko
f6fd92adcb
[POC] add graphql query runner (#6747)
## Context
The goal is to replace pg_graphql with our own ORM wrapper (TwentyORM).
This PR tries to add some parsing logic to convert graphql requests to
send to the ORM to replace pg_graphql implementation.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-27 17:06:39 +02:00
Charles Bochet
ef4f2e43b0
Fix Website build CD (#6751)
Website CD has been broken by the recent addition of typeorm patch in
root package.json

Our current vision is to add npm package to each twenty-package
package.json directly
2024-08-27 14:13:05 +02:00
gitstart-app[bot]
d61d5857f8
View becomes blank after deleting select (#6703)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-6027](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6027).
This ticket was imported from:
[TWNTY-6027](https://github.com/twentyhq/twenty/issues/6027)

 --- 

### Description

- Delete corresponding view simultaneously once select field is
deactivated instead of deleted because the bug happens on the
deactivation (one step before deleting), confirmation:
<https://discord.com/channels/1130383047699738754/1268662542172028971/1270367244509249651>
- Is still possible to create Kanban views with deactivated Select
fields, but this is not related to the PR.
- The changes on the frontend are for refreshing the data after the view
deletion

### Refs

#6027

### Demo


<https://www.loom.com/share/4f705344e3054cd5b3d5eadd398d2c9c?sid=8db3d8b9-4dce-4e31-8359-0e31cbc0e2e7>

Fixes #6027

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-27 11:10:32 +02:00
Charles Bochet
1d6a1f64c9
Fix twenty-front performances (#6744)
I have investigated the performance of our frontend vite build:
`npx nx run twenty:start` of `npx nx run twenty:build`

RAM usage:
- 160Mb: vite serve
- background typescript checker: 2.5GB
- background eslint checker: 3.5GB

I'm introducing two environment variables in FE .env to disable these
checkers on lower configuration (and to disable them from CD build):
```
# VITE_DISABLE_TYPESCRIPT_CHECKER=true
# VITE_DISABLE_ESLINT_CHECKER=true
```
2024-08-26 16:35:09 +02:00
martmull
873a4c1bd1
Fix serverless save when name empty (#6720)
- fix serverless function error on save when name empty
- remove useless unique constraint on serverless function names
2024-08-23 17:34:31 +02:00
martmull
f9af25b57e
Fix sentry issue (#6719)
https://twenty-v7.sentry.io/issues/5677123076/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=12

Removes billing section when is_free_access_enabled
2024-08-23 16:01:40 +02:00
Marie
ee6180a76f
[Fix] Prevent fields name conflicts with composite subfields names (#6713)
At field creation we are checking the availability of the name by
comparing it to the other fields' names' on the object; but for
composite fields the fields' names' as indicated in the repository do
not exactly match the column names' on the tables (e.g "createdBy" field
is actually represented by columns createdByName, createdBySource etc.).

In this PR we prevent the conflict with the standard composite fields'
names.
There is still room for errors with the custom composite fields: for
example a custom composite field "address" of type address on a custom
object "listing" will introduce the columns addressAddressStreet1,
addressAddressStreet2 etc. while we won't prevent the user from later
creating a custom field named "addressAddressStreet1".
For now I decided not to tackle this as this seem extremely edgy + would
impact performance on creation of all fields while never actually useful
(I think).
2024-08-23 13:24:10 +02:00
martmull
6f9aa1e870
6654 serverless functions add a deploy button disable deploy when autosave (#6715)
- improvements on serverless function behavior (autosave performances,
deploy on execution only)
- add versioning to serverless functions
- add a publish endpoint to create a new version of a serverless
function
  - add deploy and reset to lastVersion button in the settings section:
<img width="736" alt="image"
src="https://github.com/user-attachments/assets/2001f8d2-07a4-4f79-84dd-ec74b6f301d3">
2024-08-23 12:06:03 +02:00
gitstart-app[bot]
7ca091faa5
Add isInactive to FieldMetadata decorator (#6623)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-4145](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-4145).
This ticket was imported from:
[TWNTY-4145](https://github.com/twentyhq/twenty/issues/4145)

 --- 
### Description
This PR introduces the @isInActive() decorator to the standard field
metadata. \
- This gives the ability to allow workspaces to be able to be created
with standard fields as inactive *Helps prevent polluting existing
workspaces
- A new standard field can be added to* eg company-workspace-entity.ts
and the @WorkspaceIsInActive() decorator can be added to create it in
deactivated mode
sync-metadata command: `yarn command:prod workspace:sync-metadata -f`

### Refs
#4145 

### Demo

<https://www.loom.com/share/10c13e2614d749809cfe2d2d847e963e?sid=017bbfcf-53c6-4205-8ffc-8a09c416220a>\

<https://www.loom.com/share/6ab86bd36f344c999cb8dacdb82c7bb0?sid=13ac78a2-de44-4772-bb54-7b57975e7360>\

Fixes: #4145

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-22 18:37:06 +02:00
Raphaël Bosi
1eeeae8564
6686 Add try catch on every cron job, and send exception to exceptionHandler (#6705)
Closes #6686

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-22 18:23:05 +02:00
Thomas Trompette
0a7700351f
Update workflow version struct (#6716)
We want to avoid the nested structure of active pieces. Steps to execute
will now be separated from the trigger. It will be an array executed
sequentially.

For now a step can only be an action. But at some point it will also be
a branch or a loop
2024-08-22 17:59:16 +02:00
Raphaël Bosi
579c2ebcea
6687 change messaging import cron job to run every minute (#6704)
Closes #6687
2024-08-22 17:51:08 +02:00
Charles Bochet
eab202f107
Make workspaceMemberId optional in JWT for workspaces that are not ACTIVE (#6714)
WorkspaceMemberId is mandatory in the jwt token generated for a given
user on a given workspace.
However, when a user signs up, it does not have a workspaceMemberId yet.
2024-08-22 00:28:19 +02:00
Charles Bochet
da4bd73881 Fix logging error in webhook system 2024-08-21 20:12:14 +02:00
Thomas Trompette
be50a6256f
Check workflow version is valid before publishing (#6702)
Fix https://github.com/twentyhq/twenty/issues/6670
2024-08-21 17:56:33 +02:00
Thomas Trompette
663acd56e4
Trigger workflow run manually (#6696)
Fix https://github.com/twentyhq/twenty/issues/6669

- create a commun function `startWorkflowRun` that both create the run
object and the job for executing the workflow
- use it in both the `workflowEventJob` and the `runWorkflowVersion`
endpoint

Bonus:
- use filtering for exceptions instead of a util. It avoids doing a try
catch in all endpoint
2024-08-21 17:41:26 +02:00
Charles Bochet
c2cf8b4554 Bump version to 0.23.2 2024-08-21 15:39:55 +02:00
Charles Bochet
79641327f3
Fix webhook issue (#6711)
Fix
[#web](https://github.com/orgs/twentyhq/projects/1/views/3?pane=issue&itemId=75329194)

This PR does 2 things:
- migrate webhooks to TwentyORM
- Fix inversion between objectNameSingular and operation in webhook
eventName. It is stored as {objectNameSingular}.{operation} and we were
querying {operation}.{objectNameSingular}
2024-08-21 15:33:38 +02:00
Charles Bochet
612a875c7b
Remove performance logs (#6709)
We have found the root cause of the issue:
- when using a datasource (including the cached ones), we are fetching
ObjectMetadataCollection from cache (700kB). Datasource usage is
happening any time we are using twentyORM, which is everywhere in the
jobs and in some resolvers (including the GetCurrentUser one). This is
leading to a high load on redis and leading to the performance issues we
are seeing.
- we actually don't need to fetch this objectMetadataCollection while
using a cached datasource, only when we instantiate a new one
2024-08-21 14:17:11 +02:00
Marie
aa4ae53fb4
[Fix] field does not appear directly after creation (#6708) 2024-08-21 12:08:57 +02:00
Charles Bochet
614a81860f
Add logging on currentWorkspaceMember query (#6706)
We are experiencing slow GetCurrentUser endpoint, this is helping us
troubleshoot
2024-08-21 11:48:20 +02:00
gitstart-app[bot]
6caa78008f
If an object is disabled, then the relationships to that object should be disabled (#6690)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-5370](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-5370).
This ticket was imported from:
[TWNTY-5370](https://github.com/twentyhq/twenty/issues/5370)

 --- 


### Description

- We updated the logic in
packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts
  
  Test cases:
1. Ensure that when an object is disabled, all related relationships are
also disabled.
         a. Example disable the people object
b. Check the company object and verify that the people field has been
disabled too
c. Check the opportunity object and check that the point of contact
field has been disabled too
2. Verify that when a previously disabled object is restored, the
relationships are also restored.
3. Ensure that previously disabled relationships remain disabled when
the object is disabled and later restored.
4. Verify that relationships of a disabled object are not visible in the
UI.
5. Ensure that relationships to a disabled object are marked as inactive
in the data models screen

 ### Refs

#5370

  
### Demo
  

<https://www.loom.com/share/2b0a91f463ca4e02a6963f9a8796a0d9?sid=1e9c4fb8-8fb9-4c6c-b43a-c50f3776e1d3>

Fixes #5370

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
2024-08-21 11:19:21 +02:00
Charles Bochet
08e07ac2d5 Update graphql-yoga patch in yarn.lock 2024-08-21 00:39:55 +02:00
Raphaël Bosi
091c0f83be
6619 modify event emitter to emit an array of events (#6625)
Closes #6619

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-20 19:44:29 +02:00
Charles Bochet
17a1760afd
Improve performance twenty orm (#6691)
## Context

As we grow, the messaging scripts are experiencing performance issues
forcing us to temporarily disable them on the cloud.
While investigating the performance, I have noticed that generating the
entity schema (for twentyORM) in the repository is taking ~500ms locally
on my Mac M2 so likely more on pods. Caching the entitySchema then!

I'm also clarifying naming around schemaVersion and cacheVersions ==>
both are renamed workspaceMetadataVersion and migrated to the workspace
table (the workspaceCacheVersion table is dropped).
2024-08-20 19:42:02 +02:00