Commit Graph

1215 Commits

Author SHA1 Message Date
Raphaël Bosi
925294675c
9018 fix batch delete (#9149)
Closes #9018
2024-12-20 10:46:24 +01:00
martmull
94136d953e
8749 invalid openapi schema (#9156) 2024-12-20 09:56:22 +01:00
Guillim
360c34fd18
Phone country code unique (#9035)
fix #8775
2024-12-19 16:42:18 +01:00
Weiko
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
Marie
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
Antoine Moreaux
7d8f895ae9
fix test (#9147) 2024-12-19 15:24:49 +01:00
Ana Sofia Marin Alexandre
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
Antoine Moreaux
7375ab8d71
Fix/refresh token (#9135) 2024-12-18 19:10:16 +01:00
Antoine Moreaux
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
Marie
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
Charles Bochet
baf339567c Fix broken import on graphql api exception helper 2024-12-18 16:57:39 +01:00
Antoine Moreaux
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
Antoine Moreaux
550756c2bf
feat(auth): enhance workspace handling and error feedback (#9118)
Add support for setting a user's default workspace during sign-in if a
target workspace subdomain exists. Enhance error feedback by displaying
authentication error messages using a Snackbar in the front-end and
improving redirect logic for workspace-specific errors.
2024-12-18 16:46:25 +01:00
Thomas Trompette
94676215ad
Add fields to update in update record action (#9108)
- update backend action so it handles composite fields
- add fields to update multiselect
- generate form based on that field
- add icons
2024-12-18 13:32:21 +00:00
Jérémy M
3b48920314
feat: NoValue is bot properly created the backend (#9110)
`No Value` view groups wasn't properly created when we select a group by
field metadata, this PR fix the issue.
Also a script is added to backfill the current view groups.

---------

Co-authored-by: Marie <51697796+ijreilly@users.noreply.github.com>
2024-12-18 12:26:38 +01:00
Félix Malfait
45214fe548
Add no-seed configuration to database:reset (#9112)
Based on feedback here:
https://github.com/twentyhq/twenty/issues/9109#issuecomment-2550198035
2024-12-18 11:44:06 +01:00
Antoine Moreaux
07bde4883e
feat(auth): add default workspace support for user handling (#9099)
Introduce `defaultWorkspaceId` to improve workspace redirection logic.
Updated GraphQL schema, server logic, and frontend components
accordingly to prioritize default workspaces when available.

## Summary
This PR adds a mechanism to handle and prioritize default workspace
selection for users during authentication. It updates the logic in
multiple components and services to ensure users are redirected to their
default workspaces if no specific selection is provided.

### Main changes:
- **GraphQL Schema Updates**:
- Enhanced `UserExists` GraphQL entity with a new `defaultWorkspaceId`
field to specify the user's default workspace.
  - Updated queries and mutations to handle the `defaultWorkspaceId`.

- **Client-Side Updates**:
- Enhanced `useAuth` hook to include logic for managing default
workspace redirection.
- Adjusted UI logic in `SignInUpGlobalScopeForm` to utilize the
`defaultWorkspaceId`.

- **Server-Side Adjustments**:
- Modified `AuthService` to include `defaultWorkspaceId` in
`checkUserExists`.
- Default workspace logic added to the backend flow for consistent
handling.

- **Tests/Helpers**:
- Added utility and type changes to integrate the new backend response
changes (e.g., `UserExists` GraphQL).
- **Subsequent function lifecycle** was adjusted to include recheck for
workspace token states when performing sign-in flows.
2024-12-17 19:56:19 +01:00
Ana Sofia Marin Alexandre
55dc5983a2
add price and meter dynamically add foreign keys in billing (#9100)
**TLDR**
Solves: https://github.com/twentyhq/private-issues/issues/199
Partially solves: https://github.com/twentyhq/private-issues/issues/221
(more details below)

Updates the BillingMeter and BillingPrice tables while listening to the
events "price.created" and "price.updated" from the stripe webhook. Also
added the foreign keys, that couldn't be added to the BillingEntities.

**In Order To test**
Billing:

- Set IS_BILLING_ENABLED to true
- Add your BILLING_STRIPE_SECRET and BILLING_STRIPE_API_KEY
- Add your BILLING_STRIPE_BASE_PLAN_PRODUCT_ID (use the one in testMode
> Base Plan)

Authenticate with your account in the stripe CLI
Run the command: stripe listen --forward-to
http://localhost:3000/billing/webhooks

Run the twenty workker

Authenticate yourself on the app choose a plan and run the app normally.
In stripe and in posgress the customer table data should be added.

**Take Into Consideration**

In a previous migration the foreign key to workpaceId was taken down
this was due to the separation of the migrations if billing is enabled.
Because we want to separate in these two categories: we will be
polluting the Common Migrations with relations to tables that don't
exists. This will be addressed in a PR in the next sprint (perhaps a
decorator?)


**Doing**
Testing migrations, when we are in main and when billing is enabled.
2024-12-17 19:54:56 +01:00
martmull
e492efb79e
Remove serverless functions from settings (#9105)
closes https://github.com/twentyhq/twenty/issues/8727

@Bonapara wants to keep the code for now so I ended up by setting the
`isFunctionSettingsEnabled` constants to false in the codebase
2024-12-17 17:57:17 +01:00
Baptiste Devessier
f05a217f62
Add some tests to the variable resolver to ensure static JSON is properly evaluated (#9104) 2024-12-17 17:02:16 +01:00
Thomas Trompette
f0de1ab245
Add Multiselect for forms (#9092)
- Add new FormMultiSelectField component
- Factorize existing display / input into new ui components
- Update the variable resolver to handle arrays properly

<img width="526" alt="Capture d’écran 2024-12-17 à 11 46 38"
src="https://github.com/user-attachments/assets/6d37b513-8caa-43d0-a27e-ab55dac21f6d"
/>
2024-12-17 14:41:55 +01:00
martmull
5dfcc413cf
9024 workflow test serverless function follow up (#9066)
-  Fix Tablist style
- Fix dropdown style (wrong grey background)
- Update dropdown variable when no outputSchema is available 



https://github.com/user-attachments/assets/56698fe8-8dd3-404a-b2b2-f1eca6f5fa28
2024-12-17 10:35:38 +01:00
Antoine Moreaux
4e329d08b0
feat(database): add unique constraint on workspace subdomain (#9084)
Added a unique constraint to the "subdomain" column in the workspace
entity to ensure no duplicate subdomains exist in the database. Included
a TypeORM migration script to enforce this change at the database level.
2024-12-16 19:41:18 +01:00
Weiko
5d51a826ea
fix demo seed conflicting with dev seed (#9087)
We have conflicts which prevents us from running demo seed command after
a database-reset or/and if dev seed has already been populated. This is
because we are trying to create Tim user twice (but due to the
insert()...onConflict() in the seed creation, it does not create the
second one), for seed-dev and seed-demo .

This PR fixes that by using the same user id, allowing us to use the
same Tim apple for both dev/demo seeds

Test
<img width="802" alt="Screenshot 2024-12-16 at 15 36 56"
src="https://github.com/user-attachments/assets/72244978-130f-4561-8709-43376453b247"
/>
<img width="780" alt="Screenshot 2024-12-16 at 15 37 17"
src="https://github.com/user-attachments/assets/01ce221b-34f6-4e48-ae30-d84bdf9d3cc2"
/>
2024-12-16 15:47:09 +01:00
Antoine Moreaux
f8f3945680
fix(): sleep before redirect (#9079)
## Summary
This Pull Request centralizes the redirection logic by introducing a
reusable `useRedirect` hook, which replaces direct usage of
`window.location.href` with more standardized and testable functionality
across multiple modules.

- Introduced a new `useRedirect` hook for handling redirection logic
with optional controlled delays.
- Refactored redirection implementations in various modules (`useAuth`,
workspace, and settings-related hooks, etc.) to use the newly introduced
`useRedirect` or related high-level hooks.
- Updated API and documentation to include or improve support for SSO,
particularly OIDC and SAML setup processes in server logic.
- Enhanced frontend and backend configurability with new environment
variable settings for SSO.

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-12-16 15:15:55 +01:00
Weiko
5a27491bb2
Fix Tasks/Notes created with null position (#9068)
Fixes https://github.com/twentyhq/twenty/issues/8810
Fixes https://github.com/twentyhq/twenty/issues/5268
Fixes https://github.com/twentyhq/twenty/issues/8971

- Fixing Task/Note creation not sending position during creation
- Adding a command to backfill position being null, using existing
backfill command.
- Removed unused backfill job.
- Updated workspace entities to set position non-nullable and set a
default value to make it non-required on the API
- Updated position factory to set a default position for all objects
having a POSITION field instead of only company/people
- Moved the try/catch in each resolver factory calling
GraphqlQueryRunnerException handler, makes more sense to call it in the
actual graphql-query-runner and removing some duplicate codes
- Adding validations for input in QueryRunnerArgs factories
- Allow sync-metadata to override and sync defaultValues for certain
field types (that can't be updated by users)
- Removing health-check from sync-metadata command during force mode to
improve performances
2024-12-16 14:45:54 +01:00
Charles Bochet
2ceb1c87b3
Fix array enum renaming (#9067)
When creating an enum type (let's say post_type_enum), postgres will
automatically create a array enum type based on this enum and prefix it
with an underscore (so _post_type_enum).

Our code was not taking this case into account while dealing with
MULTISELECT

Resources:
https://www.postgresql.org/docs/current/sql-createtype.html

<img width="1329" alt="image"
src="https://github.com/user-attachments/assets/c41bc90c-9884-4995-8fae-d26869153a1d"
/>
2024-12-13 19:16:04 +01:00
Félix Malfait
042b6c65ed
Change favicon/company enrichment urls (#9065)
We're moving favicon/telemetry/company enrichment to a separate url for
better security/monitoring
2024-12-13 18:41:57 +01:00
Ana Sofia Marin Alexandre
abaf2651ec
add product table data in real time (#9055)
Solves (https://github.com/twentyhq/private-issues/issues/198)

**TLDR**

Updates the billingProduct table data using stripe webhooks event. It
saves all the updates/creates of the products, but ensuring that it has
the lastest version of the correct metadata attributes (typeof
BillingProductMetadata)

**In order to test**
Billing:

Set IS_BILLING_ENABLED to true
Add your BILLING_STRIPE_SECRET and BILLING_STRIPE_API_KEY
Add your BILLING_STRIPE_BASE_PLAN_PRODUCT_ID (use the one in testMode >
Base Plan)
Authenticate with your account in the stripe CLI
Run the command: stripe listen --forward-to
http://localhost:3000/billing/webhooks

Go to Stripe In test mode and update or create a product using a
metadata of type of BillingProductMetadata, you can also update it using
a different values for metadata.

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
2024-12-13 18:15:11 +01:00
Charles Bochet
7e67b1c5a6
Enforce system wide sso providers (#9058)
We have recently introduced the possibility to specify workspace
specific auth providers.
I'm:
- introducing system wide auth providers (provided by clientConfig)
- making sure workspace specific auth providers belong to system wide
auth providers set
2024-12-13 16:38:04 +01:00
martmull
b10d831371
8726 workflow add a test button in workflow code step (#9016)
- add test button to workflow code step
- add test tab to workflow code step


https://github.com/user-attachments/assets/e180a827-7321-49a2-8026-88490c557da2



![image](https://github.com/user-attachments/assets/cacbd756-de3f-4141-a84c-8e1853f6556b)

![image](https://github.com/user-attachments/assets/ee170d81-8a22-4178-bd6d-11a0e8c73365)
2024-12-13 10:16:29 +00:00
Marie
d56c815897
[Fix] isLabelSyncedWithName should be nullable (#9028)
isLabelSyncedWithName should be nullable for fieldMetadata, as it is for
objectMetadata.

+ Adding missing validation on label and name sync in
fieldMetadataService for creation and update
+ adding metadata tests
2024-12-12 18:25:40 +01:00
Thomas Trompette
2990d23411
Fix composite field creation (#9044)
- composite field need to be formatted before being saved
- repository.create() does not do it. So we simply lose the composite
fields on the way
- save() does it directly and doing create() before does not change
anything
2024-12-12 16:34:56 +00:00
Charles Bochet
77c2961912
Fast follows on 0.34 (#9034)
Co-authored-by: Weiko <corentin@twenty.com>
2024-12-12 15:46:48 +00:00
Ana Sofia Marin Alexandre
bce5be85a3
add info to customer table and stripe customer data (#9004)
Solves (https://github.com/twentyhq/private-issues/issues/194)

**TLDR**

Updates the billingCustomer table data using stripe webhooks event, also
updates the customer's metadata in stripe, in order to contain the
workspaceId associated to this customer.

**In order to test**
Billing:

- Set IS_BILLING_ENABLED to true
- Add your BILLING_STRIPE_SECRET and BILLING_STRIPE_API_KEY
- Add your BILLING_STRIPE_BASE_PLAN_PRODUCT_ID (use the one in testMode
> Base Plan)
- 

Authenticate with your account in the stripe CLI
Run the command: stripe listen --forward-to
http://localhost:3000/billing/webhooks

Run the twenty workker

Authenticate yourself on the app choose a plan and run the app normally.
In stripe and in posgress the customer table data should be added.

**Next steps**
Learn more about integrations tests and implement some for this PR.

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-12-12 08:00:39 +01:00
Weiko
c776179ecc
start 0.40.0 canary (#9029) 2024-12-11 19:23:51 +01:00
Charles Bochet
224b6d1334
Fix login issue (#9012)
Co-authored-by: Weiko <corentin@twenty.com>
2024-12-11 15:42:53 +01:00
Weiko
96d56f8883
Fix removeBillingFKWithCore migration location (#9006)
removeBillingFKWithCore migration is in the wrong folder and is not
executed as intended.
Moving to billing folder to fix that and to be only run in billing mode
2024-12-10 16:33:52 +01:00
Weiko
b0595e452a
Fix add-subdomain-to-workspace command (#9005)
## Context
Fix add-subdomain-to-workspace command not included in global module
also fixing the command regex logic that was not generating subdomain
properly
2024-12-10 15:32:13 +01:00
Félix Malfait
0a8960c2ed
Fix broken workspace deletion (#9002)
Fixes #8985
2024-12-10 14:13:58 +01:00
Raphaël Bosi
d70987653b
8964 add feature flag is page header v2 enabled (#8995)
Closes #8964
2024-12-10 10:56:28 +01:00
Weiko
23015de996
Add migration ci check (#8867)
Fixes #8865

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
2024-12-09 17:15:24 +01:00
Antoine Moreaux
2524d64687
Feat/improve error management in core module (#8933)
## Summary
This Pull Request introduces a custom validator for checking forbidden
words in workspaces and refines how exceptions are handled within the
workspace module.

- Introduced `ForbiddenWords` custom class validator for validating
forbidden words against specific fields in `UpdateWorkspaceInput`.
- Added `EnvironmentService` usage in `WorkspaceService` to check
default subdomains.
- New file `workspaceGraphqlApiExceptionHandler` to handle GraphQL API
exceptions with specific error mappings.
- Expanded `WorkspaceExceptionCode` with `SUBDOMAIN_ALREADY_TAKEN`.
- Added new unit tests for validating forbidden words and exception
handler behavior.
2024-12-07 16:48:53 +01:00
Charles Bochet
99f53a5030
Fix broken image urls in Settings > Profile and Invite To Workspace Email (#8942)
Fixes #8601

We had 3 implementations of getImageAbsoluteURI: in twenty-front, in
twenty-ui and in twenty-emails. I was able to remove the one in
twenty-front but I could not remove it from twenty-emails as this is a
standalone for now. The vision is to introduce shared utils in a
twenty-shared package
2024-12-07 14:57:32 +01:00
Thomas Trompette
e1a0259154
Split record crud actions (#8930)
Having a global record crud action adds complex logic.
We decided to split those actions. I only kept a common folder / module
in backend.

⚠️ this may break existing workflows if these were using previous
actions!
2024-12-06 16:58:57 +01:00
Antoine Moreaux
36fb14179b
feat(workspace): Add subdomain availability check (#8906)
Implemented a feature to check the availability of subdomains when
updating workspace settings. This includes a new mutation,
`isSubdomainAvailable`, to validate subdomain availability through
GraphQL. The frontend now verifies if a subdomain is available to
prevent duplicates during updates.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-12-06 13:28:30 +00:00
Thomas Trompette
5c565345ae
Add delete record action (#8908)
<img width="1272" alt="Capture d’écran 2024-12-05 à 18 04 19"
src="https://github.com/user-attachments/assets/dcbcc761-2f6d-4b6d-9e10-0f5b25d12c39">

- Adding new action
- Adding tests
- Moving into action folder
2024-12-06 13:02:17 +01:00
martmull
2b3b073570
8725 workflow avoid serverless function autosave errors (#8916)
See issue #8725 
- Build function asynchronously using a job
- prevent useless builds
- run promises simultaneously

Todo:
- fix outputSchema computing
2024-12-06 10:13:12 +00:00
Weiko
815e5dfa16
Fix migration folder (#8909)
## Context
Common migrations now live in a different directory however the PR that
added that behavior was not up to date with the few migrations that were
merged recently.

This PR moves the migrations to the correct folder so they can be
executed properly.

## Test
reset-db

Before
<img width="1505" alt="Screenshot 2024-12-05 at 18 14 13"
src="https://github.com/user-attachments/assets/6cabf094-805a-4101-aeb2-3678497c2947">
After
<img width="1200" alt="Screenshot 2024-12-05 at 18 15 40"
src="https://github.com/user-attachments/assets/3ae59af5-d615-48e0-bfde-9467770acc27">
2024-12-05 18:19:22 +01:00
Raphaël Bosi
de56c01206
8733 refactor gmailhandleerrorservice (#8901)
Closes #8733 
- Refactor `GmailHandleErrorService`
- Add tests and mocks for the errors
2024-12-05 17:57:57 +01:00