Skip to content

Commit 66aed86

Browse files
committed
feat(server): prefill core view wiht universal identifier
1 parent cbdaaac commit 66aed86

17 files changed

+2132
-255
lines changed

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/prefill-core-views.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { isString } from '@sniptt/guards';
22
import { type DataSource, type QueryRunner } from 'typeorm';
3-
import { v4 } from 'uuid';
43

54
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
65
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -215,7 +214,7 @@ export const createCoreViews = async (
215214
viewId: viewDefinition.id,
216215
workspaceId,
217216
applicationId: twentyStandardFlatApplication.id,
218-
universalIdentifier: v4(),
217+
universalIdentifier: field.universalIdentifier,
219218
}));
220219

221220
const viewFieldRepository =
@@ -233,7 +232,7 @@ export const createCoreViews = async (
233232
value: filter.value,
234233
workspaceId,
235234
applicationId: twentyStandardFlatApplication.id,
236-
universalIdentifier: v4(),
235+
universalIdentifier: filter.universalIdentifier,
237236
}));
238237

239238
const viewFilterRepository =
@@ -256,7 +255,7 @@ export const createCoreViews = async (
256255
viewId: viewDefinition.id,
257256
workspaceId,
258257
applicationId: twentyStandardFlatApplication.id,
259-
universalIdentifier: v4(),
258+
universalIdentifier: group.universalIdentifier,
260259
}));
261260

262261
const viewGroupRepository =

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ export interface ViewDefinition {
2020
kanbanAggregateOperation?: AggregateOperations;
2121
kanbanAggregateOperationFieldMetadataId?: string;
2222
fields?: {
23+
universalIdentifier: string;
2324
fieldMetadataId: string;
2425
position: number;
2526
isVisible: boolean;
2627
size: number;
2728
aggregateOperation?: AggregateOperations;
2829
}[];
2930
filters?: {
31+
universalIdentifier: string;
3032
fieldMetadataId: string;
3133
displayValue: string;
3234
operand: ViewFilterOperand;
3335
value: string;
3436
}[];
3537
groups?: {
38+
universalIdentifier: string;
3639
fieldMetadataId: string;
3740
isVisible: boolean;
3841
fieldValue: string;

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/companies-all.view.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { msg } from '@lingui/core/macro';
2-
import { v4 } from 'uuid';
32

43
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
54
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
@@ -11,6 +10,8 @@ import {
1110
COMPANY_STANDARD_FIELD_IDS,
1211
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
1312
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
13+
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object.constant';
14+
import { v4 } from 'uuid';
1415

1516
export const companiesAllView = ({
1617
objectMetadataItems,
@@ -29,11 +30,12 @@ export const companiesAllView = ({
2930
throw new Error('Company object metadata not found');
3031
}
3132

32-
const id = v4();
33+
const viewUniversalIdentifier =
34+
STANDARD_OBJECTS.company.views.allCompanies.universalIdentifier;
3335

3436
return {
35-
id,
36-
universalIdentifier: id,
37+
id: v4(),
38+
universalIdentifier: viewUniversalIdentifier,
3739
applicationId: twentyStandardFlatApplication.id,
3840
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Companies',
3941
objectMetadataId: companyObjectMetadata.id ?? '',
@@ -52,6 +54,9 @@ export const companiesAllView = ({
5254
position: 0,
5355
isVisible: true,
5456
size: DEFAULT_VIEW_FIELD_SIZE,
57+
universalIdentifier:
58+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.name
59+
.universalIdentifier,
5560
},
5661
{
5762
fieldMetadataId:
@@ -63,6 +68,9 @@ export const companiesAllView = ({
6368
isVisible: true,
6469
size: 100,
6570
aggregateOperation: AggregateOperations.COUNT,
71+
universalIdentifier:
72+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.domainName
73+
.universalIdentifier,
6674
},
6775
{
6876
fieldMetadataId:
@@ -73,6 +81,9 @@ export const companiesAllView = ({
7381
position: 2,
7482
isVisible: true,
7583
size: 150,
84+
universalIdentifier:
85+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.createdBy
86+
.universalIdentifier,
7687
},
7788
{
7889
fieldMetadataId:
@@ -83,6 +94,9 @@ export const companiesAllView = ({
8394
position: 3,
8495
isVisible: true,
8596
size: 150,
97+
universalIdentifier:
98+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.accountOwner
99+
.universalIdentifier,
86100
},
87101
{
88102
fieldMetadataId:
@@ -93,6 +107,9 @@ export const companiesAllView = ({
93107
position: 4,
94108
isVisible: true,
95109
size: 150,
110+
universalIdentifier:
111+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.createdAt
112+
.universalIdentifier,
96113
},
97114
{
98115
fieldMetadataId:
@@ -104,6 +121,9 @@ export const companiesAllView = ({
104121
isVisible: true,
105122
size: 150,
106123
aggregateOperation: AggregateOperations.MAX,
124+
universalIdentifier:
125+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.employees
126+
.universalIdentifier,
107127
},
108128
{
109129
fieldMetadataId:
@@ -115,6 +135,9 @@ export const companiesAllView = ({
115135
isVisible: true,
116136
size: 170,
117137
aggregateOperation: AggregateOperations.PERCENTAGE_EMPTY,
138+
universalIdentifier:
139+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.linkedinLink
140+
.universalIdentifier,
118141
},
119142
{
120143
fieldMetadataId:
@@ -125,6 +148,9 @@ export const companiesAllView = ({
125148
isVisible: true,
126149
size: 170,
127150
aggregateOperation: AggregateOperations.COUNT_NOT_EMPTY,
151+
universalIdentifier:
152+
STANDARD_OBJECTS.company.views.allCompanies.viewFields.address
153+
.universalIdentifier,
128154
},
129155
],
130156
};

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/custom-all.view.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/dashboards-all.view.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { msg } from '@lingui/core/macro';
2-
import { v4 } from 'uuid';
32

43
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
54
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -10,6 +9,8 @@ import {
109
DASHBOARD_STANDARD_FIELD_IDS,
1110
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
1211
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
12+
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object.constant';
13+
import { v4 } from 'uuid';
1314

1415
export const dashboardsAllView = ({
1516
objectMetadataItems,
@@ -28,11 +29,12 @@ export const dashboardsAllView = ({
2829
throw new Error('Dashboard object metadata not found');
2930
}
3031

31-
const id = v4();
32+
const viewUniversalIdentifier =
33+
STANDARD_OBJECTS.dashboard.views.allDashboards.universalIdentifier;
3234

3335
return {
34-
id,
35-
universalIdentifier: id,
36+
id: v4(),
37+
universalIdentifier: viewUniversalIdentifier,
3638
applicationId: twentyStandardFlatApplication.id,
3739
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Dashboards',
3840
objectMetadataId: dashboardObjectMetadata.id ?? '',
@@ -52,6 +54,9 @@ export const dashboardsAllView = ({
5254
position: 0,
5355
isVisible: true,
5456
size: 200,
57+
universalIdentifier:
58+
STANDARD_OBJECTS.dashboard.views.allDashboards.viewFields.title
59+
.universalIdentifier,
5560
},
5661
{
5762
fieldMetadataId:
@@ -62,6 +67,9 @@ export const dashboardsAllView = ({
6267
position: 1,
6368
isVisible: true,
6469
size: 150,
70+
universalIdentifier:
71+
STANDARD_OBJECTS.dashboard.views.allDashboards.viewFields.createdBy
72+
.universalIdentifier,
6573
},
6674
{
6775
fieldMetadataId:
@@ -72,6 +80,9 @@ export const dashboardsAllView = ({
7280
position: 2,
7381
isVisible: true,
7482
size: 150,
83+
universalIdentifier:
84+
STANDARD_OBJECTS.dashboard.views.allDashboards.viewFields.createdAt
85+
.universalIdentifier,
7586
},
7687
{
7788
fieldMetadataId:
@@ -82,6 +93,9 @@ export const dashboardsAllView = ({
8293
position: 3,
8394
isVisible: true,
8495
size: 150,
96+
universalIdentifier:
97+
STANDARD_OBJECTS.dashboard.views.allDashboards.viewFields.updatedAt
98+
.universalIdentifier,
8599
},
86100
],
87101
};

packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/notes-all.view.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { msg } from '@lingui/core/macro';
2-
import { v4 } from 'uuid';
32

43
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
54
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -9,6 +8,8 @@ import {
98
NOTE_STANDARD_FIELD_IDS,
109
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
1110
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
11+
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object.constant';
12+
import { v4 } from 'uuid';
1213

1314
export const notesAllView = ({
1415
objectMetadataItems,
@@ -27,11 +28,12 @@ export const notesAllView = ({
2728
throw new Error('Note object metadata not found');
2829
}
2930

30-
const id = v4();
31+
const viewUniversalIdentifier =
32+
STANDARD_OBJECTS.note.views.allNotes.universalIdentifier;
3133

3234
return {
33-
id,
34-
universalIdentifier: id,
35+
id: v4(),
36+
universalIdentifier: viewUniversalIdentifier,
3537
applicationId: twentyStandardFlatApplication.id,
3638
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Notes',
3739
objectMetadataId: noteObjectMetadata.id,
@@ -50,6 +52,9 @@ export const notesAllView = ({
5052
position: 0,
5153
isVisible: true,
5254
size: 210,
55+
universalIdentifier:
56+
STANDARD_OBJECTS.note.views.allNotes.viewFields.title
57+
.universalIdentifier,
5358
},
5459
{
5560
fieldMetadataId:
@@ -59,6 +64,9 @@ export const notesAllView = ({
5964
position: 1,
6065
isVisible: true,
6166
size: 150,
67+
universalIdentifier:
68+
STANDARD_OBJECTS.note.views.allNotes.viewFields.noteTargets
69+
.universalIdentifier,
6270
},
6371
{
6472
fieldMetadataId:
@@ -68,6 +76,9 @@ export const notesAllView = ({
6876
position: 2,
6977
isVisible: true,
7078
size: 150,
79+
universalIdentifier:
80+
STANDARD_OBJECTS.note.views.allNotes.viewFields.bodyV2
81+
.universalIdentifier,
7182
},
7283
{
7384
fieldMetadataId:
@@ -77,6 +88,9 @@ export const notesAllView = ({
7788
position: 3,
7889
isVisible: true,
7990
size: 150,
91+
universalIdentifier:
92+
STANDARD_OBJECTS.note.views.allNotes.viewFields.createdBy
93+
.universalIdentifier,
8094
},
8195
{
8296
fieldMetadataId:
@@ -87,6 +101,9 @@ export const notesAllView = ({
87101
position: 4,
88102
isVisible: true,
89103
size: 150,
104+
universalIdentifier:
105+
STANDARD_OBJECTS.note.views.allNotes.viewFields.createdAt
106+
.universalIdentifier,
90107
},
91108
/*
92109
TODO: Add later, since we don't have real-time it probably doesn't work well?

0 commit comments

Comments
 (0)