@celonis/content-cli 1.10.0 → 1.12.0

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.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/commands/asset-registry/asset-registry-api.js +14 -26
  3. package/commands/asset-registry/asset-registry-error.js +57 -0
  4. package/commands/asset-registry/asset-registry.service.js +38 -10
  5. package/commands/asset-registry/module.js +7 -6
  6. package/commands/configuration-management/api/metadata-api.js +38 -0
  7. package/commands/configuration-management/api/node-diff-api.js +15 -1
  8. package/commands/configuration-management/api/{diff-api.js → single-package-import-api.js} +5 -10
  9. package/commands/configuration-management/api/staging-package-api.js +39 -0
  10. package/commands/configuration-management/api/variable-api.js +36 -0
  11. package/commands/configuration-management/config-command.service.js +1 -61
  12. package/commands/configuration-management/connection-variable.helper.js +30 -0
  13. package/commands/configuration-management/interfaces/single-package-import.interfaces.js +12 -0
  14. package/commands/configuration-management/metadata.service.js +50 -0
  15. package/commands/configuration-management/module.js +76 -19
  16. package/commands/configuration-management/node-diff.service.js +40 -17
  17. package/commands/configuration-management/single-package-import.service.js +111 -0
  18. package/commands/configuration-management/staging-package.service.js +50 -0
  19. package/commands/configuration-management/variable.service.js +6 -7
  20. package/commands/t2tc/api/diff-api.js +40 -0
  21. package/commands/{configuration-management/api/batch-import-export-api.js → t2tc/api/t2tc-package-api.js} +7 -21
  22. package/commands/{configuration-management → t2tc}/diff.service.js +7 -7
  23. package/commands/t2tc/module.js +105 -0
  24. package/commands/{configuration-management → t2tc}/studio.service.js +4 -18
  25. package/commands/t2tc/t2tc-command.service.js +88 -0
  26. package/commands/{configuration-management/batch-import-export.service.js → t2tc/t2tc-package.service.js} +26 -41
  27. package/commands/view/module.js +54 -0
  28. package/commands/view/view-bookmarks-command.service.js +45 -0
  29. package/commands/view/view-bookmarks.manager-factory.js +39 -0
  30. package/commands/view/view-bookmarks.manager.js +60 -0
  31. package/core/utils/branches.js +23 -0
  32. package/core/utils/file-service.js +12 -0
  33. package/lib/commands/asset-registry/asset-registry-api.d.ts +2 -2
  34. package/lib/commands/asset-registry/asset-registry-error.d.ts +3 -0
  35. package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +13 -1
  36. package/lib/commands/asset-registry/asset-registry.service.d.ts +2 -1
  37. package/lib/commands/asset-registry/module.d.ts +1 -1
  38. package/lib/commands/configuration-management/api/metadata-api.d.ts +7 -0
  39. package/lib/commands/configuration-management/api/node-diff-api.d.ts +2 -1
  40. package/lib/commands/configuration-management/api/single-package-import-api.d.ts +8 -0
  41. package/lib/commands/configuration-management/api/staging-package-api.d.ts +7 -0
  42. package/lib/commands/configuration-management/api/variable-api.d.ts +7 -0
  43. package/lib/commands/configuration-management/config-command.service.d.ts +0 -8
  44. package/lib/commands/configuration-management/connection-variable.helper.d.ts +2 -0
  45. package/lib/commands/configuration-management/interfaces/node-diff.interfaces.d.ts +8 -0
  46. package/lib/commands/configuration-management/interfaces/single-package-import.interfaces.d.ts +19 -0
  47. package/lib/commands/configuration-management/metadata.service.d.ts +7 -0
  48. package/lib/commands/configuration-management/module.d.ts +3 -1
  49. package/lib/commands/configuration-management/node-diff.service.d.ts +3 -0
  50. package/lib/commands/configuration-management/single-package-import.service.d.ts +12 -0
  51. package/lib/commands/configuration-management/staging-package.service.d.ts +7 -0
  52. package/lib/commands/configuration-management/variable.service.d.ts +1 -2
  53. package/lib/commands/t2tc/api/diff-api.d.ts +9 -0
  54. package/lib/commands/{configuration-management/api/batch-import-export-api.d.ts → t2tc/api/t2tc-package-api.d.ts} +5 -7
  55. package/lib/commands/{configuration-management → t2tc}/diff.service.d.ts +1 -1
  56. package/lib/commands/t2tc/module.d.ts +10 -0
  57. package/lib/commands/{configuration-management → t2tc}/studio.service.d.ts +1 -3
  58. package/lib/commands/t2tc/t2tc-command.service.d.ts +12 -0
  59. package/lib/commands/{configuration-management/batch-import-export.service.d.ts → t2tc/t2tc-package.service.d.ts} +7 -8
  60. package/lib/commands/view/module.d.ts +11 -0
  61. package/lib/commands/view/view-bookmarks-command.service.d.ts +7 -0
  62. package/lib/commands/view/view-bookmarks.manager-factory.d.ts +8 -0
  63. package/lib/commands/view/view-bookmarks.manager.d.ts +20 -0
  64. package/lib/core/utils/branches.d.ts +4 -0
  65. package/lib/core/utils/file-service.d.ts +1 -0
  66. package/package.json +1 -1
  67. package/lib/commands/configuration-management/api/diff-api.d.ts +0 -9
  68. /package/commands/{configuration-management/interfaces → t2tc}/batch-export-import.constants.js +0 -0
  69. /package/lib/commands/{configuration-management/interfaces → t2tc}/batch-export-import.constants.d.ts +0 -0
@@ -0,0 +1,105 @@
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", "../../core/command/module-handler", "./t2tc-command.service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ const module_handler_1 = require("../../core/command/module-handler");
21
+ const t2tc_command_service_1 = require("./t2tc-command.service");
22
+ class Module extends module_handler_1.IModule {
23
+ register(context, configurator) {
24
+ const t2tcCommand = configurator.command("t2tc")
25
+ .description("Team-to-Team Copy (T2TC) commands for moving whole packages and their dependencies between teams using the batch transport archive format.");
26
+ const t2tcPackageCommand = t2tcCommand.command("package")
27
+ .description("Team-to-Team Copy package commands: list, export, import and diff packages using the batch transport archive.");
28
+ t2tcPackageCommand.command("list")
29
+ .description("List packages in the target team. Part of the Team-to-Team Copy export/import workflow.")
30
+ .option("--json", "Return response as json type", "")
31
+ .option("--flavors <flavors...>", "Lists only packages of the given flavors")
32
+ .option("--withDependencies", "Include dependencies", "")
33
+ .option("--packageKeys <packageKeys...>", "Lists only active versions of given package keys")
34
+ .option("--keysByVersion <keysByVersion...>", "Lists packages by given key and version [packageKey.version]")
35
+ .option("--variableValue <variableValue>", "Variable value for filtering packages by.")
36
+ .option("--variableType <variableType>", "Variable type for filtering packages by.")
37
+ .option("--branches", "Include branches", false)
38
+ .option("--staging", "List staging packages instead", false)
39
+ .action(this.listPackages);
40
+ t2tcPackageCommand.command("export")
41
+ .description("Export one or more packages into a Team-to-Team Copy archive. The archive is consumed by 't2tc package import' / 't2tc package diff'.")
42
+ .option("--packageKeys <packageKeys...>", "Keys of packages to export. Exports the latest deployed version only")
43
+ .option("--keysByVersion <keysByVersion...>", "Keys of packages to export by version")
44
+ .option("--withDependencies", "Include variables and dependencies", "")
45
+ .option("--unzip", "Unzip the exported file", "")
46
+ .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
47
+ .option("--gitBranch <gitBranch>", "Git branch in which you want to push the exported file")
48
+ .action(this.batchExportPackages);
49
+ t2tcPackageCommand.command("import")
50
+ .description("Import packages from a Team-to-Team Copy archive produced by 't2tc package export'. To import a single standalone package, use 'config package import'.")
51
+ .option("--overwrite", "Flag to allow overwriting of packages")
52
+ .option("--validate", "Validate node configurations before import", false)
53
+ .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
54
+ .option("--gitBranch <gitBranch>", "Git branch from which you want to pull the exported file and import")
55
+ .option("-f, --file <file>", "Exported packages file (relative path)")
56
+ .option("-d, --directory <directory>", "Exported packages directory (relative path)")
57
+ .action(this.batchImportPackages);
58
+ t2tcPackageCommand.command("diff")
59
+ .description("Diff a local Team-to-Team Copy archive (from 't2tc package export') against deployed or staging packages.")
60
+ .option("--hasChanges", "Flag to return only the information if the package has changes without the actual changes")
61
+ .option("--baseVersion <version>", "Compare against a given version or STAGING")
62
+ .option("--json", "Return the response as a JSON file")
63
+ .requiredOption("-f, --file <file>", "Exported packages file (relative or absolute path)")
64
+ .action(this.diffPackages);
65
+ }
66
+ listPackages(context, command, options) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ if (options.staging && (options.withDependencies || options.packageKeys || options.keysByVersion || options.variableValue || options.variableType)) {
69
+ throw new Error("Staging parameter is not compatible with --withDependencies, --packageKeys, --keysByVersion, --variableValue, --variableType");
70
+ }
71
+ if (options.packageKeys && options.keysByVersion) {
72
+ throw new Error("Please provide either --packageKeys or --keysByVersion, but not both.");
73
+ }
74
+ yield new t2tc_command_service_1.T2tcCommandService(context).listPackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType, options.branches, options.staging);
75
+ });
76
+ }
77
+ batchExportPackages(context, command, options) {
78
+ var _a;
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ if ((options.packageKeys && options.keysByVersion) || (!options.packageKeys && !options.keysByVersion)) {
81
+ throw new Error("Please provide either --packageKeys or --keysByVersion, but not both.");
82
+ }
83
+ if (options.gitProfile && !options.gitBranch) {
84
+ throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
85
+ }
86
+ options.withDependencies = (_a = options.withDependencies) !== null && _a !== void 0 ? _a : false;
87
+ yield new t2tc_command_service_1.T2tcCommandService(context).batchExportPackages(options.packageKeys, options.keysByVersion, options.withDependencies, options.gitBranch, options.unzip);
88
+ });
89
+ }
90
+ batchImportPackages(context, command, options) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ if (options.gitProfile && !options.gitBranch) {
93
+ throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
94
+ }
95
+ yield new t2tc_command_service_1.T2tcCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch, options.validate);
96
+ });
97
+ }
98
+ diffPackages(context, command, options) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ yield new t2tc_command_service_1.T2tcCommandService(context).diffPackages(options.file, options.hasChanges, options.baseVersion, options.json);
101
+ });
102
+ }
103
+ }
104
+ return Module;
105
+ });
@@ -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", "adm-zip", "../studio/interfaces/package-manager.interfaces", "./interfaces/batch-export-import.constants", "../../core/utils/json", "../studio/api/package-api", "../studio/service/data-model.service", "../studio/api/node-api", "../studio/api/space-api", "../studio/api/studio-variables-api", "../studio/service/space.service", "../studio/service/studio-variable.service"], factory);
16
+ define(["require", "exports", "adm-zip", "../studio/interfaces/package-manager.interfaces", "./batch-export-import.constants", "../../core/utils/json", "../studio/api/package-api", "../studio/service/data-model.service", "../studio/api/node-api", "../studio/api/space-api", "../studio/api/studio-variables-api", "../studio/service/space.service", "../studio/service/studio-variable.service", "../../core/utils/branches"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
21
  exports.StudioService = void 0;
22
22
  const AdmZip = require("adm-zip");
23
23
  const package_manager_interfaces_1 = require("../studio/interfaces/package-manager.interfaces");
24
- const batch_export_import_constants_1 = require("./interfaces/batch-export-import.constants");
24
+ const batch_export_import_constants_1 = require("./batch-export-import.constants");
25
25
  const json_1 = require("../../core/utils/json");
26
26
  const package_api_1 = require("../studio/api/package-api");
27
27
  const data_model_service_1 = require("../studio/service/data-model.service");
@@ -30,6 +30,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
30
30
  const studio_variables_api_1 = require("../studio/api/studio-variables-api");
31
31
  const space_service_1 = require("../studio/service/space.service");
32
32
  const studio_variable_service_1 = require("../studio/service/studio-variable.service");
33
+ const branches_1 = require("../../core/utils/branches");
33
34
  class StudioService {
34
35
  constructor(context) {
35
36
  this.studioPackageApi = new package_api_1.PackageApi(context);
@@ -51,14 +52,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
51
52
  return packagesToExport;
52
53
  });
53
54
  }
54
- fixConnectionVariables(variables) {
55
- return variables.map(variableManifest => (Object.assign(Object.assign({}, variableManifest), { variables: variableManifest.variables.map(variable => {
56
- if (variable.type !== package_manager_interfaces_1.PackageManagerVariableType.CONNECTION) {
57
- return variable;
58
- }
59
- return this.fixConnectionVariable(variable);
60
- }) })));
61
- }
62
55
  getStudioPackageManifests(studioPackageKeys) {
63
56
  return __awaiter(this, void 0, void 0, function* () {
64
57
  return Promise.all(studioPackageKeys.map((packageKey) => __awaiter(this, void 0, void 0, function* () {
@@ -89,7 +82,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
89
82
  }
90
83
  for (const manifest of studioManifests) {
91
84
  const existingPackage = existingStudioPackages.find(existingPackage => existingPackage.key === manifest.packageKey);
92
- if (existingPackage) {
85
+ if (existingPackage && !branches_1.BranchUtils.isBranchPackageKey(existingPackage.key)) {
93
86
  yield this.studioPackageApi.movePackageToSpace(existingPackage.id, manifest.space.id);
94
87
  }
95
88
  yield this.assignRuntimeVariables(manifest);
@@ -115,13 +108,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
115
108
  })) }) : pkg;
116
109
  });
117
110
  }
118
- fixConnectionVariable(variable) {
119
- var _a;
120
- if (!((_a = variable.value) === null || _a === void 0 ? void 0 : _a.appName)) {
121
- return variable;
122
- }
123
- return Object.assign(Object.assign({}, variable), { metadata: Object.assign(Object.assign({}, variable.metadata), { appName: variable.value.appName }) });
124
- }
125
111
  deleteScenarioAssets(packageZip) {
126
112
  packageZip.getEntries().filter(entry => entry.entryName.startsWith(batch_export_import_constants_1.BatchExportImportConstants.NODES_FOLDER_NAME) && entry.entryName.endsWith(batch_export_import_constants_1.BatchExportImportConstants.JSON_EXTENSION))
127
113
  .forEach(entry => {
@@ -0,0 +1,88 @@
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", "../../core/utils/file-service", "./t2tc-package.service", "./diff.service", "../configuration-management/staging-package.service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.T2tcCommandService = void 0;
22
+ const file_service_1 = require("../../core/utils/file-service");
23
+ const t2tc_package_service_1 = require("./t2tc-package.service");
24
+ const diff_service_1 = require("./diff.service");
25
+ const staging_package_service_1 = require("../configuration-management/staging-package.service");
26
+ class T2tcCommandService {
27
+ constructor(context) {
28
+ this.t2tcPackageService = new t2tc_package_service_1.T2tcPackageService(context);
29
+ this.diffService = new diff_service_1.DiffService(context);
30
+ this.stagingPackageService = new staging_package_service_1.StagingPackageService(context);
31
+ }
32
+ listPackages(jsonResponse, flavors, withDependencies, packageKeys, keysByVersion, variableValue, variableType, includeBranches, staging) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if (staging) {
35
+ yield this.stagingPackageService.listStagingPackages(flavors !== null && flavors !== void 0 ? flavors : [], includeBranches, jsonResponse);
36
+ }
37
+ else if (variableValue) {
38
+ yield this.listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType, includeBranches);
39
+ }
40
+ else if (jsonResponse) {
41
+ yield this.t2tcPackageService.findAndExportListOfPackages(flavors !== null && flavors !== void 0 ? flavors : [], packageKeys !== null && packageKeys !== void 0 ? packageKeys : [], keysByVersion !== null && keysByVersion !== void 0 ? keysByVersion : [], withDependencies, includeBranches);
42
+ }
43
+ else if (keysByVersion) {
44
+ yield this.t2tcPackageService.listPackagesByKeysWithVersion(keysByVersion, withDependencies);
45
+ }
46
+ else {
47
+ yield this.t2tcPackageService.listActivePackages(flavors !== null && flavors !== void 0 ? flavors : [], includeBranches);
48
+ }
49
+ });
50
+ }
51
+ batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch, unzip) {
52
+ return this.t2tcPackageService.batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch, unzip);
53
+ }
54
+ batchImportPackages(file, directory, overwrite, gitBranch, performValidation = false) {
55
+ if ((directory || file) && gitBranch) {
56
+ throw new Error("You cannot use both file/directory and gitBranch options at the same time. Only one import source can be defined.");
57
+ }
58
+ if (!directory && !file && !gitBranch) {
59
+ throw new Error("You must provide either a file/directory or a gitBranch option to import packages.");
60
+ }
61
+ if (file && directory) {
62
+ throw new Error("You cannot use both file and directory options at the same time. Only one import source can be defined.");
63
+ }
64
+ if (file && file_service_1.fileService.isDirectory(file)) {
65
+ throw new Error("The file option accepts only zip files.");
66
+ }
67
+ if (directory && !file_service_1.fileService.isDirectory(directory)) {
68
+ throw new Error("The directory option accepts only directories.");
69
+ }
70
+ const sourcePath = file !== null && file !== void 0 ? file : directory;
71
+ return this.t2tcPackageService.batchImportPackages(sourcePath, overwrite, gitBranch, performValidation);
72
+ }
73
+ diffPackages(file, hasChanges, baseVersion, jsonResponse) {
74
+ return this.diffService.diffPackages(file, hasChanges, baseVersion, jsonResponse);
75
+ }
76
+ listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType, includeBranches) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ if (jsonResponse) {
79
+ yield this.t2tcPackageService.findAndExportListOfActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType, includeBranches);
80
+ }
81
+ else {
82
+ yield this.t2tcPackageService.listActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType, includeBranches);
83
+ }
84
+ });
85
+ }
86
+ }
87
+ exports.T2tcCommandService = T2tcCommandService;
88
+ });
@@ -13,52 +13,55 @@ 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", "uuid", "form-data", "stream", "adm-zip", "./interfaces/batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/batch-import-export-api", "./studio.service", "../../core/git-profile/git/git.service", "fs", "../../core/utils/file.constants"], factory);
16
+ define(["require", "exports", "uuid", "form-data", "stream", "adm-zip", "./batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/t2tc-package-api", "../configuration-management/api/variable-api", "../configuration-management/connection-variable.helper", "./studio.service", "../../core/git-profile/git/git.service", "fs", "../../core/utils/file.constants"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.BatchImportExportService = void 0;
21
+ exports.T2tcPackageService = void 0;
22
22
  const uuid_1 = require("uuid");
23
23
  const FormData = require("form-data");
24
24
  const stream_1 = require("stream");
25
25
  const AdmZip = require("adm-zip");
26
- const batch_export_import_constants_1 = require("./interfaces/batch-export-import.constants");
26
+ const batch_export_import_constants_1 = require("./batch-export-import.constants");
27
27
  const file_service_1 = require("../../core/utils/file-service");
28
28
  const logger_1 = require("../../core/utils/logger");
29
29
  const json_1 = require("../../core/utils/json");
30
30
  const package_api_1 = require("../studio/api/package-api");
31
- const batch_import_export_api_1 = require("./api/batch-import-export-api");
31
+ const t2tc_package_api_1 = require("./api/t2tc-package-api");
32
+ const variable_api_1 = require("../configuration-management/api/variable-api");
33
+ const connection_variable_helper_1 = require("../configuration-management/connection-variable.helper");
32
34
  const studio_service_1 = require("./studio.service");
33
35
  const git_service_1 = require("../../core/git-profile/git/git.service");
34
36
  const fs = require("fs");
35
37
  const file_constants_1 = require("../../core/utils/file.constants");
36
- class BatchImportExportService {
38
+ class T2tcPackageService {
37
39
  constructor(context) {
38
- this.batchImportExportApi = new batch_import_export_api_1.BatchImportExportApi(context);
40
+ this.t2tcPackageApi = new t2tc_package_api_1.T2tcPackageApi(context);
41
+ this.variableApi = new variable_api_1.VariableApi(context);
39
42
  this.studioPackageApi = new package_api_1.PackageApi(context);
40
43
  this.studioService = new studio_service_1.StudioService(context);
41
44
  this.gitService = new git_service_1.GitService(context);
42
45
  }
43
- listActivePackages(flavors) {
46
+ listActivePackages(flavors, includeBranches) {
44
47
  return __awaiter(this, void 0, void 0, function* () {
45
- const activePackages = yield this.batchImportExportApi.findAllActivePackages(flavors);
48
+ const activePackages = yield this.t2tcPackageApi.findAllActivePackages(flavors, false, includeBranches);
46
49
  activePackages.forEach(pkg => {
47
50
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
48
51
  });
49
52
  });
50
53
  }
51
- findAndExportListOfPackages(flavors, packageKeys, keysByVersion, withDependencies) {
54
+ findAndExportListOfPackages(flavors, packageKeys, keysByVersion, withDependencies, includeBranches) {
52
55
  return __awaiter(this, void 0, void 0, function* () {
53
56
  let packagesToExport;
54
57
  if (keysByVersion.length) {
55
- packagesToExport = yield this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
58
+ packagesToExport = yield this.t2tcPackageApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
56
59
  }
57
60
  else if (packageKeys.length) {
58
- packagesToExport = yield this.batchImportExportApi.findActivePackagesByKeys(packageKeys, withDependencies);
61
+ packagesToExport = yield this.t2tcPackageApi.findActivePackagesByKeys(packageKeys, withDependencies);
59
62
  }
60
63
  else {
61
- packagesToExport = yield this.batchImportExportApi.findAllActivePackages(flavors, withDependencies);
64
+ packagesToExport = yield this.t2tcPackageApi.findAllActivePackages(flavors, withDependencies, includeBranches);
62
65
  }
63
66
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, withDependencies);
64
67
  this.exportListOfPackages(packagesToExport);
@@ -66,7 +69,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
66
69
  }
67
70
  listPackagesByKeysWithVersion(keysByVersion, withDependencies) {
68
71
  return __awaiter(this, void 0, void 0, function* () {
69
- const exportedPackages = yield this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
72
+ const exportedPackages = yield this.t2tcPackageApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
70
73
  exportedPackages.forEach(pkg => {
71
74
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
72
75
  });
@@ -76,16 +79,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
76
79
  return __awaiter(this, void 0, void 0, function* () {
77
80
  let exportedPackagesData;
78
81
  if (packageKeys) {
79
- exportedPackagesData = yield this.batchImportExportApi.exportPackages(packageKeys, withDependencies);
82
+ exportedPackagesData = yield this.t2tcPackageApi.exportPackages(packageKeys, withDependencies);
80
83
  }
81
84
  else {
82
- exportedPackagesData = yield this.batchImportExportApi.exportPackagesByVersions(packageKeysByVersion, withDependencies);
85
+ exportedPackagesData = yield this.t2tcPackageApi.exportPackagesByVersions(packageKeysByVersion, withDependencies);
83
86
  }
84
87
  const exportedPackagesZip = new AdmZip(exportedPackagesData);
85
88
  const manifest = (0, json_1.parse)(exportedPackagesZip.getEntry(batch_export_import_constants_1.BatchExportImportConstants.MANIFEST_FILE_NAME).getData().toString());
86
89
  const versionsByPackageKey = this.getVersionsByPackageKey(manifest);
87
90
  let exportedVariables = yield this.getVersionedVariablesForPackagesWithKeys(versionsByPackageKey);
88
- exportedVariables = this.studioService.fixConnectionVariables(exportedVariables);
91
+ exportedVariables = (0, connection_variable_helper_1.fixConnectionVariables)(exportedVariables);
89
92
  exportedPackagesZip.addFile(batch_export_import_constants_1.BatchExportImportConstants.VARIABLES_FILE_NAME, Buffer.from((0, json_1.stringify)(exportedVariables), "utf8"), "", file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS);
90
93
  const studioPackageKeys = manifest.filter(packageManifest => packageManifest.flavor === batch_export_import_constants_1.BatchExportImportConstants.STUDIO)
91
94
  .map(packageManifest => packageManifest.packageKey);
@@ -112,19 +115,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
112
115
  }
113
116
  });
114
117
  }
115
- batchExportPackagesMetadata(packageKeys, jsonResponse) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const exportedPackagesMetadata = yield this.batchImportExportApi.batchExportPackagesMetadata(packageKeys);
118
- if (jsonResponse) {
119
- this.exportListOfPackagesMetadata(exportedPackagesMetadata);
120
- }
121
- else {
122
- exportedPackagesMetadata.forEach(pkg => {
123
- logger_1.logger.info(`${pkg.key} - Has Unpublished Changes: ${pkg.hasUnpublishedChanges}`);
124
- });
125
- }
126
- });
127
- }
128
118
  batchImportPackages(sourcePath, overwrite, gitBranch, performValidation = false) {
129
119
  return __awaiter(this, void 0, void 0, function* () {
130
120
  let sourceToBeImported;
@@ -145,7 +135,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
145
135
  configs = yield this.studioService.mapSpaces(configs, studioManifests);
146
136
  const existingStudioPackages = yield this.studioPackageApi.findAllPackages();
147
137
  const formData = this.buildBodyForImport(configs, sourceToBeImported, variablesManifests);
148
- const postPackageImportData = yield this.batchImportExportApi.importPackages(formData, overwrite, performValidation);
138
+ const postPackageImportData = yield this.t2tcPackageApi.importPackages(formData, overwrite, performValidation);
149
139
  yield this.studioService.processImportedPackages(configs, existingStudioPackages, studioManifests);
150
140
  if (gitBranch) {
151
141
  fs.rmSync(temporaryGitFolder, { recursive: true });
@@ -156,16 +146,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
156
146
  logger_1.logger.info("Config import report file: " + reportFileName);
157
147
  });
158
148
  }
159
- findAndExportListOfActivePackagesByVariableValue(flavors, variableValue, variableType) {
149
+ findAndExportListOfActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
160
150
  return __awaiter(this, void 0, void 0, function* () {
161
- let packagesToExport = yield this.batchImportExportApi.findActivePackagesByVariableValue(flavors, variableValue, variableType);
151
+ let packagesToExport = yield this.t2tcPackageApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
162
152
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, false);
163
153
  this.exportListOfPackages(packagesToExport);
164
154
  });
165
155
  }
166
- listActivePackagesByVariableValue(flavors, variableValue, variableType) {
156
+ listActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
167
157
  return __awaiter(this, void 0, void 0, function* () {
168
- const packagesByVariableValue = yield this.batchImportExportApi.findActivePackagesByVariableValue(flavors, variableValue, variableType);
158
+ const packagesByVariableValue = yield this.t2tcPackageApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
169
159
  packagesByVariableValue.forEach(pkg => {
170
160
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
171
161
  });
@@ -193,12 +183,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
193
183
  });
194
184
  });
195
185
  });
196
- return this.batchImportExportApi.findVariablesWithValuesByPackageKeysAndVersion(variableExportRequest);
197
- }
198
- exportListOfPackagesMetadata(packagesMetadata) {
199
- const filename = (0, uuid_1.v4)() + ".json";
200
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packagesMetadata), filename);
201
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
186
+ return this.variableApi.findVariablesWithValuesByPackageKeysAndVersion(variableExportRequest);
202
187
  }
203
188
  buildBodyForImport(configs, sourcePath, variablesManifests) {
204
189
  const formData = new FormData();
@@ -249,5 +234,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
249
234
  }
250
235
  }
251
236
  }
252
- exports.BatchImportExportService = BatchImportExportService;
237
+ exports.T2tcPackageService = T2tcPackageService;
253
238
  });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Commands related to the View feature.
3
+ */
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ (function (factory) {
14
+ if (typeof module === "object" && typeof module.exports === "object") {
15
+ var v = factory(require, exports);
16
+ if (v !== undefined) module.exports = v;
17
+ }
18
+ else if (typeof define === "function" && define.amd) {
19
+ define(["require", "exports", "../../core/command/module-handler", "./view-bookmarks-command.service"], factory);
20
+ }
21
+ })(function (require, exports) {
22
+ "use strict";
23
+ const module_handler_1 = require("../../core/command/module-handler");
24
+ const view_bookmarks_command_service_1 = require("./view-bookmarks-command.service");
25
+ class Module extends module_handler_1.IModule {
26
+ register(context, configurator) {
27
+ const pullCommand = configurator.command("pull");
28
+ pullCommand
29
+ .command("view-bookmarks")
30
+ .description("Command to pull view bookmarks")
31
+ .option("--type <type>", "Type of view bookmarks to pull: USER (default), SHARED, or ALL")
32
+ .requiredOption("--id <id>", "ID of the view (board) to pull bookmarks from")
33
+ .action(this.pullViewBookmarks);
34
+ const pushCommand = configurator.command("push");
35
+ pushCommand
36
+ .command("view-bookmarks")
37
+ .description("Command to push view bookmarks to a board")
38
+ .requiredOption("--id <id>", "ID of the view (board) to push bookmarks into")
39
+ .requiredOption("-f, --file <file>", "The file to push")
40
+ .action(this.pushViewBookmarks);
41
+ }
42
+ pullViewBookmarks(context, command, options) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ yield new view_bookmarks_command_service_1.ViewBookmarksCommandService(context).pullViewBookmarks(options.id, options.type);
45
+ });
46
+ }
47
+ pushViewBookmarks(context, command, options) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ yield new view_bookmarks_command_service_1.ViewBookmarksCommandService(context).pushViewBookmarks(options.id, options.file);
50
+ });
51
+ }
52
+ }
53
+ return Module;
54
+ });
@@ -0,0 +1,45 @@
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", "./view-bookmarks.manager-factory", "../../core/utils/logger"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ViewBookmarksCommandService = void 0;
22
+ const view_bookmarks_manager_factory_1 = require("./view-bookmarks.manager-factory");
23
+ const logger_1 = require("../../core/utils/logger");
24
+ const ALLOWED_VIEW_BOOKMARK_TYPES = ["USER", "SHARED", "ALL"];
25
+ class ViewBookmarksCommandService {
26
+ constructor(context) {
27
+ this.viewBookmarksManagerFactory = new view_bookmarks_manager_factory_1.ViewBookmarksManagerFactory(context);
28
+ }
29
+ pullViewBookmarks(boardId, type) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ if (type !== undefined && !ALLOWED_VIEW_BOOKMARK_TYPES.includes(type.toUpperCase())) {
32
+ logger_1.logger.error(new logger_1.FatalError(`Invalid type "${type}". Allowed values are: ${ALLOWED_VIEW_BOOKMARK_TYPES.join(", ")}.`));
33
+ return;
34
+ }
35
+ yield this.viewBookmarksManagerFactory.createViewBookmarksManager(null, boardId, type).pull();
36
+ });
37
+ }
38
+ pushViewBookmarks(boardId, filename) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield this.viewBookmarksManagerFactory.createViewBookmarksManager(filename, boardId).push();
41
+ });
42
+ }
43
+ }
44
+ exports.ViewBookmarksCommandService = ViewBookmarksCommandService;
45
+ });
@@ -0,0 +1,39 @@
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", "node:fs", "node:path", "./view-bookmarks.manager", "../../core/utils/logger"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ViewBookmarksManagerFactory = void 0;
13
+ const fs = require("node:fs");
14
+ const path = require("node:path");
15
+ const view_bookmarks_manager_1 = require("./view-bookmarks.manager");
16
+ const logger_1 = require("../../core/utils/logger");
17
+ class ViewBookmarksManagerFactory {
18
+ constructor(context) {
19
+ this.context = context;
20
+ }
21
+ createViewBookmarksManager(filename, boardId, type) {
22
+ const viewBookmarksManager = new view_bookmarks_manager_1.ViewBookmarksManager(this.context);
23
+ viewBookmarksManager.boardId = boardId;
24
+ type = (type !== null && type !== void 0 ? type : "USER").toUpperCase();
25
+ viewBookmarksManager.type = type;
26
+ if (filename !== null) {
27
+ viewBookmarksManager.filePath = this.resolveFilePath(filename);
28
+ }
29
+ return viewBookmarksManager;
30
+ }
31
+ resolveFilePath(fileName) {
32
+ if (!fs.existsSync(path.resolve(process.cwd(), fileName))) {
33
+ logger_1.logger.error(new logger_1.FatalError("The provided file does not exist"));
34
+ }
35
+ return path.resolve(process.cwd(), fileName);
36
+ }
37
+ }
38
+ exports.ViewBookmarksManagerFactory = ViewBookmarksManagerFactory;
39
+ });
@@ -0,0 +1,60 @@
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", "node:fs", "form-data", "../../core/http/http-shared/base.manager"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ViewBookmarksManager = void 0;
13
+ const fs = require("node:fs");
14
+ const FormData = require("form-data");
15
+ const base_manager_1 = require("../../core/http/http-shared/base.manager");
16
+ class ViewBookmarksManager extends base_manager_1.BaseManager {
17
+ constructor(context) {
18
+ super(context);
19
+ }
20
+ get filePath() {
21
+ return this._filePath;
22
+ }
23
+ set filePath(value) {
24
+ this._filePath = value;
25
+ }
26
+ get boardId() {
27
+ return this._boardId;
28
+ }
29
+ set boardId(value) {
30
+ this._boardId = value;
31
+ }
32
+ get type() {
33
+ return this._type;
34
+ }
35
+ set type(value) {
36
+ this._type = value;
37
+ }
38
+ getConfig() {
39
+ return {
40
+ pushUrl: `${ViewBookmarksManager.BASE_URL}/import?boardId=${encodeURIComponent(this.boardId)}`,
41
+ pullUrl: `${ViewBookmarksManager.BASE_URL}/export?boardId=${encodeURIComponent(this.boardId)}&type=${encodeURIComponent(this.type)}`,
42
+ exportFileName: `${ViewBookmarksManager.VIEW_BOOKMARKS_FILE_PREFIX}${this.boardId}.json`,
43
+ onPushSuccessMessage: () => {
44
+ return "View Bookmarks were pushed successfully.";
45
+ },
46
+ };
47
+ }
48
+ getBody() {
49
+ const formData = new FormData();
50
+ formData.append("file", fs.createReadStream(this.filePath));
51
+ return formData;
52
+ }
53
+ getSerializedFileContent(data) {
54
+ return JSON.stringify(data);
55
+ }
56
+ }
57
+ exports.ViewBookmarksManager = ViewBookmarksManager;
58
+ ViewBookmarksManager.BASE_URL = "/blueprint/api/bookmarks";
59
+ ViewBookmarksManager.VIEW_BOOKMARKS_FILE_PREFIX = "studio_view_bookmarks_";
60
+ });