Commit Graph

973 Commits

Author SHA1 Message Date
Weiko
2f223f3294
Fix 'name' column wrongly added in standard objects (#7428)
## Context
Name shouldn't be added to all tables, especially standard objects
because they already have their own labelIdentifierFieldMetadata
specified in the workspace-entity schema. This PR removes this column
from the "base" list of columns to add when creating a new object/table
and moves it to the object-metadata service that is, as of today, only
used for custom objects. Also had to modify the migration-runner to
handle column creation in a table creation migration (this was available
in the migration definition already but was not doing anything)

This also fixes an issue in standard objects that already have a "name"
field defined with a different field type, this is even more important
when the said field is a composite field. For example people already has
a FULL_NAME name field which clashes with the default TEXT name field
meaning it was only creating 1 field metadata for 'name' but 3 columns
were created: `name, nameFirstName, nameLastName`. This inconsistency
with metadata (which is our source of truth everywhere) brought some
issues (lately, converting back typeorm response to gql (including
composition) was broken).
2024-10-04 18:31:19 +02:00
Weiko
511150a2d3
Refactor graphql query runner and add mutation resolvers (#7418)
Fixes https://github.com/twentyhq/twenty/issues/6859

This PR adds all the remaining resolvers for
- updateOne/updateMany
- createOne/createMany
- deleteOne/deleteMany
- destroyOne
- restoreMany

Also
- refactored the graphql-query-runner to be able to add other resolvers
without too much boilerplate.
- add missing events that were not sent anymore as well as webhooks
- make resolver injectable so they can inject other services as well
- use objectMetadataMap from cache instead of computing it multiple time
- various fixes (mutation not correctly parsing JSON, relationHelper
fetching data with empty ids set, ...)

Next steps: 
- Wrapping query builder to handle DB events properly
- Move webhook emitters to db event listener
- Add pagination where it's missing (findDuplicates, nested relations,
etc...)
2024-10-04 11:58:33 +02:00
gitstart-app[bot]
97eff774bd
Allow input and display of floats for Number fields (#7340)
### Description

- We added a decimal field for a Number Field type in the settings
- We updated the Number Field type create a form with decimals input
- We are not implementing the dropdown present on the Figma because it
seems not related

### Demo


<https://www.loom.com/share/18a8d4b712a14f6d8b66806764f8467f?sid=3fc79b46-ae32-46e3-8635-d0eee02e53b2>

Fixes #6987

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
2024-10-04 10:45:25 +02:00
Marie
5f9435c718
Search (#7237)
Steps to test

1. Run metadata migrations
2. Run sync-metadata on your workspace
3. Enable the following feature flags: 
IS_SEARCH_ENABLED
IS_QUERY_RUNNER_TWENTY_ORM_ENABLED
IS_WORKSPACE_MIGRATED_FOR_SEARCH
4. Type Cmd + K and search anything
2024-10-03 17:18:49 +02:00
martmull
62fe1d0e88
6653 serverless functions store and use environment variables in serverless function scripts (#7390)
![image](https://github.com/user-attachments/assets/a15bd4c1-3db4-4466-b748-06bdf3874354)

![image](https://github.com/user-attachments/assets/71242dfb-956b-43ed-9704-87cb0dfbc98d)
2024-10-03 13:56:17 +02:00
Thomas Trompette
ca027d6772
Add output to workflow run (#7276)
Example of output stored for following workflow:

<img width="244" alt="Capture d’écran 2024-09-27 à 11 18 06"
src="https://github.com/user-attachments/assets/722bfa96-2dd1-41f7-ab87-d39584ac9efc">

Output:

```
{"steps": [
  {"type": "CODE", "result": {"email": "test@twenty.com"}}, 
  {"type": "SEND_EMAIL", "result": {"success": true}}
]}
```
2024-09-30 18:45:44 +02:00
Charles Bochet
1e4ed1e96f
Tag main as 0.31 canary (#7332)
We are updating our git worklow.

Case 1: **URGENT / PATCH**
If you want to include something URGENT that cannot wait for the next
release, you'll need to:
- create a PR from the latest patch (right now v0.30.1)
- create a new patch tag from this PR (would be v0.30.2 right now)
- merge this PR in main so it's in 0.31 too

Case 2: **REGULAR**
- Open a PR from main and merge it into main

I'm tagging main as v0.31.canary to make it clear!
2024-09-30 11:42:06 +02:00
Charles Bochet
e4959ad534
Add 0.30 release notes (#7300)
In this PR:
- update your environment variables to default `CACHE_STORAGE_TYPE` to
`redis` and `MESSAGE_QUEUE_TYPE` to `bull-mq`
- add redis container to our default docker-compose
- add `REDIS_HOST` and `REDIS_PORT` to docker-compose yaml
- add upgrade instructions
2024-09-27 19:10:26 +02:00
Weiko
ae6777fab8
Fix viewFilter operand for dateTime fields (#7306) 2024-09-27 19:10:18 +02:00
Raphaël Bosi
942281f4b0
Fix email migration (#7298)
Checks if person standard email field exists before running the
migration.
2024-09-27 17:20:15 +02:00
Marie
e28d8dd952
Fix standardId issues with phones field migration (#7294)
Co-authored-by: Weiko <corentin@twenty.com>
2024-09-27 16:52:06 +02:00
ad-elias
9d36493cf0
Date filter improvements (#5917) (#7196)
Solves issue #5917.

This PR is now ready for the first review!

Filters do not fully work yet, there's a problem applying multiple
filters like the following:

```
{
  and: [
    {
      [correspondingField.name]: {
        gte: start.toISOString(),
      } as DateFilter,
    },
    {
      [correspondingField.name]: {
        lte: end.toISOString(),
      } as DateFilter,
    },
  ],
}
```

I'll do my best to dig into it tonight!

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-09-27 15:57:38 +02:00
Raphaël Bosi
c9c2f32922
7154 deleted event is not emitted when calling destroyone (#7159)
Closes #7154
2024-09-27 15:52:04 +02:00
Félix Malfait
2f41e1405f
Change tinybird event format (#7272)
Separate pageview analytics from core events
2024-09-26 17:23:58 +02:00
Félix Malfait
a10324cbd3
Fix analytics (#7271)
Incorrect check
2024-09-26 16:42:16 +02:00
Raphaël Bosi
0e375d9021
Add phone fields migration command to 0 30 (#7269)
Add phone fields migration command to 0 30
2024-09-26 15:26:58 +02:00
Thomas Trompette
6736ca784b
Update clean view command + add dry run to favorite backfill (#7268)
Clean favorites associated with activities
2024-09-26 15:00:47 +02:00
Marie
c1db435a79
Fix email migration script (#7267) 2024-09-26 14:36:19 +02:00
Ana Sofia Marin Alexandre
16bb1f22e4
Connect EventTracker to TB endpoint (#7240)
#7091 
EventTrackers send information of events to the TinyBird instance:

In order to test:

1. Set ANALYTICS_ENABLED= true and TELEMETRY_ENABLED=true in
evironment-variables.ts
2. Set the TINYBIRD_TOKEN in environment variables (go to TiniyBird
Tokens)
3. Log in to twenty's TinyBird and go to datasources/analytics_events in
twenty_analytics workspace
4. Run twenty and navigate it
5. New events will be logged in the datasources, containing their
timestamp, sessionId and payload.

<img width="1189" alt="Screenshot 2024-09-24 at 17 23 01"
src="https://github.com/user-attachments/assets/85375897-504d-4e75-98e4-98e6a9671f98">
Example of payload when user is not logged in

```
{"hostName":"localhost",
"pathname":"/welcome",
"locale":"en-US",
"userAgent":"Mozilla/5.0",
"href":"http://localhost:3001/welcome",
"referrer":"",
"timeZone":"Europe/Barcelona"}
```
Example of payload when user is logged in
```
{"userId":"2020202",
"workspaceId":"202",
"workspaceDisplayName":"Apple",
"workspaceDomainName":"apple.dev",
"hostName":"localhost",
"pathname":"/objects/companies",
"locale":"en-US",
"userAgent":"Mozilla/5.0Chrome/128.0.0.0Safari/537.36",
"href":"http://localhost:3001/objects/companies",
"referrer":"",
"timeZone":"Europe/Paris"}
```

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-09-26 10:53:10 +02:00
Baptiste Devessier
729c990546
Activate/Deactivate workflow and Discard Draft (#7022)
## Setup

This PR can be tested only if some feature flags have specific values:

- `IsWorkflowEnabled` equals `true`
- `IsQueryRunnerTwentyORMEnabled` equals `false`

These feature flags weren't committed to don't break other branches.

## What this PR brings

- Display buttons to activate and deactivate a workflow version and a
button to discard the current draft version. I also scaffolded a "Test"
button, which doesn't do anything for now.
- Wired the activate, deactivate and discard draft buttons to the
backend.
- Made it possible to "edit" active and deactivated versions by
automatically creating a new draft version when the user tries to edit
the version.
- Hide the "Discard Draft", button if the current version is not a draft
or is the first version ever created.
- On the backend, don't consider discarded drafts when checking if a new
draft version can be created.
- On the backend, disallow deleting the first created workflow version.
Otherwise, we will end up with a blank canvas in the front end, and it
will be impossible to recover from it.
- On the backend, disallow running deactivation steps if the workflow
version is not currently active. Previously, we were throwing, which is
unnecessary as it's a valid case.

## Spotted bugs that we must dive into

### Duplicate workflow versions in Apollo cache


https://github.com/user-attachments/assets/7cfffd06-11e0-417a-8da0-f9a5f43b84e2

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-25 18:09:31 +02:00
Marie
e1cb82bb23
[Phones migration](fix) update label of standard field by using raw query (#7255) 2024-09-25 16:09:55 +02:00
Marie
97ce100fa2
[Phone field migration][fix] Update field label (#7247) 2024-09-25 14:06:03 +02:00
Thomas Trompette
49b5e53ceb
Add index key to tasks and notes views (#7241)
Missing INDEX key for some tasks and notes views. We need it to backfill
favorites.
2024-09-25 11:51:25 +02:00
ad-elias
092496f2db
'Display as relative date' field formatting option for dateTime and date fields #5398 (#6945)
Implements #5398.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Félix Malfait <felix@twenty.com>
2024-09-25 11:42:16 +02:00
Marie
b3a0cba961
[Phones migration][Fix] Remove field from view after creation (#7243) 2024-09-25 11:31:07 +02:00
Marie
825dfeb400
[fix][Phone field migration] Use "Phones" in new field label (#7239) 2024-09-24 17:20:15 +02:00
gitstart-app[bot]
fa241fa4e9
Handle migration of Phone field to Phones field (#7128)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-6260](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6260).
This ticket was imported from:
[TWNTY-6260](https://github.com/twentyhq/twenty/issues/6260)

 --- 

### Description

This is the second PR on TWNTY-6260 which handles data migration of
Phone field to Phones field.\
\
How to Test?\
 Follow the below steps:

- On the main branch, 
- go to
`packages/twenty-server/src/database/typeorm-seeds/workspace/people.ts`
and change any person's phone number to a string with characters for
example: "test invalid phone", and then reset the DB.
  - reset database using `npx nx database:reset twenty-server`
- This is to make sure that invalid numbers will be handled properly. We
should use the invalid value itself to avoid removing data and see how
the behavior is on the front end. should be the same as in the main, the
display shows the invalid value, but the input is empty when you click,
and then you can update.
- Checkout to `TWNTY-6260-phone-migration` branch
- Rebuild typescript using `npx nx build twenty-server`
- Run command `yarn command:prod upgrade-0.32` to do migration
- Run both backend and frontend to see the migrated field

### Demo

- **Loom Video:**\

<https://www.loom.com/share/4b9bcb423cee447d8ad09852a83b27da?sid=ed74ecaa-0339-4575-acdc-a863e95e94fd>

### Refs

#6260

---------

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-24 16:31:30 +02:00
Raphaël Bosi
b83f0f46e5
Add try catch around messaging monitoring cron and fix decorators (#7207)
Add try catch around messaging monitoring cron and fix
decorators:`@Process` and `@SentryCronMonitor` were inverted.
2024-09-24 16:29:05 +02:00
Raphaël Bosi
4d31995564
Remove shouldUseEmailsField (#7208)
Remove shouldUseEmailsField. This boolean was used to ensure
retro-compatibility with the old email field. It is no longer needed.
2024-09-24 16:03:43 +02:00
Marie
e3547582d0
Fix demo seeds (#7204) 2024-09-23 15:13:46 +02:00
Weiko
d8e16cbfd1
Fix IN filter with empty array (#7202)
## Context
The api currently allows empty array in the IN filter but the expected
behaviour is not very clear. Typeorm seems to return all records when it
is empty which could lead to undesired result. Instead we decided to
throw an error.
I've updated the FE accordingly to skip calls when array is empty.

<img width="696" alt="Screenshot 2024-09-23 at 14 20 28"
src="https://github.com/user-attachments/assets/4b641430-ff17-40a6-bbc5-75e9a1d55f50">
2024-09-23 15:12:49 +02:00
Thomas Trompette
bb875b1ea8
Fix lambda creation (#7201)
As title
2024-09-23 14:28:22 +02:00
Weiko
c8e171a929
Fix paginated order by with composite fields (#7187)
## Context
Cursor is modifying the where object but does not handle properly
composite fields. I'm introducing field metadata as a source of truth to
fix this issue.
RAW_JSON for example (as a sub-field type) should be ignored in a lt/gt,
probably other field types as well.

## Before
```typescript
[
  {
    emails: {
      lt: {
        primaryEmail: "brenda.brown@example.com",
        additionalEmails: null,
      },
    },
  },
  {
    emails: {
      eq: {
        primaryEmail: "brenda.brown@example.com",
        additionalEmails: null,
      },
    },
    position: {
      gt: 877,
    },
  },
  {
    emails: {
      eq: {
        primaryEmail: "brenda.brown@example.com",
        additionalEmails: null,
      },
    },
    position: {
      eq: 877,
    },
    id: {
      gt: "fe43c45d-7560-4eb1-8fd3-c48fd0a4dcd4",
    },
  },
]
```


## After
```typescript
[
  {
    emails: {
      primaryEmail: {
        lt: "brenda.brown@example.com",
      },
    },
  },
  {
    emails: {
      primaryEmail: {
        eq: "brenda.brown@example.com",
      },
    },
    position: {
      gt: 877,
    },
  },
  {
    emails: {
      primaryEmail: {
        eq: "brenda.brown@example.com",
      },
    },
    position: {
      eq: 877,
    },
    id: {
      gt: "fe43c45d-7560-4eb1-8fd3-c48fd0a4dcd4",
    },
  },
]
```
2024-09-23 13:32:59 +02:00
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