@celonis/content-cli 1.9.1 → 1.11.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 (43) hide show
  1. package/README.md +1 -1
  2. package/commands/action-flows/action-flow/action-flow.service.js +5 -4
  3. package/commands/asset-registry/asset-registry-api.js +16 -19
  4. package/commands/asset-registry/asset-registry-error.js +57 -0
  5. package/commands/asset-registry/asset-registry.service.js +86 -8
  6. package/commands/asset-registry/module.js +27 -5
  7. package/commands/configuration-management/api/batch-import-export-api.js +14 -2
  8. package/commands/configuration-management/api/node-api.js +31 -0
  9. package/commands/configuration-management/api/node-diff-api.js +15 -1
  10. package/commands/configuration-management/batch-import-export.service.js +30 -13
  11. package/commands/configuration-management/config-command.service.js +12 -10
  12. package/commands/configuration-management/module.js +57 -5
  13. package/commands/configuration-management/node-diff.service.js +40 -17
  14. package/commands/configuration-management/node.service.js +54 -0
  15. package/commands/configuration-management/studio.service.js +3 -2
  16. package/commands/studio/manager/widget.manager-factory.js +3 -2
  17. package/core/git-profile/git/git.service.js +4 -3
  18. package/core/git-profile/git-profile.service.js +5 -3
  19. package/core/http/http-shared/base.manager.js +4 -2
  20. package/core/profile/profile.service.js +5 -3
  21. package/core/utils/branches.js +23 -0
  22. package/core/utils/file-service.js +25 -8
  23. package/core/utils/file.constants.js +18 -0
  24. package/core/utils/logger.js +3 -2
  25. package/lib/commands/asset-registry/asset-registry-api.d.ts +3 -2
  26. package/lib/commands/asset-registry/asset-registry-error.d.ts +3 -0
  27. package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +21 -1
  28. package/lib/commands/asset-registry/asset-registry.service.d.ts +7 -1
  29. package/lib/commands/asset-registry/module.d.ts +2 -1
  30. package/lib/commands/configuration-management/api/batch-import-export-api.d.ts +3 -2
  31. package/lib/commands/configuration-management/api/node-api.d.ts +4 -1
  32. package/lib/commands/configuration-management/api/node-diff-api.d.ts +2 -1
  33. package/lib/commands/configuration-management/batch-import-export.service.d.ts +5 -4
  34. package/lib/commands/configuration-management/config-command.service.d.ts +1 -1
  35. package/lib/commands/configuration-management/interfaces/node-diff.interfaces.d.ts +8 -0
  36. package/lib/commands/configuration-management/interfaces/node.interfaces.d.ts +20 -0
  37. package/lib/commands/configuration-management/module.d.ts +3 -0
  38. package/lib/commands/configuration-management/node-diff.service.d.ts +3 -0
  39. package/lib/commands/configuration-management/node.service.d.ts +4 -0
  40. package/lib/core/utils/branches.d.ts +4 -0
  41. package/lib/core/utils/file-service.d.ts +1 -0
  42. package/lib/core/utils/file.constants.d.ts +4 -0
  43. package/package.json +1 -1
@@ -29,20 +29,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
29
  this.variableService = new variable_service_1.VariableService(context);
30
30
  this.diffService = new diff_service_1.DiffService(context);
31
31
  }
32
- listPackages(jsonResponse, flavors, withDependencies, packageKeys, keysByVersion, variableValue, variableType) {
32
+ listPackages(jsonResponse, flavors, withDependencies, packageKeys, keysByVersion, variableValue, variableType, includeBranches, staging) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- if (variableValue) {
35
- yield this.listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType);
36
- return;
34
+ if (staging) {
35
+ yield this.batchImportExportService.listStagingPackages(flavors !== null && flavors !== void 0 ? flavors : [], includeBranches, jsonResponse);
37
36
  }
38
- if (jsonResponse) {
39
- yield this.batchImportExportService.findAndExportListOfPackages(flavors !== null && flavors !== void 0 ? flavors : [], packageKeys !== null && packageKeys !== void 0 ? packageKeys : [], keysByVersion !== null && keysByVersion !== void 0 ? keysByVersion : [], withDependencies);
37
+ else if (variableValue) {
38
+ yield this.listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType, includeBranches);
39
+ }
40
+ else if (jsonResponse) {
41
+ yield this.batchImportExportService.findAndExportListOfPackages(flavors !== null && flavors !== void 0 ? flavors : [], packageKeys !== null && packageKeys !== void 0 ? packageKeys : [], keysByVersion !== null && keysByVersion !== void 0 ? keysByVersion : [], withDependencies, includeBranches);
40
42
  }
41
43
  else if (keysByVersion) {
42
44
  yield this.batchImportExportService.listPackagesByKeysWithVersion(keysByVersion, withDependencies);
43
45
  }
44
46
  else {
45
- yield this.batchImportExportService.listActivePackages(flavors !== null && flavors !== void 0 ? flavors : []);
47
+ yield this.batchImportExportService.listActivePackages(flavors !== null && flavors !== void 0 ? flavors : [], includeBranches);
46
48
  }
47
49
  });
48
50
  }
@@ -92,13 +94,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
92
94
  diffPackages(file, hasChanges, jsonResponse) {
93
95
  return this.diffService.diffPackages(file, hasChanges, jsonResponse);
94
96
  }
95
- listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType) {
97
+ listPackagesByVariableValue(jsonResponse, flavors, variableValue, variableType, includeBranches) {
96
98
  return __awaiter(this, void 0, void 0, function* () {
97
99
  if (jsonResponse) {
98
- yield this.batchImportExportService.findAndExportListOfActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType);
100
+ yield this.batchImportExportService.findAndExportListOfActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType, includeBranches);
99
101
  }
100
102
  else {
101
- yield this.batchImportExportService.listActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType);
103
+ yield this.batchImportExportService.listActivePackagesByVariableValue(flavors !== null && flavors !== void 0 ? flavors : [], variableValue, variableType, includeBranches);
102
104
  }
103
105
  });
104
106
  }
@@ -34,12 +34,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
34
  configCommand.command("list")
35
35
  .description("Command to list packages")
36
36
  .option("--json", "Return response as json type", "")
37
- .option("--flavors <flavors...>", "Lists only active packages of the given flavors")
37
+ .option("--flavors <flavors...>", "Lists only packages of the given flavors")
38
38
  .option("--withDependencies", "Include dependencies", "")
39
39
  .option("--packageKeys <packageKeys...>", "Lists only active versions of given package keys")
40
40
  .option("--keysByVersion <keysByVersion...>", "Lists packages by given key and version [packageKey.version]")
41
41
  .option("--variableValue <variableValue>", "Variable value for filtering packages by.")
42
42
  .option("--variableType <variableType>", "Variable type for filtering packages by.")
43
+ .option("--branches", "Include branches", false)
44
+ .option("--staging", "List staging packages instead", false)
43
45
  .action(this.listPackages);
44
46
  configCommand.command("export")
45
47
  .description("Command to export package configs")
@@ -70,7 +72,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
70
72
  configCommand.command("validate")
71
73
  .description("Validate package node configurations")
72
74
  .requiredOption("--packageKey <packageKey>", "Key of the package to validate")
73
- .option("--layers <layers...>", "Validation layers to run", ["SCHEMA"])
75
+ .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
76
  .option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
75
77
  .option("--json", "Return the response as a JSON file")
76
78
  .action(this.validatePackage);
@@ -116,6 +118,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
116
118
  .option("--withConfiguration", "Include node configuration in the response", false)
117
119
  .option("--json", "Return the response as a JSON file")
118
120
  .action(this.findNode);
121
+ nodesCommand.command("create")
122
+ .description("Create a new staging node in a package")
123
+ .requiredOption("--packageKey <packageKey>", "Identifier of the package")
124
+ .option("--body <body>", "Node payload as JSON string")
125
+ .option("-f, --file <file>", "Path to a JSON file containing the node payload")
126
+ .option("--validate", "Only validate the payload without persisting. Returns success if valid.", false)
127
+ .option("--json", "Return the response as a JSON file")
128
+ .action(this.createNode);
129
+ nodesCommand.command("update")
130
+ .description("Update a staging node in a package")
131
+ .requiredOption("--packageKey <packageKey>", "Identifier of the package")
132
+ .requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
133
+ .option("--body <body>", "Node payload as JSON string")
134
+ .option("-f, --file <file>", "Path to a JSON file containing the node payload")
135
+ .option("--validate", "Only validate the payload without persisting. Returns success if valid.", false)
136
+ .option("--json", "Return the response as a JSON file")
137
+ .action(this.updateNode);
138
+ nodesCommand.command("archive")
139
+ .description("Archive a staging node in a package")
140
+ .requiredOption("--packageKey <packageKey>", "Identifier of the package")
141
+ .requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
142
+ .option("--force", "Force archive even if the node has dependants", false)
143
+ .action(this.archiveNode);
119
144
  nodesCommand.command("list")
120
145
  .description("List nodes in a specific package version")
121
146
  .requiredOption("--packageKey <packageKey>", "Identifier of the package")
@@ -130,7 +155,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
130
155
  .requiredOption("--packageKey <packageKey>", "Identifier of the package")
131
156
  .requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
132
157
  .requiredOption("--baseVersion <baseVersion>", "Base version of the node")
133
- .requiredOption("--compareVersion <compareVersion>", "Compare version of the node")
158
+ .option("--compareVersion <compareVersion>", "Compare version of the node, mutually exclusive with --file (exactly one required)")
159
+ .option("-f, --file <file>", "Local node JSON file to diff against the base version, mutually exclusive with --compareVersion (exactly one required)")
134
160
  .option("--json", "Return the response as a JSON file")
135
161
  .action(this.diffNode);
136
162
  const nodeDependenciesCommand = nodesCommand.command("dependencies")
@@ -152,10 +178,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
152
178
  }
153
179
  listPackages(context, command, options) {
154
180
  return __awaiter(this, void 0, void 0, function* () {
181
+ if (options.staging && (options.withDependencies || options.packageKeys || options.keysByVersion || options.variableValue || options.variableType)) {
182
+ throw new Error("Staging parameter is not compatible with --withDependencies, --packageKeys, --keysByVersion, --variableValue, --variableType");
183
+ }
155
184
  if (options.packageKeys && options.keysByVersion) {
156
185
  throw new Error("Please provide either --packageKeys or --keysByVersion, but not both.");
157
186
  }
158
- yield new config_command_service_1.ConfigCommandService(context).listPackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType);
187
+ yield new config_command_service_1.ConfigCommandService(context).listPackages(options.json, options.flavors, options.withDependencies, options.packageKeys, options.keysByVersion, options.variableValue, options.variableType, options.branches, options.staging);
159
188
  });
160
189
  }
161
190
  batchExportPackages(context, command, options) {
@@ -236,6 +265,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
236
265
  yield new node_service_1.NodeService(context).findNode(options.packageKey, options.nodeKey, options.withConfiguration, (_a = options.packageVersion) !== null && _a !== void 0 ? _a : null, options.json);
237
266
  });
238
267
  }
268
+ createNode(context, command, options) {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ yield new node_service_1.NodeService(context).createNode(options.packageKey, options.body, options.file, options.validate, options.json);
271
+ });
272
+ }
273
+ updateNode(context, command, options) {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ yield new node_service_1.NodeService(context).updateNode(options.packageKey, options.nodeKey, options.body, options.file, options.validate, options.json);
276
+ });
277
+ }
278
+ archiveNode(context, command, options) {
279
+ return __awaiter(this, void 0, void 0, function* () {
280
+ yield new node_service_1.NodeService(context).archiveNode(options.packageKey, options.nodeKey, options.force);
281
+ });
282
+ }
239
283
  listNodes(context, command, options) {
240
284
  return __awaiter(this, void 0, void 0, function* () {
241
285
  yield new node_service_1.NodeService(context).listNodes(options.packageKey, options.packageVersion, options.limit, options.offset, options.withConfiguration, options.json);
@@ -243,7 +287,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
243
287
  }
244
288
  diffNode(context, command, options) {
245
289
  return __awaiter(this, void 0, void 0, function* () {
246
- yield new node_diff_service_1.NodeDiffService(context).diff(options.packageKey, options.nodeKey, options.baseVersion, options.compareVersion, options.json);
290
+ if ((options.file && options.compareVersion) || (!options.file && !options.compareVersion)) {
291
+ throw new Error("Please provide either --compareVersion or --file, but not both.");
292
+ }
293
+ if (options.file) {
294
+ yield new node_diff_service_1.NodeDiffService(context).diffWithFile(options.packageKey, options.nodeKey, options.baseVersion, options.file, options.json);
295
+ }
296
+ else {
297
+ yield new node_diff_service_1.NodeDiffService(context).diff(options.packageKey, options.nodeKey, options.baseVersion, options.compareVersion, options.json);
298
+ }
247
299
  });
248
300
  }
249
301
  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
  });
@@ -57,6 +57,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
57
57
  }
58
58
  });
59
59
  }
60
+ createNode(packageKey, body, file, validateOnly, jsonResponse) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const transport = JSON.parse(NodeService.resolveBody(body, file));
63
+ const node = yield this.nodeApi.createStagingNode(packageKey, transport, validateOnly);
64
+ if (validateOnly) {
65
+ logger_1.logger.info(`Validation successful for node ${transport.key} in package ${packageKey}.`);
66
+ return;
67
+ }
68
+ if (jsonResponse) {
69
+ const filename = (0, uuid_1.v4)() + ".json";
70
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(node, null, 2), filename);
71
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
72
+ }
73
+ else {
74
+ this.printNode(node);
75
+ }
76
+ });
77
+ }
78
+ updateNode(packageKey, nodeKey, body, file, validateOnly, jsonResponse) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const transport = JSON.parse(NodeService.resolveBody(body, file));
81
+ const node = yield this.nodeApi.updateStagingNode(packageKey, nodeKey, transport, validateOnly);
82
+ if (validateOnly) {
83
+ logger_1.logger.info(`Validation successful for node ${nodeKey} in package ${packageKey}.`);
84
+ return;
85
+ }
86
+ if (jsonResponse) {
87
+ const filename = (0, uuid_1.v4)() + ".json";
88
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(node, null, 2), filename);
89
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
90
+ }
91
+ else {
92
+ this.printNode(node);
93
+ }
94
+ });
95
+ }
96
+ archiveNode(packageKey, nodeKey, force) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ yield this.nodeApi.archiveStagingNode(packageKey, nodeKey, force);
99
+ logger_1.logger.info(`Node ${nodeKey} in package ${packageKey} archived successfully.`);
100
+ });
101
+ }
102
+ static resolveBody(body, file) {
103
+ if (body && file) {
104
+ throw new Error("Please provide either --body or --file, but not both.");
105
+ }
106
+ if (!body && !file) {
107
+ throw new Error("Please provide either --body or --file.");
108
+ }
109
+ if (file) {
110
+ return file_service_1.fileService.readFile(file);
111
+ }
112
+ return body;
113
+ }
60
114
  printNode(node) {
61
115
  logger_1.logger.info(`ID: ${node.id}`);
62
116
  logger_1.logger.info(`Key: ${node.key}`);
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "adm-zip", "../studio/interfaces/package-manager.interfaces", "./interfaces/batch-export-import.constants", "../../core/utils/json", "../studio/api/package-api", "../studio/service/data-model.service", "../studio/api/node-api", "../studio/api/space-api", "../studio/api/studio-variables-api", "../studio/service/space.service", "../studio/service/studio-variable.service"], factory);
16
+ define(["require", "exports", "adm-zip", "../studio/interfaces/package-manager.interfaces", "./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";
@@ -30,6 +30,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
30
30
  const studio_variables_api_1 = require("../studio/api/studio-variables-api");
31
31
  const space_service_1 = require("../studio/service/space.service");
32
32
  const studio_variable_service_1 = require("../studio/service/studio-variable.service");
33
+ const branches_1 = require("../../core/utils/branches");
33
34
  class StudioService {
34
35
  constructor(context) {
35
36
  this.studioPackageApi = new package_api_1.PackageApi(context);
@@ -89,7 +90,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
89
90
  }
90
91
  for (const manifest of studioManifests) {
91
92
  const existingPackage = existingStudioPackages.find(existingPackage => existingPackage.key === manifest.packageKey);
92
- if (existingPackage) {
93
+ if (existingPackage && !branches_1.BranchUtils.isBranchPackageKey(existingPackage.key)) {
93
94
  yield this.studioPackageApi.movePackageToSpace(existingPackage.id, manifest.space.id);
94
95
  }
95
96
  yield this.assignRuntimeVariables(manifest);
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "fs", "path", "./widget.manager", "../../../core/utils/logger", "adm-zip", "../../../core/utils/yaml"], factory);
7
+ define(["require", "exports", "fs", "path", "./widget.manager", "../../../core/utils/logger", "adm-zip", "../../../core/utils/yaml", "../../../core/utils/file.constants"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -16,6 +16,7 @@
16
16
  const logger_1 = require("../../../core/utils/logger");
17
17
  const AdmZip = require("adm-zip");
18
18
  const yaml_1 = require("../../../core/utils/yaml");
19
+ const file_constants_1 = require("../../../core/utils/file.constants");
19
20
  class WidgetManagerFactory {
20
21
  constructor(context) {
21
22
  this.context = context;
@@ -36,7 +37,7 @@
36
37
  const zip = new AdmZip();
37
38
  const zipFileName = path.resolve(process.cwd(), "output.zip");
38
39
  zip.addLocalFolder(path.resolve(process.cwd()));
39
- zip.writeZip(zipFileName);
40
+ zip.writeZip(zipFileName, () => fs.chmodSync(zipFileName, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
40
41
  return fs.createReadStream(path.resolve(process.cwd(), "output.zip"));
41
42
  }
42
43
  fetchManifest() {
@@ -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", "simple-git", "fs", "path", "node:os", "uuid"], factory);
16
+ define(["require", "exports", "simple-git", "fs", "path", "node:os", "uuid", "../../utils/file.constants"], 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 path = require("path");
25
25
  const os = require("node:os");
26
26
  const uuid_1 = require("uuid");
27
+ const file_constants_1 = require("../../utils/file.constants");
27
28
  class GitService {
28
29
  constructor(context) {
29
30
  this.gitProfile = context.gitProfile;
@@ -33,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
34
  this.validateGitProfileExistence();
34
35
  const repoUrl = this.getRepoUrl();
35
36
  const targetDir = path.join(os.tmpdir(), `content-cli-${(0, uuid_1.v4)()}`);
36
- fs.mkdirSync(targetDir, { recursive: true });
37
+ fs.mkdirSync(targetDir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
37
38
  const git = (0, simple_git_1.default)();
38
39
  try {
39
40
  yield git.clone(repoUrl, targetDir, ["--branch", branch, "--single-branch"]);
@@ -50,7 +51,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
50
51
  return __awaiter(this, void 0, void 0, function* () {
51
52
  this.validateGitProfileExistence();
52
53
  const workingDir = path.join(os.tmpdir(), `content-cli-${(0, uuid_1.v4)()}`);
53
- fs.mkdirSync(workingDir, { recursive: true });
54
+ fs.mkdirSync(workingDir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
54
55
  const repoUrl = this.getRepoUrl();
55
56
  const git = (0, simple_git_1.default)();
56
57
  try {
@@ -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", "path", "fs", "../utils/logger", "os", "./git-profile.interface", "./git-profile.validator"], factory);
16
+ define(["require", "exports", "path", "fs", "../utils/logger", "os", "./git-profile.interface", "./git-profile.validator", "../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 os = require("os");
26
26
  const git_profile_interface_1 = require("./git-profile.interface");
27
27
  const git_profile_validator_1 = require("./git-profile.validator");
28
+ const file_constants_1 = require("../utils/file.constants");
28
29
  class GitProfileService {
29
30
  constructor() {
30
31
  this.homedir = os.homedir();
@@ -79,6 +80,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
79
80
  const newProfileFileName = this.constructProfileFileName(profile.name);
80
81
  fs.writeFileSync(path.resolve(this.gitProfileContainerPath, newProfileFileName), JSON.stringify(profile), {
81
82
  encoding: "utf-8",
83
+ mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
82
84
  });
83
85
  }
84
86
  validateProfileName(name) {
@@ -101,11 +103,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
101
103
  });
102
104
  }
103
105
  storeConfig(config) {
104
- fs.writeFileSync(this.configContainer, JSON.stringify(config), { encoding: "utf-8" });
106
+ fs.writeFileSync(this.configContainer, JSON.stringify(config), { encoding: "utf-8", mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS });
105
107
  }
106
108
  createProfileContainerIfNotExists() {
107
109
  if (!fs.existsSync(this.gitProfileContainerPath)) {
108
- fs.mkdirSync(this.gitProfileContainerPath);
110
+ fs.mkdirSync(this.gitProfileContainerPath, file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS);
109
111
  }
110
112
  }
111
113
  constructProfileFileName(profileName) {
@@ -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", "fs", "path", "../../utils/logger"], factory);
16
+ define(["require", "exports", "fs", "path", "../../utils/logger", "../../utils/file.constants"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -22,6 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  const fs = require("fs");
23
23
  const path = require("path");
24
24
  const logger_1 = require("../../utils/logger");
25
+ const file_constants_1 = require("../../utils/file.constants");
25
26
  class BaseManager {
26
27
  constructor(context) {
27
28
  this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
@@ -122,12 +123,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
122
123
  }
123
124
  writeStreamToFile(data) {
124
125
  const filename = this.getConfig().exportFileName;
125
- fs.writeFileSync(filename, data);
126
+ fs.writeFileSync(filename, data, { mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS });
126
127
  return filename;
127
128
  }
128
129
  writeToFileWithGivenName(data, filename) {
129
130
  fs.writeFileSync(path.resolve(process.cwd(), filename), this.getSerializedFileContent(data), {
130
131
  encoding: "utf-8",
132
+ mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
131
133
  });
132
134
  }
133
135
  }
@@ -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", "./profile.interface", "./profile.validator", "path", "fs", "../utils/logger", "openid-client", "axios", "os", "./secret-storage.service"], factory);
16
+ define(["require", "exports", "./profile.interface", "./profile.validator", "path", "fs", "../utils/logger", "openid-client", "axios", "os", "./secret-storage.service", "../utils/file.constants"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -28,6 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28
28
  const axios_1 = require("axios");
29
29
  const os = require("os");
30
30
  const secret_storage_service_1 = require("./secret-storage.service");
31
+ const file_constants_1 = require("../utils/file.constants");
31
32
  const homedir = os.homedir();
32
33
  // use 5 seconds buffer to avoid rare cases when accessToken is just about to expire before the command is sent
33
34
  const expiryBuffer = 5000;
@@ -131,6 +132,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
131
132
  }
132
133
  fs.writeFileSync(path.resolve(this.profileContainerPath, newProfileFileName), JSON.stringify(profileToStore), {
133
134
  encoding: "utf-8",
135
+ mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
134
136
  });
135
137
  });
136
138
  }
@@ -149,11 +151,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
149
151
  });
150
152
  }
151
153
  storeConfig(config) {
152
- fs.writeFileSync(this.configContainer, JSON.stringify(config), { encoding: "utf-8" });
154
+ fs.writeFileSync(this.configContainer, JSON.stringify(config), { encoding: "utf-8", mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS });
153
155
  }
154
156
  createProfileContainerIfNotExists() {
155
157
  if (!fs.existsSync(this.profileContainerPath)) {
156
- fs.mkdirSync(this.profileContainerPath);
158
+ fs.mkdirSync(this.profileContainerPath, file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS);
157
159
  }
158
160
  }
159
161
  constructProfileFileName(profileName) {
@@ -0,0 +1,23 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BranchUtils = void 0;
13
+ class BranchUtils {
14
+ static isBranchPackageKey(packageKey) {
15
+ if (!packageKey || packageKey.trim().length === 0) {
16
+ throw new Error("Package key cannot be empty");
17
+ }
18
+ return packageKey.includes(BranchUtils.BRANCH_SEPARATOR);
19
+ }
20
+ }
21
+ exports.BranchUtils = BranchUtils;
22
+ BranchUtils.BRANCH_SEPARATOR = "@";
23
+ });
@@ -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", "fs", "path", "./logger", "adm-zip", "uuid", "node:os"], factory);
16
+ define(["require", "exports", "fs", "path", "./logger", "adm-zip", "uuid", "node:os", "./file.constants"], 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 AdmZip = require("adm-zip");
26
26
  const uuid_1 = require("uuid");
27
27
  const os = require("node:os");
28
+ const file_constants_1 = require("./file.constants");
28
29
  class FileService {
29
30
  writeToFileWithGivenName(data, filename) {
30
31
  fs.writeFileSync(path.resolve(process.cwd(), filename), this.getSerializedFileContent(data), {
31
32
  encoding: "utf-8",
33
+ mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
32
34
  });
33
35
  }
34
36
  readFileToJson(fileName) {
@@ -45,22 +47,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
45
47
  }
46
48
  extractExportedZipWithNestedZips(zipFile) {
47
49
  const tempDir = path.join(os.tmpdir(), `${(0, uuid_1.v4)()}`);
48
- fs.mkdirSync(tempDir, { recursive: true });
49
50
  return this.extractExportedZipWithNestedZipsToDir(zipFile, tempDir);
50
51
  }
51
52
  extractExportedZipWithNestedZipsToDir(zipFile, targetDir) {
52
- zipFile.extractAllTo(targetDir, true);
53
+ fs.mkdirSync(targetDir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
54
+ zipFile.extractAllTo(targetDir, true, true);
53
55
  const files = fs.readdirSync(targetDir);
54
56
  for (const file of files) {
55
57
  const innerZipPath = path.join(targetDir, file);
56
58
  if (file.endsWith(".zip")) {
57
59
  const nestedZip = new AdmZip(innerZipPath);
58
60
  const nestedDir = innerZipPath.replace(/\.zip$/, "");
59
- fs.mkdirSync(nestedDir, { recursive: true });
60
- nestedZip.extractAllTo(nestedDir, true);
61
+ fs.mkdirSync(nestedDir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
62
+ nestedZip.extractAllTo(nestedDir, true, true);
61
63
  fs.rmSync(innerZipPath); // Optionally remove the inner zip
62
64
  }
63
65
  }
66
+ this.restrictFilePermissions(targetDir);
64
67
  return targetDir;
65
68
  }
66
69
  isDirectory(sourcePath) {
@@ -80,21 +83,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
80
83
  const zip = new AdmZip();
81
84
  zip.addLocalFolder(fullPath);
82
85
  const zippedBuffer = zip.toBuffer();
83
- finalZip.addFile(`${file}.zip`, zippedBuffer);
86
+ finalZip.addFile(`${file}.zip`, zippedBuffer, "", file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS);
84
87
  }
85
88
  else if (stat.isFile()) {
86
89
  finalZip.addLocalFile(fullPath);
87
90
  }
88
91
  });
89
92
  const tempDir = path.join(os.tmpdir(), "content-cli-exports");
90
- fs.mkdirSync(tempDir, { recursive: true });
93
+ fs.mkdirSync(tempDir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
91
94
  const zipFilePath = path.join(tempDir, `export_${(0, uuid_1.v4)()}.zip`);
92
- finalZip.writeZip(zipFilePath);
95
+ finalZip.writeZip(zipFilePath, () => fs.chmodSync(zipFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
93
96
  return zipFilePath;
94
97
  }
95
98
  getSerializedFileContent(data) {
96
99
  return data;
97
100
  }
101
+ restrictFilePermissions(targetDir) {
102
+ var _a;
103
+ const files = fs.readdirSync(targetDir);
104
+ for (const file of files) {
105
+ const filePath = path.join(targetDir, file);
106
+ if ((_a = fs.statSync(filePath)) === null || _a === void 0 ? void 0 : _a.isDirectory()) {
107
+ fs.chmodSync(filePath, file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS);
108
+ this.restrictFilePermissions(filePath);
109
+ }
110
+ else {
111
+ fs.chmodSync(filePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS);
112
+ }
113
+ }
114
+ }
98
115
  }
99
116
  exports.FileService = FileService;
100
117
  FileService.fileDownloadedMessage = "File downloaded successfully. New filename: ";