Update user friendly errors for translations (#15000)
Force msg typing instead of string for user friendly errors
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InjectDataSource } from '@nestjs/typeorm';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { DataSource, type QueryRunner, Table, type TableColumn } from 'typeorm';
|
||||
|
||||
@@ -257,7 +257,7 @@ export class WorkspaceMigrationRunnerService {
|
||||
`Unique index creation failed because of unique constraint violation`,
|
||||
IndexMetadataExceptionCode.INDEX_CREATION_FAILED,
|
||||
{
|
||||
userFriendlyMessage: t`Cannot enable uniqueness due to existing duplicate values. Please review and fix your data first (including soft deleted records).`,
|
||||
userFriendlyMessage: msg`Cannot enable uniqueness due to existing duplicate values. Please review and fix your data first (including soft deleted records).`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,21 +1,20 @@
|
||||
import { type AllFlatEntitiesByMetadataEngineName } from 'src/engine/core-modules/common/types/all-flat-entities-by-metadata-engine-name.type';
|
||||
import { type FieldMetadataMinimalInformation } from 'src/engine/metadata-modules/flat-field-metadata/types/field-metadata-minimal-information.type';
|
||||
import { type FlatFieldMetadataValidationError } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata-validation-error.type';
|
||||
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
|
||||
import { type ObjectMetadataMinimalInformation } from 'src/engine/metadata-modules/flat-object-metadata/types/object-metadata-minimal-information.type';
|
||||
import { type OrchestratorFailureReport } from 'src/engine/workspace-manager/workspace-migration-v2/types/workspace-migration-orchestrator.type';
|
||||
import { type TranslatedFlatEntityValidationError } from 'src/engine/workspace-manager/workspace-migration-v2/interceptors/utils/translate-validation-errors.util';
|
||||
import { type WorkspaceMigrationFieldActionTypeV2 } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/workspace-migration-field-action-v2';
|
||||
import { type WorkspaceMigrationObjectActionTypeV2 } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/workspace-migration-object-action-v2';
|
||||
|
||||
export type ValidationErrorFieldResponse =
|
||||
Partial<FieldMetadataMinimalInformation> & {
|
||||
operation: WorkspaceMigrationFieldActionTypeV2;
|
||||
errors: FlatFieldMetadataValidationError[];
|
||||
errors: TranslatedFlatEntityValidationError[];
|
||||
};
|
||||
export type ValidationErrorObjectResponse =
|
||||
Partial<ObjectMetadataMinimalInformation> & {
|
||||
operation: WorkspaceMigrationObjectActionTypeV2;
|
||||
errors: FlatObjectMetadataValidationError[];
|
||||
errors: TranslatedFlatEntityValidationError[];
|
||||
fields: ValidationErrorFieldResponse[];
|
||||
};
|
||||
|
||||
|
||||
+12
-3
@@ -1,8 +1,12 @@
|
||||
import { type I18n } from '@lingui/core';
|
||||
|
||||
import { type WorkspaceMigrationBuilderExceptionV2 } from 'src/engine/workspace-manager/workspace-migration-v2/exceptions/workspace-migration-builder-exception-v2';
|
||||
import { type ValidationErrorResponse } from 'src/engine/workspace-manager/workspace-migration-v2/interceptors/types/validate-error-response.type';
|
||||
import { translateOrchestratorFailureReport } from 'src/engine/workspace-manager/workspace-migration-v2/interceptors/utils/translate-validation-errors.util';
|
||||
|
||||
export const fromWorkspaceMigrationBuilderExceptionToValidationResponseError = (
|
||||
workspaceMigrationBuilderException: WorkspaceMigrationBuilderExceptionV2,
|
||||
i18n: I18n,
|
||||
): ValidationErrorResponse => {
|
||||
const emptyResponseError: ValidationErrorResponse = {
|
||||
summary: {
|
||||
@@ -30,10 +34,15 @@ export const fromWorkspaceMigrationBuilderExceptionToValidationResponseError = (
|
||||
},
|
||||
};
|
||||
|
||||
const report =
|
||||
workspaceMigrationBuilderException.failedWorkspaceMigrationBuildResult
|
||||
.report;
|
||||
|
||||
// Translate all MessageDescriptors in the report structure
|
||||
const translatedReport = translateOrchestratorFailureReport(report, i18n);
|
||||
|
||||
return {
|
||||
...emptyResponseError,
|
||||
errors:
|
||||
workspaceMigrationBuilderException.failedWorkspaceMigrationBuildResult
|
||||
.report,
|
||||
errors: translatedReport,
|
||||
};
|
||||
};
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import { type I18n, type MessageDescriptor } from '@lingui/core';
|
||||
|
||||
import { type OrchestratorFailureReport } from 'src/engine/workspace-manager/workspace-migration-v2/types/workspace-migration-orchestrator.type';
|
||||
|
||||
export type TranslatedFlatEntityValidationError<TCode extends string = string> =
|
||||
{
|
||||
code: TCode;
|
||||
message: string;
|
||||
userFriendlyMessage?: string;
|
||||
value?: unknown;
|
||||
};
|
||||
|
||||
const translateMessageDescriptorsInObject = <T>(obj: T, i18n: I18n): T => {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof obj === 'object' &&
|
||||
'id' in obj &&
|
||||
'message' in obj &&
|
||||
typeof (obj as MessageDescriptor).id === 'string'
|
||||
) {
|
||||
return i18n._(obj as MessageDescriptor) as T;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item) =>
|
||||
translateMessageDescriptorsInObject(item, i18n),
|
||||
) as T;
|
||||
}
|
||||
|
||||
const result = {} as T;
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
(result as Record<string, unknown>)[key] =
|
||||
translateMessageDescriptorsInObject(value, i18n);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const translateOrchestratorFailureReport = (
|
||||
report: OrchestratorFailureReport,
|
||||
i18n: I18n,
|
||||
): OrchestratorFailureReport => {
|
||||
return translateMessageDescriptorsInObject(report, i18n);
|
||||
};
|
||||
+8
-3
@@ -1,4 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { type I18n } from '@lingui/core';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import {
|
||||
BaseGraphQLError,
|
||||
@@ -9,15 +10,19 @@ import { fromWorkspaceMigrationBuilderExceptionToValidationResponseError } from
|
||||
|
||||
export const workspaceMigrationBuilderExceptionV2Formatter = (
|
||||
error: WorkspaceMigrationBuilderExceptionV2,
|
||||
i18n: I18n,
|
||||
) => {
|
||||
const { errors, summary } =
|
||||
fromWorkspaceMigrationBuilderExceptionToValidationResponseError(error);
|
||||
fromWorkspaceMigrationBuilderExceptionToValidationResponseError(
|
||||
error,
|
||||
i18n,
|
||||
);
|
||||
|
||||
throw new BaseGraphQLError(error.message, ErrorCode.BAD_USER_INPUT, {
|
||||
code: 'METADATA_VALIDATION_ERROR',
|
||||
errors,
|
||||
summary,
|
||||
message: `Validation failed for 0 object(s) and 0 field(s)`,
|
||||
userFriendlyMessage: t`Validation failed for 0 object(s) and 0 field(s)`,
|
||||
userFriendlyMessage: msg`Validation failed for 0 object(s) and 0 field(s)`,
|
||||
});
|
||||
};
|
||||
|
||||
+3
-1
@@ -1,10 +1,12 @@
|
||||
import { type MessageDescriptor } from '@lingui/core';
|
||||
|
||||
import { type FlatEntity } from 'src/engine/core-modules/common/types/flat-entity.type';
|
||||
import { type WorkspaceMigrationActionTypeV2 } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/workspace-migration-action-common-v2';
|
||||
|
||||
export type FlatEntityValidationError<TCode extends string = string> = {
|
||||
code: TCode; // should be a better extends
|
||||
message: string;
|
||||
userFriendlyMessage?: string;
|
||||
userFriendlyMessage?: MessageDescriptor;
|
||||
value?: unknown;
|
||||
};
|
||||
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
|
||||
@@ -33,7 +33,7 @@ export class FlatCronTriggerValidatorService {
|
||||
errors.push({
|
||||
code: CronTriggerExceptionCode.CRON_TRIGGER_NOT_FOUND,
|
||||
message: t`Cron trigger not found`,
|
||||
userFriendlyMessage: t`Cron trigger not found`,
|
||||
userFriendlyMessage: msg`Cron trigger not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export class FlatCronTriggerValidatorService {
|
||||
errors.push({
|
||||
code: CronTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class FlatCronTriggerValidatorService {
|
||||
errors.push({
|
||||
code: CronTriggerExceptionCode.CRON_TRIGGER_NOT_FOUND,
|
||||
message: t`Cron trigger not found`,
|
||||
userFriendlyMessage: t`Cron trigger not found`,
|
||||
userFriendlyMessage: msg`Cron trigger not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ export class FlatCronTriggerValidatorService {
|
||||
errors.push({
|
||||
code: CronTriggerExceptionCode.CRON_TRIGGER_ALREADY_EXIST,
|
||||
message: t`Cron trigger with same id already exists`,
|
||||
userFriendlyMessage: t`Cron trigger already exists`,
|
||||
userFriendlyMessage: msg`Cron trigger already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ export class FlatCronTriggerValidatorService {
|
||||
errors.push({
|
||||
code: CronTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
|
||||
@@ -35,7 +35,7 @@ export class FlatDatabaseEventTriggerValidatorService {
|
||||
errors.push({
|
||||
code: DatabaseEventTriggerExceptionCode.DATABASE_EVENT_TRIGGER_NOT_FOUND,
|
||||
message: t`Database event trigger not found`,
|
||||
userFriendlyMessage: t`Database event trigger not found`,
|
||||
userFriendlyMessage: msg`Database event trigger not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export class FlatDatabaseEventTriggerValidatorService {
|
||||
errors.push({
|
||||
code: DatabaseEventTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export class FlatDatabaseEventTriggerValidatorService {
|
||||
errors.push({
|
||||
code: DatabaseEventTriggerExceptionCode.DATABASE_EVENT_TRIGGER_NOT_FOUND,
|
||||
message: t`Database event trigger not found`,
|
||||
userFriendlyMessage: t`Database event trigger not found`,
|
||||
userFriendlyMessage: msg`Database event trigger not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ export class FlatDatabaseEventTriggerValidatorService {
|
||||
errors.push({
|
||||
code: DatabaseEventTriggerExceptionCode.DATABASE_EVENT_TRIGGER_ALREADY_EXIST,
|
||||
message: t`Database event trigger with same id already exists`,
|
||||
userFriendlyMessage: t`Database event trigger already exists`,
|
||||
userFriendlyMessage: msg`Database event trigger already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export class FlatDatabaseEventTriggerValidatorService {
|
||||
errors.push({
|
||||
code: DatabaseEventTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
@@ -62,7 +62,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
message: 'field metadata to update object metadata not found',
|
||||
userFriendlyMessage: t`Object related to field to update not found`,
|
||||
userFriendlyMessage: msg`Object related to field to update not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -72,7 +72,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.LABEL_IDENTIFIER_FIELD_METADATA_ID_NOT_FOUND,
|
||||
message: 'Label identifier field metadata id does not exist',
|
||||
userFriendlyMessage: t`Object related to updated field does not have a label identifier`,
|
||||
userFriendlyMessage: msg`Object related to updated field does not have a label identifier`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_NOT_FOUND,
|
||||
message: 'field metadata to update not found',
|
||||
userFriendlyMessage: t`Field to update not found`,
|
||||
userFriendlyMessage: msg`Field to update not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -108,7 +108,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_MUTATION_NOT_ALLOWED,
|
||||
message: `Forbidden updated properties for relation field metadata: ${relationNonEditableUpdatedProperties.join(', ')}`,
|
||||
userFriendlyMessage: t`Forbidden updated properties for relation field metadata`,
|
||||
userFriendlyMessage: msg`Forbidden updated properties for relation field metadata`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_MUTATION_NOT_ALLOWED,
|
||||
message: `Name is not synced with label.`,
|
||||
userFriendlyMessage: t`Updated field name is not synced with label`,
|
||||
userFriendlyMessage: msg`Updated field name is not synced with label`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_NOT_FOUND,
|
||||
message: 'Field metadata to delete not found',
|
||||
userFriendlyMessage: t`Field metadata to delete not found`,
|
||||
userFriendlyMessage: msg`Field metadata to delete not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -195,7 +195,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
code: FieldMetadataExceptionCode.FIELD_MUTATION_NOT_ALLOWED,
|
||||
message:
|
||||
'Cannot delete, please update the label identifier field first',
|
||||
userFriendlyMessage: t`Cannot delete, please update the label identifier field first`,
|
||||
userFriendlyMessage: msg`Cannot delete, please update the label identifier field first`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: "Standard Fields can't be deleted",
|
||||
userFriendlyMessage: t`Standard fields cannot be deleted`,
|
||||
userFriendlyMessage: msg`Standard fields cannot be deleted`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: "Active fields can't be deleted",
|
||||
userFriendlyMessage: t`Active fields cannot be deleted`,
|
||||
userFriendlyMessage: msg`Active fields cannot be deleted`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
message: 'Object metadata not found',
|
||||
userFriendlyMessage: t`Field to create related object not found`,
|
||||
userFriendlyMessage: msg`Field to create related object not found`,
|
||||
});
|
||||
} else {
|
||||
if (
|
||||
@@ -276,7 +276,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_ALREADY_EXISTS,
|
||||
message: 'Field with same id already exists in object',
|
||||
userFriendlyMessage: t`Field already exists`,
|
||||
userFriendlyMessage: msg`Field already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.FIELD_MUTATION_NOT_ALLOWED,
|
||||
message: 'Remote objects are read-only',
|
||||
userFriendlyMessage: t`Remote objects are not production ready yet`,
|
||||
userFriendlyMessage: msg`Remote objects are not production ready yet`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ export class FlatFieldMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: FieldMetadataExceptionCode.NAME_NOT_SYNCED_WITH_LABEL,
|
||||
message: `Name is not synced with label`,
|
||||
userFriendlyMessage: t`Field name is not synced with field label`,
|
||||
userFriendlyMessage: msg`Field name is not synced with field label`,
|
||||
value: flatFieldMetadataToValidate.label,
|
||||
});
|
||||
}
|
||||
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMapsExceptionCode } from 'src/engine/core-modules/common/exceptions/flat-entity-maps.exception';
|
||||
@@ -75,7 +75,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_ALREADY_EXISTS,
|
||||
message: t`Index with same id already exists`,
|
||||
userFriendlyMessage: t`Index already exists`,
|
||||
userFriendlyMessage: msg`Index already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_OBJECT_NOT_FOUND,
|
||||
message: t`Could not find index related object metadata`,
|
||||
userFriendlyMessage: t`Index related object not found`,
|
||||
userFriendlyMessage: msg`Index related object not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_ALREADY_EXISTS,
|
||||
message: t`Index with same name already exists`,
|
||||
userFriendlyMessage: t`Index with same name already exists`,
|
||||
userFriendlyMessage: msg`Index with same name already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_EMPTY_FIELDS,
|
||||
message: t`Index must have at least one field`,
|
||||
userFriendlyMessage: t`An index must contain at least one field`,
|
||||
userFriendlyMessage: msg`An index must contain at least one field`,
|
||||
});
|
||||
} else {
|
||||
flatIndexToValidate.flatIndexFieldMetadatas.forEach((flatIndexField) => {
|
||||
@@ -127,7 +127,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_FIELD_NOT_FOUND,
|
||||
message: t`Could not find index field related field metadata`,
|
||||
userFriendlyMessage: t`Field referenced in index does not exist`,
|
||||
userFriendlyMessage: msg`Field referenced in index does not exist`,
|
||||
});
|
||||
} else {
|
||||
if (
|
||||
@@ -137,7 +137,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_FIELD_WRONG_OBJECT,
|
||||
message: t`Field does not belong to the indexed object`,
|
||||
userFriendlyMessage: t`Field cannot be indexed as it belongs to a different object`,
|
||||
userFriendlyMessage: msg`Field cannot be indexed as it belongs to a different object`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_FIELD_INVALID_REFERENCE,
|
||||
message: t`Index field references incorrect index metadata`,
|
||||
userFriendlyMessage: t`Index field has an invalid reference`,
|
||||
userFriendlyMessage: msg`Index field has an invalid reference`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export class FlatIndexValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: IndexExceptionCode.INDEX_FIELD_ID_DUPLICATE,
|
||||
message: t`Index field ID already exists in another index`,
|
||||
userFriendlyMessage: t`Field ID is already used in another index`,
|
||||
userFriendlyMessage: msg`Field ID is already used in another index`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
|
||||
@@ -46,7 +46,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
message: t`Object to update not found`,
|
||||
userFriendlyMessage: t`Object to update not found`,
|
||||
userFriendlyMessage: msg`Object to update not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -75,7 +75,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: 'labelIdentifierFieldMetadataId cannot be null',
|
||||
userFriendlyMessage: t`Field label identifier is required`,
|
||||
userFriendlyMessage: msg`Field label identifier is required`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
message: t`Object to delete not found`,
|
||||
userFriendlyMessage: t`Object to delete not found`,
|
||||
userFriendlyMessage: msg`Object to delete not found`,
|
||||
});
|
||||
} else {
|
||||
validationResult.flatEntityMinimalInformation = {
|
||||
@@ -123,7 +123,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: t`Remote objects are not supported yet`,
|
||||
userFriendlyMessage: t`Remote objects are not supported yet`,
|
||||
userFriendlyMessage: msg`Remote objects are not supported yet`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: t`Standard objects cannot be deleted`,
|
||||
userFriendlyMessage: t`Standard objects cannot be deleted`,
|
||||
userFriendlyMessage: msg`Standard objects cannot be deleted`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: t`Active objects cannot be deleted`,
|
||||
userFriendlyMessage: t`Active objects cannot be deleted`,
|
||||
userFriendlyMessage: msg`Active objects cannot be deleted`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
objectValidationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: t`Object with same id already exists`,
|
||||
userFriendlyMessage: t`Object with same id already exists`,
|
||||
userFriendlyMessage: msg`Object with same id already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ export class FlatObjectMetadataValidatorService {
|
||||
objectValidationResult.errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message: t`Remote objects are not supported yet`,
|
||||
userFriendlyMessage: t`Remote objects are not supported yet`,
|
||||
userFriendlyMessage: msg`Remote objects are not supported yet`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
|
||||
@@ -33,7 +33,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.ROUTE_NOT_FOUND,
|
||||
message: t`Route not found`,
|
||||
userFriendlyMessage: t`Route not found`,
|
||||
userFriendlyMessage: msg`Route not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.ROUTE_NOT_FOUND,
|
||||
message: t`Route not found`,
|
||||
userFriendlyMessage: t`Route not found`,
|
||||
userFriendlyMessage: msg`Route not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.ROUTE_ALREADY_EXIST,
|
||||
message: t`Route with same id already exists`,
|
||||
userFriendlyMessage: t`Route already exists`,
|
||||
userFriendlyMessage: msg`Route already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.ROUTE_PATH_ALREADY_EXIST,
|
||||
message: t`Route with same path already exists`,
|
||||
userFriendlyMessage: t`Route path already exists`,
|
||||
userFriendlyMessage: msg`Route path already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ export class FlatRouteTriggerValidatorService {
|
||||
errors.push({
|
||||
code: RouteTriggerExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
|
||||
@@ -31,7 +31,7 @@ export class FlatServerlessFunctionValidatorService {
|
||||
errors.push({
|
||||
code: ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export class FlatServerlessFunctionValidatorService {
|
||||
errors.push({
|
||||
code: ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,
|
||||
message: t`Serverless function not found`,
|
||||
userFriendlyMessage: t`Serverless function not found`,
|
||||
userFriendlyMessage: msg`Serverless function not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class FlatServerlessFunctionValidatorService {
|
||||
errors.push({
|
||||
code: ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_ALREADY_EXIST,
|
||||
message: t`Serverless function with same id already exists`,
|
||||
userFriendlyMessage: t`Serverless function already exists`,
|
||||
userFriendlyMessage: msg`Serverless function already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { findFlatEntityByIdInFlatEntityMaps } from 'src/engine/core-modules/common/utils/find-flat-entity-by-id-in-flat-entity-maps.util';
|
||||
@@ -45,7 +45,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field to update not found`,
|
||||
userFriendlyMessage: t`View field to update not found`,
|
||||
userFriendlyMessage: msg`View field to update not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -66,7 +66,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field to update parent view not found`,
|
||||
userFriendlyMessage: t`View field to update parent view not found`,
|
||||
userFriendlyMessage: msg`View field to update parent view not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -81,7 +81,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field to update parent view object not found`,
|
||||
userFriendlyMessage: t`View field to update parent view object not found`,
|
||||
userFriendlyMessage: msg`View field to update parent view object not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -130,14 +130,14 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field to delete not found`,
|
||||
userFriendlyMessage: t`View field to delete not found`,
|
||||
userFriendlyMessage: msg`View field to delete not found`,
|
||||
});
|
||||
} else {
|
||||
if (!isDefined(existingFlatViewField.deletedAt)) {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field to delete has not been soft deleted`,
|
||||
userFriendlyMessage: t`View field to delete has not been soft deleted`,
|
||||
userFriendlyMessage: msg`View field to delete has not been soft deleted`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field metadata with id ${flatViewFieldId} already exists`,
|
||||
userFriendlyMessage: t`View field metadata already exists`,
|
||||
userFriendlyMessage: msg`View field metadata already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`Field metadata not found`,
|
||||
userFriendlyMessage: t`Field metadata not found`,
|
||||
userFriendlyMessage: msg`Field metadata not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View not found`,
|
||||
userFriendlyMessage: t`View not found`,
|
||||
userFriendlyMessage: msg`View not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -221,7 +221,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field with same fieldmetadataId and viewId already exists`,
|
||||
userFriendlyMessage: t`View field already exists`,
|
||||
userFriendlyMessage: msg`View field already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field related view object metadata not found`,
|
||||
userFriendlyMessage: t`View field related view object metadata not found`,
|
||||
userFriendlyMessage: msg`View field related view object metadata not found`,
|
||||
});
|
||||
|
||||
return validationResult;
|
||||
@@ -264,7 +264,7 @@ export class FlatViewFieldValidatorService {
|
||||
validationResult.errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View field position cannot be lower than label identifier view field position`,
|
||||
userFriendlyMessage: t`View field position cannot be lower than label identifier view field position`,
|
||||
userFriendlyMessage: msg`View field position cannot be lower than label identifier view field position`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FlatViewMaps } from 'src/engine/metadata-modules/flat-view/types/flat-view-maps.type';
|
||||
@@ -30,7 +30,7 @@ export class FlatViewValidatorService {
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View not found`,
|
||||
userFriendlyMessage: t`View not found`,
|
||||
userFriendlyMessage: msg`View not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ export class FlatViewValidatorService {
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View not found`,
|
||||
userFriendlyMessage: t`View not found`,
|
||||
userFriendlyMessage: msg`View not found`,
|
||||
});
|
||||
} else {
|
||||
if (!isDefined(existingFlatView.deletedAt)) {
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View to delete has not been soft deleted`,
|
||||
userFriendlyMessage: t`View to delete has not been soft deleted`,
|
||||
userFriendlyMessage: msg`View to delete has not been soft deleted`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export class FlatViewValidatorService {
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`Object metadata not found`,
|
||||
userFriendlyMessage: t`Object metadata not found`,
|
||||
userFriendlyMessage: msg`Object metadata not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ export class FlatViewValidatorService {
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`View with same id is already exists`,
|
||||
userFriendlyMessage: t`View already exists`,
|
||||
userFriendlyMessage: msg`View already exists`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { t, msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { type FlatViewField } from 'src/engine/metadata-modules/flat-view-field/types/flat-view-field.type';
|
||||
@@ -26,7 +26,7 @@ export const validateLabelIdentifierFieldMetadataIdFlatViewField = ({
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`Label identifier view field has to be in the lowest position`,
|
||||
userFriendlyMessage: t`Label identifier view field has to be in the lowest position`,
|
||||
userFriendlyMessage: msg`Label identifier view field has to be in the lowest position`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export const validateLabelIdentifierFieldMetadataIdFlatViewField = ({
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`Label identifier view field has to be visible`,
|
||||
userFriendlyMessage: t`Label identifier view field has to be visible`,
|
||||
userFriendlyMessage: msg`Label identifier view field has to be visible`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export const validateLabelIdentifierFieldMetadataIdFlatViewField = ({
|
||||
errors.push({
|
||||
code: ViewExceptionCode.INVALID_VIEW_DATA,
|
||||
message: t`Label identifier view field cannot be deleted`,
|
||||
userFriendlyMessage: t`Label identifier view field cannot be deleted`,
|
||||
userFriendlyMessage: msg`Label identifier view field cannot be deleted`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user