Migrate standard objects (#2439)

* Migrate standard objects

* Add migrations

* fix relation

* fix: register RelationMetadataType enum

* fix: correctly fix null relation

---------

Co-authored-by: corentin <corentin@twenty.com>
Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
This commit is contained in:
Charles Bochet 2023-11-13 16:08:27 +01:00 committed by GitHub
parent c7568ff28b
commit 9a109758c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 3031 additions and 286 deletions

View File

@ -42,4 +42,5 @@
"cSpell.words": [ "cSpell.words": [
"twentyhq" "twentyhq"
], ],
"typescript.preferences.importModuleSpecifier": "non-relative"
} }

View File

@ -449,6 +449,7 @@ export enum FieldMetadataType {
Date = 'DATE', Date = 'DATE',
Email = 'EMAIL', Email = 'EMAIL',
Enum = 'ENUM', Enum = 'ENUM',
Probability = 'PROBABILITY',
Money = 'MONEY', Money = 'MONEY',
Number = 'NUMBER', Number = 'NUMBER',
Phone = 'PHONE', Phone = 'PHONE',

View File

@ -180,37 +180,3 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
infoTooltipContent: 'The company Twitter account.', infoTooltipContent: 'The company Twitter account.',
} satisfies ColumnDefinition<FieldURLMetadata>, } satisfies ColumnDefinition<FieldURLMetadata>,
]; ];
export const suppliersAvailableColumnDefinitions: ColumnDefinition<FieldMetadata>[] =
[
{
fieldMetadataId: 'name',
label: 'Name',
Icon: IconBuildingSkyscraper,
size: 180,
position: 0,
type: 'TEXT',
metadata: {
fieldName: 'name',
placeHolder: 'Company Name',
},
isVisible: true,
infoTooltipContent: 'The company name.',
basePathToShowPage: '/companies/',
} satisfies ColumnDefinition<FieldTextMetadata>,
{
fieldMetadataId: 'city',
label: 'City',
Icon: IconBuildingSkyscraper,
size: 180,
position: 0,
type: 'TEXT',
metadata: {
fieldName: 'city',
placeHolder: 'Company Name',
},
isVisible: true,
infoTooltipContent: 'The company name.',
basePathToShowPage: '/companies/',
} satisfies ColumnDefinition<FieldTextMetadata>,
];

View File

@ -14,22 +14,14 @@ export const ObjectMetadataNavItems = () => {
return ( return (
<> <>
{objectMetadataItems {objectMetadataItems.map((objectMetadataItem) => {
.filter(
(objectMetadataItem) =>
objectMetadataItem.isActive &&
!objectMetadataItem.namePlural.endsWith('V2'),
)
.map((objectMetadataItem) => {
return ( return (
<NavItem <NavItem
key={objectMetadataItem.id} key={objectMetadataItem.id}
label={objectMetadataItem.labelPlural} label={objectMetadataItem.labelPlural}
to={`/objects/${objectMetadataItem.namePlural}`} to={`/objects/${objectMetadataItem.namePlural}`}
Icon={ Icon={
objectMetadataItem.icon objectMetadataItem.icon ? icons[objectMetadataItem.icon] : Icon123
? icons[objectMetadataItem.icon]
: Icon123
} }
onClick={() => { onClick={() => {
navigate(`/objects/${objectMetadataItem.namePlural}`); navigate(`/objects/${objectMetadataItem.namePlural}`);

View File

@ -13,6 +13,7 @@ const defaultFieldValues: Record<FieldMetadataType, unknown> = {
[FieldMetadataType.Email]: '', [FieldMetadataType.Email]: '',
[FieldMetadataType.Enum]: null, [FieldMetadataType.Enum]: null,
[FieldMetadataType.Number]: null, [FieldMetadataType.Number]: null,
[FieldMetadataType.Probability]: null,
[FieldMetadataType.Relation]: null, [FieldMetadataType.Relation]: null,
[FieldMetadataType.Phone]: '', [FieldMetadataType.Phone]: '',
[FieldMetadataType.Text]: '', [FieldMetadataType.Text]: '',

View File

@ -47,6 +47,7 @@ export {
IconHeartOff, IconHeartOff,
IconHelpCircle, IconHelpCircle,
IconHierarchy2, IconHierarchy2,
IconLanguage,
IconLayoutKanban, IconLayoutKanban,
IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftCollapse,
IconLayoutSidebarRightCollapse, IconLayoutSidebarRightCollapse,

4
server/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"javascript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "non-relative"
}

View File

@ -9,14 +9,8 @@ import { TenantMigrationRunnerService } from 'src/tenant-migration-runner/tenant
import { seedCompanies } from 'src/database/typeorm-seeds/tenant/companies'; import { seedCompanies } from 'src/database/typeorm-seeds/tenant/companies';
import { seedViewFields } from 'src/database/typeorm-seeds/tenant/view-fields'; import { seedViewFields } from 'src/database/typeorm-seeds/tenant/view-fields';
import { seedViews } from 'src/database/typeorm-seeds/tenant/views'; import { seedViews } from 'src/database/typeorm-seeds/tenant/views';
import { seedObjectMetadata } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { TypeORMService } from 'src/database/typeorm/typeorm.service'; import { TypeORMService } from 'src/database/typeorm/typeorm.service';
import { seedCompanyFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/company'; import { seedMetadataSchema } from 'src/database/typeorm-seeds/metadata';
import { seedViewFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view';
import { seedViewFieldFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewField';
import { seedViewFilterFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewFilter';
import { seedViewSortFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewSort';
import { seedViewRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/view';
// TODO: implement dry-run // TODO: implement dry-run
@Command({ @Command({
@ -25,7 +19,7 @@ import { seedViewRelationMetadata } from 'src/database/typeorm-seeds/metadata/re
'Seed tenant with initial data. This command is intended for development only.', 'Seed tenant with initial data. This command is intended for development only.',
}) })
export class DataSeedTenantCommand extends CommandRunner { export class DataSeedTenantCommand extends CommandRunner {
workspaceId = 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419'; workspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
constructor( constructor(
@InjectDataSource('metadata') @InjectDataSource('metadata')
@ -53,15 +47,7 @@ export class DataSeedTenantCommand extends CommandRunner {
} }
try { try {
await seedObjectMetadata(this.metadataDataSource, 'metadata'); await seedMetadataSchema(workspaceDataSource, 'metadata');
await seedCompanyFieldMetadata(this.metadataDataSource, 'metadata');
await seedViewFieldMetadata(this.metadataDataSource, 'metadata');
await seedViewFieldFieldMetadata(this.metadataDataSource, 'metadata');
await seedViewSortFieldMetadata(this.metadataDataSource, 'metadata');
await seedViewFilterFieldMetadata(this.metadataDataSource, 'metadata');
await seedViewRelationMetadata(this.metadataDataSource, 'metadata');
await this.tenantMigrationService.insertStandardMigrations( await this.tenantMigrationService.insertStandardMigrations(
this.workspaceId, this.workspaceId,

View File

@ -5,7 +5,7 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
title: 'Performance update', title: 'Performance update',
type: 'Note', type: 'Note',
body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"In the North American region, we have observed a strong growth rate of 18% in sales. Europe followed suit with a significant 14% increase, while Asia-Pacific sustained its performance with a steady 10% rise. Special kudos to the North American team for the excellent work done in penetrating new markets and establishing stronger footholds in the existing ones.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]', body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"In the North American region, we have observed a strong growth rate of 18% in sales. Europe followed suit with a significant 14% increase, while Asia-Pacific sustained its performance with a steady 10% rise. Special kudos to the North American team for the excellent work done in penetrating new markets and establishing stronger footholds in the existing ones.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
@ -21,7 +21,7 @@ export const seedComments = async (prisma: PrismaClient) => {
personId: null, personId: null,
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -30,7 +30,7 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb200', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb200',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'Hi Félix ! How do you like your Twenty workspace?', body: 'Hi Félix ! How do you like your Twenty workspace?',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
@ -43,7 +43,7 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b40-3ec3-4fe3-8997-b76aa0bfb200', id: 'twenty-fe256b40-3ec3-4fe3-8997-b76aa0bfb200',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'I love it!', body: 'I love it!',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
@ -56,7 +56,7 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
title: 'Buyout Proposal', title: 'Buyout Proposal',
type: 'Task', type: 'Task',
assigneeId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', assigneeId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408',
@ -74,7 +74,7 @@ export const seedComments = async (prisma: PrismaClient) => {
personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
companyId: null, companyId: null,
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -83,7 +83,7 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb100', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb100',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'I really like this comment thread feature!', body: 'I really like this comment thread feature!',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',

View File

@ -7,7 +7,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
name: 'Linkedin', name: 'Linkedin',
domainName: 'linkedin.com', domainName: 'linkedin.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -18,7 +18,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102', id: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
name: 'Facebook', name: 'Facebook',
domainName: 'facebook.com', domainName: 'facebook.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -29,7 +29,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', id: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
name: 'Qonto', name: 'Qonto',
domainName: 'qonto.com', domainName: 'qonto.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -40,7 +40,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', id: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
name: 'Microsoft', name: 'Microsoft',
domainName: 'microsoft.com', domainName: 'microsoft.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -51,7 +51,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278', id: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
name: 'Airbnb', name: 'Airbnb',
domainName: 'airbnb.com', domainName: 'airbnb.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -62,7 +62,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025', id: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
name: 'Google', name: 'Google',
domainName: 'google.com', domainName: 'google.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -73,7 +73,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-1d3a1c6e-707e-44dc-a1d2-30030bf1a944', id: 'twenty-1d3a1c6e-707e-44dc-a1d2-30030bf1a944',
name: 'Netflix', name: 'Netflix',
domainName: 'netflix.com', domainName: 'netflix.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -84,7 +84,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-7a93d1e5-3f74-492d-a101-2a70f50a1645', id: 'twenty-7a93d1e5-3f74-492d-a101-2a70f50a1645',
name: 'Libeo', name: 'Libeo',
domainName: 'libeo.io', domainName: 'libeo.io',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -96,7 +96,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-9d162de6-cfbf-4156-a790-e39854dcd4eb', id: 'twenty-9d162de6-cfbf-4156-a790-e39854dcd4eb',
name: 'Claap', name: 'Claap',
domainName: 'claap.io', domainName: 'claap.io',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -108,7 +108,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-aaffcfbd-f86b-419f-b794-02319abe8637', id: 'twenty-aaffcfbd-f86b-419f-b794-02319abe8637',
name: 'Hasura', name: 'Hasura',
domainName: 'hasura.io', domainName: 'hasura.io',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -120,7 +120,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-f33dc242-5518-4553-9433-42d8eb82834b', id: 'twenty-f33dc242-5518-4553-9433-42d8eb82834b',
name: 'Wework', name: 'Wework',
domainName: 'wework.com', domainName: 'wework.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -132,7 +132,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-a7bc68d5-f79e-40dd-bd06-c36e6abb4678', id: 'twenty-a7bc68d5-f79e-40dd-bd06-c36e6abb4678',
name: 'Samsung', name: 'Samsung',
domainName: 'samsung.com', domainName: 'samsung.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });
@ -143,7 +143,7 @@ export const seedCompanies = async (prisma: PrismaClient) => {
id: 'twenty-a674fa6c-1455-4c57-afaf-dd5dc086361d', id: 'twenty-a674fa6c-1455-4c57-afaf-dd5dc086361d',
name: 'Algolia', name: 'Algolia',
domainName: 'algolia.com', domainName: 'algolia.com',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '', address: '',
}, },
}); });

View File

@ -1,15 +1,19 @@
import { PrismaClient } from '@prisma/client'; import { PrismaClient } from '@prisma/client';
export const SeedDataSourceId = '20202020-7f63-47a9-b1b3-6c7290ca9fb1';
export const SeedWorkspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
export const SeedWorkspaceSchemaName = 'workspace_1wgvd1injqtife6y4rvfbu3h5';
export const seedMetadata = async (prisma: PrismaClient) => { export const seedMetadata = async (prisma: PrismaClient) => {
await prisma.$queryRawUnsafe( await prisma.$queryRawUnsafe(
'CREATE SCHEMA IF NOT EXISTS workspace_twenty_7icsva0r6s00mpcp6cwg4w4rd', `CREATE SCHEMA IF NOT EXISTS ${SeedWorkspaceSchemaName}`,
); );
await prisma.$queryRawUnsafe( await prisma.$queryRawUnsafe(
`INSERT INTO metadata."dataSource"( `INSERT INTO metadata."dataSource"(
id, schema, type, "workspaceId" id, schema, type, "workspaceId"
) )
VALUES ( VALUES (
'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', 'workspace_twenty_7icsva0r6s00mpcp6cwg4w4rd', 'postgres', 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419' '${SeedDataSourceId}', '${SeedWorkspaceSchemaName}', 'postgres', '${SeedWorkspaceId}'
) ON CONFLICT DO NOTHING`, ) ON CONFLICT DO NOTHING`,
); );
}; };

View File

@ -7,7 +7,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-86083141-1c0e-494c-a1b6-85b1c6fefaa5', id: 'twenty-86083141-1c0e-494c-a1b6-85b1c6fefaa5',
firstName: 'Christoph', firstName: 'Christoph',
lastName: 'Callisto', lastName: 'Callisto',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33789012345', phone: '+33789012345',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
@ -22,7 +22,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-0aa00beb-ac73-4797-824e-87a1f5aea9e0', id: 'twenty-0aa00beb-ac73-4797-824e-87a1f5aea9e0',
firstName: 'Sylvie', firstName: 'Sylvie',
lastName: 'Palmer', lastName: 'Palmer',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33780123456', phone: '+33780123456',
city: 'Los Angeles', city: 'Los Angeles',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
@ -37,7 +37,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-93c72d2e-f517-42fd-80ae-14173b3b70ae', id: 'twenty-93c72d2e-f517-42fd-80ae-14173b3b70ae',
firstName: 'Christopher', firstName: 'Christopher',
lastName: 'Gonzalez', lastName: 'Gonzalez',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33789012345', phone: '+33789012345',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
@ -52,7 +52,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-eeeacacf-eee1-4690-ad2c-8619e5b56a2e', id: 'twenty-eeeacacf-eee1-4690-ad2c-8619e5b56a2e',
firstName: 'Ashley', firstName: 'Ashley',
lastName: 'Parker', lastName: 'Parker',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33780123456', phone: '+33780123456',
city: 'Los Angeles', city: 'Los Angeles',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
@ -67,7 +67,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-9b324a88-6784-4449-afdf-dc62cb8702f2', id: 'twenty-9b324a88-6784-4449-afdf-dc62cb8702f2',
firstName: 'Nicholas', firstName: 'Nicholas',
lastName: 'Wright', lastName: 'Wright',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33781234567', phone: '+33781234567',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
@ -82,7 +82,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-1d151852-490f-4466-8391-733cfd66a0c8', id: 'twenty-1d151852-490f-4466-8391-733cfd66a0c8',
firstName: 'Isabella', firstName: 'Isabella',
lastName: 'Scott', lastName: 'Scott',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33782345678', phone: '+33782345678',
city: 'New York', city: 'New York',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
@ -97,7 +97,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-98406e26-80f1-4dff-b570-a74942528de3', id: 'twenty-98406e26-80f1-4dff-b570-a74942528de3',
firstName: 'Matthew', firstName: 'Matthew',
lastName: 'Green', lastName: 'Green',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33783456789', phone: '+33783456789',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
@ -112,7 +112,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-a2e78a5f-338b-46df-8811-fa08c7d19d35', id: 'twenty-a2e78a5f-338b-46df-8811-fa08c7d19d35',
firstName: 'Elizabeth', firstName: 'Elizabeth',
lastName: 'Baker', lastName: 'Baker',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33784567890', phone: '+33784567890',
city: 'New York', city: 'New York',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278', companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
@ -127,7 +127,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016', id: 'twenty-ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016',
firstName: 'Christopher', firstName: 'Christopher',
lastName: 'Nelson', lastName: 'Nelson',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33785678901', phone: '+33785678901',
city: 'San Francisco', city: 'San Francisco',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278', companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
@ -142,7 +142,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-56955422-5d54-41b7-ba36-f0d20e1417ae', id: 'twenty-56955422-5d54-41b7-ba36-f0d20e1417ae',
firstName: 'Avery', firstName: 'Avery',
lastName: 'Carter', lastName: 'Carter',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33786789012', phone: '+33786789012',
city: 'New York', city: 'New York',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278', companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
@ -157,7 +157,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', id: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
firstName: 'Ethan', firstName: 'Ethan',
lastName: 'Mitchell', lastName: 'Mitchell',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33787890123', phone: '+33787890123',
city: 'Los Angeles', city: 'Los Angeles',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025', companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
@ -172,7 +172,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190ef', id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190ef',
firstName: 'Madison', firstName: 'Madison',
lastName: 'Perez', lastName: 'Perez',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234', phone: '+33788901234',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025', companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
@ -187,7 +187,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190df', id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190df',
firstName: 'Bertrand', firstName: 'Bertrand',
lastName: 'Voulzy', lastName: 'Voulzy',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234', phone: '+33788901234',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025', companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
@ -202,7 +202,7 @@ export const seedPeople = async (prisma: PrismaClient) => {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190dg', id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190dg',
firstName: 'Louis', firstName: 'Louis',
lastName: 'Duss', lastName: 'Duss',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234', phone: '+33788901234',
city: 'Seattle', city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025', companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',

View File

@ -7,7 +7,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', id: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
name: 'Sales pipeline', name: 'Sales pipeline',
icon: '💰', icon: '💰',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
pipelineProgressableType: 'Company', pipelineProgressableType: 'Company',
}, },
}); });
@ -22,7 +22,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 0, position: 0,
type: 'open', type: 'open',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -36,7 +36,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 1, position: 1,
type: 'ongoing', type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -50,7 +50,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 2, position: 2,
type: 'ongoing', type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -64,7 +64,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 3, position: 3,
type: 'ongoing', type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -78,7 +78,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 4, position: 4,
type: 'won', type: 'won',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -90,7 +90,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -102,7 +102,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
companyId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102', companyId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -114,7 +114,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -126,7 +126,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -137,7 +137,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400', id: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
name: 'Customer support pipeline', name: 'Customer support pipeline',
icon: '📔', icon: '📔',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
pipelineProgressableType: 'Person', pipelineProgressableType: 'Person',
}, },
}); });
@ -152,7 +152,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
position: 1, position: 1,
type: 'open', type: 'open',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -164,7 +164,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600',
personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });

View File

@ -27,7 +27,7 @@ export const seedUsers = async (prisma: PrismaClient) => {
id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419', id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419',
}, },
create: { create: {
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109', settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109',
}, },
}, },
@ -57,7 +57,7 @@ export const seedUsers = async (prisma: PrismaClient) => {
workspaceMember: { workspaceMember: {
create: { create: {
id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419', id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215', settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215',
}, },
}, },
@ -86,7 +86,7 @@ export const seedUsers = async (prisma: PrismaClient) => {
workspaceMember: { workspaceMember: {
create: { create: {
id: 'twenty-7ed9d213-1c25-4d02-bf35-6aeccf7ea419', id: 'twenty-7ed9d213-1c25-4d02-bf35-6aeccf7ea419',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328', settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328',
}, },
}, },

View File

@ -1,10 +1,10 @@
import { PrismaClient } from '@prisma/client'; import { PrismaClient } from '@prisma/client';
export const seedWorkspaces = async (prisma: PrismaClient) => { export const seedWorkspaces = async (prisma: PrismaClient) => {
await prisma.workspace.upsert({ await prisma.workspace.upsert({
where: { id: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419' }, where: { id: '20202020-1c25-4d02-bf25-6aeccf7ea419' },
update: {}, update: {},
create: { create: {
id: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', id: '20202020-1c25-4d02-bf25-6aeccf7ea419',
displayName: 'Apple', displayName: 'Apple',
domainName: 'apple.dev', domainName: 'apple.dev',
inviteHash: 'apple.dev-invite-hash', inviteHash: 'apple.dev-invite-hash',

View File

@ -0,0 +1,88 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedActivityTargetFieldMetadataIds {
Activity = '20202020-cb21-42c9-bba8-347f7cb02b84',
Person = '20202020-e56c-43e6-8fce-5619d8c2293a',
Company = '20202020-9408-4cc0-9fe1-51467edb530b',
}
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',
])
.orIgnore()
.values([
// Relationships
{
id: SeedActivityTargetFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activity',
label: 'Activity',
targetColumnMap: {
value: 'activityId',
},
description: 'ActivityTarget activity',
icon: 'IconNotes',
isNullable: false,
},
{
id: SeedActivityTargetFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'ActivityTarget person',
icon: 'IconUser',
isNullable: true,
},
{
id: SeedActivityTargetFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.ActivityTarget,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'ActivityTarget company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
},
])
.execute();
};

View File

@ -0,0 +1,225 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedActivityFieldMetadataIds {
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',
Assignee = '20202020-4694-4ec6-9084-8d932ebb3065',
}
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',
])
.orIgnore()
.values([
// Primary identifier
{
id: SeedActivityFieldMetadataIds.Title,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'title',
label: 'Title',
targetColumnMap: {
value: 'title',
},
description: 'Activity title',
icon: 'IconNotes',
isNullable: true,
},
// Scalar fields
{
id: SeedActivityFieldMetadataIds.Body,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'body',
label: 'Body',
targetColumnMap: {
value: 'body',
},
description: 'Activity body',
icon: 'IconList',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'type',
label: 'Type',
targetColumnMap: {
value: 'type',
},
description: 'Activity type',
icon: 'IconCheckbox',
isNullable: false,
},
{
id: SeedActivityFieldMetadataIds.ReminderAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'reminderAt',
label: 'Reminder Date',
targetColumnMap: {
value: 'reminderAt',
},
description: 'Activity reminder date',
icon: 'IconCalendarEvent',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.DueAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'dueAt',
label: 'Due Date',
targetColumnMap: {
value: 'dueAt',
},
description: 'Activity due date',
icon: 'IconCalendarEvent',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.CompletedAt,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'completedAt',
label: 'Completion Date',
targetColumnMap: {
value: 'completedAt',
},
description: 'Activity completion date',
icon: 'IconCheck',
isNullable: true,
},
// Relationships
{
id: SeedActivityFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activityTargets',
label: 'Targets',
targetColumnMap: {},
description: 'Activity targets',
icon: 'IconCheckbox',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Activity attachments',
icon: 'IconFileImport',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.Comments,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'Comments',
label: 'Comments',
targetColumnMap: {},
description: 'Activity comments',
icon: 'IconComment',
isNullable: true,
},
{
id: SeedActivityFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'author',
label: 'Author',
targetColumnMap: {
value: 'authorId',
},
description:
'Activity author. This is the person who created the activity',
icon: 'IconUserCircle',
isNullable: false,
},
{
id: SeedActivityFieldMetadataIds.Assignee,
objectMetadataId: SeedObjectMetadataIds.Activity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'assignee',
label: 'Assignee',
targetColumnMap: {
value: 'assigneeId',
},
description:
'Acitivity assignee. This is the workspace member assigned to the activity ',
icon: 'IconUserCircle',
isNullable: true,
},
])
.execute();
};

View File

@ -0,0 +1,88 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedApiKeyFieldMetadataIds {
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedApiKeyFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'ApiKey name',
icon: 'IconLink',
isNullable: false,
},
{
id: SeedApiKeyFieldMetadataIds.ExpiresAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'expiresAt',
label: 'Expiration date',
targetColumnMap: {
value: 'expiresAt',
},
description: 'ApiKey expiration date',
icon: 'IconCalendar',
isNullable: false,
},
{
id: SeedApiKeyFieldMetadataIds.RevokedAt,
objectMetadataId: SeedObjectMetadataIds.ApiKey,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'revokedAt',
label: 'Revocation date',
targetColumnMap: {
value: 'revokedAt',
},
description: 'ApiKey revocation date',
icon: 'IconCalendar',
isNullable: true,
},
])
.execute();
};

View File

@ -0,0 +1,160 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedAttachmentFieldMetadataIds {
Name = '20202020-5683-4c80-8590-255321ece692',
FullPath = '20202020-bb72-4644-b255-afb4ebb83b66',
Type = '20202020-8dfa-492f-92d1-56d5fb18cbb7',
Author = '20202020-7831-43c2-827f-bc78289b7398',
Activity = '20202020-f5a9-46ec-b39a-eda906f00804',
Person = '20202020-f67c-4cc5-893c-c6b615527473',
Company = '20202020-5463-4d03-9124-1775b9b7f955',
}
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',
])
.orIgnore()
.values([
// Primary Identifier
{
id: SeedAttachmentFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'Attachment name',
icon: 'IconFileUpload',
isNullable: false,
},
// Scalar fields
{
id: SeedAttachmentFieldMetadataIds.FullPath,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'fullPath',
label: 'Full path',
targetColumnMap: {
value: 'fullPath',
},
description: 'Attachment full path',
icon: 'IconLink',
isNullable: false,
},
{
id: SeedAttachmentFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'type',
label: 'Type',
targetColumnMap: {
value: 'type',
},
description: 'Attachment type',
icon: 'IconList',
isNullable: false,
},
// Relationships
{
id: SeedAttachmentFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'author',
label: 'Author',
targetColumnMap: {
value: 'authorId',
},
description: 'Attachment author',
icon: 'IconCircleUser',
isNullable: false,
},
{
id: SeedAttachmentFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activity',
label: 'Activity',
targetColumnMap: {
value: 'activityId',
},
description: 'Attachment activity',
icon: 'IconNotes',
isNullable: false,
},
{
id: SeedAttachmentFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'Attachment person',
icon: 'IconUser',
isNullable: false,
},
{
id: SeedAttachmentFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Attachment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'Attachment company',
icon: 'IconBuildingSkyscraper',
isNullable: false,
},
])
.execute();
};

View File

@ -0,0 +1,90 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedCommentFieldMetadataIds {
Body = '20202020-354b-4f10-9425-fa3eb8fddc51',
Author = '20202020-2c70-40c2-bba6-893780b25d41',
Activity = '20202020-a9ac-4294-9462-db0f690da906',
}
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedCommentFieldMetadataIds.Body,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'body',
label: 'Body',
targetColumnMap: {
value: 'body',
},
description: 'Comment body',
icon: 'IconLink',
isNullable: false,
},
// Relationships
{
id: SeedCommentFieldMetadataIds.Author,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'author',
label: 'Author',
targetColumnMap: {
value: 'authorId',
},
description: 'Comment author',
icon: 'IconCircleUser',
isNullable: false,
},
{
id: SeedCommentFieldMetadataIds.Activity,
objectMetadataId: SeedObjectMetadataIds.Comment,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activity',
label: 'Activity',
targetColumnMap: {
value: 'activityId',
},
description: 'Comment activity',
icon: 'IconNotes',
isNullable: false,
},
])
.execute();
};

View File

@ -1,6 +1,28 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const tableName = 'fieldMetadata'; import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedCompanyFieldMetadataIds {
Name = '20202020-6d30-4111-9f40-b4301906fd3c',
DomainName = '20202020-5e4e-4007-a630-8a2617914889',
Address = '20202020-ad10-4117-a039-3f04b7a5f939',
Employees = '20202020-7fbd-41ad-b64d-25a15ff62f04',
LinkedinUrl = '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',
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 ( export const seedCompanyFieldMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
@ -9,7 +31,8 @@ export const seedCompanyFieldMetadata = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId', 'objectMetadataId',
'isCustom', 'isCustom',
'workspaceId', 'workspaceId',
@ -24,10 +47,12 @@ export const seedCompanyFieldMetadata = async (
]) ])
.orIgnore() .orIgnore()
.values([ .values([
// Main Identifier
{ {
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047', id: SeedCompanyFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'name', name: 'name',
@ -35,14 +60,17 @@ export const seedCompanyFieldMetadata = async (
targetColumnMap: { targetColumnMap: {
value: 'name', value: 'name',
}, },
description: 'Name of the company', description: 'The company name',
icon: 'IconBuildingSkyscraper', icon: 'IconBuildingSkyscraper',
isNullable: false, isNullable: false,
}, },
// Scalar Fields
{ {
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047', id: SeedCompanyFieldMetadataIds.DomainName,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'domainName', name: 'domainName',
@ -50,14 +78,16 @@ export const seedCompanyFieldMetadata = async (
targetColumnMap: { targetColumnMap: {
value: 'domainName', value: 'domainName',
}, },
description: 'Domain name of the company', description:
'The company website URL. We use this url to fetch the company icon',
icon: 'IconLink', icon: 'IconLink',
isNullable: true, isNullable: true,
}, },
{ {
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047', id: SeedCompanyFieldMetadataIds.Address,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'address', name: 'address',
@ -65,25 +95,181 @@ export const seedCompanyFieldMetadata = async (
targetColumnMap: { targetColumnMap: {
value: 'address', value: 'address',
}, },
description: 'Address of the company', description: 'The company address',
icon: 'IconMap', icon: 'IconMap',
isNullable: true, isNullable: true,
}, },
{ {
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047', id: SeedCompanyFieldMetadataIds.Employees,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'NUMBER',
name: 'employees', name: 'employees',
label: 'Employees', label: 'Employees',
targetColumnMap: { targetColumnMap: {
value: 'employees', value: 'employees',
}, },
description: 'Number of employees', description: 'Number of employees in the company',
icon: 'IconUsers', icon: 'IconUsers',
isNullable: true, isNullable: true,
}, },
{
id: SeedCompanyFieldMetadataIds.LinkedinUrl,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'linkedinUrl',
label: 'Linkedin',
targetColumnMap: {
value: 'linkedinUrl',
},
description: 'The company Linkedin account',
icon: 'IconBrandLinkedin',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.XUrl,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'xUrl',
label: 'X',
targetColumnMap: {
value: 'xUrl',
},
description: 'The company Twitter/X account',
icon: 'IconBrandX',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.AnnualRecurringRevenue,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'NUMBER',
name: 'annualRecurringRevenue',
label: 'ARR',
targetColumnMap: {
value: 'annualRecurringRevenue',
},
description:
'Annual Recurring Revenue: The actual or estimated annual revenue of the company',
icon: 'IconMoneybag',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.IdealCustomerProfile,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: '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,
},
// Relationships
{
id: SeedCompanyFieldMetadataIds.People,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'people',
label: 'People',
targetColumnMap: {},
description: 'People linked to the company.',
icon: 'IconUsers',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.AccountOwner,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'accountOwner',
label: 'Account Owner',
targetColumnMap: {
value: 'accountOwnerId',
},
description:
'Your team member responsible for managing the company account',
icon: 'IconUserCircle',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activityTargets',
label: 'Activities',
targetColumnMap: {},
description: 'Activities tied to the company',
icon: 'IconCheckbox',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the company.',
icon: 'IconTargetArrow',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the company',
icon: 'IconHeart',
isNullable: true,
},
{
id: SeedCompanyFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Company,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Attachments linked to the company.',
icon: 'IconFileImport',
isNullable: true,
},
]) ])
.execute(); .execute();
}; };

View File

@ -0,0 +1,109 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedFavoriteFieldMetadataIds {
Position = '20202020-dd6d-4f67-94aa-22cc83eb0a2e',
WorkspaceMember = '20202020-1138-4e93-bbff-917a68161abf',
Person = '20202020-0876-4735-8974-ff4d51aafa07',
Company = '20202020-09e1-4384-ae3e-39e7956396fe',
}
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedFavoriteFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'position',
label: 'Position',
targetColumnMap: {
value: 'position',
},
description: 'Favorite position',
icon: 'IconList',
isNullable: false,
},
// Relationships
{
id: SeedFavoriteFieldMetadataIds.WorkspaceMember,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'workspaceMember',
label: 'Workspace Member',
targetColumnMap: {
value: 'workspaceMemberId',
},
description: 'Favorite workspace member',
icon: 'IconCircleUser',
isNullable: false,
},
{
id: SeedFavoriteFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'Favorite person',
icon: 'IconUser',
isNullable: false,
},
{
id: SeedFavoriteFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Favorite,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'Favorite company',
icon: 'IconBuildingSkyscraper',
isNullable: false,
},
])
.execute();
};

View File

@ -0,0 +1,157 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedOpportunityFieldMetadataIds {
Amount = '20202020-8c1f-4c83-9a89-7843e586564d',
CloseDate = '20202020-de52-4e7b-a298-db7a7553500f',
Probability = '20202020-3b9c-4e58-a3d2-c617d3b596b1',
PipelineStep = '20202020-0a2e-4676-8011-3fdb2c30c258',
PointOfContact = '20202020-618e-42da-b3c3-bcd7af76e355',
Company = '20202020-31d5-4af5-b016-c61c1c265706',
Person = '20202020-0655-41df-b938-15d71e589307',
}
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedOpportunityFieldMetadataIds.Amount,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'MONEY',
name: 'amount',
label: 'Amount',
targetColumnMap: {
value: 'amount',
},
description: 'Opportunity amount',
icon: 'IconCurrencyDollar',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.CloseDate,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'DATE',
name: 'closeDate',
label: 'Close date',
targetColumnMap: {
value: 'closeDate',
},
description: 'Opportunity close date',
icon: 'IconCalendarEvent',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.Probability,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'PROBABILITY',
name: 'probability',
label: 'Probability',
targetColumnMap: {
value: 'probability',
},
description: 'Opportunity amount',
icon: 'IconProgressCheck',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.PipelineStep,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'pipelineStep',
label: 'Pipeline Step',
targetColumnMap: {
value: 'pipelineStepId',
},
description: 'Opportunity pipeline step',
icon: 'IconKanban',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.PointOfContact,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'pointOfContact',
label: 'Point of Contact',
targetColumnMap: {
value: 'pointOfContactId',
},
description: 'Opportunity point of contact',
icon: 'IconUser',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.Person,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'person',
label: 'Person',
targetColumnMap: {
value: 'personId',
},
description: 'Opportunity person',
icon: 'IconUser',
isNullable: true,
},
{
id: SeedOpportunityFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Opportunity,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'Opportunity company',
icon: 'IconBuildingSkyscraper',
isNullable: true,
},
])
.execute();
};

View File

@ -0,0 +1,288 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedPersonFieldMetadataIds {
FirstName = '20202020-9b56-4888-bfe3-f6f59aa999e3',
LastName = '20202020-b784-458a-869d-6c53fa85483d',
Email = '20202020-8a96-4e4b-86fd-ea126530e0c1',
LinkedinUrl = '20202020-dcf6-445a-b543-37e55de43c25',
XUrl = '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',
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',
])
.orIgnore()
.values([
// Main Identifier
{
id: SeedPersonFieldMetadataIds.FirstName,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'firstName',
label: 'First name',
targetColumnMap: {
value: 'firstName',
},
description: 'Contacts first name',
icon: 'IconUser',
isNullable: false,
},
{
id: SeedPersonFieldMetadataIds.LastName,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'lastName',
label: 'Last name',
targetColumnMap: {
value: 'lastName',
},
description: 'Contacts last name',
icon: 'IconUser',
isNullable: false,
},
// Scalar Fields
{
id: SeedPersonFieldMetadataIds.Email,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'EMAIL',
name: 'email',
label: 'Email',
targetColumnMap: {
value: 'email',
},
description: 'Contacts Email',
icon: 'IconMail',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.LinkedinUrl,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'URL',
name: 'linkedinUrl',
label: 'Linkedin',
targetColumnMap: {
value: 'linkedinUrl',
},
description: 'Contacts Linkedin account',
icon: 'IconBrandLinkedin',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.XUrl,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'URL',
name: 'xUrl',
label: 'X',
targetColumnMap: {
value: 'xUrl',
},
description: 'Contacts X/Twitter account',
icon: 'IconUser',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.JobTitle,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'jobTitle',
label: 'Job Title',
targetColumnMap: {
value: 'jobTitle',
},
description: 'Contacts job title',
icon: 'IconBriefcase',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.Phone,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'phone',
label: 'Phone',
targetColumnMap: {
value: 'phone',
},
description: 'Contacts phone number',
icon: 'IconPhone',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.City,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'city',
label: 'City',
targetColumnMap: {
value: 'city',
},
description: 'Contacts city',
icon: 'IconMap',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.AvatarUrl,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'avatarUrl',
label: 'Avatar',
targetColumnMap: {
value: 'avatarUrl',
},
description: 'Contacts avatar',
icon: 'IconFileUpload',
isNullable: false,
},
// Relationships
{
id: SeedPersonFieldMetadataIds.Company,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'company',
label: 'Company',
targetColumnMap: {
value: 'companyId',
},
description: 'Contacts company',
icon: 'IconBuildingSkyscraper',
isNullable: false,
},
{
id: SeedPersonFieldMetadataIds.ContactForOpportunities,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'pointOfContactForOpporunities',
label: 'POC for Opportunities',
targetColumnMap: {},
description: 'Point of Contact for Opportuniites',
icon: 'IconArrowTarget',
isNullable: false,
},
{
id: SeedPersonFieldMetadataIds.ActivityTargets,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'activityTargets',
label: 'Activities',
targetColumnMap: {},
description: 'Activities tied to the contact',
icon: 'IconCheckbox',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the contact.',
icon: 'IconTargetArrow',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the contact',
icon: 'IconHeart',
isNullable: true,
},
{
id: SeedPersonFieldMetadataIds.Attachments,
objectMetadataId: SeedObjectMetadataIds.Person,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'attachments',
label: 'Attachments',
targetColumnMap: {},
description: 'Attachments linked to the contact.',
icon: 'IconFileImport',
isNullable: true,
},
])
.execute();
};

View File

@ -0,0 +1,107 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedPipelineStepFieldMetadataIds {
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',
])
.orIgnore()
.values([
// Main Identifier
{
id: SeedPipelineStepFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'name',
label: 'Name',
targetColumnMap: {
value: 'name',
},
description: 'Pipeline Step name',
icon: 'IconCurrencyDollar',
isNullable: false,
},
// Scalar Fields
{
id: SeedPipelineStepFieldMetadataIds.Color,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'color',
label: 'Color',
targetColumnMap: {
value: 'color',
},
description: 'Pipeline Step color',
icon: 'IconColorSwatch',
isNullable: false,
},
{
id: SeedPipelineStepFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'NUMBER',
name: 'position',
label: 'Position',
targetColumnMap: {
value: 'position',
},
description: 'Pipeline Step position',
icon: 'IconHierarchy2',
isNullable: false,
},
// Relationships
{
id: SeedPipelineStepFieldMetadataIds.Opportunities,
objectMetadataId: SeedObjectMetadataIds.PipelineStep,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'opportunities',
label: 'Opportunities',
targetColumnMap: {},
description: 'Opportunities linked to the step.',
icon: 'IconTargetArrow',
isNullable: true,
},
])
.execute();
};

View File

@ -1,6 +1,17 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const tableName = 'fieldMetadata'; import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFieldFieldMetadataIds {
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',
}
export const seedViewFieldFieldMetadata = async ( export const seedViewFieldFieldMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
@ -9,7 +20,7 @@ export const seedViewFieldFieldMetadata = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${fieldMetadataTableName}`, [
'id', 'id',
'objectMetadataId', 'objectMetadataId',
'isCustom', 'isCustom',
@ -26,9 +37,10 @@ export const seedViewFieldFieldMetadata = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', id: SeedViewFieldFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'fieldMetadataId', name: 'fieldMetadataId',
@ -37,27 +49,28 @@ export const seedViewFieldFieldMetadata = async (
value: 'fieldMetadataId', value: 'fieldMetadataId',
}, },
description: 'View Field target field', description: 'View Field target field',
icon: null, icon: 'IconTag',
isNullable: false, isNullable: false,
}, },
{ {
id: 'a9a56210-a154-4965-9ace-c35f6dc43ee5', id: SeedViewFieldFieldMetadataIds.View,
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'RELATION', type: 'RELATION',
name: 'view', name: 'view',
label: 'View Id', label: 'View Id',
targetColumnMap: { value: 'viewId' }, targetColumnMap: { value: 'viewId' },
description: 'View Field related view', description: 'View Field related view',
icon: null, icon: 'IconLayoutCollage',
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', id: SeedViewFieldFieldMetadataIds.IsVisible,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'BOOLEAN', type: 'BOOLEAN',
name: 'isVisible', name: 'isVisible',
@ -66,13 +79,14 @@ export const seedViewFieldFieldMetadata = async (
value: 'isVisible', value: 'isVisible',
}, },
description: 'View Field visibility', description: 'View Field visibility',
icon: null, icon: 'IconEye',
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', id: SeedViewFieldFieldMetadataIds.Size,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'NUMBER', type: 'NUMBER',
name: 'size', name: 'size',
@ -81,13 +95,14 @@ export const seedViewFieldFieldMetadata = async (
value: 'size', value: 'size',
}, },
description: 'View Field size', description: 'View Field size',
icon: null, icon: 'IconEye',
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', id: SeedViewFieldFieldMetadataIds.Position,
objectMetadataId: SeedObjectMetadataIds.ViewField,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'NUMBER', type: 'NUMBER',
name: 'position', name: 'position',
@ -96,7 +111,7 @@ export const seedViewFieldFieldMetadata = async (
value: 'position', value: 'position',
}, },
description: 'View Field position', description: 'View Field position',
icon: null, icon: 'IconList',
isNullable: false, isNullable: false,
}, },
]) ])

View File

@ -1,6 +1,17 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const tableName = 'fieldMetadata'; import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFilterFieldMetadataIds {
FieldMetadataId = '20202020-78bb-4f2b-a052-260bc8efd694',
View = '20202020-65e5-4082-829d-8c634c20e7b5',
Operand = '20202020-1d12-465d-ab2c-8af008182730',
Value = '20202020-8b37-46ae-86b8-14287ec06802',
DisplayValue = '20202020-ed89-4892-83fa-d2b2929c6d52',
}
export const seedViewFilterFieldMetadata = async ( export const seedViewFilterFieldMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
@ -9,7 +20,8 @@ export const seedViewFilterFieldMetadata = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId', 'objectMetadataId',
'isCustom', 'isCustom',
'workspaceId', 'workspaceId',
@ -26,9 +38,10 @@ export const seedViewFilterFieldMetadata = async (
.values([ .values([
// View Filters // View Filters
{ {
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedViewFilterFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'fieldMetadataId', name: 'fieldMetadataId',
@ -41,9 +54,10 @@ export const seedViewFilterFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedViewFilterFieldMetadataIds.View,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'viewId', name: 'viewId',
@ -52,13 +66,14 @@ export const seedViewFilterFieldMetadata = async (
value: 'viewId', value: 'viewId',
}, },
description: 'View Filter related view', description: 'View Filter related view',
icon: null, icon: 'IconLayoutCollage',
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedViewFilterFieldMetadataIds.Operand,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'operand', name: 'operand',
@ -71,9 +86,10 @@ export const seedViewFilterFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedViewFilterFieldMetadataIds.Value,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'value', name: 'value',
@ -86,9 +102,10 @@ export const seedViewFilterFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedViewFilterFieldMetadataIds.DisplayValue,
objectMetadataId: SeedObjectMetadataIds.ViewFilter,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'displayValue', name: 'displayValue',

View File

@ -1,6 +1,15 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const tableName = 'fieldMetadata'; import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewSortFieldMetadataIds {
FieldMetadataId = '20202020-cb2c-4c8f-a289-c9851b23d064',
View = '20202020-f5d0-467f-a3d8-395ba16b8ebf',
Direction = '20202020-077e-4451-b1d8-e602c956ebd2',
}
export const seedViewSortFieldMetadata = async ( export const seedViewSortFieldMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
@ -9,7 +18,8 @@ export const seedViewSortFieldMetadata = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId', 'objectMetadataId',
'isCustom', 'isCustom',
'workspaceId', 'workspaceId',
@ -25,9 +35,10 @@ export const seedViewSortFieldMetadata = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251', id: SeedViewSortFieldMetadataIds.FieldMetadataId,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'fieldMetadataId', name: 'fieldMetadataId',
@ -40,9 +51,10 @@ export const seedViewSortFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251', id: SeedViewSortFieldMetadataIds.View,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'viewId', name: 'viewId',
@ -51,13 +63,14 @@ export const seedViewSortFieldMetadata = async (
value: 'viewId', value: 'viewId',
}, },
description: 'View Sort related view', description: 'View Sort related view',
icon: null, icon: 'IconLayoutCollage',
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251', id: SeedViewSortFieldMetadataIds.Direction,
objectMetadataId: SeedObjectMetadataIds.ViewSort,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'direction', name: 'direction',

View File

@ -1,6 +1,18 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const tableName = 'fieldMetadata'; import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedViewFieldMetadataIds {
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 ( export const seedViewFieldMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
@ -9,7 +21,7 @@ export const seedViewFieldMetadata = async (
await workspaceDataSource await workspaceDataSource
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${fieldMetadataTableName}`, [
'id', 'id',
'objectMetadataId', 'objectMetadataId',
'isCustom', 'isCustom',
@ -26,9 +38,10 @@ export const seedViewFieldMetadata = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', id: SeedViewFieldMetadataIds.Name,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'name', name: 'name',
@ -41,9 +54,10 @@ export const seedViewFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', id: SeedViewFieldMetadataIds.ObjectMetadataId,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'objectMetadataId', name: 'objectMetadataId',
@ -56,9 +70,10 @@ export const seedViewFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', id: SeedViewFieldMetadataIds.Type,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'TEXT', type: 'TEXT',
name: 'type', name: 'type',
@ -71,18 +86,46 @@ export const seedViewFieldMetadata = async (
isNullable: false, isNullable: false,
}, },
{ {
id: '064eb439-fdfa-4246-a13a-989c5bcc4d97', id: SeedViewFieldMetadataIds.ViewFields,
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
type: 'RELATION', type: 'RELATION',
name: 'viewFields', name: 'viewFields',
label: 'View Fields', label: 'View Fields',
targetColumnMap: {}, targetColumnMap: {},
description: 'View Fields', description: 'View Fields',
icon: null, icon: 'IconTag',
isNullable: false, isNullable: true,
},
{
id: SeedViewFieldMetadataIds.ViewSorts,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'viewSorts',
label: 'View Sorts',
targetColumnMap: {},
description: 'View Sorts',
icon: 'IconArrowsSort',
isNullable: true,
},
{
id: SeedViewFieldMetadataIds.ViewFilters,
objectMetadataId: SeedObjectMetadataIds.View,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'viewFilters',
label: 'View Filters',
targetColumnMap: {},
description: 'View Filters',
icon: 'IconFilterBolt',
isNullable: true,
}, },
]) ])
.execute(); .execute();

View File

@ -0,0 +1,71 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedWebhookFieldMetadataIds {
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedWebhookFieldMetadataIds.TargetUrl,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'targetUrl',
label: 'Target Url',
targetColumnMap: {
value: 'targetUrl',
},
description: 'Webhook target url',
icon: 'IconLink',
isNullable: false,
},
{
id: SeedWebhookFieldMetadataIds.Operation,
objectMetadataId: SeedObjectMetadataIds.Webhook,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'operation',
label: 'Operation',
targetColumnMap: {
value: 'operation',
},
description: 'Webhook operation',
icon: 'IconCheckbox',
isNullable: false,
},
])
.execute();
};

View File

@ -0,0 +1,90 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedWorkspaceMemberSettingsFieldMetadataIds {
ColorScheme = '20202020-d7b7-4f2e-bb52-90d3fd78007a',
Locale = '20202020-10f6-4df9-8d6f-a760b65bd800',
WorkspaceMember = '20202020-83f2-4c5f-96b0-0c51ecc160e3',
}
export const seedWorkspaceMemberSettingsFieldMetadata = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${fieldMetadataTableName}`, [
'id',
'objectMetadataId',
'isCustom',
'workspaceId',
'isActive',
'type',
'name',
'label',
'targetColumnMap',
'description',
'icon',
'isNullable',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedWorkspaceMemberSettingsFieldMetadataIds.ColorScheme,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMemberSettings,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'colorScheme',
label: 'Color Scheme',
targetColumnMap: {
value: 'colorScheme',
},
description: 'Preferred color scheme',
icon: 'IconColorSwatch',
isNullable: false,
},
{
id: SeedWorkspaceMemberSettingsFieldMetadataIds.Locale,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMemberSettings,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'TEXT',
name: 'locale',
label: 'Language',
targetColumnMap: {
value: 'colorScheme',
},
description: 'Preferred language',
icon: 'IconLanguage',
isNullable: false,
},
// Relationships
{
id: SeedWorkspaceMemberSettingsFieldMetadataIds.WorkspaceMember,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMemberSettings,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'workspaceMember',
label: 'Workspace member',
targetColumnMap: {
value: 'workspaceMemberId',
},
description: 'Workspace member associated with these settings',
icon: 'IconUserCircle',
isNullable: false,
},
])
.execute();
};

View File

@ -0,0 +1,180 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
const fieldMetadataTableName = 'fieldMetadata';
export enum SeedWorkspaceMemberFieldMetadataIds {
AllowImpersonation = '20202020-bb19-44a1-8156-8866f87a5f42',
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',
])
.orIgnore()
.values([
// Scalar fields
{
id: SeedWorkspaceMemberFieldMetadataIds.UserId,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'UUID',
name: 'userId',
label: 'User Id',
targetColumnMap: {
value: 'userId',
},
description: 'Associated User Id',
icon: 'IconCircleUsers',
isNullable: false,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AllowImpersonation,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'BOOLEAN',
name: 'allowImpersonation',
label: 'Admin Access',
targetColumnMap: {
value: 'allowImpersonation',
},
description: 'Allow Admin Access',
icon: 'IconEye',
isNullable: false,
},
// Relationships
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredActivities,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'authoredActivities',
label: 'Authored activities',
targetColumnMap: {},
description: 'Activities created by the workspace member',
icon: 'IconCheckbox',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AssignedActivities,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'assignedActivities',
label: 'Assigned activities',
targetColumnMap: {},
description: 'Activities assigned to the workspace member',
icon: 'IconCheckbox',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.Favorites,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'favorites',
label: 'Favorites',
targetColumnMap: {},
description: 'Favorites linked to the workspace member',
icon: 'IconHeart',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AccountOwnerForCompanies,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'accountOwnerForCompanies',
label: 'Account Owner For Companies',
targetColumnMap: {},
description: 'Account owner for companies',
icon: 'IconBriefcase',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredAttachments,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'authoredAttachments',
label: 'Authored attachments',
targetColumnMap: {},
description: 'Attachments created by the workspace member',
icon: 'IconFileImport',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.AuthoredComments,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'authoredComments',
label: 'Authored comments',
targetColumnMap: {},
description: 'Authored comments',
icon: 'IconComment',
isNullable: true,
},
{
id: SeedWorkspaceMemberFieldMetadataIds.Settings,
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
isCustom: false,
workspaceId: SeedWorkspaceId,
isActive: true,
type: 'RELATION',
name: 'settings',
label: 'Settings',
targetColumnMap: {
value: 'settingsId',
},
description: 'Workspace member settings',
icon: 'IconSettings',
isNullable: false,
},
])
.execute();
};

View File

@ -0,0 +1,60 @@
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 { seedWorkspaceMemberSettingsFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/workspace-member-settings';
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';
export const seedMetadataSchema = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await seedObjectMetadata(workspaceDataSource, schemaName);
await seedActivityTargetFieldMetadata(workspaceDataSource, schemaName);
await seedActivityFieldMetadata(workspaceDataSource, schemaName);
await seedApiKeyFieldMetadata(workspaceDataSource, schemaName);
await seedAttachmentFieldMetadata(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 seedWorkspaceMemberSettingsFieldMetadata(
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,7 +1,29 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { SeedDataSourceId, SeedWorkspaceId } from 'src/database/seeds/metadata';
const tableName = 'objectMetadata'; 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',
WorkspaceMemberSettings = '20202020-166d-445c-970f-da1ea43f1dc7',
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 ( export const seedObjectMetadata = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
schemaName: string, schemaName: string,
@ -25,7 +47,7 @@ export const seedObjectMetadata = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
id: '1a8487a0-480c-434e-b4c7-e22408b97047', id: SeedObjectMetadataIds.Company,
nameSingular: 'companyV2', nameSingular: 'companyV2',
namePlural: 'companiesV2', namePlural: 'companiesV2',
labelSingular: 'Company', labelSingular: 'Company',
@ -33,12 +55,168 @@ export const seedObjectMetadata = async (
targetTableName: 'company', targetTableName: 'company',
description: 'A company', description: 'A company',
icon: 'IconBuildingSkyscraper', icon: 'IconBuildingSkyscraper',
dataSourceId: 'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', dataSourceId: SeedDataSourceId,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
}, },
{ {
id: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', id: SeedObjectMetadataIds.Person,
nameSingular: 'personV2',
namePlural: 'peopleV2',
labelSingular: 'Person',
labelPlural: 'People',
targetTableName: 'person',
description: 'A person',
icon: 'IconUser',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Opportunity,
nameSingular: 'opportunityV2',
namePlural: 'opportunitiesV2',
labelSingular: 'Opportunity',
labelPlural: 'Opportunities',
targetTableName: 'opportunity',
description: 'An opportunity',
icon: 'IconTargetArrow',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.PipelineStep,
nameSingular: 'pipelineStepV2',
namePlural: 'pipelineStepsV2',
labelSingular: 'Pipeline Step',
labelPlural: 'Pipeline Steps',
targetTableName: 'pipelineStep',
description: 'A pipeline step',
icon: 'IconLayoutKanban',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.WorkspaceMember,
nameSingular: 'workspaceMemberV2',
namePlural: 'workspaceMembersV2',
labelSingular: 'Workspace Member',
labelPlural: 'Workspace Members',
targetTableName: 'workspaceMember',
description: 'A workspace member',
icon: 'IconUserCircle',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.WorkspaceMemberSettings,
nameSingular: 'workspaceMemberSettingV2',
namePlural: 'workspaceMemberSettingsV2',
labelSingular: 'WorkspaceMemberSetting',
labelPlural: 'Workspace Member Settings',
targetTableName: 'workspaceMemberSetting',
description: 'A workspace member setting',
icon: 'IconSettings',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Webhook,
nameSingular: 'webhookV2',
namePlural: 'webhooksV2',
labelSingular: 'Webhook',
labelPlural: 'Webhooks',
targetTableName: 'webhook',
description: 'A webhook',
icon: 'IconRobot',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.ApiKey,
nameSingular: 'apiKeyV2',
namePlural: 'apiKeysV2',
labelSingular: 'Api Key',
labelPlural: 'Api Keys',
targetTableName: 'apiKey',
description: 'An api key',
icon: 'IconRobot',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Activity,
nameSingular: 'activityV2',
namePlural: 'activitiesV2',
labelSingular: 'Activity',
labelPlural: 'Activities',
targetTableName: 'activity',
description: 'An activity',
icon: 'IconCheckbox',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.ActivityTarget,
nameSingular: 'activityTargetV2',
namePlural: 'activityTargetsV2',
labelSingular: 'Activity Target',
labelPlural: 'Activity Targets',
targetTableName: 'activityTarget',
description: 'An activity target',
icon: 'IconCheckbox',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Comment,
nameSingular: 'commentV2',
namePlural: 'commentsV2',
labelSingular: 'Comment',
labelPlural: 'Comments',
targetTableName: 'comment',
description: 'A comment',
icon: 'IconMessageCircle',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Attachment,
nameSingular: 'attachmentV2',
namePlural: 'attachmentsV2',
labelSingular: 'Attachment',
labelPlural: 'Attachments',
targetTableName: 'attachment',
description: 'An attachment',
icon: 'IconFileImport',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.Favorite,
nameSingular: 'favoriteV2',
namePlural: 'favoritesV2',
labelSingular: 'Favorite',
labelPlural: 'Favorites',
targetTableName: 'favorite',
description: 'A favorite',
icon: 'IconHeart',
dataSourceId: SeedDataSourceId,
workspaceId: SeedWorkspaceId,
isActive: true,
},
{
id: SeedObjectMetadataIds.View,
nameSingular: 'viewV2', nameSingular: 'viewV2',
namePlural: 'viewsV2', namePlural: 'viewsV2',
labelSingular: 'View', labelSingular: 'View',
@ -46,25 +224,25 @@ export const seedObjectMetadata = async (
targetTableName: 'view', targetTableName: 'view',
description: '(System) Views', description: '(System) Views',
icon: 'IconLayoutCollage', icon: 'IconLayoutCollage',
dataSourceId: 'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', dataSourceId: SeedDataSourceId,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
}, },
{ {
id: '61d9000b-485c-4c48-a22e-0d9a164f9647', id: SeedObjectMetadataIds.ViewField,
nameSingular: 'viewFieldV2', nameSingular: 'viewFieldV2',
namePlural: 'viewFieldsV2', namePlural: 'viewFieldsV2',
labelSingular: 'View Field', labelSingular: 'View Field',
labelPlural: 'View Fields', labelPlural: 'View Fields',
targetTableName: 'viewField', targetTableName: 'viewField',
description: '(System) View Fields', description: '(System) View Fields',
icon: 'IconColumns3', icon: 'IconTag',
dataSourceId: 'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', dataSourceId: SeedDataSourceId,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
}, },
{ {
id: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3', id: SeedObjectMetadataIds.ViewFilter,
nameSingular: 'viewFilterV2', nameSingular: 'viewFilterV2',
namePlural: 'viewFiltersV2', namePlural: 'viewFiltersV2',
labelSingular: 'View Filter', labelSingular: 'View Filter',
@ -72,12 +250,12 @@ export const seedObjectMetadata = async (
targetTableName: 'viewFilter', targetTableName: 'viewFilter',
description: '(System) View Filters', description: '(System) View Filters',
icon: 'IconFilterBolt', icon: 'IconFilterBolt',
dataSourceId: 'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', dataSourceId: SeedDataSourceId,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
}, },
{ {
id: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251', id: SeedObjectMetadataIds.ViewSort,
nameSingular: 'viewSortV2', nameSingular: 'viewSortV2',
namePlural: 'viewSortsV2', namePlural: 'viewSortsV2',
labelSingular: 'View Sort', labelSingular: 'View Sort',
@ -85,8 +263,8 @@ export const seedObjectMetadata = async (
targetTableName: 'viewSort', targetTableName: 'viewSort',
description: '(System) View Sorts', description: '(System) View Sorts',
icon: 'IconArrowsSort', icon: 'IconArrowsSort',
dataSourceId: 'b37b2163-7f63-47a9-b1b3-6c7290ca9fb1', dataSourceId: SeedDataSourceId,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: SeedWorkspaceId,
isActive: true, isActive: true,
}, },
]) ])

View File

@ -0,0 +1,56 @@
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 { SeedWorkspaceId } from 'src/database/seeds/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';
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

@ -0,0 +1,74 @@
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 { SeedWorkspaceId } from 'src/database/seeds/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';
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

@ -0,0 +1,73 @@
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 { SeedWorkspaceId } from 'src/database/seeds/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';
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

@ -0,0 +1,38 @@
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 { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { SeedPipelineStepFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/pipeline-step';
import { SeedOpportunityFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/opportunity';
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,6 +1,12 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity'; 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 { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { SeedViewFilterFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view-filter';
import { SeedViewSortFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/view-sort';
const tableName = 'relationMetadata'; const tableName = 'relationMetadata';
@ -23,11 +29,27 @@ export const seedViewRelationMetadata = async (
.values([ .values([
{ {
relationType: RelationMetadataType.ONE_TO_MANY, relationType: RelationMetadataType.ONE_TO_MANY,
fromObjectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', // View fromObjectMetadataId: SeedObjectMetadataIds.View,
toObjectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', // ViewField toObjectMetadataId: SeedObjectMetadataIds.ViewField,
fromFieldMetadataId: '064eb439-fdfa-4246-a13a-989c5bcc4d97', // View > ViewFields fromFieldMetadataId: SeedViewFieldMetadataIds.ViewFields,
toFieldMetadataId: 'a9a56210-a154-4965-9ace-c35f6dc43ee5', // ViewField > View toFieldMetadataId: SeedViewFieldFieldMetadataIds.View,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', 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(); .execute();

View File

@ -0,0 +1,97 @@
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 { SeedWorkspaceId } from 'src/database/seeds/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 { SeedWorkspaceMemberSettingsFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/workspace-member-settings';
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';
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_ONE,
fromObjectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
toObjectMetadataId: SeedObjectMetadataIds.WorkspaceMemberSettings,
fromFieldMetadataId: SeedWorkspaceMemberFieldMetadataIds.Settings,
toFieldMetadataId:
SeedWorkspaceMemberSettingsFieldMetadataIds.WorkspaceMember,
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

@ -1,5 +1,8 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { SeedViewIds } from 'src/database/typeorm-seeds/tenant/views';
import { SeedCompanyFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
const tableName = 'viewField'; const tableName = 'viewField';
export const seedViewFields = async ( export const seedViewFields = async (
@ -10,7 +13,6 @@ export const seedViewFields = async (
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(`${schemaName}.${tableName}`, [ .into(`${schemaName}.${tableName}`, [
'id',
'fieldMetadataId', 'fieldMetadataId',
'viewId', 'viewId',
'position', 'position',
@ -20,141 +22,132 @@ export const seedViewFields = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
id: '46a72a5b-276e-4241-a05f-c054410aebcb',
fieldMetadataId: 'name', fieldMetadataId: 'name',
viewId: '10bec73c-0aea-4cc4-a3b2-8c2186f29b43', viewId: SeedViewIds.PrismaCompany,
position: 0, position: 0,
isVisible: true, isVisible: true,
size: 180, size: 180,
}, },
{ {
id: 'f15b26ff-8f79-49dd-8f53-4286dd1af846',
fieldMetadataId: 'name',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80',
position: 0,
isVisible: true,
size: 180,
},
{
id: '8d1dbb50-c97f-42c4-8575-3d2c9bdeb6e5',
fieldMetadataId: 'domainName', fieldMetadataId: 'domainName',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 1, position: 1,
isVisible: true, isVisible: true,
size: 100, size: 100,
}, },
{ {
id: '33833b3b-4e02-4f10-91fc-c594422952af',
fieldMetadataId: 'accountOwner', fieldMetadataId: 'accountOwner',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 2, position: 2,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'c750a968-832e-4812-a1a2-74f515af55c1',
fieldMetadataId: 'createdAt', fieldMetadataId: 'createdAt',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 3, position: 3,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: '2fde3187-a0bc-47ca-80bd-457bd826fb4a',
fieldMetadataId: 'employees', fieldMetadataId: 'employees',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 4, position: 4,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: '2fead26f-3f4f-4a4d-a4c6-3abe7b2f74c9',
fieldMetadataId: 'linkedin', fieldMetadataId: 'linkedin',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 5, position: 5,
isVisible: true, isVisible: true,
size: 170, size: 170,
}, },
{ {
id: '0cffa82a-c851-4e17-b46c-2c4642d78329',
fieldMetadataId: 'address', fieldMetadataId: 'address',
viewId: '37a8a866-eb17-4e76-9382-03143a2f6a80', viewId: SeedViewIds.PrismaCompany,
position: 6, position: 6,
isVisible: true, isVisible: true,
size: 170, size: 170,
}, },
{ {
id: '93a68c4a-8107-409a-9adb-06305ffbd692',
fieldMetadataId: 'displayName', fieldMetadataId: 'displayName',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 0, position: 0,
isVisible: true, isVisible: true,
size: 210, size: 210,
}, },
{ {
id: 'd955ee31-6316-4cb2-af71-9609dede4d7e',
fieldMetadataId: 'email', fieldMetadataId: 'email',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 1, position: 1,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'bceb4d84-8ad1-4a0e-9333-efb870b42eb8',
fieldMetadataId: 'company', fieldMetadataId: 'company',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 2, position: 2,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'bef874d4-f349-4cdb-ae28-6e9fc497449b',
fieldMetadataId: 'phone', fieldMetadataId: 'phone',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 3, position: 3,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'e06f920d-1af9-404d-8b9a-4f97c4009a4a',
fieldMetadataId: 'createdAt', fieldMetadataId: 'createdAt',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 4, position: 4,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: '92d94ee8-31fc-4025-a427-29291abb2b19',
fieldMetadataId: 'city', fieldMetadataId: 'city',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 5, position: 5,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'b38e4022-1559-40da-bd5e-29d89b6c8330',
fieldMetadataId: 'jobTitle', fieldMetadataId: 'jobTitle',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 6, position: 6,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: '30147fab-9666-4db5-a11b-20af4544c712',
fieldMetadataId: 'linkedin', fieldMetadataId: 'linkedin',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 7, position: 7,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{ {
id: 'f0870949-21ac-46a2-b3ec-d1b0107c434c',
fieldMetadataId: 'x', fieldMetadataId: 'x',
viewId: '6095799e-b48f-4e00-b071-10818083593a', viewId: SeedViewIds.PrismaPerson,
position: 8, position: 8,
isVisible: true, isVisible: true,
size: 150, size: 150,
}, },
{
fieldMetadataId: SeedCompanyFieldMetadataIds.Name,
viewId: SeedViewIds.Company,
position: 0,
isVisible: true,
size: 180,
},
{
fieldMetadataId: SeedCompanyFieldMetadataIds.DomainName,
viewId: SeedViewIds.Company,
position: 1,
isVisible: true,
size: 100,
},
]) ])
.execute(); .execute();
}; };

View File

@ -1,7 +1,18 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
const tableName = 'view'; const tableName = 'view';
export const enum SeedViewIds {
PrismaCompany = '20202020-1ad3-4d1b-81f3-d7ecba29f8d3',
PrismaPerson = '20202020-9adf-4768-bd9c-27a82fa141f1',
PrismaOpportunity = '20202020-ffc7-4c81-bb41-d4baed4ed685',
Company = '20202020-2441-4424-8163-4002c523d415',
Person = '20202020-1979-447d-8115-593744eb4ead',
Opportunity = '20202020-b2b3-48a5-96ce-0936d6af21f7',
}
export const seedViews = async ( export const seedViews = async (
workspaceDataSource: DataSource, workspaceDataSource: DataSource,
schemaName: string, schemaName: string,
@ -18,29 +29,41 @@ export const seedViews = async (
.orIgnore() .orIgnore()
.values([ .values([
{ {
id: '37a8a866-eb17-4e76-9382-03143a2f6a80', id: SeedViewIds.PrismaCompany,
name: 'All companies', name: 'All companies',
objectMetadataId: 'company', objectMetadataId: 'company',
type: 'table', type: 'table',
}, },
{ {
id: '6095799e-b48f-4e00-b071-10818083593a', id: SeedViewIds.PrismaPerson,
name: 'All people', name: 'All people',
objectMetadataId: 'person', objectMetadataId: 'person',
type: 'table', type: 'table',
}, },
{ {
id: 'e26f66b7-f890-4a5c-b4d2-ec09987b5308', id: SeedViewIds.PrismaOpportunity,
name: 'All opportunities', name: 'All opportunities',
objectMetadataId: 'company', objectMetadataId: 'company',
type: 'kanban', type: 'kanban',
}, },
{ {
id: '10bec73c-0aea-4cc4-a3b2-8c2186f29b43', id: SeedViewIds.Company,
name: 'All Companies (V2)', name: 'All Companies',
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047', objectMetadataId: SeedObjectMetadataIds.Company,
type: 'table', type: 'table',
}, },
{
id: SeedViewIds.Person,
name: 'All People',
objectMetadataId: SeedObjectMetadataIds.Company,
type: 'table',
},
{
id: SeedViewIds.Opportunity,
name: 'All Opportunities',
objectMetadataId: SeedObjectMetadataIds.Opportunity,
type: 'kanban',
},
]) ])
.execute(); .execute();
}; };

View File

@ -17,13 +17,14 @@ import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metada
import { RelationMetadataEntity } from 'src/metadata/relation-metadata/relation-metadata.entity'; import { RelationMetadataEntity } from 'src/metadata/relation-metadata/relation-metadata.entity';
export enum FieldMetadataType { export enum FieldMetadataType {
UUID = 'uuid', UUID = 'UUID',
TEXT = 'TEXT', TEXT = 'TEXT',
PHONE = 'PHONE', PHONE = 'PHONE',
EMAIL = 'EMAIL', EMAIL = 'EMAIL',
DATE = 'DATE', DATE = 'DATE',
BOOLEAN = 'BOOLEAN', BOOLEAN = 'BOOLEAN',
NUMBER = 'NUMBER', NUMBER = 'NUMBER',
PROBABILITY = 'PROBABILITY',
ENUM = 'ENUM', ENUM = 'ENUM',
URL = 'URL', URL = 'URL',
MONEY = 'MONEY', MONEY = 'MONEY',

View File

@ -28,6 +28,7 @@ export function generateTargetColumnMap(
case FieldMetadataType.PHONE: case FieldMetadataType.PHONE:
case FieldMetadataType.EMAIL: case FieldMetadataType.EMAIL:
case FieldMetadataType.NUMBER: case FieldMetadataType.NUMBER:
case FieldMetadataType.PROBABILITY:
case FieldMetadataType.BOOLEAN: case FieldMetadataType.BOOLEAN:
case FieldMetadataType.DATE: case FieldMetadataType.DATE:
return { return {
@ -70,11 +71,12 @@ export function convertFieldMetadataToColumnActions(
}, },
]; ];
case FieldMetadataType.NUMBER: case FieldMetadataType.NUMBER:
case FieldMetadataType.PROBABILITY:
return [ return [
{ {
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.value, columnName: fieldMetadata.targetColumnMap.value,
columnType: 'integer', columnType: 'float',
}, },
]; ];
case FieldMetadataType.BOOLEAN: case FieldMetadataType.BOOLEAN:

View File

@ -86,6 +86,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
'fields.fromRelationMetadata.toObjectMetadata.fields', 'fields.fromRelationMetadata.toObjectMetadata.fields',
'fields.toRelationMetadata', 'fields.toRelationMetadata',
'fields.toRelationMetadata.fromObjectMetadata', 'fields.toRelationMetadata.fromObjectMetadata',
'fields.toRelationMetadata.fromObjectMetadata.fields',
'fields.toRelationMetadata.toObjectMetadata', 'fields.toRelationMetadata.toObjectMetadata',
], ],
}); });
@ -102,6 +103,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
'fields.fromRelationMetadata.toObjectMetadata.fields', 'fields.fromRelationMetadata.toObjectMetadata.fields',
'fields.toRelationMetadata', 'fields.toRelationMetadata',
'fields.toRelationMetadata.fromObjectMetadata', 'fields.toRelationMetadata.fromObjectMetadata',
'fields.toRelationMetadata.fromObjectMetadata.fields',
'fields.toRelationMetadata.toObjectMetadata', 'fields.toRelationMetadata.toObjectMetadata',
], ],
}); });

View File

@ -17,7 +17,7 @@ import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-me
export class CreateRelationInput { export class CreateRelationInput {
@IsEnum(RelationMetadataType) @IsEnum(RelationMetadataType)
@IsNotEmpty() @IsNotEmpty()
@Field() @Field(() => RelationMetadataType)
relationType: RelationMetadataType; relationType: RelationMetadataType;
@IsUUID() @IsUUID()

View File

@ -29,7 +29,7 @@ export class RelationMetadataDTO {
@IDField(() => ID) @IDField(() => ID)
id: string; id: string;
@Field() @Field(() => RelationMetadataType)
relationType: RelationMetadataType; relationType: RelationMetadataType;
@Field() @Field()

View File

@ -1,3 +1,5 @@
import { registerEnumType } from '@nestjs/graphql';
import { import {
Column, Column,
CreateDateColumn, CreateDateColumn,
@ -20,6 +22,11 @@ export enum RelationMetadataType {
MANY_TO_MANY = 'MANY_TO_MANY', MANY_TO_MANY = 'MANY_TO_MANY',
} }
registerEnumType(RelationMetadataType, {
name: 'RelationMetadataType',
description: 'Type of the relation',
});
@Entity('relationMetadata') @Entity('relationMetadata')
export class RelationMetadataEntity implements RelationMetadataInterface { export class RelationMetadataEntity implements RelationMetadataInterface {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')

View File

@ -32,6 +32,42 @@ export const addCompanyTable: TenantMigrationTableAction[] = [
columnType: 'integer', columnType: 'integer',
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
}, },
{
columnName: 'linkedinUrl_link',
columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'linkedinUrl',
columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'xUrl',
columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'annualRecurringRevenue',
columnType: 'float',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'idealCustomerProfile',
columnType: 'boolean',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'accountOwnerId',
columnType: 'uuid',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'accountOwnerId',
referencedTableName: 'workspaceMember',
referencedTableColumnName: 'id',
action: TenantMigrationColumnActionType.RELATION,
},
], ],
}, },
]; ];

View File

@ -17,11 +17,6 @@ export const addViewFilterTable: TenantMigrationTableAction[] = [
columnType: 'varchar', columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
}, },
{
columnName: 'viewId',
columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE,
},
{ {
columnName: 'operand', columnName: 'operand',
columnType: 'varchar', columnType: 'varchar',
@ -37,6 +32,17 @@ export const addViewFilterTable: TenantMigrationTableAction[] = [
columnType: 'varchar', columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
}, },
{
columnName: 'viewId',
columnType: 'uuid',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'viewId',
referencedTableName: 'view',
referencedTableColumnName: 'id',
action: TenantMigrationColumnActionType.RELATION,
},
], ],
}, },
]; ];

View File

@ -17,16 +17,22 @@ export const addViewSortTable: TenantMigrationTableAction[] = [
columnType: 'varchar', columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
}, },
{
columnName: 'viewId',
columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE,
},
{ {
columnName: 'direction', columnName: 'direction',
columnType: 'varchar', columnType: 'varchar',
action: TenantMigrationColumnActionType.CREATE, action: TenantMigrationColumnActionType.CREATE,
}, },
{
columnName: 'viewId',
columnType: 'uuid',
action: TenantMigrationColumnActionType.CREATE,
},
{
columnName: 'viewId',
referencedTableName: 'view',
referencedTableColumnName: 'id',
action: TenantMigrationColumnActionType.RELATION,
},
], ],
}, },
]; ];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addActivityTargetTable: TenantMigrationTableAction[] = [
{
name: 'activityTarget',
action: 'create',
},
{
name: 'activityTarget',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addActivityTable: TenantMigrationTableAction[] = [
{
name: 'activity',
action: 'create',
},
{
name: 'activity',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addApiKeyTable: TenantMigrationTableAction[] = [
{
name: 'apiKey',
action: 'create',
},
{
name: 'apiKey',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addAttachmentTable: TenantMigrationTableAction[] = [
{
name: 'attachment',
action: 'create',
},
{
name: 'attachment',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addCommentTable: TenantMigrationTableAction[] = [
{
name: 'comment',
action: 'create',
},
{
name: 'comment',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addFavoriteTable: TenantMigrationTableAction[] = [
{
name: 'favorite',
action: 'create',
},
{
name: 'favorite',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addOpportunityTable: TenantMigrationTableAction[] = [
{
name: 'opportunity',
action: 'create',
},
{
name: 'opportunity',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addPersonTable: TenantMigrationTableAction[] = [
{
name: 'person',
action: 'create',
},
{
name: 'person',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addPipelineStepTable: TenantMigrationTableAction[] = [
{
name: 'pipelineStep',
action: 'create',
},
{
name: 'pipelineStep',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addWebhookTable: TenantMigrationTableAction[] = [
{
name: 'webhook',
action: 'create',
},
{
name: 'webhook',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addWorkspaceMemberSettingTable: TenantMigrationTableAction[] = [
{
name: 'workspaceMemberSetting',
action: 'create',
},
{
name: 'workspaceMemberSetting',
action: 'alter',
columns: [],
},
];

View File

@ -0,0 +1,13 @@
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
export const addWorkspaceMemberTable: TenantMigrationTableAction[] = [
{
name: 'workspaceMember',
action: 'create',
},
{
name: 'workspaceMember',
action: 'alter',
columns: [],
},
];

View File

@ -1,3 +1,16 @@
import { addActivityTargetTable } from 'src/metadata/tenant-migration/migrations/1697618015-addActivityTargetTable';
import { addActivityTable } from 'src/metadata/tenant-migration/migrations/1697618016-addActivityTable';
import { addApiKeyTable } from 'src/metadata/tenant-migration/migrations/1697618017-addApiKeyTable';
import { addAttachmentTable } from 'src/metadata/tenant-migration/migrations/1697618018-addAttachmentTable';
import { addCommentTable } from 'src/metadata/tenant-migration/migrations/1697618019-addCommentTable';
import { addFavoriteTable } from 'src/metadata/tenant-migration/migrations/1697618020-addFavoriteTable';
import { addOpportunityTable } from 'src/metadata/tenant-migration/migrations/1697618021-addOpportunityTable';
import { addPersonTable } from 'src/metadata/tenant-migration/migrations/1697618022-addPersonTable';
import { addPipelineStepTable } from 'src/metadata/tenant-migration/migrations/1697618023-addPipelineStepTable';
import { addWebhookTable } from 'src/metadata/tenant-migration/migrations/1697618024-addWebhookTable';
import { addWorkspaceMemberSettingTable } from 'src/metadata/tenant-migration/migrations/1697618025-addWorkspaceMemberSettingTable';
import { addWorkspaceMemberTable } from 'src/metadata/tenant-migration/migrations/1697618026-addWorspaceMemberTable';
import { addCompanyTable } from './migrations/1697618009-addCompanyTable'; import { addCompanyTable } from './migrations/1697618009-addCompanyTable';
import { addViewTable } from './migrations/1697618011-addViewTable'; import { addViewTable } from './migrations/1697618011-addViewTable';
import { addViewFieldTable } from './migrations/1697618012-addViewFieldTable'; import { addViewFieldTable } from './migrations/1697618012-addViewFieldTable';
@ -6,9 +19,22 @@ import { addViewSortTable } from './migrations/1697618014-addViewSortTable';
// TODO: read the folder and return all migrations // TODO: read the folder and return all migrations
export const standardMigrations = { export const standardMigrations = {
'1697618009-addCompanyTable': addCompanyTable,
'1697618011-addViewTable': addViewTable, '1697618011-addViewTable': addViewTable,
'1697618012-addViewFieldTable': addViewFieldTable, '1697618012-addViewFieldTable': addViewFieldTable,
'1697618013-addViewFilterTable': addViewFilterTable, '1697618013-addViewFilterTable': addViewFilterTable,
'1697618014-addViewSortTable': addViewSortTable, '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,
'1697618025-addWorkspaceMemberSettingTable': addWorkspaceMemberSettingTable,
'1697618026-addWorkspaceMemberTable': addWorkspaceMemberTable,
'1697618009-addCompanyTable': addCompanyTable,
}; };

View File

@ -68,10 +68,10 @@ export class CompositeFieldAliasFactory {
fieldMetadata.objectMetadataId, fieldMetadata.objectMetadataId,
relationMetadata, relationMetadata,
); );
const targetTableName = const referencedObjectMetadata =
relationDirection == RelationDirection.TO relationDirection == RelationDirection.TO
? relationMetadata.fromObjectMetadata.targetTableName ? relationMetadata.fromObjectMetadata
: relationMetadata.toObjectMetadata.targetTableName; : relationMetadata.toObjectMetadata;
// If it's a relation destination is of kind MANY, we need to add the collection suffix and extract the args // If it's a relation destination is of kind MANY, we need to add the collection suffix and extract the args
if ( if (
@ -84,7 +84,7 @@ export class CompositeFieldAliasFactory {
relationMetadata.toObjectMetadata.fields ?? [], relationMetadata.toObjectMetadata.fields ?? [],
); );
return ` return `
${fieldKey}: ${targetTableName}Collection${ ${fieldKey}: ${referencedObjectMetadata.targetTableName}Collection${
argsString ? `(${argsString})` : '' argsString ? `(${argsString})` : ''
} { } {
${this.fieldsStringFactory.createFieldsStringRecursive( ${this.fieldsStringFactory.createFieldsStringRecursive(
@ -98,11 +98,11 @@ export class CompositeFieldAliasFactory {
// Otherwise it means it's a relation destination is of kind ONE // Otherwise it means it's a relation destination is of kind ONE
return ` return `
${fieldKey}: ${targetTableName} { ${fieldKey}: ${referencedObjectMetadata.targetTableName} {
${this.fieldsStringFactory.createFieldsStringRecursive( ${this.fieldsStringFactory.createFieldsStringRecursive(
info, info,
fieldValue, fieldValue,
relationMetadata.toObjectMetadata.fields ?? [], referencedObjectMetadata.fields ?? [],
)} )}
} }
`; `;

View File

@ -139,6 +139,9 @@ export class QueryRunnerService {
workspaceId, workspaceId,
)}; )};
`); `);
console.log('ho');
console.log(query);
console.log('ha');
return workspaceDataSource?.query<PGGraphQLResult>(` return workspaceDataSource?.query<PGGraphQLResult>(`
SELECT graphql.resolve($$ SELECT graphql.resolve($$

View File

@ -61,6 +61,7 @@ export class TypeMapperService {
[FieldMetadataType.DATE, dateScalar], [FieldMetadataType.DATE, dateScalar],
[FieldMetadataType.BOOLEAN, GraphQLBoolean], [FieldMetadataType.BOOLEAN, GraphQLBoolean],
[FieldMetadataType.NUMBER, numberScalar], [FieldMetadataType.NUMBER, numberScalar],
[FieldMetadataType.PROBABILITY, GraphQLFloat],
[FieldMetadataType.RELATION, GraphQLID], [FieldMetadataType.RELATION, GraphQLID],
]); ]);
@ -89,6 +90,7 @@ export class TypeMapperService {
[FieldMetadataType.DATE, dateFilter], [FieldMetadataType.DATE, dateFilter],
[FieldMetadataType.BOOLEAN, BooleanFilterType], [FieldMetadataType.BOOLEAN, BooleanFilterType],
[FieldMetadataType.NUMBER, numberScalar], [FieldMetadataType.NUMBER, numberScalar],
[FieldMetadataType.PROBABILITY, FloatFilterType],
[FieldMetadataType.RELATION, UUIDFilterType], [FieldMetadataType.RELATION, UUIDFilterType],
]); ]);
@ -107,6 +109,7 @@ export class TypeMapperService {
[FieldMetadataType.DATE, OrderByDirectionType], [FieldMetadataType.DATE, OrderByDirectionType],
[FieldMetadataType.BOOLEAN, OrderByDirectionType], [FieldMetadataType.BOOLEAN, OrderByDirectionType],
[FieldMetadataType.NUMBER, OrderByDirectionType], [FieldMetadataType.NUMBER, OrderByDirectionType],
[FieldMetadataType.PROBABILITY, OrderByDirectionType],
]); ]);
return typeOrderByMapping.get(fieldMetadataType); return typeOrderByMapping.get(fieldMetadataType);

View File

@ -1,5 +1,5 @@
{ {
"id": "twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419", "id": "20202020-1c25-4d02-bf25-6aeccf7ea419",
"displayName": "Apple", "displayName": "Apple",
"domainName": "apple.dev", "domainName": "apple.dev",
"inviteHash": "apple.dev-invite-hash", "inviteHash": "apple.dev-invite-hash",