Update Seeds while pre-fi
lling a new workspace
This commit is contained in:
@ -1,33 +0,0 @@
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
export const opportunityPrefillData = async (
|
||||
entityManager: EntityManager,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await entityManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.opportunity`, [
|
||||
'amount',
|
||||
'closeDate',
|
||||
'probability',
|
||||
'pipelineStepId',
|
||||
'pointOfContactId',
|
||||
'personId',
|
||||
'companyId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
amount: 100000,
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
pipelineStepId: '73ac09c6-2b90-4874-9e5d-553ea76912ee',
|
||||
pointOfContactId: 'bb757987-ae38-4d16-96ec-b25b595e7bd8',
|
||||
personId: 'a4a2b8e9-7a2b-4b6a-8c8b-7e9a0a0a0a0a',
|
||||
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
])
|
||||
.returning('*')
|
||||
.execute();
|
||||
};
|
||||
@ -5,7 +5,6 @@ import { viewPrefillData } from 'src/workspace/workspace-manager/standard-object
|
||||
import { companyPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/company';
|
||||
import { personPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/person';
|
||||
import { pipelineStepPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/pipeline-step';
|
||||
import { opportunityPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/opportunity';
|
||||
|
||||
export const standardObjectsPrefillData = async (
|
||||
workspaceDataSource: DataSource,
|
||||
@ -28,6 +27,5 @@ export const standardObjectsPrefillData = async (
|
||||
await personPrefillData(entityManager, schemaName);
|
||||
await viewPrefillData(entityManager, schemaName, objectMetadataMap);
|
||||
await pipelineStepPrefillData(entityManager, schemaName);
|
||||
await opportunityPrefillData(entityManager, schemaName);
|
||||
});
|
||||
};
|
||||
|
||||
@ -125,12 +125,23 @@ const personMetadata = {
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'company',
|
||||
label: 'Company',
|
||||
targetColumnMap: {
|
||||
value: 'companyId',
|
||||
},
|
||||
targetColumnMap: {},
|
||||
description: 'Contact’s company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: false,
|
||||
isSystem: false,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'companyId',
|
||||
label: 'Company ID (foreign key)',
|
||||
targetColumnMap: {},
|
||||
description: 'Foreign key for company',
|
||||
icon: undefined,
|
||||
isNullable: false,
|
||||
isSystem: true,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
|
||||
@ -73,16 +73,15 @@ const viewFieldMetadata = {
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'view',
|
||||
label: 'View',
|
||||
targetColumnMap: { value: 'viewId' },
|
||||
targetColumnMap: {},
|
||||
description: 'View Field related view',
|
||||
icon: 'IconLayoutCollage',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
// Temporary hack?
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.TEXT,
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
|
||||
@ -73,16 +73,15 @@ const viewFilterMetadata = {
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'view',
|
||||
label: 'View',
|
||||
targetColumnMap: { value: 'viewId' },
|
||||
targetColumnMap: {},
|
||||
description: 'View Filter related view',
|
||||
icon: 'IconLayoutCollage',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
// Temporary hack?
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.TEXT,
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
|
||||
@ -45,18 +45,15 @@ const viewSortMetadata = {
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'view',
|
||||
label: 'View',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
targetColumnMap: {},
|
||||
description: 'View Sort related view',
|
||||
icon: 'IconLayoutCollage',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
// Temporary Hack?
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.TEXT,
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
|
||||
@ -11,19 +11,6 @@ const workspaceMemberMetadata = {
|
||||
isActive: true,
|
||||
isSystem: true,
|
||||
fields: [
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.TEXT,
|
||||
name: 'firstName',
|
||||
label: 'First name',
|
||||
targetColumnMap: {
|
||||
value: 'firstName',
|
||||
},
|
||||
description: 'Workspace member first name',
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
@ -93,6 +80,20 @@ const workspaceMemberMetadata = {
|
||||
isNullable: true,
|
||||
isSystem: false,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.UUID,
|
||||
name: 'userId',
|
||||
label: 'User Id',
|
||||
targetColumnMap: {
|
||||
value: 'userId',
|
||||
},
|
||||
description: 'Associated User Id',
|
||||
icon: 'IconCircleUsers',
|
||||
isNullable: false,
|
||||
isSystem: false,
|
||||
},
|
||||
// Relations
|
||||
{
|
||||
isCustom: false,
|
||||
|
||||
@ -81,23 +81,21 @@ export class WorkspaceManagerService {
|
||||
workspaceId: string,
|
||||
): Promise<ObjectMetadataEntity[]> {
|
||||
const createdObjectMetadata = await this.objectMetadataService.createMany(
|
||||
Object.values(standardObjectsMetadata).map(
|
||||
(objectMetadata: ObjectMetadataEntity) => ({
|
||||
...objectMetadata,
|
||||
dataSourceId,
|
||||
workspaceId,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
fields: [...basicFieldsMetadata, ...objectMetadata.fields].map(
|
||||
(field) => ({
|
||||
...field,
|
||||
workspaceId,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
}),
|
||||
),
|
||||
}),
|
||||
),
|
||||
Object.values(standardObjectsMetadata).map((objectMetadata: any) => ({
|
||||
...objectMetadata,
|
||||
dataSourceId,
|
||||
workspaceId,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
fields: [...basicFieldsMetadata, ...objectMetadata.fields].map(
|
||||
(field) => ({
|
||||
...field,
|
||||
workspaceId,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
}),
|
||||
),
|
||||
})),
|
||||
);
|
||||
|
||||
await this.relationMetadataService.createMany(
|
||||
|
||||
Reference in New Issue
Block a user