Skip to content

Commit

Permalink
Merge pull request #171 from celonis/TA-2858-get-runtime-values-for-a…
Browse files Browse the repository at this point in the history
…ctive-drafts

TA-2858: Get runtime variable values as VIEWER
  • Loading branch information
LaberionAjvazi authored Feb 12, 2024
2 parents e66baf1 + fe5bffc commit 0de1d2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/api/variables-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ class VariablesApi {
});
}

public getRuntimeVariableValues(packageKey: string): Promise<VariablesAssignments[]> {
return httpClientV2.get(`/package-manager/api/nodes/by-package-key/${packageKey}/variables/runtime-values`).catch(e => {
public getRuntimeVariableValues(packageKey: string, appMode: string): Promise<VariablesAssignments[]> {
const queryParams = new URLSearchParams();
queryParams.set("appMode", appMode);

return httpClientV2.get(`/package-manager/api/nodes/by-package-key/${packageKey}/variables/runtime-values?${queryParams.toString()}`).catch(e => {
throw new FatalError(`Problem getting runtime variables of package ${packageKey}: ${e}`);
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/batch-export-import-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export enum BatchExportImportConstants {
STUDIO_FILE_NAME = "studio.yml",
VARIABLES_FILE_NAME = "variables.yml",
MANIFEST_FILE_NAME = "manifest.yml",
STUDIO = "STUDIO"
STUDIO = "STUDIO",
APP_MODE_VIEWER = "VIEWER"
}
2 changes: 1 addition & 1 deletion src/services/studio/studio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StudioService {
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);
const variableAssignments = await variablesApi.getRuntimeVariableValues(packageKey, BatchExportImportConstants.APP_MODE_VIEWER);

return {
packageKey: packageKey,
Expand Down
16 changes: 8 additions & 8 deletions tests/config/config-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe("Config export", () => {
mockAxiosPost("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/batch/variables-with-assignments", []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${firstStudioPackage.key}/${firstStudioPackage.key}`, firstStudioPackage);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${secondStudioPackage.key}/${secondStudioPackage.key}`, secondStudioPackage);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstStudioPackage.key}/variables/runtime-values`, [firstPackageRuntimeVariable]);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondStudioPackage.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstStudioPackage.key}/variables/runtime-values?appMode=VIEWER`, [firstPackageRuntimeVariable]);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondStudioPackage.key}/variables/runtime-values?appMode=VIEWER`, []);

await new ConfigCommand().batchExportPackages(["key-1", "key-2", "key-3"], true);

Expand Down Expand Up @@ -165,8 +165,8 @@ describe("Config export", () => {
mockAxiosPost("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/batch/variables-with-assignments", [...exportedVariables]);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${firstPackageNode.key}/${firstPackageNode.key}`, {...firstPackageNode, spaceId: "space-1"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${secondPackageNode.key}/${secondPackageNode.key}`, {...secondPackageNode, spaceId: "space-2"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);

await new ConfigCommand().batchExportPackages(["key-1", "key-2"], true);

Expand Down Expand Up @@ -253,8 +253,8 @@ describe("Config export", () => {
mockAxiosPost("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/batch/variables-with-assignments", []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${firstPackageNode.key}/${firstPackageNode.key}`, {...firstPackageNode, spaceId: "space-1"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${secondPackageNode.key}/${secondPackageNode.key}`, {...secondPackageNode, spaceId: "space-2"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);

await new ConfigCommand().batchExportPackages(["key-1", "key-2"], true);

Expand Down Expand Up @@ -356,8 +356,8 @@ describe("Config export", () => {
mockAxiosPost("https://myTeam.celonis.cloud/package-manager/api/core/packages/export/batch/variables-with-assignments", exportedVariables);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${firstPackageNode.key}/${firstPackageNode.key}`, {...firstPackageNode, spaceId: "space-1"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/${secondPackageNode.key}/${secondPackageNode.key}`, {...secondPackageNode, spaceId: "space-2"});
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${firstPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);
mockAxiosGet(`https://myTeam.celonis.cloud/package-manager/api/nodes/by-package-key/${secondPackageNode.key}/variables/runtime-values?appMode=VIEWER`, []);

await new ConfigCommand().batchExportPackages(["key-1", "key-2"], true);

Expand Down

0 comments on commit 0de1d2e

Please sign in to comment.