Commit Graph

1253 Commits

Author SHA1 Message Date
7d7955fc65 Move capitalize into twenty-shared (#9414)
capitalize had been moved into twenty-shared. Let's remove the
duplicates in server and front !
2025-01-07 14:25:29 +00:00
b71246bc5d feat: put back group by feature flag (#9428)
Rollback and put back view group feature flag to push to prod.
2025-01-07 13:52:42 +01:00
00e71477d3 feat(sso): add support for identityProviderId in SAML flow (#9411)
Updated SAML callback URLs and relevant logic to include
identityProviderId, ensuring better handling of multiple identity
providers. Refactored client and server-side code to streamline form
interactions and validation within the SSO module.

Fix https://github.com/twentyhq/twenty/issues/9323
https://github.com/twentyhq/twenty/issues/9325
2025-01-07 10:30:13 +01:00
a9b95bcf03 Add count and percent aggregations to kanban headers (#9348)
Closes https://github.com/twentyhq/private-issues/issues/226


https://github.com/user-attachments/assets/cee78080-6dda-4102-9595-d32971cf9104
2025-01-06 17:57:32 +01:00
17bf2b6173 Move the workflow draft version overriding to the backend (#9328)
- In the `formatFieldMetadataValue` function, allow people to call
TypeORM's `save()` method with unserialized JSON data.
- Create an `overrideWorkflowDraftVersion` mutation that takes a
workflow id and the id of the workflow version to use as the new draft
  - If no draft exists yet, create one
  - If a draft already exists, deactivate its serverless functions
- Duplicate every step. For serverless function steps, it includes
duplicating the functions
  - Save the data of the step in DB
- Call the `overrideWorkflowDraftVersion` mutation in the old workflow
header and in the new Cmd+K actions
- I chose to not update the Apollo cache manually as the information of
the new draft are going to be automatically fetched once the user lands
on the workflow's show page. Note that we redirect the user to this page
after overriding the draft version.
2025-01-06 14:56:09 +01:00
3eb7ec909e refactor(workspace, users, billing): remove default workspace + rename (#9360)
Replaced user-based parameterization with workspace-focused logic across
seed scripts, mocks, and billing services. Removed redundant `user`
references and standardized to `workspace` to align with updated
business rules. Adjusted mock data and tests to reflect these changes.

Fix https://github.com/twentyhq/twenty/issues/9295
2025-01-06 12:33:57 +01:00
5bd2154110 Add createdBy source for workflows (#9342)
Fix createdBy that is not displayed for workflows

<img width="1510" alt="Capture d’écran 2025-01-03 à 17 58 05"
src="https://github.com/user-attachments/assets/f2d4d7a9-466b-46e7-9d43-d55de88fb803"
/>
2025-01-03 17:26:15 +00:00
e5754d2152 Remove env-config.js (#9331)
Fixes #5340 which had been open for a long time
2025-01-03 15:18:02 +01:00
5b6c52c64b Create migration for aggregate operation options (#9318)
As a follow-up of https://github.com/twentyhq/twenty/pull/9304, we are
here creating a migration to run at the next release, aiming at adding
the new aggregate operation options (CountEmpty, CountNotEmpty, ...,
PercentEmpty, PercentNotEmpty) to the enums on View and ViewField's
aggregateOperations fields.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2025-01-02 18:53:06 +01:00
5d857fbfb5 Aggregate count variations (#9304)
Closes https://github.com/twentyhq/private-issues/issues/222

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Weiko <corentin@twenty.com>
2025-01-02 16:35:05 +00:00
0f1458cbe9 fix: view group followup (#9162)
This PR fixes all followup that @Bonapara add on Discord.

- [x] When no group by is set, clicking on group by should open the
"field selection" menu
- [x] When closed, chevron should be "chevron-right" instead of
"chevron-up"
- [x] Sort : Add ability to switch from alphabetical to manual when
moving a option in sort alphabetical
- [x] Add subtext for group by and sort
- [x] Group by menu display bug
- [x] Changing the sort should not close the menu
- [x] Group by Activation -> shows empty state + is slow
- [x] Switching from Kanban view Settings to Table Options menu displays
an empty menu
- [x] Unnecessary spacing under groups
- [x] When no "select" are set on an object, redirect the user directly
to the new Select field page
- [x] Sort : Default should be manual
- [x] Hidding "no value" displays all options and remove the "hide empty
group" toggle
- [x] Hide Empty group option disappeared
- [x] Group by should not be persisted on "Locked/Main view" (**For now
we just disable the group by on main view**)
- [x] Hide Empty group should not be activated by default on
Opportunities Kanban view
- [ ] Animate the group opening/closing (**We'll be done later**)

Performance improvement:

https://github.com/user-attachments/assets/fd2acf66-0e56-45d0-8b2f-99c62e57d6f7

https://github.com/user-attachments/assets/80f1a2e1-9f77-4923-b85d-acb9cad96886

Also fix #9036

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2025-01-02 16:40:28 +01:00
866c29e9ee Deprecate share email thread (#9319)
## Context

Following this https://github.com/twentyhq/twenty/issues/4199
This has not been fully implemented, after 5months of dead code I'm
removing the feature for the time being until we re-prioritise the
feature (unlikely during these next 6 months) to keep the codebase a bit
cleaner (no need to maintain dead features)

Feel free to reopen / revert this PR once feature is ready

## Test
locally after importing emails
2025-01-02 16:22:29 +01:00
0dff20775b Fix user deletion when workspace is deleted (#9321)
## Context
2 issues here:
- We use a metadata repository find method without providing a
workspaceId: In practice this is not an issue in this specific part but
let's avoid that pattern
- await this.workspaceService.deleteWorkspace(workspaceId); deletes
almost everything, emitting an event on workspaceMember could
potentially bring issues and not much values imho
2025-01-02 16:15:25 +01:00
23499735b4 fix: Resolve "Can't delete an account" issue (#9232) (#9238)
### Summary

This pull request addresses the issue described in #9232, where
attempting to delete a user account results in a `TypeError: Cannot read
properties of undefined (reading 'dataSourceService')`.

### Changes Made

- Fixed the `this` context issue in the `deleteUserFromWorkspace` method
by ensuring it is correctly bound.
- Updated the `deleteUser` method to use a bound function when calling
`deleteUserFromWorkspace`.

### Linked Issue

This pull request fixes #9232.

### Additional Notes

- Please review the changes carefully to ensure no unintended side
effects in the user or workspace deletion process.
- Suggestions for further improvement are welcome.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Weiko <corentin@twenty.com>
2025-01-02 14:14:28 +01:00
85c04c8931 Performance improvement to dev xp (#9294)
The DX is not great when you need to do a lot of database
resets/command.

Should we disable Typescript validation to speed things up? With this
and caching database:reset takes 1min instead of 2 on my machine.


See also: https://github.com/typeorm/typeorm/issues/4136

And #9291 / #9293

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2025-01-01 17:28:45 +01:00
d4d8883794 add command to sync plan data from stripe, doing testing (#9177)
**Solves**
[ https://github.com/twentyhq/private-issues/issues/211 ]

**TLDR:**

Add a command that fetches the plans product, meters and price in stripe
and whrites it to the DataBase. For now it fetches only active products.

**In order to test**

- Set IS_BILLING_ENABLED=true
- Run `npx nx database:reset twenty-server` if you don't have the
billing tables in your data base schema
-  run `npx nx run twenty-server:command billing:sync-plans-data -v`

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-12-31 15:10:48 +00:00
97f5a5b8a5 Pass Billing Checkout var in url to bypass credit card (#9283) 2024-12-31 14:48:00 +01:00
c52a4924b9 Add throttling on workflow execution (#9263)
We want to avoid infinite loops using workflows. Adding a throttler with
a limit of 10 executions / sec by default for each workflow.

We were not emitting events on workflow actions so loops could not
happen. Since throttler is there we can now and these.

Adding an error message so the user knows when it happens.
<img width="1284" alt="Capture d’écran 2024-12-27 à 17 05 20"
src="https://github.com/user-attachments/assets/dafa837b-5b4c-48be-8207-c90f5c71a236"
/>
2024-12-30 10:52:33 +01:00
df12ba6e98 Webhook Secret Field Implementation and Security Enhancements (#9187) (#9219)
Closes #9187

This pull request introduces a new feature and several enhancements for
managing webhook security by adding a secret field and enabling HMAC
signature-based authentication. Below is a detailed breakdown of the
changes made:

## Frontend Updates
### Secret Field on Webhook Edit Page
- Added a new **Secret** section on the webhook edit page.
  - Includes a text input field for entering a webhook secret.
- Added a descriptive note explaining the purpose of the secret for
webhook authentication.

### State Management and Persistence
- Integrated the secret field into the Webhook type definition and state
management.
- Connected the secret field UI to the data layer, ensuring seamless
persistence of the secret field.

### Validation Improvement
- Trims leading and trailing whitespace from webhook secret inputs to
avoid potential validation issues.

## Backend Updates
### Database and Entity Changes
- Introduced a nullable `secret` field to the `WebhookWorkspaceEntity`
for securely storing webhook signing secrets.
- Field uses a standard field ID:
`20202020-97ce-410f-bff9-e9ccb038fb67`.

### Signature Generation
- Implemented HMAC-SHA256 signature generation for webhook payloads when
a secret is present:
- Signatures are added as a custom `X-Twenty-Webhook-Signature` header.
  - Secret is excluded from the payload to maintain security.

### Enhanced Security Measures
- Added additional headers for enhanced security:
  - **Timestamp Header**: Prevents replay attacks.
  - **Nonce Header**: Mitigates duplicate requests.
- Updated the OpenAPI specification to include documentation on these
security-related headers and signature verification.

## Documentation Updates
- Updated OpenAPI documentation for webhook endpoints:
  - Described security-related headers (signature, timestamp, nonce).
- Included detailed instructions for verifying HMAC signatures to assist
consumers.

## Testing and Demonstration
- [Loom Video
Link](https://www.loom.com/share/bd827e4d045f46d99f3c8186e5e5676a?sid=a5e61904-0536-4e82-8055-3d05e4598393):
Demonstrating the functionality of the secret field and webhook security
features.
- [Script Example
Link](https://runkit.com/samyakpiya/676af044040c0400086d400a): A script
showing how consumers can verify webhook authenticity using the HMAC
signature.
- [Testing Site
Instance](https://webhook.site/#!/view/3472468b-ebcd-4b7f-a083-c4ba20825bb4/6885fdce-8843-4d3f-8fe0-1d8abdd53f68/1):
Contains the logged requests sent during testing and is available for
review.

## Steps for Review
1. Verify the secret field functionality on the webhook edit page,
including state persistence and UI updates.
2. Review the security enhancements, including header additions and HMAC
signature generation.
3. Validate OpenAPI documentation changes for completeness and clarity.

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-12-28 11:47:14 +01:00
a8bb3e6bdf Added all field types on pet custom object (#9248)
- Added all usable composite field types on pet custom object
- Fixed missing createdBy on people and company seeds
- DEFAULT_SUBDOMAIN is now used for login (could be improved for multi
workspace)
- Refactored ObjectMetadataStandardIdToIdMap to disambiguate from
ObjectMetadataMap
- Refactored seedCustomObjects
2024-12-27 15:01:09 +01:00
58c92e036b Add post hooks for workflow deletion (#9258)
Delete all workflow sub objects when workflow is deleted. Other sub
objects cannot be deleted otherwise.

We do not listen to deletion events so I am not adding them. Those post
hooks should be deleted Q1 once we properly handle cascade for soft
deletion
2024-12-27 13:40:19 +00:00
2da3d83a41 Fix creation of a new view duplicating existing filters (#9240)
Fixes #9239
2024-12-26 11:43:05 +01:00
cba38ab496 Fixed relations (#9227)
Follow-up : Fixed relations eager load on refactored hooks from PR
https://github.com/twentyhq/twenty/pull/8695
2024-12-24 15:59:25 +01:00
2dcfaeac73 Restore "Fix "Create profile" page not supporting dark mode (#8110)" & Fix string defaultValues during sync-metadata (#9220)
Restoring https://github.com/twentyhq/twenty/pull/9185
Also fixing sync-metadata with test values in jsonb

## Test
sync-metadata on existing workspaces should replace colorSchema in both
metadata and workspaceMember tables
2024-12-24 15:09:04 +01:00
e9717603f2 Refactored and improved seeds (#8695)
- Added a new Seeder service to help with custom object seeds
- Added RichTextFieldInput to edit a rich text field directly on the
table, but deactivated it for now.
2024-12-24 14:44:52 +01:00
53f0cd7205 refactor(workspace): clean up resolver and improve error handling (#9225)
Removed unused `LoginTokenService` imports and dependencies for better
code clarity. Enhanced error handling in
`getPublicWorkspaceDataBySubdomain` with a try-catch block, ensuring
consistent exception handling. This improves maintainability and
robustness of the resolver.
2024-12-24 14:41:20 +01:00
cd2946b670 refacto(*): remove everything about default workspace (#9157)
## Summary
- [x] Remove defaultWorkspace in user
- [x] Remove all occurrence of defaultWorkspace and defaultWorkspaceId
- [x] Improve activate workspace flow
- [x] Improve security on social login
- [x] Add `ImpersonateGuard`
- [x] Allow to use impersonation with couple `User/Workspace`
- [x] Prevent unexpected reload on activate workspace
- [x] Scope login token with workspaceId 

Fix https://github.com/twentyhq/twenty/issues/9033#event-15714863042
2024-12-24 11:47:41 +00:00
801bf7c016 quick fix for positionInViewFilterGroup (#9223)
fix 9206

In the future, we should have a look at the column naming
"positionInViewFilterGroup"
because it breaks the SQL queries in `record-position-query.factory.ts`
for viewFilter tablenames
2024-12-24 10:49:50 +00:00
b52c23bb66 feat(database): Add trigger to set impersonation on first user (#9195)
Introduced a trigger to automatically set `canImpersonate` to true for
the first user inserted into the `core.user` table. The trigger is
removed after the first user is added to ensure this behavior only
applies to the initial user. Includes both the creation and rollback
logic for the migration.

Close https://github.com/twentyhq/twenty/issues/9173
2024-12-24 09:52:57 +01:00
3eff317b59 Remove favorite folder related feature flags (#9178)
Co-authored-by: Weiko <corentin@twenty.com>
2024-12-23 15:56:56 +01:00
c947040137 Revert "Fix "Create profile" page not supporting dark mode (#8110)" (#9201)
Reverts twentyhq/twenty#9185
This PR breaks sync-metadata, will merge back after 0.35
2024-12-23 14:11:41 +01:00
7d57d61f47 Fix "Create profile" page not supporting dark mode (#8110) (#9185)
Fixes issue #8110

Co-authored-by: ad-elias <elias@autodiligence.com>
2024-12-23 11:06:10 +01:00
2651379ccc Add automatic company logo fetching during workspace creation (#9158)
Closes #9151 

## Description
This PR automatically sets a workspace's logo based on the user's work
email domain during signup. When a user creates a new workspace using
their work email (e.g., @airbnb.com), the system will fetch and set
their company logo from twenty-icons.com as the default workspace logo.

## Implementation Details
- Added a new `CompanyEnrichmentService` to handle company-related data
enrichment
- Created a modular architecture that supports future enrichment
features (e.g., company name, details)
- Integrated with existing work email detection
- Maintains user ability to override the logo later

## Testing

https://github.com/user-attachments/assets/f7855c99-462a-4053-9e52-29649e954275


I tested the following scenarios:
- Signing up with a work email (e.g., @company.com) → Logo is
automatically set
- Signing up with a personal email (e.g., @gmail.com) → No logo is set
- User can still upload a custom logo after automatic setting

## Technical Notes
- Uses existing `isWorkEmail` utility
- Structured for future extensibility (additional company data
enrichment)
- No breaking changes to existing functionality

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-12-22 09:24:27 +01:00
03f89791b6 Add upgrade 0.35 command module (#9175)
Moving commands from 0.40 to 0.35 since they should be ready for 0.35.
2024-12-20 18:18:56 +01:00
928c99a725 Phone country fix (#9167) 2024-12-20 15:28:17 +01:00
52362812a5 Catch workspace issues in backfill upgrade commands 2024-12-20 12:11:05 +01:00
779c503381 Fix sync metadata default value not being synced (#9163)
## Context
We used to not sync defaultValue and recently introduced a change in
3340f01c31/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/comparators/workspace-field.comparator.ts
with shouldNotOverrideDefaultValue to sync it for specific field
metadata type that can't be overwritten by the user.
This means we should have removed 'defaultValue' from
commonFieldPropertiesToIgnore list since it was handled differently.
This PR fixes that

Before
<img width="792" alt="Screenshot 2024-12-20 at 11 04 09"
src="https://github.com/user-attachments/assets/1771c5a3-2162-4013-8a08-c54d2619fda3"
/>

After
<img width="798" alt="Screenshot 2024-12-20 at 11 04 55"
src="https://github.com/user-attachments/assets/33e09f16-c615-4a43-950d-d2df955fb196"
/>
2024-12-20 11:42:42 +01:00
1acf845101 9018 fix batch delete follow ups (#9166)
Follow ups on #9018
2024-12-20 11:41:09 +01:00
925294675c 9018 fix batch delete (#9149)
Closes #9018
2024-12-20 10:46:24 +01:00
94136d953e 8749 invalid openapi schema (#9156) 2024-12-20 09:56:22 +01:00
360c34fd18 Phone country code unique (#9035)
fix #8775
2024-12-19 16:42:18 +01:00
3f58a41d2f Fix sort with pagination and composite fields (#9150)
Fixes https://github.com/twentyhq/twenty/issues/8863

## Description
This PR fixes an issue with cursor-based pagination when dealing with
composite fields (like `fullName`). Previously, the pagination direction
was incorrectly determined for composite fields because the code wasn't
properly handling nested object structures in the `orderBy` parameter.
Refactored the code accordingly.
2024-12-19 16:41:04 +01:00
ed56a68b7c Improve aggregate footer cell display (#9124)
Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-12-19 14:36:14 +00:00
7d8f895ae9 fix test (#9147) 2024-12-19 15:24:49 +01:00
028e5cd940 add sync customer command and drop subscription customer constraint (#9131)
**TLDR:**
Solves (https://github.com/twentyhq/private-issues/issues/212)
Add command to sync customer data from stripe to BillingCustomerTable
for all active workspaces. Drop foreign key contraint on billingCustomer
in BillingSubscription (in order to not break the DB).

**In order to test:**

- Billing should be enabled
- Have some workspaces that are active and whose id's are not mentioned
in BillingCustomer (but the customer are present in stripe).

Run the command: 
`npx nx run twenty-server:command billing:sync-customer-data`

Take into consideration
Due that all the previous subscriptions in Stripe have the workspaceId
in their metadata, we use that information as source of true for the
data sync

**Things to do:**

- Add tests for Billing utils
- Separate StripeService into multipleServices
(stripeSubscriptionService, stripePriceService etc) perhaps add them in
(https://github.com/twentyhq/private-issues/issues/201)?
2024-12-19 11:30:05 +01:00
7375ab8d71 Fix/refresh token (#9135) 2024-12-18 19:10:16 +01:00
a2423fad5e feat(auth): add workspaceId validation and token expiration (#9134)
Added validation to ensure refresh tokens include a workspaceId,
throwing an exception for malformed tokens. Included workspaceId in
payloads and introduced expiration handling for access tokens. This
enhances token security and prevents potential misuse.

Close #9126
2024-12-18 18:56:49 +01:00
f482b459a9 Remove workspace gates for aggregate fields metadata (#9125)
As part of our rollout strategy, let's remove the workspaces gates,
which will trigger the creation of the field metadatas needed for the
aggregate queries features.
In a later release we will remove the feature flag completely, after all
fields have been created for all workspaces
2024-12-18 17:45:10 +01:00
baf339567c Fix broken import on graphql api exception helper 2024-12-18 16:57:39 +01:00
2bcce44e08 feat(workspace): expand forbidden subdomain validation (#9082)
Added new forbidden words and regex patterns to subdomain validation in
`update-workspace-input`. Enhanced the `ForbiddenWords` validator to
support both strings and regex matching. Updated tests to verify
regex-based forbidden subdomain validation.

Fix #9064

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-12-18 16:46:59 +01:00