Commit Graph

685 Commits

Author SHA1 Message Date
Charles Bochet
99dff43579
Add new enum options to messageChannel syncStatus (#5694)
As per title!
This command will enable smooth migrations between 0.12 and 0.20
2024-05-31 18:02:52 +02:00
Thomas Trompette
fbd8714c76
Make positions possibly negatives (#5690)
Closes https://github.com/twentyhq/twenty/issues/5427
2024-05-31 14:17:49 +02:00
bosiraphael
f166171a1c
5531 update gmail full sync to v2 (#5674)
Closes #5531

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-31 13:29:58 +02:00
Thomas Trompette
c60a3e49cd
Catch query timeout exceptions (#5680)
Query read timeouts happen when a remote server is not available. It
breaks:
- the remote server show page
- the record table page of imported remote tables

This PR will catch the exception so it does not go to Sentry in both
cases.

Also did 2 renaming.
2024-05-31 10:39:35 +02:00
Aditya Pimpalkar
a12c1aad5e
fix: user has to login every time chrome sidepanel is opened (#5544)
We can pass the auth tokens to our front app via post message, which
will also allow us to pass route names to navigate on it
2024-05-30 12:58:45 +02:00
Marie
339aee6dbb
Run queries within queryRunner transaction sequentially (#5668)
Within a queryRunner transaction, it is important that migrations are
run subsequently and not concurrently: otherwise if an error is thrown
by one of the query, it will abort the transaction; any subsequent query
running on the same queryRunner will cause the error _current
transaction is aborted, commands ignored until end of transaction
block_.

Using an async function in a map as below does not guarantee that each
query terminates before iterating over the next one, which can be an
issue as described above, and which seems to cause [this
sentry](https://twenty-v7.sentry.io/issues/5258406553/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=4).
2024-05-30 10:45:46 +02:00
Marie
5bb205bd6a
Fix update remote field metadata (#5638)
Closes #5610.

& update fetch-policy when fetching database on the remote databases
show page to get freshest status.
2024-05-28 18:01:05 +02:00
Thomas Trompette
ebb1aa0377
Add label to remote server (#5637)
Added label on remote server entity. 

Also added the possibility to update schema. 

<img width="688" alt="Capture d’écran 2024-05-28 à 15 36 31"
src="https://github.com/twentyhq/twenty/assets/22936103/c9786122-8459-4876-833e-c9a1d7d27829">
2024-05-28 15:54:57 +02:00
Thomas Trompette
ae6d5afdfc
Add missing stripe tables (#5621)
As title

Still adding not working tables / columns commented so we know why these
are not available.
2024-05-28 11:32:57 +02:00
Marie
930237e778
Bump to version v0.12.1 (#5608) 2024-05-27 16:07:38 +02:00
Marie
f58c961d98
Remove feature flag for Links field (#5606) 2024-05-27 16:05:22 +02:00
Marie
857971458a
Bump version to v0.12.0 (#5604) 2024-05-27 15:16:50 +02:00
martmull
2f52e0fdb6
5505 forgot password feature broken (#5602)
- add missing `excludedOperations` in
`packages/twenty-server/src/engine/middlewares/graphql-hydrate-request-from-token.middleware.ts`
- update generated graphql file
- Add missing redirection to index after password update
2024-05-27 15:13:11 +02:00
Marie
def1774bf0
[Fix] Object names should be camel cased (#5571)
as per title
2024-05-25 10:29:00 +02:00
bosiraphael
936ac4027a
Introduce a new feature flag for contact creation (#5570)
Introduce new feature flag
`IS_CONTACT_CREATION_FOR_SENT_AND_RECEIVED_EMAILS_ENABLED` to allow
contacts to be created for sent and received emails.
2024-05-24 18:55:21 +02:00
bosiraphael
3680647c9a
Fix sync token is no longer valid in calendar sync (#5563)
Fix sync token is no longer valid in calendar sync.


https://developers.google.com/apps-script/add-ons/calendar/conferencing/sync-calendar-changes#implement_a_sync_trigger_function
_Caution: Occasionally sync tokens are invalidated by the server,
resulting in a Sync token is no longer valid error. When this happens,
your code should conduct a full sync and replace any stored sync tokens
you have._
2024-05-24 18:33:44 +02:00
bosiraphael
87465b13ee
5507 modify the partial sync cron to work with the new statuses (#5512)
Closes #5507
2024-05-24 18:27:54 +02:00
Thomas Trompette
18fafbdeb5
Rename findAvailableTables endpoint (#5557)
As title
2024-05-24 10:57:46 +02:00
Marie
4bd0aafb8e
[fix] Update remote table sync status in cache after schema update (#5553)
Upon schema update, sync status can change from synced to non_synced in
case the update regards a table that was deleted. Let's update the sync
status too to avoid displaying the table as still synchronized.


https://github.com/twentyhq/twenty/assets/51697796/7ff2342b-ce9f-4179-9b76-940617cf1292
2024-05-24 10:20:08 +02:00
Thomas Trompette
fede721ba8
Add sorter for distant tables (#5546)
As title
2024-05-23 22:36:50 +02:00
Marie
fe5b558477
[FE] Update remote table schema + refactor Tables list (#5548)
Closes #5062.

Refactoring tables list to avoid rendering all toggles on each sync or
schema update while using fresh data:
- introducing id for RemoteTables in apollo cache
- manually updating the cache for the record that was updated after a
sync or schema update instead of fetching all tables again
2024-05-23 17:00:24 +02:00
Thomas Trompette
0d6fe7b2b4
Handle relations separately for remotes (#5538)
Remote object id columns are not removed anymore when a remote object is
unsynced.
This is because we do not use relations anymore. We only created the id
field. So the current behavior that was implemented for custom objects,
to retrieve the fields to deleted, does not work.

Since remote object relations are really different, I extracted the
logic from `objectMetadataService`. It now handles only the relations
for custom objects creation and deletion (this part should be extracted
as well).

I create a new remote table relation service that will:
- fetch objects metadata linked to remotes (favorites,
activityTargets...)
- look for columns based on remote object name
- delete the fields and columns
2024-05-23 14:59:34 +02:00
Jérémy M
453525ca25
fix: workspace health showing error for multi select (#5547)
Fix `workspace:health` command not working properly with `MULTI_SELECT`
field metadata type.
2024-05-23 12:02:40 +02:00
Charles Bochet
7b1bea3a8a Release patch v0.11.3 2024-05-23 08:41:37 +02:00
Marie
6b1d4e0744
[Fix] Do not allow names with whitespaces (#5542)
As per title
2024-05-23 07:43:09 +02:00
Thaïs
04bf697b25
feat: add feature flag to activate Links field creation (#5535)
Related issue: #3607
2024-05-22 18:06:32 +02:00
Weiko
4e533bf2ef
fix pgGraphqlQuery with concurent search path (#5537) 2024-05-22 17:14:33 +02:00
Thomas Trompette
5448512bdc
Add quotes for table name (#5533)
As title
2024-05-22 14:21:32 +02:00
Jérémy M
bb6df43d17
fix: twentyORM datasource configuration for ssl (#5529)
We need to specify ssl configuration for TwentyORM datasources when
needed, otherwise connection will be broken.
2024-05-22 11:11:05 +02:00
bosiraphael
beaaf33544
5498 create a feature flag is gmail sync v2 enabled (#5501)
Closes #5498
2024-05-22 09:25:06 +02:00
Marie
3deda2f29a
Update foreign table to distant table schema (#5508)
Closes #5069 back-end part

And:
- do not display schemaPendingUpdates status on remote server lists as
this call will become too costly if there are dozens of servers
- (refacto) create foreignTableService

After this is merged we will be able to delete remoteTable's
availableTables column
2024-05-21 21:25:38 +02:00
gitstart-twenty
36b467d301
Fix storybook tests (#5487)
Fixes #5486

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-21 20:24:08 +02:00
bosiraphael
e47101e08b
5483 modify messagechannel syncstatus (#5484)
- Closes #5483
- Fix seeds
- Add default value to syncSubStatus
2024-05-21 13:31:39 +02:00
Jérémy M
66a23a852f
fix: unwanted change moving back datetime to date (#5499)
Moving back datetime to date, due to an unwanted change.
2024-05-21 13:29:59 +02:00
martmull
ec248f8605
Remove dumb code placement (#5494)
Fix a bug introduced in [this
PR](https://github.com/twentyhq/twenty/pull/5254/files)

When a subscription is created, we need to create the subscription,
#5254 return if no subscription is created so the sub can never be
created at all

This PR fixes that
2024-05-21 12:08:51 +02:00
martmull
4fcdfbff7d
Fix unhandled exception (#5474)
Solves exception.getStatus is not a function error logs in twenty-server

Catch all errors in order to have no error log at all
2024-05-21 11:31:03 +02:00
Marie
0d16051ded
[fix] Re-introduce beforeUpdateOneObject hook (#5495)
... and disable name edition in object edition form. This feature will
be introduced by #5491
2024-05-21 10:46:49 +02:00
Félix Malfait
4907ae5a74
Improve docs (#5492)
Fix #4382 and remove useless pages to make docs more readable
2024-05-21 09:09:19 +02:00
rostaklein
a9813447f3
feat: fetch and parse full gmail message (#5160)
first part of https://github.com/twentyhq/twenty/issues/4108
related PR https://github.com/twentyhq/twenty/pull/5081

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-20 17:29:35 +02:00
bosiraphael
b5d3396ea9
5477 - Introduce syncsubstatus in db to refactor gmail sync behavior (#5479)
Closes #5477
2024-05-20 17:19:21 +02:00
Thomas Trompette
4d479ee8ea
Remove relations for remotes (#5455)
For remotes, we will only create the foreign key, without the relation
metadata. Expected behavior will be:
- possible to create an activity. But the remote object will not be
displayed in the relations of the activity
- the remote objects should not be available in the search for relations

Also switched the number settings to an enum, since we now have to
handle `BigInt` case.

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-05-20 16:37:35 +02:00
Weiko
b098027174
Fix graphql prep query (#5478) 2024-05-20 15:53:13 +02:00
martmull
88f5eb669e
4689 multi workspace i should be able to accept an invite if im already logged in (#5454)
- split signInUp to separate Invitation from signInUp
- update redirection logic
- add a resolver for userWorkspace
- add a mutation to add a user to a workspace
- authorize /invite/hash while loggedIn
- add a button to join a workspace

### Base functionnality

https://github.com/twentyhq/twenty/assets/29927851/a1075a4e-a2af-4184-aa3e-e163711277a1

### Error handling

https://github.com/twentyhq/twenty/assets/29927851/1bdd78ce-933a-4860-a87a-3f1f7bda389e
2024-05-20 12:11:38 +02:00
Jérémy M
8b5f79ddbf
fix: multiple twenty orm issues & show an example of use (#5439)
This PR is fixing some issues and adding enhancement in TwentyORM:

- [x] Composite fields in nested relations are not formatted properly
- [x] Passing operators like `Any` in `where` condition is breaking the
query
- [x] Ability to auto load workspace-entities based on a regex path

I've also introduced an example of use for `CalendarEventService`:


https://github.com/twentyhq/twenty/pull/5439/files#diff-3a7dffc0dea57345d10e70c648e911f98fe237248bcea124dafa9c8deb1db748R15
2024-05-20 11:01:47 +02:00
Weiko
66637a3770
Add more details to mutation limit exception message and fix update many query (#5460)
## Context
Since we rely on PgGraphql to query the DB, we have to map its errors to
more comprehensible errors before sending them back to the FE. This has
already been done for unicity constraint and mutation maximum records
but for the last one the message wasn't clear enough. This PR introduces
a new pgGraphqlConfig param to the util to pass down the 'atMost' config
that we are actually overwriting with an
'MUTATION_MAXIMUM_RECORD_AFFECTED' env variable. See how atMost works in
this doc (https://supabase.github.io/pg_graphql/api/#delete)

Also adding the same message for the update since this mutation is also
affected. Create is not though.

Lastly, this PR introduces a fix on the updateMany. Since the current FE
is not using updateMany, this was missed for a few weeks but a
regression has been introduced when we started checking if the id is a
valid UUID however for updateMany this was checking the data object
instead of the filter object. Actually, the data object should never
contain id because it wouldn't make sense to allow the update of the id
and even more for multiple records since the id should be unique.

## Test
locally with MUTATION_MAXIMUM_RECORD_AFFECTED=5

<img width="1408" alt="Screenshot 2024-05-18 at 02 11 59"
src="https://github.com/twentyhq/twenty/assets/1834158/06bf25ce-4a44-4851-8456-aed7689bb33e">
<img width="1250" alt="Screenshot 2024-05-18 at 02 12 10"
src="https://github.com/twentyhq/twenty/assets/1834158/06fc4329-147b-4bb4-9223-c3bce340a8d2">
<img width="1222" alt="Screenshot 2024-05-18 at 02 12 36"
src="https://github.com/twentyhq/twenty/assets/1834158/0674546e-73e2-4e5c-918f-9825f2ee5967">
<img width="1228" alt="Screenshot 2024-05-18 at 02 13 01"
src="https://github.com/twentyhq/twenty/assets/1834158/f50df435-1fd4-45df-a953-8fefa8f36e75">
<img width="1174" alt="Screenshot 2024-05-18 at 02 13 09"
src="https://github.com/twentyhq/twenty/assets/1834158/707b9300-2779-43df-8177-9658b8965b49">


<img width="1393" alt="Screenshot 2024-05-18 at 02 19 11"
src="https://github.com/twentyhq/twenty/assets/1834158/2cd167b6-1261-4914-a4db-36f792d810c0">
2024-05-18 08:00:00 +02:00
Thomas Trompette
36e54119a3
Enable remotes with existing name (#5433)
- Check if a table with the same name already exists
- If yes, add a number suffix, and check again

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-05-17 10:38:17 +02:00
Marie
1694e0cccd
Fix missing name validation on object names at update (#5434)
## Context
as per title

## How was it tested? 
local (/metadata + in product)
2024-05-16 18:15:56 +02:00
Marie
d741f4a5bd
Minor refacto and fixes on Remotes updates (#5438)
In this PR

- Code refactoring
- v0 of adding "updates available" info in Connection sync status
<img width="835" alt="Capture d’écran 2024-05-16 à 17 02 07"
src="https://github.com/twentyhq/twenty/assets/51697796/9674d3ca-bed2-4520-a5a6-ba37bc242d06">

- fix distant table columns with not-camel case names are always
considered as new
2024-05-16 17:31:34 +02:00
martmull
afad993bb3
Fix main (#5435)
- fix lint issue
- fix Apply Cors exception handler (do not work when logged out)
2024-05-16 15:29:27 +02:00
martmull
fdf10f17e2
4655 batch endpoints on the rest api (#5411)
- add POST rest/batch/<OBJECT> endpoint
- rearrange rest api code with Twenty quality standard
- unify REST API error format
- Added PATCH verb to update objects
- In openapi schema, we replaced PUT with PATCH verb to comply with REST
standard
- fix openApi schema to match the REST api

### Batch Create

![image](https://github.com/twentyhq/twenty/assets/29927851/fe8cd91d-7b35-477f-9077-3477b57b054c)

### Replace PUT by PATCH in open Api

![image](https://github.com/twentyhq/twenty/assets/29927851/9a95060d-0b21-4a04-a3fa-c53390897b5b)

### Error format unification

![image](https://github.com/twentyhq/twenty/assets/29927851/f47dfcef-a4f8-4f93-8504-22f82a8d8057)

![image](https://github.com/twentyhq/twenty/assets/29927851/d76a87e2-2bf6-4ed9-a142-71ad7c123beb)

![image](https://github.com/twentyhq/twenty/assets/29927851/6db59ad3-0ba7-4390-a02d-be15884e2516)
2024-05-16 14:15:49 +02:00
Aditya Pimpalkar
ea5a7ba70e
feat: add renew token query for apollo client (chrome-extension) (#5200)
fixes - #5203
2024-05-16 10:21:16 +02:00
Marie
63387424c3
Fix transliteration for metadata + transliterate select options (#5430)
## Context 
Fixes #5403

Transliteration is now integrated to form validation through the schema.
While it does not impede inputting an invalid value, it impedes
submitting a form that will fail as the transliteration is not possible.
Until then we were only performing the transliteration at save time in
the front-end, but it's best to provide the information as soon as
possible. Later we will add helpers to guide the user (eg "This name is
not valid": https://github.com/twentyhq/twenty/issues/5428).

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-15 21:43:58 +02:00
Thomas Trompette
e1eead56c6
Alter comment on foreign key deletion (#5406)
We do not update the comment on the local table when a foreign table key
is deleted.
This was not breaking, which is why we did not see it. But comments
should be kept up to date.

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-05-15 17:05:30 +02:00
Jérémy M
f0383e3147
feat: twenty orm sync (#5266)
This PR is updating all object metadata entities with the new
decorators, and deleting the old ones.
This way we can use the new TwentyORM with all the standard objects.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-05-15 16:58:47 +02:00
Marie
38eb293b3c
Compare distant tables schema with remote tables schema (#5413)
Closes #4532 and part of #5062
2024-05-15 15:47:54 +02:00
Félix Malfait
a53ce1c488
Track backend events (#5405)
Add tracking to backend events, we might disable frontend tracking which
doesn't bring much value to improve the product
2024-05-14 16:42:28 +02:00
martmull
ffdd3a7d4e
Return graphql errors when exists (#5389)
- throw badRequest with graphql error messages when graphql request
fails
- clean some code

Before
<img width="1470" alt="image"
src="https://github.com/twentyhq/twenty/assets/29927851/0b700d9a-2bbe-41f7-84a9-981dc7dd5344">

After

![image](https://github.com/twentyhq/twenty/assets/29927851/6bbaaf7c-1244-473d-9ae5-4fefc6a1b994)
2024-05-14 13:21:55 +02:00
Marie
b9154f315e
Enable deletion of relation fields (#5338)
In this PR
1. Enable deletion of relation fields in the product and via the api
(migration part was missing in the api)
3. Change wording, only use "deactivate" and "delete" everywhere (and
not a mix of the two + "disable", "erase")
2024-05-13 17:43:51 +02:00
martmull
0018ec78b0
4840 multi workspace update user userworkspace inconsistent on delete set null constraint (#5373) 2024-05-13 14:50:27 +02:00
martmull
8576127b47
Add migration to restrict users without workspaces (#5369)
- update set null ON DELETE constraint to RESTRICT
- update missing updates
2024-05-13 14:18:45 +02:00
martmull
1ac8abb118
5188 bug some canceled subscriptions are billed (#5254)
When user is deleting its account on a specific workspace, we remove it
as if it was a workspaceMember, and if no workspaceMember remains, we
delete the workspace and the associated stripe subscription
2024-05-13 10:23:32 +02:00
Marie
ae0e31abc7
Bump versions to 0.11.2 (#5349) 2024-05-10 13:56:41 +02:00
Charles Bochet
ce4e78aa85
Fix Rest API id UUID error (#5321)
A user has reported an issue with REST API.
We have recently migrated the graphql IDs from UUID to ID type. As Rest
API is leveraging the graphql API under the hood, the Rest API query
builder should be updated accordingly
2024-05-07 21:04:45 +02:00
Weiko
b691894254
Fix query runner throwing 500 when pg_graphql detects unique constraint (#5323)
## Context
Since pg_graphql does not return specific error/exception, we have to
map the error message and throw validation errors when needed
This PR adds a check on unicity constraint error returned by pg_graphql
when we are trying to insert duplicate records and returns a 400 instead
of being handled by the exceptionHandler as a 500.
2024-05-07 21:03:15 +02:00
Weiko
e802cef8f1
Fix 400 yoga errors being sent to exception handlers (#5322)
## Context
Yoga can catch its own errors and we don't want to convert them again.
Moreover those errors don't have an "originalError" property and should
be schema related only (400 validation) so we only want to send them
back to the API caller without going through the exception handler.

Also fixed an issue in the createMany which was throwing a 500 when id
was missing from the creation payload. It seems the FE is always sending
an ID but it should actually be optional since the DB can generate one.
This is a regression from the new UUID validation introduced a few weeks
ago.
2024-05-07 20:54:10 +02:00
Marie
7c3e82870c
[fix] Increment cache version after object/field/relation update (#5316)
Fixes #5276.

Updates were not triggering a cache version incrementation because they
do not trigger migrations while that is where the caching version logic
was.
We have decided to move the cache incrementation logic to the services.
2024-05-07 16:30:25 +02:00
Weiko
8074aae449
Split job modules (#5318)
## Context
JobsModule is hard to maintain because we provide all the jobs there,
including their dependencies. This PR aims to split jobs in dedicated
modules.
2024-05-07 14:08:20 +02:00
Weiko
ffd804d04b
Fix convertRecordPositionsToIntegers command for camelCase tables (#5315)
## Context
Per title, postgresql will use lowercase if not surrounded by quotes
2024-05-07 11:07:20 +02:00
Charles Bochet
a2017eaeb7
Improve messaging/calendar create contact performance (#5314)
In this PR, I'm refactoring the way we associate messageParticipant post
person/company creation. Instead of looking a all person without
participant, we are passing the one that were just created.

Also, I'm making sure the message and messageParticipant creation
transaction is commited before creating person/company creation (and
then messageParticipant association)
2024-05-06 23:43:18 +02:00
Charles Bochet
2c9f50ecb1
Fix enum defaultValue issues (#5307)
This PR fixes several issues:
- enum naming should be: {tableName}_{fieldName}_enum and respecting the
case
- defaultValue format handled in the FE should respect the one in the BE

In my opinion we should refactor the defaultValue:
- we should respect backend format: "'myDefault'" for constant default
and "0" for float, "now" for expressions, "true" for booleans. we can
rename it to defaultValueExpression if it is more clear but we should
not maintain a parallel system
- we should deprecate option: isDefaultValue which is confusing
- we should re-work backend to have a more unified approach between
fields and avoid having if everywhere about select, multiselect, and
currency cases. one unified "computeDefaultValue" function should do the
job

What is still broken:
- currency default Value on creation. I think we should do the refactor
first
- select default value edition.
These cases do not break the schema but are ignored currently
2024-05-06 17:00:38 +02:00
Pacifique LINJANJA
ff77a4ee21
Feat/migrate password reset token to app token table (#5051)
# This PR

- Fix #5021 
- Migrates `passwordResetToken` and `passwordResetTokenExpiresAt` fields
from `core.users` to `core.appToken`
- Marks those fields as `deprecated` so we can remove them later if we
are happy with the transition -- I took this decision on my own,
@FellipeMTX let me know what you think about it, we can also remove them
straight away if you think it's better
- Fixed the `database:migration` script from the `twenty-server` to:
```json
    "database:migrate": {
      "executor": "nx:run-commands",
      "dependsOn": ["build"], // added this line
      "options": {
        "cwd": "packages/twenty-server",
        "commands": [
          "nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource",
          "nx typeorm -- migration:run -d src/database/typeorm/core/core.datasource"
        ],
        "parallel": false
      }
    },
```
The migration script wasn't running because the builds were not executed
- [x] Added unit tests for the token.service file's changes

Looking forward to hearing feedback from you

cc: @charlesBochet

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-05-06 15:30:03 +02:00
Jérémy M
b207d10312
feat: extend twenty orm (#5238)
This PR is a follow up of PR #5153.
This one introduce some changes on how we're querying composite fields.
We can do:

```typescript
export class CompanyService {
  constructor(
    @InjectWorkspaceRepository(CompanyObjectMetadata)
    private readonly companyObjectMetadataRepository: WorkspaceRepository<CompanyObjectMetadata>,
  ) {}

  async companies(): Promise<CompanyObjectMetadata[]> {
    // Old way
    // const companiesFilteredByLinkLabel = await this.companyObjectMetadataRepository.find({
    //   where: { xLinkLabel: 'MyLabel' },
    // });
    // Result will return xLinkLabel property

    // New way
    const companiesFilteredByLinkLabel = await this.companyObjectMetadataRepository.find({
      where: { xLink: { label:  'MyLabel' } },
    });
    // Result will return { xLink: { label: 'MyLabel' } } property instead of  { xLinkLabel: 'MyLabel' }

    return companiesFilteredByLinkLabel;
  }
}
```

Also we can now inject `TwentyORMManage` class to manually create a
repository based on a given `workspaceId` using
`getRepositoryForWorkspace` function that way:

```typescript
export class CompanyService {
  constructor(
    // TwentyORMModule should be initialized
    private readonly twentyORMManager,
  ) {}

  async companies(): Promise<CompanyObjectMetadata[]> {
    const repository = await this.twentyORMManager.getRepositoryForWorkspace(
      '8bb6e872-a71f-4341-82b5-6b56fa81cd77',
      CompanyObjectMetadata,
    );

    const companies = await repository.find();

    return companies;
  }
}
```
2024-05-06 14:12:11 +02:00
Weiko
154ae99ed3
[flexible-schema] Add reserved keyword check on object creation (#5303)
## Context
Because creating an object in metadata also generates a graphql type and
because graphql does not allow 2 types with the same name, we have to
manage a list of reserved keywords that can't be used as object names.

Currently we were maintaining a list of the core objects but we also
have to introduce composite fields that are also generated as gql types.
2024-05-06 13:44:40 +02:00
Thaïs
fc87a51acf
fix: fix storybook:build memory allocation error in CI (#5284) 2024-05-03 19:19:21 +02:00
Charles Bochet
839a7e2a10
Bump versions to 0.11 (#5289)
As per title! 
Bumping to 0.11.1 as we have already merged a few minor upgrades on top
of 0.11
2024-05-03 19:11:03 +02:00
Charles Bochet
a750901582
Remove Feature Flag on Calendar (#5288)
Remove Calendar feature Flag!
2024-05-03 19:10:33 +02:00
Weiko
381bf0fc8d
Create convert record positions to integers command (#5287)
## Context
Positions are used within a view to display and sort the different
records of standard/custom object.
When we add a new record and want to put it before the existing first
record, we have to use float values to insert them in the DB and respect
the desired order. We are adding a new command that can be executed to
flatten those positions.

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
2024-05-03 19:05:56 +02:00
Weiko
abf0f4664d
Fix yoga patch user id cache (#5285)
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-03 18:47:31 +02:00
Thomas Trompette
a5a9e0e238
Remove isMultiSelect feature flag (#5280)
As title

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-05-03 16:30:58 +02:00
Charles Bochet
1d9cd234ea
Fix white screen on token expire (#5271)
While using middleware (executed pre-graphql) for graphql endpoint, we
need to swallow exception and return errors with a 200. Otherwise it's
not a valid graphql response
2024-05-03 15:35:49 +02:00
Weiko
50421863d4
Fix filter transform with logic operators (#5269)
Various fixes

- Remote objects are read-only for now, we already hide and block most
of the write actions but the button that allows you to add a new record
in an empty collection was still visible.
- CreatedAt is not mandatory on remote objects (at least for now) so it
was breaking the show page, it now checks if createdAt exists and is not
null before trying to display the human readable format `Added x days
ago`
- The filters are overwritten in query-runner-args.factory.ts to handle
NUMBER field type, this was only working with filters like
```
      {
        "id": {
          "in": [
            1
          ]
        }
```
but not with more depth such as 
```
    "and": [
      {},
      {
        "id": {
          "in": [
            1
          ]
        }
      }
    ]
 ```
- Fixes CREATE FOREIGN TABLE raw query which was missing ",".
2024-05-03 14:52:20 +02:00
Weiko
30ffe0160e
Fix token validation on graphql IntrospectionQuery (#5255)
## Context
We recently introduced a change that now throws a 401 if the token is
invalid or expired.
The first implementation is using an allow list and 'IntrospectionQuery'
was missing so the playground was broken.

The check has been updated and we now only check the excludedOperations
list if a token is not present. This is because some operations can be
both used as loggedIn and loggedOut so we want to validate the token for
those sometimes (and set the workspace, user, cache version, etc). Still
not a very clean solution imho.
2024-05-03 10:30:47 +02:00
Weiko
fe758e193f
fix workspace-member deletion with existing attachments/documents (#5232)
## Context
We have a non-nullable constraint on authorId in attachments and
documents, until we have soft-deletion we need to handle deletion of
workspace-members and their attachments/documents.
This PR introduces pre-hooks to deleteOne/deleteMany
This is called when a user deletes a workspace-member from the members
page

Next: needs to be done on user level as well. This is called when users
try to delete their own accounts. I've seen other issues such as
re-creating a user with a previously used email failing.
2024-05-02 17:36:57 +02:00
Thomas Trompette
f9c19c839b
Build stripe integration on backend side (#5246)
Adding stripe integration by making the server logic independent of the
input fields:
- query factories (remote server, foreign data wrapper, foreign table)
to loop on fields and values without hardcoding the names of the fields
- adding stripe input and type
- add the logic to handle static schema. Simply creating a big object to
store into the server

Additional work:
- rename username field to user. This is the input intended for postgres
user mapping and we now need a matching by name

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-05-02 17:13:15 +02:00
Charles Bochet
f802964de4 Bump to 0.10.6 2024-05-02 15:55:11 +02:00
Charles Bochet
3015f4ce31
Fix sync metadata script (#5253)
While troubleshooting self-hosting migration, we run into issues with
sync-metadata script introduced by recent changes
2024-05-02 15:50:40 +02:00
brendanlaschke
05a90d6153
Constant api version (#5248)
closes #5206
2024-05-02 14:21:19 +02:00
Weiko
9a116b08a4
User workspace middleware throws 401 if token is invalid (#5245)
## Context
Currently, this middleware validates the token and stores the user,
workspace and cacheversion in the request object.
It only does so when a token is provided and ignores the middleware
logic if not. If the token is invalid or expired, the exception is
swallowed.

This PR removes the try/catch and adds an allowlist to skip the token
validation for operations executed while not signed-in.
I don't know a better way to do that with Nestjs. We can't easily add
the middleware per resolver without refactoring the flexible schema
engine so I'm doing it the other way around.

Fixes https://github.com/twentyhq/twenty/issues/5224
2024-05-02 12:54:01 +02:00
Charles Bochet
27a3d7ec27 Bump to 0.10.5 2024-05-02 11:00:24 +02:00
Thaïs
0d023e5e77
feat: update links field (#5212)
Closes #5113

---------

Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
2024-05-01 14:56:55 +02:00
Thaïs
8853226d17
feat: add Links field type (#5176)
Closes #5113

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-05-01 11:56:14 +02:00
Marie
e0ece3c917
Rename types for UserMappingOptions (#5230)
Following #5210

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-01 11:46:47 +02:00
Marie
1b2ed80c1c
[feat][Remote objects] Edit a connection (for pg) (#5210)
## Context
#4774 

## How was it tested
Locally

## In further PRs
- Update connection status upon page change
- Adapt Info banner to dark mode
- placeholders for form
2024-04-30 17:46:30 +02:00
bosiraphael
3bf9045990
Fix record position on contact creation (#5227)
Fix record position on contact creation

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-04-30 17:09:29 +02:00
Weiko
bc0d30f28b
[flexible-backend] handle object already exists error (#5225)
## Context
Currently we have an unicity constraint in the DB but we don't return a
clear error to the frontend before reaching the DB (which then throws a
500). This PR adds a validation check similar to what we have with field
creation
2024-04-30 16:36:02 +02:00
Thaïs
c193663a71
chore: use Nx affected tasks in CI (#5110)
Closes #5097

- Uses "nx affected" to detect what projects need to be checked in the
current PR (for now, `ci-front` and `ci-server` workflows only).
- Caches results of certain tasks (`lint`, `typecheck`, `test`,
`storybook:build`) when a PR pipeline runs. The next runs of the same
PR's pipeline will then be able to reuse the PR's task cache to execute
tasks faster.
- Caches Yarn's cache folder to install dependencies faster in CI jobs.
- Rewrites the node modules cache/install steps as a custom, reusable
Github action.
- Distributes `ci-front` jobs with a "matrix" strategy.
- Sets common tasks config at the root `nx.json`. For instance, to
activate the `typecheck` task in a project, add `typecheck: {}` to its
`project.json` and it'll use the default config set in `nx.json` for the
`typecheck` task. Options can be overridden in each individual
`project.json` if needed.
- Adds "scope" tags to some projects: `scope:frontend`, `scope:backend`,
`scope:shared`. An eslint rule ensures that `scope:frontend` only
depends on `scope:frontent` or `scope:shared` projects, same for
`scope:backend`. These tags are used by `nx affected` to filter projects
by scope and generates different task cache keys according to the
requested scope.
- Enables checks for twenty-emails in the `ci-server` workflow.
2024-04-30 16:28:25 +02:00
Weiko
a77cb023c0
Flush cache when reset db (#5214)
Now that we have persistent cache for schemas, we want to be able to
reset its state when users run the database:reset db otherwise schemas
won't be synced with the new DB state.

Note: In an upcoming PR, we want to be able to invalidate the cache on a
workspace level when we change the metadata schema through twenty
version upgrade
2024-04-30 15:03:24 +02:00
Weiko
f512049381
[messaging/calendar] cron jobs can run regardless of sub status if billing is disabled (#5218)
## Context
Messaging and calendar cron jobs are only working for workspace that
have sub status different than incomplete, this is because currently
this is the simplest way to know if a user is onboarded. This should not
be the source of truth and this will be updated in a later version. In
the meantime, to make self-hosting easier, we are adding an extra check
on IS_BILLING_ENABLED env var since sub status is not relevant for
people not using billing.
2024-04-30 15:01:22 +02:00
bosiraphael
7c605fc2f9
4002 prevent user from creating twice the same blocklist item (#5213)
Closes #4002
2024-04-30 14:36:33 +02:00
Thomas Trompette
3a61c922f1
Import full distant schema and store in remote server (#5211)
We should not depend on the foreign data wrapper type to manage distant
table. The remote server should be enough to handle the table creation.

Here is the new flow to fetch available tables:
- check if the remote server have available tables already stored
- if not, import full schema in a temporary schema
- copy the tables into the available tables field 
- delete the schema

Left todo:
- update remote server input for postgres so we receive the schema

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-30 14:18:33 +02:00
Charles Bochet
dd366dba47 Bump version to 0.10.4 2024-04-29 23:48:15 +02:00
Jérémy M
e2185448ed
Feat/twenty orm (#5153)
## Introduction

This PR introduces "TwentyORM," a custom ORM module designed to
streamline database interactions within our workspace schema, reducing
the need for raw SQL queries. The API mirrors TypeORM's to provide a
familiar interface while integrating enhancements specific to our
project's needs.

To facilitate this integration, new decorators prefixed with `Workspace`
have been implemented. These decorators are used to define entity
metadata more explicitly and are critical in constructing our schema
dynamically.

## New Features

- **Custom ORM System**: Named "TwentyORM," which aligns closely with
TypeORM for ease of use but is tailored to our application's specific
requirements.
- **Decorator-Driven Configuration**: Entities are now configured with
`Workspace`-prefixed decorators that clearly define schema mappings and
relationships directly within the entity classes.
- **Injectable Repositories**: Repositories can be injected similarly to
TypeORM, allowing for flexible and straightforward data management.

## Example Implementations

### Decorated Entity Definitions

Entities are defined with new decorators that outline table and field
metadata, relationships, and constraints. Here are examples of these
implementations:

#### Company Metadata Object

```typescript
@WorkspaceObject({
  standardId: STANDARD_OBJECT_IDS.company,
  namePlural: 'companies',
  labelSingular: 'Company',
  labelPlural: 'Companies',
  description: 'A company',
  icon: 'IconBuildingSkyscraper',
})
export class CompanyObjectMetadata extends BaseObjectMetadata {
  @WorkspaceField({
    standardId: COMPANY_STANDARD_FIELD_IDS.name,
    type: FieldMetadataType.TEXT,
    label: 'Name',
    description: 'The company name',
    icon: 'IconBuildingSkyscraper',
  })
  name: string;

  @WorkspaceField({
    standardId: COMPANY_STANDARD_FIELD_IDS.xLink,
    type: FieldMetadataType.LINK,
    label: 'X',
    description: 'The company Twitter/X account',
    icon: 'IconBrandX',
  })
  @WorkspaceIsNullable()
  xLink: LinkMetadata;

  @WorkspaceField({
    standardId: COMPANY_STANDARD_FIELD_IDS.position,
    type: FieldMetadataType.POSITION,
    label: 'Position',
    description: 'Company record position',
    icon: 'IconHierarchy2',
  })
  @WorkspaceIsSystem()
  @WorkspaceIsNullable()
  position: number;

  @WorkspaceRelation({
    standardId: COMPANY_STANDARD_FIELD_IDS.accountOwner,
    label: 'Account Owner',
    description: 'Your team member responsible for managing the company account',
    type: RelationMetadataType.MANY_TO_ONE,
    inverseSideTarget: () => WorkspaceMemberObjectMetadata,
    inverseSideFieldKey: 'accountOwnerForCompanies',
    onDelete: RelationOnDeleteAction.SET_NULL,
  })
  @WorkspaceIsNullable()
  accountOwner: WorkspaceMemberObjectMetadata;
}
```

#### Workspace Member Metadata Object

```typescript
@WorkspaceObject({
  standardId: STANDARD_OBJECT_IDS.workspaceMember,
  namePlural: 'workspaceMembers',
  labelSingular: 'Workspace Member',
  labelPlural: 'Workspace Members',
  description: 'A workspace member',
  icon: 'IconUserCircle',
})
@WorkspaceIsSystem()
@WorkspaceIsNotAuditLogged()
export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
  @WorkspaceField({
    standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.name,
    type: FieldMetadataType.FULL_NAME,
    label: 'Name',
    description: 'Workspace member name',
    icon: 'IconCircleUser',
  })
  name: FullNameMetadata;

  @WorkspaceRelation({
    standardId: WORKSPACE_MEMBER_STANDARD_FIELD_IDS.accountOwnerForCompanies,
    label: 'Account Owner For Companies',
    description: 'Account owner for companies',
    icon: 'IconBriefcase',
    type: RelationMetadataType.ONE_TO_MANY,
    inverseSideTarget: () => CompanyObjectMetadata,
    inverseSideFieldKey: 'accountOwner',
    onDelete: RelationOnDeleteAction.SET_NULL,
  })
  accountOwnerForCompanies: Relation

<CompanyObjectMetadata[]>;
}
```

### Injectable Repository Usage

Repositories can be directly injected into services, allowing for
streamlined query operations:

```typescript
export class CompanyService {
  constructor(
    @InjectWorkspaceRepository(CompanyObjectMetadata)
    private readonly companyObjectMetadataRepository: WorkspaceRepository<CompanyObjectMetadata>,
  ) {}

  async companies(): Promise<CompanyObjectMetadata[]> {
    // Example queries demonstrating simple and relation-loaded operations
    const simpleCompanies = await this.companyObjectMetadataRepository.find({});
    const companiesWithOwners = await this.companyObjectMetadataRepository.find({
      relations: ['accountOwner'],
    });
    const companiesFilteredByLinkLabel = await this.companyObjectMetadataRepository.find({
      where: { xLinkLabel: 'MyLabel' },
    });

    return companiesFilteredByLinkLabel;
  }
}
```

## Conclusions

This PR sets the foundation for a decorator-driven ORM layer that
simplifies data interactions and supports complex entity relationships
while maintaining clean and manageable code architecture. This is not
finished yet, and should be extended.
All the standard objects needs to be migrated and all the module using
the old decorators too.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-04-29 16:47:42 +02:00
bosiraphael
6cafd25c97
Fix duplicated calendar events (#5209)
Fix duplicated calendar events when two workspace members participate to
the same event.
2024-04-29 15:23:40 +02:00
Charles Bochet
e976a1bdfc
Uniformize datasources (#5196)
## Context

We recently enabled the option to bypass SSL certificate authority
validation when establishing a connection to PostgreSQL. Previously, if
this validation failed, the server would revert to unencrypted traffic.
Now, it maintains encryption even if the SSL certificate check fails. In
the process, we overlooked a few DataSource setups, prompting a review
of DataSource creation within our code.

## Current State

Our DataSource initialization is distributed as follows:
- **Database folder**: Contains 'core', 'metadata', and 'raw'
DataSources. The 'core' and 'metadata' DataSources manage migrations and
static resolver calls to the database. The 'raw' DataSource is utilized
in scripts and commands that require handling both aspects.
- **typeorm.service.ts script**: These DataSources facilitate
multi-schema connections.

## Vision for Discussion
- **SystemSchema (formerly core) DataSource**: Manages system schema
migrations and system resolvers/repos. The 'core' schema will be renamed
to 'system' as the Core API will include parts of the system and
workspace schemas.
- **MetadataSchema DataSource**: Handles metadata schema migrations and
metadata API resolvers/repos.
- **(Dynamic) WorkspaceSchema DataSource**: Will be used in the Twenty
ORM to access a specific workspace schema.

We currently do not support cross-schema joins, so maintaining these
DataSources separately should be feasible. Core API resolvers will
select the appropriate DataSource based on the field context.
- **To be discussed**: The potential need for an AdminDataSource (akin
to 'Raw'), which would be used in commands, setup scripts, and the admin
panel to connect to any database schema without loading any model. This
DataSource should be reserved for cases where utilizing metadata,
system, or workspace entities is impractical.

## In This PR
- Ensuring all existing DataSources are compliant with the SSL update.
- Introducing RawDataSource to eliminate the need for declaring new
DataSource() instances in commands.
2024-04-27 11:43:44 +02:00
Weiko
ebc25c8695
Add redis to useMetadataCache yoga plugin (#5194)
## Context
@lucasbordeau introduced a new Yoga plugin that allows us to cache our
requests (👏), see https://github.com/twentyhq/twenty/pull/5189
I'm simply updating the implementation to allow us to use different
cache storage types such as redis
Also adding a check so it does not use cache for other operations than
ObjectMetadataItems

## Test
locally, first call takes 340ms, 2nd takes 30ms with 'redis' and 13ms
with 'memory'
2024-04-26 19:27:09 +02:00
bosiraphael
5e143f1f49
5187 delete all emails and events from a blocklisted domain name (#5190)
Closes #5187
2024-04-26 18:24:02 +02:00
Marie
76d4188ba8
[feat] Add updateRemoteServer endpoint (#5148)
## Context
#4765 

Following investigations
([#5083](https://github.com/twentyhq/twenty/issues/5083)) we decided to
restrict updates of server from which zero tables have been synchronized
only

## How was it tested
Locally with /metadata
1. Updating a database that already has synchronized tables
<img width="1072" alt="Capture d’écran 2024-04-24 à 16 16 05"
src="https://github.com/twentyhq/twenty/assets/51697796/f9a84c34-2dcd-4f3c-b0bc-b710abae5021">

2. Updating a database that has no synchronized tables
<img width="843" alt="Capture d’écran 2024-04-24 à 16 17 28"
src="https://github.com/twentyhq/twenty/assets/51697796/f320fe03-a6bc-4724-bcd0-4e89d3ac31f5">
+ tested that the connection works well
2024-04-26 18:12:08 +02:00
Charles Bochet
b15533e4b3 Bump version to 0.10.3 2024-04-26 17:52:13 +02:00
Lucas Bordeau
77eece77ea
Add a cache on /metadata (#5189)
In this PR I'm introducing a simple custom graphql-yoga plugin to create
a caching mechanism specific to our metadata.

The cache key is made of : workspace id + workspace cache version, with
this the cache is automatically invalidated each time a change is made
on the workspace metadata.
2024-04-26 17:31:40 +02:00
Thomas Trompette
224c8d361b
Setup relations for remote objects (#5149)
New strategy:
- add settings field on FieldMetadata. Contains a boolean isIdField and
for numbers, a precision
- if idField, the graphql scalar returned will be a GraphQL id. This
will allow the app to work even for ids that are not uuid
- remove globals dateScalar and numberScalar modes. These were not used
- set limit as Integer
- check manually in query runner mutations that we send a valid id

Todo left:
- remove WorkspaceBuildSchemaOptions since this is not used anymore.
Will do in another PR

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Co-authored-by: Weiko <corentin@twenty.com>
2024-04-26 14:37:34 +02:00
Deepak Kumar
dc576d0818
GH-3546 Recaptcha on login form (#4626)
## Description

This PR adds recaptcha on login form. One can add any one of three
recaptcha vendor -
1. Google Recaptcha -
https://developers.google.com/recaptcha/docs/v3#programmatically_invoke_the_challenge
2. HCaptcha -
https://docs.hcaptcha.com/invisible#programmatically-invoke-the-challenge
3. Turnstile -
https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#execution-modes

### Issue
- #3546 

### Environment variables - 
1. `CAPTCHA_DRIVER` - `google-recaptcha` | `hcaptcha` | `turnstile`
2. `CAPTCHA_SITE_KEY` - site key
3. `CAPTCHA_SECRET_KEY` - secret key

### Engineering choices
1. If some of the above env variable provided, then, backend generates
an error -
<img width="990" alt="image"
src="https://github.com/twentyhq/twenty/assets/60139930/9fb00fab-9261-4ff3-b23e-2c2e06f1bf89">
    Please note that login/signup form will keep working as expected.
2. I'm using a Captcha guard that intercepts the request. If
"captchaToken" is present in the body and all env is set, then, the
captcha token is verified by backend through the service.
3. One can use this guard on any resolver to protect it by the captcha.
4. On frontend, two hooks `useGenerateCaptchaToken` and
`useInsertCaptchaScript` is created. `useInsertCaptchaScript` adds the
respective captcha JS script on frontend. `useGenerateCaptchaToken`
returns a function that one can use to trigger captcha token generation
programatically. This allows one to generate token keeping recaptcha
invisible.

### Note
This PR contains some changes in unrelated files like indentation,
spacing, inverted comma etc. I ran "yarn nx fmt:fix twenty-front" and
"yarn nx lint twenty-front -- --fix".

### Screenshots

<img width="869" alt="image"
src="https://github.com/twentyhq/twenty/assets/60139930/a75f5677-9b66-47f7-9730-4ec916073f8c">

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-04-25 23:52:28 +02:00
martmull
44855f0317
Fix broken billing portal when subscription canceled (#5082)
Fix billing portal link for canceled subscription
2024-04-25 18:33:49 +02:00
bosiraphael
9f1818aef7
4748 create updated listener on blocklist (#5145)
Closes #4748
2024-04-25 17:39:56 +02:00
bosiraphael
d23e02adca
4001 add validation for blocklist (#5172)
Closes #4001
2024-04-25 15:32:55 +02:00
Quentin G
806666d909
feat: allow self signed certificates with postgres connections (#5143) 2024-04-25 15:29:07 +02:00
Charles Bochet
11a7db5672
Fix workspace schema caching when user is not logged in (#5173)
In this PR:
- Follow up on #5170 as we did not take into account not logged in users
- only apply throttler on root fields to avoid performance overhead
2024-04-25 14:45:14 +02:00
Lucas Bordeau
52f4c34cd6
Cache yoga conditional schema (#5170)
In this PR I'm introducing a new patch on @graphql-yoga/nestjs package.

This patch overrides a previous patch that was made to compute the
conditionnal schema on each request,

Here we use a cache map to compute only once per schema workspace cache
version.

This allows us to have sub 100ms query time.
2024-04-25 14:01:32 +02:00
Charles Bochet
07c8779411
Fix broken sync-metadata (#5154)
An error has been recently introduced in the sync of fieldMetadata. This
PR fixes it

Additionnally, we are enabling email for trialing and past_due
workspaces. There is an ongoing work to introduce a more robust
activationStatus on workspace.
2024-04-24 17:45:17 +02:00
bosiraphael
0f47426d19
4747 create deleted listener on blocklist (#5067)
Closes #4747
2024-04-24 16:10:56 +02:00
bosiraphael
d130b78166
5044 Dispatch createcontact job instead of emitting an event (#5135)
Closes #5044
2024-04-24 15:01:13 +02:00
martmull
87a9ecee28
D gamer007/add microsoft oauth (#5103)
Need to create a new branch because original branch name is `main` and
we cannot push additional commits
Linked to https://github.com/twentyhq/twenty/pull/4718


![image](https://github.com/twentyhq/twenty/assets/29927851/52b220e7-770a-4ffe-b6e9-468605c2b8fa)

![image](https://github.com/twentyhq/twenty/assets/29927851/7a7a4737-f09f-4d9b-8962-5a9b8c71edc1)

---------

Co-authored-by: DGamer007 <prajapatidhruv266@gmail.com>
2024-04-24 14:56:02 +02:00
Charles Bochet
b3e1d6becf
Fix default value fixer script (#5144)
While trying to migrate a workspace from 0.3.3 to 0.10.0, we've faced an
issue with the script to migrate default-values format.
This PR fixes it.

We really need to add tests on this part ;)
2024-04-24 14:50:57 +02:00
Hinson Chan
3b0f81e7e1
5125 - fix npx nx start does not exit gracefully (#5133)
Fixes: https://github.com/twentyhq/twenty/issues/5125

Updated nx version that includes fix (see fix PR:
https://github.com/nrwl/nx/pull/22895, release confirming fix:
https://github.com/nrwl/nx/releases/tag/18.3.3)

<img width="291" alt="image"
src="https://github.com/twentyhq/twenty/assets/68029599/b72b4a5c-9957-445d-b8b2-8352122cade8">
2024-04-24 11:53:53 +02:00
Aditya Pimpalkar
c63ee519ea
feat: oauth for chrome extension (#4870)
Previously we had to create a separate API key to give access to chrome
extension so we can make calls to the DB. This PR includes logic to
initiate a oauth flow with PKCE method which redirects to the
`Authorise` screen to give access to server tokens.

Implemented in this PR- 
1. make `redirectUrl` a non-nullable parameter 
2. Add `NODE_ENV` to environment variable service
3. new env variable `CHROME_EXTENSION_REDIRECT_URL` on server side
4. strict checks for redirectUrl
5. try catch blocks on utils db query methods
6. refactor Apollo Client to handle `unauthorized` condition
7. input field to enter server url (for self-hosting)
8. state to show user if its already connected
9. show error if oauth flow is cancelled by user

Follow up PR -
Renew token logic

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-04-24 11:45:16 +02:00
Charles Bochet
fafa56411c
Fix email sync (#5132) 2024-04-23 18:50:37 +02:00
Marie
ff39ba5a15
[fix] Support non latin characters in schema names (#5063)
Fixes #4943

## How was it tested?
Local (front + /metadata)
Unit tests for utils

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-04-23 13:37:29 +02:00
bosiraphael
824786ff04
4746 create created listener on blocklist for calendar (#5046)
Follows #5031.
Closes #4746
2024-04-23 11:46:27 +02:00
Dev
bd2a6cbbd3
Add company to default opportunity fields (#5075)
Fixes #4484 

<img width="1904" alt="Screenshot 2024-04-21 at 6 58 10 AM"
src="https://github.com/twentyhq/twenty/assets/21654351/dd1dcd3b-3bbe-48d9-8576-dc6e885fc11e">
2024-04-23 11:43:27 +02:00
Weiko
fa4670b14d
chore: extend root eslint config in twenty-server (#5101)
Reopening @thaisguigon work from
https://github.com/twentyhq/twenty/pull/4781

---------

Co-authored-by: Thaïs Guigon <guigon.thais@gmail.com>
2024-04-22 17:34:24 +02:00
Charles Bochet
3e8d42f2ed Fix standard field ids of timelineActivities relations 2024-04-20 19:29:42 +02:00
Charles Bochet
72b7d41cac Fix syncing of old event models 2024-04-20 18:12:27 +02:00
Charles Bochet
d77ad1052c Fix demo workspace seed 2024-04-20 00:11:04 +02:00
Thaïs
d3170fc1ea
fix: fix root start script (#5032)
Fixes #5022

See https://nx.dev/recipes/running-tasks/root-level-scripts#setup
2024-04-19 18:28:02 +02:00
Félix Malfait
d145684966
New Timeline (#4936)
Refactored the code to introduce two different concepts:
- AuditLogs (immutable, raw data)
- TimelineActivities (user-friendly, transformed data)

Still some work needed:
- Add message, files, calendar events to timeline (~2 hours if done
naively)
- Refactor repository to try to abstract concept when we can (tbd, wait
for Twenty ORM)
- Introduce ability to display child timelines on parent timeline with
filtering (~2 days)
- Improve UI: add links to open note/task, improve diff display, etc
(half a day)
- Decide the path forward for Task vs Notes: either introduce a new
field type "Record Type" and start going into that direction ; or split
in two objects?
- Trigger updates when a field is changed (will be solved by real-time /
websockets: 2 weeks)
- Integrate behavioral events (1 day for POC, 1 week for
clean/documented)

<img width="1248" alt="Screenshot 2024-04-12 at 09 24 49"
src="https://github.com/twentyhq/twenty/assets/6399865/9428db1a-ab2b-492c-8b0b-d4d9a36e81fa">
2024-04-19 17:52:57 +02:00
Weiko
3a959248f9
Fix billing check for trial sub status (#5054)
## Context
Sub status is not binary as you can also be in trial mode and still
should be able to share invite link. This PR should fix this issue
2024-04-19 15:16:08 +02:00
martmull
36d4c38c3d
Check password in signinup only when email/password signInUp (#5042)
- disable password check when signInUp from google (sso)
- check password when signInUp with email password
2024-04-18 17:52:01 +02:00
Weiko
220a0e91d2
[messaging/calendar] fix missing authFailedAt reset once refreshToken is updated (#5037) 2024-04-18 15:43:35 +02:00
bosiraphael
8702c71d45
4746 create created listener on blocklist (#5031)
Closes #4746 for messaging.

I will create another PR to implement the listener on calendar.
2024-04-18 15:06:13 +02:00
Thomas Trompette
b08e95494c
Move id column check before foreign table creation (#5029)
When distant table does not have an id column, syncing does not work.
Today the check is only made after creating the foreign table locally.
We should do it first, so we avoid having a foreign table created and
failing right after.

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-18 11:34:21 +02:00
Charles Bochet
977927af04
Disable audit log on system objects (#5018)
## Context

We have recently added an event listener to create audit logs on objects
update. However, we have only created the structure (relations on event
standard objects) for Company, Person, Opportunity and custom objects.
There is a larger effort in #4936 to refactor this.
For now, we are disabling log auditing on all other objects

## How
Add @IsNotAuditLogged() annotation on all standard objects except
Company, Person, Opportunity
2024-04-17 17:52:39 +02:00
Thomas Trompette
6cf3ade300
Make id available in remote table output (#5003)
Wrongly use `PrimaryGeneratedColumn` typeOrm decorator instead of the
nest query one.

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-17 17:05:47 +02:00
Weiko
979b8d29cc
UpdateSubscriptionJob should not be enqueued if billing is not enabled (#5007)
## Context
Adding this check to avoid enqueuing this job and following return-early
good practice

## Test
Without IS_BILLING_ENABLED env set

<img width="565" alt="Screenshot 2024-04-17 at 15 31 12"
src="https://github.com/twentyhq/twenty/assets/1834158/fcc43ce0-4455-4c4a-9889-02d99f0cd519">

With IS_BILLING_ENABLED env set
<img width="581" alt="Screenshot 2024-04-17 at 15 32 28"
src="https://github.com/twentyhq/twenty/assets/1834158/dc9756bd-2f6b-49bd-8897-84b6d8e09d56">
2024-04-17 17:04:48 +02:00
Weiko
6804a90f2f
Fix invite link sign-up with workspace without subcription and billing not enabled (#5006)
## Context

We recently introduced this verification but we didn't take into account
self-hosting that might not use billing.

## Test
tested locally with
- new workspace and new account
- existing workspace with new account and billing not enabled and status
incomplete => OK
- existing workspace with new account and billing enabled and status
incomplete => NOK
- existing workspace with new account and billing enabled and status
active => OK
2024-04-17 15:09:51 +02:00
bosiraphael
3024e04a1c
4971 add issyncenabled toggle in messaging settings (#4995)
- Closes #4971
- Fix calendar import to take isSyncEnabled into account
2024-04-17 13:35:23 +02:00
Weiko
6211f84de8
block invite link if workspace subscription is not active (#4991)
Fixes https://github.com/twentyhq/twenty/issues/4980

## Test
tested locally with incomplete and active
2024-04-17 10:55:47 +02:00
Thomas Trompette
6fa2aee624
Introduce remote table entity (#4994)
We will require remote table entity to map distant table name and local
foreign table name.
Introducing the entity:
- new source of truth to know if a table is sync or not
- created synchronously at the same time as metadata and foreign table

Adding a few more changes:
- exception rather than errors so the user can see these
- `pluralize` library that will allow to stop adding `Remote` suffix on
names

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-17 10:52:10 +02:00
Weiko
2efc794b43
[messaging] Add message deletion during partial sync (#4972)
## Context

- Rename remaining V2 services.
- Delete messages in DB when gmail history tells us they've been
deleted. I removed the logic where we store those in a cache since it's
a bit overkill because we don't need to query gmail and can use those
ids directly. The strategy is to delete the message channel message
association of the current channel, not the message or the thread since
they can still be linked to other channels. However, we will need to
call the threadCleaner service on the workspace to remove orphan
threads/non-associated messages.

Note: deletion for full-sync is a bit tricky because we need the full
list of message ids to compare with the DB and make sure we don't
over-delete. Currently, to keep memory, we don't have a variable that
holds all ids as we flush it after each page. Easier solution would be
to wipe everything before each full sync but it's probably not great for
the user experience if they are currently manipulating messages since
full-sync can happen without a user intervention (if a partial sync
fails due to historyId being invalidated by google for some reason)
2024-04-16 17:18:06 +02:00
bosiraphael
d63937ec6f
4988 dont import emails with ics attachments (#4990)
- Closes #4988 
- Fix parenthesis error in filter
2024-04-16 15:45:31 +02:00
Weiko
4bf23780a1
[calendar/messaging] fix google refresh token transaction (#4989)
## Context
The full-sync job was enqueued within a transaction, which means it
could be executed before the transaction was commit and
connected-account was not created yet.
This PR re-arrange the code a bit to avoid this

cc @bosiraphael thx for flagging this!
2024-04-16 15:06:37 +02:00
Weiko
cd6ed867be
fix google oauth guard (#4987)
## Context
Recent PR introduced a verifyTransientToken inside the
GoogleAPIsProviderEnabledGuard guard. This is used to extract the
workspaceId from the token. This is working fine for the first call sent
to google however the callback is calling the same guard which is
causing an issue because the transientToken is missing from the
callback.
Imho, the same guard shouldn't be used by the callback but for the time
being I'm adding a check to prevent using feature flag when
transientToken is absent. In fact, it is present in the request but not
in the same key. Because the scope is only relevant for the first call,
I'm simply adding a check there.
2024-04-16 12:47:59 +02:00