Skip to content

The open alternative to Salesforce, designed for AI.

chore: replace JSDoc blocks on internal utils with short comments (#24130)

Charles Bochetae0ca57f8432
diff --git a/packages/twenty-front/setupTests.ts b/packages/twenty-front/setupTests.ts
index 4fc4c3798ae..9c8295f1b9c 100644
--- a/packages/twenty-front/setupTests.ts
+++ b/packages/twenty-front/setupTests.ts
@@ -1,7 +1,3 @@
-// jest-dom adds custom jest matchers for asserting on DOM nodes.
-// allows you to do things like:
-// expect(element).toHaveTextContent(/react/i)
-// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
import {
ReadableStream as NodeReadableStream,
diff --git a/packages/twenty-front/src/modules/apollo/utils/__tests__/hasTokenPair.test.ts b/packages/twenty-front/src/modules/apollo/utils/__tests__/hasTokenPair.test.ts
index 28e907bccf9..d2425dd9b44 100644
--- a/packages/twenty-front/src/modules/apollo/utils/__tests__/hasTokenPair.test.ts
+++ b/packages/twenty-front/src/modules/apollo/utils/__tests__/hasTokenPair.test.ts
@@ -86,8 +86,6 @@ describe('hasTokenPair', () => {
describe('validation behavior', () => {
it('should rely on getTokenPair for all validation logic', () => {
- // Test that hasTokenPair doesn't do its own validation
- // and trusts getTokenPair's validation completely
mockGetTokenPair.mockReturnValue(undefined);
hasTokenPair();
diff --git a/packages/twenty-front/src/modules/localization/utils/detection/detectTimeZone.ts b/packages/twenty-front/src/modules/localization/utils/detection/detectTimeZone.ts
index 86f678a67e7..d2d752cb50b 100644
--- a/packages/twenty-front/src/modules/localization/utils/detection/detectTimeZone.ts
+++ b/packages/twenty-front/src/modules/localization/utils/detection/detectTimeZone.ts
@@ -1,7 +1,3 @@
-/**
- * Detects the user's time zone.
- * @returns a IANA time zone
- */
export const detectTimeZone = (): string => {
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
diff --git a/packages/twenty-front/src/modules/localization/utils/findAvailableTimeZoneOption.ts b/packages/twenty-front/src/modules/localization/utils/findAvailableTimeZoneOption.ts
index ada7868b349..dc083b80ce7 100644
--- a/packages/twenty-front/src/modules/localization/utils/findAvailableTimeZoneOption.ts
+++ b/packages/twenty-front/src/modules/localization/utils/findAvailableTimeZoneOption.ts
@@ -1,10 +1,5 @@
import { formatTimeZoneLabel } from '@/localization/utils/formatTimeZoneLabel';
import { AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL } from '@/settings/experience/constants/AvailableTimezoneOptionsByLabel';
-/**
- * Finds the matching available IANA time zone select option from a given IANA time zone.
- * @param value the IANA time zone to match
- * @returns the matching available IANA time zone select option or undefined
- */
export const findAvailableTimeZoneOption = (value: string) =>
AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL[formatTimeZoneLabel(value)];
diff --git a/packages/twenty-front/src/modules/localization/utils/formatTimeZoneLabel.ts b/packages/twenty-front/src/modules/localization/utils/formatTimeZoneLabel.ts
index b318759b63c..5930f407d2f 100644
--- a/packages/twenty-front/src/modules/localization/utils/formatTimeZoneLabel.ts
+++ b/packages/twenty-front/src/modules/localization/utils/formatTimeZoneLabel.ts
@@ -1,12 +1,7 @@
import { formatInTimeZone } from 'date-fns-tz';
import { enUS as defaultLocale } from 'date-fns/locale/en-US';
-/**
- * Formats a IANA time zone to a select option label.
- * @param ianaTimeZone IANA time zone
- * @returns Formatted label
- * @example 'Europe/Paris' => '(GMT+01:00) Central European Time - Paris'
- */
+// 'Europe/Paris' => '(GMT+01:00) Central European Time - Paris'
export const formatTimeZoneLabel = (ianaTimeZone: string) => {
const timeZoneWithGmtOffset = formatInTimeZone(
Date.now(),
diff --git a/packages/twenty-front/src/modules/settings/two-factor-authentication/utils/extractSecretFromOtpUri.ts b/packages/twenty-front/src/modules/settings/two-factor-authentication/utils/extractSecretFromOtpUri.ts
index 14d094d9c65..9251aafede5 100644
--- a/packages/twenty-front/src/modules/settings/two-factor-authentication/utils/extractSecretFromOtpUri.ts
+++ b/packages/twenty-front/src/modules/settings/two-factor-authentication/utils/extractSecretFromOtpUri.ts
@@ -1,8 +1,3 @@
-/**
- * Extracts the secret from an OTP URI (otpauth://totp/...)
- * @param otpUri - The OTP URI containing the secret
- * @returns The secret string or null if not found
- */
export const extractSecretFromOtpUri = (otpUri: string): string | null => {
try {
const url = new URL(otpUri);
diff --git a/packages/twenty-front/src/utils/array/groupArrayItemsBy.ts b/packages/twenty-front/src/utils/array/groupArrayItemsBy.ts
index 1aa3fac7106..a8bf2c941b7 100644
--- a/packages/twenty-front/src/utils/array/groupArrayItemsBy.ts
+++ b/packages/twenty-front/src/utils/array/groupArrayItemsBy.ts
@@ -1,22 +1,4 @@
-/**
- * Groups an array of items by a key computed from each item.
- *
- * @param array - The array to group.
- * @param computeGroupKey - A function that computes the group key to which the item belongs.
- *
- * @returns An object with items grouped by a computed key.
- *
- * @example
- * groupArrayItemsBy(
- * [{ id: '1', type: 'fruit' }, { id: '2', type: 'vegetable' }, { id: '3', type: 'fruit' }],
- * ({ type }) => type,
- * )
- * ⬇️
- * {
- * fruit: [{ id: '1', type: 'fruit' }, { id: '3', type: 'fruit' }],
- * vegetable: [{ id: '2', type: 'vegetable' }],
- * }
- */
+// Groups are keyed by computeGroupKey, so a key no item produces is absent rather than empty
export const groupArrayItemsBy = <ArrayItem, Key extends string | number>(
array: ArrayItem[],
computeGroupKey: (item: ArrayItem) => Key,
diff --git a/packages/twenty-front/src/utils/array/mapArrayToObject.ts b/packages/twenty-front/src/utils/array/mapArrayToObject.ts
index 2d331f178dd..bc5380b6fb6 100644
--- a/packages/twenty-front/src/utils/array/mapArrayToObject.ts
+++ b/packages/twenty-front/src/utils/array/mapArrayToObject.ts
@@ -1,23 +1,4 @@
-/**
- * Transforms an array of items into an object where the keys are computed from each item.
- *
- * @param array - The array to transform.
- * @param computeItemKey - A function that computes a key from an item.
- *
- * @returns An object where the keys are computed from the items in the array.
- *
- * @example
- * mapArrayToObject(
- * [{ id: '1', type: 'fruit' }, { id: '2', type: 'vegetable' }, { id: '3', type: 'fruit' }],
- * ({ id }) => id,
- * )
- * ⬇️
- * {
- * '1': { id: '1', type: 'fruit' },
- * '2': { id: '2', type: 'vegetable' },
- * '3': { id: '3', type: 'fruit' },
- * }
- */
+// Later items win on a duplicate key, so computeItemKey should be unique per item
export const mapArrayToObject = <ArrayItem, Key extends string>(
array: ArrayItem[],
computeItemKey: (item: ArrayItem) => Key,
diff --git a/packages/twenty-front/src/utils/array/moveArrayItem.ts b/packages/twenty-front/src/utils/array/moveArrayItem.ts
index 4e6e52f89a8..cd5bfdfafff 100644
--- a/packages/twenty-front/src/utils/array/moveArrayItem.ts
+++ b/packages/twenty-front/src/utils/array/moveArrayItem.ts
@@ -1,19 +1,6 @@
import { toSpliced } from '~/utils/array/toSpliced';
-/**
- * Moves an item in an array from one index to another.
- *
- * @param array - The array to move an item in.
- * @param indices - The indices to move the item from and to.
- * @param indices.fromIndex - The index to move the item from.
- * @param indices.toIndex - The index to move the item to.
- *
- * @returns A new array with the item moved to the new index.
- *
- * @example
- * moveArrayItem(['a', 'b', 'c'], { fromIndex: 0, toIndex: 2 })
- * => ['b', 'c', 'a']
- */
+// moveArrayItem(['a', 'b', 'c'], { fromIndex: 0, toIndex: 2 }) => ['b', 'c', 'a']
export const moveArrayItem = <ArrayItem>(
array: ArrayItem[],
{ fromIndex, toIndex }: { fromIndex: number; toIndex: number },
diff --git a/packages/twenty-front/src/utils/array/toSpliced.ts b/packages/twenty-front/src/utils/array/toSpliced.ts
index 40fe1991004..fc8f5c79dd0 100644
--- a/packages/twenty-front/src/utils/array/toSpliced.ts
+++ b/packages/twenty-front/src/utils/array/toSpliced.ts
@@ -3,24 +3,7 @@ type ToSplicedFn = {
<T>(array: T[], start: number, deleteCount: number, ...items: T[]): T[];
};
-/**
- * Returns a new array with some elements removed and/or replaced at a given index.
- * This does the same as `Array.prototype.toSpliced`.
- * Polyfill for environments that don't support Array.prototype.toSpliced.
- *
- * @param array - The array to remove and/or replace elements from.
- * @param start - The index at which to start changing the array.
- * @param deleteCount - The number of elements in the array to remove from `start`.
- * @param items - The elements to add to the array at `start`.
- *
- * @returns A new array with elements removed and/or replaced at a given index.
- *
- * @example
- * toSpliced(['a', 'b', 'c'], 0, 1)
- * => ['b', 'c']
- * toSpliced(['a', 'b', 'c'], 0, 1, 'd')
- * => ['d', 'b', 'c']
- */
+// Polyfill for Array.prototype.toSpliced, which our lowest supported runtimes lack
export const toSpliced: ToSplicedFn = (array, ...args) => {
const arrayCopy = [...array];
arrayCopy.splice(...(args as [number, number, ...any[]]));
diff --git a/packages/twenty-server/src/engine/core-modules/exception-handler/exception-handler.module-factory.ts b/packages/twenty-server/src/engine/core-modules/exception-handler/exception-handler.module-factory.ts
index ddd5b92f29e..cf46c79c32b 100644
--- a/packages/twenty-server/src/engine/core-modules/exception-handler/exception-handler.module-factory.ts
+++ b/packages/twenty-server/src/engine/core-modules/exception-handler/exception-handler.module-factory.ts
@@ -6,12 +6,6 @@ import { type OPTIONS_TYPE } from 'src/engine/core-modules/exception-handler/exc
import { ExceptionHandlerDriver } from 'src/engine/core-modules/exception-handler/interfaces';
import { type TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
-/**
- * ExceptionHandler Module factory
- * @returns ExceptionHandlerModuleOptions
- * @param twentyConfigService
- * @param adapterHost
- */
export const exceptionHandlerModuleFactory = async (
twentyConfigService: TwentyConfigService,
adapterHost: HttpAdapterHost,
diff --git a/packages/twenty-server/src/engine/core-modules/logger/logger.module-factory.ts b/packages/twenty-server/src/engine/core-modules/logger/logger.module-factory.ts
index 43941216120..0afbfd5353e 100644
--- a/packages/twenty-server/src/engine/core-modules/logger/logger.module-factory.ts
+++ b/packages/twenty-server/src/engine/core-modules/logger/logger.module-factory.ts
@@ -4,11 +4,6 @@ import {
} from 'src/engine/core-modules/logger/interfaces';
import { type TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
-/**
- * Logger Module factory
- * @returns LoggerModuleOptions
- * @param twentyConfigService
- */
export const loggerModuleFactory = async (
twentyConfigService: TwentyConfigService,
): Promise<LoggerModuleOptions> => {
diff --git a/packages/twenty-server/src/engine/core-modules/message-queue/decorators/processor.decorator.ts b/packages/twenty-server/src/engine/core-modules/message-queue/decorators/processor.decorator.ts
index 923633834be..de3608444de 100644
--- a/packages/twenty-server/src/engine/core-modules/message-queue/decorators/processor.decorator.ts
+++ b/packages/twenty-server/src/engine/core-modules/message-queue/decorators/processor.decorator.ts
@@ -17,10 +17,6 @@ export interface MessageQueueProcessorOptions {
scope?: Scope;
}
-/**
- * Represents a worker that is able to process jobs from the queue.
- * @param processorOptions processor options
- */
export function Processor(
queueNameOrOptions: string | MessageQueueProcessorOptions,
): ClassDecorator {
diff --git a/packages/twenty-server/src/engine/core-modules/message-queue/message-queue.module-factory.ts b/packages/twenty-server/src/engine/core-modules/message-queue/message-queue.module-factory.ts
index 2d30c80cc0b..21cb0169770 100644
--- a/packages/twenty-server/src/engine/core-modules/message-queue/message-queue.module-factory.ts
+++ b/packages/twenty-server/src/engine/core-modules/message-queue/message-queue.module-factory.ts
@@ -7,13 +7,6 @@ import { type MetricsService } from 'src/engine/core-modules/metrics/metrics.ser
import { type RedisClientService } from 'src/engine/core-modules/redis-client/redis-client.service';
import { type TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
-/**
- * MessageQueue Module factory
- * @returns MessageQueueModuleOptions
- * @param twentyConfigService
- * @param redisClientService
- * @param metricsService
- */
export const messageQueueModuleFactory = async (
twentyConfigService: TwentyConfigService,
redisClientService: RedisClientService,
diff --git a/packages/twenty-server/src/engine/core-modules/two-factor-authentication/two-factor-authentication.service.ts b/packages/twenty-server/src/engine/core-modules/two-factor-authentication/two-factor-authentication.service.ts
index 0681cab32c5..f9bb4494cff 100644
--- a/packages/twenty-server/src/engine/core-modules/two-factor-authentication/two-factor-authentication.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/two-factor-authentication/two-factor-authentication.service.ts
@@ -52,14 +52,8 @@ export class TwoFactorAuthenticationService {
});
}
- /**
- * Validates two-factor authentication requirements for a workspace.
- *
- * @throws {AuthException} with TWO_FACTOR_AUTHENTICATION_VERIFICATION_REQUIRED if 2FA is set up and needs verification
- * @throws {AuthException} with TWO_FACTOR_AUTHENTICATION_PROVISION_REQUIRED if 2FA is enforced but not set up
- * @param targetWorkspace - The workspace to check 2FA requirements for
- * @param userTwoFactorAuthenticationMethods - Optional array of user's 2FA methods
- */
+ // Throws TWO_FACTOR_AUTHENTICATION_VERIFICATION_REQUIRED when 2FA is set up, and
+ // TWO_FACTOR_AUTHENTICATION_PROVISION_REQUIRED when it is enforced but not set up
async validateTwoFactorAuthenticationRequirement(
targetWorkspace: WorkspaceEntity,
userTwoFactorAuthenticationMethods?: TwoFactorAuthenticationMethodEntity[],
diff --git a/packages/twenty-server/src/engine/workspace-datasource/workspace-datasource.service.ts b/packages/twenty-server/src/engine/workspace-datasource/workspace-datasource.service.ts
index 7411b4bb789..684d71c26e1 100644
--- a/packages/twenty-server/src/engine/workspace-datasource/workspace-datasource.service.ts
+++ b/packages/twenty-server/src/engine/workspace-datasource/workspace-datasource.service.ts
@@ -46,13 +46,6 @@ export class WorkspaceDataSourceService {
return isNonEmptyString(workspace?.databaseSchema);
}
- /**
- *
- * Create a new DB schema for a workspace
- *
- * @param workspaceId
- * @returns
- */
public async createWorkspaceDBSchema(workspaceId: string): Promise<string> {
this.assertDDLNotLocked();
@@ -68,13 +61,6 @@ export class WorkspaceDataSourceService {
}
}
- /**
- *
- * Delete a DB schema for a workspace
- *
- * @param workspaceId
- * @returns
- */
public async deleteWorkspaceDBSchema(workspaceId: string): Promise<void> {
this.assertDDLNotLocked();
diff --git a/packages/twenty-server/src/modules/match-participant/utils/add-person-email-filters-to-query-builder.ts b/packages/twenty-server/src/modules/match-participant/utils/add-person-email-filters-to-query-builder.ts
index abc93777858..807a7b0fad9 100644
--- a/packages/twenty-server/src/modules/match-participant/utils/add-person-email-filters-to-query-builder.ts
+++ b/packages/twenty-server/src/modules/match-participant/utils/add-person-email-filters-to-query-builder.ts
@@ -8,16 +8,7 @@ export interface AddPersonEmailFiltersToQueryBuilderOptions {
excludePersonIds?: string[];
}
-/**
- * Adds filters to a query builder to only return people with the given emails.
- * This is used to find people by their primary or additional emails.
- * We use the query builder here instead of the find method from typeorm
- * because we need to use the jsonb @> operator to check if the email is in the additional emails array.
- *
- * @param queryBuilder - The query builder to add the filters to
- * @param emails - The emails to filter by
- * @param excludePersonIds - The person IDs to exclude from the results
- */
+// A query builder rather than find(): matching additional emails needs the jsonb @> operator
export function addPersonEmailFiltersToQueryBuilder({
queryBuilder,
emails,
diff --git a/packages/twenty-shared/src/utils/deepMerge.ts b/packages/twenty-shared/src/utils/deepMerge.ts
index 3339d7c6ae4..e7d6ab66629 100644
--- a/packages/twenty-shared/src/utils/deepMerge.ts
+++ b/packages/twenty-shared/src/utils/deepMerge.ts
@@ -1,16 +1,5 @@
-/**
- * Deep merges two objects or arrays recursively
- * - Objects are merged by combining their properties
- * - Arrays are merged by concatenating them
- * - Primitive values from target override source
- * - Null values from target are preserved
- * - Undefined values from target are ignored
- * - Date and RegExp objects are treated as primitives (replaced, not merged)
- *
- * @param source The source object to merge from
- * @param target The target object to merge into
- * @returns A new merged object
- */
+// Arrays concatenate rather than replace, Date/RegExp are replaced rather than merged, and in
+// target a null overwrites the source while an undefined is ignored
export const deepMerge = <T extends object>(
source: Required<T>,
target: Required<T>,
diff --git a/packages/twenty-ui/setupTests.ts b/packages/twenty-ui/setupTests.ts
index 8f2609b7b3e..7b0828bfa80 100644
--- a/packages/twenty-ui/setupTests.ts
+++ b/packages/twenty-ui/setupTests.ts
@@ -1,5 +1 @@
-// jest-dom adds custom jest matchers for asserting on DOM nodes.
-// allows you to do things like:
-// expect(element).toHaveTextContent(/react/i)
-// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';