diff --git a/.changeset/light-adults-pump.md b/.changeset/light-adults-pump.md new file mode 100644 index 0000000000..77a03eb818 --- /dev/null +++ b/.changeset/light-adults-pump.md @@ -0,0 +1,5 @@ +--- +'@finos/legend-application-studio': minor +--- + +Remove handling of legacy dependencies diff --git a/.changeset/neat-bobcats-shake.md b/.changeset/neat-bobcats-shake.md new file mode 100644 index 0000000000..aa55adc3a1 --- /dev/null +++ b/.changeset/neat-bobcats-shake.md @@ -0,0 +1,5 @@ +--- +'@finos/legend-server-depot': patch +--- + +Remove deprecated depot api that fetches project by id. diff --git a/.changeset/purple-waves-grab.md b/.changeset/purple-waves-grab.md new file mode 100644 index 0000000000..bc5f21baf3 --- /dev/null +++ b/.changeset/purple-waves-grab.md @@ -0,0 +1,4 @@ +--- +'@finos/legend-extension-dsl-service': patch +'@finos/legend-server-sdlc': patch +--- diff --git a/packages/legend-application-studio/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx b/packages/legend-application-studio/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx index 45b3008de5..a9e4574d19 100644 --- a/packages/legend-application-studio/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx +++ b/packages/legend-application-studio/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx @@ -221,7 +221,6 @@ export const TEST__setUpEditor = async ( latestProjectStructureVersion: PlainObject; availableGenerationDescriptions: GenerationConfigurationDescription[]; projects: PlainObject[]; - projectData: PlainObject[]; projectDependency: PlainObject[]; projectDependencyVersions: string[]; projectDependencyReport: PlainObject; @@ -236,7 +235,6 @@ export const TEST__setUpEditor = async ( entities, latestProjectStructureVersion, availableGenerationDescriptions, - projectData, projects, projectDependency, projectDependencyVersions, @@ -295,10 +293,6 @@ export const TEST__setUpEditor = async ( MOCK__editorStore.depotServerClient, 'getVersions', ).mockResolvedValue(projectDependencyVersions); - createSpy( - MOCK__editorStore.depotServerClient, - 'getProjectById', - ).mockResolvedValue(projectData); createSpy( MOCK__editorStore.depotServerClient, 'collectDependencyEntities', @@ -417,7 +411,6 @@ export const TEST__setUpEditorWithDefaultSDLCData = ( ...TEST_DATA__DefaultSDLCInfo.availableCodeGenerations, ], projects: [], - projectData: [], projectDependency: [], projectDependencyVersions: [], projectDependencyReport: TEST_DATA__DefaultDepotReport.dependencyReport, diff --git a/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyConflictViewer.test.tsx b/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyConflictViewer.test.tsx index b6b9c9e2ff..b0a9420e42 100644 --- a/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyConflictViewer.test.tsx +++ b/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyConflictViewer.test.tsx @@ -44,7 +44,7 @@ const TEST_DATA__ProjectConfiguration = { artifactId: 'dependency-test', projectDependencies: [ { - projectId: 'PROD-1', + projectId: 'org.finos.legend:prod-1', versionId: '2.0.0', }, { @@ -55,17 +55,6 @@ const TEST_DATA__ProjectConfiguration = { metamodelDependencies: [], }; -const TEST_DATA__ProjectData = [ - { - id: 'PROD-1', - projectId: 'PROD-1', - groupId: 'org.finos.legend', - artifactId: 'prod-1', - versions: ['1.0.0', '2.0.0'], - latestVersion: '2.0.0', - }, -]; - const TEST_DATA__Projects = [ { id: 'PROD-1', @@ -122,7 +111,6 @@ test.skip(integrationTest('Test Project Report With Conflicts'), async () => { projectConfiguration: TEST_DATA__ProjectConfiguration, latestProjectStructureVersion: TEST_DATA__latestProjectStructure, projects: TEST_DATA__Projects, - projectData: TEST_DATA__ProjectData, projectDependency: TEST_DATA__DependencyEntities, projectDependencyReport: TEST_DATA__ProjectDependencyReportWithConflict, }); diff --git a/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyEditor.test.tsx b/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyEditor.test.tsx index 93d02ed289..55c32a9a9b 100644 --- a/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyEditor.test.tsx +++ b/packages/legend-application-studio/src/components/editor/editor-group/__tests__/ProjectDependencyEditor.test.tsx @@ -33,7 +33,6 @@ import { } from '../../__test-utils__/EditorComponentTestUtils.js'; import { LEGEND_STUDIO_TEST_ID } from '../../../../__lib__/LegendStudioTesting.js'; import type { EditorStore } from '../../../../stores/editor/EditorStore.js'; -import type { ProjectDependency } from '@finos/legend-server-sdlc'; import { TEST_DATA__ProjectDependencyReport } from './TEST_DATA__ProjectDependencyReport.js'; import { RawProjectDependencyReport, @@ -49,7 +48,7 @@ const TEST_DATA__ProjectConfiguration = { artifactId: 'dependency-test', projectDependencies: [ { - projectId: 'PROD-1', + projectId: 'org.finos.legend:prod-1', versionId: '2.0.0', }, { @@ -60,17 +59,6 @@ const TEST_DATA__ProjectConfiguration = { metamodelDependencies: [], }; -const TEST_DATA__ProjectData = [ - { - id: 'PROD-1', - projectId: 'PROD-1', - groupId: 'org.finos.legend', - artifactId: 'prod-1', - versions: ['1.0.0', '2.0.0'], - latestVersion: '2.0.0', - }, -]; - const TEST_DATA__Projects = [ { id: 'PROD-1', @@ -127,7 +115,6 @@ beforeEach(async () => { projectConfiguration: TEST_DATA__ProjectConfiguration, latestProjectStructureVersion: TEST_DATA__latestProjectStructure, projects: TEST_DATA__Projects, - projectData: TEST_DATA__ProjectData, projectDependency: TEST_DATA__DependencyEntities, projectDependencyVersions: TEST_DATA__Versions, projectDependencyReport: TEST_DATA__ProjectDependencyReport, @@ -145,9 +132,7 @@ test(integrationTest('Test Project Dependency Editor'), async () => { const editorGroup = renderResult.getByTestId( LEGEND_STUDIO_TEST_ID.EDITOR_GROUP_CONTENT, ); - const updateButton = getByText(editorGroup, 'Update'); fireEvent.click(getByText(editorGroup, 'Project Dependencies')); - const configState = MOCK__editorStore.projectConfigurationEditorState; // dependency 1 await waitFor(() => getByText(editorGroup, 'PROD-1')); @@ -158,30 +143,6 @@ test(integrationTest('Test Project Dependency Editor'), async () => { await waitFor(() => getByText(editorGroup, 'PROD-2')); await waitFor(() => getByText(editorGroup, 'org.finos.legend:prod-2')); await waitFor(() => getByText(editorGroup, '3.0.0')); - - const projectDependenciesToAdd = - configState.currentProjectConfiguration.projectDependencies.filter( - (dep) => - !configState.originalConfig.projectDependencies.find( - (originalProjDep) => originalProjDep.hashCode === dep.hashCode, - ), - ); - const projectDependenciesToRemove = - configState.originalConfig.projectDependencies.filter( - (originalProjDep) => - !configState.currentProjectConfiguration.projectDependencies.find( - (dep) => dep.hashCode === originalProjDep.hashCode, - ), - ); - expect(updateButton.getAttribute('disabled')).toBeNull(); - expect(projectDependenciesToAdd).toHaveLength(1); - expect(projectDependenciesToRemove).toHaveLength(1); - expect((projectDependenciesToAdd[0] as ProjectDependency).projectId).toBe( - 'org.finos.legend:prod-1', - ); - expect((projectDependenciesToRemove[0] as ProjectDependency).projectId).toBe( - 'PROD-1', - ); }); test(integrationTest('Test Project Report'), async () => { diff --git a/packages/legend-application-studio/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx b/packages/legend-application-studio/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx index c8653280f3..ba8a68f322 100644 --- a/packages/legend-application-studio/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx +++ b/packages/legend-application-studio/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx @@ -852,19 +852,17 @@ const ProjectVersionDependencyEditor = observer( } }; const viewProject = (): void => { - if (!projectDependency.isLegacyDependency) { - applicationStore.navigationService.navigator.visitAddress( - applicationStore.navigationService.navigator.generateAddress( - generateViewProjectByGAVRoute( - guaranteeNonNullable(projectDependency.groupId), - guaranteeNonNullable(projectDependency.artifactId), - projectDependency.versionId === MASTER_SNAPSHOT_ALIAS - ? SNAPSHOT_VERSION_ALIAS - : projectDependency.versionId, - ), + applicationStore.navigationService.navigator.visitAddress( + applicationStore.navigationService.navigator.generateAddress( + generateViewProjectByGAVRoute( + guaranteeNonNullable(projectDependency.groupId), + guaranteeNonNullable(projectDependency.artifactId), + projectDependency.versionId === MASTER_SNAPSHOT_ALIAS + ? SNAPSHOT_VERSION_ALIAS + : projectDependency.versionId, ), - ); - } + ), + ); }; // NOTE: This assumes that the dependant project is in the same studio instance as the current project // In the future, the studio instance may be part of the project data @@ -929,11 +927,7 @@ const ProjectVersionDependencyEditor = observer( content={ @@ -942,7 +936,6 @@ const ProjectVersionDependencyEditor = observer( dep.projectId === node?.packageableElement.name, ); - if (projectDependency && !projectDependency.isLegacyDependency) { + if (projectDependency) { applicationStore.navigationService.navigator.visitAddress( applicationStore.navigationService.navigator.generateAddress( generateViewProjectByGAVRoute( diff --git a/packages/legend-application-studio/src/components/editor/side-bar/__tests__/DependencyTree.test.tsx b/packages/legend-application-studio/src/components/editor/side-bar/__tests__/DependencyTree.test.tsx index f9ac01fbb7..f4a7bcbb92 100644 --- a/packages/legend-application-studio/src/components/editor/side-bar/__tests__/DependencyTree.test.tsx +++ b/packages/legend-application-studio/src/components/editor/side-bar/__tests__/DependencyTree.test.tsx @@ -41,7 +41,7 @@ const TEST_DATA__ProjectConfiguration = { artifactId: 'dependency-test', projectDependencies: [ { - projectId: 'PROD-1', + projectId: 'org.finos.legend:prod-1', versionId: '2.0.0', }, { @@ -52,17 +52,6 @@ const TEST_DATA__ProjectConfiguration = { metamodelDependencies: [], }; -const TEST_DATA__ProjectData = [ - { - id: 'PROD-1', - projectId: 'PROD-1', - groupId: 'org.finos.legend', - artifactId: 'prod-1', - versions: ['1.0.0', '2.0.0'], - latestVersion: '2.0.0', - }, -]; - const TEST_DATA__Projects = [ { id: 'PROD-1', @@ -157,7 +146,6 @@ beforeEach(async () => { projectConfiguration: TEST_DATA__ProjectConfiguration, latestProjectStructureVersion: TEST_DATA__latestProjectStructure, projects: TEST_DATA__Projects, - projectData: TEST_DATA__ProjectData, projectDependency: TEST_DATA__DependencyEntities, projectDependencyReport: TEST_DATA__ProjectDependencyReport, }); diff --git a/packages/legend-application-studio/src/stores/editor/EditorGraphState.ts b/packages/legend-application-studio/src/stores/editor/EditorGraphState.ts index 88213f3f33..9cfbff55bd 100644 --- a/packages/legend-application-studio/src/stores/editor/EditorGraphState.ts +++ b/packages/legend-application-studio/src/stores/editor/EditorGraphState.ts @@ -42,11 +42,7 @@ import { ElementEditorState } from './editor-state/element-editor-state/ElementE import { GraphGenerationState } from './editor-state/GraphGenerationState.js'; import { MODEL_IMPORT_NATIVE_INPUT_TYPE } from './editor-state/ModelImporterState.js'; import type { DSL_LegendStudioApplicationPlugin_Extension } from '../LegendStudioApplicationPlugin.js'; -import { - type Entity, - EntitiesWithOrigin, - generateGAVCoordinates, -} from '@finos/legend-storage'; +import { type Entity, EntitiesWithOrigin } from '@finos/legend-storage'; import { type EntityChange, type ProjectDependency, @@ -59,7 +55,6 @@ import { ProjectDependencyCoordinates, RawProjectDependencyReport, buildDependencyReport, - StoreProjectData, } from '@finos/legend-server-depot'; import { GRAPH_MANAGER_EVENT, @@ -752,53 +747,15 @@ export class EditorGraphState { projectDependencies: ProjectDependency[], ): Promise { return Promise.all( - projectDependencies.map(async (dep) => { - /** - * We expect current dependency ids to be in the format of {groupId}:{artifactId}. - * For the legacy dependency we must fetch the corresponding coordinates (group, artifact ids) from the depot server - * - * @backwardCompatibility - */ - if (dep.isLegacyDependency) { - return this.editorStore.depotServerClient - .getProjectById(dep.projectId) - .then((projects) => { - const projectsData = projects.map((p) => - StoreProjectData.serialization.fromJson(p), - ); - if (projectsData.length !== 1) { - throw new Error( - `Expected 1 project for project ID '${dep.projectId}'. Got ${ - projectsData.length - } projects with coordinates ${projectsData - .map( - (i) => - `'${generateGAVCoordinates( - i.groupId, - i.artifactId, - undefined, - )}'`, - ) - .join(', ')}.`, - ); - } - const project = projectsData[0] as StoreProjectData; - return new ProjectDependencyCoordinates( - project.groupId, - project.artifactId, - dep.versionId, - ); - }); - } else { - return Promise.resolve( - new ProjectDependencyCoordinates( - guaranteeNonNullable(dep.groupId), - guaranteeNonNullable(dep.artifactId), - dep.versionId, - ), - ); - } - }), + projectDependencies.map(async (dep) => + Promise.resolve( + new ProjectDependencyCoordinates( + guaranteeNonNullable(dep.groupId), + guaranteeNonNullable(dep.artifactId), + dep.versionId, + ), + ), + ), ); } diff --git a/packages/legend-application-studio/src/stores/editor/__tests__/ProjectDependencyManager.test.ts b/packages/legend-application-studio/src/stores/editor/__tests__/ProjectDependencyManager.test.ts index 40b7349f5b..bf36e667ef 100644 --- a/packages/legend-application-studio/src/stores/editor/__tests__/ProjectDependencyManager.test.ts +++ b/packages/legend-application-studio/src/stores/editor/__tests__/ProjectDependencyManager.test.ts @@ -127,7 +127,7 @@ const PROJECT_CONFIG = { artifactId: 'string', projectDependencies: [ { - projectId: 'PROD_1', + projectId: 'groupId:my-artifact', versionId: '1.0.0', }, { @@ -149,25 +149,6 @@ const PROJECT_DATA = [ }, ]; -const MULTI_PROJECT_DATA = [ - { - id: '1', - projectId: 'PROD_1', - groupId: 'org.finos.legend', - artifactId: 'my-artifact', - versions: ['1.0.0'], - latestVersion: '1.0.0', - }, - { - id: '2', - projectId: 'PROD_1', - groupId: 'org.finos.legend', - artifactId: 'my-artifact-diff', - versions: ['1.0.0', '2.0.0'], - latestVersion: '2.0.0', - }, -]; - const FILE_GENERATION_PATH = 'model::myFileGeneration'; const buildFileGenerationDepentOnDependencyElements = ( dependencyEntities: string[], @@ -216,12 +197,6 @@ const testDependencyElements = async ( guaranteeNonNullable(editorStore.depotServerClient), 'collectDependencyEntities', ).mockResolvedValue(dependencyEntities); - if (projectsData) { - createSpy( - guaranteeNonNullable(editorStore.depotServerClient), - 'getProjectById', - ).mockResolvedValue(projectsData); - } if (dependencyInfo) { createSpy( guaranteeNonNullable(editorStore.depotServerClient), @@ -350,22 +325,6 @@ test( }, ); -test( - unitTest('Legacy project not returning singular project from depot'), - async () => { - await expect( - testDependencyElements( - [] as Entity[], - testDependingOnDifferentProjectVersions, - MULTI_PROJECT_DATA, - true, - ), - ).rejects.toThrowError( - "Expected 1 project for project ID 'PROD_1'. Got 2 projects with coordinates 'org.finos.legend:my-artifact', 'org.finos.legend:my-artifact-diff'.", - ); - }, -); - test( unitTest('Same project different versions dependency error check'), async () => { diff --git a/packages/legend-application-studio/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts b/packages/legend-application-studio/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts index fdafec3c8f..196c479037 100644 --- a/packages/legend-application-studio/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts +++ b/packages/legend-application-studio/src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts @@ -200,22 +200,6 @@ export class ProjectConfigurationEditorState extends EditorState { .map((v) => StoreProjectData.serialization.fromJson(v)) .forEach((project) => this.projects.set(project.coordinates, project)); - // Update the legacy dependency to newer format (using group ID and artifact ID instead of just project ID) - this.projectConfiguration?.projectDependencies.forEach( - (dependency): void => { - if (!dependency.isLegacyDependency) { - return; - } - const project = Array.from(this.projects.values()).find( - (e) => e.projectId === dependency.projectId, - ); - // re-write to new format - if (project) { - dependency.setProjectId(project.coordinates); - } - }, - ); - // fetch the versions for the dependency projects for (const dep of this.projectConfiguration?.projectDependencies ?? []) { const project = this.projects.get(dep.projectId); diff --git a/packages/legend-extension-dsl-service/src/stores/studio/QueryProductionizerStore.ts b/packages/legend-extension-dsl-service/src/stores/studio/QueryProductionizerStore.ts index db23228722..c385e6543d 100644 --- a/packages/legend-extension-dsl-service/src/stores/studio/QueryProductionizerStore.ts +++ b/packages/legend-extension-dsl-service/src/stores/studio/QueryProductionizerStore.ts @@ -71,8 +71,6 @@ import { uuid, LogEvent, guaranteeNonNullable, - assertTrue, - AssertionError, } from '@finos/legend-shared'; import { type Entity, generateGAVCoordinates } from '@finos/legend-storage'; import { @@ -90,17 +88,12 @@ import { const projectDependencyToProjectCoordinates = ( projectDependency: ProjectDependency, -): ProjectDependencyCoordinates => { - assertTrue( - !projectDependency.isLegacyDependency, - `Legacy dependency is not supported`, - ); - return new ProjectDependencyCoordinates( +): ProjectDependencyCoordinates => + new ProjectDependencyCoordinates( guaranteeNonNullable(projectDependency.groupId), guaranteeNonNullable(projectDependency.artifactId), projectDependency.versionId, ); -}; export const createServiceElement = async ( servicePath: string, @@ -589,15 +582,6 @@ export class QueryProductionizerStore { showLoading: true, }); - if ( - currentProjectConfiguration.projectDependencies.some( - (p) => p.isLegacyDependency, - ) - ) { - throw new AssertionError( - `Can't productionize query: selected project '${project.name}' (${project.projectId}) contains legacy dependencies. Please update the project and try again.`, - ); - } const dependencyEntities = ( await this.depotServerClient.collectDependencyEntities( [ diff --git a/packages/legend-server-depot/src/DepotServerClient.ts b/packages/legend-server-depot/src/DepotServerClient.ts index a5550d68c9..9d3184fb1c 100644 --- a/packages/legend-server-depot/src/DepotServerClient.ts +++ b/packages/legend-server-depot/src/DepotServerClient.ts @@ -53,8 +53,6 @@ export class DepotServerClient extends AbstractServerClient { `${this._projects()}/${encodeURIComponent(groupId)}/${encodeURIComponent( artifactId, )}`; - private _projectById = (projectId: string): string => - `${this._projects()}/${encodeURIComponent(projectId)}`; getProjects = (): Promise[]> => this.get(this._projectConfigurations()); @@ -69,11 +67,6 @@ export class DepotServerClient extends AbstractServerClient { )}/${encodeURIComponent(artifactId)}`, ); - getProjectById = ( - projectId: string, - ): Promise[]> => - this.get(this._projectById(projectId)); - // ------------------------------------------- Entities ------------------------------------------- private _versions = (groupId: string, artifactId: string): string => diff --git a/packages/legend-server-sdlc/src/models/configuration/ProjectDependency.ts b/packages/legend-server-sdlc/src/models/configuration/ProjectDependency.ts index 45a84e0501..409a3e5d71 100644 --- a/packages/legend-server-sdlc/src/models/configuration/ProjectDependency.ts +++ b/packages/legend-server-sdlc/src/models/configuration/ProjectDependency.ts @@ -58,21 +58,11 @@ export class ProjectDependency implements Hashable { this.versionId = id; } - get isLegacyDependency(): boolean { - return !this.projectId.includes(GAV_DELIMITER); - } - get groupId(): string | undefined { - if (this.isLegacyDependency) { - return undefined; - } return this.projectId.split(GAV_DELIMITER)[0]; } get artifactId(): string | undefined { - if (this.isLegacyDependency) { - return undefined; - } return this.projectId.split(GAV_DELIMITER)[1]; }