@celonis/content-cli 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.variableAssignmentApis = {
13
+ DATA_MODEL: {
14
+ url: "/package-manager/api/compute-pools/pools-with-data-models"
15
+ },
16
+ CONNECTION: {
17
+ url: "/process-automation-v2/api/connections"
18
+ }
19
+ };
20
+ });
@@ -13,13 +13,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "../services/http-client-service.v2", "../util/logger"], factory);
16
+ define(["require", "exports", "../services/http-client-service.v2", "../util/logger", "./variable-assignment-apis"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const http_client_service_v2_1 = require("../services/http-client-service.v2");
22
22
  const logger_1 = require("../util/logger");
23
+ const variable_assignment_apis_1 = require("./variable-assignment-apis");
23
24
  class VariablesApi {
24
25
  assignVariableValues(packageKey, variablesAssignments) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
@@ -28,7 +29,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28
29
  });
29
30
  });
30
31
  }
32
+ getCandidateAssignments(type, params) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if (!VariablesApi.ASSIGNMENT_APIS[type]) {
35
+ throw new logger_1.FatalError(`Variable type ${type} not supported.`);
36
+ }
37
+ const apiUrl = VariablesApi.ASSIGNMENT_APIS[type].url + (params.toString().length ? `?${params.toString()}` : "");
38
+ return http_client_service_v2_1.httpClientV2.get(apiUrl).catch(e => {
39
+ throw new logger_1.FatalError(`Problem getting variables assignment values for type ${type}: ${e}`);
40
+ });
41
+ });
42
+ }
31
43
  }
32
44
  VariablesApi.INSTANCE = new VariablesApi();
45
+ VariablesApi.ASSIGNMENT_APIS = variable_assignment_apis_1.variableAssignmentApis;
33
46
  exports.variablesApi = VariablesApi.INSTANCE;
34
47
  });
@@ -0,0 +1,35 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../services/package-manager/variable-service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const variable_service_1 = require("../services/package-manager/variable-service");
22
+ class VariableCommand {
23
+ listAssignments(variableType, jsonResponse, params) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (jsonResponse) {
26
+ yield variable_service_1.variableService.findAndExportCandidateAssignments(variableType, params);
27
+ }
28
+ else {
29
+ yield variable_service_1.variableService.listCandidateAssignments(variableType, params);
30
+ }
31
+ });
32
+ }
33
+ }
34
+ exports.VariableCommand = VariableCommand;
35
+ });
@@ -31,7 +31,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  .option("-p, --profile <profile>", "Profile which you want to use to list packages")
32
32
  .option("--spaceMappings <spaceMappings...>", "List of mappings for importing packages to different target spaces. Mappings should follow format 'packageKey:targetSpaceKey'")
33
33
  .option("--overwrite", "Flag to allow overwriting of packages")
34
- .option("--dataModelMappingsFile <dataModelMappingsFile>", "DataModel variable mappings file path")
34
+ .option("--dataModelMappingsFile <dataModelMappingsFile>", "DataModel variable mappings file path. If missing, variables will be mapped from manifest file.")
35
35
  .requiredOption("-f, --file <file>", "Exported packages file (relative path)")
36
36
  .action((cmd) => __awaiter(this, void 0, void 0, function* () {
37
37
  yield new package_command_1.PackageCommand().batchImportPackages(cmd.spaceMappings, cmd.dataModelMappingsFile, cmd.file, cmd.overwrite);
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "./commands/package.command", "./commands/space.command", "./commands/data-pool.command", "./commands/asset.command", "./util/logger", "commander", "./util/context-initializer"], factory);
16
+ define(["require", "exports", "./commands/package.command", "./commands/space.command", "./commands/data-pool.command", "./commands/asset.command", "./util/logger", "commander", "./util/context-initializer", "./commands/variable.command"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -25,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  const logger_1 = require("./util/logger");
26
26
  const commander = require("commander");
27
27
  const context_initializer_1 = require("./util/context-initializer");
28
+ const variable_command_1 = require("./commands/variable.command");
28
29
  class List {
29
30
  static packages(program) {
30
31
  program
@@ -77,6 +78,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
77
78
  }));
78
79
  return program;
79
80
  }
81
+ static assignments(program) {
82
+ program
83
+ .command("assignments")
84
+ .description("Command to list possible variable assignments for a type")
85
+ .option("-p, --profile <profile>", "Profile which you want to use to list possible variable assignments")
86
+ .option("--json", "Return response as json type", "")
87
+ .requiredOption("--type <type>", "Type of variable")
88
+ .option("--params <params>", "Variable query params")
89
+ .action((cmd) => __awaiter(this, void 0, void 0, function* () {
90
+ yield new variable_command_1.VariableCommand().listAssignments(cmd.type, cmd.json, cmd.params);
91
+ process.exit();
92
+ }));
93
+ return program;
94
+ }
80
95
  }
81
96
  exports.List = List;
82
97
  process.on("unhandledRejection", (e, promise) => {
@@ -87,6 +102,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
87
102
  List.spaces(commander);
88
103
  List.dataPools(commander);
89
104
  List.assets(commander);
105
+ List.assignments(commander);
90
106
  commander.parse(process.argv);
91
107
  };
92
108
  context_initializer_1.ContextInitializer.initContext()
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,4 @@
1
+ import { VariableAssignmentApi } from "../interfaces/variable-assignment-api.interface";
2
+ export declare const variableAssignmentApis: {
3
+ [key: string]: VariableAssignmentApi;
4
+ };
@@ -1,7 +1,13 @@
1
+ /// <reference types="node" />
1
2
  import { ContentNodeTransport, VariablesAssignments } from "../interfaces/package-manager.interfaces";
3
+ import { URLSearchParams } from "url";
2
4
  declare class VariablesApi {
3
5
  static readonly INSTANCE: VariablesApi;
6
+ static readonly ASSIGNMENT_APIS: {
7
+ [key: string]: import("../interfaces/variable-assignment-api.interface").VariableAssignmentApi;
8
+ };
4
9
  assignVariableValues(packageKey: string, variablesAssignments: VariablesAssignments[]): Promise<ContentNodeTransport[]>;
10
+ getCandidateAssignments(type: string, params: URLSearchParams): Promise<object[]>;
5
11
  }
6
12
  export declare const variablesApi: VariablesApi;
7
13
  export {};
@@ -0,0 +1,3 @@
1
+ export declare class VariableCommand {
2
+ listAssignments(variableType: string, jsonResponse: boolean, params: string): Promise<void>;
3
+ }
@@ -5,5 +5,6 @@ export declare class List {
5
5
  static spaces(program: CommanderStatic): CommanderStatic;
6
6
  static dataPools(program: CommanderStatic): CommanderStatic;
7
7
  static assets(program: CommanderStatic): CommanderStatic;
8
+ static assignments(program: CommanderStatic): CommanderStatic;
8
9
  }
9
10
  export {};
@@ -0,0 +1,3 @@
1
+ export interface VariableAssignmentApi {
2
+ url: string;
3
+ }
@@ -2,6 +2,9 @@ import { PackageManagerVariableType, PackageWithVariableAssignments, VariablesAs
2
2
  declare class VariableService {
3
3
  getVariableAssignmentsForNodes(type?: PackageManagerVariableType): Promise<PackageWithVariableAssignments[]>;
4
4
  assignVariableValues(packageKey: string, variablesAssignments: VariablesAssignments[]): Promise<void>;
5
+ listCandidateAssignments(type: string, params: string): Promise<void>;
6
+ findAndExportCandidateAssignments(type: string, params: string): Promise<void>;
7
+ private parseParams;
5
8
  }
6
9
  export declare const variableService: VariableService;
7
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celonis/content-cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "CLI Tool to help manage content in Celonis EMS",
5
5
  "main": "content-cli.js",
6
6
  "bin": {
@@ -173,13 +173,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
173
173
  }
174
174
  nodeInTargetTeam = yield node_api_1.nodeApi.findOneByKeyAndRootNodeKey(packageToImport.packageKey, packageToImport.packageKey);
175
175
  if (this.isLatestVersion(versionOfPackageBeingImported, [...packageToImport.dependenciesByVersion.keys()])) {
176
- const variableAssignments = packageToImport.variables
177
- .filter(variable => variable.type === package_manager_interfaces_1.PackageManagerVariableType.DATA_MODEL).map(variable => {
178
- var _a;
179
- variable.value = dmTargetIdsBySourceIds.get((_a = variable.value) === null || _a === void 0 ? void 0 : _a.toString());
180
- return variable;
181
- });
182
- yield variable_service_1.variableService.assignVariableValues(nodeInTargetTeam.key, variableAssignments);
176
+ if (dmTargetIdsBySourceIds.size > 0) {
177
+ const variableAssignments = packageToImport.variables
178
+ .filter(variable => variable.type === package_manager_interfaces_1.PackageManagerVariableType.DATA_MODEL).map(variable => {
179
+ var _a;
180
+ variable.value = dmTargetIdsBySourceIds.get((_a = variable.value) === null || _a === void 0 ? void 0 : _a.toString());
181
+ return variable;
182
+ });
183
+ yield variable_service_1.variableService.assignVariableValues(nodeInTargetTeam.key, variableAssignments);
184
+ }
185
+ else {
186
+ yield variable_service_1.variableService.assignVariableValues(nodeInTargetTeam.key, packageToImport.variables);
187
+ }
183
188
  }
184
189
  draftIdsByPackageKeyAndVersion.set(`${nodeInTargetTeam.key}_${versionOfPackageBeingImported}`, nodeInTargetTeam.workingDraftId);
185
190
  yield this.updateDependencyVersions(packageToImport, versionOfPackageBeingImported, sourceToTargetVersionsByNodeKey, draftIdsByPackageKeyAndVersion);
@@ -13,13 +13,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "../../api/package-api", "../../api/variables-api"], factory);
16
+ define(["require", "exports", "../../api/package-api", "../../api/variables-api", "uuid", "../../util/logger", "../file-service", "url"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const package_api_1 = require("../../api/package-api");
22
22
  const variables_api_1 = require("../../api/variables-api");
23
+ const uuid_1 = require("uuid");
24
+ const logger_1 = require("../../util/logger");
25
+ const file_service_1 = require("../file-service");
26
+ const url_1 = require("url");
23
27
  class VariableService {
24
28
  getVariableAssignmentsForNodes(type) {
25
29
  return __awaiter(this, void 0, void 0, function* () {
@@ -31,6 +35,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
35
  yield variables_api_1.variablesApi.assignVariableValues(packageKey, variablesAssignments);
32
36
  });
33
37
  }
38
+ listCandidateAssignments(type, params) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const parsedParams = this.parseParams(params);
41
+ const assignments = yield variables_api_1.variablesApi.getCandidateAssignments(type, parsedParams);
42
+ assignments.forEach(assignment => {
43
+ logger_1.logger.info(JSON.stringify(assignment));
44
+ });
45
+ });
46
+ }
47
+ findAndExportCandidateAssignments(type, params) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const parsedParams = this.parseParams(params);
50
+ const assignments = yield variables_api_1.variablesApi.getCandidateAssignments(type, parsedParams);
51
+ const filename = uuid_1.v4() + ".json";
52
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(assignments), filename);
53
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
54
+ });
55
+ }
56
+ parseParams(params) {
57
+ const queryParams = new url_1.URLSearchParams();
58
+ if (params) {
59
+ try {
60
+ params.split(",").forEach((param) => {
61
+ const paramKeyValuePair = param.split("=");
62
+ queryParams.set(paramKeyValuePair[0], paramKeyValuePair[1]);
63
+ });
64
+ }
65
+ catch (e) {
66
+ throw new logger_1.FatalError(`Problem parsing query params: ${e}`);
67
+ }
68
+ }
69
+ return queryParams;
70
+ }
34
71
  }
35
72
  exports.variableService = new VariableService();
36
73
  });