Commit Graph

1527 Commits

Author SHA1 Message Date
bosiraphael
f3701281e9
Create new sync statuses and stages for calendar (#5997)
Create fields:
- syncStatus
- syncStage
- syncStageStartedAt
2024-06-24 16:39:56 +02:00
Charles Bochet
ad61efe6ed
Remove multi select usage (#6004)
As per title!

Also, I'm removing an incorrect logic in the enum migration runner that
takes care of the case where we have no defaultValue but non nullable
which is not a valid business case.
2024-06-24 16:39:17 +02:00
Us3r-gitHub
24c31f9b39
Fix(view): Show Kanban View Creation (#5985)
# This PR
- Revise my previous work (PR #5969)
Because it would break the current logic and cause unexpected behavior.
(Issue #5979)
- Solve (Issue #5915) with another way

@lucasbordeau  What do you think about my current approach?
@JarWarren Please check it out—I'd love to get your feedback too!

---------

Co-authored-by: Achsan <achsanh@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-24 16:05:40 +02:00
Aakarshan Thapa
57bbd7c129
Add update chevron (#5988)
Fixes #5986 


1. Added right chevron to Fields Menu Item
<img width="735" alt="Screenshot 2024-06-21 at 5 59 46 PM"
src="https://github.com/twentyhq/twenty/assets/63531478/1515aba0-6732-424d-a0b3-5cc826a35b16">



2. Changed color of Hidden fields menu item chevron and stroke of left
chevron
<img width="735" alt="Screenshot 2024-06-21 at 6 21 30 PM"
src="https://github.com/twentyhq/twenty/assets/63531478/20952197-2f09-486c-a3bb-5b6c285a6996">

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-24 15:01:21 +02:00
Rob Luke
901ef65545
feat: add australian dollar currency (#5990)
Hi Twenty team,
I'd love to have Australian dollar as an option in Twenty! Please let me
me know if I have missed anything I need to change to enable this.
Thanks for a a great product

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-24 14:55:37 +02:00
Atharv Parlikar
28c8f0df32
Turned on tooltip on kanban cards with shortDelay (#5991)
fixes: #5982 

Demo:


https://github.com/twentyhq/twenty/assets/58113282/6593381c-c01a-4259-9caa-8612247a9e95

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-24 14:51:18 +02:00
bosiraphael
77f9f6473b
Create feature flag for calendar V2 (#5998)
Create feature flag for calendar V2
2024-06-24 13:54:52 +02:00
Charles Bochet
498e4ff6ba
Refactor infiniteScoll to use debouncing (#5999)
Same as https://github.com/twentyhq/twenty/pull/5996 but with
useDebounced as asked in review
2024-06-24 13:45:07 +02:00
Raunak Singh Jolly
2e4ba9ca7b
Remove Right-Edge Gap in Table Cell Display (#5992)
fixes #5941 

![Screenshot from 2024-06-23
17-24-24](https://github.com/twentyhq/twenty/assets/59247136/ae67603a-824d-4e6b-b873-2d58e6296341)

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-24 12:03:46 +02:00
Charles Bochet
e8f386ce43
Fix infinite scroll issue on table (#5996)
We had an issue on infinite scroll on table view.
The fetch more logic was modifying isTableLastRowVisible state (which is
wrong, how could it know)? This was done to prevent loading too much
data at once. This was causing some race condition on
isTableLastRowVisible (as the table itself was also changing it
depending on the real visibility of the line)

I have remove this hacky usage of isTableLastRowVisible and replaced it
by a setTimeout to let the user some time to scroll and introduce a
throttle logic.
2024-06-24 11:20:16 +02:00
Charles Bochet
158e7a31f4
Improve tests (#5994)
Our tests on FE are red, which is a threat to code quality. I'm adding a
few unit tests to improve the coverage and lowering a bit the lines
coverage threshold
2024-06-23 20:12:18 +02:00
Weiko
e13dc7a1fc
[FlexibleSchema] Add IndexMetadata decorator (#5981)
## Context
Our Flexible Schema engine dynamically generates entities/tables/APIs
for us but was not flexible enough to build indexes in the DB. With more
and more features involving heavy queries such as Messaging, we are now
adding a new WorkspaceIndex() decorator for our standard objects (will
come later for custom objects). This decorator will give enough
information to the workspace sync metadata manager to generate the
proper migrations that will create or drop indexes on demand.
To be aligned with the rest of the engine, we are adding 2 new tables:
IndexMetadata and IndexFieldMetadata, that will store the info of our
indexes.

## Implementation

```typescript
@WorkspaceEntity({
  standardId: STANDARD_OBJECT_IDS.person,
  namePlural: 'people',
  labelSingular: 'Person',
  labelPlural: 'People',
  description: 'A person',
  icon: 'IconUser',
})
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
  @WorkspaceField({
    standardId: PERSON_STANDARD_FIELD_IDS.email,
    type: FieldMetadataType.EMAIL,
    label: 'Email',
    description: 'Contact’s Email',
    icon: 'IconMail',
  })
  @WorkspaceIndex()
  email: string;
```
By simply adding the WorkspaceIndex decorator, sync-metadata command
will create a new index for that column.
We can also add composite indexes, note that the order is important for
PSQL.
```typescript
@WorkspaceEntity({
  standardId: STANDARD_OBJECT_IDS.person,
  namePlural: 'people',
  labelSingular: 'Person',
  labelPlural: 'People',
  description: 'A person',
  icon: 'IconUser',
})
@WorkspaceIndex(['phone', 'email'])
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```

Currently composite fields and relation fields are not handled by
@WorkspaceIndex() and you will need to use this notation instead
```typescript
@WorkspaceIndex(['companyId', 'nameFirstName'])
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```
<img width="700" alt="Screenshot 2024-06-21 at 15 15 45"
src="https://github.com/twentyhq/twenty/assets/1834158/ac6da1d9-d315-40a4-9ba6-6ab9ae4709d4">

Next step: We might need to implement more complex index expressions,
this is why we have an expression column in IndexMetadata.
What I had in mind for the decorator, still open to discussion
```typescript
@WorkspaceIndex(['nameFirstName', 'nameLastName'], { expression: "$1 || ' ' || $2"})
export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
```

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-06-22 12:39:57 +02:00
Jérémy M
0b4bfce324
feat: drop calendar repository (#5824)
This PR is replacing and removing all the raw queries and repositories
with the new `TwentyORM` and injection system using
`@InjectWorkspaceRepository`.
Some logic that was contained inside repositories has been moved to the
services.
In this PR we're only replacing repositories for calendar feature.

---------

Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-06-22 09:26:58 +02:00
Vitor Hugo Rodrigues
91b0c2bb8e
feat: add brazilian real currency (#5989)
Added support to Brazilian Real currency code, added the new code on
`CurrencyCode.ts` and on `SETTINGS_FIELD_CURRENCY_CODES`
2024-06-22 08:38:52 +02:00
Ymir
d126b148a1
Navigation Panel UI Sizing Changes (#5964)
## Fixes #5902 :
- [x] Navigation items' height should be risen to 28px.
> For clarity:
- [x] Also increased the height of NavigationDrawerSectionTitle to 28px
to match navigation item.
- [x] The gap between sections should be reduced to 12px
> Was already completed it seems.
- [x] The workspace switcher should be aligned with the navigation items

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-21 16:49:48 +02:00
Thomas Trompette
9a4a2e4ca9
Fix links chip design (#5963)
Fix https://github.com/twentyhq/twenty/issues/5938 and
https://github.com/twentyhq/twenty/issues/5655

- Make sure chip count is displayed
- Fix padding
- Fix background colors, border
- Add hover and active states

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-21 16:15:17 +02:00
Akilesh Praveen
732653034e
fix: background colors for record table (#5967)
# Summary
- Address issue #5959 
- Update background color on hover & click for record table

# Test Plan

![Kapture 2024-06-19 at 20 32
44](https://github.com/twentyhq/twenty/assets/10789158/18a58c09-040a-47e6-953d-aac6f3803486)
2024-06-21 16:01:27 +02:00
Aakarshan Thapa
35b9b29f20
Fix: Selected Line Not Fully Highlighted in Blue (#5966)
Fixes: #5942

<img width="1517" alt="Screenshot 2024-06-19 at 5 07 35 PM"
src="https://github.com/twentyhq/twenty/assets/63531478/c88a98e9-7ce3-43fe-a496-1a5dfe796b81">

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-21 15:49:47 +02:00
JarWarren
51e3454d50
Update LOGGER_DRIVER env var description (#5968)
Update the docs to accurately reflect `LoggerDriverType`. Using `sentry`
throws an error on startup.

```
export enum LoggerDriverType {
  Console = 'console',
}
```

Happy to change the wording of course.
2024-06-21 14:52:36 +02:00
Thomas Trompette
68e20c0e87
Add disabled style on non-draggable menu items (#5974)
Closes https://github.com/twentyhq/twenty/issues/5653

<img width="256" alt="Capture d’écran 2024-06-20 à 17 19 44"
src="https://github.com/twentyhq/twenty/assets/22936103/c9d7e58f-818b-44f2-8aa4-4d85c8e1b6be">
<img width="231" alt="Capture d’écran 2024-06-20 à 17 20 03"
src="https://github.com/twentyhq/twenty/assets/22936103/5e981e93-9d59-403a-bb6b-0ff75151ace2">
2024-06-21 14:42:48 +02:00
Us3r-gitHub
7a0f097df4
Fix(view): Create Button is not visible when creating Kanban View (#5969)
Closes #5915 

This issue occurs only when there is no select field.

The user then creates a new one in settings and returns back to the view
picker.
And the bug arises, it because `viewPickerKanbanFieldMetadataId` is not
being set correctly.

When a user navigate to settings, the dirty state should be set to
false. As a result, after re-rendering the view picker component, it
triggers the effect to set `viewPickerKanbanFieldMetadataId`

---------

Co-authored-by: Achsan <achsanh@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-21 12:13:27 +02:00
Pacifique LINJANJA
9228667a57
Add the support of Empty and Non-Empty filter (#5773) 2024-06-20 18:18:12 +02:00
Lucas Bordeau
9e08445bff
Fix date picker wrong on certain timezones (#5972)
Timezone with a negative offset weren't working good with date pickers.

I split the logic for display and parsing between date only and
datetime.

Date time is sending and displaying using timezone, and date only is
sending and displaying by forcing the date to take its UTC day and month
and 00:00:00 time.

This way its consistent across all timezones.
2024-06-20 17:13:30 +02:00
Aditya Pimpalkar
8c6e96c41b
fix: Column header menu Filter button (#5973)
fixes: #5957



https://github.com/twentyhq/twenty/assets/13139771/51d42aa5-c774-4cbe-adca-b95ea6e17bbd
2024-06-20 16:44:28 +02:00
Aditya Pimpalkar
59b9ce689d
add object id column to csv export (#5971)
closes: #5893

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-06-20 16:42:33 +02:00
Rushikesh Tarapure
bc8c895b0e
Feat : Introduced Delay Options for Tooltip (#5766)
Fixes https://github.com/twentyhq/twenty/issues/5727

---------

Co-authored-by: Rushikesh Tarapure <rushikeshtarapure@gofynd.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 16:37:44 +02:00
bosiraphael
86f95c0870
5898 Create a cron to monitor messageChannelSyncStatus (#5933)
Closes #5898
2024-06-19 16:04:01 +02:00
bosiraphael
016132ecf6
Fix reconnect google account bug (#5905)
Update syncStage to FULL_MESSAGE_LIST_FETCH_PENDING when reconnecting
the account to trigger a full sync on the next cron iteration.
2024-06-19 16:00:39 +02:00
bosiraphael
d6fcb9cae8
5934 create alert banner component (#5950)
Closes #5934

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 15:41:57 +02:00
gitstart-twenty
701059007b
Data Skeleton Loading on Indexes (#5828)
### Description
Data Skeleton Loading on Indexes

### Refs
#4459

### Demo


https://github.com/twentyhq/twenty/assets/140154534/d9c9b0fa-2d8c-4b0d-8d48-cae09530622a


Fixes #4459

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 15:25:20 +02:00
Thomas Trompette
ff21396bc6
[Bug] Put back subject is email right drawer (#5955)
Fix https://github.com/twentyhq/twenty/issues/5903
2024-06-19 14:48:09 +02:00
Joshua Zacek
60b60bd4b3
(5943) Match country selector button's background to phone number input's background (#5956)
Fixes #5943

### Before
Light
<img width="218" alt="Screenshot 2024-06-19 at 12 37 22 PM"
src="https://github.com/twentyhq/twenty/assets/57673080/981d1877-be4e-4071-9a8d-9d0ed7e933ab">
Dark
<img width="223" alt="Screenshot 2024-06-19 at 12 39 42 PM"
src="https://github.com/twentyhq/twenty/assets/57673080/a3730ef5-21ba-4d90-998d-d330aec350ad">


### After
Light
<img width="216" alt="Screenshot 2024-06-19 at 12 39 00 PM"
src="https://github.com/twentyhq/twenty/assets/57673080/eef3b743-1b28-43a5-8c1c-bd944a4915c7">
Dark
<img width="228" alt="Screenshot 2024-06-19 at 12 39 29 PM"
src="https://github.com/twentyhq/twenty/assets/57673080/5bf10e51-5a07-4d55-99f1-734517b22781">
2024-06-19 14:46:47 +02:00
Atchyut Preetham Pulavarthi
1c685e8a31
fix(twenty-front): update DateTimeInput styles to apply top border radius to date picker (#5946)
update DateTimeInput styled components to prevent the StyledInput from
overflowing out of it's parent container

<img width="860" alt="Screenshot 2024-06-19 at 9 55 04 AM"
src="https://github.com/twentyhq/twenty/assets/19223383/8c5daf6a-9eb6-4ecd-a2e9-aa2ba8db3874">



Fixes #5940
2024-06-19 14:38:30 +02:00
Lucas Bordeau
76bcf31341
Added a mechanism to reset error boundary on page change. (#5913)
Previously the error boundary component was re-rendering with the same
state as long as we stayed in the same router, so for page change inside
an index container, it would stay on error state.

The fix is to memorize the location the error page is on during its
first render, and then to reset the error boundary if it gets
re-rendered with a different location even in the same index container.

Fixes : #3592
2024-06-19 14:34:11 +02:00
Ravan
c7e6d6959f
Add a ⏎ shortcut on Select options (#5641)
fixes #5540 

Added onkeyDown to 
1. Create new option and 
2. Move focus to it.

[screen-capture
(6).webm](https://github.com/twentyhq/twenty/assets/69167444/ede54ad8-22db-4b09-9617-4d999c6c08c7)

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 14:30:26 +02:00
gitstart-twenty
64b456912a
Favicons are being re-rendered on hover (#5849)
### Description

Favicons are being re-rendered on hover

### Refs

#3523

### Demo


https://www.loom.com/share/e3944d940a014283af8c26baac1fed57?sid=e3e96a81-3a54-4969-8602-99c64bb3ffe7

Fixes #3523

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-06-19 13:34:42 +02:00
Thomas Trompette
96da777107
Handle no concurrency option (#5952)
Fix error in local `teamConcurrency must be an integer between 1 and
1000`
2024-06-19 11:54:11 +02:00
Thomas Trompette
d045bcbb94
Add http status to graphql errors (#5896)
Graphql errors are not properly filtered by our handler. We still
receive errors like `NOT_FOUND` in sentry while they should be filtered.
Example
[here](https://twenty-v7.sentry.io/issues/5490383016/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=6).

We associate statuses with errors in our map
`graphQLPredefinedExceptions` but we cannot retrieve the status from the
error.

This PR lists the codes that should be filtered.

To test:
- call `findDuplicates` with an invalid id
- before, server would breaks
- now the error is simply returned
2024-06-19 10:39:09 +02:00
martmull
6fd8dab552
5582 get httpsapitwentycomrestmetadata objects filters dont work (#5906)
- Remove filters from metadata rest api
- add limite before and after parameters for metadata
- remove update from metadata relations
- fix typing issue
- fix naming
- fix before parameter

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-06-18 18:55:13 +02:00
Félix Malfait
dbaa787d19
website / Fix broken links, slow loading, and prod errors (#5932)
The code is in a bad state, this is just fixing it but not improving the
structure
2024-06-18 18:40:19 +02:00
Thomas Trompette
6b1548ebbe
Add loader and transition for details page tabs (#5935)
Closes https://github.com/twentyhq/twenty/issues/5656



https://github.com/twentyhq/twenty/assets/22936103/3e4beea2-9aa9-4015-bb99-ee22adb53b63
2024-06-18 18:38:14 +02:00
martmull
cff8561597
Upgrade pg graphql version to 1.5.6 (#5937)
- update `pg_graphql` version doc
- update `pg_graphql` version to 1.5.6
2024-06-18 17:34:16 +02:00
Hanch Han
38537a3967
Add South Korean won to currency codes (#5914)
Greetings from Seoul! I found this amazing project a few days ago, and
trying to introduce it to my team. However there is a tiny but
significant problem, that South Korean won is not available in twenty.

So I added `KRW` to the enum `CurrencyCode` and the constant
`SETTINGS_FIELD_CURRENCY_CODES`. I tested it locally and apparently
works fine.
2024-06-18 11:14:31 +02:00
Aditya Pimpalkar
14abd99bb7
add multiple filters of same FieldMetadataType (#5892)
fixes: #5378
2024-06-18 10:49:33 +02:00
Thomas Trompette
de2b0527a3
Fix secondaryLinks field input (#5911)
PR https://github.com/twentyhq/twenty/pull/5785/files broke links
update.

Also, dropdown "Add link" will be displayed only if a link is already
added. Otherwise, it should be a normal input.
2024-06-17 18:09:46 +02:00
Lucas Bordeau
e1bd3a4c5a
Added and optimized missing RatingFieldDisplay component (#5904)
The display for Rating field type was missing, I just added it based on
RatingInput in readonly mode and optimized a bit for performance also.

Fixes https://github.com/twentyhq/twenty/issues/5900
2024-06-17 17:27:19 +02:00
Thomas Trompette
dba0b28eae
Fix verticale line timeline activity (#5894)
Before 

<img width="400" alt="Capture d’écran 2024-06-17 à 10 23 17"
src="https://github.com/twentyhq/twenty/assets/22936103/01408d7b-9a6c-4a21-9f08-c8cf304e2ea0">

After

<img width="400" alt="Capture d’écran 2024-06-17 à 10 05 39"
src="https://github.com/twentyhq/twenty/assets/22936103/df384726-bbf9-4828-ad47-d1c91724947d">
2024-06-17 11:54:04 +02:00
martmull
1ba7037fdc
5581 get httpsapitwentycomrestmetadata relations not working (#5867)
Filtering relations is not allowed
(see`packages/twenty-server/src/engine/metadata-modules/relation-metadata/dtos/relation-metadata.dto.ts`)
so we remove filtering for find many relation

we also fixed some bug in result structure and metadata open-api schema
2024-06-17 10:59:29 +02:00
martmull
d8034b1f40
5236 expandable list leave options when editing (#5890)
Fixes https://github.com/twentyhq/twenty/issues/5236
## After

![image](https://github.com/twentyhq/twenty/assets/29927851/5f0f910c-11b0-40ce-9c59-34e7ce0c2741)
2024-06-17 10:17:31 +02:00
Jérémy M
d99b9d1d6b
feat: Enhancements to MessageQueue Module with Decorators (#5657)
### Overview

This PR introduces significant enhancements to the MessageQueue module
by integrating `@Processor`, `@Process`, and `@InjectMessageQueue`
decorators. These changes streamline the process of defining and
managing queue processors and job handlers, and also allow for
request-scoped handlers, improving compatibility with services that rely
on scoped providers like TwentyORM repositories.

### Key Features

1. **Decorator-based Job Handling**: Use `@Processor` and `@Process`
decorators to define job handlers declaratively.
2. **Request Scope Support**: Job handlers can be scoped per request,
enhancing integration with request-scoped services.

### Usage

#### Defining Processors and Job Handlers

The `@Processor` decorator is used to define a class that processes jobs
for a specific queue. The `@Process` decorator is applied to methods
within this class to define specific job handlers.

##### Example 1: Specific Job Handlers

```typescript
import { Processor, Process, InjectMessageQueue } from 'src/engine/integrations/message-queue';

@Processor('taskQueue')
export class TaskProcessor {

  @Process('taskA')
  async handleTaskA(job: { id: string, data: any }) {
    console.log(`Handling task A with data:`, job.data);
    // Logic for task A
  }

  @Process('taskB')
  async handleTaskB(job: { id: string, data: any }) {
    console.log(`Handling task B with data:`, job.data);
    // Logic for task B
  }
}
```

In the example above, `TaskProcessor` is responsible for processing jobs
in the `taskQueue`. The `handleTaskA` method will only be called for
jobs with the name `taskA`, while `handleTaskB` will be called for
`taskB` jobs.

##### Example 2: General Job Handler

```typescript
import { Processor, Process, InjectMessageQueue } from 'src/engine/integrations/message-queue';

@Processor('generalQueue')
export class GeneralProcessor {

  @Process()
  async handleAnyJob(job: { id: string, name: string, data: any }) {
    console.log(`Handling job ${job.name} with data:`, job.data);
    // Logic for any job
  }
}
```

In this example, `GeneralProcessor` handles all jobs in the
`generalQueue`, regardless of the job name. The `handleAnyJob` method
will be invoked for every job added to the `generalQueue`.

#### Adding Jobs to a Queue

You can use the `@InjectMessageQueue` decorator to inject a queue into a
service and add jobs to it.

##### Example:

```typescript
import { Injectable } from '@nestjs/common';
import { InjectMessageQueue, MessageQueue } from 'src/engine/integrations/message-queue';

@Injectable()
export class TaskService {
  constructor(
    @InjectMessageQueue('taskQueue') private readonly taskQueue: MessageQueue,
  ) {}

  async addTaskA(data: any) {
    await this.taskQueue.add('taskA', data);
  }

  async addTaskB(data: any) {
    await this.taskQueue.add('taskB', data);
  }
}
```

In this example, `TaskService` adds jobs to the `taskQueue`. The
`addTaskA` and `addTaskB` methods add jobs named `taskA` and `taskB`,
respectively, to the queue.

#### Using Scoped Job Handlers

To utilize request-scoped job handlers, specify the scope in the
`@Processor` decorator. This is particularly useful for services that
use scoped repositories like those in TwentyORM.

##### Example:

```typescript
import { Processor, Process, InjectMessageQueue, Scope } from 'src/engine/integrations/message-queue';

@Processor({ name: 'scopedQueue', scope: Scope.REQUEST })
export class ScopedTaskProcessor {

  @Process('scopedTask')
  async handleScopedTask(job: { id: string, data: any }) {
    console.log(`Handling scoped task with data:`, job.data);
    // Logic for scoped task, which might use request-scoped services
  }
}
```

Here, the `ScopedTaskProcessor` is associated with `scopedQueue` and
operates with request scope. This setup is essential when the job
handler relies on services that need to be instantiated per request,
such as scoped repositories.

### Migration Notes

- **Decorators**: Refactor job handlers to use `@Processor` and
`@Process` decorators.
- **Request Scope**: Utilize the scope option in `@Processor` if your
job handlers depend on request-scoped services.

Fix #5628

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-06-17 09:49:37 +02:00