@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
@@ -16,33 +16,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
16
16
  if (v !== undefined) module.exports = v;
17
17
  }
18
18
  else if (typeof define === "function" && define.amd) {
19
- define(["require", "exports", "../../core/command/module-handler", "./config-command.service", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service", "./package-version-command.service", "./package-validation.service"], factory);
19
+ define(["require", "exports", "../../core/command/module-handler", "./config-command.service", "./staging-package.service", "./metadata.service", "../t2tc/t2tc-command.service", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service", "./package-version-command.service", "./package-validation.service", "./single-package-import.service"], factory);
20
20
  }
21
21
  })(function (require, exports) {
22
22
  "use strict";
23
23
  const module_handler_1 = require("../../core/command/module-handler");
24
24
  const config_command_service_1 = require("./config-command.service");
25
+ const staging_package_service_1 = require("./staging-package.service");
26
+ const metadata_service_1 = require("./metadata.service");
27
+ const t2tc_command_service_1 = require("../t2tc/t2tc-command.service");
25
28
  const variable_command_service_1 = require("./variable-command.service");
26
29
  const node_service_1 = require("./node.service");
27
30
  const node_diff_service_1 = require("./node-diff.service");
28
31
  const node_dependency_service_1 = require("./node-dependency.service");
29
32
  const package_version_command_service_1 = require("./package-version-command.service");
30
33
  const package_validation_service_1 = require("./package-validation.service");
34
+ const single_package_import_service_1 = require("./single-package-import.service");
31
35
  class Module extends module_handler_1.IModule {
32
36
  register(context, configurator) {
33
- const configCommand = configurator.command("config");
37
+ const configCommand = configurator.command("config")
38
+ .description("Manage package configurations and their resources (package, nodes, versions, variables, metadata). Note: 'config list/export/import/diff' are deprecated — bulk Team-to-Team Copy operations have moved to the 't2tc package' group, and single-package operations live under 'config package'.");
34
39
  configCommand.command("list")
35
- .description("Command to list packages")
40
+ .description("[Deprecated] Use 't2tc package list' instead. List packages in the target team.")
41
+ .deprecationNotice("'config list' is deprecated and will be removed in a future release. Use 't2tc package list' instead.")
36
42
  .option("--json", "Return response as json type", "")
37
- .option("--flavors <flavors...>", "Lists only active packages of the given flavors")
43
+ .option("--flavors <flavors...>", "Lists only packages of the given flavors")
38
44
  .option("--withDependencies", "Include dependencies", "")
39
45
  .option("--packageKeys <packageKeys...>", "Lists only active versions of given package keys")
40
46
  .option("--keysByVersion <keysByVersion...>", "Lists packages by given key and version [packageKey.version]")
41
47
  .option("--variableValue <variableValue>", "Variable value for filtering packages by.")
42
48
  .option("--variableType <variableType>", "Variable type for filtering packages by.")
49
+ .option("--branches", "Include branches", false)
50
+ .option("--staging", "List staging packages instead", false)
43
51
  .action(this.listPackages);
44
52
  configCommand.command("export")
45
- .description("Command to export package configs")
53
+ .description("[Deprecated] Use 't2tc package export' instead. Export one or more packages into a Team-to-Team Copy archive.")
54
+ .deprecationNotice("'config export' is deprecated and will be removed in a future release. Use 't2tc package export' instead.")
46
55
  .option("--packageKeys <packageKeys...>", "Keys of packages to export. Exports the latest deployed version only")
47
56
  .option("--keysByVersion <keysByVersion...>", "Keys of packages to export by version")
48
57
  .option("--withDependencies", "Include variables and dependencies", "")
@@ -54,12 +63,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
54
63
  .description("Commands related to package metadata");
55
64
  metadataCommand
56
65
  .command("export")
57
- .description("Command to show whether packages have unpublished changes")
66
+ .description("Show whether multiple packages have unpublished changes (bulk metadata export).")
58
67
  .requiredOption("--packageKeys <packageKeys...>", "Keys of packages to find the metadata of")
59
68
  .option("--json", "Return response as json type", "")
60
- .action(this.batchExportPackagesMetadata);
69
+ .action(this.exportPackagesMetadata);
61
70
  configCommand.command("import")
62
- .description("Command to import package configs")
71
+ .description("[Deprecated] Use 't2tc package import' (batch) or 'config package import' (single package) instead. Import packages from a Team-to-Team Copy archive.")
72
+ .deprecationNotice("'config import' is deprecated and will be removed in a future release. Use 't2tc package import' (batch archive) or 'config package import' (single package) instead.")
63
73
  .option("--overwrite", "Flag to allow overwriting of packages")
64
74
  .option("--validate", "Validate node configurations before import", false)
65
75
  .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
@@ -67,16 +77,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
67
77
  .option("-f, --file <file>", "Exported packages file (relative path)")
68
78
  .option("-d, --directory <directory>", "Exported packages directory (relative path)")
69
79
  .action(this.batchImportPackages);
70
- configCommand.command("validate")
80
+ const packageCommand = configCommand.command("package")
81
+ .description("Commands for working with a single package.");
82
+ packageCommand.command("import")
83
+ .description("Import a package from a zip file or directory. Uses the package format, which is not interchangeable with the 't2tc package export' / 't2tc package import' batch archive.")
84
+ .option("-f, --file <file>", "Package zip file (relative path)")
85
+ .option("-d, --directory <directory>", "Package directory (relative path)")
86
+ .option("--overwrite", "Flag to allow overwriting an existing package with the same key")
87
+ .option("--json", "Return the response as a JSON file")
88
+ .action(this.importSinglePackage);
89
+ packageCommand.command("validate")
71
90
  .description("Validate package node configurations")
72
91
  .requiredOption("--packageKey <packageKey>", "Key of the package to validate")
73
- .option("--layers <layers...>", "Validation layers to run", ["SCHEMA"])
92
+ .option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS). Defaults to SCHEMA.", ["SCHEMA"])
93
+ .option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
94
+ .option("--json", "Return the response as a JSON file")
95
+ .action(this.validatePackage);
96
+ packageCommand.command("list")
97
+ .description("List packages in the target team. Lists staging packages by default.")
98
+ .option("--json", "Return response as json type", "")
99
+ .option("--flavors <flavors...>", "Lists only packages of the given flavors")
100
+ .action(this.listStagingPackages);
101
+ configCommand.command("validate")
102
+ .description("[Deprecated] Use 'config package validate' instead. Validate package node configurations.")
103
+ .deprecationNotice("'config validate' is deprecated and will be removed in a future release. Use 'config package validate' instead.")
104
+ .requiredOption("--packageKey <packageKey>", "Key of the package to validate")
105
+ .option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS). Defaults to SCHEMA.", ["SCHEMA"])
74
106
  .option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
75
107
  .option("--json", "Return the response as a JSON file")
76
108
  .action(this.validatePackage);
77
109
  configCommand.command("diff")
78
- .description("Command to diff configs of packages")
110
+ .description("[Deprecated] Use 't2tc package diff' instead. Diff a local Team-to-Team Copy archive against deployed or staging packages.")
111
+ .deprecationNotice("'config diff' is deprecated and will be removed in a future release. Use 't2tc package diff' instead.")
79
112
  .option("--hasChanges", "Flag to return only the information if the package has changes without the actual changes")
113
+ .option("--baseVersion <version>", "Compare against a given version or STAGING")
80
114
  .option("--json", "Return the response as a JSON file")
81
115
  .requiredOption("-f, --file <file>", "Exported packages file (relative or absolute path)")
82
116
  .action(this.diffPackages);
@@ -153,7 +187,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
153
187
  .requiredOption("--packageKey <packageKey>", "Identifier of the package")
154
188
  .requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
155
189
  .requiredOption("--baseVersion <baseVersion>", "Base version of the node")
156
- .requiredOption("--compareVersion <compareVersion>", "Compare version of the node")
190
+ .option("--compareVersion <compareVersion>", "Compare version of the node, mutually exclusive with --file (exactly one required)")
191
+ .option("-f, --file <file>", "Local node JSON file to diff against the base version, mutually exclusive with --compareVersion (exactly one required)")
157
192
  .option("--json", "Return the response as a JSON file")
158
193
  .action(this.diffNode);
159
194
  const nodeDependenciesCommand = nodesCommand.command("dependencies")
@@ -175,10 +210,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
175
210
  }
176
211
  listPackages(context, command, options) {
177
212
  return __awaiter(this, void 0, void 0, function* () {
213
+ if (options.staging && (options.withDependencies || options.packageKeys || options.keysByVersion || options.variableValue || options.variableType)) {
214
+ throw new Error("Staging parameter is not compatible with --withDependencies, --packageKeys, --keysByVersion, --variableValue, --variableType");
215
+ }
178
216
  if (options.packageKeys && options.keysByVersion) {
179
217
  throw new Error("Please provide either --packageKeys or --keysByVersion, but not both.");
180
218
  }
181
- yield new config_command_service_1.ConfigCommandService(context).listPackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType);
219
+ 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);
220
+ });
221
+ }
222
+ listStagingPackages(context, command, options) {
223
+ var _a;
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ yield new staging_package_service_1.StagingPackageService(context).listStagingPackages((_a = options.flavors) !== null && _a !== void 0 ? _a : [], false, options.json);
182
226
  });
183
227
  }
184
228
  batchExportPackages(context, command, options) {
@@ -191,12 +235,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
191
235
  throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
192
236
  }
193
237
  options.withDependencies = (_a = options.withDependencies) !== null && _a !== void 0 ? _a : false;
194
- yield new config_command_service_1.ConfigCommandService(context).batchExportPackages(options.packageKeys, options.keysByVersion, options.withDependencies, options.gitBranch, options.unzip);
238
+ yield new t2tc_command_service_1.T2tcCommandService(context).batchExportPackages(options.packageKeys, options.keysByVersion, options.withDependencies, options.gitBranch, options.unzip);
195
239
  });
196
240
  }
197
- batchExportPackagesMetadata(context, command, options) {
241
+ exportPackagesMetadata(context, command, options) {
198
242
  return __awaiter(this, void 0, void 0, function* () {
199
- yield new config_command_service_1.ConfigCommandService(context).batchExportPackagesMetadata(options.packageKeys, options.json);
243
+ yield new metadata_service_1.MetadataService(context).exportPackagesMetadata(options.packageKeys, options.json);
200
244
  });
201
245
  }
202
246
  getPackageVersion(context, command, options) {
@@ -222,12 +266,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
222
266
  if (options.gitProfile && !options.gitBranch) {
223
267
  throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
224
268
  }
225
- yield new config_command_service_1.ConfigCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch, options.validate);
269
+ yield new t2tc_command_service_1.T2tcCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch, options.validate);
270
+ });
271
+ }
272
+ importSinglePackage(context, command, options) {
273
+ return __awaiter(this, void 0, void 0, function* () {
274
+ yield new single_package_import_service_1.SinglePackageImportService(context).importPackage(options.file, options.directory, options.overwrite, options.json);
226
275
  });
227
276
  }
228
277
  diffPackages(context, command, options) {
229
278
  return __awaiter(this, void 0, void 0, function* () {
230
- yield new config_command_service_1.ConfigCommandService(context).diffPackages(options.file, options.hasChanges, options.json);
279
+ yield new t2tc_command_service_1.T2tcCommandService(context).diffPackages(options.file, options.hasChanges, options.baseVersion, options.json);
231
280
  });
232
281
  }
233
282
  validatePackage(context, command, options) {
@@ -281,7 +330,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
281
330
  }
282
331
  diffNode(context, command, options) {
283
332
  return __awaiter(this, void 0, void 0, function* () {
284
- yield new node_diff_service_1.NodeDiffService(context).diff(options.packageKey, options.nodeKey, options.baseVersion, options.compareVersion, options.json);
333
+ if ((options.file && options.compareVersion) || (!options.file && !options.compareVersion)) {
334
+ throw new Error("Please provide either --compareVersion or --file, but not both.");
335
+ }
336
+ if (options.file) {
337
+ yield new node_diff_service_1.NodeDiffService(context).diffWithFile(options.packageKey, options.nodeKey, options.baseVersion, options.file, options.json);
338
+ }
339
+ else {
340
+ yield new node_diff_service_1.NodeDiffService(context).diff(options.packageKey, options.nodeKey, options.baseVersion, options.compareVersion, options.json);
341
+ }
285
342
  });
286
343
  }
287
344
  listNodeDependencies(context, command, options) {
@@ -13,12 +13,13 @@ 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", "../../core/utils/logger", "../../core/utils/file-service", "./api/node-diff-api"], factory);
16
+ define(["require", "exports", "node:fs", "uuid", "../../core/utils/logger", "../../core/utils/file-service", "./api/node-diff-api"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.NodeDiffService = void 0;
22
+ const fs = require("node:fs");
22
23
  const uuid_1 = require("uuid");
23
24
  const logger_1 = require("../../core/utils/logger");
24
25
  const file_service_1 = require("../../core/utils/file-service");
@@ -36,27 +37,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
36
37
  compareVersion,
37
38
  });
38
39
  if (jsonResponse) {
39
- const filename = (0, uuid_1.v4)() + ".json";
40
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodeDiff, null, 2), filename);
41
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
40
+ this.exportDiffAsJson(nodeDiff);
42
41
  }
43
42
  else {
44
- logger_1.logger.info(`Package Key: ${nodeDiff.packageKey}`);
45
- logger_1.logger.info(`Node Key: ${nodeDiff.nodeKey}`);
46
- logger_1.logger.info(`Name: ${nodeDiff.name}`);
47
- logger_1.logger.info(`Type: ${nodeDiff.type}`);
48
- logger_1.logger.info(`Is invalid configuration: ${nodeDiff.invalidContent}`);
49
- if (nodeDiff.parentNodeKey) {
50
- logger_1.logger.info(`Parent Node Key: ${nodeDiff.parentNodeKey}`);
51
- }
52
- logger_1.logger.info(`Change Date: ${new Date(nodeDiff.changeDate).toISOString()}`);
53
- logger_1.logger.info(`Updated By: ${nodeDiff.updatedBy}`);
54
- logger_1.logger.info(`Change Type: ${nodeDiff.changeType}`);
55
- logger_1.logger.info(`Changes: ${JSON.stringify(nodeDiff.changes)}`);
56
- logger_1.logger.info(`Metadata Changes: ${JSON.stringify(nodeDiff.metadataChanges)}`);
43
+ this.logDiff(nodeDiff);
57
44
  }
58
45
  });
59
46
  }
47
+ diffWithFile(packageKey, nodeKey, baseVersion, file, jsonResponse) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const nodeDiff = yield this.nodeDiffApi.diffWithFile({
50
+ packageKey,
51
+ nodeKey,
52
+ baseVersion,
53
+ file: fs.createReadStream(file),
54
+ });
55
+ if (jsonResponse) {
56
+ this.exportDiffAsJson(nodeDiff);
57
+ }
58
+ else {
59
+ this.logDiff(nodeDiff);
60
+ }
61
+ });
62
+ }
63
+ exportDiffAsJson(nodeDiff) {
64
+ const filename = (0, uuid_1.v4)() + ".json";
65
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodeDiff, null, 2), filename);
66
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
67
+ }
68
+ logDiff(nodeDiff) {
69
+ logger_1.logger.info(`Package Key: ${nodeDiff.packageKey}`);
70
+ logger_1.logger.info(`Node Key: ${nodeDiff.nodeKey}`);
71
+ logger_1.logger.info(`Name: ${nodeDiff.name}`);
72
+ logger_1.logger.info(`Type: ${nodeDiff.type}`);
73
+ logger_1.logger.info(`Is invalid configuration: ${nodeDiff.invalidContent}`);
74
+ if (nodeDiff.parentNodeKey) {
75
+ logger_1.logger.info(`Parent Node Key: ${nodeDiff.parentNodeKey}`);
76
+ }
77
+ logger_1.logger.info(`Change Date: ${new Date(nodeDiff.changeDate).toISOString()}`);
78
+ logger_1.logger.info(`Updated By: ${nodeDiff.updatedBy}`);
79
+ logger_1.logger.info(`Change Type: ${nodeDiff.changeType}`);
80
+ logger_1.logger.info(`Changes: ${JSON.stringify(nodeDiff.changes)}`);
81
+ logger_1.logger.info(`Metadata Changes: ${JSON.stringify(nodeDiff.metadataChanges)}`);
82
+ }
60
83
  }
61
84
  exports.NodeDiffService = NodeDiffService;
62
85
  });
@@ -0,0 +1,111 @@
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", "uuid", "form-data", "node:stream", "adm-zip", "node:fs", "../../core/utils/file-service", "../../core/utils/logger", "./api/single-package-import-api"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.SinglePackageImportService = void 0;
22
+ const uuid_1 = require("uuid");
23
+ const FormData = require("form-data");
24
+ const node_stream_1 = require("node:stream");
25
+ const AdmZip = require("adm-zip");
26
+ const fs = require("node:fs");
27
+ const file_service_1 = require("../../core/utils/file-service");
28
+ const logger_1 = require("../../core/utils/logger");
29
+ const single_package_import_api_1 = require("./api/single-package-import-api");
30
+ class SinglePackageImportService {
31
+ constructor(context) {
32
+ this.singlePackageImportApi = new single_package_import_api_1.SinglePackageImportApi(context);
33
+ }
34
+ importPackage(file, directory, overwrite, jsonResponse) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const resolvedSource = this.resolveSource(file, directory);
37
+ try {
38
+ const packageZip = new AdmZip(resolvedSource.zipPath);
39
+ const formData = this.buildBodyForImport(packageZip, resolvedSource.zipPath);
40
+ const result = yield this.singlePackageImportApi.importPackage(formData, overwrite);
41
+ this.outputResult(result, jsonResponse);
42
+ }
43
+ finally {
44
+ if (resolvedSource.isTemporary) {
45
+ fs.rmSync(resolvedSource.zipPath);
46
+ }
47
+ }
48
+ });
49
+ }
50
+ resolveSource(file, directory) {
51
+ if (file && directory) {
52
+ throw new Error("You cannot use both --file and --directory options at the same time. Only one import source can be defined.");
53
+ }
54
+ if (!file && !directory) {
55
+ throw new Error("You must provide either a --file or a --directory option to import a package.");
56
+ }
57
+ if (file) {
58
+ if (file_service_1.fileService.isDirectory(file)) {
59
+ throw new Error("The --file option accepts only zip files.");
60
+ }
61
+ return { zipPath: file, isTemporary: false };
62
+ }
63
+ if (!file_service_1.fileService.isDirectory(directory)) {
64
+ throw new Error("The --directory option accepts only directories.");
65
+ }
66
+ return { zipPath: file_service_1.fileService.zipDirectoryAsSinglePackage(directory), isTemporary: true };
67
+ }
68
+ buildBodyForImport(packageZip, sourcePath) {
69
+ this.assertUncompressedSizeWithinLimit(packageZip, sourcePath);
70
+ const formData = new FormData();
71
+ formData.append("packageFile", this.getReadableStream(packageZip), { filename: "package.zip" });
72
+ return formData;
73
+ }
74
+ assertUncompressedSizeWithinLimit(packageZip, sourcePath) {
75
+ const totalUncompressedBytes = packageZip.getEntries().reduce((sum, entry) => sum + entry.header.size, 0);
76
+ if (totalUncompressedBytes > SinglePackageImportService.MAX_UNCOMPRESSED_ZIP_SIZE) {
77
+ throw new Error(`Failed to handle zip file "${sourcePath}": uncompressed size ${(totalUncompressedBytes / (Math.pow(1024, 3))).toFixed(2)} GB exceeds the 4 GB limit.`);
78
+ }
79
+ }
80
+ getReadableStream(packageZip) {
81
+ return new node_stream_1.Readable({
82
+ read() {
83
+ this.push(packageZip.toBuffer());
84
+ this.push(null);
85
+ },
86
+ });
87
+ }
88
+ outputResult(result, jsonResponse) {
89
+ var _a;
90
+ if (jsonResponse) {
91
+ const filename = (0, uuid_1.v4)() + ".json";
92
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(result, null, 2), filename);
93
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
94
+ return;
95
+ }
96
+ const importedPackage = result.importedPackage;
97
+ const importedNodes = (_a = result.importedNodes) !== null && _a !== void 0 ? _a : [];
98
+ logger_1.logger.info(`Successfully imported package: ${importedPackage.key}`);
99
+ logger_1.logger.info(`Name: ${importedPackage.name}`);
100
+ if (importedPackage.flavor) {
101
+ logger_1.logger.info(`Flavor: ${importedPackage.flavor}`);
102
+ }
103
+ logger_1.logger.info(`Imported ${importedNodes.length} node(s).`);
104
+ importedNodes.forEach(node => {
105
+ logger_1.logger.info(` - ${node.key} (${node.type})`);
106
+ });
107
+ }
108
+ }
109
+ exports.SinglePackageImportService = SinglePackageImportService;
110
+ SinglePackageImportService.MAX_UNCOMPRESSED_ZIP_SIZE = 4 * 1024 * 1024 * 1024;
111
+ });
@@ -0,0 +1,50 @@
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", "uuid", "../../core/utils/file-service", "../../core/utils/logger", "./api/staging-package-api"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.StagingPackageService = void 0;
22
+ const uuid_1 = require("uuid");
23
+ const file_service_1 = require("../../core/utils/file-service");
24
+ const logger_1 = require("../../core/utils/logger");
25
+ const staging_package_api_1 = require("./api/staging-package-api");
26
+ class StagingPackageService {
27
+ constructor(context) {
28
+ this.stagingPackageApi = new staging_package_api_1.StagingPackageApi(context);
29
+ }
30
+ listStagingPackages(flavors, includeBranches, jsonResponse) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const stagingPackages = yield this.stagingPackageApi.findAllStagingPackages(flavors, includeBranches);
33
+ if (jsonResponse) {
34
+ this.exportListOfPackages(stagingPackages);
35
+ }
36
+ else {
37
+ stagingPackages.forEach(pkg => {
38
+ logger_1.logger.info(`${pkg.name} - Key: "${pkg.key}"`);
39
+ });
40
+ }
41
+ });
42
+ }
43
+ exportListOfPackages(packages) {
44
+ const filename = (0, uuid_1.v4)() + ".json";
45
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packages), filename);
46
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
47
+ }
48
+ }
49
+ exports.StagingPackageService = StagingPackageService;
50
+ });
@@ -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", "uuid", "../../core/utils/logger", "./studio.service", "../../core/utils/file-service", "./api/batch-import-export-api", "url", "./api/variable-assignment-candidates-api", "./api/staging-package-variables-api"], factory);
16
+ define(["require", "exports", "uuid", "../../core/utils/logger", "./connection-variable.helper", "../../core/utils/file-service", "./api/variable-api", "url", "./api/variable-assignment-candidates-api", "./api/staging-package-variables-api"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -21,18 +21,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
21
  exports.VariableService = void 0;
22
22
  const uuid_1 = require("uuid");
23
23
  const logger_1 = require("../../core/utils/logger");
24
- const studio_service_1 = require("./studio.service");
24
+ const connection_variable_helper_1 = require("./connection-variable.helper");
25
25
  const file_service_1 = require("../../core/utils/file-service");
26
- const batch_import_export_api_1 = require("./api/batch-import-export-api");
26
+ const variable_api_1 = require("./api/variable-api");
27
27
  const url_1 = require("url");
28
28
  const variable_assignment_candidates_api_1 = require("./api/variable-assignment-candidates-api");
29
29
  const staging_package_variables_api_1 = require("./api/staging-package-variables-api");
30
30
  class VariableService {
31
31
  constructor(context) {
32
- this.batchImportExportApi = new batch_import_export_api_1.BatchImportExportApi(context);
32
+ this.variableApi = new variable_api_1.VariableApi(context);
33
33
  this.variableAssignmentCandidatesApi = new variable_assignment_candidates_api_1.VariableAssignmentCandidatesApi(context);
34
34
  this.stagingPackageVariablesApi = new staging_package_variables_api_1.StagingPackageVariablesApi(context);
35
- this.studioService = new studio_service_1.StudioService(context);
36
35
  }
37
36
  listVariables(keysByVersion, keysByVersionFile) {
38
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -86,8 +85,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
86
85
  getVersionedVariablesByKeyVersionPairs(keysByVersion, keysByVersionFile) {
87
86
  return __awaiter(this, void 0, void 0, function* () {
88
87
  const variablesExportRequest = yield this.buildKeyVersionPairs(keysByVersion, keysByVersionFile);
89
- const variableManifests = yield this.batchImportExportApi.findVariablesWithValuesByPackageKeysAndVersion(variablesExportRequest);
90
- return this.studioService.fixConnectionVariables(variableManifests);
88
+ const variableManifests = yield this.variableApi.findVariablesWithValuesByPackageKeysAndVersion(variablesExportRequest);
89
+ return (0, connection_variable_helper_1.fixConnectionVariables)(variableManifests);
91
90
  });
92
91
  }
93
92
  buildKeyVersionPairs(keysByVersion, keysByVersionFile) {
@@ -0,0 +1,40 @@
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"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.DiffApi = void 0;
22
+ class DiffApi {
23
+ constructor(context) {
24
+ this.httpClient = () => context.httpClient;
25
+ }
26
+ diffPackages(baseVersion, data) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const paramString = baseVersion ? "?" + new URLSearchParams({ "baseVersion": baseVersion }).toString() : "";
29
+ return this.httpClient().postFile(`/package-manager/api/core/packages/diff/configuration${paramString}`, data);
30
+ });
31
+ }
32
+ hasChanges(baseVersion, data) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const paramString = baseVersion ? "?" + new URLSearchParams({ "baseVersion": baseVersion }).toString() : "";
35
+ return this.httpClient().postFile(`/package-manager/api/core/packages/diff/configuration/has-changes${paramString}`, data);
36
+ });
37
+ }
38
+ }
39
+ exports.DiffApi = DiffApi;
40
+ });
@@ -18,29 +18,31 @@ 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
  }
27
- findAllActivePackages(flavors, withDependencies = false) {
27
+ findAllActivePackages(flavors, withDependencies = false, includeBranches = false) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  const queryParams = new URLSearchParams();
30
30
  queryParams.set("withDependencies", withDependencies.toString());
31
+ queryParams.set("includeBranches", includeBranches.toString());
31
32
  flavors.forEach(flavor => queryParams.append("flavors", flavor));
32
33
  return this.httpClient().get(`/package-manager/api/core/packages/export/list?${queryParams.toString()}`).catch(e => {
33
34
  throw new logger_1.FatalError(`Problem getting active packages: ${e}`);
34
35
  });
35
36
  });
36
37
  }
37
- findActivePackagesByVariableValue(flavors, variableValue, variableType) {
38
+ findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches = false) {
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  const queryParams = new URLSearchParams();
40
41
  queryParams.set("variableValue", variableValue);
41
42
  if (variableType) {
42
43
  queryParams.set("variableType", variableType);
43
44
  }
45
+ queryParams.set("includeBranches", includeBranches.toString());
44
46
  flavors.forEach(flavor => queryParams.append("flavors", flavor));
45
47
  return this.httpClient().get(`/package-manager/api/core/packages/export/list-by-variable-value?${queryParams.toString()}`).catch(e => {
46
48
  throw new logger_1.FatalError(`Problem getting active packages by variable value: ${e}`);
@@ -87,27 +89,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
87
89
  });
88
90
  });
89
91
  }
90
- batchExportPackagesMetadata(packageKeys) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const queryParams = new URLSearchParams();
93
- packageKeys.forEach(packageKey => queryParams.append("packageKeys", packageKey));
94
- return this.httpClient().get(`/package-manager/api/core/packages/metadata/export?${queryParams.toString()}`).catch(e => {
95
- throw new logger_1.FatalError(`Problem exporting packages metadata: ${e}`);
96
- });
97
- });
98
- }
99
92
  importPackages(data, overwrite, performValidation) {
100
93
  return __awaiter(this, void 0, void 0, function* () {
101
94
  return this.httpClient().postFile("/package-manager/api/core/packages/import/batch", data, { overwrite, performValidation });
102
95
  });
103
96
  }
104
- findVariablesWithValuesByPackageKeysAndVersion(packagesByKeyAndVersion) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- return this.httpClient().post("/package-manager/api/core/packages/export/batch/variables-with-assignments", packagesByKeyAndVersion).catch(e => {
107
- throw new logger_1.FatalError(`Problem exporting package variables: ${e}`);
108
- });
109
- });
110
- }
111
97
  }
112
- exports.BatchImportExportApi = BatchImportExportApi;
98
+ exports.T2tcPackageApi = T2tcPackageApi;
113
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
  }