Files
twenty/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata.ts
Jérémy M d532f22fbb feat: migration can be applied on a specific schema & some enhancements (#2998)
* fix: remove old metadata seed files

* feat: wip standard to core relation

* fix: lint

* fix: merge

* fix: remove debug files

* feat: add feature flag for core object metadata

* fix: remove debug

* feat: always disable the standard core relation

* fix: missing feature flag

* fix: remove debug

* fix: feature flag doesn't seems to disable relation

* fix: delete .vscode folder, change this in another PR

* Update packages/twenty-server/src/workspace/workspace-sync-metadata/reflective-metadata.factory.ts

Co-authored-by: Weiko <corentin@twenty.com>

* Update packages/twenty-server/src/workspace/workspace-sync-metadata/reflective-metadata.factory.ts

Co-authored-by: Weiko <corentin@twenty.com>

* Update packages/twenty-server/src/workspace/workspace-sync-metadata/workspace-sync.metadata.service.ts

Co-authored-by: Weiko <corentin@twenty.com>

* fix: remove optional fields from metadata entities

* fix: renamed variable

* fix: put back CursorScalarType

* fix: delete test command

* fix: remove unused workspace standard migration command

* fix: drop core object metadata declaration

* fix: rename variable

* fix: drop creation of core datasource

* fix: remove feature flag

* fix: drop support of standard to core relations

* feat: add user email field on workspace-member standard object

* fix: update seed accordingly

* fix: missing remove command file

* fix: datasource label should remain nullable

* fix: better asserts

* Remove unused code

* Remove unused code

---------

Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2023-12-21 19:15:05 +01:00

176 lines
5.5 KiB
TypeScript

import { CurrencyMetadata } from 'src/metadata/field-metadata/composite-types/currency.composite-type';
import { LinkMetadata } from 'src/metadata/field-metadata/composite-types/link.composite-type';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
import { ActivityTargetObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity-target.object-metadata';
import { AttachmentObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/attachment.object-metadata';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata';
import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.object-metadata';
import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata';
import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';
@ObjectMetadata({
namePlural: 'companies',
labelSingular: 'Company',
labelPlural: 'Companies',
description: 'A company',
icon: 'IconBuildingSkyscraper',
})
export class CompanyObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Name',
description: 'The company name',
icon: 'IconBuildingSkyscraper',
})
name: string;
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Domain Name',
description:
'The company website URL. We use this url to fetch the company icon',
icon: 'IconLink',
})
@IsNullable()
domainName?: string;
@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Address',
description: 'The company address',
icon: 'IconMap',
})
@IsNullable()
address: string;
@FieldMetadata({
type: FieldMetadataType.NUMBER,
label: 'Employees',
description: 'Number of employees in the company',
icon: 'IconUsers',
})
@IsNullable()
employees: number;
@FieldMetadata({
type: FieldMetadataType.LINK,
label: 'Linkedin',
description: 'The company Linkedin account',
icon: 'IconBrandLinkedin',
})
@IsNullable()
linkedinLink: LinkMetadata;
@FieldMetadata({
type: FieldMetadataType.LINK,
label: 'X',
description: 'The company Twitter/X account',
icon: 'IconBrandX',
})
@IsNullable()
xLink: LinkMetadata;
@FieldMetadata({
type: FieldMetadataType.CURRENCY,
label: 'ARR',
description:
'Annual Recurring Revenue: The actual or estimated annual revenue of the company',
icon: 'IconMoneybag',
})
@IsNullable()
annualRecurringRevenue: CurrencyMetadata;
@FieldMetadata({
type: FieldMetadataType.BOOLEAN,
label: 'ICP',
description:
'Ideal Customer Profile: Indicates whether the company is the most suitable and valuable customer for you',
icon: 'IconTarget',
})
@IsNullable()
idealCustomerProfile: boolean;
// Relations
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'People',
description: 'People linked to the company.',
icon: 'IconUsers',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'person',
})
@IsNullable()
people: PersonObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Account Owner',
description:
'Your team member responsible for managing the company account',
icon: 'IconUserCircle',
joinColumn: 'accountOwnerId',
})
@IsNullable()
accountOwner: WorkspaceMemberObjectMetadata;
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Activities',
description: 'Activities tied to the company',
icon: 'IconCheckbox',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'activityTarget',
})
@IsNullable()
activityTargets: ActivityTargetObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Opportunities',
description: 'Opportunities linked to the company.',
icon: 'IconTargetArrow',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'opportunity',
})
@IsNullable()
opportunities: OpportunityObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Favorites',
description: 'Favorites linked to the company',
icon: 'IconHeart',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'favorite',
})
@IsNullable()
favorites: FavoriteObjectMetadata[];
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Attachments',
description: 'Attachments linked to the company.',
icon: 'IconFileImport',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'attachment',
})
@IsNullable()
attachments: AttachmentObjectMetadata[];
}