Update enums to be all caps (#12372)

- Make custom domain public (remove from lab)
- Use ALL_CAPS definition for enums
This commit is contained in:
Félix Malfait
2025-05-29 14:08:36 +02:00
committed by GitHub
parent 76d0be7f81
commit 4485e8e3db
165 changed files with 845 additions and 847 deletions
@@ -1,5 +1,5 @@
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { COUNT_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-table/record-table-footer/constants/countAggregateOperationOptions';
import { NON_STANDARD_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-table/record-table-footer/constants/nonStandardAggregateOperationsOptions';
import { PERCENT_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-table/record-table-footer/constants/percentAggregateOperationOptions';
@@ -23,43 +23,43 @@ jest.mock(
() => ({
getAvailableAggregationsFromObjectFields: jest.fn().mockReturnValue({
active: {
[AGGREGATE_OPERATIONS.countTrue]: 'countTrueActive',
[AGGREGATE_OPERATIONS.countFalse]: 'CountFalseActive',
[AggregateOperations.COUNT_TRUE]: 'countTrueActive',
[AggregateOperations.COUNT_FALSE]: 'CountFalseActive',
},
amount: {
[AGGREGATE_OPERATIONS.sum]: 'sumAmount',
[AGGREGATE_OPERATIONS.avg]: 'avgAmount',
[AGGREGATE_OPERATIONS.min]: 'minAmount',
[AGGREGATE_OPERATIONS.max]: 'maxAmount',
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AGGREGATE_OPERATIONS.countUniqueValues]: 'countUniqueValuesAmount',
[AGGREGATE_OPERATIONS.countEmpty]: 'countEmptyAmount',
[AGGREGATE_OPERATIONS.countNotEmpty]: 'countNotEmptyAmount',
[AGGREGATE_OPERATIONS.percentageEmpty]: 'percentageEmptyAmount',
[AGGREGATE_OPERATIONS.percentageNotEmpty]: 'percentageNotEmptyAmount',
[AggregateOperations.SUM]: 'sumAmount',
[AggregateOperations.AVG]: 'avgAmount',
[AggregateOperations.MIN]: 'minAmount',
[AggregateOperations.MAX]: 'maxAmount',
[AggregateOperations.COUNT]: 'totalCount',
[AggregateOperations.COUNT_UNIQUE_VALUES]: 'countUniqueValuesAmount',
[AggregateOperations.COUNT_EMPTY]: 'countEmptyAmount',
[AggregateOperations.COUNT_NOT_EMPTY]: 'countNotEmptyAmount',
[AggregateOperations.PERCENTAGE_EMPTY]: 'percentageEmptyAmount',
[AggregateOperations.PERCENTAGE_NOT_EMPTY]: 'percentageNotEmptyAmount',
},
price: {
[AGGREGATE_OPERATIONS.sum]: 'sumPriceAmountMicros',
[AGGREGATE_OPERATIONS.avg]: 'avgPriceAmountMicros',
[AGGREGATE_OPERATIONS.min]: 'minPriceAmountMicros',
[AGGREGATE_OPERATIONS.max]: 'maxPriceAmountMicros',
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AGGREGATE_OPERATIONS.countUniqueValues]:
[AggregateOperations.SUM]: 'sumPriceAmountMicros',
[AggregateOperations.AVG]: 'avgPriceAmountMicros',
[AggregateOperations.MIN]: 'minPriceAmountMicros',
[AggregateOperations.MAX]: 'maxPriceAmountMicros',
[AggregateOperations.COUNT]: 'totalCount',
[AggregateOperations.COUNT_UNIQUE_VALUES]:
'countUniqueValuesPriceAmountMicros',
[AGGREGATE_OPERATIONS.countEmpty]: 'countEmptyPriceAmountMicros',
[AGGREGATE_OPERATIONS.countNotEmpty]: 'countNotEmptyPriceAmountMicros',
[AGGREGATE_OPERATIONS.percentageEmpty]:
[AggregateOperations.COUNT_EMPTY]: 'countEmptyPriceAmountMicros',
[AggregateOperations.COUNT_NOT_EMPTY]: 'countNotEmptyPriceAmountMicros',
[AggregateOperations.PERCENTAGE_EMPTY]:
'percentageEmptyPriceAmountMicros',
[AGGREGATE_OPERATIONS.percentageNotEmpty]:
[AggregateOperations.PERCENTAGE_NOT_EMPTY]:
'percentageNotEmptyPriceAmountMicros',
},
name: {
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AGGREGATE_OPERATIONS.countUniqueValues]: 'countUniqueValuesName',
[AGGREGATE_OPERATIONS.countEmpty]: 'countEmptyName',
[AGGREGATE_OPERATIONS.countNotEmpty]: 'countNotEmptyName',
[AGGREGATE_OPERATIONS.percentageEmpty]: 'percentageEmptyName',
[AGGREGATE_OPERATIONS.percentageNotEmpty]: 'percentageNotEmptyName',
[AggregateOperations.COUNT]: 'totalCount',
[AggregateOperations.COUNT_UNIQUE_VALUES]: 'countUniqueValuesName',
[AggregateOperations.COUNT_EMPTY]: 'countEmptyName',
[AggregateOperations.COUNT_NOT_EMPTY]: 'countNotEmptyName',
[AggregateOperations.PERCENTAGE_EMPTY]: 'percentageEmptyName',
[AggregateOperations.PERCENTAGE_NOT_EMPTY]: 'percentageNotEmptyName',
},
}),
}),
@@ -1,4 +1,4 @@
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { FIELD_TYPES_AVAILABLE_FOR_NON_STANDARD_AGGREGATE_OPERATION } from '@/object-record/record-table/constants/FieldTypesAvailableForNonStandardAggregateOperation';
import { COUNT_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-table/record-table-footer/constants/countAggregateOperationOptions';
import { PERCENT_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-table/record-table-footer/constants/percentAggregateOperationOptions';
@@ -10,7 +10,7 @@ describe('initializeAvailableFieldsForAggregateOperationMap', () => {
const result = initializeAvailableFieldsForAggregateOperationMap(
Object.keys(
FIELD_TYPES_AVAILABLE_FOR_NON_STANDARD_AGGREGATE_OPERATION,
) as AGGREGATE_OPERATIONS[],
) as AggregateOperations[],
);
expect(Object.keys(result)).toEqual(
@@ -25,11 +25,11 @@ describe('initializeAvailableFieldsForAggregateOperationMap', () => {
const result = initializeAvailableFieldsForAggregateOperationMap(
Object.keys(
FIELD_TYPES_AVAILABLE_FOR_NON_STANDARD_AGGREGATE_OPERATION,
) as AGGREGATE_OPERATIONS[],
) as AggregateOperations[],
);
expect(
result[
AGGREGATE_OPERATIONS.count as AggregateOperationsOmittingStandardOperations
AggregateOperations.COUNT as AggregateOperationsOmittingStandardOperations
],
).toBeUndefined();
});
@@ -38,21 +38,21 @@ describe('initializeAvailableFieldsForAggregateOperationMap', () => {
const result = initializeAvailableFieldsForAggregateOperationMap(
COUNT_AGGREGATE_OPERATION_OPTIONS,
);
expect(result[AGGREGATE_OPERATIONS.count]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.countEmpty]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.countNotEmpty]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.countUniqueValues]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.min]).toBeUndefined();
expect(result[AGGREGATE_OPERATIONS.percentageEmpty]).toBeUndefined();
expect(result[AggregateOperations.COUNT]).toEqual([]);
expect(result[AggregateOperations.COUNT_EMPTY]).toEqual([]);
expect(result[AggregateOperations.COUNT_NOT_EMPTY]).toEqual([]);
expect(result[AggregateOperations.COUNT_UNIQUE_VALUES]).toEqual([]);
expect(result[AggregateOperations.MIN]).toBeUndefined();
expect(result[AggregateOperations.PERCENTAGE_EMPTY]).toBeUndefined();
});
it('should include percent operation when called with count aggregate operations', () => {
const result = initializeAvailableFieldsForAggregateOperationMap(
PERCENT_AGGREGATE_OPERATION_OPTIONS,
);
expect(result[AGGREGATE_OPERATIONS.percentageEmpty]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.percentageNotEmpty]).toEqual([]);
expect(result[AGGREGATE_OPERATIONS.count]).toBeUndefined();
expect(result[AGGREGATE_OPERATIONS.min]).toBeUndefined();
expect(result[AggregateOperations.PERCENTAGE_EMPTY]).toEqual([]);
expect(result[AggregateOperations.PERCENTAGE_NOT_EMPTY]).toEqual([]);
expect(result[AggregateOperations.COUNT]).toBeUndefined();
expect(result[AggregateOperations.MIN]).toBeUndefined();
});
});
@@ -1,4 +1,4 @@
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { AggregateOperationsOmittingStandardOperations } from '@/object-record/types/AggregateOperationsOmittingStandardOperations';
import { isFieldTypeValidForAggregateOperation } from '@/object-record/utils/isFieldTypeValidForAggregateOperation';
import { FieldMetadataType } from '~/generated/graphql';
@@ -8,14 +8,14 @@ describe('isFieldTypeValidForAggregateOperation', () => {
expect(
isFieldTypeValidForAggregateOperation(
FieldMetadataType.NUMBER,
AGGREGATE_OPERATIONS.sum,
AggregateOperations.SUM,
),
).toBe(true);
expect(
isFieldTypeValidForAggregateOperation(
FieldMetadataType.CURRENCY,
AGGREGATE_OPERATIONS.min,
AggregateOperations.MIN,
),
).toBe(true);
});
@@ -24,14 +24,14 @@ describe('isFieldTypeValidForAggregateOperation', () => {
expect(
isFieldTypeValidForAggregateOperation(
FieldMetadataType.TEXT,
AGGREGATE_OPERATIONS.avg,
AggregateOperations.AVG,
),
).toBe(false);
expect(
isFieldTypeValidForAggregateOperation(
FieldMetadataType.BOOLEAN,
AGGREGATE_OPERATIONS.max,
AggregateOperations.MAX,
),
).toBe(false);
});
@@ -39,10 +39,10 @@ describe('isFieldTypeValidForAggregateOperation', () => {
it('should handle all aggregate operations', () => {
const numericField = FieldMetadataType.NUMBER;
const operations = [
AGGREGATE_OPERATIONS.min,
AGGREGATE_OPERATIONS.max,
AGGREGATE_OPERATIONS.avg,
AGGREGATE_OPERATIONS.sum,
AggregateOperations.MIN,
AggregateOperations.MAX,
AggregateOperations.AVG,
AggregateOperations.SUM,
];
operations.forEach((operation) => {
@@ -1,19 +1,19 @@
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { DATE_AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/DateAggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { DateAggregateOperations } from '@/object-record/record-table/constants/DateAggregateOperations';
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { isFieldMetadataDateKind } from 'twenty-shared/utils';
import { FieldMetadataType } from '~/generated-metadata/graphql';
export const convertAggregateOperationToExtendedAggregateOperation = (
aggregateOperation: AGGREGATE_OPERATIONS,
aggregateOperation: AggregateOperations,
fieldType?: FieldMetadataType,
): ExtendedAggregateOperations => {
if (isFieldMetadataDateKind(fieldType) === true) {
if (aggregateOperation === AGGREGATE_OPERATIONS.min) {
return DATE_AGGREGATE_OPERATIONS.earliest;
if (aggregateOperation === AggregateOperations.MIN) {
return DateAggregateOperations.EARLIEST;
}
if (aggregateOperation === AGGREGATE_OPERATIONS.max) {
return DATE_AGGREGATE_OPERATIONS.latest;
if (aggregateOperation === AggregateOperations.MAX) {
return DateAggregateOperations.LATEST;
}
}
return aggregateOperation;
@@ -1,16 +1,16 @@
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { DATE_AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/DateAggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { DateAggregateOperations } from '@/object-record/record-table/constants/DateAggregateOperations';
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
export const convertExtendedAggregateOperationToAggregateOperation = (
extendedAggregateOperation: ExtendedAggregateOperations | null,
) => {
if (extendedAggregateOperation === DATE_AGGREGATE_OPERATIONS.earliest) {
return AGGREGATE_OPERATIONS.min;
if (extendedAggregateOperation === DateAggregateOperations.EARLIEST) {
return AggregateOperations.MIN;
}
if (extendedAggregateOperation === DATE_AGGREGATE_OPERATIONS.latest) {
return AGGREGATE_OPERATIONS.max;
if (extendedAggregateOperation === DateAggregateOperations.LATEST) {
return AggregateOperations.MAX;
}
return extendedAggregateOperation;
};
@@ -1,10 +1,10 @@
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { DATE_AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/DateAggregateOperations';
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
import { DateAggregateOperations } from '@/object-record/record-table/constants/DateAggregateOperations';
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { capitalize, isFieldMetadataDateKind } from 'twenty-shared/utils';
import { FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION } from 'twenty-shared/constants';
import { capitalize, isFieldMetadataDateKind } from 'twenty-shared/utils';
import { FieldMetadataType } from '~/generated-metadata/graphql';
type NameForAggregation = {
[T in ExtendedAggregateOperations]?: string;
@@ -25,53 +25,53 @@ export const getAvailableAggregationsFromObjectFields = (
if (field.type === FieldMetadataType.RELATION) {
acc[field.name] = {
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AggregateOperations.COUNT]: 'totalCount',
};
return acc;
}
acc[field.name] = {
[AGGREGATE_OPERATIONS.countUniqueValues]: `countUniqueValues${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.countEmpty]: `countEmpty${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.countNotEmpty]: `countNotEmpty${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.percentageEmpty]: `percentageEmpty${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.percentageNotEmpty]: `percentageNotEmpty${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AggregateOperations.COUNT_UNIQUE_VALUES]: `countUniqueValues${capitalize(field.name)}`,
[AggregateOperations.COUNT_EMPTY]: `countEmpty${capitalize(field.name)}`,
[AggregateOperations.COUNT_NOT_EMPTY]: `countNotEmpty${capitalize(field.name)}`,
[AggregateOperations.PERCENTAGE_EMPTY]: `percentageEmpty${capitalize(field.name)}`,
[AggregateOperations.PERCENTAGE_NOT_EMPTY]: `percentageNotEmpty${capitalize(field.name)}`,
[AggregateOperations.COUNT]: 'totalCount',
};
if (field.type === FieldMetadataType.NUMBER) {
acc[field.name] = {
...acc[field.name],
[AGGREGATE_OPERATIONS.min]: `min${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.max]: `max${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.avg]: `avg${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.sum]: `sum${capitalize(field.name)}`,
[AggregateOperations.MIN]: `min${capitalize(field.name)}`,
[AggregateOperations.MAX]: `max${capitalize(field.name)}`,
[AggregateOperations.AVG]: `avg${capitalize(field.name)}`,
[AggregateOperations.SUM]: `sum${capitalize(field.name)}`,
};
}
if (field.type === FieldMetadataType.CURRENCY) {
acc[field.name] = {
...acc[field.name],
[AGGREGATE_OPERATIONS.min]: `min${capitalize(field.name)}AmountMicros`,
[AGGREGATE_OPERATIONS.max]: `max${capitalize(field.name)}AmountMicros`,
[AGGREGATE_OPERATIONS.avg]: `avg${capitalize(field.name)}AmountMicros`,
[AGGREGATE_OPERATIONS.sum]: `sum${capitalize(field.name)}AmountMicros`,
[AggregateOperations.MIN]: `min${capitalize(field.name)}AmountMicros`,
[AggregateOperations.MAX]: `max${capitalize(field.name)}AmountMicros`,
[AggregateOperations.AVG]: `avg${capitalize(field.name)}AmountMicros`,
[AggregateOperations.SUM]: `sum${capitalize(field.name)}AmountMicros`,
};
}
if (field.type === FieldMetadataType.BOOLEAN) {
acc[field.name] = {
...acc[field.name],
[AGGREGATE_OPERATIONS.countTrue]: `countTrue${capitalize(field.name)}`,
[AGGREGATE_OPERATIONS.countFalse]: `countFalse${capitalize(field.name)}`,
[AggregateOperations.COUNT_TRUE]: `countTrue${capitalize(field.name)}`,
[AggregateOperations.COUNT_FALSE]: `countFalse${capitalize(field.name)}`,
};
}
if (isFieldMetadataDateKind(field.type) === true) {
acc[field.name] = {
...acc[field.name],
[DATE_AGGREGATE_OPERATIONS.earliest]: `min${capitalize(field.name)}`,
[DATE_AGGREGATE_OPERATIONS.latest]: `max${capitalize(field.name)}`,
[DateAggregateOperations.EARLIEST]: `min${capitalize(field.name)}`,
[DateAggregateOperations.LATEST]: `max${capitalize(field.name)}`,
};
}
@@ -83,7 +83,7 @@ export const getAvailableAggregationsFromObjectFields = (
},
{
[FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION]: {
[AGGREGATE_OPERATIONS.count]: 'totalCount',
[AggregateOperations.COUNT]: 'totalCount',
},
},
);