Skip to content

Commit

Permalink
[TA-2736] Refactor getStudioPackageManifests calls
Browse files Browse the repository at this point in the history
  • Loading branch information
LaberionAjvazi committed Jan 29, 2024
1 parent 3444704 commit 15b6d80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/services/package-manager/batch-import-export-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions src/services/studio/studio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
NodeExportTransport,
NodeSerializedContent,
PackageExportTransport,
PackageManifestTransport,
StudioPackageManifest,
VariableExportTransport,
VariableManifestTransport
Expand Down Expand Up @@ -52,12 +51,8 @@ class StudioService {
}));
}

public async getStudioPackageManifests(manifests: PackageManifestTransport[]): Promise<StudioPackageManifest[]> {
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<StudioPackageManifest[]> {
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);
Expand Down

0 comments on commit 15b6d80

Please sign in to comment.