@celonis/content-cli 1.8.1 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/commands/asset-registry/asset-registry-api.js +74 -0
  2. package/commands/asset-registry/asset-registry.interfaces.js +12 -0
  3. package/commands/asset-registry/asset-registry.service.js +115 -0
  4. package/commands/asset-registry/module.js +78 -0
  5. package/commands/configuration-management/api/batch-import-export-api.js +2 -2
  6. package/commands/configuration-management/api/package-validation-api.js +36 -0
  7. package/commands/configuration-management/batch-import-export.service.js +2 -2
  8. package/commands/configuration-management/config-command.service.js +2 -2
  9. package/commands/configuration-management/interfaces/package-validation.interfaces.js +12 -0
  10. package/commands/configuration-management/module.js +16 -2
  11. package/commands/configuration-management/package-validation.service.js +62 -0
  12. package/lib/commands/asset-registry/asset-registry-api.d.ts +11 -0
  13. package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +30 -0
  14. package/lib/commands/asset-registry/asset-registry.service.d.ts +13 -0
  15. package/lib/commands/asset-registry/module.d.ts +11 -0
  16. package/lib/commands/configuration-management/api/batch-import-export-api.d.ts +1 -1
  17. package/lib/commands/configuration-management/api/package-validation-api.d.ts +7 -0
  18. package/lib/commands/configuration-management/batch-import-export.service.d.ts +1 -1
  19. package/lib/commands/configuration-management/config-command.service.d.ts +1 -1
  20. package/lib/commands/configuration-management/interfaces/package-validation.interfaces.d.ts +25 -0
  21. package/lib/commands/configuration-management/module.d.ts +1 -0
  22. package/lib/commands/configuration-management/package-validation.service.d.ts +7 -0
  23. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../../core/utils/logger"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.AssetRegistryApi = void 0;
22
+ const logger_1 = require("../../core/utils/logger");
23
+ class AssetRegistryApi {
24
+ constructor(context) {
25
+ this.httpClient = () => context.httpClient;
26
+ }
27
+ listTypes() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.httpClient()
30
+ .get("/pacman/api/core/asset-registry/types")
31
+ .catch((e) => {
32
+ throw new logger_1.FatalError(`Problem listing asset registry types: ${e}`);
33
+ });
34
+ });
35
+ }
36
+ getType(assetType) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return this.httpClient()
39
+ .get(`/pacman/api/core/asset-registry/types/${encodeURIComponent(assetType)}`)
40
+ .catch((e) => {
41
+ throw new logger_1.FatalError(`Problem getting asset type '${assetType}': ${e}`);
42
+ });
43
+ });
44
+ }
45
+ getSchema(assetType) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ return this.httpClient()
48
+ .get(`/pacman/api/core/asset-registry/schemas/${encodeURIComponent(assetType)}`)
49
+ .catch((e) => {
50
+ throw new logger_1.FatalError(`Problem getting schema for asset type '${assetType}': ${e}`);
51
+ });
52
+ });
53
+ }
54
+ getExamples(assetType) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return this.httpClient()
57
+ .get(`/pacman/api/core/asset-registry/examples/${encodeURIComponent(assetType)}`)
58
+ .catch((e) => {
59
+ throw new logger_1.FatalError(`Problem getting examples for asset type '${assetType}': ${e}`);
60
+ });
61
+ });
62
+ }
63
+ getMethodology(assetType) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ return this.httpClient()
66
+ .get(`/pacman/api/core/asset-registry/methodologies/${encodeURIComponent(assetType)}`)
67
+ .catch((e) => {
68
+ throw new logger_1.FatalError(`Problem getting methodology for asset type '${assetType}': ${e}`);
69
+ });
70
+ });
71
+ }
72
+ }
73
+ exports.AssetRegistryApi = AssetRegistryApi;
74
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,115 @@
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", "./asset-registry-api", "../../core/utils/file-service", "../../core/utils/logger", "uuid"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.AssetRegistryService = void 0;
22
+ const asset_registry_api_1 = require("./asset-registry-api");
23
+ const file_service_1 = require("../../core/utils/file-service");
24
+ const logger_1 = require("../../core/utils/logger");
25
+ const uuid_1 = require("uuid");
26
+ class AssetRegistryService {
27
+ constructor(context) {
28
+ this.api = new asset_registry_api_1.AssetRegistryApi(context);
29
+ }
30
+ listTypes(jsonResponse) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const metadata = yield this.api.listTypes();
33
+ const descriptors = Object.values(metadata.types);
34
+ if (jsonResponse) {
35
+ const filename = (0, uuid_1.v4)() + ".json";
36
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(metadata), filename);
37
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
38
+ }
39
+ else {
40
+ if (descriptors.length === 0) {
41
+ logger_1.logger.info("No asset types registered.");
42
+ return;
43
+ }
44
+ descriptors.forEach((descriptor) => {
45
+ this.logDescriptorSummary(descriptor);
46
+ });
47
+ }
48
+ });
49
+ }
50
+ getType(assetType, jsonResponse) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const descriptor = yield this.api.getType(assetType);
53
+ if (jsonResponse) {
54
+ const filename = (0, uuid_1.v4)() + ".json";
55
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(descriptor), filename);
56
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
57
+ }
58
+ else {
59
+ this.logDescriptorDetail(descriptor);
60
+ }
61
+ });
62
+ }
63
+ getSchema(assetType, jsonResponse) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const data = yield this.api.getSchema(assetType);
66
+ this.outputResponse(data, jsonResponse);
67
+ });
68
+ }
69
+ getExamples(assetType, jsonResponse) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const data = yield this.api.getExamples(assetType);
72
+ this.outputResponse(data, jsonResponse);
73
+ });
74
+ }
75
+ getMethodology(assetType, jsonResponse) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const data = yield this.api.getMethodology(assetType);
78
+ this.outputResponse(data, jsonResponse);
79
+ });
80
+ }
81
+ outputResponse(data, jsonResponse) {
82
+ if (jsonResponse) {
83
+ const filename = (0, uuid_1.v4)() + ".json";
84
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(data, null, 2), filename);
85
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
86
+ }
87
+ else {
88
+ logger_1.logger.info(typeof data === "string" ? data : JSON.stringify(data, null, 2));
89
+ }
90
+ }
91
+ logDescriptorSummary(descriptor) {
92
+ logger_1.logger.info(`${descriptor.assetType} - ${descriptor.displayName} [${descriptor.group}] (basePath: ${descriptor.service.basePath})`);
93
+ }
94
+ logDescriptorDetail(descriptor) {
95
+ logger_1.logger.info(`Asset Type: ${descriptor.assetType}`);
96
+ logger_1.logger.info(`Display Name: ${descriptor.displayName}`);
97
+ if (descriptor.description) {
98
+ logger_1.logger.info(`Description: ${descriptor.description}`);
99
+ }
100
+ logger_1.logger.info(`Group: ${descriptor.group}`);
101
+ logger_1.logger.info(`Schema: v${descriptor.assetSchema.version}`);
102
+ logger_1.logger.info(`Base Path: ${descriptor.service.basePath}`);
103
+ logger_1.logger.info(`Endpoints:`);
104
+ logger_1.logger.info(` schema: ${descriptor.endpoints.schema}`);
105
+ logger_1.logger.info(` validate: ${descriptor.endpoints.validate}`);
106
+ if (descriptor.endpoints.methodology) {
107
+ logger_1.logger.info(` methodology: ${descriptor.endpoints.methodology}`);
108
+ }
109
+ if (descriptor.endpoints.examples) {
110
+ logger_1.logger.info(` examples: ${descriptor.endpoints.examples}`);
111
+ }
112
+ }
113
+ }
114
+ exports.AssetRegistryService = AssetRegistryService;
115
+ });
@@ -0,0 +1,78 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../../core/command/module-handler", "./asset-registry.service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ const module_handler_1 = require("../../core/command/module-handler");
21
+ const asset_registry_service_1 = require("./asset-registry.service");
22
+ class Module extends module_handler_1.IModule {
23
+ register(context, configurator) {
24
+ const assetRegistryCommand = configurator.command("asset-registry")
25
+ .description("Manage the asset registry — discover registered asset types and their service descriptors.");
26
+ assetRegistryCommand.command("list")
27
+ .description("List all registered asset types")
28
+ .option("--json", "Return the response as a JSON file")
29
+ .action(this.listTypes);
30
+ assetRegistryCommand.command("get")
31
+ .description("Get the descriptor for a specific asset type")
32
+ .requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
33
+ .option("--json", "Return the response as a JSON file")
34
+ .action(this.getType);
35
+ assetRegistryCommand.command("schema")
36
+ .description("Get the JSON schema for an asset type's configuration")
37
+ .requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
38
+ .option("--json", "Return the response as a JSON file")
39
+ .action(this.getSchema);
40
+ assetRegistryCommand.command("examples")
41
+ .description("Get example configurations for an asset type")
42
+ .requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
43
+ .option("--json", "Return the response as a JSON file")
44
+ .action(this.getExamples);
45
+ assetRegistryCommand.command("methodology")
46
+ .description("Get the methodology / best-practices guide for an asset type")
47
+ .requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
48
+ .option("--json", "Return the response as a JSON file")
49
+ .action(this.getMethodology);
50
+ }
51
+ listTypes(context, command, options) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ yield new asset_registry_service_1.AssetRegistryService(context).listTypes(!!options.json);
54
+ });
55
+ }
56
+ getType(context, command, options) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ yield new asset_registry_service_1.AssetRegistryService(context).getType(options.assetType, !!options.json);
59
+ });
60
+ }
61
+ getSchema(context, command, options) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ yield new asset_registry_service_1.AssetRegistryService(context).getSchema(options.assetType, !!options.json);
64
+ });
65
+ }
66
+ getExamples(context, command, options) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ yield new asset_registry_service_1.AssetRegistryService(context).getExamples(options.assetType, !!options.json);
69
+ });
70
+ }
71
+ getMethodology(context, command, options) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ yield new asset_registry_service_1.AssetRegistryService(context).getMethodology(options.assetType, !!options.json);
74
+ });
75
+ }
76
+ }
77
+ return Module;
78
+ });
@@ -96,9 +96,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
96
96
  });
97
97
  });
98
98
  }
99
- importPackages(data, overwrite) {
99
+ importPackages(data, overwrite, performValidation) {
100
100
  return __awaiter(this, void 0, void 0, function* () {
101
- return this.httpClient().postFile("/package-manager/api/core/packages/import/batch", data, { overwrite });
101
+ return this.httpClient().postFile("/package-manager/api/core/packages/import/batch", data, { overwrite, performValidation });
102
102
  });
103
103
  }
104
104
  findVariablesWithValuesByPackageKeysAndVersion(packagesByKeyAndVersion) {
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../../../core/utils/logger"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PackageValidationApi = void 0;
22
+ const logger_1 = require("../../../core/utils/logger");
23
+ class PackageValidationApi {
24
+ constructor(context) {
25
+ this.httpClient = () => context.httpClient;
26
+ }
27
+ validatePackage(packageKey, request) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.httpClient().post(`/pacman/api/core/packages/${packageKey}/validate`, request).catch(e => {
30
+ throw new logger_1.FatalError(`Problem validating package "${packageKey}": ${e}`);
31
+ });
32
+ });
33
+ }
34
+ }
35
+ exports.PackageValidationApi = PackageValidationApi;
36
+ });
@@ -124,7 +124,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
124
124
  }
125
125
  });
126
126
  }
127
- batchImportPackages(sourcePath, overwrite, gitBranch) {
127
+ batchImportPackages(sourcePath, overwrite, gitBranch, performValidation = false) {
128
128
  return __awaiter(this, void 0, void 0, function* () {
129
129
  let sourceToBeImported;
130
130
  if (gitBranch) {
@@ -142,7 +142,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
142
142
  configs = yield this.studioService.mapSpaces(configs, studioManifests);
143
143
  const existingStudioPackages = yield this.studioPackageApi.findAllPackages();
144
144
  const formData = this.buildBodyForImport(configs, sourceToBeImported, variablesManifests);
145
- const postPackageImportData = yield this.batchImportExportApi.importPackages(formData, overwrite);
145
+ const postPackageImportData = yield this.batchImportExportApi.importPackages(formData, overwrite, performValidation);
146
146
  yield this.studioService.processImportedPackages(configs, existingStudioPackages, studioManifests);
147
147
  if (gitBranch) {
148
148
  fs.rmSync(sourceToBeImported);
@@ -70,7 +70,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
70
70
  batchExportPackagesMetadata(packageKeys, jsonResponse) {
71
71
  return this.batchImportExportService.batchExportPackagesMetadata(packageKeys, jsonResponse);
72
72
  }
73
- batchImportPackages(file, directory, overwrite, gitBranch) {
73
+ batchImportPackages(file, directory, overwrite, gitBranch, performValidation = false) {
74
74
  if ((directory || file) && gitBranch) {
75
75
  throw new Error("You cannot use both file/directory and gitBranch options at the same time. Only one import source can be defined.");
76
76
  }
@@ -87,7 +87,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
87
87
  throw new Error("The directory option accepts only directories.");
88
88
  }
89
89
  const sourcePath = file !== null && file !== void 0 ? file : directory;
90
- return this.batchImportExportService.batchImportPackages(sourcePath, overwrite, gitBranch);
90
+ return this.batchImportExportService.batchImportPackages(sourcePath, overwrite, gitBranch, performValidation);
91
91
  }
92
92
  diffPackages(file, hasChanges, jsonResponse) {
93
93
  return this.diffService.diffPackages(file, hasChanges, jsonResponse);
@@ -0,0 +1,12 @@
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
+ });
@@ -16,7 +16,7 @@ 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"], factory);
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);
20
20
  }
21
21
  })(function (require, exports) {
22
22
  "use strict";
@@ -27,6 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27
27
  const node_diff_service_1 = require("./node-diff.service");
28
28
  const node_dependency_service_1 = require("./node-dependency.service");
29
29
  const package_version_command_service_1 = require("./package-version-command.service");
30
+ const package_validation_service_1 = require("./package-validation.service");
30
31
  class Module extends module_handler_1.IModule {
31
32
  register(context, configurator) {
32
33
  const configCommand = configurator.command("config");
@@ -60,11 +61,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
60
61
  configCommand.command("import")
61
62
  .description("Command to import package configs")
62
63
  .option("--overwrite", "Flag to allow overwriting of packages")
64
+ .option("--validate", "Validate node configurations before import", false)
63
65
  .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
64
66
  .option("--gitBranch <gitBranch>", "Git branch from which you want to pull the exported file and import")
65
67
  .option("-f, --file <file>", "Exported packages file (relative path)")
66
68
  .option("-d, --directory <directory>", "Exported packages directory (relative path)")
67
69
  .action(this.batchImportPackages);
70
+ configCommand.command("validate")
71
+ .description("Validate package node configurations")
72
+ .requiredOption("--packageKey <packageKey>", "Key of the package to validate")
73
+ .option("--layers <layers...>", "Validation layers to run", ["SCHEMA"])
74
+ .option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
75
+ .option("--json", "Return the response as a JSON file")
76
+ .action(this.validatePackage);
68
77
  configCommand.command("diff")
69
78
  .description("Command to diff configs of packages")
70
79
  .option("--hasChanges", "Flag to return only the information if the package has changes without the actual changes")
@@ -190,7 +199,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
190
199
  if (options.gitProfile && !options.gitBranch) {
191
200
  throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
192
201
  }
193
- yield new config_command_service_1.ConfigCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch);
202
+ yield new config_command_service_1.ConfigCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch, options.validate);
194
203
  });
195
204
  }
196
205
  diffPackages(context, command, options) {
@@ -198,6 +207,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
198
207
  yield new config_command_service_1.ConfigCommandService(context).diffPackages(options.file, options.hasChanges, options.json);
199
208
  });
200
209
  }
210
+ validatePackage(context, command, options) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ yield new package_validation_service_1.PackageValidationService(context).validatePackage(options.packageKey, options.layers, options.nodeKeys, options.json);
213
+ });
214
+ }
201
215
  listVariables(context, command, options) {
202
216
  return __awaiter(this, void 0, void 0, function* () {
203
217
  const hasStagingKeys = options.packageKeys.length > 0;
@@ -0,0 +1,62 @@
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", "./api/package-validation-api", "../../core/utils/logger", "../../core/utils/file-service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PackageValidationService = void 0;
22
+ const uuid_1 = require("uuid");
23
+ const package_validation_api_1 = require("./api/package-validation-api");
24
+ const logger_1 = require("../../core/utils/logger");
25
+ const file_service_1 = require("../../core/utils/file-service");
26
+ class PackageValidationService {
27
+ constructor(context) {
28
+ this.packageValidationApi = new package_validation_api_1.PackageValidationApi(context);
29
+ }
30
+ validatePackage(packageKey, layers, nodeKeys, jsonOutput) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const request = { layers };
33
+ if (nodeKeys && nodeKeys.length > 0) {
34
+ request.nodeKeys = nodeKeys;
35
+ }
36
+ const response = yield this.packageValidationApi.validatePackage(packageKey, request);
37
+ if (jsonOutput) {
38
+ const reportFileName = "config_validate_report_" + (0, uuid_1.v4)() + ".json";
39
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(response), reportFileName);
40
+ logger_1.logger.info("Validation report file: " + reportFileName);
41
+ }
42
+ else {
43
+ this.printValidationResult(response);
44
+ }
45
+ });
46
+ }
47
+ printValidationResult(response) {
48
+ const status = response.valid ? "VALID" : "INVALID";
49
+ logger_1.logger.info("");
50
+ logger_1.logger.info(`Validation result: ${status}`);
51
+ logger_1.logger.info(`Errors: ${response.summary.errors} | Warnings: ${response.summary.warnings} | Info: ${response.summary.info}`);
52
+ if (response.results.length > 0) {
53
+ logger_1.logger.info("");
54
+ response.results.forEach((result) => {
55
+ const prefix = result.severity.toUpperCase().padEnd(7);
56
+ logger_1.logger.info(` ${prefix} ${result.nodeKey} (${result.assetType}) - ${result.message} [${result.code}]`);
57
+ });
58
+ }
59
+ }
60
+ }
61
+ exports.PackageValidationService = PackageValidationService;
62
+ });
@@ -0,0 +1,11 @@
1
+ import { Context } from "../../core/command/cli-context";
2
+ import { AssetRegistryDescriptor, AssetRegistryMetadata } from "./asset-registry.interfaces";
3
+ export declare class AssetRegistryApi {
4
+ private httpClient;
5
+ constructor(context: Context);
6
+ listTypes(): Promise<AssetRegistryMetadata>;
7
+ getType(assetType: string): Promise<AssetRegistryDescriptor>;
8
+ getSchema(assetType: string): Promise<any>;
9
+ getExamples(assetType: string): Promise<any>;
10
+ getMethodology(assetType: string): Promise<any>;
11
+ }
@@ -0,0 +1,30 @@
1
+ export interface AssetRegistryMetadata {
2
+ types: Record<string, AssetRegistryDescriptor>;
3
+ }
4
+ export interface AssetRegistryDescriptor {
5
+ assetType: string;
6
+ displayName: string;
7
+ description: string | null;
8
+ group: string;
9
+ assetSchema: AssetSchema;
10
+ service: AssetService;
11
+ endpoints: AssetEndpoints;
12
+ contributions: AssetContributions;
13
+ }
14
+ export interface AssetSchema {
15
+ version: string;
16
+ }
17
+ export interface AssetService {
18
+ basePath: string;
19
+ }
20
+ export interface AssetEndpoints {
21
+ schema: string;
22
+ validate: string;
23
+ methodology?: string;
24
+ examples?: string;
25
+ }
26
+ export interface AssetContributions {
27
+ pigEntityTypes: string[];
28
+ dataPipelineEntityTypes: string[];
29
+ actionTypes: string[];
30
+ }
@@ -0,0 +1,13 @@
1
+ import { Context } from "../../core/command/cli-context";
2
+ export declare class AssetRegistryService {
3
+ private api;
4
+ constructor(context: Context);
5
+ listTypes(jsonResponse: boolean): Promise<void>;
6
+ getType(assetType: string, jsonResponse: boolean): Promise<void>;
7
+ getSchema(assetType: string, jsonResponse: boolean): Promise<void>;
8
+ getExamples(assetType: string, jsonResponse: boolean): Promise<void>;
9
+ getMethodology(assetType: string, jsonResponse: boolean): Promise<void>;
10
+ private outputResponse;
11
+ private logDescriptorSummary;
12
+ private logDescriptorDetail;
13
+ }
@@ -0,0 +1,11 @@
1
+ import { Configurator, IModule } from "../../core/command/module-handler";
2
+ import { Context } from "../../core/command/cli-context";
3
+ declare class Module extends IModule {
4
+ register(context: Context, configurator: Configurator): void;
5
+ private listTypes;
6
+ private getType;
7
+ private getSchema;
8
+ private getExamples;
9
+ private getMethodology;
10
+ }
11
+ export = Module;
@@ -12,6 +12,6 @@ export declare class BatchImportExportApi {
12
12
  exportPackages(packageKeys: string[], withDependencies: boolean): Promise<Buffer>;
13
13
  exportPackagesByVersions(packageKeysWithVersion: string[], withDependencies: boolean): Promise<Buffer>;
14
14
  batchExportPackagesMetadata(packageKeys: string[]): Promise<PackageMetadataExportTransport[]>;
15
- importPackages(data: FormData, overwrite: boolean): Promise<PostPackageImportData[]>;
15
+ importPackages(data: FormData, overwrite: boolean, performValidation: boolean): Promise<PostPackageImportData[]>;
16
16
  findVariablesWithValuesByPackageKeysAndVersion(packagesByKeyAndVersion: PackageKeyAndVersionPair[]): Promise<VariableManifestTransport[]>;
17
17
  }
@@ -0,0 +1,7 @@
1
+ import { Context } from "../../../core/command/cli-context";
2
+ import { PackageValidationRequest, SchemaValidationResponse } from "../interfaces/package-validation.interfaces";
3
+ export declare class PackageValidationApi {
4
+ private httpClient;
5
+ constructor(context: Context);
6
+ validatePackage(packageKey: string, request: PackageValidationRequest): Promise<SchemaValidationResponse>;
7
+ }
@@ -10,7 +10,7 @@ export declare class BatchImportExportService {
10
10
  listPackagesByKeysWithVersion(keysByVersion: string[], withDependencies: boolean): Promise<void>;
11
11
  batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string, unzip: boolean): Promise<void>;
12
12
  batchExportPackagesMetadata(packageKeys: string[], jsonResponse: boolean): Promise<void>;
13
- batchImportPackages(sourcePath: string, overwrite: boolean, gitBranch: string): Promise<void>;
13
+ batchImportPackages(sourcePath: string, overwrite: boolean, gitBranch: string, performValidation?: boolean): Promise<void>;
14
14
  findAndExportListOfActivePackagesByVariableValue(flavors: string[], variableValue: string, variableType: string): Promise<void>;
15
15
  listActivePackagesByVariableValue(flavors: string[], variableValue: string, variableType: string): Promise<void>;
16
16
  private exportListOfPackages;
@@ -8,7 +8,7 @@ export declare class ConfigCommandService {
8
8
  listVariables(jsonResponse: boolean, keysByVersion: string[], keysByVersionFile: string, packageKeys: string[]): Promise<void>;
9
9
  batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string, unzip: boolean): Promise<void>;
10
10
  batchExportPackagesMetadata(packageKeys: string[], jsonResponse: boolean): Promise<void>;
11
- batchImportPackages(file: string, directory: string, overwrite: boolean, gitBranch: string): Promise<void>;
11
+ batchImportPackages(file: string, directory: string, overwrite: boolean, gitBranch: string, performValidation?: boolean): Promise<void>;
12
12
  diffPackages(file: string, hasChanges: boolean, jsonResponse: boolean): Promise<void>;
13
13
  private listPackagesByVariableValue;
14
14
  }
@@ -0,0 +1,25 @@
1
+ export interface PackageValidationRequest {
2
+ layers: string[];
3
+ nodeKeys?: string[];
4
+ }
5
+ export interface SchemaValidationResponse {
6
+ packageKey: string;
7
+ valid: boolean;
8
+ summary: SchemaValidationSummary;
9
+ results: SchemaValidationResult[];
10
+ }
11
+ export interface SchemaValidationSummary {
12
+ errors: number;
13
+ warnings: number;
14
+ info: number;
15
+ }
16
+ export interface SchemaValidationResult {
17
+ layer: string;
18
+ severity: string;
19
+ nodeKey: string;
20
+ assetType: string;
21
+ path: string;
22
+ code: string;
23
+ message: string;
24
+ suggestion?: string;
25
+ }
@@ -12,6 +12,7 @@ declare class Module extends IModule {
12
12
  private createPackageVersion;
13
13
  private batchImportPackages;
14
14
  private diffPackages;
15
+ private validatePackage;
15
16
  private listVariables;
16
17
  private listAssignments;
17
18
  private findNode;
@@ -0,0 +1,7 @@
1
+ import { Context } from "../../core/command/cli-context";
2
+ export declare class PackageValidationService {
3
+ private packageValidationApi;
4
+ constructor(context: Context);
5
+ validatePackage(packageKey: string, layers: string[], nodeKeys: string[], jsonOutput: boolean): Promise<void>;
6
+ private printValidationResult;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celonis/content-cli",
3
- "version": "1.8.1",
3
+ "version": "1.9.1",
4
4
  "description": "CLI Tool to help manage content in Celonis Platform",
5
5
  "main": "content-cli.js",
6
6
  "bin": {