@celonis/content-cli 1.11.0 → 1.13.1

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 (71) hide show
  1. package/commands/action-flows/action-flow/action-flow.service.js +4 -2
  2. package/commands/asset-registry/asset-registry-api.js +33 -7
  3. package/commands/asset-registry/asset-registry.service.js +25 -3
  4. package/commands/asset-registry/module.js +15 -0
  5. package/commands/configuration-management/api/metadata-api.js +38 -0
  6. package/commands/configuration-management/api/single-package-export-api.js +38 -0
  7. package/commands/configuration-management/api/{diff-api.js → single-package-import-api.js} +5 -10
  8. package/commands/configuration-management/api/staging-package-api.js +39 -0
  9. package/commands/configuration-management/api/variable-api.js +36 -0
  10. package/commands/configuration-management/config-command.service.js +1 -63
  11. package/commands/configuration-management/connection-variable.helper.js +30 -0
  12. package/commands/configuration-management/interfaces/single-package-import.interfaces.js +12 -0
  13. package/commands/configuration-management/metadata.service.js +50 -0
  14. package/commands/configuration-management/module.js +80 -16
  15. package/commands/configuration-management/single-package-export.service.js +64 -0
  16. package/commands/configuration-management/single-package-import.service.js +131 -0
  17. package/commands/configuration-management/staging-package.service.js +50 -0
  18. package/commands/configuration-management/variable.service.js +18 -21
  19. package/commands/studio/manager/package.manager.js +1 -1
  20. package/commands/studio/module.js +8 -4
  21. package/commands/t2tc/api/diff-api.js +40 -0
  22. package/commands/{configuration-management/api/batch-import-export-api.js → t2tc/api/t2tc-package-api.js} +3 -29
  23. package/commands/{configuration-management → t2tc}/diff.service.js +7 -7
  24. package/commands/t2tc/module.js +105 -0
  25. package/commands/{configuration-management → t2tc}/studio.service.js +2 -17
  26. package/commands/t2tc/t2tc-command.service.js +88 -0
  27. package/commands/{configuration-management/batch-import-export.service.js → t2tc/t2tc-package.service.js} +26 -52
  28. package/commands/view/module.js +54 -0
  29. package/commands/view/view-bookmarks-command.service.js +45 -0
  30. package/commands/view/view-bookmarks.manager-factory.js +39 -0
  31. package/commands/view/view-bookmarks.manager.js +60 -0
  32. package/content-cli.js +61 -35
  33. package/core/command/module-handler.js +5 -0
  34. package/core/utils/file-service.js +45 -16
  35. package/core/utils/path.js +17 -0
  36. package/lib/commands/asset-registry/asset-registry-api.d.ts +5 -0
  37. package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +5 -0
  38. package/lib/commands/asset-registry/asset-registry.service.d.ts +3 -1
  39. package/lib/commands/asset-registry/module.d.ts +1 -0
  40. package/lib/commands/configuration-management/api/metadata-api.d.ts +7 -0
  41. package/lib/commands/configuration-management/api/single-package-export-api.d.ts +7 -0
  42. package/lib/commands/configuration-management/api/single-package-import-api.d.ts +8 -0
  43. package/lib/commands/configuration-management/api/staging-package-api.d.ts +7 -0
  44. package/lib/commands/configuration-management/api/variable-api.d.ts +7 -0
  45. package/lib/commands/configuration-management/config-command.service.d.ts +0 -8
  46. package/lib/commands/configuration-management/connection-variable.helper.d.ts +2 -0
  47. package/lib/commands/configuration-management/interfaces/single-package-import.interfaces.d.ts +19 -0
  48. package/lib/commands/configuration-management/metadata.service.d.ts +7 -0
  49. package/lib/commands/configuration-management/module.d.ts +4 -1
  50. package/lib/commands/configuration-management/single-package-export.service.d.ts +8 -0
  51. package/lib/commands/configuration-management/single-package-import.service.d.ts +13 -0
  52. package/lib/commands/configuration-management/staging-package.service.d.ts +7 -0
  53. package/lib/commands/configuration-management/variable.service.d.ts +1 -2
  54. package/lib/commands/t2tc/api/diff-api.d.ts +9 -0
  55. package/lib/commands/{configuration-management/api/batch-import-export-api.d.ts → t2tc/api/t2tc-package-api.d.ts} +3 -6
  56. package/lib/commands/{configuration-management → t2tc}/diff.service.d.ts +1 -1
  57. package/lib/commands/t2tc/module.d.ts +10 -0
  58. package/lib/commands/{configuration-management → t2tc}/studio.service.d.ts +1 -3
  59. package/lib/commands/t2tc/t2tc-command.service.d.ts +12 -0
  60. package/lib/commands/{configuration-management/batch-import-export.service.d.ts → t2tc/t2tc-package.service.d.ts} +3 -5
  61. package/lib/commands/view/module.d.ts +11 -0
  62. package/lib/commands/view/view-bookmarks-command.service.d.ts +7 -0
  63. package/lib/commands/view/view-bookmarks.manager-factory.d.ts +8 -0
  64. package/lib/commands/view/view-bookmarks.manager.d.ts +20 -0
  65. package/lib/content-cli.d.ts +15 -1
  66. package/lib/core/utils/file-service.d.ts +8 -1
  67. package/lib/core/utils/path.d.ts +1 -0
  68. package/package.json +4 -4
  69. package/lib/commands/configuration-management/api/diff-api.d.ts +0 -9
  70. /package/commands/{configuration-management/interfaces → t2tc}/batch-export-import.constants.js +0 -0
  71. /package/lib/commands/{configuration-management/interfaces → t2tc}/batch-export-import.constants.d.ts +0 -0
@@ -18,9 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.BatchImportExportApi = void 0;
21
+ exports.T2tcPackageApi = void 0;
22
22
  const logger_1 = require("../../../core/utils/logger");
23
- class BatchImportExportApi {
23
+ class T2tcPackageApi {
24
24
  constructor(context) {
25
25
  this.httpClient = () => context.httpClient;
26
26
  }
@@ -35,16 +35,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
35
35
  });
36
36
  });
37
37
  }
38
- findAllStagingPackages(flavors, includeBranches = false) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const queryParams = new URLSearchParams();
41
- queryParams.set("includeBranches", includeBranches.toString());
42
- flavors.forEach(flavor => queryParams.append("flavors", flavor));
43
- return this.httpClient().get(`/pacman/api/core/staging/packages/export/list?${queryParams.toString()}`).catch(e => {
44
- throw new logger_1.FatalError(`Problem getting staging packages: ${e}`);
45
- });
46
- });
47
- }
48
38
  findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches = false) {
49
39
  return __awaiter(this, void 0, void 0, function* () {
50
40
  const queryParams = new URLSearchParams();
@@ -99,27 +89,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
99
89
  });
100
90
  });
101
91
  }
102
- batchExportPackagesMetadata(packageKeys) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const queryParams = new URLSearchParams();
105
- packageKeys.forEach(packageKey => queryParams.append("packageKeys", packageKey));
106
- return this.httpClient().get(`/package-manager/api/core/packages/metadata/export?${queryParams.toString()}`).catch(e => {
107
- throw new logger_1.FatalError(`Problem exporting packages metadata: ${e}`);
108
- });
109
- });
110
- }
111
92
  importPackages(data, overwrite, performValidation) {
112
93
  return __awaiter(this, void 0, void 0, function* () {
113
94
  return this.httpClient().postFile("/package-manager/api/core/packages/import/batch", data, { overwrite, performValidation });
114
95
  });
115
96
  }
116
- findVariablesWithValuesByPackageKeysAndVersion(packagesByKeyAndVersion) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- return this.httpClient().post("/package-manager/api/core/packages/export/batch/variables-with-assignments", packagesByKeyAndVersion).catch(e => {
119
- throw new logger_1.FatalError(`Problem exporting package variables: ${e}`);
120
- });
121
- });
122
- }
123
97
  }
124
- exports.BatchImportExportApi = BatchImportExportApi;
98
+ exports.T2tcPackageApi = T2tcPackageApi;
125
99
  });
@@ -30,21 +30,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
30
30
  constructor(context) {
31
31
  this.diffApi = new diff_api_1.DiffApi(context);
32
32
  }
33
- diffPackages(file, hasChanges, jsonResponse) {
33
+ diffPackages(file, hasChanges, baseVersion, jsonResponse) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  if (hasChanges) {
36
- yield this.hasChanges(file, jsonResponse);
36
+ yield this.hasChanges(baseVersion, file, jsonResponse);
37
37
  }
38
38
  else {
39
- yield this.diffPackagesAndReturnDiff(file, jsonResponse);
39
+ yield this.diffPackagesAndReturnDiff(baseVersion, file, jsonResponse);
40
40
  }
41
41
  });
42
42
  }
43
- hasChanges(file, jsonResponse) {
43
+ hasChanges(baseVersion, file, jsonResponse) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const packages = new AdmZip(file);
46
46
  const formData = this.buildBodyForDiff(packages);
47
- const returnedHasChangesData = yield this.diffApi.hasChanges(formData);
47
+ const returnedHasChangesData = yield this.diffApi.hasChanges(baseVersion, formData);
48
48
  if (jsonResponse) {
49
49
  this.exportListOfPackageDiffMetadata(returnedHasChangesData);
50
50
  }
@@ -53,11 +53,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
53
53
  }
54
54
  });
55
55
  }
56
- diffPackagesAndReturnDiff(file, jsonResponse) {
56
+ diffPackagesAndReturnDiff(baseVersion, file, jsonResponse) {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  const packages = new AdmZip(file);
59
59
  const formData = this.buildBodyForDiff(packages);
60
- const returnedHasChangesData = yield this.diffApi.diffPackages(formData);
60
+ const returnedHasChangesData = yield this.diffApi.diffPackages(baseVersion, formData);
61
61
  if (jsonResponse) {
62
62
  this.exportListOfPackageDiffs(returnedHasChangesData);
63
63
  }
@@ -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'. To export a single standalone package, use 'config package export'.")
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", "../../core/utils/branches"], 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");
@@ -52,14 +52,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
52
52
  return packagesToExport;
53
53
  });
54
54
  }
55
- fixConnectionVariables(variables) {
56
- return variables.map(variableManifest => (Object.assign(Object.assign({}, variableManifest), { variables: variableManifest.variables.map(variable => {
57
- if (variable.type !== package_manager_interfaces_1.PackageManagerVariableType.CONNECTION) {
58
- return variable;
59
- }
60
- return this.fixConnectionVariable(variable);
61
- }) })));
62
- }
63
55
  getStudioPackageManifests(studioPackageKeys) {
64
56
  return __awaiter(this, void 0, void 0, function* () {
65
57
  return Promise.all(studioPackageKeys.map((packageKey) => __awaiter(this, void 0, void 0, function* () {
@@ -116,13 +108,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
116
108
  })) }) : pkg;
117
109
  });
118
110
  }
119
- fixConnectionVariable(variable) {
120
- var _a;
121
- if (!((_a = variable.value) === null || _a === void 0 ? void 0 : _a.appName)) {
122
- return variable;
123
- }
124
- return Object.assign(Object.assign({}, variable), { metadata: Object.assign(Object.assign({}, variable.metadata), { appName: variable.value.appName }) });
125
- }
126
111
  deleteScenarioAssets(packageZip) {
127
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))
128
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,65 +13,56 @@ 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", "node:path"], 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
+ const node_path_1 = require("node:path");
39
+ class T2tcPackageService {
37
40
  constructor(context) {
38
- this.batchImportExportApi = new batch_import_export_api_1.BatchImportExportApi(context);
41
+ this.t2tcPackageApi = new t2tc_package_api_1.T2tcPackageApi(context);
42
+ this.variableApi = new variable_api_1.VariableApi(context);
39
43
  this.studioPackageApi = new package_api_1.PackageApi(context);
40
44
  this.studioService = new studio_service_1.StudioService(context);
41
45
  this.gitService = new git_service_1.GitService(context);
42
46
  }
43
47
  listActivePackages(flavors, includeBranches) {
44
48
  return __awaiter(this, void 0, void 0, function* () {
45
- const activePackages = yield this.batchImportExportApi.findAllActivePackages(flavors, false, includeBranches);
49
+ const activePackages = yield this.t2tcPackageApi.findAllActivePackages(flavors, false, includeBranches);
46
50
  activePackages.forEach(pkg => {
47
51
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
48
52
  });
49
53
  });
50
54
  }
51
- listStagingPackages(flavors, includeBranches, jsonResponse) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const stagingPackages = yield this.batchImportExportApi.findAllStagingPackages(flavors, includeBranches);
54
- if (jsonResponse) {
55
- this.exportListOfPackages(stagingPackages);
56
- }
57
- else {
58
- stagingPackages.forEach(pkg => {
59
- logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
60
- });
61
- }
62
- });
63
- }
64
55
  findAndExportListOfPackages(flavors, packageKeys, keysByVersion, withDependencies, includeBranches) {
65
56
  return __awaiter(this, void 0, void 0, function* () {
66
57
  let packagesToExport;
67
58
  if (keysByVersion.length) {
68
- packagesToExport = yield this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
59
+ packagesToExport = yield this.t2tcPackageApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
69
60
  }
70
61
  else if (packageKeys.length) {
71
- packagesToExport = yield this.batchImportExportApi.findActivePackagesByKeys(packageKeys, withDependencies);
62
+ packagesToExport = yield this.t2tcPackageApi.findActivePackagesByKeys(packageKeys, withDependencies);
72
63
  }
73
64
  else {
74
- packagesToExport = yield this.batchImportExportApi.findAllActivePackages(flavors, withDependencies, includeBranches);
65
+ packagesToExport = yield this.t2tcPackageApi.findAllActivePackages(flavors, withDependencies, includeBranches);
75
66
  }
76
67
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, withDependencies);
77
68
  this.exportListOfPackages(packagesToExport);
@@ -79,7 +70,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
79
70
  }
80
71
  listPackagesByKeysWithVersion(keysByVersion, withDependencies) {
81
72
  return __awaiter(this, void 0, void 0, function* () {
82
- const exportedPackages = yield this.batchImportExportApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
73
+ const exportedPackages = yield this.t2tcPackageApi.findPackagesByKeysAndVersion(keysByVersion, withDependencies);
83
74
  exportedPackages.forEach(pkg => {
84
75
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
85
76
  });
@@ -89,16 +80,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
89
80
  return __awaiter(this, void 0, void 0, function* () {
90
81
  let exportedPackagesData;
91
82
  if (packageKeys) {
92
- exportedPackagesData = yield this.batchImportExportApi.exportPackages(packageKeys, withDependencies);
83
+ exportedPackagesData = yield this.t2tcPackageApi.exportPackages(packageKeys, withDependencies);
93
84
  }
94
85
  else {
95
- exportedPackagesData = yield this.batchImportExportApi.exportPackagesByVersions(packageKeysByVersion, withDependencies);
86
+ exportedPackagesData = yield this.t2tcPackageApi.exportPackagesByVersions(packageKeysByVersion, withDependencies);
96
87
  }
97
88
  const exportedPackagesZip = new AdmZip(exportedPackagesData);
98
89
  const manifest = (0, json_1.parse)(exportedPackagesZip.getEntry(batch_export_import_constants_1.BatchExportImportConstants.MANIFEST_FILE_NAME).getData().toString());
99
90
  const versionsByPackageKey = this.getVersionsByPackageKey(manifest);
100
91
  let exportedVariables = yield this.getVersionedVariablesForPackagesWithKeys(versionsByPackageKey);
101
- exportedVariables = this.studioService.fixConnectionVariables(exportedVariables);
92
+ exportedVariables = (0, connection_variable_helper_1.fixConnectionVariables)(exportedVariables);
102
93
  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);
103
94
  const studioPackageKeys = manifest.filter(packageManifest => packageManifest.flavor === batch_export_import_constants_1.BatchExportImportConstants.STUDIO)
104
95
  .map(packageManifest => packageManifest.packageKey);
@@ -125,19 +116,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
125
116
  }
126
117
  });
127
118
  }
128
- batchExportPackagesMetadata(packageKeys, jsonResponse) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- const exportedPackagesMetadata = yield this.batchImportExportApi.batchExportPackagesMetadata(packageKeys);
131
- if (jsonResponse) {
132
- this.exportListOfPackagesMetadata(exportedPackagesMetadata);
133
- }
134
- else {
135
- exportedPackagesMetadata.forEach(pkg => {
136
- logger_1.logger.info(`${pkg.key} - Has Unpublished Changes: ${pkg.hasUnpublishedChanges}`);
137
- });
138
- }
139
- });
140
- }
141
119
  batchImportPackages(sourcePath, overwrite, gitBranch, performValidation = false) {
142
120
  return __awaiter(this, void 0, void 0, function* () {
143
121
  let sourceToBeImported;
@@ -158,10 +136,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
158
136
  configs = yield this.studioService.mapSpaces(configs, studioManifests);
159
137
  const existingStudioPackages = yield this.studioPackageApi.findAllPackages();
160
138
  const formData = this.buildBodyForImport(configs, sourceToBeImported, variablesManifests);
161
- const postPackageImportData = yield this.batchImportExportApi.importPackages(formData, overwrite, performValidation);
139
+ const postPackageImportData = yield this.t2tcPackageApi.importPackages(formData, overwrite, performValidation);
162
140
  yield this.studioService.processImportedPackages(configs, existingStudioPackages, studioManifests);
163
141
  if (gitBranch) {
164
- fs.rmSync(temporaryGitFolder, { recursive: true });
142
+ fs.rmSync(temporaryGitFolder, { recursive: true, force: true });
165
143
  }
166
144
  fs.rmSync(sourceToBeImported);
167
145
  const reportFileName = "config_import_report_" + (0, uuid_1.v4)() + ".json";
@@ -171,14 +149,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
171
149
  }
172
150
  findAndExportListOfActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
173
151
  return __awaiter(this, void 0, void 0, function* () {
174
- let packagesToExport = yield this.batchImportExportApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
152
+ let packagesToExport = yield this.t2tcPackageApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
175
153
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, false);
176
154
  this.exportListOfPackages(packagesToExport);
177
155
  });
178
156
  }
179
157
  listActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
180
158
  return __awaiter(this, void 0, void 0, function* () {
181
- const packagesByVariableValue = yield this.batchImportExportApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
159
+ const packagesByVariableValue = yield this.t2tcPackageApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
182
160
  packagesByVariableValue.forEach(pkg => {
183
161
  logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
184
162
  });
@@ -206,12 +184,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
206
184
  });
207
185
  });
208
186
  });
209
- return this.batchImportExportApi.findVariablesWithValuesByPackageKeysAndVersion(variableExportRequest);
210
- }
211
- exportListOfPackagesMetadata(packagesMetadata) {
212
- const filename = (0, uuid_1.v4)() + ".json";
213
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packagesMetadata), filename);
214
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
187
+ return this.variableApi.findVariablesWithValuesByPackageKeysAndVersion(variableExportRequest);
215
188
  }
216
189
  buildBodyForImport(configs, sourcePath, variablesManifests) {
217
190
  const formData = new FormData();
@@ -257,10 +230,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
257
230
  else {
258
231
  const fileDownloadedMessage = "File downloaded successfully. New filename: ";
259
232
  const filename = `export_${(0, uuid_1.v4)()}.zip`;
260
- exportedZip.writeZip(filename, () => fs.chmodSync(filename, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
233
+ const fullFilePath = (0, node_path_1.resolve)(process.cwd(), filename);
234
+ exportedZip.writeZip(fullFilePath, () => fs.chmodSync(fullFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
261
235
  logger_1.logger.info(fileDownloadedMessage + filename);
262
236
  }
263
237
  }
264
238
  }
265
- exports.BatchImportExportService = BatchImportExportService;
239
+ exports.T2tcPackageService = T2tcPackageService;
266
240
  });
@@ -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
+ });