From fff92bb67d807fad3e44fd433b656672001383f4 Mon Sep 17 00:00:00 2001 From: zgjimhaziri Date: Mon, 23 Feb 2026 13:36:13 +0100 Subject: [PATCH 1/4] TA-4766: Add option for listing packages by package key and version --- .../api/batch-import-export-api.ts | 11 +++++++++++ .../batch-import-export.service.ts | 15 ++++++++++++--- .../config-command.service.ts | 6 ++++-- src/commands/configuration-management/module.ts | 6 +++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/commands/configuration-management/api/batch-import-export-api.ts b/src/commands/configuration-management/api/batch-import-export-api.ts index 619f45e5..6b6b8ee2 100644 --- a/src/commands/configuration-management/api/batch-import-export-api.ts +++ b/src/commands/configuration-management/api/batch-import-export-api.ts @@ -52,6 +52,17 @@ export class BatchImportExportApi { }); } + public async findPackagesByKeysAndVersion(packageKeysWithVersion: string[], withDependencies: boolean = false): Promise { + const queryParams = new URLSearchParams(); + + packageKeysWithVersion.forEach(keyWithVersion => queryParams.append("packageKeysWithVersion", keyWithVersion)); + queryParams.set("withDependencies", withDependencies.toString()); + + return this.httpClient().get(`/package-manager/api/core/packages/versions/export/list?${queryParams.toString()}`).catch(e => { + throw new FatalError(`Problem getting packages by keys and versions: ${e}`); + }); + } + public async exportPackages(packageKeys: string[], withDependencies: boolean): Promise { const queryParams = new URLSearchParams(); packageKeys.forEach(packageKey => queryParams.append("packageKeys", packageKey)); diff --git a/src/commands/configuration-management/batch-import-export.service.ts b/src/commands/configuration-management/batch-import-export.service.ts index dd4c8656..5e42bb17 100644 --- a/src/commands/configuration-management/batch-import-export.service.ts +++ b/src/commands/configuration-management/batch-import-export.service.ts @@ -41,12 +41,14 @@ export class BatchImportExportService { }); } - public async findAndExportListOfActivePackages(flavors: string[], packageKeys: string[], withDependencies: boolean): Promise { + public async findAndExportListOfActivePackages(flavors: string[], packageKeys: string[], keysByVersion: string[], withDependencies: boolean): Promise { let packagesToExport: PackageExportTransport[]; - if (packageKeys.length) { + if (keysByVersion.length) { + packagesToExport = await this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies); + } else if (packageKeys.length) { packagesToExport = await this.batchImportExportApi.findActivePackagesByKeys(packageKeys, withDependencies); - } else { + } else { packagesToExport = await this.batchImportExportApi.findAllActivePackages(flavors, withDependencies); } @@ -55,6 +57,13 @@ export class BatchImportExportService { this.exportListOfPackages(packagesToExport); } + public async listPackagesByKeysWithVersion(keysByVersion: string[], withDependencies: boolean): Promise { + const activePackages = await this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies); + activePackages.forEach(pkg => { + logger.info(`${pkg.name} - Key: "${pkg.key}"`); + }); + } + public async batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string, unzip: boolean): Promise { let exportedPackagesData: Buffer; if (packageKeys) { diff --git a/src/commands/configuration-management/config-command.service.ts b/src/commands/configuration-management/config-command.service.ts index 6e0ed493..2914a160 100644 --- a/src/commands/configuration-management/config-command.service.ts +++ b/src/commands/configuration-management/config-command.service.ts @@ -16,14 +16,16 @@ export class ConfigCommandService { this.diffService = new DiffService(context); } - public async listActivePackages(jsonResponse: boolean, flavors: string[], withDependencies: boolean, packageKeys: string[], variableValue: string, variableType: string): Promise { + public async listActivePackages(jsonResponse: boolean, flavors: string[], withDependencies: boolean, packageKeys: string[], keysByVersion: string[], variableValue: string, variableType: string): Promise { if (variableValue) { await this.listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType); return; } if (jsonResponse) { - await this.batchImportExportService.findAndExportListOfActivePackages(flavors ?? [], packageKeys ?? [], withDependencies) + await this.batchImportExportService.findAndExportListOfActivePackages(flavors ?? [], packageKeys ?? [], keysByVersion ?? [], withDependencies); + } else if (keysByVersion) { + await this.batchImportExportService.listPackagesByKeysWithVersion(keysByVersion, withDependencies); } else { await this.batchImportExportService.listActivePackages(flavors ?? []); } diff --git a/src/commands/configuration-management/module.ts b/src/commands/configuration-management/module.ts index b5e3fb68..b2937aaf 100644 --- a/src/commands/configuration-management/module.ts +++ b/src/commands/configuration-management/module.ts @@ -22,6 +22,7 @@ class Module extends IModule { .option("--flavors ", "Lists only active packages of the given flavors") .option("--withDependencies", "Include dependencies", "") .option("--packageKeys ", "Lists only given package keys") + .option("--keysByVersion ", "Lists only given package keys by version") .option("--variableValue ", "Variable value for filtering packages by.") .option("--variableType ", "Variable type for filtering packages by.") .action(this.listActivePackages); @@ -134,7 +135,10 @@ class Module extends IModule { } private async listActivePackages(context: Context, command: Command, options: OptionValues): Promise { - await new ConfigCommandService(context).listActivePackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.variableValue, options.variableType); + if (options.packageKeys && options.keysByVersion) { + throw new Error("Please provide either --packageKeys or --keysByVersion, but not both."); + } + await new ConfigCommandService(context).listActivePackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType); } private async batchExportPackages(context: Context, command: Command, options: OptionValues): Promise { From 57a703b6e3c6a047cf930229cefef97fad286ab9 Mon Sep 17 00:00:00 2001 From: zgjimhaziri Date: Mon, 23 Feb 2026 13:40:19 +0100 Subject: [PATCH 2/4] TA-4766: Fix existing tests --- .../configuration-management/config-list.spec.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/commands/configuration-management/config-list.spec.ts b/tests/commands/configuration-management/config-list.spec.ts index b1c6af02..ade0f61e 100644 --- a/tests/commands/configuration-management/config-list.spec.ts +++ b/tests/commands/configuration-management/config-list.spec.ts @@ -1,5 +1,4 @@ import * as path from "path"; -import { stringify } from "../../../src/core/utils/json"; import { PacmanApiUtils } from "../../utls/pacman-api.utils"; import { mockAxiosGet } from "../../utls/http-requests-mock"; import { ConfigCommandService } from "../../../src/commands/configuration-management/config-command.service"; @@ -33,7 +32,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list?" + urlParams.toString(), [firstPackage, secondPackage]); - await new ConfigCommandService(testContext).listActivePackages(false, flavorsArray, false, [], null, null); + await new ConfigCommandService(testContext).listActivePackages(false, flavorsArray, false, [], undefined, null, null); expect(loggingTestTransport.logMessages.length).toBe(2); expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); @@ -50,7 +49,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list?withDependencies=false", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], null, null); + await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -96,7 +95,7 @@ describe("Config list", () => { }; mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/compute-pools/data-models/details", [dataModelDetailResponse]); - await new ConfigCommandService(testContext).listActivePackages(true, [], true, [], null, null); + await new ConfigCommandService(testContext).listActivePackages(true, [], true, [], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -121,7 +120,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-keys?packageKeys=key-1&packageKeys=key-2&withDependencies=false", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [firstPackage.key, secondPackage.key], null, null); + await new ConfigCommandService(testContext).listActivePackages(true, [], false, [firstPackage.key, secondPackage.key], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -167,7 +166,7 @@ describe("Config list", () => { }; mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/compute-pools/data-models/details", [dataModelDetailResponse]); - await new ConfigCommandService(testContext).listActivePackages(true, [], true, [firstPackage.key, secondPackage.key], null, null); + await new ConfigCommandService(testContext).listActivePackages(true, [], true, [firstPackage.key, secondPackage.key], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -191,7 +190,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-variable-value?variableValue=1", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", []); - await new ConfigCommandService(testContext).listActivePackages(false, [], false, [], "1", null); + await new ConfigCommandService(testContext).listActivePackages(false, [], false, [], undefined, "1", null); expect(loggingTestTransport.logMessages.length).toBe(2); expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); @@ -205,7 +204,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-variable-value?variableValue=1", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", []); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], "1", null); + await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], undefined, "1", null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; From a6f45cd3aabacab4f6135b8aa0239485e7b2fd39 Mon Sep 17 00:00:00 2001 From: zgjimhaziri Date: Mon, 23 Feb 2026 13:42:19 +0100 Subject: [PATCH 3/4] TA-4766: Add new tests for the new option --- .../config-list.spec.ts | 60 +++++++++++++++++++ .../configuration-management/module.spec.ts | 56 +++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/tests/commands/configuration-management/config-list.spec.ts b/tests/commands/configuration-management/config-list.spec.ts index ade0f61e..6e8c0852 100644 --- a/tests/commands/configuration-management/config-list.spec.ts +++ b/tests/commands/configuration-management/config-list.spec.ts @@ -214,4 +214,64 @@ describe("Config list", () => { expect(exportedTransports.length).toBe(2); }) + it("Should list packages by keysByVersion for non-json response", async () => { + const firstPackage = PacmanApiUtils.buildPackageExportTransport("key-1", "name-1"); + const secondPackage = PacmanApiUtils.buildPackageExportTransport("key-2", "name-2"); + + const keysByVersion = ["key-1.1.0.0", "key-2.1.0.1"]; + mockAxiosGet( + "https://myTeam.celonis.cloud/package-manager/api/core/packages/versions/export/list?packageKeysWithVersion=key-1.1.0.0&packageKeysWithVersion=key-2.1.0.1&withDependencies=false", + [firstPackage, secondPackage] + ); + + await new ConfigCommandService(testContext).listActivePackages(false, [], false, undefined, keysByVersion, null, null); + + expect(loggingTestTransport.logMessages.length).toBe(2); + expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); + expect(loggingTestTransport.logMessages[1].message).toContain(`${secondPackage.name} - Key: "${secondPackage.key}"`); + }) + + it("Should list packages by keysByVersion with withDependencies for non-json response", async () => { + const firstPackage = PacmanApiUtils.buildPackageExportTransport("key-1", "name-1"); + const secondPackage = PacmanApiUtils.buildPackageExportTransport("key-2", "name-2"); + + const keysByVersion = ["key-1.1.0.0", "key-2.1.0.1"]; + mockAxiosGet( + "https://myTeam.celonis.cloud/package-manager/api/core/packages/versions/export/list?packageKeysWithVersion=key-1.1.0.0&packageKeysWithVersion=key-2.1.0.1&withDependencies=true", + [firstPackage, secondPackage] + ); + + await new ConfigCommandService(testContext).listActivePackages(false, [], true, undefined, keysByVersion, null, null); + + expect(loggingTestTransport.logMessages.length).toBe(2); + }) + + it("Should list packages by keysByVersion for json response", async () => { + const firstPackage = PacmanApiUtils.buildPackageExportTransport("key-1", "name-1"); + const secondPackage = PacmanApiUtils.buildPackageExportTransport("key-2", "name-2"); + + const studioPackage: ContentNodeTransport = PacmanApiUtils.buildContentNodeTransport("key-1", "spaceId-1"); + const keysByVersion = ["key-1.1.0.0", "key-2.1.0.1"]; + + mockAxiosGet( + "https://myTeam.celonis.cloud/package-manager/api/core/packages/versions/export/list?packageKeysWithVersion=key-1.1.0.0&packageKeysWithVersion=key-2.1.0.1&withDependencies=false", + [{...firstPackage}, {...secondPackage}] + ); + mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); + + await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], keysByVersion, null, null); + + const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; + + expect(mockWriteFileSync).toHaveBeenCalledWith(path.resolve(process.cwd(), expectedFileName), expect.any(String), {encoding: "utf-8"}); + + const exportedTransports = JSON.parse(mockWriteFileSync.mock.calls[0][1]) as PackageExportTransport[]; + expect(exportedTransports.length).toBe(2); + + const exportedFirstPackage = exportedTransports.filter(transport => transport.key === firstPackage.key)[0]; + const exportedSecondPackage = exportedTransports.filter(transport => transport.key === secondPackage.key)[0]; + + expect(exportedSecondPackage).toEqual(secondPackage); + expect(exportedFirstPackage).toEqual({...firstPackage, spaceId: "spaceId-1"}); + }) }) \ No newline at end of file diff --git a/tests/commands/configuration-management/module.spec.ts b/tests/commands/configuration-management/module.spec.ts index 17e62cc0..375714a2 100644 --- a/tests/commands/configuration-management/module.spec.ts +++ b/tests/commands/configuration-management/module.spec.ts @@ -19,6 +19,7 @@ describe("Configuration Management Module - Action Validations", () => { mockCommand = {} as Command; mockConfigCommandService = { + listActivePackages: jest.fn().mockResolvedValue(undefined), batchExportPackages: jest.fn().mockResolvedValue(undefined), batchImportPackages: jest.fn().mockResolvedValue(undefined), } as any; @@ -31,6 +32,61 @@ describe("Configuration Management Module - Action Validations", () => { (NodeDependencyService as jest.MockedClass).mockImplementation(() => mockNodeDependencyService); }); + describe("listActivePackages validation", () => { + describe("packageKeys and keysByVersion validation", () => { + it("should throw error when both packageKeys and keysByVersion are provided", async () => { + const options: OptionValues = { + packageKeys: ["package1", "package2"], + keysByVersion: ["package3.1.0.0", "package4.1.0.0"], + }; + + await expect( + (module as any).listActivePackages(testContext, mockCommand, options) + ).rejects.toThrow("Please provide either --packageKeys or --keysByVersion, but not both."); + + expect(mockConfigCommandService.listActivePackages).not.toHaveBeenCalled(); + }); + + it("should pass validation when only packageKeys is provided", async () => { + const options: OptionValues = { + packageKeys: ["package1", "package2"], + json: true, + }; + + await (module as any).listActivePackages(testContext, mockCommand, options); + + expect(mockConfigCommandService.listActivePackages).toHaveBeenCalledWith( + true, + undefined, + undefined, + ["package1", "package2"], + undefined, + undefined, + undefined + ); + }); + + it("should pass validation when only keysByVersion is provided", async () => { + const options: OptionValues = { + keysByVersion: ["package3.1.0.0", "package4.1.0.0"], + json: true, + }; + + await (module as any).listActivePackages(testContext, mockCommand, options); + + expect(mockConfigCommandService.listActivePackages).toHaveBeenCalledWith( + true, + undefined, + undefined, + undefined, + ["package3.1.0.0", "package4.1.0.0"], + undefined, + undefined + ); + }); + }); + }); + describe("batchExportPackages validation", () => { describe("packageKeys and keysByVersion validation", () => { it("should throw error when both packageKeys and keysByVersion are provided", async () => { From 3375e16e88a8d994f8c58bd5e42b28a68665e4de Mon Sep 17 00:00:00 2001 From: zgjimhaziri Date: Mon, 23 Feb 2026 18:09:46 +0100 Subject: [PATCH 4/4] TA-4766: Naming refactorings --- .../batch-import-export.service.ts | 6 +++--- .../config-command.service.ts | 4 ++-- .../configuration-management/module.ts | 12 +++++------ .../config-list.spec.ts | 20 +++++++++---------- .../configuration-management/module.spec.ts | 14 ++++++------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/commands/configuration-management/batch-import-export.service.ts b/src/commands/configuration-management/batch-import-export.service.ts index 5e42bb17..8b45b099 100644 --- a/src/commands/configuration-management/batch-import-export.service.ts +++ b/src/commands/configuration-management/batch-import-export.service.ts @@ -41,7 +41,7 @@ export class BatchImportExportService { }); } - public async findAndExportListOfActivePackages(flavors: string[], packageKeys: string[], keysByVersion: string[], withDependencies: boolean): Promise { + public async findAndExportListOfPackages(flavors: string[], packageKeys: string[], keysByVersion: string[], withDependencies: boolean): Promise { let packagesToExport: PackageExportTransport[]; if (keysByVersion.length) { @@ -58,8 +58,8 @@ export class BatchImportExportService { } public async listPackagesByKeysWithVersion(keysByVersion: string[], withDependencies: boolean): Promise { - const activePackages = await this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies); - activePackages.forEach(pkg => { + const exportedPackages = await this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies); + exportedPackages.forEach(pkg => { logger.info(`${pkg.name} - Key: "${pkg.key}"`); }); } diff --git a/src/commands/configuration-management/config-command.service.ts b/src/commands/configuration-management/config-command.service.ts index 2914a160..b0a903f1 100644 --- a/src/commands/configuration-management/config-command.service.ts +++ b/src/commands/configuration-management/config-command.service.ts @@ -16,14 +16,14 @@ export class ConfigCommandService { this.diffService = new DiffService(context); } - public async listActivePackages(jsonResponse: boolean, flavors: string[], withDependencies: boolean, packageKeys: string[], keysByVersion: string[], variableValue: string, variableType: string): Promise { + public async listPackages(jsonResponse: boolean, flavors: string[], withDependencies: boolean, packageKeys: string[], keysByVersion: string[], variableValue: string, variableType: string): Promise { if (variableValue) { await this.listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType); return; } if (jsonResponse) { - await this.batchImportExportService.findAndExportListOfActivePackages(flavors ?? [], packageKeys ?? [], keysByVersion ?? [], withDependencies); + await this.batchImportExportService.findAndExportListOfPackages(flavors ?? [], packageKeys ?? [], keysByVersion ?? [], withDependencies); } else if (keysByVersion) { await this.batchImportExportService.listPackagesByKeysWithVersion(keysByVersion, withDependencies); } else { diff --git a/src/commands/configuration-management/module.ts b/src/commands/configuration-management/module.ts index b2937aaf..1d45f7f2 100644 --- a/src/commands/configuration-management/module.ts +++ b/src/commands/configuration-management/module.ts @@ -17,15 +17,15 @@ class Module extends IModule { public register(context: Context, configurator: Configurator): void { const configCommand = configurator.command("config"); configCommand.command("list") - .description("Command to list active packages that can be exported") + .description("Command to list packages") .option("--json", "Return response as json type", "") .option("--flavors ", "Lists only active packages of the given flavors") .option("--withDependencies", "Include dependencies", "") - .option("--packageKeys ", "Lists only given package keys") - .option("--keysByVersion ", "Lists only given package keys by version") + .option("--packageKeys ", "Lists only active versions of given package keys") + .option("--keysByVersion ", "Lists packages by given key and version [packageKey.version]") .option("--variableValue ", "Variable value for filtering packages by.") .option("--variableType ", "Variable type for filtering packages by.") - .action(this.listActivePackages); + .action(this.listPackages); configCommand.command("export") .description("Command to export package configs") @@ -134,11 +134,11 @@ class Module extends IModule { .action(this.listAssignments); } - private async listActivePackages(context: Context, command: Command, options: OptionValues): Promise { + private async listPackages(context: Context, command: Command, options: OptionValues): Promise { if (options.packageKeys && options.keysByVersion) { throw new Error("Please provide either --packageKeys or --keysByVersion, but not both."); } - await new ConfigCommandService(context).listActivePackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType); + await new ConfigCommandService(context).listPackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType); } private async batchExportPackages(context: Context, command: Command, options: OptionValues): Promise { diff --git a/tests/commands/configuration-management/config-list.spec.ts b/tests/commands/configuration-management/config-list.spec.ts index 6e8c0852..11898b05 100644 --- a/tests/commands/configuration-management/config-list.spec.ts +++ b/tests/commands/configuration-management/config-list.spec.ts @@ -32,7 +32,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list?" + urlParams.toString(), [firstPackage, secondPackage]); - await new ConfigCommandService(testContext).listActivePackages(false, flavorsArray, false, [], undefined, null, null); + await new ConfigCommandService(testContext).listPackages(false, flavorsArray, false, [], undefined, null, null); expect(loggingTestTransport.logMessages.length).toBe(2); expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); @@ -49,7 +49,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list?withDependencies=false", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], undefined, null, null); + await new ConfigCommandService(testContext).listPackages(true, [], false, [], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -95,7 +95,7 @@ describe("Config list", () => { }; mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/compute-pools/data-models/details", [dataModelDetailResponse]); - await new ConfigCommandService(testContext).listActivePackages(true, [], true, [], undefined, null, null); + await new ConfigCommandService(testContext).listPackages(true, [], true, [], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -120,7 +120,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-keys?packageKeys=key-1&packageKeys=key-2&withDependencies=false", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [firstPackage.key, secondPackage.key], undefined, null, null); + await new ConfigCommandService(testContext).listPackages(true, [], false, [firstPackage.key, secondPackage.key], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -166,7 +166,7 @@ describe("Config list", () => { }; mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/compute-pools/data-models/details", [dataModelDetailResponse]); - await new ConfigCommandService(testContext).listActivePackages(true, [], true, [firstPackage.key, secondPackage.key], undefined, null, null); + await new ConfigCommandService(testContext).listPackages(true, [], true, [firstPackage.key, secondPackage.key], undefined, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -190,7 +190,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-variable-value?variableValue=1", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", []); - await new ConfigCommandService(testContext).listActivePackages(false, [], false, [], undefined, "1", null); + await new ConfigCommandService(testContext).listPackages(false, [], false, [], undefined, "1", null); expect(loggingTestTransport.logMessages.length).toBe(2); expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); @@ -204,7 +204,7 @@ describe("Config list", () => { mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/list-by-variable-value?variableValue=1", [{...firstPackage}, {...secondPackage}]); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", []); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], undefined, "1", null); + await new ConfigCommandService(testContext).listPackages(true, [], false, [], undefined, "1", null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; @@ -224,7 +224,7 @@ describe("Config list", () => { [firstPackage, secondPackage] ); - await new ConfigCommandService(testContext).listActivePackages(false, [], false, undefined, keysByVersion, null, null); + await new ConfigCommandService(testContext).listPackages(false, [], false, undefined, keysByVersion, null, null); expect(loggingTestTransport.logMessages.length).toBe(2); expect(loggingTestTransport.logMessages[0].message).toContain(`${firstPackage.name} - Key: "${firstPackage.key}"`); @@ -241,7 +241,7 @@ describe("Config list", () => { [firstPackage, secondPackage] ); - await new ConfigCommandService(testContext).listActivePackages(false, [], true, undefined, keysByVersion, null, null); + await new ConfigCommandService(testContext).listPackages(false, [], true, undefined, keysByVersion, null, null); expect(loggingTestTransport.logMessages.length).toBe(2); }) @@ -259,7 +259,7 @@ describe("Config list", () => { ); mockAxiosGet("https://myTeam.celonis.cloud/package-manager/api/packages/with-variable-assignments?type=DATA_MODEL", [studioPackage]); - await new ConfigCommandService(testContext).listActivePackages(true, [], false, [], keysByVersion, null, null); + await new ConfigCommandService(testContext).listPackages(true, [], false, [], keysByVersion, null, null); const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1]; diff --git a/tests/commands/configuration-management/module.spec.ts b/tests/commands/configuration-management/module.spec.ts index 375714a2..c6fb4995 100644 --- a/tests/commands/configuration-management/module.spec.ts +++ b/tests/commands/configuration-management/module.spec.ts @@ -19,7 +19,7 @@ describe("Configuration Management Module - Action Validations", () => { mockCommand = {} as Command; mockConfigCommandService = { - listActivePackages: jest.fn().mockResolvedValue(undefined), + listPackages: jest.fn().mockResolvedValue(undefined), batchExportPackages: jest.fn().mockResolvedValue(undefined), batchImportPackages: jest.fn().mockResolvedValue(undefined), } as any; @@ -41,10 +41,10 @@ describe("Configuration Management Module - Action Validations", () => { }; await expect( - (module as any).listActivePackages(testContext, mockCommand, options) + (module as any).listPackages(testContext, mockCommand, options) ).rejects.toThrow("Please provide either --packageKeys or --keysByVersion, but not both."); - expect(mockConfigCommandService.listActivePackages).not.toHaveBeenCalled(); + expect(mockConfigCommandService.listPackages).not.toHaveBeenCalled(); }); it("should pass validation when only packageKeys is provided", async () => { @@ -53,9 +53,9 @@ describe("Configuration Management Module - Action Validations", () => { json: true, }; - await (module as any).listActivePackages(testContext, mockCommand, options); + await (module as any).listPackages(testContext, mockCommand, options); - expect(mockConfigCommandService.listActivePackages).toHaveBeenCalledWith( + expect(mockConfigCommandService.listPackages).toHaveBeenCalledWith( true, undefined, undefined, @@ -72,9 +72,9 @@ describe("Configuration Management Module - Action Validations", () => { json: true, }; - await (module as any).listActivePackages(testContext, mockCommand, options); + await (module as any).listPackages(testContext, mockCommand, options); - expect(mockConfigCommandService.listActivePackages).toHaveBeenCalledWith( + expect(mockConfigCommandService.listPackages).toHaveBeenCalledWith( true, undefined, undefined,