@axway/axway-central-cli 4.5.0 → 4.6.0-rc.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/.security-profile-branches.json +18 -0
- package/package.json +1 -1
- package/dist/cli.js +0 -71
- package/dist/commands/apply/index.js +0 -112
- package/dist/commands/completion/index.js +0 -100
- package/dist/commands/config/common/index.js +0 -28
- package/dist/commands/config/index.js +0 -20
- package/dist/commands/config/list.js +0 -24
- package/dist/commands/config/set.js +0 -102
- package/dist/commands/config/unset.js +0 -48
- package/dist/commands/create/agentResource.js +0 -108
- package/dist/commands/create/environment.js +0 -62
- package/dist/commands/create/index.js +0 -109
- package/dist/commands/create/serviceAccount.js +0 -15
- package/dist/commands/delete/index.js +0 -196
- package/dist/commands/edit/environment.js +0 -101
- package/dist/commands/edit/index.js +0 -28
- package/dist/commands/get/index.js +0 -272
- package/dist/commands/install/agents.js +0 -290
- package/dist/commands/install/apigeexAgents.js +0 -223
- package/dist/commands/install/apigeexSaasAgents.js +0 -300
- package/dist/commands/install/awsAgents.js +0 -525
- package/dist/commands/install/awsSaasAgents.js +0 -508
- package/dist/commands/install/azureAgents.js +0 -242
- package/dist/commands/install/azureSaasAgents.js +0 -519
- package/dist/commands/install/backstageAgents.js +0 -167
- package/dist/commands/install/edgeAgents.js +0 -409
- package/dist/commands/install/gitHubSaasAgents.js +0 -294
- package/dist/commands/install/gitLabAgents.js +0 -178
- package/dist/commands/install/graylogAgent.js +0 -147
- package/dist/commands/install/helpers/creators.js +0 -359
- package/dist/commands/install/helpers/deleters.js +0 -36
- package/dist/commands/install/helpers/getters.js +0 -95
- package/dist/commands/install/helpers/index.js +0 -267
- package/dist/commands/install/helpers/inputs.js +0 -593
- package/dist/commands/install/helpers/regex.js +0 -67
- package/dist/commands/install/helpers/templates/apigeexTemplates.js +0 -109
- package/dist/commands/install/helpers/templates/awsTemplates.js +0 -129
- package/dist/commands/install/helpers/templates/azureTemplates.js +0 -125
- package/dist/commands/install/helpers/templates/backstageTemplates.js +0 -95
- package/dist/commands/install/helpers/templates/edgeTemplates.js +0 -360
- package/dist/commands/install/helpers/templates/gitLabTemplates.js +0 -66
- package/dist/commands/install/helpers/templates/graylogTemplates.js +0 -75
- package/dist/commands/install/helpers/templates/ibmAPIConnectTemplates.js +0 -116
- package/dist/commands/install/helpers/templates/istioTemplates.js +0 -214
- package/dist/commands/install/helpers/templates/kafkaTemplates.js +0 -194
- package/dist/commands/install/helpers/templates/sapApiPortalTemplates.js +0 -114
- package/dist/commands/install/helpers/templates/softwareAGWebMethodsTemplates.js +0 -93
- package/dist/commands/install/helpers/templates/traceableTemplates.js +0 -135
- package/dist/commands/install/helpers/templates/wso2Templates.js +0 -85
- package/dist/commands/install/helpers/util.js +0 -26
- package/dist/commands/install/ibmAPIConnectAgents.js +0 -213
- package/dist/commands/install/index.js +0 -36
- package/dist/commands/install/istioAgents.js +0 -346
- package/dist/commands/install/kafkaAgents.js +0 -303
- package/dist/commands/install/platform.js +0 -175
- package/dist/commands/install/sapApiPortalAgents.js +0 -198
- package/dist/commands/install/softwareAGWebMethodsAgents.js +0 -161
- package/dist/commands/install/swaggerHubSaasAgents.js +0 -272
- package/dist/commands/install/traceableAgents.js +0 -257
- package/dist/commands/install/traceableSaasAgents.js +0 -275
- package/dist/commands/install/wso2Agents.js +0 -163
- package/dist/commands/productize/helpers/productizationHelper.js +0 -408
- package/dist/commands/productize/index.js +0 -99
- package/dist/common/ApiServerClient.js +0 -1109
- package/dist/common/CacheController.js +0 -146
- package/dist/common/CliConfigManager.js +0 -76
- package/dist/common/CompositeError.js +0 -95
- package/dist/common/CoreConfigController.js +0 -174
- package/dist/common/DefinitionsManager.js +0 -298
- package/dist/common/Kubectl.js +0 -68
- package/dist/common/PlatformClient.js +0 -128
- package/dist/common/Renderer.js +0 -409
- package/dist/common/TmpFile.js +0 -96
- package/dist/common/bashCommands.js +0 -97
- package/dist/common/basicPrompts.js +0 -160
- package/dist/common/dataService.js +0 -312
- package/dist/common/errorHandler.js +0 -46
- package/dist/common/modules.d.js +0 -1
- package/dist/common/resultsRenderers.js +0 -164
- package/dist/common/types.js +0 -746
- package/dist/common/utils.js +0 -476
- package/dist/main.js +0 -8
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CacheController = void 0;
|
|
7
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
-
var _fsExtra = require("fs-extra");
|
|
9
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
10
|
-
var _nodeCache = _interopRequireDefault(require("node-cache"));
|
|
11
|
-
var _os = require("os");
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
14
|
-
var _types = require("./types");
|
|
15
|
-
var _utils = require("./utils");
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
-
const {
|
|
21
|
-
log
|
|
22
|
-
} = (0, _snooplogg.default)('central: CacheController');
|
|
23
|
-
/**
|
|
24
|
-
* Note: this file intentionally exporting only a single instance of CacheController,
|
|
25
|
-
* since its possible to face a race condition when multiple instances will try to read/write file at the same time
|
|
26
|
-
* Please do not use this class directly or rework the logic before.
|
|
27
|
-
*/
|
|
28
|
-
class CacheControllerClass {
|
|
29
|
-
constructor() {
|
|
30
|
-
_defineProperty(this, "cacheFilePath", _path.default.join((0, _os.homedir)(), '.axway', 'central', 'cache.json'));
|
|
31
|
-
_defineProperty(this, "cache", new _nodeCache.default());
|
|
32
|
-
// note: init cache fire only once since using only a single instance of the class, remove if this will change
|
|
33
|
-
this.initCacheFile();
|
|
34
|
-
this.readFromFile();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Inits and validate cache file, should run once before using this class in the code (initialized in cli.ts currently)
|
|
39
|
-
* An empty JSON file will be created if it is not exists of the file size is more than some value.
|
|
40
|
-
*/
|
|
41
|
-
initCacheFile() {
|
|
42
|
-
try {
|
|
43
|
-
if ((0, _fsExtra.pathExistsSync)(this.cacheFilePath)) {
|
|
44
|
-
log(`init, cache file found at ${this.cacheFilePath}`);
|
|
45
|
-
const stats = (0, _fsExtra.lstatSync)(this.cacheFilePath);
|
|
46
|
-
log(`init, cache file size: ${Math.round(stats.size / 1000)} kb`);
|
|
47
|
-
if (stats.size >= _types.MAX_CACHE_FILE_SIZE) {
|
|
48
|
-
// validating the size
|
|
49
|
-
log(`init, cache size is exceeding the max allowed size of ${Math.round(_types.MAX_CACHE_FILE_SIZE / 1000)} kb, resetting the file`);
|
|
50
|
-
(0, _fsExtra.outputJsonSync)(this.cacheFilePath, {});
|
|
51
|
-
} else if (!(0, _utils.isValidJson)((0, _fsExtra.readFileSync)(this.cacheFilePath, 'utf8'))) {
|
|
52
|
-
// validating the content
|
|
53
|
-
log('init, cache content is invalid, resetting the file ');
|
|
54
|
-
(0, _fsExtra.outputJsonSync)(this.cacheFilePath, {});
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
log(`init, cache file not found, creating an empty one at ${this.cacheFilePath}`);
|
|
58
|
-
(0, _fsExtra.outputJsonSync)(this.cacheFilePath, {});
|
|
59
|
-
}
|
|
60
|
-
} catch (e) {
|
|
61
|
-
log(`cannot initialize cache file`, e);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Set the key in memory cache.
|
|
67
|
-
* @param key cache key to set
|
|
68
|
-
* @param value value to set, note that setting "undefined" value will result in "null" value stored
|
|
69
|
-
* @returns CacheController instance
|
|
70
|
-
*/
|
|
71
|
-
set(key, value) {
|
|
72
|
-
this.cache.set(key, value);
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Returns the key value from the memory cache.
|
|
78
|
-
* @param key key to get
|
|
79
|
-
* @returns key value
|
|
80
|
-
*/
|
|
81
|
-
get(key) {
|
|
82
|
-
return this.cache.get(key);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Load stored cache from the file into memory and checks its timestamp.
|
|
87
|
-
* If the timestamp is more than X days old it will reset the file without any changes to cache.
|
|
88
|
-
* Note: using this method before writeToFile() will override keys in memory cache with the same name.
|
|
89
|
-
* @returns CacheController instance
|
|
90
|
-
*/
|
|
91
|
-
readFromFile() {
|
|
92
|
-
try {
|
|
93
|
-
log('reading cache from the file');
|
|
94
|
-
const jsonData = (0, _fsExtra.readFileSync)(this.cacheFilePath, 'utf8');
|
|
95
|
-
const storedCache = JSON.parse(jsonData);
|
|
96
|
-
|
|
97
|
-
// validate values stored in the cache, reset the content of the file if its not empty already.
|
|
98
|
-
if (storedCache.data && storedCache.metadata && storedCache.metadata.modifyTimestamp && (0, _dayjs.default)().diff(storedCache.metadata.modifyTimestamp, 'milliseconds') < _types.CACHE_FILE_TTL_MILLISECONDS) {
|
|
99
|
-
for (const [key, val] of Object.entries(storedCache.data)) {
|
|
100
|
-
if (storedCache.data.hasOwnProperty(key)) {
|
|
101
|
-
this.cache.set(key, val);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
} else if (!(0, _isEmpty.default)(storedCache)) {
|
|
105
|
-
log('timestamp or content is not valid and file is not empty, resetting the cache file');
|
|
106
|
-
(0, _fsExtra.outputJsonSync)(this.cacheFilePath, {});
|
|
107
|
-
}
|
|
108
|
-
} catch (e) {
|
|
109
|
-
log('cannot read cache from the file', e);
|
|
110
|
-
} finally {
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Writes current set of keys to the json file with following structure:
|
|
117
|
-
* {
|
|
118
|
-
* metadata: {
|
|
119
|
-
* modifyTimestamp: current timestamp, used on read for TTL validation
|
|
120
|
-
* schemaVersion: indicates the version of cache file structure, can be used later on if changing it.
|
|
121
|
-
* },
|
|
122
|
-
* data: {} key-value cache data
|
|
123
|
-
* }
|
|
124
|
-
* @returns CacheController instance
|
|
125
|
-
*/
|
|
126
|
-
writeToFile() {
|
|
127
|
-
try {
|
|
128
|
-
log('writing cache to the file');
|
|
129
|
-
const keys = this.cache.keys();
|
|
130
|
-
const cachedData = this.cache.mget(keys);
|
|
131
|
-
const dataToStore = {
|
|
132
|
-
metadata: {
|
|
133
|
-
modifyTimestamp: Date.now(),
|
|
134
|
-
schemaVersion: '1'
|
|
135
|
-
},
|
|
136
|
-
data: cachedData
|
|
137
|
-
};
|
|
138
|
-
(0, _utils.writeToFile)(this.cacheFilePath, JSON.stringify(dataToStore));
|
|
139
|
-
} catch (e) {
|
|
140
|
-
log('cannot write cache to the file', e);
|
|
141
|
-
} finally {
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const CacheController = exports.CacheController = new CacheControllerClass();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CliConfigManager = exports.CliConfigKeys = void 0;
|
|
7
|
-
var _fsExtra = require("fs-extra");
|
|
8
|
-
var _unset2 = _interopRequireDefault(require("lodash/unset"));
|
|
9
|
-
var _os = require("os");
|
|
10
|
-
var _path = require("path");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
let CliConfigKeys = exports.CliConfigKeys = /*#__PURE__*/function (CliConfigKeys) {
|
|
16
|
-
CliConfigKeys["APIC_DEPLOYMENT"] = "apic-deployment";
|
|
17
|
-
CliConfigKeys["BASE_URL"] = "base-url";
|
|
18
|
-
CliConfigKeys["ACCOUNT"] = "account";
|
|
19
|
-
CliConfigKeys["REGION"] = "region";
|
|
20
|
-
CliConfigKeys["PLATFORM"] = "platform";
|
|
21
|
-
CliConfigKeys["EXTENSIONS"] = "extensions";
|
|
22
|
-
CliConfigKeys["CLIENT_ID"] = "client-id";
|
|
23
|
-
return CliConfigKeys;
|
|
24
|
-
}({});
|
|
25
|
-
class CliConfigManager {
|
|
26
|
-
saveToFile(values) {
|
|
27
|
-
(0, _fsExtra.outputJsonSync)(CliConfigManager.configFilePath, values, {
|
|
28
|
-
spaces: '\t'
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Temporary validator for config file content. Needed only to cleanup some values from config files for a couple of
|
|
34
|
-
* versions, remove it after some time.
|
|
35
|
-
*/
|
|
36
|
-
validateSavedConfigKeys() {
|
|
37
|
-
const deprecatedKeys = [
|
|
38
|
-
// TODO: a few other configs might be getting deprecated: https://jira.axway.com/browse/APIGOV-19737
|
|
39
|
-
// CliConfigKeys.PLATFORM,
|
|
40
|
-
CliConfigKeys.CLIENT_ID];
|
|
41
|
-
const keysToRemove = Object.keys(this.getAll()).filter(key => deprecatedKeys.includes(key));
|
|
42
|
-
if (keysToRemove.length) {
|
|
43
|
-
throw Error(`Following Axway Central CLI config keys has been deprecated and no longer needed: ${keysToRemove.join(', ')}
|
|
44
|
-
Please unset by running:
|
|
45
|
-
${keysToRemove.map(key => `axway central config unset ${key}`).join('\n')}
|
|
46
|
-
`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Note: current validation is good for "unset" but for "set" its needed to validate the value for "extensions" (should be non-empty)
|
|
51
|
-
validate(key) {
|
|
52
|
-
// validate 'extensions' keys - should alway have dot in the mid: extensions.abc
|
|
53
|
-
if (key.startsWith(`${CliConfigKeys.EXTENSIONS}`)) {
|
|
54
|
-
if (!key.includes('.')) throw Error(`invalid "${CliConfigKeys.EXTENSIONS}" key format.`);
|
|
55
|
-
} else if (!Object.values(CliConfigKeys).includes(key)) {
|
|
56
|
-
throw Error(`central configuration doesn't support the "${key}" key.`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
getAll() {
|
|
60
|
-
return (0, _fsExtra.existsSync)(CliConfigManager.configFilePath) ? (0, _fsExtra.readJsonSync)(CliConfigManager.configFilePath) : {};
|
|
61
|
-
}
|
|
62
|
-
get(key) {
|
|
63
|
-
return this.getAll()[key];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// TODO
|
|
67
|
-
// set(key: CentralConfigKeys) {}
|
|
68
|
-
|
|
69
|
-
unset(key) {
|
|
70
|
-
const config = this.getAll();
|
|
71
|
-
(0, _unset2.default)(config, key);
|
|
72
|
-
this.saveToFile(config);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.CliConfigManager = CliConfigManager;
|
|
76
|
-
_defineProperty(CliConfigManager, "configFilePath", (0, _path.join)((0, _os.homedir)(), '.axway', 'central.json'));
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CompositeError = void 0;
|
|
7
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
8
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
9
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
10
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
11
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
12
|
-
var _nestedErrors = /*#__PURE__*/new WeakMap();
|
|
13
|
-
/** This type is returnd by the CompositeError.toDictionary() method. Intended to be outputted to JSON or YAML. */
|
|
14
|
-
|
|
15
|
-
/** Error object which can provide nested errors to indicated if multiple errors have occurred. */
|
|
16
|
-
class CompositeError extends Error {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new error wrapping the given array of errors.
|
|
19
|
-
* @param errors Array of errors to be owned by this composite error. Can contain CompositeError instances.
|
|
20
|
-
* @param message Optional error message to be displayed by this root error object.
|
|
21
|
-
*/
|
|
22
|
-
constructor(errors, message) {
|
|
23
|
-
super(message);
|
|
24
|
-
/** Array of errors wrapped by this error object. */
|
|
25
|
-
_classPrivateFieldInitSpec(this, _nestedErrors, void 0);
|
|
26
|
-
_classPrivateFieldSet(_nestedErrors, this, errors);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Gets the name of this error type. */
|
|
30
|
-
get name() {
|
|
31
|
-
return 'CompositeError';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Gets an array of error objects owned by this composite error. */
|
|
35
|
-
get nestedErrors() {
|
|
36
|
-
return _classPrivateFieldGet(_nestedErrors, this);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates a dictionary providing the name, message, and array of all errors nested under this error object.
|
|
41
|
-
* Intended to be outputted to JSON or YAML.
|
|
42
|
-
* @returns Returns a dictionary of this error object and all nested error objects.
|
|
43
|
-
*/
|
|
44
|
-
toDictionary() {
|
|
45
|
-
const dictionary = {
|
|
46
|
-
name: this.name,
|
|
47
|
-
message: this.message,
|
|
48
|
-
nestedErrors: []
|
|
49
|
-
};
|
|
50
|
-
for (const nextError of _classPrivateFieldGet(_nestedErrors, this)) {
|
|
51
|
-
if (nextError instanceof CompositeError) {
|
|
52
|
-
dictionary.nestedErrors.push(nextError.toDictionary());
|
|
53
|
-
} else {
|
|
54
|
-
dictionary.nestedErrors.push({
|
|
55
|
-
name: nextError.name,
|
|
56
|
-
message: nextError.message
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return dictionary;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Creates an array of strings providing this object's error message and all of its nested error messages.
|
|
65
|
-
* Each error object's message is added to its own array entry and will be indented according to nested position.
|
|
66
|
-
* @returns Returns an array of all error messages that are indented according to their nested position.
|
|
67
|
-
*/
|
|
68
|
-
toNestedMessageArray() {
|
|
69
|
-
const messageLines = [];
|
|
70
|
-
if (this.message) {
|
|
71
|
-
messageLines.push(this.message);
|
|
72
|
-
}
|
|
73
|
-
for (const nextError of _classPrivateFieldGet(_nestedErrors, this)) {
|
|
74
|
-
if (nextError instanceof CompositeError) {
|
|
75
|
-
for (const nextLine of nextError.toNestedMessageArray()) {
|
|
76
|
-
const prefix = nextLine.startsWith('-') ? ' ' : '* ';
|
|
77
|
-
messageLines.push(prefix + nextLine);
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
messageLines.push(`- ${nextError.message || 'Unknown error'}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return messageLines;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates an error message containing this object's message and all nested error messages separated by newlines
|
|
88
|
-
* and indented according to their nested position.
|
|
89
|
-
* @returns Returns a single string containing all nested error messages separated by newlines.
|
|
90
|
-
*/
|
|
91
|
-
toNestedMessageString() {
|
|
92
|
-
return this.toNestedMessageArray().join('\n');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.CompositeError = CompositeError;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CoreConfigController = exports.AccountRole = void 0;
|
|
7
|
-
var _amplifyCliUtils = require("@axway/amplify-cli-utils");
|
|
8
|
-
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
|
-
var _CliConfigManager = require("./CliConfigManager");
|
|
10
|
-
var _types = require("./types");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
const {
|
|
16
|
-
log
|
|
17
|
-
} = (0, _snooplogg.default)('central: CoreConfigController');
|
|
18
|
-
|
|
19
|
-
// TODO: https://jira.axway.com/browse/APIGOV-20520
|
|
20
|
-
// interface AuthenticationError extends Error {
|
|
21
|
-
// errors?: Array<object>;
|
|
22
|
-
// }
|
|
23
|
-
let AccountRole = exports.AccountRole = /*#__PURE__*/function (AccountRole) {
|
|
24
|
-
AccountRole["AnalyticsSpecialist"] = "analytics_specialist";
|
|
25
|
-
AccountRole["ApiCentralAdmin"] = "api_central_admin";
|
|
26
|
-
AccountRole["FileTransferServicesAdmin"] = "fts_admin";
|
|
27
|
-
AccountRole["FlowCentralAccessManager"] = "fc_access_manager";
|
|
28
|
-
AccountRole["FlowCentralIntegration"] = "fc_integration";
|
|
29
|
-
AccountRole["FlowCentralITAdmin"] = "fc_it_admin";
|
|
30
|
-
AccountRole["FlowCentralProductsAdmin"] = "fc_products_admin";
|
|
31
|
-
AccountRole["FlowCentralSpecOps"] = "fc_spec_ops";
|
|
32
|
-
AccountRole["FlowCentralSubscriptionApprover"] = "fc_subscriptionapprover";
|
|
33
|
-
AccountRole["FlowCentralSubscriptionSpecialist"] = "fc_subscriptionspecialist";
|
|
34
|
-
AccountRole["FlowCentralTemplatePublisher"] = "fc_templatepublisher";
|
|
35
|
-
AccountRole["FlowCentralCftAdmin"] = "fc_cft_admin";
|
|
36
|
-
AccountRole["PlatformAdmin"] = "administrator";
|
|
37
|
-
AccountRole["PlatformAuditor"] = "auditor";
|
|
38
|
-
AccountRole["PlatformCollaborator"] = "collaborator";
|
|
39
|
-
AccountRole["PlatformConsumer"] = "consumer";
|
|
40
|
-
AccountRole["PlatformDeveloper"] = "developer";
|
|
41
|
-
AccountRole["PlatformReadOnly"] = "read_only";
|
|
42
|
-
AccountRole["RuntimeServicesAdmin"] = "ars_admin";
|
|
43
|
-
return AccountRole;
|
|
44
|
-
}({});
|
|
45
|
-
class CoreConfigController {
|
|
46
|
-
/**
|
|
47
|
-
* Get authentication info
|
|
48
|
-
* @param {String} clientId client id to use
|
|
49
|
-
* @param {String} [team] The team name or guid to use, otherwise fallsback to the default from
|
|
50
|
-
* the Axway CLI config.
|
|
51
|
-
* @returns object containing token and orgId. For service accounts orgId is undefined.
|
|
52
|
-
* @throws 401 if no authenticated account found.
|
|
53
|
-
*/
|
|
54
|
-
async getAuthInfo({
|
|
55
|
-
account,
|
|
56
|
-
clientId,
|
|
57
|
-
team,
|
|
58
|
-
forceGetAuthInfo
|
|
59
|
-
} = {}) {
|
|
60
|
-
var _devOpsAccount, _devOpsAccount$org, _devOpsAccount$org$id, _devOpsAccount$org2;
|
|
61
|
-
const configCtrl = new _CliConfigManager.CliConfigManager();
|
|
62
|
-
const config = (0, _amplifyCliUtils.loadConfig)();
|
|
63
|
-
|
|
64
|
-
// note: remove this validator after couple of versions
|
|
65
|
-
configCtrl.validateSavedConfigKeys();
|
|
66
|
-
log(`getAuthInfo, received clientId = ${clientId}, account = ${account}, team = ${team}`);
|
|
67
|
-
const baseUrl = process.env.AXWAY_CENTRAL_BASE_URL || configCtrl.get(_CliConfigManager.CliConfigKeys.BASE_URL);
|
|
68
|
-
|
|
69
|
-
// environment defined by using central cli "base-url" or axway "env" configs if set,
|
|
70
|
-
// otherwise its undefined (equals to prod)
|
|
71
|
-
const environment = !baseUrl || baseUrl === _types.ProdBaseUrls.US || baseUrl === _types.ProdBaseUrls.EU || baseUrl === _types.ProdBaseUrls.AP ? config.get('env') : 'staging';
|
|
72
|
-
log(`getAuthInfo, baseUrl = ${baseUrl}, environment = ${environment}`);
|
|
73
|
-
const {
|
|
74
|
-
sdk
|
|
75
|
-
} = (0, _amplifyCliUtils.initSDK)({
|
|
76
|
-
env: environment
|
|
77
|
-
}, config);
|
|
78
|
-
let {
|
|
79
|
-
devOpsAccount
|
|
80
|
-
} = CoreConfigController;
|
|
81
|
-
if (forceGetAuthInfo) {
|
|
82
|
-
devOpsAccount = null;
|
|
83
|
-
}
|
|
84
|
-
if (!devOpsAccount || account && devOpsAccount.name !== account) {
|
|
85
|
-
log(`getAuthInfo, no cached devOpsAccount found, or account name does not match`);
|
|
86
|
-
if (clientId) {
|
|
87
|
-
// TODO: client-id is a legacy option used only by proxies promote/create, should be removed
|
|
88
|
-
// https://jira.axway.com/browse/APIGOV-20818
|
|
89
|
-
log(`getAuthInfo, clientId value passed, trying to find a matching account`);
|
|
90
|
-
const list = await sdk.auth.list({
|
|
91
|
-
validate: true
|
|
92
|
-
});
|
|
93
|
-
const matchingAccount = list.find(a => a.auth.clientId === clientId);
|
|
94
|
-
if (matchingAccount) {
|
|
95
|
-
devOpsAccount = await sdk.auth.find(matchingAccount.name);
|
|
96
|
-
}
|
|
97
|
-
} else if (account) {
|
|
98
|
-
// ELSE IF: account name passed - ignoring defaultAccount and other accounts
|
|
99
|
-
log(`getAuthInfo, account value passed, trying to find a matching account`);
|
|
100
|
-
devOpsAccount = await sdk.auth.find(account);
|
|
101
|
-
} else {
|
|
102
|
-
// ELSE: trying to get any authenticated account
|
|
103
|
-
log(`getAuthInfo, account value not passed, trying to find default/any match`);
|
|
104
|
-
const list = await sdk.auth.list({
|
|
105
|
-
validate: true
|
|
106
|
-
});
|
|
107
|
-
log(`getAuthInfo, authenticated accounts found: ${list.length}`);
|
|
108
|
-
if (list.length === 1) {
|
|
109
|
-
log(`getAuthInfo, using a single account found with name: ${list[0].name}`);
|
|
110
|
-
devOpsAccount = list[0];
|
|
111
|
-
} else if (list.length > 1) {
|
|
112
|
-
// try to find the default account
|
|
113
|
-
devOpsAccount = list.find(a => a.name === config.get('auth.defaultAccount')) || list.find(a => a.default) || list[0];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!devOpsAccount) {
|
|
117
|
-
// TODO: piece of old logic here, move throwing out of the method?
|
|
118
|
-
// temporary commenting out the new functionality and reverting back to the old one, will be fixed with:
|
|
119
|
-
// https://jira.axway.com/browse/APIGOV-20520
|
|
120
|
-
log(`getAuthInfo, no devOpsAccount set after all, throwing 401`);
|
|
121
|
-
// const title: string = accountName
|
|
122
|
-
// ? `Account "${accountName}" cannot be found`
|
|
123
|
-
// : 'No authenticated accounts found.';
|
|
124
|
-
// const err: AuthenticationError = new Error(title);
|
|
125
|
-
// err.errors = [{ status: 401, title }];
|
|
126
|
-
// throw err;
|
|
127
|
-
throw {
|
|
128
|
-
errors: [{
|
|
129
|
-
status: 401,
|
|
130
|
-
title: account ? `Account "${account}" cannot be found` : 'No authenticated accounts found.'
|
|
131
|
-
}]
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
CoreConfigController.devOpsAccount = devOpsAccount;
|
|
135
|
-
}
|
|
136
|
-
const result = {
|
|
137
|
-
orgId: (_devOpsAccount = devOpsAccount) === null || _devOpsAccount === void 0 ? void 0 : (_devOpsAccount$org = _devOpsAccount.org) === null || _devOpsAccount$org === void 0 ? void 0 : (_devOpsAccount$org$id = _devOpsAccount$org.id) === null || _devOpsAccount$org$id === void 0 ? void 0 : _devOpsAccount$org$id.toString(),
|
|
138
|
-
orgRegion: (_devOpsAccount$org2 = devOpsAccount.org) === null || _devOpsAccount$org2 === void 0 ? void 0 : _devOpsAccount$org2.region,
|
|
139
|
-
token: process.env.AXWAY_CENTRAL_AUTH_TOKEN || config.get('central.authToken', devOpsAccount.auth.tokens.access_token)
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// now that we have resolved the account, we can validate the team
|
|
143
|
-
if (team) {
|
|
144
|
-
const {
|
|
145
|
-
teams
|
|
146
|
-
} = await sdk.team.list(devOpsAccount);
|
|
147
|
-
const teamObj = teams.find(t => {
|
|
148
|
-
return t.guid.toLowerCase() === team.toLowerCase() || t.name.toLowerCase() === team.toLowerCase();
|
|
149
|
-
});
|
|
150
|
-
if (!teamObj) {
|
|
151
|
-
throw new Error(`Unable to find team "${team}" in the "${devOpsAccount.org.name}" organization`);
|
|
152
|
-
}
|
|
153
|
-
result.teamGuid = teamObj.guid;
|
|
154
|
-
} else if (team === null) {
|
|
155
|
-
result.teamGuid = null;
|
|
156
|
-
}
|
|
157
|
-
log(`getAuthInfo, returning account = ${devOpsAccount.name}`);
|
|
158
|
-
log(`getAuthInfo, returning token = ${result.token.substring(0, 5)}*****${result.token.substring(result.token.length - 5)}`);
|
|
159
|
-
log(`getAuthInfo, returning orgId = ${result.orgId}`);
|
|
160
|
-
log(`getAuthInfo, returning orgRegion = ${result.orgRegion}`);
|
|
161
|
-
log(`getAuthInfo, returning teamGuid = ${result.teamGuid}`);
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
static getEnv() {
|
|
165
|
-
var _CoreConfigController2, _CoreConfigController3;
|
|
166
|
-
return ((_CoreConfigController2 = CoreConfigController.devOpsAccount) === null || _CoreConfigController2 === void 0 ? void 0 : (_CoreConfigController3 = _CoreConfigController2.auth) === null || _CoreConfigController3 === void 0 ? void 0 : _CoreConfigController3.env) || _types.Platforms.prod;
|
|
167
|
-
}
|
|
168
|
-
static getAuthUrl() {
|
|
169
|
-
var _CoreConfigController4, _CoreConfigController5;
|
|
170
|
-
return ((_CoreConfigController4 = CoreConfigController.devOpsAccount) === null || _CoreConfigController4 === void 0 ? void 0 : (_CoreConfigController5 = _CoreConfigController4.auth) === null || _CoreConfigController5 === void 0 ? void 0 : _CoreConfigController5.baseUrl) || _types.AuthUrls.Prod;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.CoreConfigController = CoreConfigController;
|
|
174
|
-
_defineProperty(CoreConfigController, "devOpsAccount", null);
|