@celonis/content-cli 1.14.1 → 1.16.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/asset-registry/asset-registry-api.js +12 -11
- package/commands/asset-registry/asset-registry.service.js +4 -53
- package/commands/asset-registry/module.js +4 -23
- package/commands/configuration-management/api/variable-assignment-candidates-api.js +7 -3
- package/commands/configuration-management/interfaces/variable-assignment-apis.constants.js +29 -3
- package/commands/git-profile/module.js +2 -1
- package/commands/profile/module.js +2 -1
- package/content-cli.js +10 -2
- package/core/command/module-handler.js +14 -1
- package/core/http/http-client.js +6 -3
- package/core/profile/profile.service.js +35 -21
- package/core/profile/profile.validator.js +19 -9
- package/lib/commands/asset-registry/asset-registry-api.d.ts +3 -3
- package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +0 -8
- package/lib/commands/asset-registry/asset-registry.service.d.ts +2 -7
- package/lib/commands/asset-registry/module.d.ts +0 -1
- package/lib/commands/configuration-management/api/variable-assignment-candidates-api.d.ts +2 -1
- package/lib/commands/configuration-management/interfaces/variable-assignment-apis.constants.d.ts +5 -0
- package/lib/content-cli.d.ts +1 -0
- package/lib/core/command/module-handler.d.ts +2 -0
- package/lib/core/profile/profile.service.d.ts +2 -0
- package/lib/core/profile/profile.validator.d.ts +3 -0
- package/package.json +1 -1
|
@@ -24,10 +24,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
constructor(context) {
|
|
25
25
|
this.httpClient = () => context.httpClient;
|
|
26
26
|
}
|
|
27
|
-
listTypes() {
|
|
27
|
+
listTypes(flavor) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
return this.httpClient()
|
|
30
|
-
.get(AssetRegistryApi.endpointUrl("types"))
|
|
30
|
+
.get(AssetRegistryApi.withQuery(AssetRegistryApi.endpointUrl("types"), { flavor }))
|
|
31
31
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)("listing asset registry types", e));
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -38,10 +38,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
38
38
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting asset type '${assetType}'`, e));
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
getSchema(assetType) {
|
|
41
|
+
getSchema(assetType, path) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
return this.httpClient()
|
|
44
|
-
.get(AssetRegistryApi.endpointUrl("schemas", encodeURIComponent(assetType)))
|
|
44
|
+
.get(AssetRegistryApi.withQuery(AssetRegistryApi.endpointUrl("schemas", encodeURIComponent(assetType)), { path }))
|
|
45
45
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting schema for asset type '${assetType}'`, e));
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -52,16 +52,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
52
52
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting examples for asset type '${assetType}'`, e));
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
validate(assetType, body) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return this.httpClient()
|
|
58
|
-
.post(AssetRegistryApi.endpointUrl("validate", encodeURIComponent(assetType)), body)
|
|
59
|
-
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`validating asset type '${assetType}'`, e));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
55
|
static endpointUrl(...segments) {
|
|
63
56
|
return `${AssetRegistryApi.BASE_URL}/${segments.join("/")}`;
|
|
64
57
|
}
|
|
58
|
+
static withQuery(url, params) {
|
|
59
|
+
const queryParams = new URLSearchParams();
|
|
60
|
+
Object.entries(params)
|
|
61
|
+
.filter(([, value]) => value !== undefined && value.trim() !== "")
|
|
62
|
+
.forEach(([name, value]) => queryParams.set(name, value));
|
|
63
|
+
const query = queryParams.toString();
|
|
64
|
+
return query ? `${url}?${query}` : url;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
exports.AssetRegistryApi = AssetRegistryApi;
|
|
67
68
|
AssetRegistryApi.BASE_URL = "/pacman/api/core/asset-registry";
|
|
@@ -29,9 +29,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
29
29
|
this.api = new asset_registry_api_1.AssetRegistryApi(context);
|
|
30
30
|
this.cuiFileService = new cui_file_service_1.CuiFileService(context);
|
|
31
31
|
}
|
|
32
|
-
listTypes(jsonResponse) {
|
|
32
|
+
listTypes(jsonResponse, flavor) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const metadata = yield this.api.listTypes();
|
|
34
|
+
const metadata = yield this.api.listTypes(flavor);
|
|
35
35
|
const descriptors = Object.values(metadata.types);
|
|
36
36
|
if (jsonResponse) {
|
|
37
37
|
const filename = (0, uuid_1.v4)() + ".json";
|
|
@@ -62,9 +62,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
getSchema(assetType, jsonResponse) {
|
|
65
|
+
getSchema(assetType, jsonResponse, path) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const data = yield this.api.getSchema(assetType);
|
|
67
|
+
const data = yield this.api.getSchema(assetType, path);
|
|
68
68
|
yield this.outputResponse(data, jsonResponse);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -74,54 +74,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
74
74
|
yield this.outputResponse(data, jsonResponse);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
validate(opts) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const payload = this.buildValidatePayload(opts);
|
|
80
|
-
const data = yield this.api.validate(opts.assetType, payload);
|
|
81
|
-
yield this.outputResponse(data, opts.json);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
buildValidatePayload(opts) {
|
|
85
|
-
const hasNodeKey = !!opts.nodeKey;
|
|
86
|
-
const hasConfig = !!opts.configuration;
|
|
87
|
-
const hasFile = !!opts.file;
|
|
88
|
-
if (hasFile && (hasNodeKey || hasConfig || !!opts.packageKey)) {
|
|
89
|
-
throw new logger_1.FatalError("Option -f is mutually exclusive with --packageKey, --nodeKey and --configuration.");
|
|
90
|
-
}
|
|
91
|
-
if (hasFile) {
|
|
92
|
-
return this.parseJson(file_service_1.fileService.readFile(opts.file), `-f ${opts.file}`);
|
|
93
|
-
}
|
|
94
|
-
if (hasNodeKey && hasConfig) {
|
|
95
|
-
throw new logger_1.FatalError("Options --nodeKey and --configuration are mutually exclusive. Use --nodeKey to validate a stored node, or --configuration to validate a configuration. For full control, use -f.");
|
|
96
|
-
}
|
|
97
|
-
if (!hasNodeKey && !hasConfig) {
|
|
98
|
-
throw new logger_1.FatalError("Provide --packageKey with one of --nodeKey (validate a stored node) or --configuration (validate a configuration), or use -f for a full request file.");
|
|
99
|
-
}
|
|
100
|
-
if (!opts.packageKey) {
|
|
101
|
-
throw new logger_1.FatalError("--packageKey is required when using --nodeKey or --configuration.");
|
|
102
|
-
}
|
|
103
|
-
if (hasNodeKey) {
|
|
104
|
-
return {
|
|
105
|
-
assetType: opts.assetType,
|
|
106
|
-
packageKey: opts.packageKey,
|
|
107
|
-
nodeKeys: [opts.nodeKey],
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const configJson = this.parseJson(opts.configuration, "--configuration");
|
|
111
|
-
return {
|
|
112
|
-
assetType: opts.assetType,
|
|
113
|
-
packageKey: opts.packageKey,
|
|
114
|
-
nodes: [{ key: AssetRegistryService.INLINE_VALIDATION_NODE_KEY, configuration: configJson }],
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
parseJson(raw, source) {
|
|
118
|
-
try {
|
|
119
|
-
return JSON.parse(raw);
|
|
120
|
-
}
|
|
121
|
-
catch (_a) {
|
|
122
|
-
throw new logger_1.FatalError(`Invalid JSON in ${source}.`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
77
|
outputResponse(data, jsonResponse) {
|
|
126
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
79
|
if (jsonResponse) {
|
|
@@ -164,5 +116,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
164
116
|
}
|
|
165
117
|
}
|
|
166
118
|
exports.AssetRegistryService = AssetRegistryService;
|
|
167
|
-
AssetRegistryService.INLINE_VALIDATION_NODE_KEY = "validation-node";
|
|
168
119
|
});
|
|
@@ -25,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
25
|
.description("Manage the asset registry — discover registered asset types and their service descriptors.");
|
|
26
26
|
assetRegistryCommand.command("list")
|
|
27
27
|
.description("List all registered asset types")
|
|
28
|
+
.option("--flavor <flavor>", "Lists only the asset types that apply to the given package flavor (e.g., STUDIO)")
|
|
28
29
|
.option("--json", "Return the response as a JSON file")
|
|
29
30
|
.action(this.listTypes);
|
|
30
31
|
assetRegistryCommand.command("get")
|
|
@@ -35,6 +36,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35
36
|
assetRegistryCommand.command("schema")
|
|
36
37
|
.description("Get the JSON schema for an asset type's configuration")
|
|
37
38
|
.requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
|
|
39
|
+
.option("--path <path>", "Return only this part of the schema, written like a $ref inside it (e.g., '#/$defs/table'); '#' returns the entry point")
|
|
38
40
|
.option("--json", "Return the response as a JSON file")
|
|
39
41
|
.action(this.getSchema);
|
|
40
42
|
assetRegistryCommand.command("examples")
|
|
@@ -42,19 +44,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
42
44
|
.requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
|
|
43
45
|
.option("--json", "Return the response as a JSON file")
|
|
44
46
|
.action(this.getExamples);
|
|
45
|
-
assetRegistryCommand.command("validate")
|
|
46
|
-
.description("Validate asset configuration against the asset service's validate endpoint.")
|
|
47
|
-
.requiredOption("--assetType <assetType>", "The asset type identifier (e.g., BOARD_V2)")
|
|
48
|
-
.option("--packageKey <packageKey>", "Package key. Required when validating with --nodeKey or --configuration.")
|
|
49
|
-
.option("--nodeKey <nodeKey>", "Key of an already-stored node to validate (use with --packageKey).")
|
|
50
|
-
.option("--configuration <configuration>", "Inline JSON of a configuration to validate (use with --packageKey).")
|
|
51
|
-
.option("-f, --file <file>", "Path to a JSON file containing a full ValidateRequest body. Mutually exclusive with the build-from-options flags.")
|
|
52
|
-
.option("--json", "Return the response as a JSON file")
|
|
53
|
-
.action(this.validate);
|
|
54
47
|
}
|
|
55
48
|
listTypes(context, command, options) {
|
|
56
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield new asset_registry_service_1.AssetRegistryService(context).listTypes(!!options.json);
|
|
50
|
+
yield new asset_registry_service_1.AssetRegistryService(context).listTypes(!!options.json, options.flavor);
|
|
58
51
|
});
|
|
59
52
|
}
|
|
60
53
|
getType(context, command, options) {
|
|
@@ -64,19 +57,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
64
57
|
}
|
|
65
58
|
getSchema(context, command, options) {
|
|
66
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
yield new asset_registry_service_1.AssetRegistryService(context).getSchema(options.assetType, !!options.json);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
validate(context, command, options) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
yield new asset_registry_service_1.AssetRegistryService(context).validate({
|
|
73
|
-
assetType: options.assetType,
|
|
74
|
-
packageKey: options.packageKey,
|
|
75
|
-
nodeKey: options.nodeKey,
|
|
76
|
-
configuration: options.configuration,
|
|
77
|
-
file: options.file,
|
|
78
|
-
json: !!options.json,
|
|
79
|
-
});
|
|
60
|
+
yield new asset_registry_service_1.AssetRegistryService(context).getSchema(options.assetType, !!options.json, options.path);
|
|
80
61
|
});
|
|
81
62
|
}
|
|
82
63
|
getExamples(context, command, options) {
|
|
@@ -27,13 +27,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
}
|
|
28
28
|
getCandidateAssignments(type, params) {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
|
|
30
|
+
const assignmentApi = variable_assignment_apis_constants_1.variableAssignmentApis[type];
|
|
31
|
+
if (!assignmentApi) {
|
|
31
32
|
throw new logger_1.FatalError(`Variable type ${type} not supported.`);
|
|
32
33
|
}
|
|
33
|
-
const apiUrl =
|
|
34
|
-
|
|
34
|
+
const apiUrl = assignmentApi.url + (params.toString().length ? `?${params.toString()}` : "");
|
|
35
|
+
const candidates = yield this.httpClient().get(apiUrl).catch(e => {
|
|
35
36
|
throw new logger_1.FatalError(`Problem getting variables assignment values for type ${type}: ${e}`);
|
|
36
37
|
});
|
|
38
|
+
return (Array.isArray(candidates) ? candidates : [])
|
|
39
|
+
.map(candidate => assignmentApi.toAssignment(candidate))
|
|
40
|
+
.filter(assignment => !!assignment.value);
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
}
|
|
@@ -10,12 +10,38 @@
|
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.variableAssignmentApis = void 0;
|
|
13
|
+
const connectionName = (connection) => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const parts = [(_b = (_a = connection === null || connection === void 0 ? void 0 : connection.authProvider) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : (_c = connection === null || connection === void 0 ? void 0 : connection.authProvider) === null || _c === void 0 ? void 0 : _c.name, connection === null || connection === void 0 ? void 0 : connection.username].filter(Boolean);
|
|
16
|
+
return parts.length ? parts.join(" - ") : connection === null || connection === void 0 ? void 0 : connection.id;
|
|
17
|
+
};
|
|
13
18
|
exports.variableAssignmentApis = {
|
|
14
19
|
DATA_MODEL: {
|
|
15
|
-
url: "/package-manager/api/compute-pools/pools-with-data-models"
|
|
20
|
+
url: "/package-manager/api/compute-pools/pools-with-data-models",
|
|
21
|
+
toAssignment: candidate => {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
return ({
|
|
24
|
+
value: (_a = candidate === null || candidate === void 0 ? void 0 : candidate.dataModel) === null || _a === void 0 ? void 0 : _a.dataModelId,
|
|
25
|
+
name: [(_b = candidate === null || candidate === void 0 ? void 0 : candidate.pool) === null || _b === void 0 ? void 0 : _b.name, (_c = candidate === null || candidate === void 0 ? void 0 : candidate.dataModel) === null || _c === void 0 ? void 0 : _c.name].filter(Boolean).join(" / ") || ((_d = candidate === null || candidate === void 0 ? void 0 : candidate.dataModel) === null || _d === void 0 ? void 0 : _d.dataModelId),
|
|
26
|
+
});
|
|
27
|
+
},
|
|
16
28
|
},
|
|
17
29
|
CONNECTION: {
|
|
18
|
-
url: "/process-automation-v2/api/connections"
|
|
19
|
-
|
|
30
|
+
url: "/process-automation-v2/api/connections",
|
|
31
|
+
toAssignment: candidate => ({
|
|
32
|
+
value: candidate === null || candidate === void 0 ? void 0 : candidate.id,
|
|
33
|
+
name: connectionName(candidate),
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
DATA_POOL_ID: {
|
|
37
|
+
url: "/integration/api/pools",
|
|
38
|
+
toAssignment: candidate => {
|
|
39
|
+
var _a;
|
|
40
|
+
return ({
|
|
41
|
+
value: candidate === null || candidate === void 0 ? void 0 : candidate.id,
|
|
42
|
+
name: (_a = candidate === null || candidate === void 0 ? void 0 : candidate.name) !== null && _a !== void 0 ? _a : candidate === null || candidate === void 0 ? void 0 : candidate.id,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
},
|
|
20
46
|
};
|
|
21
47
|
});
|
|
@@ -27,7 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
const gitCommand = configurator.command("git")
|
|
28
28
|
.description("Commands related to Git settings");
|
|
29
29
|
const gitProfileCommand = gitCommand.command("profile")
|
|
30
|
-
.description("Manage Git profiles required to use git-related operations.")
|
|
30
|
+
.description("Manage Git profiles required to use git-related operations.")
|
|
31
|
+
.skipProfileLoading();
|
|
31
32
|
gitProfileCommand.command("list")
|
|
32
33
|
.description("Command to list all stored Git profiles")
|
|
33
34
|
.action(this.listProfiles);
|
|
@@ -26,7 +26,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
26
|
class Module extends module_handler_1.IModule {
|
|
27
27
|
register(context, configurator) {
|
|
28
28
|
const command = configurator.command("profile")
|
|
29
|
-
.description("Manage profiles required to access a system.")
|
|
29
|
+
.description("Manage profiles required to access a system.")
|
|
30
|
+
.skipProfileLoading();
|
|
30
31
|
command.command("list")
|
|
31
32
|
.description("Command to list all stored profiles")
|
|
32
33
|
.action(this.listProfiles);
|
package/content-cli.js
CHANGED
|
@@ -19,7 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
})(function (require, exports) {
|
|
20
20
|
"use strict";
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.createProgram = void 0;
|
|
22
|
+
exports.loadProfileOnDemand = exports.createProgram = void 0;
|
|
23
23
|
const semverSatisfies = require("semver/functions/satisfies");
|
|
24
24
|
const commander_1 = require("commander");
|
|
25
25
|
const module_handler_1 = require("./core/command/module-handler");
|
|
@@ -69,6 +69,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
69
69
|
return program;
|
|
70
70
|
}
|
|
71
71
|
exports.createProgram = createProgram;
|
|
72
|
+
function loadProfileOnDemand(program, context) {
|
|
73
|
+
program.hook("preAction", (_program, actionCommand) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if ((0, module_handler_1.shouldLoadProfile)(actionCommand)) {
|
|
75
|
+
yield context.init();
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
exports.loadProfileOnDemand = loadProfileOnDemand;
|
|
72
80
|
/**
|
|
73
81
|
* To support the legacy command structure, we have to configure some root commands
|
|
74
82
|
* that the individual modules will extend.
|
|
@@ -103,8 +111,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
103
111
|
});
|
|
104
112
|
}
|
|
105
113
|
const context = new cli_context_1.Context(globalOpts);
|
|
106
|
-
yield context.init();
|
|
107
114
|
const program = createProgram(context, { devMode: !!globalOpts.dev });
|
|
115
|
+
loadProfileOnDemand(program, context);
|
|
108
116
|
try {
|
|
109
117
|
yield program.parseAsync(process.argv);
|
|
110
118
|
}
|
|
@@ -18,7 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CommandConfig = exports.Configurator = exports.ModuleHandler = exports.IModule = void 0;
|
|
21
|
+
exports.CommandConfig = exports.Configurator = exports.shouldLoadProfile = exports.ModuleHandler = exports.IModule = void 0;
|
|
22
22
|
const path = require("path");
|
|
23
23
|
const fs = require("fs");
|
|
24
24
|
const commander_1 = require("commander");
|
|
@@ -120,6 +120,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
exports.ModuleHandler = ModuleHandler;
|
|
123
|
+
function shouldLoadProfile(command) {
|
|
124
|
+
for (let cmd = command; cmd; cmd = cmd.parent) {
|
|
125
|
+
if (cmd.skipsProfileLoading) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
exports.shouldLoadProfile = shouldLoadProfile;
|
|
123
132
|
/**
|
|
124
133
|
* Allows the creation of root level commands.
|
|
125
134
|
*/
|
|
@@ -192,6 +201,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
192
201
|
this.cmd.isBeta = true;
|
|
193
202
|
return this;
|
|
194
203
|
}
|
|
204
|
+
skipProfileLoading() {
|
|
205
|
+
this.cmd.skipsProfileLoading = true;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
195
208
|
action(handler) {
|
|
196
209
|
this.cmd.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
197
210
|
try {
|
package/core/http/http-client.js
CHANGED
|
@@ -246,11 +246,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
246
246
|
return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(this.context.profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
|
|
247
247
|
}
|
|
248
248
|
buildAuthorizationHeaders(profile, contentType) {
|
|
249
|
-
const
|
|
250
|
-
return {
|
|
251
|
-
Authorization: `${authenticationType} ${profile.apiToken}`,
|
|
249
|
+
const headers = {
|
|
252
250
|
"Content-Type": contentType !== null && contentType !== void 0 ? contentType : "application/json",
|
|
253
251
|
};
|
|
252
|
+
if (profile.apiToken) {
|
|
253
|
+
const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
|
|
254
|
+
headers.Authorization = `${authenticationType} ${profile.apiToken}`;
|
|
255
|
+
}
|
|
256
|
+
return headers;
|
|
254
257
|
}
|
|
255
258
|
}
|
|
256
259
|
exports.HttpClient = HttpClient;
|
|
@@ -72,15 +72,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
72
72
|
.catch(() => reject(`The profile ${profileName} couldn't be resolved.`));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
else if (process.env.TEAM_URL && process.env.API_TOKEN) {
|
|
76
|
-
resolve(this.buildProfileFromEnvVariables());
|
|
77
|
-
}
|
|
78
|
-
else if (process.env.CELONIS_URL && process.env.CELONIS_API_TOKEN) {
|
|
79
|
-
this.mapCelonisEnvProfile();
|
|
80
|
-
resolve(this.buildProfileFromEnvVariables());
|
|
81
|
-
}
|
|
82
75
|
else {
|
|
83
|
-
|
|
76
|
+
const envProfileSource = this.selectEnvProfileSource();
|
|
77
|
+
if (envProfileSource) {
|
|
78
|
+
if (envProfileSource.requiresCelonisMapping) {
|
|
79
|
+
this.mapCelonisEnvProfile();
|
|
80
|
+
}
|
|
81
|
+
resolve(this.buildProfileFromEnvVariables());
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
reject(`The profile ${profileName} couldn't be resolved due to missing environment variables.`);
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
catch (e) {
|
|
@@ -136,6 +138,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
136
138
|
});
|
|
137
139
|
});
|
|
138
140
|
}
|
|
141
|
+
selectEnvProfileSource() {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const sources = [
|
|
144
|
+
{ teamUrl: process.env.TEAM_URL, apiToken: process.env.API_TOKEN, requiresCelonisMapping: false },
|
|
145
|
+
{ teamUrl: process.env.CELONIS_URL, apiToken: process.env.CELONIS_API_TOKEN, requiresCelonisMapping: true },
|
|
146
|
+
].filter(source => !!source.teamUrl);
|
|
147
|
+
return (_b = (_a = sources.find(source => !!source.apiToken)) !== null && _a !== void 0 ? _a : sources[0]) !== null && _b !== void 0 ? _b : null;
|
|
148
|
+
}
|
|
139
149
|
buildProfileFromEnvVariables() {
|
|
140
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
151
|
const profileVariables = this.getProfileEnvVariables();
|
|
@@ -146,7 +156,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
146
156
|
authenticationType: profile_interface_1.AuthenticationType.BEARER,
|
|
147
157
|
type: profile_interface_1.ProfileType.KEY
|
|
148
158
|
};
|
|
149
|
-
|
|
159
|
+
profile_validator_1.ProfileValidator.validateEnvironmentProfile(profile);
|
|
160
|
+
if (!profile.apiToken) {
|
|
161
|
+
logger_1.logger.warn(`No API token provided. Requests to ${profile.team} will be sent without an authorization header.`);
|
|
162
|
+
}
|
|
150
163
|
return profile;
|
|
151
164
|
});
|
|
152
165
|
}
|
|
@@ -266,9 +279,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
266
279
|
if (!this.isProfileExpired(profile, expiryBuffer)) {
|
|
267
280
|
return;
|
|
268
281
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
282
|
+
try {
|
|
283
|
+
const issuer = yield openid_client_1.Issuer.discover(profile.team);
|
|
284
|
+
if (profile.type === profile_interface_1.ProfileType.DEVICE_CODE) {
|
|
272
285
|
const oauthClient = new issuer.Client({
|
|
273
286
|
client_id: "content-cli",
|
|
274
287
|
token_endpoint_auth_method: "none",
|
|
@@ -278,12 +291,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
278
291
|
profile.expiresAt = tokenSet.expires_at;
|
|
279
292
|
profile.refreshToken = tokenSet.refresh_token;
|
|
280
293
|
}
|
|
281
|
-
|
|
282
|
-
logger_1.logger.error(new logger_1.FatalError("The profile cannot be refreshed. Please retry or recreate profile."));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
try {
|
|
294
|
+
else {
|
|
287
295
|
const oauthClient = new issuer.Client({
|
|
288
296
|
client_id: profile.clientId,
|
|
289
297
|
client_secret: profile.clientSecret,
|
|
@@ -296,13 +304,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
296
304
|
profile.apiToken = tokenSet.access_token;
|
|
297
305
|
profile.expiresAt = tokenSet.expires_at;
|
|
298
306
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
throw this.unrefreshableProfile(profile.name, err);
|
|
302
310
|
}
|
|
303
311
|
yield this.storeProfile(profile);
|
|
304
312
|
});
|
|
305
313
|
}
|
|
314
|
+
unrefreshableProfile(profileName, err) {
|
|
315
|
+
const cause = err instanceof Error ? err.message : "an unrecognised error";
|
|
316
|
+
logger_1.logger.debug(`Refreshing the profile ${profileName} failed: ${cause}`);
|
|
317
|
+
logger_1.logger.warn(`The profile ${profileName} cannot be refreshed. Retry, or recreate it.`);
|
|
318
|
+
return new Error(`The profile ${profileName} cannot be refreshed.`);
|
|
319
|
+
}
|
|
306
320
|
getProfileEnvVariables() {
|
|
307
321
|
return {
|
|
308
322
|
teamUrl: this.getBaseTeamUrl(process.env.TEAM_URL),
|
|
@@ -25,23 +25,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
25
|
class ProfileValidator {
|
|
26
26
|
static validateProfile(profile) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
logger_1.logger.error(new logger_1.FatalError("The name can not be empty"));
|
|
30
|
-
}
|
|
31
|
-
if (profile.team == null) {
|
|
32
|
-
logger_1.logger.error(new logger_1.FatalError("The team can not be empty"));
|
|
33
|
-
}
|
|
28
|
+
this.validateIdentity(profile);
|
|
34
29
|
if (profile.type === profile_interface_1.ProfileType.KEY && profile.apiToken == null) {
|
|
35
30
|
logger_1.logger.error(new logger_1.FatalError("The api token can not be empty for this profile type"));
|
|
36
31
|
}
|
|
37
32
|
if (profile.type === profile_interface_1.ProfileType.CLIENT_CREDENTIALS && (profile.clientId == null || profile.clientSecret == null)) {
|
|
38
33
|
logger_1.logger.error(new logger_1.FatalError("The client id and secret can not be empty for this profile type"));
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
logger_1.logger.error(new logger_1.FatalError("The provided url is not a valid url."));
|
|
42
|
-
}
|
|
35
|
+
this.validateTeamUrl(profile);
|
|
43
36
|
});
|
|
44
37
|
}
|
|
38
|
+
static validateEnvironmentProfile(profile) {
|
|
39
|
+
this.validateIdentity(profile);
|
|
40
|
+
this.validateTeamUrl(profile);
|
|
41
|
+
}
|
|
42
|
+
static validateIdentity(profile) {
|
|
43
|
+
if (profile.name == null) {
|
|
44
|
+
logger_1.logger.error(new logger_1.FatalError("The name can not be empty"));
|
|
45
|
+
}
|
|
46
|
+
if (profile.team == null) {
|
|
47
|
+
logger_1.logger.error(new logger_1.FatalError("The team can not be empty"));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static validateTeamUrl(profile) {
|
|
51
|
+
if (!validUrl.isUri(profile.team)) {
|
|
52
|
+
logger_1.logger.error(new logger_1.FatalError("The provided url is not a valid url."));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
45
55
|
}
|
|
46
56
|
exports.ProfileValidator = ProfileValidator;
|
|
47
57
|
});
|
|
@@ -4,10 +4,10 @@ export declare class AssetRegistryApi {
|
|
|
4
4
|
private static readonly BASE_URL;
|
|
5
5
|
private readonly httpClient;
|
|
6
6
|
constructor(context: Context);
|
|
7
|
-
listTypes(): Promise<AssetRegistryMetadata>;
|
|
7
|
+
listTypes(flavor?: string): Promise<AssetRegistryMetadata>;
|
|
8
8
|
getType(assetType: string): Promise<AssetRegistryDescriptor>;
|
|
9
|
-
getSchema(assetType: string): Promise<any>;
|
|
9
|
+
getSchema(assetType: string, path?: string): Promise<any>;
|
|
10
10
|
getExamples(assetType: string): Promise<any>;
|
|
11
|
-
validate(assetType: string, body: any): Promise<any>;
|
|
12
11
|
private static endpointUrl;
|
|
12
|
+
private static withQuery;
|
|
13
13
|
}
|
|
@@ -28,11 +28,3 @@ export interface AssetContributions {
|
|
|
28
28
|
dataPipelineEntityTypes: string[];
|
|
29
29
|
actionTypes: string[];
|
|
30
30
|
}
|
|
31
|
-
export interface ValidateOptions {
|
|
32
|
-
assetType: string;
|
|
33
|
-
packageKey?: string;
|
|
34
|
-
nodeKey?: string;
|
|
35
|
-
configuration?: string;
|
|
36
|
-
file?: string;
|
|
37
|
-
json: boolean;
|
|
38
|
-
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { ValidateOptions } from "./asset-registry.interfaces";
|
|
2
1
|
import { Context } from "../../core/command/cli-context";
|
|
3
2
|
export declare class AssetRegistryService {
|
|
4
3
|
private readonly api;
|
|
5
4
|
private readonly cuiFileService;
|
|
6
5
|
constructor(context: Context);
|
|
7
|
-
listTypes(jsonResponse: boolean): Promise<void>;
|
|
6
|
+
listTypes(jsonResponse: boolean, flavor?: string): Promise<void>;
|
|
8
7
|
getType(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
9
|
-
getSchema(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
8
|
+
getSchema(assetType: string, jsonResponse: boolean, path?: string): Promise<void>;
|
|
10
9
|
getExamples(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
11
|
-
validate(opts: ValidateOptions): Promise<void>;
|
|
12
|
-
private static readonly INLINE_VALIDATION_NODE_KEY;
|
|
13
|
-
private buildValidatePayload;
|
|
14
|
-
private parseJson;
|
|
15
10
|
private outputResponse;
|
|
16
11
|
private logDescriptorSummary;
|
|
17
12
|
private logDescriptorDetail;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { URLSearchParams } from "url";
|
|
3
|
+
import { VariableAssignment } from "../interfaces/variable-assignment-apis.constants";
|
|
3
4
|
import { Context } from "../../../core/command/cli-context";
|
|
4
5
|
export declare class VariableAssignmentCandidatesApi {
|
|
5
6
|
private httpClient;
|
|
6
7
|
constructor(context: Context);
|
|
7
|
-
getCandidateAssignments(type: string, params: URLSearchParams): Promise<
|
|
8
|
+
getCandidateAssignments(type: string, params: URLSearchParams): Promise<VariableAssignment[]>;
|
|
8
9
|
}
|
package/lib/commands/configuration-management/interfaces/variable-assignment-apis.constants.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
export interface VariableAssignment {
|
|
2
|
+
value: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
1
5
|
export interface VariableAssignmentApi {
|
|
2
6
|
url: string;
|
|
7
|
+
toAssignment: (candidate: any) => VariableAssignment;
|
|
3
8
|
}
|
|
4
9
|
export declare const variableAssignmentApis: {
|
|
5
10
|
[key: string]: VariableAssignmentApi;
|
package/lib/content-cli.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export interface CreateProgramOptions {
|
|
|
14
14
|
* Build a fully-configured Commander program without parsing argv
|
|
15
15
|
*/
|
|
16
16
|
export declare function createProgram(context: Context, opts?: CreateProgramOptions): Command;
|
|
17
|
+
export declare function loadProfileOnDemand(program: Command, context: Context): void;
|
|
@@ -20,6 +20,7 @@ export declare class ModuleHandler {
|
|
|
20
20
|
discoverAndRegisterModules(rootPath: string, devMode?: boolean): void;
|
|
21
21
|
}
|
|
22
22
|
type CommandHandler = (context: Context, command: Command, options: OptionValues) => Promise<void>;
|
|
23
|
+
export declare function shouldLoadProfile(command: Command): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* Allows the creation of root level commands.
|
|
25
26
|
*/
|
|
@@ -53,6 +54,7 @@ export declare class CommandConfig {
|
|
|
53
54
|
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): CommandConfig;
|
|
54
55
|
deprecationNotice(deprecationMessage: string): CommandConfig;
|
|
55
56
|
beta(): CommandConfig;
|
|
57
|
+
skipProfileLoading(): this;
|
|
56
58
|
action(handler: CommandHandler): void;
|
|
57
59
|
private printDeprecationNoticeIfDeprecated;
|
|
58
60
|
private printBetaNoticeIfBetaCommand;
|
|
@@ -10,6 +10,7 @@ export declare class ProfileService {
|
|
|
10
10
|
makeDefaultProfile(profileName: string): Promise<Profile>;
|
|
11
11
|
getDefaultProfile(): string;
|
|
12
12
|
storeProfile(profile: Profile): Promise<void>;
|
|
13
|
+
private selectEnvProfileSource;
|
|
13
14
|
private buildProfileFromEnvVariables;
|
|
14
15
|
private storeConfig;
|
|
15
16
|
private createProfileContainerIfNotExists;
|
|
@@ -18,6 +19,7 @@ export declare class ProfileService {
|
|
|
18
19
|
getAllFilesInDirectory(): string[];
|
|
19
20
|
authorizeProfile(profile: Profile): Promise<void>;
|
|
20
21
|
refreshProfile(profile: Profile): Promise<void>;
|
|
22
|
+
private unrefreshableProfile;
|
|
21
23
|
private getProfileEnvVariables;
|
|
22
24
|
private getBaseTeamUrl;
|
|
23
25
|
private isProfileExpired;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Profile } from "./profile.interface";
|
|
2
2
|
export declare class ProfileValidator {
|
|
3
3
|
static validateProfile(profile: Profile): Promise<any>;
|
|
4
|
+
static validateEnvironmentProfile(profile: Profile): void;
|
|
5
|
+
private static validateIdentity;
|
|
6
|
+
private static validateTeamUrl;
|
|
4
7
|
}
|