@celonis/content-cli 1.14.0 → 1.15.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 (73) hide show
  1. package/commands/action-flows/action-flow/action-flow.service.js +9 -9
  2. package/commands/asset-registry/asset-registry-api.js +0 -7
  3. package/commands/asset-registry/asset-registry.service.js +18 -63
  4. package/commands/asset-registry/module.js +0 -21
  5. package/commands/bookmarks/bookmarks-command.service.js +5 -3
  6. package/commands/configuration-management/api/node-api.js +17 -0
  7. package/commands/configuration-management/branch/branch-export-import.command.service.js +31 -24
  8. package/commands/configuration-management/branch/branch.command.service.js +14 -10
  9. package/commands/configuration-management/metadata.service.js +9 -5
  10. package/commands/configuration-management/module.js +6 -5
  11. package/commands/configuration-management/node-dependency.service.js +5 -3
  12. package/commands/configuration-management/node-diff.service.js +10 -6
  13. package/commands/configuration-management/node.service.js +14 -10
  14. package/commands/configuration-management/package-validation.service.js +11 -5
  15. package/commands/configuration-management/package-version.service.js +7 -5
  16. package/commands/configuration-management/single-package-export.service.js +6 -6
  17. package/commands/configuration-management/single-package-import.service.js +22 -18
  18. package/commands/configuration-management/staging-package.service.js +9 -5
  19. package/commands/configuration-management/variable.service.js +11 -7
  20. package/commands/data-pipeline/data-pool/data-pool-service.js +13 -9
  21. package/commands/deployment/deployment.service.js +15 -13
  22. package/commands/git-profile/module.js +2 -1
  23. package/commands/profile/module.js +2 -1
  24. package/commands/studio/manager/space.manager.js +21 -10
  25. package/commands/studio/service/asset-service.js +5 -4
  26. package/commands/studio/service/package.service.js +9 -5
  27. package/commands/t2tc/diff.service.js +15 -9
  28. package/commands/t2tc/t2tc-package.service.js +25 -23
  29. package/content-cli.js +10 -2
  30. package/core/command/module-handler.js +14 -1
  31. package/core/http/http-client.js +24 -3
  32. package/core/http/http-shared/base.manager.js +35 -59
  33. package/core/profile/profile.service.js +35 -21
  34. package/core/profile/profile.validator.js +19 -9
  35. package/core/utils/cui-api.js +52 -0
  36. package/core/utils/cui-file-service.js +106 -0
  37. package/core/utils/file-service.js +7 -6
  38. package/lib/commands/action-flows/action-flow/action-flow.service.d.ts +1 -0
  39. package/lib/commands/asset-registry/asset-registry-api.d.ts +0 -1
  40. package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +0 -8
  41. package/lib/commands/asset-registry/asset-registry.service.d.ts +1 -5
  42. package/lib/commands/asset-registry/module.d.ts +0 -1
  43. package/lib/commands/bookmarks/bookmarks-command.service.d.ts +1 -0
  44. package/lib/commands/configuration-management/api/node-api.d.ts +1 -0
  45. package/lib/commands/configuration-management/branch/branch-export-import.command.service.d.ts +2 -1
  46. package/lib/commands/configuration-management/branch/branch.command.service.d.ts +2 -1
  47. package/lib/commands/configuration-management/interfaces/package-validation.interfaces.d.ts +1 -1
  48. package/lib/commands/configuration-management/metadata.service.d.ts +1 -0
  49. package/lib/commands/configuration-management/node-dependency.service.d.ts +1 -0
  50. package/lib/commands/configuration-management/node-diff.service.d.ts +1 -0
  51. package/lib/commands/configuration-management/node.service.d.ts +2 -1
  52. package/lib/commands/configuration-management/package-validation.service.d.ts +1 -0
  53. package/lib/commands/configuration-management/package-version.service.d.ts +1 -0
  54. package/lib/commands/configuration-management/single-package-export.service.d.ts +1 -0
  55. package/lib/commands/configuration-management/single-package-import.service.d.ts +1 -0
  56. package/lib/commands/configuration-management/staging-package.service.d.ts +1 -0
  57. package/lib/commands/configuration-management/variable.service.d.ts +1 -0
  58. package/lib/commands/data-pipeline/data-pool/data-pool-service.d.ts +1 -0
  59. package/lib/commands/deployment/deployment.service.d.ts +1 -0
  60. package/lib/commands/studio/service/asset-service.d.ts +1 -0
  61. package/lib/commands/studio/service/package.service.d.ts +1 -0
  62. package/lib/commands/t2tc/diff.service.d.ts +1 -0
  63. package/lib/commands/t2tc/t2tc-package.service.d.ts +1 -0
  64. package/lib/content-cli.d.ts +1 -0
  65. package/lib/core/command/module-handler.d.ts +2 -0
  66. package/lib/core/http/http-client.d.ts +4 -0
  67. package/lib/core/http/http-shared/base.manager.d.ts +7 -5
  68. package/lib/core/http/http-shared/manager-config.interface.d.ts +1 -1
  69. package/lib/core/profile/profile.service.d.ts +2 -0
  70. package/lib/core/profile/profile.validator.d.ts +3 -0
  71. package/lib/core/utils/cui-api.d.ts +26 -0
  72. package/lib/core/utils/cui-file-service.d.ts +19 -0
  73. package/package.json +1 -1
@@ -26,7 +26,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
26
26
  class Module extends module_handler_1.IModule {
27
27
  register(context, configurator) {
28
28
  const command = configurator.command("profile")
29
- .description("Manage profiles required to access a system.");
29
+ .description("Manage profiles required to access a system.")
30
+ .skipProfileLoading();
30
31
  command.command("list")
31
32
  .description("Command to list all stored profiles")
32
33
  .action(this.listProfiles);
@@ -1,3 +1,12 @@
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
+ };
1
10
  (function (factory) {
2
11
  if (typeof module === "object" && typeof module.exports === "object") {
3
12
  var v = factory(require, exports);
@@ -30,16 +39,18 @@
30
39
  };
31
40
  }
32
41
  listSpaces(nodes) {
33
- if (this.jsonResponse) {
34
- const filename = (0, uuid_1.v4)() + ".json";
35
- this.writeToFileWithGivenName(JSON.stringify(nodes, ["id", "name"]), filename);
36
- logger_1.logger.info(this.fileDownloadedMessage + filename);
37
- }
38
- else {
39
- nodes.forEach(node => {
40
- logger_1.logger.info(`${node.id} - Name: "${node.name}"`);
41
- });
42
- }
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ if (this.jsonResponse) {
44
+ const filename = (0, uuid_1.v4)() + ".json";
45
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(nodes, ["id", "name"]), filename);
46
+ logger_1.logger.info(this.fileDownloadedMessage + writtenFilename);
47
+ }
48
+ else {
49
+ nodes.forEach(node => {
50
+ logger_1.logger.info(`${node.id} - Name: "${node.name}"`);
51
+ });
52
+ }
53
+ });
43
54
  }
44
55
  getBody() {
45
56
  return {};
@@ -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", "../api/asset-api", "../../../core/utils/logger", "../../../core/utils/file-service"], factory);
16
+ define(["require", "exports", "uuid", "../api/asset-api", "../../../core/utils/logger", "../../../core/utils/cui-file-service"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -22,11 +22,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  const uuid_1 = require("uuid");
23
23
  const asset_api_1 = require("../api/asset-api");
24
24
  const logger_1 = require("../../../core/utils/logger");
25
- const file_service_1 = require("../../../core/utils/file-service");
25
+ const cui_file_service_1 = require("../../../core/utils/cui-file-service");
26
26
  class AssetService {
27
27
  constructor(context) {
28
28
  this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
29
29
  this.assetApi = new asset_api_1.AssetApi(context);
30
+ this.cuiFileService = new cui_file_service_1.CuiFileService(context);
30
31
  }
31
32
  listAssets(assetType) {
32
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -41,8 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
42
  const fieldsToInclude = ["key", "name", "assetType", "rootNodeKey", "activatedDraftId"];
42
43
  const nodes = yield this.assetApi.findAllAssets(assetType);
43
44
  const filename = (0, uuid_1.v4)() + ".json";
44
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodes, fieldsToInclude), filename);
45
- logger_1.logger.info(this.fileDownloadedMessage + filename);
45
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(nodes, fieldsToInclude), filename);
46
+ logger_1.logger.info(this.fileDownloadedMessage + writtenFilename);
46
47
  });
47
48
  }
48
49
  }
@@ -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", "../api/package-api", "../../../core/utils/logger", "../interfaces/package-manager.interfaces", "../../../core/utils/file-service", "../api/package-dependencies-api", "./data-model.service", "./studio-variable.service"], factory);
16
+ define(["require", "exports", "uuid", "../api/package-api", "../../../core/utils/logger", "../interfaces/package-manager.interfaces", "../../../core/utils/file-service", "../../../core/utils/cui-file-service", "../api/package-dependencies-api", "./data-model.service", "./studio-variable.service"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -24,6 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
24
24
  const logger_1 = require("../../../core/utils/logger");
25
25
  const package_manager_interfaces_1 = require("../interfaces/package-manager.interfaces");
26
26
  const file_service_1 = require("../../../core/utils/file-service");
27
+ const cui_file_service_1 = require("../../../core/utils/cui-file-service");
27
28
  const package_dependencies_api_1 = require("../api/package-dependencies-api");
28
29
  const data_model_service_1 = require("./data-model.service");
29
30
  const studio_variable_service_1 = require("./studio-variable.service");
@@ -34,6 +35,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
35
  this.packageDependenciesApi = new package_dependencies_api_1.PackageDependenciesApi(context);
35
36
  this.dataModelService = new data_model_service_1.DataModelService(context);
36
37
  this.variableService = new studio_variable_service_1.StudioVariableService(context);
38
+ this.cuiFileService = new cui_file_service_1.CuiFileService(context);
37
39
  }
38
40
  listPackages() {
39
41
  return __awaiter(this, void 0, void 0, function* () {
@@ -70,7 +72,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
70
72
  return nodeToExport;
71
73
  });
72
74
  }
73
- this.exportListOfPackages(nodesListToExport, fieldsToInclude);
75
+ yield this.exportListOfPackages(nodesListToExport, fieldsToInclude);
74
76
  });
75
77
  }
76
78
  getNodesWithActiveVersion(nodes) {
@@ -88,9 +90,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
88
90
  });
89
91
  }
90
92
  exportListOfPackages(nodes, fieldsToInclude) {
91
- const filename = (0, uuid_1.v4)() + ".json";
92
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodes, fieldsToInclude), filename);
93
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const filename = (0, uuid_1.v4)() + ".json";
95
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(nodes, fieldsToInclude), filename);
96
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + writtenFilename);
97
+ });
94
98
  }
95
99
  }
96
100
  exports.PackageService = PackageService;
@@ -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", "stream", "form-data", "uuid", "../../core/utils/logger", "../../core/utils/file-service", "./api/diff-api"], factory);
16
+ define(["require", "exports", "adm-zip", "stream", "form-data", "uuid", "../../core/utils/logger", "../../core/utils/file-service", "../../core/utils/cui-file-service", "./api/diff-api"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -25,10 +25,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  const uuid_1 = require("uuid");
26
26
  const logger_1 = require("../../core/utils/logger");
27
27
  const file_service_1 = require("../../core/utils/file-service");
28
+ const cui_file_service_1 = require("../../core/utils/cui-file-service");
28
29
  const diff_api_1 = require("./api/diff-api");
29
30
  class DiffService {
30
31
  constructor(context) {
31
32
  this.diffApi = new diff_api_1.DiffApi(context);
33
+ this.cuiFileService = new cui_file_service_1.CuiFileService(context);
32
34
  }
33
35
  diffPackages(file, hasChanges, baseVersion, jsonResponse) {
34
36
  return __awaiter(this, void 0, void 0, function* () {
@@ -46,7 +48,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46
48
  const formData = this.buildBodyForDiff(packages);
47
49
  const returnedHasChangesData = yield this.diffApi.hasChanges(baseVersion, formData);
48
50
  if (jsonResponse) {
49
- this.exportListOfPackageDiffMetadata(returnedHasChangesData);
51
+ yield this.exportListOfPackageDiffMetadata(returnedHasChangesData);
50
52
  }
51
53
  else {
52
54
  logger_1.logger.info(this.buildStringResponseForPackageDiffMetadataList(returnedHasChangesData));
@@ -59,7 +61,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
59
61
  const formData = this.buildBodyForDiff(packages);
60
62
  const returnedHasChangesData = yield this.diffApi.diffPackages(baseVersion, formData);
61
63
  if (jsonResponse) {
62
- this.exportListOfPackageDiffs(returnedHasChangesData);
64
+ yield this.exportListOfPackageDiffs(returnedHasChangesData);
63
65
  }
64
66
  else {
65
67
  logger_1.logger.info(this.buildStringResponseForPackageDiffs(returnedHasChangesData));
@@ -81,14 +83,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
81
83
  });
82
84
  }
83
85
  exportListOfPackageDiffs(packageDiffs) {
84
- const filename = (0, uuid_1.v4)() + ".json";
85
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packageDiffs), filename);
86
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const filename = (0, uuid_1.v4)() + ".json";
88
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(packageDiffs), filename);
89
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + writtenFilename);
90
+ });
87
91
  }
88
92
  exportListOfPackageDiffMetadata(packageDiffMetadata) {
89
- const filename = (0, uuid_1.v4)() + ".json";
90
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packageDiffMetadata), filename);
91
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const filename = (0, uuid_1.v4)() + ".json";
95
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(packageDiffMetadata), filename);
96
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + writtenFilename);
97
+ });
92
98
  }
93
99
  buildStringResponseForPackageDiffs(packageDiffs) {
94
100
  return "\n" + JSON.stringify(packageDiffs, null, 2);
@@ -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", "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);
16
+ define(["require", "exports", "uuid", "form-data", "stream", "adm-zip", "./batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/cui-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";
@@ -25,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  const AdmZip = require("adm-zip");
26
26
  const batch_export_import_constants_1 = require("./batch-export-import.constants");
27
27
  const file_service_1 = require("../../core/utils/file-service");
28
+ const cui_file_service_1 = require("../../core/utils/cui-file-service");
28
29
  const logger_1 = require("../../core/utils/logger");
29
30
  const json_1 = require("../../core/utils/json");
30
31
  const package_api_1 = require("../studio/api/package-api");
@@ -35,7 +36,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
35
36
  const git_service_1 = require("../../core/git-profile/git/git.service");
36
37
  const fs = require("fs");
37
38
  const file_constants_1 = require("../../core/utils/file.constants");
38
- const node_path_1 = require("node:path");
39
39
  class T2tcPackageService {
40
40
  constructor(context) {
41
41
  this.t2tcPackageApi = new t2tc_package_api_1.T2tcPackageApi(context);
@@ -43,6 +43,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  this.studioPackageApi = new package_api_1.PackageApi(context);
44
44
  this.studioService = new studio_service_1.StudioService(context);
45
45
  this.gitService = new git_service_1.GitService(context);
46
+ this.cuiFileService = new cui_file_service_1.CuiFileService(context);
46
47
  }
47
48
  listActivePackages(flavors, includeBranches) {
48
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -65,7 +66,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
65
66
  packagesToExport = yield this.t2tcPackageApi.findAllActivePackages(flavors, withDependencies, includeBranches);
66
67
  }
67
68
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, withDependencies);
68
- this.exportListOfPackages(packagesToExport);
69
+ yield this.exportListOfPackages(packagesToExport);
69
70
  });
70
71
  }
71
72
  listPackagesByKeysWithVersion(keysByVersion, withDependencies) {
@@ -112,7 +113,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
112
113
  fs.rmSync(extractedDirectory, { recursive: true });
113
114
  }
114
115
  else {
115
- this.downloadZip(exportedPackagesZip, unzip);
116
+ yield this.downloadZip(exportedPackagesZip, unzip);
116
117
  }
117
118
  });
118
119
  }
@@ -143,15 +144,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
143
144
  }
144
145
  fs.rmSync(sourceToBeImported);
145
146
  const reportFileName = "config_import_report_" + (0, uuid_1.v4)() + ".json";
146
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(postPackageImportData), reportFileName);
147
- logger_1.logger.info("Config import report file: " + reportFileName);
147
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(postPackageImportData), reportFileName);
148
+ logger_1.logger.info("Config import report file: " + writtenFilename);
148
149
  });
149
150
  }
150
151
  findAndExportListOfActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
151
152
  return __awaiter(this, void 0, void 0, function* () {
152
153
  let packagesToExport = yield this.t2tcPackageApi.findActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches);
153
154
  packagesToExport = yield this.studioService.getExportPackagesWithStudioData(packagesToExport, false);
154
- this.exportListOfPackages(packagesToExport);
155
+ yield this.exportListOfPackages(packagesToExport);
155
156
  });
156
157
  }
157
158
  listActivePackagesByVariableValue(flavors, variableValue, variableType, includeBranches) {
@@ -163,9 +164,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
163
164
  });
164
165
  }
165
166
  exportListOfPackages(packages) {
166
- const filename = (0, uuid_1.v4)() + ".json";
167
- file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packages), filename);
168
- logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ const filename = (0, uuid_1.v4)() + ".json";
169
+ const writtenFilename = yield this.cuiFileService.writeToFileWithGivenName(JSON.stringify(packages), filename);
170
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + writtenFilename);
171
+ });
169
172
  }
170
173
  getVersionsByPackageKey(manifests) {
171
174
  const versionsByPackageKey = new Map();
@@ -221,19 +224,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
221
224
  return null;
222
225
  }
223
226
  downloadZip(exportedZip, unzip) {
224
- if (unzip) {
225
- const fileDownloadedMessage = "Successful download. Downloaded directory: ";
226
- const targetDirectoryName = `export_${(0, uuid_1.v4)()}`;
227
- file_service_1.fileService.extractExportedZipWithNestedZipsToDir(exportedZip, targetDirectoryName);
228
- logger_1.logger.info(fileDownloadedMessage + targetDirectoryName);
229
- }
230
- else {
231
- const fileDownloadedMessage = "File downloaded successfully. New filename: ";
232
- const filename = `export_${(0, uuid_1.v4)()}.zip`;
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));
235
- logger_1.logger.info(fileDownloadedMessage + filename);
236
- }
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ if (unzip) {
229
+ const fileDownloadedMessage = "Successful download. Downloaded directory: ";
230
+ const directoryName = yield this.cuiFileService.writeDirectoryWithGivenName(targetDir => file_service_1.fileService.extractExportedZipWithNestedZipsToDir(exportedZip, targetDir), `export_${(0, uuid_1.v4)()}`);
231
+ logger_1.logger.info(fileDownloadedMessage + directoryName);
232
+ }
233
+ else {
234
+ const fileDownloadedMessage = "File downloaded successfully. New filename: ";
235
+ const filename = yield this.cuiFileService.writeZipToFileWithGivenName(exportedZip.toBuffer(), `export_${(0, uuid_1.v4)()}.zip`);
236
+ logger_1.logger.info(fileDownloadedMessage + filename);
237
+ }
238
+ });
237
239
  }
238
240
  }
239
241
  exports.T2tcPackageService = T2tcPackageService;
package/content-cli.js CHANGED
@@ -19,7 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
19
  })(function (require, exports) {
20
20
  "use strict";
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.createProgram = void 0;
22
+ exports.loadProfileOnDemand = exports.createProgram = void 0;
23
23
  const semverSatisfies = require("semver/functions/satisfies");
24
24
  const commander_1 = require("commander");
25
25
  const module_handler_1 = require("./core/command/module-handler");
@@ -69,6 +69,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
69
69
  return program;
70
70
  }
71
71
  exports.createProgram = createProgram;
72
+ function loadProfileOnDemand(program, context) {
73
+ program.hook("preAction", (_program, actionCommand) => __awaiter(this, void 0, void 0, function* () {
74
+ if ((0, module_handler_1.shouldLoadProfile)(actionCommand)) {
75
+ yield context.init();
76
+ }
77
+ }));
78
+ }
79
+ exports.loadProfileOnDemand = loadProfileOnDemand;
72
80
  /**
73
81
  * To support the legacy command structure, we have to configure some root commands
74
82
  * that the individual modules will extend.
@@ -103,8 +111,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
103
111
  });
104
112
  }
105
113
  const context = new cli_context_1.Context(globalOpts);
106
- yield context.init();
107
114
  const program = createProgram(context, { devMode: !!globalOpts.dev });
115
+ loadProfileOnDemand(program, context);
108
116
  try {
109
117
  yield program.parseAsync(process.argv);
110
118
  }
@@ -18,7 +18,7 @@ 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.CommandConfig = exports.Configurator = exports.ModuleHandler = exports.IModule = void 0;
21
+ exports.CommandConfig = exports.Configurator = exports.shouldLoadProfile = exports.ModuleHandler = exports.IModule = void 0;
22
22
  const path = require("path");
23
23
  const fs = require("fs");
24
24
  const commander_1 = require("commander");
@@ -120,6 +120,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
120
120
  }
121
121
  }
122
122
  exports.ModuleHandler = ModuleHandler;
123
+ function shouldLoadProfile(command) {
124
+ for (let cmd = command; cmd; cmd = cmd.parent) {
125
+ if (cmd.skipsProfileLoading) {
126
+ return false;
127
+ }
128
+ }
129
+ return true;
130
+ }
131
+ exports.shouldLoadProfile = shouldLoadProfile;
123
132
  /**
124
133
  * Allows the creation of root level commands.
125
134
  */
@@ -192,6 +201,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
192
201
  this.cmd.isBeta = true;
193
202
  return this;
194
203
  }
204
+ skipProfileLoading() {
205
+ this.cmd.skipsProfileLoading = true;
206
+ return this;
207
+ }
195
208
  action(handler) {
196
209
  this.cmd.action(() => __awaiter(this, void 0, void 0, function* () {
197
210
  try {
@@ -53,6 +53,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
53
53
  });
54
54
  });
55
55
  }
56
+ getStatusAndData(url) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const fullUrl = this.resolveUrl(url);
59
+ logger_1.logger.debug(`HttpClient - GET ${fullUrl}`);
60
+ return this.axios.get(fullUrl, {
61
+ headers: this.buildHeaders(),
62
+ validateStatus: () => true,
63
+ }).then(response => {
64
+ logger_1.logger.debug(`Response ${response.status}`);
65
+ return { status: response.status, data: response.data };
66
+ }).catch(err => {
67
+ if (err.response) {
68
+ return { status: err.response.status, data: err.response.data };
69
+ }
70
+ throw new logger_1.FatalError(err);
71
+ });
72
+ });
73
+ }
56
74
  getFile(url) {
57
75
  return __awaiter(this, void 0, void 0, function* () {
58
76
  return new Promise((resolve, reject) => {
@@ -228,11 +246,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
228
246
  return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(this.context.profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
229
247
  }
230
248
  buildAuthorizationHeaders(profile, contentType) {
231
- const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
232
- return {
233
- Authorization: `${authenticationType} ${profile.apiToken}`,
249
+ const headers = {
234
250
  "Content-Type": contentType !== null && contentType !== void 0 ? contentType : "application/json",
235
251
  };
252
+ if (profile.apiToken) {
253
+ const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
254
+ headers.Authorization = `${authenticationType} ${profile.apiToken}`;
255
+ }
256
+ return headers;
236
257
  }
237
258
  }
238
259
  exports.HttpClient = HttpClient;
@@ -13,59 +13,44 @@ 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", "fs", "path", "../../utils/logger", "../../utils/file.constants"], factory);
16
+ define(["require", "exports", "../../utils/logger", "../../utils/cui-file-service"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.BaseManager = void 0;
22
- const fs = require("fs");
23
- const path = require("path");
24
22
  const logger_1 = require("../../utils/logger");
25
- const file_constants_1 = require("../../utils/file.constants");
23
+ const cui_file_service_1 = require("../../utils/cui-file-service");
26
24
  class BaseManager {
27
25
  constructor(context) {
28
26
  this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
29
27
  this.httpClient = () => context.httpClient;
28
+ this.cuiFileService = new cui_file_service_1.CuiFileService(context);
30
29
  }
31
30
  pull() {
32
31
  return __awaiter(this, void 0, void 0, function* () {
33
- return new Promise((resolve, reject) => {
34
- this.httpClient()
35
- .get(this.getConfig().pullUrl)
36
- .then(data => {
37
- try {
38
- const filename = this.writeToFile(data);
39
- logger_1.logger.info(this.fileDownloadedMessage + filename);
40
- resolve();
41
- }
42
- catch (e) {
43
- logger_1.logger.error(new logger_1.FatalError(e));
44
- reject();
45
- }
46
- })
47
- .catch(err => {
48
- logger_1.logger.error(new logger_1.FatalError(err));
49
- reject();
50
- });
51
- });
32
+ try {
33
+ const data = yield this.httpClient().get(this.getConfig().pullUrl);
34
+ const filename = yield this.writeToFile(data);
35
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
36
+ }
37
+ catch (err) {
38
+ logger_1.logger.error(new logger_1.FatalError(err));
39
+ throw err;
40
+ }
52
41
  });
53
42
  }
54
43
  pullFile() {
55
44
  return __awaiter(this, void 0, void 0, function* () {
56
- return new Promise((resolve, reject) => {
57
- this.httpClient()
58
- .downloadFile(this.getConfig().pullUrl)
59
- .then(data => {
60
- const filename = this.writeStreamToFile(data);
61
- logger_1.logger.info(this.fileDownloadedMessage + filename);
62
- resolve();
63
- })
64
- .catch(err => {
65
- logger_1.logger.error(new logger_1.FatalError(err));
66
- reject();
67
- });
68
- });
45
+ try {
46
+ const data = yield this.httpClient().downloadFile(this.getConfig().pullUrl);
47
+ const filename = yield this.writeStreamToFile(data);
48
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
49
+ }
50
+ catch (err) {
51
+ logger_1.logger.error(new logger_1.FatalError(err));
52
+ throw err;
53
+ }
69
54
  });
70
55
  }
71
56
  push() {
@@ -102,34 +87,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
102
87
  }
103
88
  findAll() {
104
89
  return __awaiter(this, void 0, void 0, function* () {
105
- return new Promise((resolve, reject) => {
106
- this.httpClient()
107
- .get(this.getConfig().findAllUrl)
108
- .then(data => {
109
- this.getConfig().onFindAll(data);
110
- resolve(data);
111
- })
112
- .catch(err => {
113
- logger_1.logger.error(new logger_1.FatalError(err));
114
- reject();
115
- });
116
- });
90
+ try {
91
+ const data = yield this.httpClient().get(this.getConfig().findAllUrl);
92
+ yield this.getConfig().onFindAll(data);
93
+ return data;
94
+ }
95
+ catch (err) {
96
+ logger_1.logger.error(new logger_1.FatalError(err));
97
+ throw err;
98
+ }
117
99
  });
118
100
  }
119
101
  writeToFile(data) {
120
- const filename = this.getConfig().exportFileName;
121
- this.writeToFileWithGivenName(data, filename);
122
- return filename;
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ return this.cuiFileService.writeToFileWithGivenName(this.getSerializedFileContent(data), this.getConfig().exportFileName);
104
+ });
123
105
  }
124
106
  writeStreamToFile(data) {
125
- const filename = this.getConfig().exportFileName;
126
- fs.writeFileSync(filename, data, { mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS });
127
- return filename;
128
- }
129
- writeToFileWithGivenName(data, filename) {
130
- fs.writeFileSync(path.resolve(process.cwd(), filename), this.getSerializedFileContent(data), {
131
- encoding: "utf-8",
132
- mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ return this.cuiFileService.writeZipToFileWithGivenName(data, this.getConfig().exportFileName);
133
109
  });
134
110
  }
135
111
  }