The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Resolve pageLayout default tab via generic id preallocation (#24854)
Félix Malfait251d02aa21b2
diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/__tests__/enrich-create-workspace-migration-action-with-ids.util.spec.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/__tests__/enrich-create-workspace-migration-action-with-ids.util.spec.tsindex 6b08a333994..3847043c1fa 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/__tests__/enrich-create-workspace-migration-action-with-ids.util.spec.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/__tests__/enrich-create-workspace-migration-action-with-ids.util.spec.ts@@ -1,12 +1,10 @@import { enrichCreateWorkspaceMigrationActionsWithIds } from 'src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util';import { type UniversalCreateFieldAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/field/types/workspace-migration-field-action';import { type UniversalCreatePageLayoutTabAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout-tab/types/workspace-migration-page-layout-tab-action.type';-import { type UniversalCreatePageLayoutAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type';import { type WorkspaceMigration } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/types/workspace-migration.type';type SpecMigrationAction =| UniversalCreateFieldAction- | UniversalCreatePageLayoutAction| UniversalCreatePageLayoutTabAction;const buildCreateFieldAction = ({@@ -32,23 +30,6 @@ const buildCreateFieldAction = ({: undefined,}) as unknown as UniversalCreateFieldAction;-const buildCreatePageLayoutAction = ({- pageLayoutUniversalIdentifier,- defaultTabUniversalIdentifier,-}: {- pageLayoutUniversalIdentifier: string;- defaultTabUniversalIdentifier?: string;-}): UniversalCreatePageLayoutAction =>- ({- type: 'create',- metadataName: 'pageLayout',- flatEntity: {- universalIdentifier: pageLayoutUniversalIdentifier,- defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier:- defaultTabUniversalIdentifier ?? null,- },- }) as unknown as UniversalCreatePageLayoutAction;-const buildCreatePageLayoutTabAction = ({tabUniversalIdentifier,pageLayoutUniversalIdentifier,@@ -171,65 +152,39 @@ describe('enrichCreateWorkspaceMigrationActionsWithIds', () => {expect(enrichedAction.id).toBe('external-id');});- it('should stamp a pageLayout create with the id minted for a pageLayoutTab created in the same migration', () => {- const pageLayoutAction = buildCreatePageLayoutAction({- pageLayoutUniversalIdentifier: 'layout',- defaultTabUniversalIdentifier: 'tab',- });+ it('should mint an id for any create action so same-migration references can be preallocated', () => {const pageLayoutTabAction = buildCreatePageLayoutTabAction({tabUniversalIdentifier: 'tab',pageLayoutUniversalIdentifier: 'layout',});const workspaceMigration = enrichCreateWorkspaceMigrationActionsWithIds({- workspaceMigration: buildWorkspaceMigration([- pageLayoutAction,- pageLayoutTabAction,- ]),+ workspaceMigration: buildWorkspaceMigration([pageLayoutTabAction]),idByUniversalIdentifierByMetadataName: {},});- const [enrichedPageLayoutAction, enrichedPageLayoutTabAction] =- workspaceMigration.actions as [- UniversalCreatePageLayoutAction,- UniversalCreatePageLayoutTabAction,- ];+ const [enrichedAction] =+ workspaceMigration.actions as UniversalCreatePageLayoutTabAction[];- expect(enrichedPageLayoutTabAction.id).toEqual(expect.any(String));- expect(enrichedPageLayoutAction.tabIdByUniversalIdentifier?.tab).toBe(- enrichedPageLayoutTabAction.id,- );+ expect(enrichedAction.id).toEqual(expect.any(String));});- it('should use the provided pageLayoutTab id for both the tab create and the pageLayout create', () => {- const pageLayoutAction = buildCreatePageLayoutAction({- pageLayoutUniversalIdentifier: 'layout',- defaultTabUniversalIdentifier: 'tab',- });+ it('should use the provided id over a generated one for any create action', () => {const pageLayoutTabAction = buildCreatePageLayoutTabAction({tabUniversalIdentifier: 'tab',pageLayoutUniversalIdentifier: 'layout',});const workspaceMigration = enrichCreateWorkspaceMigrationActionsWithIds({- workspaceMigration: buildWorkspaceMigration([- pageLayoutAction,- pageLayoutTabAction,- ]),+ workspaceMigration: buildWorkspaceMigration([pageLayoutTabAction]),idByUniversalIdentifierByMetadataName: {pageLayoutTab: { tab: 'external-tab-id' },},});- const [enrichedPageLayoutAction, enrichedPageLayoutTabAction] =- workspaceMigration.actions as [- UniversalCreatePageLayoutAction,- UniversalCreatePageLayoutTabAction,- ];+ const [enrichedAction] =+ workspaceMigration.actions as UniversalCreatePageLayoutTabAction[];- expect(enrichedPageLayoutTabAction.id).toBe('external-tab-id');- expect(enrichedPageLayoutAction.tabIdByUniversalIdentifier?.tab).toBe(- 'external-tab-id',- );+ expect(enrichedAction.id).toBe('external-tab-id');});});diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util.tsindex 8ef5b0a0edc..fb4acafa9bf 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util.ts@@ -1,10 +1,9 @@import { type AllMetadataName } from 'twenty-shared/metadata';-import { assertUnreachable, isDefined } from 'twenty-shared/utils';+import { isDefined } from 'twenty-shared/utils';import { v4 } from 'uuid';import { type UniversalCreateFieldAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/field/types/workspace-migration-field-action';import { type UniversalCreateObjectAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/object/types/workspace-migration-object-action';-import { type UniversalCreatePageLayoutAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type';import { type WorkspaceMigration } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/types/workspace-migration.type';export type IdByUniversalIdentifierByMetadataName = {@@ -41,57 +40,6 @@ const buildFieldIdByUniversalIdentifierForObjectAction = ({return fieldIdByUniversalIdentifier;};-const buildTabIdByUniversalIdentifier = ({- action,- pageLayoutTabIdByUniversalIdentifier,-}: {- action: UniversalCreatePageLayoutAction;- pageLayoutTabIdByUniversalIdentifier: Record<string, string>;-}): Record<string, string> | undefined => {- const tabIdByUniversalIdentifier = {- ...action.tabIdByUniversalIdentifier,- ...pageLayoutTabIdByUniversalIdentifier,- };-- if (Object.keys(tabIdByUniversalIdentifier).length === 0) {- return undefined;- }-- return tabIdByUniversalIdentifier;-};--const buildTabIdByUniversalIdentifierForTabActions = ({- actions,- providedTabIdByUniversalIdentifier,-}: {- actions: WorkspaceMigration['actions'];- providedTabIdByUniversalIdentifier?: Record<string, string>;-}): Record<string, string> | undefined => {- const tabIdByUniversalIdentifier = {- ...providedTabIdByUniversalIdentifier,- };-- for (const action of actions) {- if (action.type !== 'create' || action.metadataName !== 'pageLayoutTab') {- continue;- }-- const { universalIdentifier } = action.flatEntity;-- if (isDefined(tabIdByUniversalIdentifier[universalIdentifier])) {- continue;- }-- tabIdByUniversalIdentifier[universalIdentifier] = action.id ?? v4();- }-- if (Object.keys(tabIdByUniversalIdentifier).length === 0) {- return undefined;- }-- return tabIdByUniversalIdentifier;-};-const buildFieldIdByUniversalIdentifierForFieldActions = ({actions,providedFieldIdByUniversalIdentifier,@@ -211,8 +159,6 @@ export const enrichCreateWorkspaceMigrationActionsWithIds = ({}): WorkspaceMigration => {const fieldMetadataIdByUniversalIdentifier =idByUniversalIdentifierByMetadataName.fieldMetadata;- const pageLayoutTabIdByUniversalIdentifier =- idByUniversalIdentifierByMetadataName.pageLayoutTab;const fieldIdByUniversalIdentifier =buildFieldIdByUniversalIdentifierForFieldActions({@@ -221,38 +167,18 @@ export const enrichCreateWorkspaceMigrationActionsWithIds = ({fieldMetadataIdByUniversalIdentifier,});- const tabIdByUniversalIdentifierForTabActions =- buildTabIdByUniversalIdentifierForTabActions({- actions: workspaceMigration.actions,- providedTabIdByUniversalIdentifier: pageLayoutTabIdByUniversalIdentifier,- });-const enrichedActions = workspaceMigration.actions.map((action) => {if (action.type !== 'create') {return action;}- const idByUniversalIdentifier =- idByUniversalIdentifierByMetadataName[action.metadataName];-- if (- action.metadataName !== 'fieldMetadata' &&- action.metadataName !== 'objectMetadata' &&- !isDefined(idByUniversalIdentifier) &&- !isDefined(fieldMetadataIdByUniversalIdentifier) &&- !isDefined(tabIdByUniversalIdentifierForTabActions)- ) {- return action;- }+ const providedId =+ idByUniversalIdentifierByMetadataName[action.metadataName]?.[+ action.flatEntity.universalIdentifier+ ];switch (action.metadataName) {case 'objectMetadata': {- const id =- (isDefined(idByUniversalIdentifier)- ? idByUniversalIdentifier[action.flatEntity.universalIdentifier]- : undefined) ??- action.id ??- v4();const objectFieldIdByUniversalIdentifier =buildFieldIdByUniversalIdentifierForObjectAction({action,@@ -262,7 +188,7 @@ export const enrichCreateWorkspaceMigrationActionsWithIds = ({return {...action,- id,+ id: providedId ?? action.id ?? v4(),fieldIdByUniversalIdentifier: objectFieldIdByUniversalIdentifier,};}@@ -298,77 +224,12 @@ export const enrichCreateWorkspaceMigrationActionsWithIds = ({}),};}- case 'pageLayout': {- const id = isDefined(idByUniversalIdentifier)- ? idByUniversalIdentifier[action.flatEntity.universalIdentifier]- : undefined;- const tabIdByUniversalIdentifier = isDefined(- tabIdByUniversalIdentifierForTabActions,- )- ? buildTabIdByUniversalIdentifier({- action,- pageLayoutTabIdByUniversalIdentifier:- tabIdByUniversalIdentifierForTabActions,- })- : undefined;-- return {- ...action,- id,- tabIdByUniversalIdentifier,- };- }- case 'pageLayoutTab': {- const id =- tabIdByUniversalIdentifierForTabActions?.[- action.flatEntity.universalIdentifier- ] ?? action.id;-- return {- ...action,- id,- };- }- case 'view':- case 'viewField':- case 'viewGroup':- case 'viewFieldGroup':- case 'rowLevelPermissionPredicate':- case 'rowLevelPermissionPredicateGroup':- case 'viewFilterGroup':- case 'index':- case 'logicFunction':- case 'viewFilter':- case 'role':- case 'roleTarget':- case 'agent':- case 'skill':- case 'pageLayoutWidget':- case 'commandMenuItem':- case 'navigationMenuItem':- case 'frontComponent':- case 'viewSort':- case 'rolePermissionFlag':- case 'permissionFlag':- case 'objectPermission':- case 'fieldPermission':- case 'webhook':- case 'applicationVariable':- case 'connectionProvider':- case 'timelineActivityType':- case 'searchFieldMetadata': {- if (!isDefined(idByUniversalIdentifier)) {- return action;- }-+ default: {return {...action,- id: idByUniversalIdentifier[action.flatEntity.universalIdentifier],+ id: providedId ?? action.id ?? v4(),};}- default: {- assertUnreachable(action);- }}});diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type.tsindex 75ccfcbfb56..43575bd74ab 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type.ts@@ -9,9 +9,7 @@ export type FlatCreatePageLayoutAction =BaseFlatCreateWorkspaceMigrationAction<'pageLayout'>;export type UniversalCreatePageLayoutAction =- BaseUniversalCreateWorkspaceMigrationAction<'pageLayout'> & {- tabIdByUniversalIdentifier?: Record<string, string>;- };+ BaseUniversalCreateWorkspaceMigrationAction<'pageLayout'>;export type FlatUpdatePageLayoutAction =BaseFlatUpdateWorkspaceMigrationAction<'pageLayout'>;diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/create-page-layout-action-handler.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/create-page-layout-action-handler.service.tsindex 5554ae35d29..66366c477ac 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/create-page-layout-action-handler.service.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/create-page-layout-action-handler.service.ts@@ -1,21 +1,15 @@import { Injectable } from '@nestjs/common';-import { isDefined } from 'twenty-shared/utils';import { v4 } from 'uuid';import { WorkspaceMigrationRunnerActionHandler } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/interfaces/workspace-migration-runner-action-handler-service.interface';-import {- FlatEntityMapsException,- FlatEntityMapsExceptionCode,-} from 'src/engine/metadata-modules/flat-entity/exceptions/flat-entity-maps.exception';import { getUniversalFlatEntityEmptyForeignKeyAggregators } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/reset-universal-flat-entity-foreign-key-aggregators.util';import { resolveUniversalRelationIdentifiersToIds } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/resolve-universal-relation-identifiers-to-ids.util';import {FlatCreatePageLayoutAction,UniversalCreatePageLayoutAction,} from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type';-import { findPageLayoutTabIdInCreatePageLayoutContext } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/utils/find-page-layout-tab-id-in-create-page-layout-context.util';import {WorkspaceMigrationActionRunnerArgs,WorkspaceMigrationActionRunnerContext,@@ -35,41 +29,25 @@ export class CreatePageLayoutActionHandlerService extends WorkspaceMigrationRunnallFlatEntityMaps,flatApplication,workspaceId,+ preallocatedIdByUniversalIdentifierByMetadataName,}: WorkspaceMigrationActionRunnerArgs<UniversalCreatePageLayoutAction>): Promise<FlatCreatePageLayoutAction> {- const { objectMetadataId } = resolveUniversalRelationIdentifiersToIds<- 'pageLayout',- 'objectMetadataUniversalIdentifier'- >({- flatEntityMaps: allFlatEntityMaps,- metadataName: 'pageLayout',- universalForeignKeyValues: {- objectMetadataUniversalIdentifier:- action.flatEntity.objectMetadataUniversalIdentifier,- },- });-- let defaultTabToFocusOnMobileAndSidePanelId: string | null = null;-- const defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier =- action.flatEntity- .defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier;-- if (isDefined(defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier)) {- defaultTabToFocusOnMobileAndSidePanelId =- findPageLayoutTabIdInCreatePageLayoutContext({- universalIdentifier:- defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier,- tabIdByUniversalIdentifier: action.tabIdByUniversalIdentifier,- flatPageLayoutTabMaps: allFlatEntityMaps.flatPageLayoutTabMaps,- });-- if (!isDefined(defaultTabToFocusOnMobileAndSidePanelId)) {- throw new FlatEntityMapsException(- `Could not resolve defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier to defaultTabToFocusOnMobileAndSidePanelId: no pageLayoutTab found for universal identifier ${defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier}`,- FlatEntityMapsExceptionCode.ENTITY_NOT_FOUND,- );- }- }+ const { objectMetadataId, defaultTabToFocusOnMobileAndSidePanelId } =+ resolveUniversalRelationIdentifiersToIds<+ 'pageLayout',+ | 'objectMetadataUniversalIdentifier'+ | 'defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier'+ >({+ flatEntityMaps: allFlatEntityMaps,+ metadataName: 'pageLayout',+ universalForeignKeyValues: {+ objectMetadataUniversalIdentifier:+ action.flatEntity.objectMetadataUniversalIdentifier,+ defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier:+ action.flatEntity+ .defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier,+ },+ preallocatedIdByUniversalIdentifierByMetadataName,+ });const emptyUniversalForeignKeyAggregators =getUniversalFlatEntityEmptyForeignKeyAggregators({diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/update-page-layout-action-handler.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/update-page-layout-action-handler.service.tsindex 7bb5b1e41d2..e9e8ba8b10f 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/update-page-layout-action-handler.service.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/update-page-layout-action-handler.service.ts@@ -1,16 +1,8 @@import { Injectable } from '@nestjs/common';-import { isDefined } from 'twenty-shared/utils';-import { WorkspaceMigrationRunnerActionHandler } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/interfaces/workspace-migration-runner-action-handler-service.interface';-import {- FlatEntityMapsException,- FlatEntityMapsExceptionCode,-} from 'src/engine/metadata-modules/flat-entity/exceptions/flat-entity-maps.exception';-import { type FlatEntityUpdate } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-update.type';import { findFlatEntityByUniversalIdentifierOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-universal-identifier-or-throw.util';-import { findFlatEntityByUniversalIdentifier } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-universal-identifier.util';import { PageLayoutEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout.entity';import { resolveUniversalUpdateRelationIdentifiersToIds } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/resolve-universal-update-relation-identifiers-to-ids.util';import {@@ -37,35 +29,11 @@ export class UpdatePageLayoutActionHandlerService extends WorkspaceMigrationRunnuniversalIdentifier: action.universalIdentifier,});- const {- defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier,- ...restUpdate- } = action.update;-- const transpiledUpdate: FlatEntityUpdate<'pageLayout'> =- resolveUniversalUpdateRelationIdentifiersToIds({- metadataName: 'pageLayout',- universalUpdate: restUpdate,- allFlatEntityMaps,- });-- if (isDefined(defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier)) {- const flatPageLayoutTab = findFlatEntityByUniversalIdentifier({- flatEntityMaps: allFlatEntityMaps.flatPageLayoutTabMaps,- universalIdentifier:- defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier,- });-- if (!isDefined(flatPageLayoutTab)) {- throw new FlatEntityMapsException(- `Could not resolve defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier to defaultTabToFocusOnMobileAndSidePanelId: no pageLayoutTab found for universal identifier ${defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier}`,- FlatEntityMapsExceptionCode.ENTITY_NOT_FOUND,- );- }-- transpiledUpdate.defaultTabToFocusOnMobileAndSidePanelId =- flatPageLayoutTab.id;- }+ const transpiledUpdate = resolveUniversalUpdateRelationIdentifiersToIds({+ metadataName: 'pageLayout',+ universalUpdate: action.update,+ allFlatEntityMaps,+ });return {type: 'update',diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/utils/find-page-layout-tab-id-in-create-page-layout-context.util.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/utils/find-page-layout-tab-id-in-create-page-layout-context.util.tsdeleted file mode 100644index 1e495d193e4..00000000000--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/page-layout/services/utils/find-page-layout-tab-id-in-create-page-layout-context.util.ts+++ /dev/null@@ -1,24 +0,0 @@-import { isDefined } from 'twenty-shared/utils';--import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';--export const findPageLayoutTabIdInCreatePageLayoutContext = ({- universalIdentifier,- tabIdByUniversalIdentifier,- flatPageLayoutTabMaps,-}: {- universalIdentifier: string;- tabIdByUniversalIdentifier: Record<string, string> | undefined;- flatPageLayoutTabMaps: AllFlatEntityMaps['flatPageLayoutTabMaps'];-}): string | null => {- const providedId = tabIdByUniversalIdentifier?.[universalIdentifier];-- if (isDefined(providedId)) {- return providedId;- }-- const existingTab =- flatPageLayoutTabMaps.byUniversalIdentifier[universalIdentifier];-- return existingTab?.id ?? null;-};diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/__tests__/build-preallocated-id-by-universal-identifier-from-actions.util.spec.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/__tests__/build-preallocated-id-by-universal-identifier-from-actions.util.spec.tsnew file mode 100644index 00000000000..12a6ac7e721--- /dev/null+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/__tests__/build-preallocated-id-by-universal-identifier-from-actions.util.spec.ts@@ -0,0 +1,136 @@+import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';+import { enrichCreateWorkspaceMigrationActionsWithIds } from 'src/engine/workspace-manager/workspace-migration/services/utils/enrich-create-workspace-migration-action-with-ids.util';+import { resolveUniversalRelationIdentifiersToIds } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/resolve-universal-relation-identifiers-to-ids.util';+import { type UniversalCreatePageLayoutTabAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout-tab/types/workspace-migration-page-layout-tab-action.type';+import { type UniversalCreatePageLayoutAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/builders/page-layout/types/workspace-migration-page-layout-action.type';+import { type WorkspaceMigration } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/types/workspace-migration.type';+import { buildPreallocatedIdByUniversalIdentifierFromActions } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/build-preallocated-id-by-universal-identifier-from-actions.util';++const buildCreatePageLayoutAction = ({+ pageLayoutUniversalIdentifier,+ defaultTabUniversalIdentifier,+}: {+ pageLayoutUniversalIdentifier: string;+ defaultTabUniversalIdentifier?: string;+}): UniversalCreatePageLayoutAction =>+ ({+ type: 'create',+ metadataName: 'pageLayout',+ flatEntity: {+ universalIdentifier: pageLayoutUniversalIdentifier,+ defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier:+ defaultTabUniversalIdentifier ?? null,+ },+ }) as unknown as UniversalCreatePageLayoutAction;++const buildCreatePageLayoutTabAction = ({+ tabUniversalIdentifier,+ pageLayoutUniversalIdentifier,+}: {+ tabUniversalIdentifier: string;+ pageLayoutUniversalIdentifier: string;+}): UniversalCreatePageLayoutTabAction =>+ ({+ type: 'create',+ metadataName: 'pageLayoutTab',+ flatEntity: {+ universalIdentifier: tabUniversalIdentifier,+ pageLayoutUniversalIdentifier,+ },+ }) as unknown as UniversalCreatePageLayoutTabAction;++const buildWorkspaceMigration = (+ actions: (+ | UniversalCreatePageLayoutAction+ | UniversalCreatePageLayoutTabAction+ )[],+): WorkspaceMigration =>+ ({+ applicationUniversalIdentifier: 'app',+ actions,+ }) as unknown as WorkspaceMigration;++const EMPTY_FLAT_PAGE_LAYOUT_TAB_MAPS = {+ byUniversalIdentifier: {},+} as unknown as AllFlatEntityMaps['flatPageLayoutTabMaps'];++describe('buildPreallocatedIdByUniversalIdentifierFromActions', () => {+ it('should preallocate the id of every enriched create action', () => {+ const workspaceMigration = enrichCreateWorkspaceMigrationActionsWithIds({+ workspaceMigration: buildWorkspaceMigration([+ buildCreatePageLayoutAction({+ pageLayoutUniversalIdentifier: 'layout',+ }),+ buildCreatePageLayoutTabAction({+ tabUniversalIdentifier: 'tab',+ pageLayoutUniversalIdentifier: 'layout',+ }),+ ]),+ idByUniversalIdentifierByMetadataName: {},+ });++ const preallocatedIdByUniversalIdentifierByMetadataName =+ buildPreallocatedIdByUniversalIdentifierFromActions(+ workspaceMigration.actions,+ );++ const [enrichedPageLayoutAction, enrichedPageLayoutTabAction] =+ workspaceMigration.actions as [+ UniversalCreatePageLayoutAction,+ UniversalCreatePageLayoutTabAction,+ ];++ expect(+ preallocatedIdByUniversalIdentifierByMetadataName.pageLayout?.layout,+ ).toBe(enrichedPageLayoutAction.id);+ expect(+ preallocatedIdByUniversalIdentifierByMetadataName.pageLayoutTab?.tab,+ ).toBe(enrichedPageLayoutTabAction.id);+ });++ it('should let a pageLayout create resolve its default tab to the id of a tab created in the same migration', () => {+ const workspaceMigration = enrichCreateWorkspaceMigrationActionsWithIds({+ workspaceMigration: buildWorkspaceMigration([+ buildCreatePageLayoutAction({+ pageLayoutUniversalIdentifier: 'layout',+ defaultTabUniversalIdentifier: 'tab',+ }),+ buildCreatePageLayoutTabAction({+ tabUniversalIdentifier: 'tab',+ pageLayoutUniversalIdentifier: 'layout',+ }),+ ]),+ idByUniversalIdentifierByMetadataName: {},+ });++ const [enrichedPageLayoutAction, enrichedPageLayoutTabAction] =+ workspaceMigration.actions as [+ UniversalCreatePageLayoutAction,+ UniversalCreatePageLayoutTabAction,+ ];++ const { defaultTabToFocusOnMobileAndSidePanelId } =+ resolveUniversalRelationIdentifiersToIds<+ 'pageLayout',+ 'defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier'+ >({+ flatEntityMaps: {+ flatPageLayoutTabMaps: EMPTY_FLAT_PAGE_LAYOUT_TAB_MAPS,+ },+ metadataName: 'pageLayout',+ universalForeignKeyValues: {+ defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier:+ enrichedPageLayoutAction.flatEntity+ .defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier,+ },+ preallocatedIdByUniversalIdentifierByMetadataName:+ buildPreallocatedIdByUniversalIdentifierFromActions(+ workspaceMigration.actions,+ ),+ });++ expect(defaultTabToFocusOnMobileAndSidePanelId).toBe(+ enrichedPageLayoutTabAction.id,+ );+ });+});diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/build-preallocated-id-by-universal-identifier-from-actions.util.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/build-preallocated-id-by-universal-identifier-from-actions.util.tsindex 63ffd8c9bb1..be258e26658 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/build-preallocated-id-by-universal-identifier-from-actions.util.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/utils/build-preallocated-id-by-universal-identifier-from-actions.util.ts@@ -1,3 +1,4 @@+import { type AllMetadataName } from 'twenty-shared/metadata';import { isDefined } from 'twenty-shared/utils';import { type PreallocatedIdByUniversalIdentifierByMetadataName } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/utils/resolve-universal-relation-identifiers-to-ids.util';@@ -6,52 +7,68 @@ import { type AllUniversalWorkspaceMigrationAction } from 'src/engine/workspace-export const buildPreallocatedIdByUniversalIdentifierFromActions = (actions: AllUniversalWorkspaceMigrationAction[],): PreallocatedIdByUniversalIdentifierByMetadataName => {- const objectMetadata: Record<string, string> = {};- const fieldMetadata: Record<string, string> = {};+ const preallocatedIdByUniversalIdentifierByMetadataName: PreallocatedIdByUniversalIdentifierByMetadataName =+ {};++ const registerId = ({+ metadataName,+ universalIdentifier,+ id,+ }: {+ metadataName: AllMetadataName;+ universalIdentifier: string;+ id: string | undefined;+ }) => {+ if (!isDefined(id)) {+ return;+ }++ const idByUniversalIdentifier =+ preallocatedIdByUniversalIdentifierByMetadataName[metadataName] ?? {};++ idByUniversalIdentifier[universalIdentifier] = id;+ preallocatedIdByUniversalIdentifierByMetadataName[metadataName] =+ idByUniversalIdentifier;+ };for (const action of actions) {if (action.type !== 'create') {continue;}- if (action.metadataName === 'objectMetadata') {- if (isDefined(action.id)) {- objectMetadata[action.flatEntity.universalIdentifier] = action.id;- }+ registerId({+ metadataName: action.metadataName,+ universalIdentifier: action.flatEntity.universalIdentifier,+ id: action.id,+ });+ if (action.metadataName === 'objectMetadata') {const fieldIdByUniversalIdentifier =action.fieldIdByUniversalIdentifier ?? {};for (const universalFlatFieldMetadata of action.universalFlatFieldMetadatas) {- const fieldId =- fieldIdByUniversalIdentifier[+ registerId({+ metadataName: 'fieldMetadata',+ universalIdentifier: universalFlatFieldMetadata.universalIdentifier,+ id: fieldIdByUniversalIdentifier[universalFlatFieldMetadata.universalIdentifier- ];-- if (isDefined(fieldId)) {- fieldMetadata[universalFlatFieldMetadata.universalIdentifier] =- fieldId;- }+ ],+ });}-- continue;}- if (action.metadataName === 'fieldMetadata') {- if (isDefined(action.id)) {- fieldMetadata[action.flatEntity.universalIdentifier] = action.id;- }-- if (- isDefined(action.relatedUniversalFlatFieldMetadata) &&- isDefined(action.relatedFieldId)- ) {- fieldMetadata[- action.relatedUniversalFlatFieldMetadata.universalIdentifier- ] = action.relatedFieldId;- }+ if (+ action.metadataName === 'fieldMetadata' &&+ isDefined(action.relatedUniversalFlatFieldMetadata)+ ) {+ registerId({+ metadataName: 'fieldMetadata',+ universalIdentifier:+ action.relatedUniversalFlatFieldMetadata.universalIdentifier,+ id: action.relatedFieldId,+ });}}- return { objectMetadata, fieldMetadata };+ return preallocatedIdByUniversalIdentifierByMetadataName;};diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-manifest-record-table-view-universal-identifier.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-manifest-record-table-view-universal-identifier.integration-spec.ts.snapindex 334c80de132..eae4c1b7792 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-manifest-record-table-view-universal-identifier.integration-spec.ts.snap+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-manifest-record-table-view-universal-identifier.integration-spec.ts.snap@@ -32,6 +32,7 @@ exports[`Failing manifest sync - RECORD_TABLE widget with unknown view universal"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-sync-application-unique-index-duplicate-data.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-sync-application-unique-index-duplicate-data.integration-spec.ts.snapindex e572a9cd54a..d317c7755ad 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-sync-application-unique-index-duplicate-data.integration-spec.ts.snap+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-sync-application-unique-index-duplicate-data.integration-spec.ts.snap@@ -28,6 +28,7 @@ exports[`Sync application should surface the root cause when a unique index cann"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-sync-application-workspace-migration.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-sync-application-workspace-migration.integration-spec.ts.snapindex 4a0582a8cbf..ff3627f745d 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-sync-application-workspace-migration.integration-spec.ts.snap+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/successful-sync-application-workspace-migration.integration-spec.ts.snap@@ -54,6 +54,7 @@ exports[`syncApplication should create a TEXT field on the standard Company obje"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -75,6 +76,7 @@ exports[`syncApplication should create a TEXT field on the standard Company obje"viewFieldGroupUniversalIdentifier": Any<String>,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -98,6 +100,7 @@ exports[`syncApplication should create a TEXT field on the standard Company obje"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "role","type": "create",},@@ -689,6 +692,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -716,6 +720,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -743,6 +748,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -770,6 +776,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -797,6 +804,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -890,6 +898,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -911,6 +920,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -932,6 +942,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -953,6 +964,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -974,6 +986,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -995,6 +1008,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1016,6 +1030,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1037,6 +1052,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1058,6 +1074,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1079,6 +1096,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1100,6 +1118,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1123,6 +1142,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "role","type": "create",},@@ -1139,8 +1159,8 @@ exports[`syncApplication should delete old field and create equivalent one when"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayout",- "tabIdByUniversalIdentifier": Any<Object>,"type": "create",},{@@ -1274,6 +1294,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -1306,6 +1327,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -1338,6 +1360,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -1370,6 +1393,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -1402,6 +1426,7 @@ exports[`syncApplication should delete old field and create equivalent one when"universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -1553,6 +1578,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -1574,6 +1600,7 @@ exports[`syncApplication should delete old field and create equivalent one when"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2165,6 +2192,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -2192,6 +2220,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -2219,6 +2248,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -2246,6 +2276,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -2273,6 +2304,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "index","type": "create",},@@ -2366,6 +2398,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2387,6 +2420,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2408,6 +2442,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2429,6 +2464,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2450,6 +2486,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2471,6 +2508,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2492,6 +2530,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2513,6 +2552,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2534,6 +2574,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2555,6 +2596,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2576,6 +2618,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"viewFieldGroupUniversalIdentifier": null,"viewUniversalIdentifier": Any<String>,},+ "id": Any<String>,"metadataName": "viewField","type": "create",},@@ -2599,6 +2642,7 @@ exports[`syncApplication should return workspace migration actions on initial sy"universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "role","type": "create",},@@ -2618,6 +2662,7 @@ This is a test skill.","universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "skill","type": "create",},@@ -2634,8 +2679,8 @@ This is a test skill.","universalIdentifier": Any<String>,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayout",- "tabIdByUniversalIdentifier": Any<Object>,"type": "create",},{@@ -2769,6 +2814,7 @@ This is a test skill.","universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -2801,6 +2847,7 @@ This is a test skill.","universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -2833,6 +2880,7 @@ This is a test skill.","universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -2865,6 +2913,7 @@ This is a test skill.","universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},@@ -2897,6 +2946,7 @@ This is a test skill.","universalOverrides": null,"updatedAt": Any<String>,},+ "id": Any<String>,"metadataName": "pageLayoutWidget","type": "create",},diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-page-layout-default-tab.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-page-layout-default-tab.integration-spec.tsindex 04d3d3399f6..ac877a1cdf0 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-page-layout-default-tab.integration-spec.ts+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-manifest-page-layout-default-tab.integration-spec.ts@@ -146,4 +146,52 @@ describe('Manifest sync - page layout default tab', () => {secondTabRow.id,);}, 60000);++ it('should clear defaultTabToFocusOnMobileAndSidePanel when a second sync removes it from the manifest', async () => {+ await syncApplication({+ manifest: buildManifest({+ pageLayouts: [+ {+ universalIdentifier: TEST_PAGE_LAYOUT_ID,+ name: 'Test Page',+ type: PageLayoutType.STANDALONE_PAGE,+ defaultTabToFocusOnMobileAndSidePanelUniversalIdentifier:+ TEST_FIRST_TAB_ID,+ tabs: [+ {+ universalIdentifier: TEST_FIRST_TAB_ID,+ title: 'Overview',+ position: 0,+ },+ ],+ },+ ],+ }),+ expectToFail: false,+ });++ await syncApplication({+ manifest: buildManifest({+ pageLayouts: [+ {+ universalIdentifier: TEST_PAGE_LAYOUT_ID,+ name: 'Test Page',+ type: PageLayoutType.STANDALONE_PAGE,+ tabs: [+ {+ universalIdentifier: TEST_FIRST_TAB_ID,+ title: 'Overview',+ position: 0,+ },+ ],+ },+ ],+ }),+ expectToFail: false,+ });++ const pageLayoutRow = await findTestPageLayoutRow();++ expect(pageLayoutRow.defaultTabToFocusOnMobileAndSidePanelId).toBeNull();+ }, 60000);});