@celonis/content-cli 1.8.1 → 1.9.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.
- package/commands/api/api.service.js +81 -0
- package/commands/api/module.js +42 -0
- package/commands/asset-registry/asset-registry-api.js +47 -0
- package/commands/asset-registry/asset-registry.interfaces.js +12 -0
- package/commands/asset-registry/asset-registry.service.js +87 -0
- package/commands/asset-registry/module.js +48 -0
- package/commands/configuration-management/api/batch-import-export-api.js +2 -2
- package/commands/configuration-management/api/package-validation-api.js +36 -0
- package/commands/configuration-management/batch-import-export.service.js +2 -2
- package/commands/configuration-management/config-command.service.js +2 -2
- package/commands/configuration-management/interfaces/package-validation.interfaces.js +12 -0
- package/commands/configuration-management/module.js +16 -2
- package/commands/configuration-management/package-validation.service.js +62 -0
- package/lib/commands/api/api.service.d.ts +7 -0
- package/lib/commands/api/module.d.ts +7 -0
- package/lib/commands/asset-registry/asset-registry-api.d.ts +8 -0
- package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +30 -0
- package/lib/commands/asset-registry/asset-registry.service.d.ts +9 -0
- package/lib/commands/asset-registry/module.d.ts +8 -0
- package/lib/commands/configuration-management/api/batch-import-export-api.d.ts +1 -1
- package/lib/commands/configuration-management/api/package-validation-api.d.ts +7 -0
- package/lib/commands/configuration-management/batch-import-export.service.d.ts +1 -1
- package/lib/commands/configuration-management/config-command.service.d.ts +1 -1
- package/lib/commands/configuration-management/interfaces/package-validation.interfaces.d.ts +25 -0
- package/lib/commands/configuration-management/module.d.ts +1 -0
- package/lib/commands/configuration-management/package-validation.service.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
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", "../../core/utils/file-service", "uuid"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ApiService = void 0;
|
|
22
|
+
const logger_1 = require("../../core/utils/logger");
|
|
23
|
+
const file_service_1 = require("../../core/utils/file-service");
|
|
24
|
+
const uuid_1 = require("uuid");
|
|
25
|
+
class ApiService {
|
|
26
|
+
constructor(context) {
|
|
27
|
+
this.httpClient = () => context.httpClient;
|
|
28
|
+
}
|
|
29
|
+
request(path, method, body, jsonFile) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (!path.startsWith("/")) {
|
|
32
|
+
throw new logger_1.FatalError("Path must start with /");
|
|
33
|
+
}
|
|
34
|
+
const validMethods = ["GET", "POST", "PUT", "DELETE"];
|
|
35
|
+
if (!validMethods.includes(method)) {
|
|
36
|
+
throw new logger_1.FatalError(`Invalid method '${method}'. Must be one of: ${validMethods.join(", ")}`);
|
|
37
|
+
}
|
|
38
|
+
logger_1.logger.info(`${method} ${path}`);
|
|
39
|
+
let parsedBody;
|
|
40
|
+
if (body) {
|
|
41
|
+
try {
|
|
42
|
+
parsedBody = JSON.parse(body);
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
throw new logger_1.FatalError("--body must be valid JSON");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const data = yield this.execute(method, path, parsedBody);
|
|
49
|
+
if (jsonFile) {
|
|
50
|
+
const filename = (0, uuid_1.v4)() + ".json";
|
|
51
|
+
file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(data, null, 2), filename);
|
|
52
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const output = typeof data === "string" ? data : JSON.stringify(data, null, 2);
|
|
56
|
+
logger_1.logger.info(output);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
execute(method, path, body) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
switch (method) {
|
|
64
|
+
case "GET":
|
|
65
|
+
return yield this.httpClient().get(path);
|
|
66
|
+
case "POST":
|
|
67
|
+
return yield this.httpClient().post(path, body !== null && body !== void 0 ? body : {});
|
|
68
|
+
case "PUT":
|
|
69
|
+
return yield this.httpClient().put(path, body !== null && body !== void 0 ? body : {});
|
|
70
|
+
case "DELETE":
|
|
71
|
+
return yield this.httpClient().delete(path);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
throw new logger_1.FatalError(`${method} ${path} failed: ${e}`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ApiService = ApiService;
|
|
81
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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", "./api.service"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
const module_handler_1 = require("../../core/command/module-handler");
|
|
21
|
+
const api_service_1 = require("./api.service");
|
|
22
|
+
class Module extends module_handler_1.IModule {
|
|
23
|
+
register(context, configurator) {
|
|
24
|
+
configurator.command("api")
|
|
25
|
+
.description("Send raw HTTP requests to Celonis APIs on the configured team (beta — testing only).")
|
|
26
|
+
.beta()
|
|
27
|
+
.command("request")
|
|
28
|
+
.description("Send a request to the given Celonis API path (e.g. /package-manager/api/packages)")
|
|
29
|
+
.requiredOption("--path <path>", "API path starting with / (e.g. /package-manager/api/packages)")
|
|
30
|
+
.option("--method <method>", "HTTP method: GET, POST, PUT, DELETE", "GET")
|
|
31
|
+
.option("--body <body>", "Request body as JSON string (for POST/PUT)")
|
|
32
|
+
.option("--json", "Write the response to a JSON file instead of printing it")
|
|
33
|
+
.action(this.request);
|
|
34
|
+
}
|
|
35
|
+
request(context, command, options) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
yield new api_service_1.ApiService(context).request(options.path, options.method.toUpperCase(), options.body, !!options.json);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return Module;
|
|
42
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
}
|
|
46
|
+
exports.AssetRegistryApi = AssetRegistryApi;
|
|
47
|
+
});
|
|
@@ -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,87 @@
|
|
|
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
|
+
logDescriptorSummary(descriptor) {
|
|
64
|
+
logger_1.logger.info(`${descriptor.assetType} - ${descriptor.displayName} [${descriptor.group}] (basePath: ${descriptor.service.basePath})`);
|
|
65
|
+
}
|
|
66
|
+
logDescriptorDetail(descriptor) {
|
|
67
|
+
logger_1.logger.info(`Asset Type: ${descriptor.assetType}`);
|
|
68
|
+
logger_1.logger.info(`Display Name: ${descriptor.displayName}`);
|
|
69
|
+
if (descriptor.description) {
|
|
70
|
+
logger_1.logger.info(`Description: ${descriptor.description}`);
|
|
71
|
+
}
|
|
72
|
+
logger_1.logger.info(`Group: ${descriptor.group}`);
|
|
73
|
+
logger_1.logger.info(`Schema: v${descriptor.assetSchema.version}`);
|
|
74
|
+
logger_1.logger.info(`Base Path: ${descriptor.service.basePath}`);
|
|
75
|
+
logger_1.logger.info(`Endpoints:`);
|
|
76
|
+
logger_1.logger.info(` schema: ${descriptor.endpoints.schema}`);
|
|
77
|
+
logger_1.logger.info(` validate: ${descriptor.endpoints.validate}`);
|
|
78
|
+
if (descriptor.endpoints.methodology) {
|
|
79
|
+
logger_1.logger.info(` methodology: ${descriptor.endpoints.methodology}`);
|
|
80
|
+
}
|
|
81
|
+
if (descriptor.endpoints.examples) {
|
|
82
|
+
logger_1.logger.info(` examples: ${descriptor.endpoints.examples}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.AssetRegistryService = AssetRegistryService;
|
|
87
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
|
36
|
+
listTypes(context, command, options) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
yield new asset_registry_service_1.AssetRegistryService(context).listTypes(!!options.json);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
getType(context, command, options) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
yield new asset_registry_service_1.AssetRegistryService(context).getType(options.assetType, !!options.json);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return Module;
|
|
48
|
+
});
|
|
@@ -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,7 @@
|
|
|
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 request;
|
|
6
|
+
}
|
|
7
|
+
export = Module;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -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,9 @@
|
|
|
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
|
+
private logDescriptorSummary;
|
|
8
|
+
private logDescriptorDetail;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
8
|
+
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
|
+
}
|
|
@@ -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
|
+
}
|