Fixes https://github.com/twentyhq/twenty/issues/8810 Fixes https://github.com/twentyhq/twenty/issues/5268 Fixes https://github.com/twentyhq/twenty/issues/8971 - Fixing Task/Note creation not sending position during creation - Adding a command to backfill position being null, using existing backfill command. - Removed unused backfill job. - Updated workspace entities to set position non-nullable and set a default value to make it non-required on the API - Updated position factory to set a default position for all objects having a POSITION field instead of only company/people - Moved the try/catch in each resolver factory calling GraphqlQueryRunnerException handler, makes more sense to call it in the actual graphql-query-runner and removing some duplicate codes - Adding validations for input in QueryRunnerArgs factories - Allow sync-metadata to override and sync defaultValues for certain field types (that can't be updated by users) - Removing health-check from sync-metadata command during force mode to improve performances
143 lines
4.9 KiB
TypeScript
143 lines
4.9 KiB
TypeScript
import { registerEnumType } from '@nestjs/graphql';
|
|
|
|
import { Relation } from 'typeorm';
|
|
|
|
import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
|
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
|
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
|
import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
|
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
|
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
|
|
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
|
import { WorkspaceGate } from 'src/engine/twenty-orm/decorators/workspace-gate.decorator';
|
|
import { WorkspaceIndex } from 'src/engine/twenty-orm/decorators/workspace-index.decorator';
|
|
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
|
|
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
|
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
|
|
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
|
|
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
|
import { VIEW_FIELD_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
|
import { STANDARD_OBJECT_ICONS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-icons';
|
|
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
|
import { ViewWorkspaceEntity } from 'src/modules/view/standard-objects/view.workspace-entity';
|
|
|
|
registerEnumType(AGGREGATE_OPERATIONS, {
|
|
name: 'AggregateOperations',
|
|
});
|
|
|
|
@WorkspaceEntity({
|
|
standardId: STANDARD_OBJECT_IDS.viewField,
|
|
namePlural: 'viewFields',
|
|
labelSingular: 'View Field',
|
|
labelPlural: 'View Fields',
|
|
description: '(System) View Fields',
|
|
icon: STANDARD_OBJECT_ICONS.viewField,
|
|
})
|
|
@WorkspaceIsNotAuditLogged()
|
|
@WorkspaceIsSystem()
|
|
@WorkspaceIndex(['fieldMetadataId', 'viewId'], {
|
|
isUnique: true,
|
|
indexWhereClause: '"deletedAt" IS NULL',
|
|
})
|
|
export class ViewFieldWorkspaceEntity extends BaseWorkspaceEntity {
|
|
@WorkspaceField({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.fieldMetadataId,
|
|
type: FieldMetadataType.UUID,
|
|
label: 'Field Metadata Id',
|
|
description: 'View Field target field',
|
|
icon: 'IconTag',
|
|
})
|
|
fieldMetadataId: string;
|
|
|
|
@WorkspaceField({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.isVisible,
|
|
type: FieldMetadataType.BOOLEAN,
|
|
label: 'Visible',
|
|
description: 'View Field visibility',
|
|
icon: 'IconEye',
|
|
defaultValue: true,
|
|
})
|
|
isVisible: boolean;
|
|
|
|
@WorkspaceField({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.size,
|
|
type: FieldMetadataType.NUMBER,
|
|
label: 'Size',
|
|
description: 'View Field size',
|
|
icon: 'IconEye',
|
|
defaultValue: 0,
|
|
})
|
|
size: number;
|
|
|
|
@WorkspaceField({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.position,
|
|
type: FieldMetadataType.NUMBER,
|
|
label: 'Position',
|
|
description: 'View Field position',
|
|
icon: 'IconList',
|
|
defaultValue: 0,
|
|
})
|
|
@WorkspaceIsSystem()
|
|
position: number;
|
|
|
|
@WorkspaceRelation({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.view,
|
|
type: RelationMetadataType.MANY_TO_ONE,
|
|
label: 'View',
|
|
description: 'View Field related view',
|
|
icon: 'IconLayoutCollage',
|
|
inverseSideTarget: () => ViewWorkspaceEntity,
|
|
inverseSideFieldKey: 'viewFields',
|
|
})
|
|
view: Relation<ViewWorkspaceEntity>;
|
|
|
|
@WorkspaceField({
|
|
standardId: VIEW_FIELD_STANDARD_FIELD_IDS.aggregateOperation,
|
|
type: FieldMetadataType.SELECT,
|
|
label: 'Aggregate operation',
|
|
description: 'Optional aggregate operation',
|
|
icon: 'IconCalculator',
|
|
options: [
|
|
{
|
|
value: AGGREGATE_OPERATIONS.avg,
|
|
label: 'Average',
|
|
position: 0,
|
|
color: 'red',
|
|
},
|
|
{
|
|
value: AGGREGATE_OPERATIONS.count,
|
|
label: 'Count',
|
|
position: 1,
|
|
color: 'purple',
|
|
},
|
|
{
|
|
value: AGGREGATE_OPERATIONS.max,
|
|
label: 'Maximum',
|
|
position: 2,
|
|
color: 'sky',
|
|
},
|
|
{
|
|
value: AGGREGATE_OPERATIONS.min,
|
|
label: 'Minimum',
|
|
position: 3,
|
|
color: 'turquoise',
|
|
},
|
|
{
|
|
value: AGGREGATE_OPERATIONS.sum,
|
|
label: 'Sum',
|
|
position: 4,
|
|
color: 'yellow',
|
|
},
|
|
],
|
|
defaultValue: null,
|
|
})
|
|
@WorkspaceGate({
|
|
featureFlag: FeatureFlagKey.IsAggregateQueryEnabled,
|
|
})
|
|
@WorkspaceIsNullable()
|
|
aggregateOperation?: AGGREGATE_OPERATIONS | null;
|
|
|
|
@WorkspaceJoinColumn('view')
|
|
viewId: string;
|
|
}
|