Commit Graph

998 Commits

Author SHA1 Message Date
Weiko
f4bc0c687e
[search] simplify tsvector generated expression and remove deletedAt condition (#7561)
## Context
Because we can't create GIN indexes on primitive types and in this case
both tsvector and deletedAt (date), we had to create an index on the
tsvector only and had to make sure it wouldn't return results for
deleted records.
To handle this, we added a CASE in the generated expression to generate
an empty value if the row has been soft-deleted. This is a bit too
complex and won't allow search on softDeleted records in the future.

What we want to do is to make sure deleted records are not returned by
default by adding a WHERE clause in the search and still keep good
performances by also adding a BTREE index on deletedAt column.

When this was implemented, soft-deleted was not handled properly but now
typeorm query builder exclude soft deleted records by default which
means the WHERE clause is not necessary. As for the BTREE index on
deletedAt, this should be part on a broader effort to add it to all
tables and can be added in a later PR.

This PR simply updates the complex tsVectorExpression to only return the
expression regardless of the deletedAt column. Search won't return
soft-deleted records as explained above and perfs will be improved in an
upcoming version.

## Test
tested locally with reset db + created a new workspace. Since the
feature is not launched yet no more effort should be made.
<img width="1289" alt="Screenshot 2024-10-10 at 15 16 16"
src="https://github.com/user-attachments/assets/d9a6f06b-d738-4f1d-8053-2fa93bd8b4f8">

## Note
Some issues with optimistic rendering, we need to refresh once a record
has been deleted otherwise it will still be returned by the search
2024-10-10 15:30:13 +02:00
Thomas Trompette
c055d167f2
Make workflow objects read only in frontend (#7545)
Expected behavior:
- workflows can be added and deleted. Only name field is editable
- versions and runs cannot be added nor deleted. No fields are editable

Added two new utils for those needs:
- `isReadOnlyObject` the similar logic between remote objects, versions
and runs
- `isFieldReadonlyFromObjectMetadataName` to easily block field edition
from object context
2024-10-10 15:29:43 +02:00
Weiko
66a483c332
Remove graphql twenty orm feature flag (#7556)
## Context
IS_QUERY_RUNNER_TWENTY_ORM_ENABLED has been fully launched in 0.31.0,
the feature flag can be safely removed.

Note: Waiting for 0.31.1
2024-10-10 14:52:35 +02:00
Charles Bochet
a58236e6da
Remove deprecated EMAIL, PHONE, LINK (#7551)
In this PR:
- remove deprecated EMAIL, PHONE, LINK field types (except for Zapier
package as there is another work ongoing)
- remove composite currency filter on currencyCode, actor filter on name
and workspaceMember as the UX is not great yet
2024-10-10 14:14:58 +02:00
Marie
b6b7d0e665
Fix field creation (#7547)
In [this](https://github.com/twentyhq/twenty/pull/7522) and
[this](https://github.com/twentyhq/twenty/pull/7543) PR we introduced
the impossibility to save a field that would be non nullable but without
a default value.
The check is actually called on the input while the defaultValue is
added by the service on a "built" fieldMetadata to create or save. So
far all fields created from the app it currently fails as both
isNullable and defaultValue are undefined so falsy at that stage.
2024-10-10 09:38:29 +02:00
Marie
b80fa9cf13
Fix seeds (#7543)
- Fixing seeds after introducing the requirement for non-nullable fields
to have a default value (https://github.com/twentyhq/twenty/pull/7522).
- Empty string needs to be considered a valid default value
2024-10-09 17:03:28 +02:00
Ana Sofia Marin Alexandre
f901512a4f
Add webhook response graph from the last 5 days (#7487)
#7346 #7343 #7342 #7344 

Before:

<img width="799" alt="Screenshot 2024-10-08 at 11 59 37"
src="https://github.com/user-attachments/assets/a1cd1714-41ed-4f96-85eb-2861e7a8b2c2">


Now:

![Screenshot 2024-10-07 at 18 56
21](https://github.com/user-attachments/assets/c87ee17a-c6c4-4938-b024-aaa635bab022)


In order to test:

1. Set ANALYTICS_ENABLED to true
2. Set TINYBIRD_TOKEN to your token from the workspace
_twenty_analytics_playground_
3. Write your client tinybird token in
SettingsDeveloppersWebhookDetail.tsx in line 93
4. Create a Webhook in twenty and set wich events it needs to track
5. Run twenty-worker in order to make the webhooks work.
6. Do your tasks in order to populate the data
7. Enter to settings> webhook>your webhook and the statistics section
should be displayed.
2024-10-09 15:41:41 +02:00
Marie
798722179e
[fix] Nullable fields must have default values (#7522) 2024-10-09 14:02:35 +02:00
martmull
f138a1cf6e
7417 workflows i can send emails using the email account (#7431)
- update `send-email.workflow-action.ts` so it send email via the google
sdk
- remove useless `workflow-action.email.ts`
- add `send` authorization to google api scopes
- update the front workflow email step form to provide a
`connectedAccountId` from the available connected accounts
- update the permissions of connected accounts: ask users to reconnect
when selecting missing send permission


![image](https://github.com/user-attachments/assets/fe3c329d-fd67-4d0d-8450-099c35933645)
2024-10-08 23:29:09 +02:00
Weiko
d5bd320b8d
Add DestroyMany to graphql query runner (#7507)
## Context
destroyMany was not implemented, this PR adds it
2024-10-08 17:40:48 +02:00
Marie
a048436929
Bump version to v0.31.0 (#7500)
Co-authored-by: Weiko <corentin@twenty.com>
2024-10-08 17:22:16 +02:00
Raphaël Bosi
e042711f34
Fixes on messaging and calendar (#7485)
Fix syncedAt no longer been set on message sync.
Fix calendar data model:
- Add `syncedAt` to `CalendarChannelWorkspaceEntity`
- Move `recurringEventExternalId` from `CalendarEventWorkspaceEntity` to
`CalendarChannelEventAssociationWorkspaceEntity` since the id is
relative to one channel
Fix save queries on calendar sync after regression.
2024-10-08 13:44:16 +02:00
Raphaël Bosi
33d5a57ea2
6694 remove raw queries from connected account (#7101)
Closes #6694

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-10-08 13:31:44 +02:00
Pacifique LINJANJA
4156d7821c
Ability to filter by composite's subfields (#6832)
# This PR

- Fix #6425 

See https://github.com/twentyhq/twenty/issues/7188 because there's some
more work to do.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-10-08 11:25:42 +02:00
Weiko
af4f3cebb0
Fix restApi should not use TS_VECTOR fields as mutation inputs (#7484)
## Context
<img width="398" alt="Screenshot 2024-10-08 at 11 10 59"
src="https://github.com/user-attachments/assets/03ee0305-527c-42ed-a8a1-0ccea8176357">
<img width="489" alt="Screenshot 2024-10-08 at 11 10 50"
src="https://github.com/user-attachments/assets/1403876b-40b6-490e-8557-d8280c439d57">

Tested with
https://twenty.com/developers/rest-api/core#/operations/createOnePerson
2024-10-08 11:21:11 +02:00
Marie
491fe80132
Rename typeorm metadata table (#7473)
Fixes #7453
2024-10-07 18:25:38 +02:00
Marie
8b716f98f7
[Search] Fix tests (#7471) 2024-10-07 16:02:07 +02:00
Marie
94031605ac
Prepare workspace for search features at creation (#7467)
Enabling feature flags IsSearchEnabled and IsWorkspaceMigratedForSearch
at workspace creation to ensure workspaces have the searchVector fields
and indexes created.
For the feature to be enabled in the front-end we will also need
IsQueryRunnerTwentyORMEnabled to be enabled but that is an independent
topic.
2024-10-07 15:29:33 +02:00
Weiko
7bdbbcf72e
Add delete name column from standard object tables (#7470)
Following this https://github.com/twentyhq/twenty/pull/7428 we now need
to fix existing workspaces thanks to this migration command.

This command will fetch all standard objects and their fields then
filter out tables that don't have that column OR objects that have an
existing fieldMetadata "name" of type TEXT and delete the rest.
2024-10-07 15:20:45 +02:00
Thomas Trompette
b5d1486830
Fix currency input (#7469)
Fix https://github.com/twentyhq/twenty/issues/7458
2024-10-07 15:00:47 +02:00
Thomas Trompette
ce676f699d
Add opened section (#7265)
When object is not part of the workspace favorite list, we want to show
it in the "opened section" while its record page is accessed.

This PR:
- adds a new component `NavigationDrawerOpenedSection`
- makes workflow versions and runs not system object + creates a
prefilled view index for these
- do not create workspace favorites for these so these do not appear in
the workspace section

<img width="1129" alt="Capture d’écran 2024-09-26 à 11 45 25"
src="https://github.com/user-attachments/assets/c84d773c-0bef-4dce-b66a-55d7d00b0fb6">
2024-10-07 13:45:29 +02:00
Raphaël Bosi
23e7958218
Fix syncStageStartedAt not correctly set (#7436)
Fix syncStageStartedAt not correctly set

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-10-05 00:44:52 +02:00
Charles Bochet
d8c4af9279 Fix all broken CIs (#7439)
Fix all the broken CIs :p

This includes an ongoing effort to simplify test maintenance by having 1
unique source of truth about metadata and data mocks (that will later be
generated from a unique source of seeds: dev = demo = test)

Regressions:
- Unit line coverage: 60 > 55
- Storybook Pages branch coverage: 40 > 35
We will need to write tests to increase those coverage
- RelationFieldDisplay perf: 0.2ms to 0.22ms > We might have a
regression here
- Removed perf story about RawJSON > We will need to re-add it
2024-10-05 00:23:23 +02:00
Weiko
bd305c8432
Fix worker run ci step (#7437)
## Context
Updating the Worker / Run step to run in sync mode with in-memory cache
type so it does not hang forever in the CI.
2024-10-04 19:28:29 +02:00
bmbaji
ae2bd66f45
changed the createdByName to Twenty(Sample data). (#7424)
I changed the createdByName from' system' to 'Twenty(Sample Data)'.

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-10-04 18:57:15 +02:00
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