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>
This commit is contained in:
Jérémy M 2023-12-21 19:15:05 +01:00 committed by GitHub
parent 3234134a30
commit d532f22fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
112 changed files with 714 additions and 6381 deletions

View File

@ -1,5 +1,5 @@
type DeepPartial<T> = T extends object
? {
[P in keyof T]?: DeepPartial<T[P]>;
}
: T;
type DeepPartial<T> = {
[K in keyof T]?: T[K] extends Array<infer R>
? Array<DeepPartial<R>>
: DeepPartial<T[K]>;
};

View File

@ -6,12 +6,10 @@ import { FetchWorkspaceMessagesCommandsModule } from 'src/workspace/messaging/co
import { AppModule } from './app.module';
import { WorkspaceSyncMetadataCommandsModule } from './workspace/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module';
import { WorkspaceMigrationRunnerCommandsModule } from './workspace/workspace-migration-runner/commands/workspace-migration-runner-commands.module';
@Module({
imports: [
AppModule,
WorkspaceMigrationRunnerCommandsModule,
WorkspaceSyncMetadataCommandsModule,
DatabaseCommandModule,
FetchWorkspaceMessagesCommandsModule,

View File

@ -2,8 +2,8 @@ import { Field, ID, ObjectType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';
@ObjectType('UserWorkspaceMemberName')
export class UserWorkspaceMemberName {
@ObjectType('FullName')
export class FullName {
@Field({ nullable: false })
firstName: string;
@ -11,13 +11,13 @@ export class UserWorkspaceMemberName {
lastName: string;
}
@ObjectType('UserWorkspaceMember')
export class UserWorkspaceMember {
@ObjectType('WorkspaceMember')
export class WorkspaceMember {
@IDField(() => ID)
id: string;
@Field(() => UserWorkspaceMemberName)
name: UserWorkspaceMemberName;
@Field(() => FullName)
name: FullName;
@Field({ nullable: false })
colorScheme: string;

View File

@ -5,7 +5,7 @@ import { Repository } from 'typeorm';
import { assert } from 'src/utils/assert';
import { User } from 'src/core/user/user.entity';
import { UserWorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
import { WorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
@ -35,7 +35,7 @@ export class UserService extends TypeOrmQueryService<User> {
assert(workspaceMembers.length === 1, 'WorkspaceMember not found');
const userWorkspaceMember = new UserWorkspaceMember();
const userWorkspaceMember = new WorkspaceMember();
userWorkspaceMember.id = workspaceMembers[0].id;
userWorkspaceMember.colorScheme = workspaceMembers[0].colorScheme;

View File

@ -13,7 +13,7 @@ import { IDField } from '@ptc-org/nestjs-query-graphql';
import { RefreshToken } from 'src/core/refresh-token/refresh-token.entity';
import { Workspace } from 'src/core/workspace/workspace.entity';
import { UserWorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
import { WorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
@Entity({ name: 'user', schema: 'core' })
@ObjectType('User')
@ -73,6 +73,6 @@ export class User {
})
refreshTokens: RefreshToken[];
@Field(() => UserWorkspaceMember, { nullable: false })
workspaceMember: UserWorkspaceMember;
@Field(() => WorkspaceMember, { nullable: false })
workspaceMember: WorkspaceMember;
}

View File

@ -22,7 +22,7 @@ import { FileUploadService } from 'src/core/file/services/file-upload.service';
import { assert } from 'src/utils/assert';
import { JwtAuthGuard } from 'src/guards/jwt.auth.guard';
import { User } from 'src/core/user/user.entity';
import { UserWorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
import { WorkspaceMember } from 'src/core/user/dtos/workspace-member.dto';
import { UserService } from './services/user.service';
@ -54,10 +54,10 @@ export class UserResolver {
return user;
}
@ResolveField(() => UserWorkspaceMember, {
@ResolveField(() => WorkspaceMember, {
nullable: false,
})
async workspaceMember(@Parent() user: User): Promise<UserWorkspaceMember> {
async workspaceMember(@Parent() user: User): Promise<WorkspaceMember> {
return this.userService.loadWorkspaceMember(user);
}

View File

@ -1,33 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
export const SeedWorkspaceSchemaName = 'workspace_1wgvd1injqtife6y4rvfbu3h5';
const tableName = 'dataSource';
export const SeedDataSourceId = '20202020-7f63-47a9-b1b3-6c7290ca9fb1';
export const seedDataSource = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource.query(
`CREATE SCHEMA IF NOT EXISTS ${SeedWorkspaceSchemaName}`,
);
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, ['id', 'schema', 'type', 'workspaceId'])
.orIgnore()
.values([
{
id: SeedDataSourceId,
schema: SeedWorkspaceSchemaName,
type: 'postgres',
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,201 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedActivityTargetFieldMetadataIds {
Id = '20202020-7db7-4dac-8093-ea0a12e9466f',
CreatedAt = '20202020-585f-48fa-a4b6-97cf7f86315e',
UpdatedAt = '20202020-4cf0-4478-8c68-62a855622a99',
Activity = '20202020-cb21-42c9-bba8-347f7cb02b84',
ActivityForeignKey = '20202020-2b1a-4c6a-9c0a-1b9f5b7c9b1a',
Person = '20202020-e56c-43e6-8fce-5619d8c2293a',
PersonForeignKey = '20202020-4c5d-4b5e-8d6e-3b2a4d5f6a7b',
Company = '20202020-9408-4cc0-9fe1-51467edb530b',
CompanyForeignKey = '20202020-9408-4cc0-9fe1-51467edb530c',
}
export const seedActivityTargetFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedActivityTargetFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedActivityTargetFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedActivityTargetFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Relationships
{
id: SeedActivityTargetFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activity',
label: 'Activity',
targetColumnMap: {},
description: 'ActivityTarget activity',
icon: 'IconNotes',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityTargetFieldMetadataIds.ActivityForeignKey,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'activityId',
label: 'Activity id (foreign key)',
targetColumnMap: {},
description: 'ActivityTarget activity id foreign key',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedActivityTargetFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'person',
label: 'Person',
targetColumnMap: {},
description: 'ActivityTarget person',
icon: 'IconUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityTargetFieldMetadataIds.PersonForeignKey,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'personId',
label: 'Person id (foreign key)',
targetColumnMap: {},
description: 'ActivityTarget person id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedActivityTargetFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'company',
label: 'Company',
targetColumnMap: {},
description: 'ActivityTarget company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityTargetFieldMetadataIds.CompanyForeignKey,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'companyId',
label: 'Company id (foreign key)',
targetColumnMap: {},
description: 'ActivityTarget company id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,341 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedActivityFieldMetadataIds {
Id = '20202020-f695-419c-b928-c488323d6df3',
CreatedAt = '20202020-65a2-4d9c-b640-bac54007a14d',
UpdatedAt = '20202020-88df-4202-bf82-6a06c6963280',
Title = '20202020-2584-4797-95a8-5cc90d48c040',
Body = '20202020-aff0-4961-be8a-0e5c2598b9a6',
Type = '20202020-a243-4b94-a4b4-25705af86be2',
ReminderAt = '20202020-cd46-44f4-bf22-b0aa20d009da',
DueAt = '20202020-20e1-4366-b386-750bdca2dfe3',
CompletedAt = '20202020-0924-48f0-a8c2-d2dd4e2098e2',
ActivityTargets = '20202020-ec1d-4ffe-8bd2-a85c23ae0037',
Comments = '20202020-c85c-47f2-bbe4-6b36c26f9247',
Attachments = '20202020-9755-43a8-b621-f94df0f6b839',
Author = '20202020-3acb-46bb-b993-0dc49fa2a48c',
AuthorForeignKey = '20202020-3acb-46bb-b993-0dc49fa2a48d',
Assignee = '20202020-4694-4ec6-9084-8d932ebb3065',
AssigneeForeignKey = '20202020-4694-4ec6-9084-8d932ebb3066',
}
export const seedActivityFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedActivityFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedActivityFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedActivityFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Primary identifier
{
id: SeedActivityFieldMetadataIds.Title,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'title',
label: 'Title',
targetColumnMap: {
value: 'title',
},
description: 'Activity title',
icon: 'IconNotes',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
// Scalar fields
{
id: SeedActivityFieldMetadataIds.Body,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'body',
label: 'Body',
targetColumnMap: {
value: 'body',
},
description: 'Activity body',
icon: 'IconList',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedActivityFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'type',
label: 'Type',
targetColumnMap: {
value: 'type',
},
description: 'Activity type',
icon: 'IconCheckbox',
isNullable: false,
isSystem: false,
defaultValue: { value: 'Note' },
},
{
id: SeedActivityFieldMetadataIds.ReminderAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'reminderAt',
label: 'Reminder Date',
targetColumnMap: {
value: 'reminderAt',
},
description: 'Activity reminder date',
icon: 'IconCalendarEvent',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.DueAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'dueAt',
label: 'Due Date',
targetColumnMap: {
value: 'dueAt',
},
description: 'Activity due date',
icon: 'IconCalendarEvent',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.CompletedAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'completedAt',
label: 'Completion Date',
targetColumnMap: {
value: 'completedAt',
},
description: 'Activity completion date',
icon: 'IconCheck',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
// Relationships
{
id: SeedActivityFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activityTargets',
label: 'Targets',
targetColumnMap: {},
description: 'Activity targets',
icon: 'IconCheckbox',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Activity attachments',
icon: 'IconFileImport',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.Comments,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'comments',
label: 'Comments',
targetColumnMap: {},
description: 'Activity comments',
icon: 'IconComment',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'author',
label: 'Author',
targetColumnMap: {
value: 'authorId',
},
description:
'Activity author. This is the person who created the activity',
icon: 'IconUserCircle',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.AuthorForeignKey,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'authorId',
label: 'Author id (foreign key)',
targetColumnMap: {},
description: 'Activity author id foreign key',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.Assignee,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'assignee',
label: 'Assignee',
targetColumnMap: {},
description:
'Acitivity assignee. This is the workspace member assigned to the activity ',
icon: 'IconUserCircle',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedActivityFieldMetadataIds.AssigneeForeignKey,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'assigneeId',
label: 'Assignee id (foreign key)',
targetColumnMap: {},
description: 'Acitivity assignee id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,156 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedApiKeyFieldMetadataIds {
Id = '20202020-7222-45ee-b5c4-c30eba68566f',
CreatedAt = '20202020-ecd6-479f-8368-5032fdee43b3',
UpdatedAt = '20202020-435c-4133-93c0-df5709d1694d',
Name = '20202020-1dfa-4ef3-8d19-51e82c28677a',
ExpiresAt = '20202020-a092-41e2-940e-e17cd0403aa7',
RevokedAt = '20202020-da41-436e-8498-b1a99c23b275',
}
export const seedApiKeyFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedApiKeyFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedApiKeyFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedApiKeyFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedApiKeyFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'ApiKey name',
icon: 'IconLink',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedApiKeyFieldMetadataIds.ExpiresAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'expiresAt',
label: 'Expiration date',
targetColumnMap: {
value: 'expiresAt',
},
description: 'ApiKey expiration date',
icon: 'IconCalendar',
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedApiKeyFieldMetadataIds.RevokedAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'revokedAt',
label: 'Revocation date',
targetColumnMap: {
value: 'revokedAt',
},
description: 'ApiKey revocation date',
icon: 'IconCalendar',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,304 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedAttachmentFieldMetadataIds {
Id = '20202020-0544-432b-8f96-84c4d6a94d50',
CreatedAt = '20202020-839b-4cbb-a1be-1a0cb85524a4',
UpdatedAt = '20202020-7f29-490d-a3e1-9c3015524057',
Name = '20202020-5683-4c80-8590-255321ece692',
FullPath = '20202020-bb72-4644-b255-afb4ebb83b66',
Type = '20202020-8dfa-492f-92d1-56d5fb18cbb7',
Author = '20202020-7831-43c2-827f-bc78289b7398',
AuthorForeignKey = '20202020-7831-43c2-827f-bc78289b7399',
Activity = '20202020-f5a9-46ec-b39a-eda906f00804',
ActivityForeignKey = '20202020-f5a9-46ec-b39a-eda906f00805',
Person = '20202020-f67c-4cc5-893c-c6b615527473',
PersonForeignKey = '20202020-f67c-4cc5-893c-c6b615527474',
Company = '20202020-5463-4d03-9124-1775b9b7f955',
CompanyForeignKey = '20202020-5463-4d03-9124-1775b9b7f956',
}
export const seedAttachmentFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedAttachmentFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedAttachmentFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedAttachmentFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Primary Identifier
{
id: SeedAttachmentFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'Attachment name',
icon: 'IconFileUpload',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
// Scalar fields
{
id: SeedAttachmentFieldMetadataIds.FullPath,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'fullPath',
label: 'Full path',
targetColumnMap: {
value: 'fullPath',
},
description: 'Attachment full path',
icon: 'IconLink',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedAttachmentFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'type',
label: 'Type',
targetColumnMap: {
value: 'type',
},
description: 'Attachment type',
icon: 'IconList',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
// Relationships
{
id: SeedAttachmentFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'author',
label: 'Author',
targetColumnMap: {
value: 'authorId',
},
description: 'Attachment author',
icon: 'IconCircleUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.AuthorForeignKey,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'authorId',
label: 'Author id (foreign key)',
targetColumnMap: {},
description: 'Attachment author id foreign key',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activity',
label: 'Activity',
targetColumnMap: {
value: 'activityId',
},
description: 'Attachment activity',
icon: 'IconNotes',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.ActivityForeignKey,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'activityId',
label: 'Activity id (foreign key)',
targetColumnMap: {},
description: 'Attachment activity id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'Attachment person',
icon: 'IconUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.PersonForeignKey,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'personId',
label: 'Person id (foreign key)',
targetColumnMap: {},
description: 'Attachment person id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'Attachment company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedAttachmentFieldMetadataIds.CompanyForeignKey,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'companyId',
label: 'Company id (foreign key)',
targetColumnMap: {},
description: 'Attachment company id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,187 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedCommentFieldMetadataIds {
Id = '20202020-2899-42fa-ba07-1f4dad7ae28f',
CreatedAt = '20202020-88fd-4db2-9fcb-b5f4f5955cf2',
UpdatedAt = '20202020-63dd-4426-abad-9973fece49ed',
Body = '20202020-354b-4f10-9425-fa3eb8fddc51',
Author = '20202020-2c70-40c2-bba6-893780b25d41',
AuthorForeignKey = '20202021-2c70-40c2-bba6-893780b25d42',
Activity = '20202020-a9ac-4294-9462-db0f690da906',
ActivityForeignKey = '20202021-a9ac-4294-9462-db0f690da907',
}
export const seedCommentFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedCommentFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedCommentFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedCommentFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedCommentFieldMetadataIds.Body,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'body',
label: 'Body',
targetColumnMap: {
value: 'body',
},
description: 'Comment body',
icon: 'IconLink',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
// Relationships
{
id: SeedCommentFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'author',
label: 'Author',
targetColumnMap: {},
description: 'Comment author',
icon: 'IconCircleUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCommentFieldMetadataIds.AuthorForeignKey,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'authorId',
label: 'Author id (foreign key)',
targetColumnMap: {},
description: 'Comment author id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedCommentFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activity',
label: 'Activity',
targetColumnMap: {},
description: 'Comment activity',
icon: 'IconNotes',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCommentFieldMetadataIds.ActivityForeignKey,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'activityId',
label: 'Activity id (foreign key)',
targetColumnMap: {},
description: 'Activity id foreign key',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,382 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedCompanyFieldMetadataIds {
Id = '20202020-8169-44a3-9e0b-6bad1ac50f87',
CreatedAt = '20202020-4dc2-47c9-bb15-6e6f19ba9e46',
UpdatedAt = '20202020-64b8-41bf-a01c-be6a806e8b70',
Name = '20202020-6d30-4111-9f40-b4301906fd3c',
DomainName = '20202020-5e4e-4007-a630-8a2617914889',
Address = '20202020-ad10-4117-a039-3f04b7a5f939',
Employees = '20202020-7fbd-41ad-b64d-25a15ff62f04',
LinkedinLink = '20202020-a61d-4b78-b998-3fd88b4f73a1',
XUrl = '20202020-46e3-479a-b8f4-77137c74daa6',
AnnualRecurringRevenue = '20202020-4a5a-466f-92d9-c3870d9502a9',
IdealCustomerProfile = '20202020-9e9f-4235-98b2-c76f3e2d281e',
People = '20202020-68b4-4c8e-af19-738eba2a42a5',
AccountOwner = '20202020-0739-495d-8e70-c0807f6b2268',
AccountOwnerForeignKey = '20202020-0b9e-4b9e-8b0a-5b0b5b0b5b0b',
ActivityTargets = '20202020-4a2e-4b41-8562-279963e8947e',
Opportunities = '20202020-e3fc-46ff-b552-3e757843f06e',
Favorites = '20202020-e7c8-4771-8cc4-ce0e8c36a3c0',
Attachments = '20202020-61af-4ffd-b79b-baed6db8ad11',
}
export const seedCompanyFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedCompanyFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedCompanyFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: false,
defaultValue: { type: 'now' },
},
{
id: SeedCompanyFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Main Identifier
{
id: SeedCompanyFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'The company name',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
// Scalar Fields
{
id: SeedCompanyFieldMetadataIds.DomainName,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'domainName',
label: 'Domain Name',
targetColumnMap: {
value: 'domainName',
},
description:
'The company website URL. We use this url to fetch the company icon',
icon: 'IconLink',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedCompanyFieldMetadataIds.Address,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'address',
label: 'Address',
targetColumnMap: {
value: 'address',
},
description: 'The company address',
icon: 'IconMap',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedCompanyFieldMetadataIds.Employees,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.NUMBER,
name: 'employees',
label: 'Employees',
targetColumnMap: {
value: 'employees',
},
description: 'Number of employees in the company',
icon: 'IconUsers',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.LinkedinLink,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.LINK,
name: 'linkedinLink',
label: 'Linkedin',
targetColumnMap: {
label: 'linkedinLinkLabel',
url: 'linkedinLinkUrl',
},
description: 'The company Linkedin account',
icon: 'IconBrandLinkedin',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.XUrl,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.LINK,
name: 'xLink',
label: 'X',
targetColumnMap: {
label: 'xLinkLabel',
url: 'xLinkUrl',
},
description: 'The company Twitter/X account',
icon: 'IconBrandX',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.AnnualRecurringRevenue,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.CURRENCY,
name: 'annualRecurringRevenue',
label: 'ARR',
targetColumnMap: {
amountMicros: 'annualRecurringRevenueAmountMicros',
currencyCode: 'annualRecurringRevenueCurrencyCode',
},
description:
'Annual Recurring Revenue: The actual or estimated annual revenue of the company',
icon: 'IconMoneybag',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.IdealCustomerProfile,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.BOOLEAN,
name: 'idealCustomerProfile',
label: 'ICP',
targetColumnMap: {
value: 'idealCustomerProfile',
},
description:
'Ideal Customer Profile: Indicates whether the company is the most suitable and valuable customer for you',
icon: 'IconTarget',
isNullable: true,
isSystem: false,
defaultValue: false,
},
// Relationships
{
id: SeedCompanyFieldMetadataIds.People,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'people',
label: 'People',
targetColumnMap: {},
description: 'People linked to the company.',
icon: 'IconUsers',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.AccountOwner,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'accountOwner',
label: 'Account Owner',
targetColumnMap: {},
description:
'Your team member responsible for managing the company account',
icon: 'IconUserCircle',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.AccountOwnerForeignKey,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'accountOwnerId',
label: 'Account Owner ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for account owner',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activityTargets',
label: 'Activities',
targetColumnMap: {},
description: 'Activities tied to the company',
icon: 'IconCheckbox',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the company.',
icon: 'IconTargetArrow',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the company',
icon: 'IconHeart',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedCompanyFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Attachments linked to the company.',
icon: 'IconFileImport',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,225 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedFavoriteFieldMetadataIds {
Id = '20202020-7d1d-46c7-8c09-8e8c73e30042',
CreatedAt = '20202020-a0f4-443c-a63d-2776a842d024',
UpdatedAt = '20202020-273a-41bc-babf-f58f0b2ba2ec',
Position = '20202020-dd6d-4f67-94aa-22cc83eb0a2e',
WorkspaceMember = '20202020-1138-4e93-bbff-917a68161abf',
WorkspaceMemberForeignKey = '20202020-0f4c-4b9a-9b9a-917a68161a4f',
Person = '20202020-0876-4735-8974-ff4d51aafa07',
PersonForeignKey = '20202020-0876-4735-9473-ff4d51aa4e7b',
Company = '20202020-09e1-4384-ae3e-39e7956396ff',
CompanyForeignKey = '20202020-09e1-4384-ae3e-45e79563d528',
}
export const seedFavoriteFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedFavoriteFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedFavoriteFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedFavoriteFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedFavoriteFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.NUMBER,
name: 'position',
label: 'Position',
targetColumnMap: {
value: 'position',
},
description: 'Favorite position',
icon: 'IconList',
isNullable: false,
isSystem: false,
defaultValue: { value: 0 },
},
// Relationships
{
id: SeedFavoriteFieldMetadataIds.WorkspaceMember,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'workspaceMember',
label: 'Workspace Member',
targetColumnMap: {},
description: 'Favorite workspace member',
icon: 'IconCircleUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedFavoriteFieldMetadataIds.WorkspaceMemberForeignKey,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'workspaceMemberId',
label: 'Workspace Member ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for workspace member',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedFavoriteFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'Favorite person',
icon: 'IconUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedFavoriteFieldMetadataIds.PersonForeignKey,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'personId',
label: 'Person ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for person',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedFavoriteFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'company',
label: 'Company',
targetColumnMap: {},
description: 'Favorite company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedFavoriteFieldMetadataIds.CompanyForeignKey,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'companyId',
label: 'Company ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for company',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,295 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedOpportunityFieldMetadataIds {
Id = '20202020-16ef-476c-8eac-d439b84024cb',
CreatedAt = '20202020-a39d-4ea9-994f-28d1ebd15904',
UpdatedAt = '20202020-437b-4fd7-98bd-00cb91204329',
Amount = '20202020-8c1f-4c83-9a89-7843e586564d',
CloseDate = '20202020-de52-4e7b-a298-db7a7553500f',
Probability = '20202020-3b9c-4e58-a3d2-c617d3b596b1',
PipelineStep = '20202020-0a2e-4676-8011-3fdb2c30c258',
PipelineStepForeignKey = '20202020-0a2e-4676-8011-3fdb2c30d7f8',
PointOfContact = '20202020-618e-42da-b3c3-bcd7af76e355',
PointOfContactForeignKey = '20202020-618e-42da-b3c3-bcd7af76e4c2',
Company = '20202020-31d5-4af5-b016-c61c1c265706',
CompanyForeignKey = '20202020-31d5-4af5-b016-c61c1c2657b9',
Person = '20202020-0655-41df-b938-15d71e589307',
PersonForeignKey = '20202020-0655-41df-b938-15d71e589d3e',
}
export const seedOpportunityFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedOpportunityFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedOpportunityFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: false,
defaultValue: { type: 'now' },
},
{
id: SeedOpportunityFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedOpportunityFieldMetadataIds.Amount,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.CURRENCY,
name: 'amount',
label: 'Amount',
targetColumnMap: {
amountMicros: 'amountAmountMicros',
currencyCode: 'amountCurrencyCode',
},
description: 'Opportunity amount',
icon: 'IconCurrencyDollar',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.CloseDate,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'closeDate',
label: 'Close date',
targetColumnMap: {
value: 'closeDate',
},
description: 'Opportunity close date',
icon: 'IconCalendarEvent',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.Probability,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'probability',
label: 'Probability',
targetColumnMap: {
value: 'probability',
},
description: 'Opportunity probability',
icon: 'IconProgressCheck',
isNullable: true,
isSystem: false,
defaultValue: { value: '0' },
},
// Relationships
{
id: SeedOpportunityFieldMetadataIds.PipelineStep,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'pipelineStep',
label: 'Pipeline Step',
targetColumnMap: {},
description: 'Opportunity pipeline step',
icon: 'IconKanban',
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.PipelineStepForeignKey,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'pipelineStepId',
label: 'Pipeline Step ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for pipeline step',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.PointOfContact,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'pointOfContact',
label: 'Point of Contact',
targetColumnMap: {},
description: 'Opportunity point of contact',
icon: 'IconUser',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.PointOfContactForeignKey,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'pointOfContactId',
label: 'Point of Contact ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for point of contact',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'person',
label: 'Person',
targetColumnMap: {},
description: 'Opportunity person',
icon: 'IconUser',
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.PersonForeignKey,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'personId',
label: 'Person ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for person',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'company',
label: 'Company',
targetColumnMap: {},
description: 'Opportunity company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedOpportunityFieldMetadataIds.CompanyForeignKey,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'companyId',
label: 'Company ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for company',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,379 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedPersonFieldMetadataIds {
Id = '20202020-03cd-4cd0-9afc-92077b69f24f',
CreatedAt = '20202020-bec0-4cf0-bf1c-8b2ed21f027a',
UpdatedAt = '20202020-2bf4-42b8-8718-a3e852bfa6a6',
Name = '20202020-9b56-4888-bfe3-f6f59aa999e3',
Email = '20202020-8a96-4e4b-86fd-ea126530e0c1',
LinkedinLink = '20202020-dcf6-445a-b543-37e55de43c25',
XLink = '20202020-a3a7-4f63-9303-10226f6055be',
JobTitle = '20202020-3b86-413e-ab56-0ebd1a583ff3',
Phone = '20202020-486f-45f9-bbdf-aac18b1831c0',
City = '20202020-78f8-4b4c-90ff-86adf77590f5',
AvatarUrl = '20202020-bb05-45cb-aa2a-71b58d49dd23',
Company = '20202020-64e1-4080-b6ad-db03c3809885',
CompanyForeignKey = '20202020-64e1-4080-b6ad-db03c3809f8b',
ContactForOpportunities = '20202020-2c2e-418e-ba2d-d28434ff02a6',
Opportunities = '20202020-6bc4-4905-a9d3-4f8d616a19e1',
ActivityTargets = '20202020-f285-4115-a46c-116522986b29',
Favorites = '20202020-6268-4165-8774-9aaf45db2b25',
Attachments = '20202020-5883-4bb3-a308-65271901a1d4',
}
export const seedPersonFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedPersonFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedPersonFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: false,
defaultValue: { type: 'now' },
},
{
id: SeedPersonFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Main Identifier
{
id: SeedPersonFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.FULL_NAME,
name: 'name',
label: 'Name',
targetColumnMap: {
firstName: 'nameFirstName',
lastName: 'nameLastName',
},
description: 'Contacts name',
icon: 'IconUser',
isNullable: true,
isSystem: false,
defaultValue: { firstName: '', lastName: '' },
},
// Scalar Fields
{
id: SeedPersonFieldMetadataIds.Email,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.EMAIL,
name: 'email',
label: 'Email',
targetColumnMap: {
value: 'email',
},
description: 'Contacts Email',
icon: 'IconMail',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.LinkedinLink,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.LINK,
name: 'linkedinLink',
label: 'Linkedin',
targetColumnMap: {
label: 'linkedinLinkLabel',
url: 'linkedinLinkUrl',
},
description: 'Contacts Linkedin account',
icon: 'IconBrandLinkedin',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.XLink,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.LINK,
name: 'xLink',
label: 'X',
targetColumnMap: {
label: 'xLinkLabel',
url: 'xLinkUrl',
},
description: 'Contacts X/Twitter account',
icon: 'IconBrandX',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.JobTitle,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'jobTitle',
label: 'Job Title',
targetColumnMap: {
value: 'jobTitle',
},
description: 'Contacts job title',
icon: 'IconBriefcase',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.Phone,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'phone',
label: 'Phone',
targetColumnMap: {
value: 'phone',
},
description: 'Contacts phone number',
icon: 'IconPhone',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.City,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'city',
label: 'City',
targetColumnMap: {
value: 'city',
},
description: 'Contacts city',
icon: 'IconMap',
isNullable: true,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedPersonFieldMetadataIds.AvatarUrl,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'avatarUrl',
label: 'Avatar',
targetColumnMap: {
value: 'avatarUrl',
},
description: 'Contacts avatar',
icon: 'IconFileUpload',
isNullable: true,
isSystem: true,
defaultValue: { value: '' },
},
// Relationships
{
id: SeedPersonFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'company',
label: 'Company',
targetColumnMap: {},
description: 'Contacts company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.CompanyForeignKey,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'companyId',
label: 'Company ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for company',
icon: undefined,
isNullable: true,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.ContactForOpportunities,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'pointOfContactForOpportunities',
label: 'POC for Opportunities',
targetColumnMap: {},
description: 'Point of Contact for Opportuniites',
icon: 'IconTargetArrow',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'activityTargets',
label: 'Activities',
targetColumnMap: {},
description: 'Activities tied to the contact',
icon: 'IconCheckbox',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the contact.',
icon: 'IconTargetArrow',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the contact',
icon: 'IconHeart',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedPersonFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Attachments linked to the contact.',
icon: 'IconFileImport',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,177 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedPipelineStepFieldMetadataIds {
Id = '20202020-039a-4fbd-b4c1-66dfa9e4bd3f',
CreatedAt = '20202020-816f-4861-9b36-4a2f8ae2791c',
UpdatedAt = '20202020-2d73-4829-b774-522c2f5627d7',
Name = '20202020-f294-430e-b800-3a411fc05ad3',
Color = '20202020-5b93-4b28-8c45-7988ea68f91b',
Position = '20202020-6296-4cab-aafb-121ef5822b13',
Opportunities = '20202020-22c4-443a-b114-43c97dda5867',
}
export const seedPipelineStepFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedPipelineStepFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedPipelineStepFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedPipelineStepFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Main Identifier
{
id: SeedPipelineStepFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'Pipeline Step name',
icon: 'IconCurrencyDollar',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
// Scalar Fields
{
id: SeedPipelineStepFieldMetadataIds.Color,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'color',
label: 'Color',
targetColumnMap: {
value: 'color',
},
description: 'Pipeline Step color',
icon: 'IconColorSwatch',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedPipelineStepFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.NUMBER,
name: 'position',
label: 'Position',
targetColumnMap: {
value: 'position',
},
description: 'Pipeline Step position',
icon: 'IconHierarchy2',
isNullable: false,
isSystem: false,
defaultValue: { value: 0 },
},
// Relationships
{
id: SeedPipelineStepFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the step.',
icon: 'IconTargetArrow',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,209 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFieldFieldMetadataIds {
Id = '20202020-64f2-4ecf-b4c5-45daf154756a',
CreatedAt = '20202020-e137-4e59-b417-a134c050936c',
UpdatedAt = '20202020-17ff-4585-9f3b-cd9ee9523448',
FieldMetadataId = '20202020-1a5e-4ac1-9530-c7fff8481b79',
IsVisible = '20202020-3aa9-42db-a74d-0fd6b7cb7c4a',
Size = '20202020-b9a1-4c2e-a5af-3a6b4fef4af6',
Position = '20202020-a4bb-440a-add2-81dbd9a74517',
View = '20202020-8788-4508-b771-719807b60e61',
ViewForeignKey = '20202020-c852-4c28-b13a-07788c845d6a',
}
export const seedViewFieldFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedViewFieldFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedViewFieldFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedViewFieldFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Fields
{
id: SeedViewFieldFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
value: 'fieldMetadataId',
},
description: 'View Field target field',
icon: 'IconTag',
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFieldFieldMetadataIds.View,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'view',
label: 'View Id',
targetColumnMap: {},
description: 'View Field related view',
icon: 'IconLayoutCollage',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFieldFieldMetadataIds.ViewForeignKey,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'viewId',
label: 'View ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for view',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedViewFieldFieldMetadataIds.IsVisible,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.BOOLEAN,
name: 'isVisible',
label: 'Visible',
targetColumnMap: {
value: 'isVisible',
},
description: 'View Field visibility',
icon: 'IconEye',
isNullable: false,
isSystem: false,
defaultValue: { value: true },
},
{
id: SeedViewFieldFieldMetadataIds.Size,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.NUMBER,
name: 'size',
label: 'Size',
targetColumnMap: {
value: 'size',
},
description: 'View Field size',
icon: 'IconEye',
isNullable: false,
isSystem: false,
defaultValue: { value: 0 },
},
{
id: SeedViewFieldFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.NUMBER,
name: 'position',
label: 'Position',
targetColumnMap: {
value: 'position',
},
description: 'View Field position',
icon: 'IconList',
isNullable: false,
isSystem: false,
defaultValue: { value: 0 },
},
])
.execute();
};

View File

@ -1,209 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFilterFieldMetadataIds {
Id = '20202020-353c-4fb0-9011-1ad8e1dd67f9',
CreatedAt = '20202020-da57-452d-9671-ab3ccac2a9da',
UpdatedAt = '20202020-96c9-4cf1-87b4-8a009c591a16',
FieldMetadataId = '20202020-78bb-4f2b-a052-260bc8efd694',
View = '20202020-65e5-4082-829d-8c634c20e7b5',
ViewForeignKey = '20202020-c852-4c28-b13a-07788c845d6b',
Operand = '20202020-1d12-465d-ab2c-8af008182730',
Value = '20202020-8b37-46ae-86b8-14287ec06802',
DisplayValue = '20202020-ed89-4892-83fa-d2b2929c6d52',
}
export const seedViewFilterFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedViewFilterFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedViewFilterFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedViewFilterFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Fields
{
id: SeedViewFilterFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
value: 'fieldMetadataId',
},
description: 'View Filter target field',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFilterFieldMetadataIds.View,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'view',
label: 'View',
targetColumnMap: {},
description: 'View Filter related view',
icon: 'IconLayoutCollage',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFilterFieldMetadataIds.ViewForeignKey,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'viewId',
label: 'View ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for view',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedViewFilterFieldMetadataIds.Operand,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'operand',
label: 'Operand',
targetColumnMap: {
value: 'operand',
},
description: 'View Filter operand',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: 'Contains' },
},
{
id: SeedViewFilterFieldMetadataIds.Value,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'value',
label: 'Value',
targetColumnMap: {
value: 'value',
},
description: 'View Filter value',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedViewFilterFieldMetadataIds.DisplayValue,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'displayValue',
label: 'Display Value',
targetColumnMap: {
value: 'displayValue',
},
description: 'View Filter Display Value',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
])
.execute();
};

View File

@ -1,171 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewSortFieldMetadataIds {
Id = '20202020-5870-4665-92a6-a39b7f53352d',
CreatedAt = '20202020-7677-4955-8ffe-06481534d12c',
UpdatedAt = '20202020-16ec-4074-a54b-c8f7f1178cf6',
FieldMetadataId = '20202020-cb2c-4c8f-a289-c9851b23d064',
View = '20202020-f5d0-467f-a3d8-395ba16b8ebf',
ViewForeignKey = '20202020-c852-4c28-b13a-07788c845d6c',
Direction = '20202020-077e-4451-b1d8-e602c956ebd2',
}
export const seedViewSortFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedViewSortFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedViewSortFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedViewSortFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Fields
{
id: SeedViewSortFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'fieldMetadataId',
label: 'Field Metadata Id',
targetColumnMap: {
value: 'fieldMetadataId',
},
description: 'View Sort target field',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewSortFieldMetadataIds.View,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'view',
label: 'View',
targetColumnMap: {},
description: 'View Sort related view',
icon: 'IconLayoutCollage',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewSortFieldMetadataIds.ViewForeignKey,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'viewId',
label: 'View ID (foreign key)',
targetColumnMap: {},
description: 'Foreign key for view',
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: undefined,
},
{
id: SeedViewSortFieldMetadataIds.Direction,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'direction',
label: 'Direction',
targetColumnMap: {
value: 'direction',
},
description: 'View Sort direction',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: 'asc' },
},
])
.execute();
};

View File

@ -1,207 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFieldMetadataIds {
Id = '20202020-2957-4431-b3b5-879b5e687c6e',
CreatedAt = '20202020-ad91-42b0-b654-cbd981ddb5bf',
UpdatedAt = '20202020-b4e6-4044-8f6e-886c6eb2a67c',
Name = '20202020-e10e-4346-8690-b2e582ebc03c',
ObjectMetadataId = '20202020-2c69-46f0-9cf2-1a4f9869d560',
Type = '20202020-2c70-46f0-9cf2-1a4f9869d591',
ViewFields = '20202020-d288-4df4-9548-7b5c5747f623',
ViewSorts = '20202020-3011-4d5c-8133-c01134e733df',
ViewFilters = '20202020-afe8-40bc-9a81-9b33e45131d9',
}
export const seedViewFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedViewFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedViewFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedViewFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Fields
{
id: SeedViewFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'View name',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedViewFieldMetadataIds.ObjectMetadataId,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'objectMetadataId',
label: 'Object Metadata Id',
targetColumnMap: {
value: 'objectMetadataId',
},
description: 'View target object',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'type',
label: 'Type',
targetColumnMap: {
value: 'type',
},
description: 'View type',
icon: null,
isNullable: false,
isSystem: false,
defaultValue: { value: 'table' },
},
{
id: SeedViewFieldMetadataIds.ViewFields,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'viewFields',
label: 'View Fields',
targetColumnMap: {},
description: 'View Fields',
icon: 'IconTag',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFieldMetadataIds.ViewSorts,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'viewSorts',
label: 'View Sorts',
targetColumnMap: {},
description: 'View Sorts',
icon: 'IconArrowsSort',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedViewFieldMetadataIds.ViewFilters,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'viewFilters',
label: 'View Filters',
targetColumnMap: {},
description: 'View Filters',
icon: 'IconFilterBolt',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,137 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedWebhookFieldMetadataIds {
Id = '20202020-bc24-4387-8abe-9fbe7849f820',
CreatedAt = '20202020-c643-4324-9032-f38117fbca3b',
UpdatedAt = '20202020-489b-4f1d-80a4-2dddf6fa0e7c',
TargetUrl = '20202020-c16e-4ba8-bb24-bbd88e9cdabc',
Operation = '20202020-5995-493a-92a8-31376e5c052a',
}
export const seedWebhookFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedWebhookFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedWebhookFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedWebhookFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedWebhookFieldMetadataIds.TargetUrl,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'targetUrl',
label: 'Target Url',
targetColumnMap: {
value: 'targetUrl',
},
description: 'Webhook target url',
icon: 'IconLink',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
{
id: SeedWebhookFieldMetadataIds.Operation,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'operation',
label: 'Operation',
targetColumnMap: {
value: 'operation',
},
description: 'Webhook operation',
icon: 'IconCheckbox',
isNullable: false,
isSystem: false,
defaultValue: { value: '' },
},
])
.execute();
};

View File

@ -1,300 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedWorkspaceMemberFieldMetadataIds {
Id = '20202020-678e-4702-a535-2549ef07f1ca',
CreatedAt = '20202020-1cbf-4b32-8c33-fbfedcd9afa8',
UpdatedAt = '20202020-1ba3-4c24-b2cd-b0789633e8d4',
Name = '20202020-8c37-4163-ba06-1dada334ce3e',
AvatarUrl = '20202020-7ba6-40d5-934b-17146183a212',
Locale = '20202020-10f6-4df9-8d6f-a760b65bd800',
ColorScheme = '20202020-83f2-4c5f-96b0-0c51ecc160e3',
UserId = '20202020-f2c1-4ca1-9ca5-7b9d5cc87eb0',
AuthoredActivities = '20202020-37a0-4db4-9c9f-fd3e3f4e47fc',
AssignedActivities = '20202020-ac05-44b9-9526-764dd5ce14e2',
AuthoredAttachments = '20202020-7e0c-4dc4-be49-37de4396349e',
Favorites = '20202020-5ecb-405b-8712-171bb8916b96',
Settings = '20202020-50ed-46ed-8198-65e237b83eb9',
AccountOwnerForCompanies = '20202020-41bb-4c17-8979-40fa915df9e1',
AuthoredComments = '20202020-7238-4e2a-9ccf-d2c8f604933a',
}
export const seedWorkspaceMemberFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
'isSystem',
'defaultValue',
])
.orIgnore()
.values([
// Default fields
{
id: SeedWorkspaceMemberFieldMetadataIds.Id,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'id',
label: 'Id',
targetColumnMap: {
value: 'id',
},
description: undefined,
icon: undefined,
isNullable: false,
isSystem: true,
defaultValue: { type: 'uuid' },
},
{
id: SeedWorkspaceMemberFieldMetadataIds.CreatedAt,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'createdAt',
label: 'Creation date',
targetColumnMap: {
value: 'createdAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
{
id: SeedWorkspaceMemberFieldMetadataIds.UpdatedAt,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.DATE_TIME,
name: 'updatedAt',
label: 'Update date',
targetColumnMap: {
value: 'updatedAt',
},
description: undefined,
icon: 'IconCalendar',
isNullable: false,
isSystem: true,
defaultValue: { type: 'now' },
},
// Scalar fields
{
id: SeedWorkspaceMemberFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.FULL_NAME,
name: 'name',
label: 'Name',
targetColumnMap: {
firstName: 'nameFirstName',
lastName: 'nameLastName',
},
description: 'Workspace member name',
icon: 'IconCircleUser',
isNullable: false,
isSystem: false,
defaultValue: { firstName: '', lastName: '' },
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AvatarUrl,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'avatarUrl',
label: 'Avatar Url',
targetColumnMap: {
value: 'avatarUrl',
},
description: 'Workspace member avatar',
icon: 'IconFileUpload',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.UserId,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.UUID,
name: 'userId',
label: 'User Id',
targetColumnMap: {
value: 'userId',
},
description: 'Associated User Id',
icon: 'IconCircleUsers',
isNullable: false,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.ColorScheme,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'colorScheme',
label: 'Color Scheme',
targetColumnMap: {
value: 'colorScheme',
},
description: 'Preferred color scheme',
icon: 'IconColorSwatch',
isNullable: true,
isSystem: false,
defaultValue: { value: 'Light' },
},
{
id: SeedWorkspaceMemberFieldMetadataIds.Locale,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.TEXT,
name: 'locale',
label: 'Language',
targetColumnMap: {
value: 'locale',
},
description: 'Preferred language',
icon: 'IconLanguage',
isNullable: false,
isSystem: false,
defaultValue: { value: 'en' },
},
// Relationships
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredActivities,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'authoredActivities',
label: 'Authored activities',
targetColumnMap: {},
description: 'Activities created by the workspace member',
icon: 'IconCheckbox',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AssignedActivities,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'assignedActivities',
label: 'Assigned activities',
targetColumnMap: {},
description: 'Activities assigned to the workspace member',
icon: 'IconCheckbox',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the workspace member',
icon: 'IconHeart',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AccountOwnerForCompanies,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'accountOwnerForCompanies',
label: 'Account Owner For Companies',
targetColumnMap: {},
description: 'Account owner for companies',
icon: 'IconBriefcase',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredAttachments,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'authoredAttachments',
label: 'Authored attachments',
targetColumnMap: {},
description: 'Attachments created by the workspace member',
icon: 'IconFileImport',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredComments,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: FieldMetadataType.RELATION,
name: 'authoredComments',
label: 'Authored comments',
targetColumnMap: {},
description: 'Authored comments',
icon: 'IconComment',
isNullable: true,
isSystem: false,
defaultValue: undefined,
},
])
.execute();
};

View File

@ -1,58 +0,0 @@
import { DataSource } from 'typeorm';
import { seedCompanyFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
import { seedViewFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view';
import { seedViewFieldFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view-field';
import { seedViewFilterFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view-filter';
import { seedViewSortFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view-sort';
import { seedObjectMetadata } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { seedViewRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/view';
import { seedActivityTargetFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/activity-target';
import { seedActivityFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/activity';
import { seedApiKeyFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/api-key';
import { seedAttachmentFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/attachment';
import { seedCommentFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/comment';
import { seedFavoriteFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/favorite';
import { seedOpportunityFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/opportunity';
import { seedPersonFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/person';
import { seedPipelineStepFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/pipeline-step';
import { seedWorkspaceMemberFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/workspace-member';
import { seedCompanyRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/company';
import { seedActivityRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/activity';
import { seedPipelineStepRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/pipeline-step';
import { seedPersonRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/person';
import { seedWorkspaceMemberRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/workspace-member';
import { seedDataSource } from 'src/database/typeorm-seeds/metadata/data-source';
import { seedWebhookFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/webhook';
export const seedMetadataSchema = async (workspaceDataSource: DataSource) => {
const schemaName = 'metadata';
await seedDataSource(workspaceDataSource, schemaName);
await seedObjectMetadata(workspaceDataSource, schemaName);
await seedActivityTargetFieldMetadata(workspaceDataSource, schemaName);
await seedActivityFieldMetadata(workspaceDataSource, schemaName);
await seedApiKeyFieldMetadata(workspaceDataSource, schemaName);
await seedAttachmentFieldMetadata(workspaceDataSource, schemaName);
await seedWebhookFieldMetadata(workspaceDataSource, schemaName);
await seedCommentFieldMetadata(workspaceDataSource, schemaName);
await seedCompanyFieldMetadata(workspaceDataSource, schemaName);
await seedFavoriteFieldMetadata(workspaceDataSource, schemaName);
await seedOpportunityFieldMetadata(workspaceDataSource, schemaName);
await seedPersonFieldMetadata(workspaceDataSource, schemaName);
await seedPipelineStepFieldMetadata(workspaceDataSource, schemaName);
await seedViewFieldMetadata(workspaceDataSource, schemaName);
await seedViewFieldFieldMetadata(workspaceDataSource, schemaName);
await seedViewFilterFieldMetadata(workspaceDataSource, schemaName);
await seedViewSortFieldMetadata(workspaceDataSource, schemaName);
await seedViewRelationMetadata(workspaceDataSource, schemaName);
await seedWorkspaceMemberFieldMetadata(workspaceDataSource, schemaName);
await seedActivityRelationMetadata(workspaceDataSource, schemaName);
await seedCompanyRelationMetadata(workspaceDataSource, schemaName);
await seedPersonRelationMetadata(workspaceDataSource, schemaName);
await seedPipelineStepRelationMetadata(workspaceDataSource, schemaName);
await seedViewRelationMetadata(workspaceDataSource, schemaName);
await seedWorkspaceMemberRelationMetadata(workspaceDataSource, schemaName);
};

View File

@ -1,306 +0,0 @@
import { DataSource } from 'typeorm';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
import { SeedDataSourceId } from 'src/database/typeorm-seeds/metadata/data-source';
import { SeedCompanyFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
import { SeedPersonFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/person';
const tableName = 'objectMetadata';
export enum SeedObjectMetadataIds {
Company = '20202020-480c-434e-b4c7-e22408b97047',
Person = '20202020-c64b-44bc-bd2c-502c99f49dca',
Opportunity = '20202020-cae9-4ff4-9579-f7d9fe44c937',
PipelineStep = '20202020-1029-4661-9e91-83bad932bdcd',
WorkspaceMember = '20202020-b550-40bb-a96b-9ab54b664753',
Webhook = '20202020-ddee-40de-9c9b-5f82a3503360',
ApiKey = '20202020-d8d0-4c2d-a370-5499b2181d02',
Activity = '20202020-8ee3-4f67-84ab-1b7a6eb5a448',
ActivityTarget = '20202020-439a-4a41-83a3-3cda03d01d38',
Comment = '20202020-4de3-4e65-ac60-b40b8e08d7d6',
Attachment = '20202020-5f98-4317-915d-3779bb821be2',
Favorite = '20202020-90e4-4701-a350-8ab75e23e3b8',
View = '20202020-767f-473f-8fd0-6cdbefbf8dbe',
ViewField = '20202020-485c-4c48-a22e-0d9a164f9647',
ViewFilter = '20202020-4461-4e2d-bf9e-9b47e68846d3',
ViewSort = '20202020-cf28-41dd-b98b-d6e1f5b3a251',
}
export const seedObjectMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'id',
'nameSingular',
'namePlural',
'labelSingular',
'labelPlural',
'targetTableName',
'description',
'icon',
'dataSourceId',
'workspaceId',
'isActive',
'isSystem',
'labelIdentifierFieldMetadataId',
'imageIdentifierFieldMetadataId',
])
.orIgnore()
.values([
{
id: SeedObjectMetadataIds.Company,
nameSingular: 'company',
namePlural: 'companies',
labelSingular: 'Company',
labelPlural: 'Companies',
targetTableName: 'company',
description: 'A company',
icon: 'IconBuildingSkyscraper',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: false,
labelIdentifierFieldMetadataId: SeedCompanyFieldMetadataIds.Name,
imageIdentifierFieldMetadataId: SeedCompanyFieldMetadataIds.DomainName,
},
{
id: SeedObjectMetadataIds.Person,
nameSingular: 'person',
namePlural: 'people',
labelSingular: 'Person',
labelPlural: 'People',
targetTableName: 'person',
description: 'A person',
icon: 'IconUser',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: false,
labelIdentifierFieldMetadataId: SeedPersonFieldMetadataIds.Email,
imageIdentifierFieldMetadataId: SeedPersonFieldMetadataIds.AvatarUrl,
},
])
.execute();
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'id',
'nameSingular',
'namePlural',
'labelSingular',
'labelPlural',
'targetTableName',
'description',
'icon',
'dataSourceId',
'workspaceId',
'isActive',
'isSystem',
])
.orIgnore()
.values([
{
id: SeedObjectMetadataIds.Opportunity,
nameSingular: 'opportunity',
namePlural: 'opportunities',
labelSingular: 'Opportunity',
labelPlural: 'Opportunities',
targetTableName: 'opportunity',
description: 'An opportunity',
icon: 'IconTargetArrow',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: false,
},
{
id: SeedObjectMetadataIds.PipelineStep,
nameSingular: 'pipelineStep',
namePlural: 'pipelineSteps',
labelSingular: 'Pipeline Step',
labelPlural: 'Pipeline Steps',
targetTableName: 'pipelineStep',
description: 'A pipeline step',
icon: 'IconLayoutKanban',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.WorkspaceMember,
nameSingular: 'workspaceMember',
namePlural: 'workspaceMembers',
labelSingular: 'Workspace Member',
labelPlural: 'Workspace Members',
targetTableName: 'workspaceMember',
description: 'A workspace member',
icon: 'IconUserCircle',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.Webhook,
nameSingular: 'webhook',
namePlural: 'webhooks',
labelSingular: 'Webhook',
labelPlural: 'Webhooks',
targetTableName: 'webhook',
description: 'A webhook',
icon: 'IconRobot',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.ApiKey,
nameSingular: 'apiKey',
namePlural: 'apiKeys',
labelSingular: 'Api Key',
labelPlural: 'Api Keys',
targetTableName: 'apiKey',
description: 'An api key',
icon: 'IconRobot',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.Activity,
nameSingular: 'activity',
namePlural: 'activities',
labelSingular: 'Activity',
labelPlural: 'Activities',
targetTableName: 'activity',
description: 'An activity',
icon: 'IconCheckbox',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.ActivityTarget,
nameSingular: 'activityTarget',
namePlural: 'activityTargets',
labelSingular: 'Activity Target',
labelPlural: 'Activity Targets',
targetTableName: 'activityTarget',
description: 'An activity target',
icon: 'IconCheckbox',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.Comment,
nameSingular: 'comment',
namePlural: 'comments',
labelSingular: 'Comment',
labelPlural: 'Comments',
targetTableName: 'comment',
description: 'A comment',
icon: 'IconMessageCircle',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.Attachment,
nameSingular: 'attachment',
namePlural: 'attachments',
labelSingular: 'Attachment',
labelPlural: 'Attachments',
targetTableName: 'attachment',
description: 'An attachment',
icon: 'IconFileImport',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.Favorite,
nameSingular: 'favorite',
namePlural: 'favorites',
labelSingular: 'Favorite',
labelPlural: 'Favorites',
targetTableName: 'favorite',
description: 'A favorite',
icon: 'IconHeart',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.View,
nameSingular: 'view',
namePlural: 'views',
labelSingular: 'View',
labelPlural: 'Views',
targetTableName: 'view',
description: '(System) Views',
icon: 'IconLayoutCollage',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.ViewField,
nameSingular: 'viewField',
namePlural: 'viewFields',
labelSingular: 'View Field',
labelPlural: 'View Fields',
targetTableName: 'viewField',
description: '(System) View Fields',
icon: 'IconTag',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.ViewFilter,
nameSingular: 'viewFilter',
namePlural: 'viewFilters',
labelSingular: 'View Filter',
labelPlural: 'View Filters',
targetTableName: 'viewFilter',
description: '(System) View Filters',
icon: 'IconFilterBolt',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
{
id: SeedObjectMetadataIds.ViewSort,
nameSingular: 'viewSort',
namePlural: 'viewSorts',
labelSingular: 'View Sort',
labelPlural: 'View Sorts',
targetTableName: 'viewSort',
description: '(System) View Sorts',
icon: 'IconArrowsSort',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
isSystem: true,
},
])
.execute();
};

View File

@ -1,56 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedActivityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/activity';
import { SeedActivityTargetFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/activity-target';
import { SeedAttachmentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/attachment';
import { SeedCommentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/comment';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedActivityRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Activity,
toObjectMetadataId: SeedObjectMetadataIds.ActivityTarget,
fromFieldMetadataId: SeedActivityFieldMetadataIds.ActivityTargets,
toFieldMetadataId: SeedActivityTargetFieldMetadataIds.Activity,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Activity,
toObjectMetadataId: SeedObjectMetadataIds.Attachment,
fromFieldMetadataId: SeedActivityFieldMetadataIds.Attachments,
toFieldMetadataId: SeedAttachmentFieldMetadataIds.Activity,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Activity,
toObjectMetadataId: SeedObjectMetadataIds.Comment,
fromFieldMetadataId: SeedActivityFieldMetadataIds.Comments,
toFieldMetadataId: SeedCommentFieldMetadataIds.Activity,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,74 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedCompanyFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
import { SeedPersonFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/person';
import { SeedFavoriteFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/favorite';
import { SeedAttachmentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/attachment';
import { SeedOpportunityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/opportunity';
import { SeedActivityTargetFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/activity-target';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedCompanyRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Company,
toObjectMetadataId: SeedObjectMetadataIds.Person,
fromFieldMetadataId: SeedCompanyFieldMetadataIds.People,
toFieldMetadataId: SeedPersonFieldMetadataIds.Company,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Company,
toObjectMetadataId: SeedObjectMetadataIds.Favorite,
fromFieldMetadataId: SeedCompanyFieldMetadataIds.Favorites,
toFieldMetadataId: SeedFavoriteFieldMetadataIds.Company,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Company,
toObjectMetadataId: SeedObjectMetadataIds.Attachment,
fromFieldMetadataId: SeedCompanyFieldMetadataIds.Attachments,
toFieldMetadataId: SeedAttachmentFieldMetadataIds.Company,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Company,
toObjectMetadataId: SeedObjectMetadataIds.Opportunity,
fromFieldMetadataId: SeedCompanyFieldMetadataIds.Opportunities,
toFieldMetadataId: SeedOpportunityFieldMetadataIds.Company,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Company,
toObjectMetadataId: SeedObjectMetadataIds.ActivityTarget,
fromFieldMetadataId: SeedCompanyFieldMetadataIds.ActivityTargets,
toFieldMetadataId: SeedActivityTargetFieldMetadataIds.Company,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,73 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedFavoriteFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/favorite';
import { SeedPersonFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/person';
import { SeedActivityTargetFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/activity-target';
import { SeedAttachmentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/attachment';
import { SeedOpportunityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/opportunity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedPersonRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Person,
toObjectMetadataId: SeedObjectMetadataIds.Favorite,
fromFieldMetadataId: SeedPersonFieldMetadataIds.Favorites,
toFieldMetadataId: SeedFavoriteFieldMetadataIds.Person,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Person,
toObjectMetadataId: SeedObjectMetadataIds.Attachment,
fromFieldMetadataId: SeedPersonFieldMetadataIds.Attachments,
toFieldMetadataId: SeedAttachmentFieldMetadataIds.Person,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Person,
toObjectMetadataId: SeedObjectMetadataIds.Opportunity,
fromFieldMetadataId: SeedPersonFieldMetadataIds.Opportunities,
toFieldMetadataId: SeedOpportunityFieldMetadataIds.Person,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Person,
toObjectMetadataId: SeedObjectMetadataIds.Opportunity,
fromFieldMetadataId: SeedPersonFieldMetadataIds.ContactForOpportunities,
toFieldMetadataId: SeedOpportunityFieldMetadataIds.PointOfContact,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.Person,
toObjectMetadataId: SeedObjectMetadataIds.ActivityTarget,
fromFieldMetadataId: SeedPersonFieldMetadataIds.ActivityTargets,
toFieldMetadataId: SeedActivityTargetFieldMetadataIds.Person,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,38 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedPipelineStepFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/pipeline-step';
import { SeedOpportunityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/opportunity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedPipelineStepRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.PipelineStep,
toObjectMetadataId: SeedObjectMetadataIds.Opportunity,
fromFieldMetadataId: SeedPipelineStepFieldMetadataIds.Opportunities,
toFieldMetadataId: SeedOpportunityFieldMetadataIds.PipelineStep,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,56 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedViewFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view';
import { SeedViewFieldFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view-field';
import { SeedViewFilterFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view-filter';
import { SeedViewSortFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view-sort';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedViewRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.View,
toObjectMetadataId: SeedObjectMetadataIds.ViewField,
fromFieldMetadataId: SeedViewFieldMetadataIds.ViewFields,
toFieldMetadataId: SeedViewFieldFieldMetadataIds.View,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.View,
toObjectMetadataId: SeedObjectMetadataIds.ViewFilter,
fromFieldMetadataId: SeedViewFieldMetadataIds.ViewFilters,
toFieldMetadataId: SeedViewFilterFieldMetadataIds.View,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.View,
toObjectMetadataId: SeedObjectMetadataIds.ViewSort,
fromFieldMetadataId: SeedViewFieldMetadataIds.ViewSorts,
toFieldMetadataId: SeedViewSortFieldMetadataIds.View,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,87 +0,0 @@
import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedCompanyFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
import { SeedWorkspaceMemberFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/workspace-member';
import { SeedFavoriteFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/favorite';
import { SeedActivityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/activity';
import { SeedCommentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/comment';
import { SeedAttachmentFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/attachment';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'relationMetadata';
export const seedWorkspaceMemberRelationMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'relationType',
'fromObjectMetadataId',
'toObjectMetadataId',
'fromFieldMetadataId',
'toFieldMetadataId',
'workspaceId',
])
.orIgnore()
.values([
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Company,
fromFieldMetadataId:
SeedWorkspaceMemberFieldMetadataIds.AccountOwnerForCompanies,
toFieldMetadataId: SeedCompanyFieldMetadataIds.AccountOwner,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Favorite,
fromFieldMetadataId: SeedWorkspaceMemberFieldMetadataIds.Favorites,
toFieldMetadataId: SeedFavoriteFieldMetadataIds.WorkspaceMember,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Activity,
fromFieldMetadataId:
SeedWorkspaceMemberFieldMetadataIds.AuthoredActivities,
toFieldMetadataId: SeedActivityFieldMetadataIds.Author,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Activity,
fromFieldMetadataId:
SeedWorkspaceMemberFieldMetadataIds.AssignedActivities,
toFieldMetadataId: SeedActivityFieldMetadataIds.Assignee,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Comment,
fromFieldMetadataId:
SeedWorkspaceMemberFieldMetadataIds.AuthoredComments,
toFieldMetadataId: SeedCommentFieldMetadataIds.Author,
workspaceId: SeedWorkspaceId,
},
{
relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.Attachment,
fromFieldMetadataId:
SeedWorkspaceMemberFieldMetadataIds.AuthoredAttachments,
toFieldMetadataId: SeedAttachmentFieldMetadataIds.Author,
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -23,6 +23,7 @@ export const seedWorkspaceMember = async (
'nameLastName',
'locale',
'colorScheme',
'userEmail',
'userId',
])
.orIgnore()
@ -33,6 +34,7 @@ export const seedWorkspaceMember = async (
nameLastName: 'Apple',
locale: 'en',
colorScheme: 'Light',
userEmail: 'tim@apple.dev',
userId: SeedUserIds.Tim,
},
{
@ -41,6 +43,7 @@ export const seedWorkspaceMember = async (
nameLastName: 'Ive',
locale: 'en',
colorScheme: 'Light',
userEmail: 'jony.ive@apple.dev',
userId: SeedUserIds.Jony,
},
{
@ -49,6 +52,7 @@ export const seedWorkspaceMember = async (
nameLastName: 'Shiler',
locale: 'en',
colorScheme: 'Light',
userEmail: 'phil.schiler@apple.dev',
userId: SeedUserIds.Phil,
},
])

View File

@ -10,13 +10,16 @@ import {
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
type DataSourceType = DataSourceOptions['type'];
export type DataSourceType = DataSourceOptions['type'];
@Entity('dataSource')
export class DataSourceEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: true })
label: string;
@Column({ nullable: true })
url: string;
@ -26,9 +29,6 @@ export class DataSourceEntity {
@Column({ type: 'enum', enum: ['postgres'], default: 'postgres' })
type: DataSourceType;
@Column({ nullable: true, name: 'label' })
label: string;
@Column({ default: false })
isRemote: boolean;

View File

@ -94,6 +94,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
{
name: objectMetadata.targetTableName,
action: 'alter',
schemaName: objectMetadata.dataSource.schema,
columns: this.workspaceMigrationFactory.createColumnActions(
WorkspaceMigrationColumnActionType.CREATE,
createdFieldMetadata,
@ -204,6 +205,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
{
name: objectMetadata.targetTableName,
action: 'alter',
schemaName: objectMetadata.dataSource.schema,
columns: this.workspaceMigrationFactory.createColumnActions(
WorkspaceMigrationColumnActionType.ALTER,
existingFieldMetadata,

View File

@ -230,11 +230,13 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
{
name: createdObjectMetadata.targetTableName,
action: 'create',
schemaName: createdObjectMetadata.dataSource.schema,
} satisfies WorkspaceMigrationTableAction,
// Add activity target relation
{
name: activityTargetObjectMetadata.targetTableName,
action: 'alter',
schemaName: activityTargetObjectMetadata.dataSource.schema,
columns: [
{
action: WorkspaceMigrationColumnActionType.CREATE,
@ -247,6 +249,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
{
name: activityTargetObjectMetadata.targetTableName,
action: 'alter',
schemaName: activityTargetObjectMetadata.dataSource.schema,
columns: [
{
action: WorkspaceMigrationColumnActionType.RELATION,
@ -260,6 +263,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
{
name: createdObjectMetadata.targetTableName,
action: 'alter',
schemaName: createdObjectMetadata.dataSource.schema,
columns: [
{
action: WorkspaceMigrationColumnActionType.CREATE,
@ -313,16 +317,16 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
options: FindOneOptions<ObjectMetadataEntity>,
): Promise<ObjectMetadataEntity | null> {
return this.objectMetadataRepository.findOne({
...options,
where: {
...options.where,
workspaceId,
},
relations: [
'fields',
'fields.fromRelationMetadata',
'fields.toRelationMetadata',
],
...options,
where: {
...options.where,
workspaceId,
},
});
}
@ -331,17 +335,17 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
options?: FindManyOptions<ObjectMetadataEntity>,
) {
return this.objectMetadataRepository.find({
...options,
where: {
...options?.where,
workspaceId,
},
relations: [
'fields',
'fields.fromRelationMetadata',
'fields.toRelationMetadata',
'fields.fromRelationMetadata.toObjectMetadata',
],
...options,
where: {
...options?.where,
workspaceId,
},
});
}

View File

@ -200,6 +200,9 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
name: objectMetadataMap[relationMetadataInput.toObjectMetadataId]
.targetTableName,
action: 'alter',
schemaName:
objectMetadataMap[relationMetadataInput.toObjectMetadataId]
.dataSource.schema,
columns: [
{
action: WorkspaceMigrationColumnActionType.CREATE,
@ -214,6 +217,9 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
name: objectMetadataMap[relationMetadataInput.toObjectMetadataId]
.targetTableName,
action: 'alter',
schemaName:
objectMetadataMap[relationMetadataInput.toObjectMetadataId]
.dataSource.schema,
columns: [
{
action: WorkspaceMigrationColumnActionType.RELATION,

View File

@ -1,84 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addCompanyTable: WorkspaceMigrationTableAction[] = [
{
name: 'company',
action: 'create',
},
{
name: 'company',
action: 'alter',
columns: [
{
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'domainName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'address',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'employees',
columnType: 'integer',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'linkedinLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'annualRecurringRevenueAmountMicros',
columnType: 'numeric',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'annualRecurringRevenueCurrencyCode',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'idealCustomerProfile',
columnType: 'boolean',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'accountOwnerId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,34 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addViewTable: WorkspaceMigrationTableAction[] = [
{
name: 'view',
action: 'create',
},
{
name: 'view',
action: 'alter',
columns: [
{
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'objectMetadataId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'table'",
},
],
},
];

View File

@ -1,51 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addViewFieldTable: WorkspaceMigrationTableAction[] = [
{
name: 'viewField',
action: 'create',
},
{
name: 'viewField',
action: 'alter',
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'position',
columnType: 'float',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 0,
},
{
columnName: 'isVisible',
columnType: 'boolean',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: true,
},
{
columnName: 'size',
columnType: 'integer',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 0,
},
{
columnName: 'viewId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'viewId',
referencedTableName: 'view',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,51 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addViewFilterTable: WorkspaceMigrationTableAction[] = [
{
name: 'viewFilter',
action: 'create',
},
{
name: 'viewFilter',
action: 'alter',
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'operand',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'Contains'",
},
{
columnName: 'value',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'displayValue',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'viewId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'viewId',
referencedTableName: 'view',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,39 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addViewSortTable: WorkspaceMigrationTableAction[] = [
{
name: 'viewSort',
action: 'create',
},
{
name: 'viewSort',
action: 'alter',
columns: [
{
columnName: 'fieldMetadataId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'direction',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'asc'",
},
{
columnName: 'viewId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'viewId',
referencedTableName: 'view',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,32 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addActivityTargetTable: WorkspaceMigrationTableAction[] = [
{
name: 'activityTarget',
action: 'create',
},
{
name: 'activityTarget',
action: 'alter',
columns: [
{
columnName: 'companyId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'activityId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'personId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,60 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addActivityTable: WorkspaceMigrationTableAction[] = [
{
name: 'activity',
action: 'create',
},
{
name: 'activity',
action: 'alter',
columns: [
{
columnName: 'title',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'body',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'{}'",
},
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'Note'",
},
{
columnName: 'reminderAt',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'dueAt',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'completedAt',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'authorId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'assigneeId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,33 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addApiKeyTable: WorkspaceMigrationTableAction[] = [
{
name: 'apiKey',
action: 'create',
},
{
name: 'apiKey',
action: 'alter',
columns: [
{
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'revokedAt',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'expiresAt',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,55 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addAttachmentTable: WorkspaceMigrationTableAction[] = [
{
name: 'attachment',
action: 'create',
},
{
name: 'attachment',
action: 'alter',
columns: [
{
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'fullPath',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'companyId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'authorId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'activityId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'personId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,33 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addCommentTable: WorkspaceMigrationTableAction[] = [
{
name: 'comment',
action: 'create',
},
{
name: 'comment',
action: 'alter',
columns: [
{
columnName: 'body',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'authorId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'activityId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,38 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addFavoriteTable: WorkspaceMigrationTableAction[] = [
{
name: 'favorite',
action: 'create',
},
{
name: 'favorite',
action: 'alter',
columns: [
{
columnName: 'position',
columnType: 'float',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 0,
},
{
columnName: 'companyId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'personId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'workspaceMemberId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,58 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addOpportunityTable: WorkspaceMigrationTableAction[] = [
{
name: 'opportunity',
action: 'create',
},
{
name: 'opportunity',
action: 'alter',
columns: [
{
columnName: 'amountAmountMicros',
columnType: 'numeric',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'amountCurrencyCode',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'probability',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'0'",
},
{
columnName: 'closeDate',
columnType: 'timestamp',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'companyId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'personId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'pipelineStepId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'pointOfContactId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,88 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addPersonTable: WorkspaceMigrationTableAction[] = [
{
name: 'person',
action: 'create',
},
{
name: 'person',
action: 'alter',
columns: [
{
columnName: 'nameFirstName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'nameLastName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'email',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'jobTitle',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'phone',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'city',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'avatarUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'companyId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,35 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addPipelineStepTable: WorkspaceMigrationTableAction[] = [
{
name: 'pipelineStep',
action: 'create',
},
{
name: 'pipelineStep',
action: 'alter',
columns: [
{
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'color',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'position',
columnType: 'float',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 0,
},
],
},
];

View File

@ -1,29 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addWebhookTable: WorkspaceMigrationTableAction[] = [
{
name: 'webhook',
action: 'create',
},
{
name: 'webhook',
action: 'alter',
columns: [
{
columnName: 'targetUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'operation',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
],
},
];

View File

@ -1,51 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addWorkspaceMemberTable: WorkspaceMigrationTableAction[] = [
{
name: 'workspaceMember',
action: 'create',
},
{
name: 'workspaceMember',
action: 'alter',
columns: [
{
columnName: 'nameFirstName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'nameLastName',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'avatarUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
},
{
columnName: 'colorScheme',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'Light'",
},
{
columnName: 'locale',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "'en'",
},
{
columnName: 'userId',
columnType: 'uuid',
action: WorkspaceMigrationColumnActionType.CREATE,
},
],
},
];

View File

@ -1,19 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addCompanyRelations: WorkspaceMigrationTableAction[] = [
{
name: 'company',
action: 'alter',
columns: [
{
columnName: 'accountOwnerId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,37 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addAttachmentRelations: WorkspaceMigrationTableAction[] = [
{
name: 'attachment',
action: 'alter',
columns: [
{
columnName: 'companyId',
referencedTableName: 'company',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'personId',
referencedTableName: 'person',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'activityId',
referencedTableName: 'activity',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'authorId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,19 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addPersonRelations: WorkspaceMigrationTableAction[] = [
{
name: 'person',
action: 'alter',
columns: [
{
columnName: 'companyId',
referencedTableName: 'company',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,31 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addFavoriteRelations: WorkspaceMigrationTableAction[] = [
{
name: 'favorite',
action: 'alter',
columns: [
{
columnName: 'companyId',
referencedTableName: 'company',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'personId',
referencedTableName: 'person',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'workspaceMemberId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,37 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addOpportunityRelations: WorkspaceMigrationTableAction[] = [
{
name: 'opportunity',
action: 'alter',
columns: [
{
columnName: 'companyId',
referencedTableName: 'company',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'personId',
referencedTableName: 'person',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'pointOfContactId',
referencedTableName: 'person',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'pipelineStepId',
referencedTableName: 'pipelineStep',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,31 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addActivityTargetRelations: WorkspaceMigrationTableAction[] = [
{
name: 'activityTarget',
action: 'alter',
columns: [
{
columnName: 'companyId',
referencedTableName: 'company',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'personId',
referencedTableName: 'person',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'activityId',
referencedTableName: 'activity',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,25 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addActivityRelations: WorkspaceMigrationTableAction[] = [
{
name: 'activity',
action: 'alter',
columns: [
{
columnName: 'authorId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'assigneeId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,25 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addCommentRelations: WorkspaceMigrationTableAction[] = [
{
name: 'comment',
action: 'alter',
columns: [
{
columnName: 'authorId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
{
columnName: 'activityId',
referencedTableName: 'activity',
referencedTableColumnName: 'id',
action: WorkspaceMigrationColumnActionType.RELATION,
},
],
},
];

View File

@ -1,47 +0,0 @@
import {
WorkspaceMigrationColumnActionType,
WorkspaceMigrationTableAction,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
export const addConnectedAccount: WorkspaceMigrationTableAction[] = [
{
name: 'connectedAccount',
action: 'create',
},
{
name: 'connectedAccount',
action: 'alter',
columns: [
{
columnName: 'type',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'accessToken',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'refreshToken',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'externalScopes',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'hasEmailScope',
columnType: 'boolean',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 'false',
},
],
},
];

View File

@ -1,56 +0,0 @@
import { addActivityTargetTable } from 'src/metadata/workspace-migration/migrations/1697618015-addActivityTargetTable';
import { addActivityTable } from 'src/metadata/workspace-migration/migrations/1697618016-addActivityTable';
import { addApiKeyTable } from 'src/metadata/workspace-migration/migrations/1697618017-addApiKeyTable';
import { addAttachmentTable } from 'src/metadata/workspace-migration/migrations/1697618018-addAttachmentTable';
import { addCommentTable } from 'src/metadata/workspace-migration/migrations/1697618019-addCommentTable';
import { addFavoriteTable } from 'src/metadata/workspace-migration/migrations/1697618020-addFavoriteTable';
import { addOpportunityTable } from 'src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable';
import { addPersonTable } from 'src/metadata/workspace-migration/migrations/1697618022-addPersonTable';
import { addPipelineStepTable } from 'src/metadata/workspace-migration/migrations/1697618023-addPipelineStepTable';
import { addWebhookTable } from 'src/metadata/workspace-migration/migrations/1697618024-addWebhookTable';
import { addWorkspaceMemberTable } from 'src/metadata/workspace-migration/migrations/1697618026-addWorspaceMemberTable';
import { addCompanyRelations } from 'src/metadata/workspace-migration/migrations/1697618027-addCompanyRelations';
import { addAttachmentRelations } from 'src/metadata/workspace-migration/migrations/1697618028-addAttachmentRelations';
import { addPersonRelations } from 'src/metadata/workspace-migration/migrations/1697618029-addPersonRelations';
import { addFavoriteRelations } from 'src/metadata/workspace-migration/migrations/1697618030-addFavoriteRelations';
import { addActivityTargetRelations } from 'src/metadata/workspace-migration/migrations/1697618032-addActivityTargetRelations';
import { addActivityRelations } from 'src/metadata/workspace-migration/migrations/1697618033-addActivityRelations';
import { addCommentRelations } from 'src/metadata/workspace-migration/migrations/1697618034-addCommentRelations';
import { addOpportunityRelations } from 'src/metadata/workspace-migration/migrations/1697618031-addOpportunityRelations';
import { addConnectedAccount } from 'src/metadata/workspace-migration/migrations/1697618035-addConnectedAccount';
import { addCompanyTable } from './migrations/1697618009-addCompanyTable';
import { addViewTable } from './migrations/1697618011-addViewTable';
import { addViewFieldTable } from './migrations/1697618012-addViewFieldTable';
import { addViewFilterTable } from './migrations/1697618013-addViewFilterTable';
import { addViewSortTable } from './migrations/1697618014-addViewSortTable';
// TODO: read the folder and return all migrations
export const standardMigrations = {
'1697618009-addCompanyTable': addCompanyTable,
'1697618011-addViewTable': addViewTable,
'1697618012-addViewFieldTable': addViewFieldTable,
'1697618013-addViewFilterTable': addViewFilterTable,
'1697618014-addViewSortTable': addViewSortTable,
'1697618015-addActivityTargetTable': addActivityTargetTable,
'1697618016-addActivityTable': addActivityTable,
'1697618017-addApiKeyTable': addApiKeyTable,
'1697618018-addAttachmentTable': addAttachmentTable,
'1697618019-addCommentTable': addCommentTable,
'1697618020-addFavoriteTable': addFavoriteTable,
'1697618021-addOpportunityTable': addOpportunityTable,
'1697618022-addPersonTable': addPersonTable,
'1697618023-addPipelineStepTable': addPipelineStepTable,
'1697618024-addWebhookTable': addWebhookTable,
'1697618026-addWorkspaceMemberTable': addWorkspaceMemberTable,
'1697618027-addCompanyRelations': addCompanyRelations,
'1697618028-addAttachmentRelations': addAttachmentRelations,
'1697618029-addPersonRelations': addPersonRelations,
'1697618030-addFavoriteRelations': addFavoriteRelations,
'1697618031-addOpportunitiesRelations': addOpportunityRelations,
'1697618032-addActivityTargetRelations': addActivityTargetRelations,
'1697618033-addActivityRelations': addActivityRelations,
'1697618034-addCommentRelations': addCommentRelations,
'1697618035-addConnectedAccount': addConnectedAccount,
};

View File

@ -39,6 +39,7 @@ export type WorkspaceMigrationColumnRelation = {
columnName: string;
referencedTableName: string;
referencedTableColumnName: string;
referencedSchema?: string;
isUnique?: boolean;
};
@ -59,6 +60,7 @@ export type WorkspaceMigrationColumnAction = {
export type WorkspaceMigrationTableAction = {
name: string;
action: 'create' | 'alter';
schemaName: string;
columns?: WorkspaceMigrationColumnAction[];
};

View File

@ -3,7 +3,6 @@ import { InjectRepository } from '@nestjs/typeorm';
import { IsNull, Repository } from 'typeorm';
import { standardMigrations } from './standard-migrations';
import {
WorkspaceMigrationEntity,
WorkspaceMigrationTableAction,
@ -16,43 +15,6 @@ export class WorkspaceMigrationService {
private readonly workspaceMigrationRepository: Repository<WorkspaceMigrationEntity>,
) {}
/**
* Insert all standard migrations that have not been inserted yet
*
* @param workspaceId
*/
public async insertStandardMigrations(workspaceId: string): Promise<void> {
// TODO: we actually don't need to fetch all of them, to improve later so it scales well.
const insertedStandardMigrations =
await this.workspaceMigrationRepository.find({
where: { workspaceId, isCustom: false },
});
const insertedStandardMigrationsMapByName =
insertedStandardMigrations.reduce((acc, migration) => {
acc[migration.name] = migration;
return acc;
}, {});
const standardMigrationsListThatNeedToBeInserted = Object.entries(
standardMigrations,
)
.filter(([name]) => !insertedStandardMigrationsMapByName[name])
.map(([name, migrations]) => ({ name, migrations }));
const standardMigrationsThatNeedToBeInserted =
standardMigrationsListThatNeedToBeInserted.map((migration) => ({
...migration,
workspaceId,
isCustom: false,
}));
await this.workspaceMigrationRepository.save(
standardMigrationsThatNeedToBeInserted,
);
}
/**
* Get all pending migrations for a given workspaceId
*

View File

@ -0,0 +1,71 @@
import 'reflect-metadata';
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { ReflectFieldMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-field-metadata.interface';
import { ReflectObjectMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-object-metadata.interface';
import { ReflectRelationMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-relation-metadata.interface';
export interface ReflectMetadataTypeMap {
objectMetadata: ReflectObjectMetadata;
fieldMetadata: ReflectFieldMetadata;
relationMetadata: ReflectRelationMetadata[];
gate: GateDecoratorParams;
isNullable: true;
isSystem: true;
}
export class TypedReflect {
static defineMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
metadataValue: ReflectMetadataTypeMap[T],
target: object,
): void;
static defineMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
metadataValue: ReflectMetadataTypeMap[T],
target: object,
propertyKey: string,
): void;
static defineMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
metadataValue: ReflectMetadataTypeMap[T],
target: object,
propertyKeyOrUndefined?: string,
) {
if (propertyKeyOrUndefined === undefined) {
Reflect.defineMetadata(metadataKey, metadataValue, target);
} else {
Reflect.defineMetadata(
metadataKey,
metadataValue,
target,
propertyKeyOrUndefined,
);
}
}
static getMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
target: object,
): ReflectMetadataTypeMap[T] | undefined;
static getMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
target: object,
propertyKey: string,
): ReflectMetadataTypeMap[T] | undefined;
static getMetadata<T extends keyof ReflectMetadataTypeMap>(
metadataKey: T,
target: object,
propertyKeyOrUndefined?: string,
) {
if (propertyKeyOrUndefined === undefined) {
return Reflect.getMetadata(metadataKey, target);
} else {
return Reflect.getMetadata(metadataKey, target, propertyKeyOrUndefined);
}
}
}

View File

@ -1,45 +0,0 @@
import { Command, CommandRunner, Option } from 'nest-commander';
import { WorkspaceMigrationService } from 'src/metadata/workspace-migration/workspace-migration.service';
import { WorkspaceMigrationRunnerService } from 'src/workspace/workspace-migration-runner/workspace-migration-runner.service';
// TODO: implement dry-run
interface RunWorkspaceMigrationsOptions {
workspaceId: string;
}
@Command({
name: 'workspace:migrate',
description: 'Run workspace migrations',
})
export class RunWorkspaceMigrationsCommand extends CommandRunner {
constructor(
private readonly workspaceMigrationService: WorkspaceMigrationService,
private readonly workspaceMigrationRunnerService: WorkspaceMigrationRunnerService,
) {
super();
}
async run(
_passedParam: string[],
options: RunWorkspaceMigrationsOptions,
): Promise<void> {
// TODO: run in a dedicated job + run queries in a transaction.
await this.workspaceMigrationService.insertStandardMigrations(
options.workspaceId,
);
await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
options.workspaceId,
);
}
// TODO: workspaceId should be optional and we should run migrations for all workspaces
@Option({
flags: '-w, --workspace-id [workspace_id]',
description: 'workspace id',
required: true,
})
parseWorkspaceId(value: string): string {
return value;
}
}

View File

@ -1,12 +0,0 @@
import { Module } from '@nestjs/common';
import { WorkspaceMigrationModule } from 'src/metadata/workspace-migration/workspace-migration.module';
import { WorkspaceMigrationRunnerModule } from 'src/workspace/workspace-migration-runner/workspace-migration-runner.module';
import { RunWorkspaceMigrationsCommand } from './run-workspace-migrations.command';
@Module({
imports: [WorkspaceMigrationModule, WorkspaceMigrationRunnerModule],
providers: [RunWorkspaceMigrationsCommand],
})
export class WorkspaceMigrationRunnerCommandsModule {}

View File

@ -63,13 +63,11 @@ export class WorkspaceMigrationRunnerService {
}, []);
const queryRunner = workspaceDataSource?.createQueryRunner();
const schemaName =
this.workspaceDataSourceService.getSchemaName(workspaceId);
// Loop over each migration and create or update the table
// TODO: Should be done in a transaction
for (const migration of flattenedPendingMigrations) {
await this.handleTableChanges(queryRunner, schemaName, migration);
await this.handleTableChanges(queryRunner, migration);
}
// Update appliedAt date for each migration
@ -98,17 +96,20 @@ export class WorkspaceMigrationRunnerService {
*/
private async handleTableChanges(
queryRunner: QueryRunner,
schemaName: string,
tableMigration: WorkspaceMigrationTableAction,
) {
switch (tableMigration.action) {
case 'create':
await this.createTable(queryRunner, schemaName, tableMigration.name);
await this.createTable(
queryRunner,
tableMigration.schemaName,
tableMigration.name,
);
break;
case 'alter':
await this.handleColumnChanges(
queryRunner,
schemaName,
tableMigration.schemaName,
tableMigration.name,
tableMigration?.columns,
);
@ -180,7 +181,7 @@ export class WorkspaceMigrationRunnerService {
);
break;
case WorkspaceMigrationColumnActionType.RELATION:
await this.createForeignKey(
await this.createRelation(
queryRunner,
schemaName,
tableName,
@ -279,10 +280,9 @@ export class WorkspaceMigrationRunnerService {
isNullable: migrationColumn.alteredColumnDefinition.isNullable,
}),
);
// }
}
private async createForeignKey(
private async createRelation(
queryRunner: QueryRunner,
schemaName: string,
tableName: string,
@ -293,6 +293,7 @@ export class WorkspaceMigrationRunnerService {
new TableForeignKey({
columnNames: [migrationColumn.columnName],
referencedColumnNames: [migrationColumn.referencedTableColumnName],
referencedSchema: migrationColumn.referencedSchema,
referencedTableName: migrationColumn.referencedTableName,
onDelete: 'CASCADE',
}),

View File

@ -104,12 +104,12 @@ export class RelationFieldAliasFactory {
);
return `
${fieldKey}: ${referencedObjectMetadata.targetTableName}Collection${
${fieldKey}: ${referencedObjectMetadata.targetTableName}Collection${
argsString ? `(${argsString})` : ''
} {
${fieldsString}
}
`;
${fieldsString}
}
`;
}
let relationAlias = fieldMetadata.isCustom
? `${fieldKey}: ${fieldMetadata.targetColumnMap.value}`

View File

@ -1,6 +1,6 @@
import { CursorScalarType } from './cursor.scalar';
import { BigFloatScalarType } from './big-float.scalar';
import { BigIntScalarType } from './big-int.scalar';
import { CursorScalarType } from './cursor.scalar';
import { DateScalarType } from './date.scalar';
import { DateTimeScalarType } from './date-time.scalar';
import { TimeScalarType } from './time.scalar';

View File

@ -0,0 +1,82 @@
import {
FieldMetadataDecoratorParams,
ReflectFieldMetadata,
} from 'src/workspace/workspace-sync-metadata/interfaces/reflect-field-metadata.interface';
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { generateTargetColumnMap } from 'src/metadata/field-metadata/utils/generate-target-column-map.util';
import { generateDefaultValue } from 'src/metadata/field-metadata/utils/generate-default-value';
import { TypedReflect } from 'src/utils/typed-reflect';
export function FieldMetadata<T extends FieldMetadataType>(
params: FieldMetadataDecoratorParams<T>,
): PropertyDecorator {
return (target: object, fieldKey: string) => {
const existingFieldMetadata =
TypedReflect.getMetadata('fieldMetadata', target.constructor) ?? {};
const isNullable =
TypedReflect.getMetadata('isNullable', target, fieldKey) ?? false;
const isSystem =
TypedReflect.getMetadata('isSystem', target, fieldKey) ?? false;
const gate = TypedReflect.getMetadata('gate', target, fieldKey);
const { joinColumn, ...restParams } = params;
TypedReflect.defineMetadata(
'fieldMetadata',
{
...existingFieldMetadata,
[fieldKey]: generateFieldMetadata<T>(
restParams,
fieldKey,
isNullable,
isSystem,
gate,
),
...(joinColumn && restParams.type === FieldMetadataType.RELATION
? {
[joinColumn]: generateFieldMetadata<FieldMetadataType.UUID>(
{
...restParams,
type: FieldMetadataType.UUID,
label: `${restParams.label} id (foreign key)`,
description: `${restParams.description} id foreign key`,
defaultValue: null,
},
joinColumn,
isNullable,
true,
gate,
),
}
: {}),
},
target.constructor,
);
};
}
function generateFieldMetadata<T extends FieldMetadataType>(
params: FieldMetadataDecoratorParams<T>,
fieldKey: string,
isNullable: boolean,
isSystem: boolean,
gate: GateDecoratorParams | undefined = undefined,
): ReflectFieldMetadata[string] {
const targetColumnMap = generateTargetColumnMap(params.type, false, fieldKey);
const defaultValue = params.defaultValue ?? generateDefaultValue(params.type);
return {
name: fieldKey,
...params,
targetColumnMap: JSON.stringify(targetColumnMap),
isNullable: params.type === FieldMetadataType.RELATION ? true : isNullable,
isSystem,
isCustom: false,
// TODO: handle options + stringify for the diff.
description: params.description,
icon: params.icon,
defaultValue: defaultValue ? JSON.stringify(defaultValue) : null,
gate,
};
}

View File

@ -0,0 +1,13 @@
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { TypedReflect } from 'src/utils/typed-reflect';
export function Gate(metadata: GateDecoratorParams) {
return function (target: object, fieldKey?: string) {
if (fieldKey) {
TypedReflect.defineMetadata('gate', metadata, target, fieldKey);
} else {
TypedReflect.defineMetadata('gate', metadata, target);
}
};
}

View File

@ -0,0 +1,7 @@
import { TypedReflect } from 'src/utils/typed-reflect';
export function IsNullable() {
return function (target: object, fieldKey: string) {
TypedReflect.defineMetadata('isNullable', true, target, fieldKey);
};
}

View File

@ -0,0 +1,11 @@
import { TypedReflect } from 'src/utils/typed-reflect';
export function IsSystem() {
return function (target: object, fieldKey?: string) {
if (fieldKey) {
TypedReflect.defineMetadata('isSystem', true, target, fieldKey);
} else {
TypedReflect.defineMetadata('isSystem', true, target);
}
};
}

View File

@ -1,210 +0,0 @@
import camelCase from 'lodash.camelcase';
import 'reflect-metadata';
import { FieldMetadataDefaultValue } from 'src/metadata/field-metadata/interfaces/field-metadata-default-value.interface';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { generateTargetColumnMap } from 'src/metadata/field-metadata/utils/generate-target-column-map.util';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import { generateDefaultValue } from 'src/metadata/field-metadata/utils/generate-default-value';
export interface FieldMetadataDecorator<T extends FieldMetadataType> {
type: T;
label: string;
description?: string | null;
icon?: string | null;
defaultValue?: FieldMetadataDefaultValue<T> | null;
joinColumn?: string;
}
export type ObjectMetadataDecorator = {
namePlural: string;
labelSingular: string;
labelPlural: string;
description?: string | null;
icon?: string | null;
};
export type RelationMetadataDecorator = {
type: RelationMetadataType;
objectName: string;
inverseSideFieldName?: string;
};
export type GateDecorator = {
featureFlag: string;
};
function convertClassNameToObjectMetadataName(name: string): string {
const classSuffix = 'ObjectMetadata';
let objectName = camelCase(name);
if (objectName.endsWith(classSuffix)) {
objectName = objectName.slice(0, -classSuffix.length);
}
return objectName;
}
export function ObjectMetadata(
metadata: ObjectMetadataDecorator,
): ClassDecorator {
return (target) => {
const isSystem = Reflect.getMetadata('isSystem', target) || false;
const gate = Reflect.getMetadata('gate', target) || undefined;
const objectName = convertClassNameToObjectMetadataName(target.name);
Reflect.defineMetadata(
'objectMetadata',
{
nameSingular: objectName,
...metadata,
gate,
targetTableName: objectName,
isSystem,
isCustom: false,
description: metadata.description ?? null,
icon: metadata.icon ?? null,
},
target,
);
};
}
export function IsNullable() {
return function (target: object, fieldKey: string) {
Reflect.defineMetadata('isNullable', true, target, fieldKey);
};
}
export function IsSystem() {
return function (target: object, fieldKey?: string) {
if (fieldKey) {
Reflect.defineMetadata('isSystem', true, target, fieldKey);
} else {
Reflect.defineMetadata('isSystem', true, target);
}
};
}
export function Gate(metadata: GateDecorator) {
return function (target: object, fieldKey?: string) {
if (fieldKey) {
Reflect.defineMetadata('gate', metadata, target, fieldKey);
} else {
Reflect.defineMetadata('gate', metadata, target);
}
};
}
export function FieldMetadata<T extends FieldMetadataType>(
metadata: FieldMetadataDecorator<T>,
): PropertyDecorator {
return (target: object, fieldKey: string) => {
const existingFieldMetadata =
Reflect.getMetadata('fieldMetadata', target.constructor) || {};
const isNullable =
Reflect.getMetadata('isNullable', target, fieldKey) || false;
const isSystem = Reflect.getMetadata('isSystem', target, fieldKey) || false;
const gate = Reflect.getMetadata('gate', target, fieldKey) || undefined;
const { joinColumn, ...fieldMetadata } = metadata;
Reflect.defineMetadata(
'fieldMetadata',
{
...existingFieldMetadata,
[fieldKey]: generateFieldMetadata<T>(
fieldMetadata,
fieldKey,
isNullable,
isSystem,
gate,
),
...(joinColumn && fieldMetadata.type === FieldMetadataType.RELATION
? {
[joinColumn]: generateFieldMetadata<FieldMetadataType.UUID>(
{
...fieldMetadata,
type: FieldMetadataType.UUID,
label: `${fieldMetadata.label} id (foreign key)`,
description: `${fieldMetadata.description} id foreign key`,
defaultValue: null,
},
joinColumn,
isNullable,
true,
gate,
),
}
: {}),
},
target.constructor,
);
};
}
function generateFieldMetadata<T extends FieldMetadataType>(
metadata: FieldMetadataDecorator<T>,
fieldKey: string,
isNullable: boolean,
isSystem: boolean,
gate: GateDecorator | undefined = undefined,
) {
const targetColumnMap = JSON.stringify(
generateTargetColumnMap(metadata.type, false, fieldKey),
);
const defaultValue =
metadata.defaultValue ?? generateDefaultValue(metadata.type);
return {
name: fieldKey,
...metadata,
targetColumnMap: targetColumnMap,
isNullable:
metadata.type === FieldMetadataType.RELATION ? true : isNullable,
isSystem,
isCustom: false,
options: null, // TODO: handle options + stringify for the diff.
description: metadata.description ?? null,
icon: metadata.icon ?? null,
defaultValue: defaultValue ? JSON.stringify(defaultValue) : null,
gate,
};
}
export function RelationMetadata(
metadata: RelationMetadataDecorator,
): PropertyDecorator {
return (target: object, fieldKey: string) => {
const existingRelationMetadata =
Reflect.getMetadata('relationMetadata', target.constructor) || [];
const gate = Reflect.getMetadata('gate', target, fieldKey) || undefined;
const objectName = convertClassNameToObjectMetadataName(
target.constructor.name,
);
Reflect.defineMetadata(
'relationMetadata',
[
...existingRelationMetadata,
{
type: metadata.type,
fromObjectNameSingular: objectName,
toObjectNameSingular: metadata.objectName,
fromFieldMetadataName: fieldKey,
toFieldMetadataName: metadata.inverseSideFieldName ?? objectName,
gate,
},
],
target.constructor,
);
};
}

View File

@ -0,0 +1,29 @@
import { ObjectMetadataDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-object-metadata.interface';
import { TypedReflect } from 'src/utils/typed-reflect';
import { convertClassNameToObjectMetadataName } from 'src/workspace/workspace-sync-metadata/utils/convert-class-to-object-metadata-name.util';
export function ObjectMetadata(
params: ObjectMetadataDecoratorParams,
): ClassDecorator {
return (target) => {
const isSystem = TypedReflect.getMetadata('isSystem', target) ?? false;
const gate = TypedReflect.getMetadata('gate', target);
const objectName = convertClassNameToObjectMetadataName(target.name);
TypedReflect.defineMetadata(
'objectMetadata',
{
nameSingular: objectName,
...params,
targetTableName: objectName,
isSystem,
isCustom: false,
description: params.description,
icon: params.icon,
gate,
},
target,
);
};
}

View File

@ -0,0 +1,35 @@
import 'reflect-metadata';
import { RelationMetadataDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-relation-metadata.interface';
import { TypedReflect } from 'src/utils/typed-reflect';
import { convertClassNameToObjectMetadataName } from 'src/workspace/workspace-sync-metadata/utils/convert-class-to-object-metadata-name.util';
export function RelationMetadata(
params: RelationMetadataDecoratorParams,
): PropertyDecorator {
return (target: object, fieldKey: string) => {
const existingRelationMetadata =
TypedReflect.getMetadata('relationMetadata', target.constructor) ?? [];
const gate = TypedReflect.getMetadata('gate', target, fieldKey);
const objectName = convertClassNameToObjectMetadataName(
target.constructor.name,
);
Reflect.defineMetadata(
'relationMetadata',
[
...existingRelationMetadata,
{
type: params.type,
fromObjectNameSingular: objectName,
toObjectNameSingular: params.objectName,
fromFieldMetadataName: fieldKey,
toFieldMetadataName: params.inverseSideFieldName ?? objectName,
gate,
},
],
target.constructor,
);
};
}

View File

@ -0,0 +1,3 @@
export interface GateDecoratorParams {
featureFlag: string;
}

View File

@ -0,0 +1,19 @@
import { PartialFieldMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/partial-field-metadata.interface';
import { PartialObjectMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/partial-object-metadata.interface';
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
import { FieldMetadataEntity } from 'src/metadata/field-metadata/field-metadata.entity';
export type MappedFieldMetadata = Record<string, PartialFieldMetadata>;
export interface MappedObjectMetadata
extends Omit<PartialObjectMetadata, 'fields'> {
fields: MappedFieldMetadata;
}
export type MappedFieldMetadataEntity = Record<string, FieldMetadataEntity>;
export interface MappedObjectMetadataEntity
extends Omit<ObjectMetadataEntity, 'fields'> {
fields: MappedFieldMetadataEntity;
}

View File

@ -0,0 +1,6 @@
import { ReflectFieldMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-field-metadata.interface';
export type PartialFieldMetadata = ReflectFieldMetadata[string] & {
workspaceId: string;
objectMetadataId?: string;
};

View File

@ -0,0 +1,8 @@
import { PartialFieldMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/partial-field-metadata.interface';
import { ReflectObjectMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-object-metadata.interface';
export type PartialObjectMetadata = ReflectObjectMetadata & {
workspaceId: string;
dataSourceId: string;
fields: PartialFieldMetadata[];
};

View File

@ -0,0 +1,32 @@
import { FieldMetadataDefaultValue } from 'src/metadata/field-metadata/interfaces/field-metadata-default-value.interface';
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
export interface FieldMetadataDecoratorParams<
T extends FieldMetadataType | 'default',
> {
type: T;
label: string;
description?: string;
icon?: string;
defaultValue?: FieldMetadataDefaultValue<T>;
joinColumn?: string;
}
export interface ReflectFieldMetadata {
[key: string]: Omit<
FieldMetadataDecoratorParams<'default'>,
'defaultValue' | 'type'
> & {
name: string;
type: FieldMetadataType;
targetColumnMap: string;
isNullable: boolean;
isSystem: boolean;
isCustom: boolean;
description?: string;
defaultValue: string | null;
gate?: GateDecoratorParams;
};
}

View File

@ -0,0 +1,17 @@
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
export interface ObjectMetadataDecoratorParams {
namePlural: string;
labelSingular: string;
labelPlural: string;
description?: string;
icon?: string;
}
export interface ReflectObjectMetadata extends ObjectMetadataDecoratorParams {
nameSingular: string;
targetTableName: string;
isSystem: boolean;
isCustom: boolean;
gate?: GateDecoratorParams;
}

View File

@ -0,0 +1,18 @@
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
export interface RelationMetadataDecoratorParams {
type: RelationMetadataType;
objectName: string;
inverseSideFieldName?: string;
}
export interface ReflectRelationMetadata {
type: RelationMetadataType;
fromObjectNameSingular: string;
toObjectNameSingular: string;
fromFieldMetadataName: string;
toFieldMetadataName: string;
gate?: GateDecoratorParams;
}

View File

@ -1,18 +1,25 @@
import { Injectable } from '@nestjs/common';
import assert from 'assert';
import { FieldMetadataEntity } from 'src/metadata/field-metadata/field-metadata.entity';
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { PartialObjectMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/partial-object-metadata.interface';
import { MappedObjectMetadataEntity } from 'src/workspace/workspace-sync-metadata/interfaces/mapped-metadata.interface';
export class MetadataParser {
static parseMetadata(
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { TypedReflect } from 'src/utils/typed-reflect';
import { isGatedAndNotEnabled } from 'src/workspace/workspace-sync-metadata/utils/is-gate-and-not-enabled.util';
@Injectable()
export class ReflectiveMetadataFactory {
async createObjectMetadata(
metadata: typeof BaseObjectMetadata,
workspaceId: string,
dataSourceId: string,
defaultDataSourceId: string,
workspaceFeatureFlagsMap: Record<string, boolean>,
): ObjectMetadataEntity | undefined {
const objectMetadata = Reflect.getMetadata('objectMetadata', metadata);
const fieldMetadata = Reflect.getMetadata('fieldMetadata', metadata);
): Promise<PartialObjectMetadata | undefined> {
const objectMetadata = TypedReflect.getMetadata('objectMetadata', metadata);
const fieldMetadata =
TypedReflect.getMetadata('fieldMetadata', metadata) ?? {};
if (!objectMetadata) {
throw new Error(
@ -31,47 +38,48 @@ export class MetadataParser {
return {
...objectMetadata,
workspaceId,
dataSourceId,
fields: fields.map((field: FieldMetadataEntity) => ({
dataSourceId: defaultDataSourceId,
fields: fields.map((field) => ({
...field,
workspaceId,
isSystem: objectMetadata.isSystem || field.isSystem,
defaultValue: field.defaultValue || null,
options: field.options || null,
defaultValue: field.defaultValue,
})),
};
}
static parseAllMetadata(
async createObjectMetadataCollection(
metadataCollection: (typeof BaseObjectMetadata)[],
workspaceId: string,
dataSourceId: string,
workspaceFeatureFlagsMap: Record<string, boolean>,
): ObjectMetadataEntity[] {
return metadataCollection
.map((metadata) =>
MetadataParser.parseMetadata(
metadata,
workspaceId,
dataSourceId,
workspaceFeatureFlagsMap,
),
)
.filter(
(metadata): metadata is ObjectMetadataEntity => metadata !== undefined,
);
) {
const metadataPromises = metadataCollection.map((metadata) =>
this.createObjectMetadata(
metadata,
workspaceId,
dataSourceId,
workspaceFeatureFlagsMap,
),
);
const resolvedMetadata = await Promise.all(metadataPromises);
return resolvedMetadata.filter(
(metadata): metadata is PartialObjectMetadata => !!metadata,
);
}
static parseRelationMetadata(
createRelationMetadata(
metadata: typeof BaseObjectMetadata,
workspaceId: string,
objectMetadataFromDB: Record<string, ObjectMetadataEntity>,
objectMetadataFromDB: Record<string, MappedObjectMetadataEntity>,
workspaceFeatureFlagsMap: Record<string, boolean>,
) {
const objectMetadata = Reflect.getMetadata('objectMetadata', metadata);
const relationMetadata = Reflect.getMetadata('relationMetadata', metadata);
if (!relationMetadata) return [];
const objectMetadata = TypedReflect.getMetadata('objectMetadata', metadata);
const relationMetadata = TypedReflect.getMetadata(
'relationMetadata',
metadata,
);
if (!objectMetadata) {
throw new Error(
@ -79,7 +87,10 @@ export class MetadataParser {
);
}
if (isGatedAndNotEnabled(objectMetadata, workspaceFeatureFlagsMap)) {
if (
!relationMetadata ||
isGatedAndNotEnabled(objectMetadata, workspaceFeatureFlagsMap)
) {
return [];
}
@ -94,7 +105,7 @@ export class MetadataParser {
assert(
fromObjectMetadata,
`Object ${relation.fromObjectNameSingular} not found in DB
for fromRelation defined in class ${objectMetadata.nameSingular}`,
for relation FROM defined in class ${objectMetadata.nameSingular}`,
);
const toObjectMetadata =
@ -103,7 +114,7 @@ export class MetadataParser {
assert(
toObjectMetadata,
`Object ${relation.toObjectNameSingular} not found in DB
for toRelation defined in class ${objectMetadata.nameSingular}`,
for relation TO defined in class ${objectMetadata.nameSingular}`,
);
const fromFieldMetadata =
@ -112,7 +123,7 @@ export class MetadataParser {
assert(
fromFieldMetadata,
`Field ${relation.fromFieldMetadataName} not found in object ${relation.fromObjectNameSingular}
for fromRelation defined in class ${objectMetadata.nameSingular}`,
for relation FROM defined in class ${objectMetadata.nameSingular}`,
);
const toFieldMetadata =
@ -121,7 +132,7 @@ export class MetadataParser {
assert(
toFieldMetadata,
`Field ${relation.toFieldMetadataName} not found in object ${relation.toObjectNameSingular}
for toRelation defined in class ${objectMetadata.nameSingular}`,
for relation TO defined in class ${objectMetadata.nameSingular}`,
);
return {
@ -135,14 +146,14 @@ export class MetadataParser {
});
}
static parseAllRelations(
createRelationMetadataCollection(
metadataCollection: (typeof BaseObjectMetadata)[],
workspaceId: string,
objectMetadataFromDB: Record<string, ObjectMetadataEntity>,
objectMetadataFromDB: Record<string, MappedObjectMetadataEntity>,
workspaceFeatureFlagsMap: Record<string, boolean>,
) {
return metadataCollection.flatMap((metadata) =>
MetadataParser.parseRelationMetadata(
this.createRelationMetadata(
metadata,
workspaceId,
objectMetadataFromDB,
@ -151,14 +162,3 @@ export class MetadataParser {
);
}
}
function isGatedAndNotEnabled(
metadata,
workspaceFeatureFlagsMap: Record<string, boolean>,
): boolean {
const featureFlagValue =
metadata.gate?.featureFlag &&
workspaceFeatureFlagsMap[metadata.gate.featureFlag];
return metadata.gate?.featureFlag !== undefined && !featureFlagValue;
}

View File

@ -1,10 +1,8 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
FieldMetadata,
IsSystem,
IsNullable,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-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';

View File

@ -1,12 +1,10 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import {
ObjectMetadata,
IsSystem,
IsNullable,
FieldMetadata,
RelationMetadata,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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';

View File

@ -1,10 +1,8 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
FieldMetadata,
IsNullable,
IsSystem,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
@ObjectMetadata({

View File

@ -1,10 +1,8 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-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';

View File

@ -1,15 +1,11 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
FieldMetadata,
IsSystem,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
export abstract class BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.UUID,
label: 'Id',
icon: null,
description: null,
defaultValue: { type: 'uuid' },
})
@IsSystem()
@ -18,7 +14,6 @@ export abstract class BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.DATE_TIME,
label: 'Creation date',
description: null,
icon: 'IconCalendar',
defaultValue: { type: 'now' },
})
@ -27,7 +22,6 @@ export abstract class BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.DATE_TIME,
label: 'Update date',
description: null,
icon: 'IconCalendar',
defaultValue: { type: 'now' },
})

View File

@ -1,9 +1,7 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-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';

View File

@ -2,12 +2,10 @@ import { CurrencyMetadata } from 'src/metadata/field-metadata/composite-types/cu
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 {
ObjectMetadata,
FieldMetadata,
IsNullable,
RelationMetadata,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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';

View File

@ -1,13 +1,11 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
RelationMetadata,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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 { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata';
import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';

View File

@ -1,10 +1,8 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-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';

View File

@ -1,13 +1,11 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
RelationMetadata,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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 { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata';
import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata';

View File

@ -1,11 +1,9 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata';
import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata';

View File

@ -1,13 +1,11 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
RelationMetadata,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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 { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata';
import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata';

View File

@ -1,13 +1,11 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
import {
ObjectMetadata,
IsSystem,
FieldMetadata,
IsNullable,
RelationMetadata,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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 { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { MessageRecipientObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata';
import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata';

View File

@ -1,10 +1,8 @@
import { CurrencyMetadata } from 'src/metadata/field-metadata/composite-types/currency.composite-type';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
ObjectMetadata,
FieldMetadata,
IsNullable,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
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 { 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';

View File

@ -2,14 +2,12 @@ import { FullNameMetadata } from 'src/metadata/field-metadata/composite-types/fu
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 {
ObjectMetadata,
FieldMetadata,
IsNullable,
RelationMetadata,
IsSystem,
Gate,
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.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';

Some files were not shown because too many files have changed in this diff Show More