Commit Graph

43 Commits

Author SHA1 Message Date
Ana Sofia Marin Alexandre
373926b895
Secure connexion between TinyBird and webhookResponseGraph (#7913)
TLDR:
Secure connexion between tinybird and twenty using jwt when accessing
datasource from tinybird.

Solves:
https://github.com/twentyhq/private-issues/issues/73


In order to test:

1. Set ANALYTICS_ENABLED to true
2. Set TINYBIRD_JWT_TOKEN to the ADMIN token from the workspace
twenty_analytics_playground
3. Set TINYBIRD_JWT_TOKEN to the datasource or your admin token from the
workspace twenty_analytics_playground
4. Create a Webhook in twenty and set wich events it needs to track
5. Run twenty-worker in order to make the webhooks work.
6. Do your tasks in order to populate the data
7. Enter to settings> webhook>your webhook and the statistics section
should be displayed.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-10-21 17:42:52 +02:00
Jérémy M
eef7f1661d
feat: add integration tests (#6923)
### Summary

This PR introduces several integration tests, a mix of manually written
tests and those generated using the `generate-integration-tests` Python
script located in the `scripts` folder.

### Tests Added:
- **Authentication tests**: Validating login, registration, and token
handling.
- **FindMany queries**: Fetching multiple records for all existing
entities that do not require input arguments.

### How the Integration Tests Work:
- A `setupTest` function is called during the Jest test run. This
function initializes a test instance of the application and exposes it
on a dedicated port.
- Since tests are executed in isolated workers, they do not have direct
access to the in-memory app instance. Instead, the tests query the
application through the exposed port.
- A static accessToken is used, this one as a big expiration time so it
will never expire (365 years)
- The queries are executed, and the results are validated against
expected outcomes.

### Current State and Next Steps:
- These tests currently run using the existing development seed data. We
plan to introduce more comprehensive test data using `faker` to improve
coverage.
- At the moment, the only mutation tests implemented are for
authentication. Future updates should include broader mutation testing
for other entities.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-09-20 11:02:52 +02:00
Jérémy M
6432ad39b9
feat: add new ACTOR field type and createdBy standard fields (#6324)
This pull request introduces a new `FieldMetadataType` called `ACTOR`.
The primary objective of this new type is to add an extra column to the
following objects: `person`, `company`, `opportunity`, `note`, `task`,
and all custom objects.

This composite type contains three properties:

- `source`
    ```typescript
    export enum FieldActorSource {
      EMAIL = 'EMAIL',
      CALENDAR = 'CALENDAR',
      API = 'API',
      IMPORT = 'IMPORT',
      MANUAL = 'MANUAL',
    }
    ```
- `workspaceMemberId`
- This property can be `undefined` in some cases and refers to the
member who created the record.
- `name`
- Serves as a fallback if the `workspaceMember` is deleted and is used
for other source types like `API`.

### Functionality

The pre-hook system has been updated to allow real-time argument
updates. When a record is created, a pre-hook can now compute and update
the arguments accordingly. This enhancement enables the `createdBy`
field to be populated with the correct values based on the
`authContext`.

The `authContext` now includes:
- An optional User entity
- An optional ApiKey entity
- The workspace entity

This provides access to the necessary data for the `createdBy` field.

In the GraphQL API, only the `source` can be specified in the
`createdBy` input. This allows the front-end to specify the source when
creating records from a CSV file.

### Front-End Handling

On the front-end, `orderBy` and `filter` are only applied to the name
property of the `ACTOR` composite type. Currently, we are unable to
apply these operations to the workspace member relation. This means that
if a workspace member changes their first name or last name, there may
be a mismatch because the name will differ from the new one. The name
displayed on the screen is based on the workspace member entity when
available.

### Missing Components

Currently, this PR does not include a `createdBy` value for the `MAIL`
and `CALENDAR` sources. These records are created in a job, and at
present, we only have access to the workspaceId within the job. To
address this, we should use a function similar to
`loadServiceWithContext`, which was recently removed from `TwentyORM`.
This function would allow us to pass the `authContext` to the jobs
without disrupting existing jobs.
Another PR will be created to handle these cases.

### Related Issues

Fixes issue #5155.

### Additional Notes

This PR doesn't include the migrations of the current records and views.
Everything works properly when the database is reset but this part is
still missing for now. We'll add that in another PR.

- There is a minor issue: front-end tests are broken since this commit:
[80c0fc7ff1).

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-03 15:43:31 +02:00
Lucas Bordeau
7b3a590f79
5421 box shadow on frozen header and first column (#6130)
- Refactored components in table
- Added a isTableRecordScrolledLeftState and
isTableRecordScrolledTopState to subscribe to table scroll
- Added a zIndex logic that subscribes to those new states in new tinier
components

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-07-05 18:30:59 +02:00
Jérémy M
5b26452649
feat: refactor workspace sync fields (#6069)
This PR was first here to fix the issue related to ticket #5004, after
some testing it seems that changing the name of a relation is actually
properly working, if we rename `ONE-TO-MANY` side, the only things that
is going to be updated is the FieldMetadata as the `joinColumn` is
stored on the opposite object.
For `MANY-TO-ONE` relations, the `joinColumn` migration is properly
generated. We need to take care that if we rename a side of a relation,
sometimes the opposite side doesn't have `inverseSideFieldKey`
implemented and used by default the name of the opposite object, so this
is going to throw an error as the field can't be found in the object.

---------

Co-authored-by: Marie <51697796+ijreilly@users.noreply.github.com>
2024-07-02 17:21:13 +02:00
Charles Bochet
a57e251208
Fix docs build in CI (#5826) 2024-06-11 19:06:37 +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
Charles Bochet
fafa56411c
Fix email sync (#5132) 2024-04-23 18:50:37 +02:00
Félix Malfait
f82b1ff9ef
Fix duplicate imports by VSCode (#4959)
Fixes  #3819
This was annoying. 
It was caused by a duplicate rule in VS Code config.
2024-04-14 08:48:03 +02:00
Jérémy M
5019b5febc
feat: drop target column map (#4670)
This PR is dropping the column `targetColumnMap` of fieldMetadata
entities.
The goal of this column was to properly map field to their respecting
column in the table.
We decide to drop it and instead compute the column name on the fly when
we need it, as it's more easier to support.
Some parts of the code has been refactored to try making implementation
of composite type more easier to understand and maintain.

Fix #3760

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-04-08 16:00:28 +02:00
Charles Bochet
e576fe0d67
Update yarn commands (#4644)
* Simplify commands

* Simplify commands

* Migrate all dev commands to project.json

* Fix tests
2024-03-25 12:31:18 +01:00
Jérémy M
af6ffbcc68
feat: standard fields on custom (#4332)
* feat: add ability to sync standard fields on custom object

* fix: clean

* fix: wrong compute during object creation

* fix: missing cascade delete

* fix: remove unused injected class

* fix: naming

* fix: rename factory to paramsFactory and clean

* fix: rename ExtendCustomObjectMetadata to BaseCustomObjectMetadata

* fix: partial fix inconsistent label and description

* Fixes

* Fix

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-03-07 17:21:50 +01:00
gitstart-app[bot]
b2210bd418
TWNTY-2244 - ESLint rule: enforce usage of .getLoadable() + .getValue() to get atoms (#4143)
* ESLint rule: enforce usage of .getLoadable() + .getValue() to get atoms

Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Merge main

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Fix

* Refactor according to review

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Fix linter issue

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Fix linter

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-03-06 00:24:20 +01:00
Aditya Pimpalkar
63d403454c
feat: multi-workspace followup (#4197)
* Seed UserWorkspace for existing demo/dev users

* add workspaces field to currentUser

* new token generation endpoint for switching workspace

* lint fix

* include dependency

* requested fixes

* resolver test pass

* changing defaultWorkspace and workspaceMember when switching workspaces

* tests fix

* requested changes

* delete user/workspace edge case handled

* after merge

* requested changes

* :wq!

* workspace manytoone relation

* lint fix / import fix

* gql codegen

* Fix migrations and generateJWT

* migration fix

* relations fix

---------

Co-authored-by: martmull <martmull@hotmail.fr>
2024-03-04 16:14:04 +01:00
rostaklein
9aefab2297
fix: added working launch.json for VSCode (#4037)
* fix: added working launch json for VScode

* fix: removed unused env
2024-02-20 14:27:56 +01:00
Abdullah
1265dc74d0
Closes #2413 - Building a chrome extension for twenty to store person/company data into a workspace. (#3430)
* build: create a new vite project for chrome extension

* feat: configure theme per the frontend codebase for chrome extension

* feat: inject the add to twenty button into linkedin profile page

* feat: create the api key form ui and render it on the options page

* feat: inject the add to twenty button into linkedin company page

* feat: scrape required data from both the user profile and the company profile

* refactor: move modules into options because it is the only page using react for now

* fix: show add to twenty button without having to reload the single page application

* fix: extract domain of the business website instead of scrapping the industry type

* feat: store api key to local storage and open options page when trying to store data without setting a key

* feat: send data to the backend upon click and store it to the database

* fix: open options page upon clicking the extension icon

* fix: update terminology from user to person to match the codebase convention

* fix: adopt chrome extension to monorepo approach using nx and get the development server working

* fix: update vite config for build command to work per the requirement

* feat: add instructions in the readme file to install the extension for local testing

* fix: move server base url to a dotenv file and replace the hard-coded url

* feat: permit user to configure a custom route for the server from the options page

* fix: fetch api key and route from local storage and display on options page to inform users of their choices

* fix: move front base url to dotenv and replace the hard-coded url

* fix: remove the trailing slash from person and company linkedin username

* fix: improve code commenting to explain implementation somewhat better

* ci: introduce a workflow to build chrome extension to ensure it can be published

* fix: format files to display code in a consistent manner per the prettier configuration in codebase

* fix: improve the commenting significantly to explain important and hard-to-understand parts of the code

* fix: remove unused permissions from the manifest file for publishing to the chrome web store

* Add nx

* Fix vale

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-02-12 12:30:23 +01:00
Thaïs
8483cf0b4b
POC: chore: use Nx workspace lint rules (#3163)
* chore: use Nx workspace lint rules

Closes #3162

* Fix lint

* Fix lint on BE

* Fix tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-01-03 23:07:25 +01:00
Jérémy M
b9de9f1a08
fix: add vscode workspace (#2937) 2023-12-11 15:45:45 +01:00
Charles Bochet
44baaee28e
Update scripts and documentation to use nx and new monorepo architecture (#2912)
* Update scripts and documentation to use nx and new monorepo architecture

* Start fixing docker

* Migrate eslint plugin and postgres setup

* Fix docker

* Fix patches

* Fix

* fix: wip try to fix the patches

* Apply patches

---------

Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
2023-12-11 10:54:57 +01:00
Charles Bochet
5bdca9de6c
Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
Aasim Attia
a70a9281eb
Move frontend to Vite 5 (#2775)
* merge squashed

- A couple of CJS modules into ESM (config mostly)
- Vite complains about node.js modules: fixed `useIsMatchingLocation.ts`
	> or use rollupOptions in vite.config.ts
	> ref: f0e4f59d97/vite.config.js (L6)
- Adjust Storybook to work with Vite: use @storybook/test
- Use SWC for jest tranformations
- Remove unused deps:
	- ts-jest: replaced with @swc/jest, typecheck by `tsc`
	- babel plugins
	- @svgr/plugin-jsx: not used
	- @testing-library/user-event: handled by @storybook/test
	- @typescript-eslint/utils: was not plugged in
	- tsup, esbuild-plugin-svgr: will look into that later
- Install Vite required deps, and remove craco/webpack deps
- Adjust SVG to work with Vite as components
- Fixed `Step.tsx`: I dont know if one should be swaped for the other,
  but there should be no slash
- Initial formating and linting:
	- removed empty object params
	- sorting imports, etc..

* prettier: fix pattern

* coverage: sb coverage report isnt working

* Add missing pieces

* `yarn lint --fix`

* fix: scripts permissions

* tsc: cut errors in half

* fix: remove `react-app-env.d.ts`

* tsc: all fixed, except `react-data-grid` types issue

* eslint: ignore env-config.js

* eslint: Align ci with config

* msw: bypass testing warnings

ref: https://stackoverflow.com/questions/68024935/msw-logging-warnings-for-unhandled-supertest-requests

* rebase: and fix things

* Adjust to current `graphql-codegen` no ESM support

* Remove vite plugin and use built-in methods

* rebase: and some fixes

* quick fix + `corepack use yarn@1.22.19`

* Fix build errors

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-12-10 16:22:43 +01:00
Jérémy M
93decaceab
fix: FieldMetadata default value and options better validation (#2785)
* fix: wip better field metadata validation

* fix: remove files

* fix: default value and options validation

* fix: small fix

* fix: try to limit patch

* fix: tests

* Update server/src/metadata/field-metadata/validators/is-field-metadata-options.validator.ts

Co-authored-by: Weiko <corentin@twenty.com>

* fix: lint

* fix: standard fields update security

---------

Co-authored-by: Weiko <corentin@twenty.com>
2023-12-06 15:19:23 +01:00
Charles Bochet
f5e1d7825a
Removing Prisma and Grapql-nestjs-prisma resolvers (#2574)
* Some cleaning

* Fix seeds

* Fix all sign in, sign up flow and apiKey optimistic rendering

* Fix
2023-11-19 18:25:47 +01:00
Charles Bochet
9a109758c8
Migrate standard objects (#2439)
* Migrate standard objects

* Add migrations

* fix relation

* fix: register RelationMetadataType enum

* fix: correctly fix null relation

---------

Co-authored-by: corentin <corentin@twenty.com>
Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
2023-11-13 16:08:27 +01:00
Lucas Bordeau
a35ea5e8f9
Feat/front forge graphql query (#2007)
* wip

* Wip

* Wip

* Finished v1

* Wip

* Fix from PR

* Removed unused fragment masking feature

* Fix from PR

* Removed POC from nav bar

* Fix lint

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-10-13 22:27:57 +02:00
David Kramer
aea088df16
eslint prettier error on windows #1798 (#1804)
* fixing es linter errors on windows

* Indentation

* Indentation

---------

Co-authored-by: kramer <david.kramer@gmail.com>
2023-10-03 16:48:52 +02:00
bosiraphael
35fb2576b7
added figma link to README.md (#1835)
* added figma link to README.md

* added figma to the recommended extensions for the project

* updated useful tips in 'work with Figma' section of the docs to add Figma extension for VSCode

* removing yarn.lock

* modified Figma extension docs in 'Work with Figma'

* added Mdx Preview extension to recommended extensions
2023-10-03 12:50:05 +02:00
Charles Bochet
510c466271
Add WSL instruction and IDE setup instruction (#1150)
* Add WSL instruction and IDE setup instruction

* Fix setup

* Fix setup

* Fix

* Update docs/docs/developer/additional/ide-setup.mdx

Co-authored-by: Weiko <corentin@twenty.com>

---------

Co-authored-by: Weiko <corentin@twenty.com>
2023-08-09 22:24:15 -07:00
Charles Bochet
92b9e987a5 Fix vscode using relative imports 2023-07-25 11:34:14 -07:00
Jérémy M
ce3e023a00
feat: server lint import & order (#750) 2023-07-19 14:01:32 +02:00
Félix Malfait
94a913a41f
Add "show company / people" view and "Notes" concept (#528)
* Begin adding show view and refactoring threads to become notes

* Progress on design

* Progress redesign timeline

* Dropdown button, design improvement

* Open comment thread edit mode in drawer

* Autosave local storage and commentThreadcount

* Improve display and fix missing key issue

* Remove some hardcoded CSS properties

* Create button

* Split company show into ui/business + fix eslint

* Fix font weight

* Begin auto-save on edit mode

* Save server-side query result to Apollo cache

* Fix save behavior

* Refetch timeline after creating note

* Rename createCommentThreadWithComment

* Improve styling

* Revert "Improve styling"

This reverts commit 9fbbf2db00.

* Improve CSS styling

* Bring back border radius inadvertently removed

* padding adjustment

* Improve blocknote design

* Improve edit mode display

* Remove Comments.tsx

* Remove irrelevant comment stories

* Removed un-necessary panel component

* stop using fragment, move trash icon

* Add a basic story for CompanyShow

* Add a basic People show view

* Fix storybook tests

* Add very basic Person story

* Refactor PR1

* Refactor part 2

* Refactor part 3

* Refactor part 4

* Fix tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-07-09 22:25:34 -07:00
Jérémy M
433962321a
feat: onboarding ui flow (#464)
* feat: onboarding ui flow

* fix: route naming and auth

* fix: clean unused imports

* fix: remove react.fc

* fix: infra dev remove package.json

* fix: remove usefull memoization

* fix: button stories

* fix: use type instead of interface

* fix: remove debug
2023-06-30 06:26:06 +00:00
Jérémy M
d9af205ccb
feat: clean prisma file, add validation, add prisma editor (#472) 2023-06-29 15:41:58 +02:00
Félix Malfait
1c7980b270
Disable linter on generated code (#363) 2023-06-23 08:43:41 -07:00
Félix Malfait
c20108e088
Add VSCode extensions (#283) 2023-06-14 17:20:12 +02:00
Félix Malfait
830b76cd9a
Icon refactoring (#287)
* Refactor icons

* Fix additional icons
2023-06-14 07:55:54 +02:00
Félix Malfait
3ae6405f4d
Add Algolia Search + other quick improvements to docs (#198) 2023-06-05 18:48:12 +02:00
Lucas Bordeau
fe70f30a29
Lucas/t 364 on comment drawer i can fetch all comment threads with (#193)
* Added prisma to suggested extension in container

* Added comments and authors on drawer with proper resolving

* Fix lint

* Fix console log

* Fixed generated front graphql from rebase
2023-06-05 15:23:29 +02:00
Félix Malfait
14c0119c4b
Update documentation, add GraphiQL to docs (#175)
* Update docusaurus and fix security vulnerabilities

* Begin cleanup docs

* Remove redocusaurus

* Add graphiql in doc

* Add architecture schema

* New tableIcons and cleanup docs
2023-06-01 15:05:53 +02:00
Lucas Bordeau
b0044ed1a2
Lucas/t 231 timebox i can create a company at the same time im creating (#140)
This PR is a bit messy:

adding graphql schema
adding create company creation on company select on People page
some frontend refactoring to be continued

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-05-25 23:09:23 +02:00
Charles Bochet
34543b7fea
Simplify local dev (#137) 2023-05-25 15:56:28 +02:00
Charles Bochet
5d06398d2e
Remove hasura and hasura-auth (#134)
* Remove hasura and hasura-auth

* Move all models to prisma

* Start implementing graphql

* chore: clean package json

* chore: make the code build

* chore: get initial graphql.tsx file

* feature: use typegql as qgl server

* refactor: small refactoring

* refactor: clean tests

* bugfix: make all filters not case sensitive

* chore: remove unused imports

---------

Co-authored-by: Sammy Teillet <sammy.teillet@gmail.com>
2023-05-24 17:20:15 +02:00
Anders Borch
f28edd405f
I can open the project in GitHub (#92)
* Ignore node_modules

* Use bash-compatible dotenv format

While still being compatible with dotenv, this
also allows sourcing the file to export all
variables in bash.

* Add prettier extension to recommendations

* Move to port 5001 to avoid conflict with macOS services

* Add workspace

* Add devcontainer

This automatically starts with all environment
variables available locally.

It brings up services which are dependent on each
other individually and verifies health before
moving on to the next service.

* Split init into clean, up, and logs tasks.

This allows the developer to set up .env and .npmrc
files before running services, and does not require
starting from a clean db every time the devcontainer
is restarted.

* Copy .env when creating codespace

* Automatically run UP command upon devcontainer creation

* Fix log message

---------

Co-authored-by: Felix Malfait <felix.malfait@gmail.com>
2023-05-03 11:34:10 +02:00