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:
@ -44,7 +44,7 @@ export class GraphQLConfigService
|
||||
|
||||
createGqlOptions(): YogaDriverConfig {
|
||||
const isDebugMode =
|
||||
this.twentyConfigService.get('NODE_ENV') === NodeEnvironment.development;
|
||||
this.twentyConfigService.get('NODE_ENV') === NodeEnvironment.DEVELOPMENT;
|
||||
const plugins = [
|
||||
useThrottler({
|
||||
ttl: this.twentyConfigService.get('API_RATE_LIMITING_TTL'),
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
export enum AGGREGATE_OPERATIONS {
|
||||
min = 'MIN',
|
||||
max = 'MAX',
|
||||
avg = 'AVG',
|
||||
sum = 'SUM',
|
||||
count = 'COUNT',
|
||||
countUniqueValues = 'COUNT_UNIQUE_VALUES',
|
||||
countEmpty = 'COUNT_EMPTY',
|
||||
countNotEmpty = 'COUNT_NOT_EMPTY',
|
||||
countTrue = 'COUNT_TRUE',
|
||||
countFalse = 'COUNT_FALSE',
|
||||
percentageEmpty = 'PERCENTAGE_EMPTY',
|
||||
percentageNotEmpty = 'PERCENTAGE_NOT_EMPTY',
|
||||
export enum AggregateOperations {
|
||||
MIN = 'MIN',
|
||||
MAX = 'MAX',
|
||||
AVG = 'AVG',
|
||||
SUM = 'SUM',
|
||||
COUNT = 'COUNT',
|
||||
COUNT_UNIQUE_VALUES = 'COUNT_UNIQUE_VALUES',
|
||||
COUNT_EMPTY = 'COUNT_EMPTY',
|
||||
COUNT_NOT_EMPTY = 'COUNT_NOT_EMPTY',
|
||||
COUNT_TRUE = 'COUNT_TRUE',
|
||||
COUNT_FALSE = 'COUNT_FALSE',
|
||||
PERCENTAGE_EMPTY = 'PERCENTAGE_EMPTY',
|
||||
PERCENTAGE_NOT_EMPTY = 'PERCENTAGE_NOT_EMPTY',
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
export enum DatabaseEventAction {
|
||||
CREATED = 'created',
|
||||
UPDATED = 'updated',
|
||||
DELETED = 'deleted',
|
||||
DESTROYED = 'destroyed',
|
||||
RESTORED = 'restored',
|
||||
CREATED = 'CREATED',
|
||||
UPDATED = 'UPDATED',
|
||||
DELETED = 'DELETED',
|
||||
DESTROYED = 'DESTROYED',
|
||||
RESTORED = 'RESTORED',
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
|
||||
import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { AggregationField } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-available-aggregations-from-object-fields.util';
|
||||
import { formatColumnNamesFromCompositeFieldAndSubfields } from 'src/engine/twenty-orm/utils/format-column-names-from-composite-field-and-subfield.util';
|
||||
|
||||
@ -44,7 +44,7 @@ export class ProcessAggregateHelper {
|
||||
: columnNames[0];
|
||||
|
||||
if (
|
||||
!Object.values(AGGREGATE_OPERATIONS).includes(
|
||||
!Object.values(AggregateOperations).includes(
|
||||
aggregatedField.aggregateOperation,
|
||||
)
|
||||
) {
|
||||
@ -58,44 +58,44 @@ export class ProcessAggregateHelper {
|
||||
const columnExpression = `NULLIF(CONCAT(${concatenatedColumns}), '')`;
|
||||
|
||||
switch (aggregatedField.aggregateOperation) {
|
||||
case AGGREGATE_OPERATIONS.countEmpty:
|
||||
case AggregateOperations.COUNT_EMPTY:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(*) - COUNT(${columnExpression}) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
case AGGREGATE_OPERATIONS.countNotEmpty:
|
||||
case AggregateOperations.COUNT_NOT_EMPTY:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(${columnExpression}) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
case AGGREGATE_OPERATIONS.countUniqueValues:
|
||||
case AggregateOperations.COUNT_UNIQUE_VALUES:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(DISTINCT ${columnExpression}) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
case AGGREGATE_OPERATIONS.percentageEmpty:
|
||||
case AggregateOperations.PERCENTAGE_EMPTY:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE CAST(((COUNT(*) - COUNT(${columnExpression})::decimal) / COUNT(*)) AS DECIMAL) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
case AGGREGATE_OPERATIONS.percentageNotEmpty:
|
||||
case AggregateOperations.PERCENTAGE_NOT_EMPTY:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE CAST((COUNT(${columnExpression})::decimal / COUNT(*)) AS DECIMAL) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
case AGGREGATE_OPERATIONS.countTrue:
|
||||
case AggregateOperations.COUNT_TRUE:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(CASE WHEN ${columnExpression}::boolean = TRUE THEN 1 ELSE NULL END) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
);
|
||||
break;
|
||||
|
||||
case AGGREGATE_OPERATIONS.countFalse:
|
||||
case AggregateOperations.COUNT_FALSE:
|
||||
queryBuilder.addSelect(
|
||||
`CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(CASE WHEN ${columnExpression}::boolean = FALSE THEN 1 ELSE NULL END) END`,
|
||||
`${aggregatedFieldName}`,
|
||||
|
||||
@ -94,7 +94,7 @@ export abstract class GraphqlQueryBaseResolverService<
|
||||
const featureFlagsMap = workspaceDataSource.featureFlagMap;
|
||||
|
||||
const isPermissionsV2Enabled =
|
||||
featureFlagsMap[FeatureFlagKey.IsPermissionsV2Enabled];
|
||||
featureFlagsMap[FeatureFlagKey.IS_PERMISSIONS_V2_ENABLED];
|
||||
|
||||
if (objectMetadataItemWithFieldMaps.isSystem === true) {
|
||||
await this.validateSystemObjectPermissionsOrThrow(options);
|
||||
|
||||
@ -49,7 +49,7 @@ export const metadataModuleFactory = async (
|
||||
}),
|
||||
};
|
||||
|
||||
if (twentyConfigService.get('NODE_ENV') === NodeEnvironment.development) {
|
||||
if (twentyConfigService.get('NODE_ENV') === NodeEnvironment.DEVELOPMENT) {
|
||||
config.renderGraphiQL = () => {
|
||||
return renderApolloPlayground({ path: 'metadata' });
|
||||
};
|
||||
|
||||
@ -29,7 +29,7 @@ export function WorkspaceQueryHook(
|
||||
|
||||
// Default to PreHook
|
||||
if (!options.type) {
|
||||
options.type = WorkspaceQueryHookType.PreHook;
|
||||
options.type = WorkspaceQueryHookType.PRE_HOOK;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
|
||||
@ -14,8 +14,8 @@ import {
|
||||
} from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
|
||||
|
||||
export enum WorkspaceQueryHookType {
|
||||
PreHook = 'PreHook',
|
||||
PostHook = 'PostHook',
|
||||
PRE_HOOK = 'PRE_HOOK',
|
||||
POST_HOOK = 'POST_HOOK',
|
||||
}
|
||||
|
||||
export type WorkspacePreQueryHookPayload<T> = T extends 'createMany'
|
||||
|
||||
@ -201,7 +201,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
|
||||
isRequestScoped: boolean,
|
||||
) {
|
||||
switch (type) {
|
||||
case WorkspaceQueryHookType.PreHook:
|
||||
case WorkspaceQueryHookType.PRE_HOOK:
|
||||
this.workspaceQueryHookStorage.registerWorkspaceQueryPreHookInstance(
|
||||
key,
|
||||
{
|
||||
@ -211,7 +211,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
|
||||
},
|
||||
);
|
||||
break;
|
||||
case WorkspaceQueryHookType.PostHook:
|
||||
case WorkspaceQueryHookType.POST_HOOK:
|
||||
this.workspaceQueryHookStorage.registerWorkspacePostQueryHookInstance(
|
||||
key,
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { GraphQLISODateTime } from '@nestjs/graphql';
|
||||
|
||||
import { GraphQLFloat, GraphQLInt, GraphQLScalarType } from 'graphql';
|
||||
import { capitalize, isFieldMetadataDateKind } from 'twenty-shared/utils';
|
||||
import { FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION } from 'twenty-shared/constants';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { capitalize, isFieldMetadataDateKind } from 'twenty-shared/utils';
|
||||
|
||||
import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface';
|
||||
|
||||
import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { getSubfieldsForAggregateOperation } from 'src/engine/twenty-orm/utils/get-subfields-for-aggregate-operation.util';
|
||||
|
||||
export type AggregationField = {
|
||||
@ -17,7 +17,7 @@ export type AggregationField = {
|
||||
fromFieldType: FieldMetadataType;
|
||||
fromSubFields?: string[];
|
||||
subFieldForNumericOperation?: string;
|
||||
aggregateOperation: AGGREGATE_OPERATIONS;
|
||||
aggregateOperation: AggregateOperations;
|
||||
};
|
||||
|
||||
export const getAvailableAggregationsFromObjectFields = (
|
||||
@ -37,7 +37,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
fromSubFields,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.countUniqueValues,
|
||||
aggregateOperation: AggregateOperations.COUNT_UNIQUE_VALUES,
|
||||
};
|
||||
|
||||
acc[`countEmpty${capitalize(field.name)}`] = {
|
||||
@ -46,7 +46,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
fromSubFields,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.countEmpty,
|
||||
aggregateOperation: AggregateOperations.COUNT_EMPTY,
|
||||
};
|
||||
|
||||
acc[`countNotEmpty${capitalize(field.name)}`] = {
|
||||
@ -55,7 +55,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
fromSubFields,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.countNotEmpty,
|
||||
aggregateOperation: AggregateOperations.COUNT_NOT_EMPTY,
|
||||
};
|
||||
|
||||
acc[`percentageEmpty${capitalize(field.name)}`] = {
|
||||
@ -64,7 +64,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
fromSubFields,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.percentageEmpty,
|
||||
aggregateOperation: AggregateOperations.PERCENTAGE_EMPTY,
|
||||
};
|
||||
|
||||
acc[`percentageNotEmpty${capitalize(field.name)}`] = {
|
||||
@ -73,7 +73,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
fromSubFields,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.percentageNotEmpty,
|
||||
aggregateOperation: AggregateOperations.PERCENTAGE_NOT_EMPTY,
|
||||
};
|
||||
|
||||
if (isFieldMetadataDateKind(field.type)) {
|
||||
@ -82,7 +82,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Earliest date contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.min,
|
||||
aggregateOperation: AggregateOperations.MIN,
|
||||
};
|
||||
|
||||
acc[`max${capitalize(field.name)}`] = {
|
||||
@ -90,7 +90,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Latest date contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.max,
|
||||
aggregateOperation: AggregateOperations.MAX,
|
||||
};
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Count of true values in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.countTrue,
|
||||
aggregateOperation: AggregateOperations.COUNT_TRUE,
|
||||
};
|
||||
|
||||
acc[`countFalse${capitalize(field.name)}`] = {
|
||||
@ -109,7 +109,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Count of false values in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.countFalse,
|
||||
aggregateOperation: AggregateOperations.COUNT_FALSE,
|
||||
};
|
||||
break;
|
||||
|
||||
@ -119,7 +119,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Minimum amount contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.min,
|
||||
aggregateOperation: AggregateOperations.MIN,
|
||||
};
|
||||
|
||||
acc[`max${capitalize(field.name)}`] = {
|
||||
@ -127,7 +127,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Maximum amount contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.max,
|
||||
aggregateOperation: AggregateOperations.MAX,
|
||||
};
|
||||
|
||||
acc[`avg${capitalize(field.name)}`] = {
|
||||
@ -135,7 +135,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Average amount contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.avg,
|
||||
aggregateOperation: AggregateOperations.AVG,
|
||||
};
|
||||
|
||||
acc[`sum${capitalize(field.name)}`] = {
|
||||
@ -143,7 +143,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Sum of amounts contained in the field ${field.name}`,
|
||||
fromField: field.name,
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.sum,
|
||||
aggregateOperation: AggregateOperations.SUM,
|
||||
};
|
||||
break;
|
||||
case FieldMetadataType.CURRENCY:
|
||||
@ -154,7 +154,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromSubFields: getSubfieldsForAggregateOperation(field.type),
|
||||
subFieldForNumericOperation: 'amountMicros',
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.min,
|
||||
aggregateOperation: AggregateOperations.MIN,
|
||||
};
|
||||
|
||||
acc[`max${capitalize(field.name)}AmountMicros`] = {
|
||||
@ -163,7 +163,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromSubFields: getSubfieldsForAggregateOperation(field.type),
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.max,
|
||||
aggregateOperation: AggregateOperations.MAX,
|
||||
};
|
||||
|
||||
acc[`sum${capitalize(field.name)}AmountMicros`] = {
|
||||
@ -172,7 +172,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromSubFields: getSubfieldsForAggregateOperation(field.type),
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.sum,
|
||||
aggregateOperation: AggregateOperations.SUM,
|
||||
};
|
||||
|
||||
acc[`avg${capitalize(field.name)}AmountMicros`] = {
|
||||
@ -181,7 +181,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
fromField: field.name,
|
||||
fromSubFields: getSubfieldsForAggregateOperation(field.type),
|
||||
fromFieldType: field.type,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.avg,
|
||||
aggregateOperation: AggregateOperations.AVG,
|
||||
};
|
||||
break;
|
||||
}
|
||||
@ -194,7 +194,7 @@ export const getAvailableAggregationsFromObjectFields = (
|
||||
description: `Total number of records in the connection`,
|
||||
fromField: FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION,
|
||||
fromFieldType: FieldMetadataType.UUID,
|
||||
aggregateOperation: AGGREGATE_OPERATIONS.count,
|
||||
aggregateOperation: AggregateOperations.COUNT,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user