From 15b6d80e6626a0c7fd87ccbe5d13937e9d38d7a8 Mon Sep 17 00:00:00 2001 From: LaberionAjvazi Date: Mon, 29 Jan 2024 11:08:50 +0100 Subject: [PATCH] [TA-2736] Refactor getStudioPackageManifests calls --- .../package-manager/batch-import-export-service.ts | 6 +++--- src/services/studio/studio.service.ts | 9 ++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/services/package-manager/batch-import-export-service.ts b/src/services/package-manager/batch-import-export-service.ts index 212bda0..6886598 100644 --- a/src/services/package-manager/batch-import-export-service.ts +++ b/src/services/package-manager/batch-import-export-service.ts @@ -49,12 +49,12 @@ class BatchImportExportService { exportedVariables = studioService.fixConnectionVariables(exportedVariables); exportedPackagesZip.addFile("variables.yml", Buffer.from(stringify(exportedVariables), "utf8")); - const studioData = await studioService.getStudioPackageManifests(manifest); - exportedPackagesZip.addFile("studio.yml", Buffer.from(stringify(studioData), "utf8")); - const studioPackageKeys = manifest.filter(packageManifest => packageManifest.flavor === "STUDIO") .map(packageManifest => packageManifest.packageKey); + const studioData = await studioService.getStudioPackageManifests(studioPackageKeys); + exportedPackagesZip.addFile("studio.yml", Buffer.from(stringify(studioData), "utf8")); + exportedPackagesZip.getEntries().forEach(entry => { if (entry.name.endsWith(".zip") && studioPackageKeys.includes(entry.name.split("_")[0])) { const updatedPackage = studioService.processPackageForExport(entry, exportedVariables); diff --git a/src/services/studio/studio.service.ts b/src/services/studio/studio.service.ts index 1b6f112..8899888 100644 --- a/src/services/studio/studio.service.ts +++ b/src/services/studio/studio.service.ts @@ -2,7 +2,6 @@ import { NodeExportTransport, NodeSerializedContent, PackageExportTransport, - PackageManifestTransport, StudioPackageManifest, VariableExportTransport, VariableManifestTransport @@ -52,12 +51,8 @@ class StudioService { })); } - public async getStudioPackageManifests(manifests: PackageManifestTransport[]): Promise { - const exportedStudioPackageKeys = manifests - .filter(manifest => manifest.flavor === "STUDIO") - .map(exportedPackage => exportedPackage.packageKey); - - return Promise.all(exportedStudioPackageKeys.map(async packageKey => { + public async getStudioPackageManifests(studioPackageKeys: string[]): Promise { + return Promise.all(studioPackageKeys.map(async packageKey => { const node = await nodeApi.findOneByKeyAndRootNodeKey(packageKey, packageKey); const nodeSpace: SpaceTransport = await spaceApi.findOne(node.spaceId); const variableAssignments = await variablesApi.getRuntimeVariableValues(packageKey);