Improve Metadata sync setup (#2874)
* Improve Metadata sync setup * add missing IsNullable() * add composite fields types
This commit is contained in:
@ -47,3 +47,8 @@ export const currencyObjectDefinition = {
|
||||
fromRelations: [],
|
||||
toRelations: [],
|
||||
} satisfies ObjectMetadataInterface;
|
||||
|
||||
export type CurrencyMetadata = {
|
||||
amountMicros: number;
|
||||
currencyCode: string;
|
||||
}
|
||||
@ -43,3 +43,8 @@ export const fullNameObjectDefinition = {
|
||||
fromRelations: [],
|
||||
toRelations: [],
|
||||
} satisfies ObjectMetadataInterface;
|
||||
|
||||
export type FullNameMetadata = {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
@ -43,3 +43,8 @@ export const linkObjectDefinition = {
|
||||
fromRelations: [],
|
||||
toRelations: [],
|
||||
} satisfies ObjectMetadataInterface;
|
||||
|
||||
export type LinkMetadata = {
|
||||
label: string;
|
||||
url: string;
|
||||
}
|
||||
@ -16,7 +16,7 @@ import { fullNameFields } from 'src/metadata/field-metadata/composite-types/full
|
||||
import { currencyFields } from 'src/metadata/field-metadata/composite-types/currency.composite-type';
|
||||
import { linkFields } from 'src/metadata/field-metadata/composite-types/link.composite-type';
|
||||
|
||||
type CompositeFieldSplitterFunction = (
|
||||
type CompositeFieldsDefinitionFunction = (
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
) => FieldMetadataInterface[];
|
||||
|
||||
@ -32,7 +32,7 @@ export class WorkspaceMigrationFactory {
|
||||
>;
|
||||
private compositeDefinitions = new Map<
|
||||
string,
|
||||
CompositeFieldSplitterFunction
|
||||
CompositeFieldsDefinitionFunction
|
||||
>();
|
||||
|
||||
constructor(
|
||||
@ -90,7 +90,7 @@ export class WorkspaceMigrationFactory {
|
||||
],
|
||||
]);
|
||||
|
||||
this.compositeDefinitions = new Map<string, CompositeFieldSplitterFunction>(
|
||||
this.compositeDefinitions = new Map<string, CompositeFieldsDefinitionFunction>(
|
||||
[
|
||||
[FieldMetadataType.LINK, linkFields],
|
||||
[FieldMetadataType.CURRENCY, currencyFields],
|
||||
|
||||
@ -8,14 +8,14 @@ import { generateTargetColumnMap } from 'src/metadata/field-metadata/utils/gener
|
||||
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
import { generateDefaultValue } from 'src/metadata/field-metadata/utils/generate-default-value';
|
||||
|
||||
export type FieldMetadataDecorator = {
|
||||
type: FieldMetadataType;
|
||||
export interface FieldMetadataDecorator<T extends FieldMetadataType> {
|
||||
type: T;
|
||||
label: string;
|
||||
description?: string | null;
|
||||
icon?: string | null;
|
||||
defaultValue?: FieldMetadataDefaultValue | null;
|
||||
defaultValue?: FieldMetadataDefaultValue<T> | null;
|
||||
joinColumn?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type ObjectMetadataDecorator = {
|
||||
namePlural: string;
|
||||
@ -82,8 +82,8 @@ export function IsSystem() {
|
||||
};
|
||||
}
|
||||
|
||||
export function FieldMetadata(
|
||||
metadata: FieldMetadataDecorator,
|
||||
export function FieldMetadata<T extends FieldMetadataType>(
|
||||
metadata: FieldMetadataDecorator<T>,
|
||||
): PropertyDecorator {
|
||||
return (target: object, fieldKey: string) => {
|
||||
const existingFieldMetadata =
|
||||
@ -100,7 +100,7 @@ export function FieldMetadata(
|
||||
'fieldMetadata',
|
||||
{
|
||||
...existingFieldMetadata,
|
||||
[fieldKey]: generateFieldMetadata(
|
||||
[fieldKey]: generateFieldMetadata<T>(
|
||||
fieldMetadata,
|
||||
fieldKey,
|
||||
isNullable,
|
||||
@ -108,7 +108,7 @@ export function FieldMetadata(
|
||||
),
|
||||
...(joinColumn && fieldMetadata.type === FieldMetadataType.RELATION
|
||||
? {
|
||||
[joinColumn]: generateFieldMetadata(
|
||||
[joinColumn]: generateFieldMetadata<FieldMetadataType.UUID>(
|
||||
{
|
||||
...fieldMetadata,
|
||||
type: FieldMetadataType.UUID,
|
||||
@ -128,8 +128,8 @@ export function FieldMetadata(
|
||||
};
|
||||
}
|
||||
|
||||
function generateFieldMetadata(
|
||||
metadata: FieldMetadataDecorator,
|
||||
function generateFieldMetadata<T extends FieldMetadataType>(
|
||||
metadata: FieldMetadataDecorator<T>,
|
||||
fieldKey: string,
|
||||
isNullable: boolean,
|
||||
isSystem: boolean,
|
||||
|
||||
@ -5,7 +5,10 @@ import {
|
||||
IsSystem,
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.object-metadata';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata';
|
||||
import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'activityTargets',
|
||||
@ -23,7 +26,7 @@ export class ActivityTargetObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconNotes',
|
||||
joinColumn: 'activityId',
|
||||
})
|
||||
activity: object;
|
||||
activity: ActivityObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -33,7 +36,7 @@ export class ActivityTargetObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'personId',
|
||||
})
|
||||
@IsNullable()
|
||||
person: object;
|
||||
person: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -43,5 +46,5 @@ export class ActivityTargetObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'companyId',
|
||||
})
|
||||
@IsNullable()
|
||||
company: object;
|
||||
company: CompanyObjectMetadata;
|
||||
}
|
||||
|
||||
@ -7,7 +7,11 @@ import {
|
||||
FieldMetadata,
|
||||
RelationMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/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 { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata';
|
||||
import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'activities',
|
||||
@ -82,7 +86,8 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'activityTarget',
|
||||
})
|
||||
activityTargets: object[];
|
||||
@IsNullable()
|
||||
activityTargets: ActivityTargetObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -94,7 +99,8 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'attachment',
|
||||
})
|
||||
attachments: object[];
|
||||
@IsNullable()
|
||||
attachments: AttachmentObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -106,7 +112,8 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'comment',
|
||||
})
|
||||
comments: object[];
|
||||
@IsNullable()
|
||||
comments: CommentObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -115,7 +122,7 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'authorId',
|
||||
})
|
||||
author: object;
|
||||
author: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -124,5 +131,5 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'assigneeId',
|
||||
})
|
||||
assignee: object;
|
||||
assignee: WorkspaceMemberObjectMetadata;
|
||||
}
|
||||
|
||||
@ -5,7 +5,11 @@ import {
|
||||
FieldMetadata,
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.object-metadata';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.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: 'attachments',
|
||||
@ -47,7 +51,7 @@ export class AttachmentObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconCircleUser',
|
||||
joinColumn: 'authorId',
|
||||
})
|
||||
author: string;
|
||||
author: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -56,7 +60,7 @@ export class AttachmentObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconNotes',
|
||||
joinColumn: 'activityId',
|
||||
})
|
||||
activity: string;
|
||||
activity: ActivityObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -66,7 +70,7 @@ export class AttachmentObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'personId',
|
||||
})
|
||||
@IsNullable()
|
||||
person: string;
|
||||
person: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -76,5 +80,5 @@ export class AttachmentObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'companyId',
|
||||
})
|
||||
@IsNullable()
|
||||
company: string;
|
||||
company: CompanyObjectMetadata;
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import {
|
||||
IsSystem,
|
||||
FieldMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.object-metadata';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'comments',
|
||||
@ -31,7 +33,7 @@ export class CommentObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconCircleUser',
|
||||
joinColumn: 'authorId',
|
||||
})
|
||||
author: string;
|
||||
author: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -40,5 +42,5 @@ export class CommentObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconNotes',
|
||||
joinColumn: 'activityId',
|
||||
})
|
||||
activity: string;
|
||||
activity: ActivityObjectMetadata;
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
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 {
|
||||
@ -6,7 +8,13 @@ import {
|
||||
IsNullable,
|
||||
RelationMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/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',
|
||||
@ -59,7 +67,7 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconBrandLinkedin',
|
||||
})
|
||||
@IsNullable()
|
||||
linkedinLink: string;
|
||||
linkedinLink: LinkMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.LINK,
|
||||
@ -68,7 +76,7 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconBrandX',
|
||||
})
|
||||
@IsNullable()
|
||||
xLink: string;
|
||||
xLink: LinkMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.CURRENCY,
|
||||
@ -78,7 +86,7 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconMoneybag',
|
||||
})
|
||||
@IsNullable()
|
||||
annualRecurringRevenue: number;
|
||||
annualRecurringRevenue: CurrencyMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
@ -101,7 +109,8 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'person',
|
||||
})
|
||||
people: object[];
|
||||
@IsNullable()
|
||||
people: PersonObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -112,7 +121,7 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'accountOwnerId',
|
||||
})
|
||||
@IsNullable()
|
||||
accountOwner: string;
|
||||
accountOwner: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -124,7 +133,8 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'activityTarget',
|
||||
})
|
||||
activityTargets: object[];
|
||||
@IsNullable()
|
||||
activityTargets: ActivityTargetObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -136,7 +146,8 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'opportunity',
|
||||
})
|
||||
opportunities: object[];
|
||||
@IsNullable()
|
||||
opportunities: OpportunityObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -148,7 +159,8 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'favorite',
|
||||
})
|
||||
favorites: object[];
|
||||
@IsNullable()
|
||||
favorites: FavoriteObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -160,5 +172,6 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'attachment',
|
||||
})
|
||||
attachments: object[];
|
||||
@IsNullable()
|
||||
attachments: AttachmentObjectMetadata[];
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@ import {
|
||||
FieldMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.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: 'favorites',
|
||||
@ -32,7 +35,7 @@ export class FavoriteObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconCircleUser',
|
||||
joinColumn: 'workspaceMemberId',
|
||||
})
|
||||
workspaceMember: object;
|
||||
workspaceMember: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -41,7 +44,7 @@ export class FavoriteObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUser',
|
||||
joinColumn: 'personId',
|
||||
})
|
||||
person: object;
|
||||
person: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -50,5 +53,5 @@ export class FavoriteObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
joinColumn: 'companyId',
|
||||
})
|
||||
company: object;
|
||||
company: CompanyObjectMetadata;
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { CurrencyMetadata } from 'src/metadata/field-metadata/composite-types/currency.composite-type';
|
||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
ObjectMetadata,
|
||||
@ -6,6 +7,9 @@ import {
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata';
|
||||
import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata';
|
||||
import { PipelineStepObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/pipeline-step.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'opportunities',
|
||||
@ -22,7 +26,7 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconCurrencyDollar',
|
||||
})
|
||||
@IsNullable()
|
||||
amount: string;
|
||||
amount: CurrencyMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
@ -31,7 +35,7 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconCalendarEvent',
|
||||
})
|
||||
@IsNullable()
|
||||
closeDate: string;
|
||||
closeDate: Date;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.TEXT,
|
||||
@ -52,7 +56,7 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'pipelineStepId',
|
||||
})
|
||||
@IsNullable()
|
||||
pipelineStep: string;
|
||||
pipelineStep: PipelineStepObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -62,7 +66,7 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'pointOfContactId',
|
||||
})
|
||||
@IsNullable()
|
||||
pointOfContact: string;
|
||||
pointOfContact: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -71,7 +75,7 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUser',
|
||||
joinColumn: 'personId',
|
||||
})
|
||||
person: string;
|
||||
person: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -81,5 +85,5 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'companyId',
|
||||
})
|
||||
@IsNullable()
|
||||
company: string;
|
||||
company: CompanyObjectMetadata;
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { FullNameMetadata } from 'src/metadata/field-metadata/composite-types/full-name.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 {
|
||||
@ -7,7 +9,12 @@ import {
|
||||
RelationMetadata,
|
||||
IsSystem,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/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 { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.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';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'people',
|
||||
@ -24,7 +31,7 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUser',
|
||||
})
|
||||
@IsNullable()
|
||||
name: string;
|
||||
name: FullNameMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.EMAIL,
|
||||
@ -42,7 +49,7 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconBrandLinkedin',
|
||||
})
|
||||
@IsNullable()
|
||||
linkedinLink: string;
|
||||
linkedinLink: LinkMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.LINK,
|
||||
@ -51,7 +58,7 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconBrandX',
|
||||
})
|
||||
@IsNullable()
|
||||
xLink: string;
|
||||
xLink: LinkMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.TEXT,
|
||||
@ -99,7 +106,7 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'companyId',
|
||||
})
|
||||
@IsNullable()
|
||||
company: string;
|
||||
company: CompanyObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -112,7 +119,8 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'opportunity',
|
||||
inverseSideFieldName: 'pointOfContact',
|
||||
})
|
||||
pointOfContactForOpportunities: object[];
|
||||
@IsNullable()
|
||||
pointOfContactForOpportunities: OpportunityObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -124,7 +132,8 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'activityTarget',
|
||||
})
|
||||
activityTargets: object[];
|
||||
@IsNullable()
|
||||
activityTargets: ActivityTargetObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -136,7 +145,8 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'opportunity',
|
||||
})
|
||||
opportunities: object[];
|
||||
@IsNullable()
|
||||
opportunities: OpportunityObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -148,7 +158,8 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'favorite',
|
||||
})
|
||||
favorites: object[];
|
||||
@IsNullable()
|
||||
favorites: FavoriteObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -160,5 +171,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'attachment',
|
||||
})
|
||||
attachments: object[];
|
||||
@IsNullable()
|
||||
attachments: AttachmentObjectMetadata[];
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
RelationMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'pipelineSteps',
|
||||
@ -58,5 +59,5 @@ export class PipelineStepObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'opportunity',
|
||||
})
|
||||
@IsNullable()
|
||||
opportunities: object[];
|
||||
opportunities: OpportunityObjectMetadata[];
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { ViewObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'viewFields',
|
||||
@ -59,5 +60,5 @@ export class ViewFieldObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'viewId',
|
||||
})
|
||||
@IsNullable()
|
||||
view?: object;
|
||||
view?: ViewObjectMetadata;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { ViewObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'viewFilters',
|
||||
@ -59,5 +60,5 @@ export class ViewFilterObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'viewId',
|
||||
})
|
||||
@IsNullable()
|
||||
view: string;
|
||||
view: ViewObjectMetadata;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
IsSystem,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { ViewObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'viewSorts',
|
||||
@ -41,5 +42,5 @@ export class ViewSortObjectMetadata extends BaseObjectMetadata {
|
||||
joinColumn: 'viewId',
|
||||
})
|
||||
@IsNullable()
|
||||
view: string;
|
||||
view: ViewObjectMetadata;
|
||||
}
|
||||
|
||||
@ -5,8 +5,12 @@ import {
|
||||
IsSystem,
|
||||
FieldMetadata,
|
||||
RelationMetadata,
|
||||
IsNullable,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { ViewFieldObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-field.object-metadata';
|
||||
import { ViewFilterObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-filter.object-metadata';
|
||||
import { ViewSortObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-sort.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'views',
|
||||
@ -53,7 +57,8 @@ export class ViewObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'viewField',
|
||||
})
|
||||
viewFields: object[];
|
||||
@IsNullable()
|
||||
viewFields: ViewFieldObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -65,7 +70,8 @@ export class ViewObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'viewFilter',
|
||||
})
|
||||
viewFilters: object[];
|
||||
@IsNullable()
|
||||
viewFilters: ViewFilterObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -77,5 +83,6 @@ export class ViewObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'viewSort',
|
||||
})
|
||||
viewSorts: object[];
|
||||
@IsNullable()
|
||||
viewSorts: ViewSortObjectMetadata[];
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ export class WebhookObjectMetadata extends BaseObjectMetadata {
|
||||
label: 'Target Url',
|
||||
description: 'Webhook target url',
|
||||
icon: 'IconLink',
|
||||
defaultValue: { value: '' },
|
||||
})
|
||||
targetUrl: string;
|
||||
|
||||
@ -29,7 +28,6 @@ export class WebhookObjectMetadata extends BaseObjectMetadata {
|
||||
label: 'Operation',
|
||||
description: 'Webhook operation',
|
||||
icon: 'IconCheckbox',
|
||||
defaultValue: { value: '' },
|
||||
})
|
||||
operation: string;
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { FullNameMetadata } from 'src/metadata/field-metadata/composite-types/full-name.composite-type';
|
||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
import {
|
||||
@ -7,7 +8,12 @@ import {
|
||||
IsNullable,
|
||||
RelationMetadata,
|
||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||
import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.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 { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata';
|
||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata';
|
||||
import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
namePlural: 'workspaceMembers',
|
||||
@ -24,7 +30,7 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
description: 'Workspace member name',
|
||||
icon: 'IconCircleUser',
|
||||
})
|
||||
name: string;
|
||||
name: FullNameMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.TEXT,
|
||||
@ -49,9 +55,7 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
label: 'Avatar Url',
|
||||
description: 'Workspace member avatar',
|
||||
icon: 'IconFileUpload',
|
||||
defaultValue: { value: '' },
|
||||
})
|
||||
@IsNullable()
|
||||
avatarUrl: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@ -74,7 +78,8 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'activity',
|
||||
inverseSideFieldName: 'author',
|
||||
})
|
||||
authoredActivities: object[];
|
||||
@IsNullable()
|
||||
authoredActivities: ActivityObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -87,7 +92,8 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'activity',
|
||||
inverseSideFieldName: 'assignee',
|
||||
})
|
||||
assignedActivities: object[];
|
||||
@IsNullable()
|
||||
assignedActivities: ActivityObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -99,7 +105,8 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
objectName: 'favorite',
|
||||
})
|
||||
favorites: object[];
|
||||
@IsNullable()
|
||||
favorites: FavoriteObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -112,7 +119,8 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'company',
|
||||
inverseSideFieldName: 'accountOwner',
|
||||
})
|
||||
accountOwnerForCompanies: object[];
|
||||
@IsNullable()
|
||||
accountOwnerForCompanies: CompanyObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -125,7 +133,8 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'attachment',
|
||||
inverseSideFieldName: 'author',
|
||||
})
|
||||
authoredAttachments: object[];
|
||||
@IsNullable()
|
||||
authoredAttachments: AttachmentObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
@ -138,5 +147,6 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
|
||||
objectName: 'comment',
|
||||
inverseSideFieldName: 'author',
|
||||
})
|
||||
authoredComments: object[];
|
||||
@IsNullable()
|
||||
authoredComments: CommentObjectMetadata[];
|
||||
}
|
||||
|
||||
@ -34,12 +34,12 @@ export class MetadataParser {
|
||||
}
|
||||
|
||||
static parseAllMetadata(
|
||||
metadata: (typeof BaseObjectMetadata)[],
|
||||
metadataCollection: (typeof BaseObjectMetadata)[],
|
||||
workspaceId: string,
|
||||
dataSourceId: string,
|
||||
) {
|
||||
return metadata.map((_metadata) =>
|
||||
MetadataParser.parseMetadata(_metadata, workspaceId, dataSourceId),
|
||||
return metadataCollection.map((metadata) =>
|
||||
MetadataParser.parseMetadata(metadata, workspaceId, dataSourceId),
|
||||
);
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ export class MetadataParser {
|
||||
`Object ${relation.fromObjectNameSingular} not found in DB
|
||||
for relation defined in class ${objectMetadata.nameSingular}`,
|
||||
);
|
||||
|
||||
const toObjectMetadata =
|
||||
objectMetadataFromDB[relation.toObjectNameSingular];
|
||||
assert(
|
||||
@ -68,6 +69,7 @@ export class MetadataParser {
|
||||
`Object ${relation.toObjectNameSingular} not found in DB
|
||||
for relation defined in class ${objectMetadata.nameSingular}`,
|
||||
);
|
||||
|
||||
const fromFieldMetadata =
|
||||
fromObjectMetadata?.fields[relation.fromFieldMetadataName];
|
||||
assert(
|
||||
@ -75,6 +77,7 @@ export class MetadataParser {
|
||||
`Field ${relation.fromFieldMetadataName} not found in object ${relation.fromObjectNameSingular}
|
||||
for relation defined in class ${objectMetadata.nameSingular}`,
|
||||
);
|
||||
|
||||
const toFieldMetadata =
|
||||
toObjectMetadata?.fields[relation.toFieldMetadataName];
|
||||
assert(
|
||||
@ -82,6 +85,7 @@ export class MetadataParser {
|
||||
`Field ${relation.toFieldMetadataName} not found in object ${relation.toObjectNameSingular}
|
||||
for relation defined in class ${objectMetadata.nameSingular}`,
|
||||
);
|
||||
|
||||
return {
|
||||
relationType: relation.type,
|
||||
fromObjectMetadataId: fromObjectMetadata?.id,
|
||||
@ -94,13 +98,13 @@ export class MetadataParser {
|
||||
}
|
||||
|
||||
static parseAllRelations(
|
||||
metadata: (typeof BaseObjectMetadata)[],
|
||||
metadataCollection: (typeof BaseObjectMetadata)[],
|
||||
workspaceId: string,
|
||||
objectMetadataFromDB: Record<string, ObjectMetadataEntity>,
|
||||
) {
|
||||
return metadata.flatMap((_metadata) =>
|
||||
return metadataCollection.flatMap((metadata) =>
|
||||
MetadataParser.parseRelationMetadata(
|
||||
_metadata,
|
||||
metadata,
|
||||
workspaceId,
|
||||
objectMetadataFromDB,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user