@axway/axway-central-cli 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/commands/get/index.js +12 -16
- package/dist/commands/install/agents.js +3 -10
- package/dist/commands/install/edgeAgents.js +1 -1
- package/dist/commands/install/helpers/creators.js +15 -16
- package/dist/commands/install/helpers/index.js +4 -4
- package/dist/commands/install/helpers/inputs.js +25 -30
- package/dist/commands/install/helpers/templates/edgeTemplates.js +6 -6
- package/dist/commands/install/helpers/templates/istioTemplates.js +6 -6
- package/dist/commands/install/istioAgents.js +4 -4
- package/dist/commands/install/platform.js +14 -10
- package/dist/common/ApiServerClient.js +19 -8
- package/dist/common/CoreConfigController.js +67 -68
- package/dist/common/PlatformClient.js +145 -33
- package/dist/common/dataService.js +52 -18
- package/dist/common/types.js +6 -4
- package/package.json +19 -19
- package/dist/common/ApiCentralClient.js +0 -114
|
@@ -7,12 +7,8 @@ exports.CoreConfigController = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _amplifyCliUtils = require("@axway/amplify-cli-utils");
|
|
9
9
|
|
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
-
|
|
12
10
|
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
13
11
|
|
|
14
|
-
var _basicPrompts = require("./basicPrompts");
|
|
15
|
-
|
|
16
12
|
var _CliConfigManager = require("./CliConfigManager");
|
|
17
13
|
|
|
18
14
|
var _types = require("./types");
|
|
@@ -23,85 +19,83 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
23
19
|
|
|
24
20
|
const {
|
|
25
21
|
log
|
|
26
|
-
} = (0, _snooplogg.default)('central: CoreConfigController');
|
|
22
|
+
} = (0, _snooplogg.default)('central: CoreConfigController'); // TODO: https://jira.axway.com/browse/APIGOV-20520
|
|
23
|
+
// interface AuthenticationError extends Error {
|
|
24
|
+
// errors?: Array<object>;
|
|
25
|
+
// }
|
|
27
26
|
|
|
28
27
|
class CoreConfigController {
|
|
29
28
|
/**
|
|
30
29
|
* Get authentication info
|
|
31
|
-
* @param clientId client id to use
|
|
30
|
+
* @param {String} clientId client id to use
|
|
31
|
+
* @param {String} [team] The team name or guid to use, otherwise fallsback to the default from
|
|
32
|
+
* the Axway CLI config.
|
|
32
33
|
* @returns object containing token and orgId. For service accounts orgId is undefined.
|
|
33
34
|
* @throws 401 if no authenticated account found.
|
|
34
35
|
*/
|
|
35
36
|
async getAuthInfo({
|
|
36
37
|
account,
|
|
37
|
-
clientId
|
|
38
|
+
clientId,
|
|
39
|
+
team
|
|
38
40
|
} = {}) {
|
|
39
|
-
var
|
|
41
|
+
var _devOpsAccount$org;
|
|
40
42
|
|
|
41
|
-
const configCtrl = new _CliConfigManager.CliConfigManager();
|
|
43
|
+
const configCtrl = new _CliConfigManager.CliConfigManager();
|
|
44
|
+
const config = (0, _amplifyCliUtils.loadConfig)(); // note: remove this validator after couple of versions
|
|
42
45
|
|
|
43
46
|
configCtrl.validateSavedConfigKeys();
|
|
44
|
-
log(`getAuthInfo, received clientId = ${clientId}, account = ${account}`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
log(`getAuthInfo, received clientId = ${clientId}, account = ${account}, team = ${team}`);
|
|
48
|
+
const baseUrl = configCtrl.get(_CliConfigManager.CliConfigKeys.BASE_URL); // environment defined by using central cli "base-url" or axway "env" configs if set,
|
|
49
|
+
// otherwise its undefined (equals to prod)
|
|
50
|
+
|
|
51
|
+
const environment = !baseUrl || baseUrl === _types.ProdBaseUrls.US || baseUrl === _types.ProdBaseUrls.EU ? config.get('env') : 'preprod';
|
|
52
|
+
log(`getAuthInfo, baseUrl = ${baseUrl}, environment = ${environment}`);
|
|
53
|
+
const {
|
|
54
|
+
sdk
|
|
55
|
+
} = (0, _amplifyCliUtils.initSDK)({
|
|
56
|
+
env: environment
|
|
57
|
+
}, config);
|
|
58
|
+
let {
|
|
59
|
+
devOpsAccount
|
|
60
|
+
} = CoreConfigController;
|
|
61
|
+
|
|
62
|
+
if (!devOpsAccount || account && devOpsAccount.name !== account) {
|
|
47
63
|
log(`getAuthInfo, no cached devOpsAccount found, or account name does not match`);
|
|
48
|
-
const baseUrl = configCtrl.get(_CliConfigManager.CliConfigKeys.BASE_URL); // environment defined by using central cli "base-url" or axway "env" configs if set,
|
|
49
|
-
// otherwise its undefined (equals to prod)
|
|
50
|
-
|
|
51
|
-
const environment = !baseUrl || baseUrl === _types.ProdBaseUrls.US || baseUrl === _types.ProdBaseUrls.EU ? this.getConfig('env') : 'preprod';
|
|
52
|
-
log(`getAuthInfo, baseUrl = ${baseUrl}, environment = ${environment}`);
|
|
53
|
-
const {
|
|
54
|
-
config,
|
|
55
|
-
sdk
|
|
56
|
-
} = (0, _amplifyCliUtils.initSDK)({
|
|
57
|
-
env: environment
|
|
58
|
-
});
|
|
59
64
|
|
|
60
65
|
if (clientId) {
|
|
61
66
|
// TODO: client-id is a legacy option used only by proxies promote/create, should be removed
|
|
62
67
|
// https://jira.axway.com/browse/APIGOV-20818
|
|
63
68
|
log(`getAuthInfo, clientId value passed, trying to find a matching account`);
|
|
64
69
|
const list = await sdk.auth.list({
|
|
65
|
-
|
|
70
|
+
validate: true
|
|
66
71
|
});
|
|
67
72
|
const matchingAccount = list.find(a => a.auth.clientId === clientId);
|
|
68
|
-
|
|
73
|
+
|
|
74
|
+
if (matchingAccount) {
|
|
75
|
+
devOpsAccount = await sdk.auth.find(matchingAccount.name);
|
|
76
|
+
}
|
|
69
77
|
} else if (account) {
|
|
70
78
|
// ELSE IF: account name passed - ignoring defaultAccount and other accounts
|
|
71
79
|
log(`getAuthInfo, account value passed, trying to find a matching account`);
|
|
72
|
-
|
|
80
|
+
devOpsAccount = await sdk.auth.find(account);
|
|
73
81
|
} else {
|
|
74
82
|
// ELSE: trying to get any authenticated account
|
|
75
83
|
log(`getAuthInfo, account value not passed, trying to find default/any match`);
|
|
76
84
|
const list = await sdk.auth.list({
|
|
77
|
-
|
|
85
|
+
validate: true
|
|
78
86
|
});
|
|
79
87
|
log(`getAuthInfo, authenticated accounts found: ${list.length}`);
|
|
80
88
|
|
|
81
89
|
if (list.length === 1) {
|
|
82
90
|
log(`getAuthInfo, using a single account found with name: ${list[0].name}`);
|
|
83
|
-
|
|
91
|
+
devOpsAccount = list[0];
|
|
84
92
|
} else if (list.length > 1) {
|
|
85
93
|
// try to find the default account
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (defaultAccount) {
|
|
89
|
-
log(`getAuthInfo, match found for defaultAccount, refreshing its token`);
|
|
90
|
-
CoreConfigController.devOpsAccount = await sdk.auth.find(defaultAccount.name);
|
|
91
|
-
} else {
|
|
92
|
-
log(`getAuthInfo, no match found for defaultAccount`);
|
|
93
|
-
const selectedName = await (0, _basicPrompts.askList)({
|
|
94
|
-
msg: 'Multiple authenticated accounts found, please select which one you want to use',
|
|
95
|
-
choices: Array.from(new Set(list.map(a => a.name)))
|
|
96
|
-
});
|
|
97
|
-
console.log((0, _chalk.default)`{grey If you always want to use this account by default, run:\naxway config set auth.defaultAccount ${selectedName}}\n`);
|
|
98
|
-
log(`getAuthInfo, refreshing token for selected account: ${selectedName}`);
|
|
99
|
-
CoreConfigController.devOpsAccount = await sdk.auth.find(selectedName);
|
|
100
|
-
}
|
|
94
|
+
devOpsAccount = list.find(a => a.name === config.get('auth.defaultAccount')) || list.find(a => a.default) || list[0];
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
|
|
104
|
-
if (!
|
|
98
|
+
if (!devOpsAccount) {
|
|
105
99
|
// TODO: piece of old logic here, move throwing out of the method?
|
|
106
100
|
// temporary commenting out the new functionality and reverting back to the old one, will be fixed with:
|
|
107
101
|
// https://jira.axway.com/browse/APIGOV-20520
|
|
@@ -119,43 +113,48 @@ class CoreConfigController {
|
|
|
119
113
|
}]
|
|
120
114
|
};
|
|
121
115
|
}
|
|
116
|
+
|
|
117
|
+
CoreConfigController.devOpsAccount = devOpsAccount;
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
log(`getAuthInfo, returning orgId = ${orgId}`);
|
|
130
|
-
log(`getAuthInfo, returning orgRegion = ${orgRegion}`);
|
|
131
|
-
return {
|
|
132
|
-
orgId,
|
|
133
|
-
orgRegion,
|
|
134
|
-
token
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get all or specific config value from core cli.
|
|
139
|
-
* @returns entire object config or a specific value if key passed.
|
|
140
|
-
*/
|
|
120
|
+
const result = {
|
|
121
|
+
orgId: devOpsAccount.isPlatform ? `${devOpsAccount.org.id}` : undefined,
|
|
122
|
+
orgRegion: (_devOpsAccount$org = devOpsAccount.org) === null || _devOpsAccount$org === void 0 ? void 0 : _devOpsAccount$org.region,
|
|
123
|
+
token: devOpsAccount.auth.tokens.access_token
|
|
124
|
+
}; // now that we have resolved the account, we can validate the team
|
|
141
125
|
|
|
126
|
+
if (team) {
|
|
127
|
+
var _devOpsAccount$org$te;
|
|
128
|
+
|
|
129
|
+
const teamObj = (_devOpsAccount$org$te = devOpsAccount.org.teams) === null || _devOpsAccount$org$te === void 0 ? void 0 : _devOpsAccount$org$te.find(t => {
|
|
130
|
+
return t.guid.toLowerCase() === team.toLowerCase() || t.name.toLowerCase() === team.toLowerCase();
|
|
131
|
+
});
|
|
142
132
|
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
if (!teamObj) {
|
|
134
|
+
throw new Error(`Unable to find team "${team}" in the "${devOpsAccount.org.name}" organization`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
result.teamGuid = teamObj.guid;
|
|
138
|
+
}
|
|
145
139
|
|
|
146
|
-
|
|
140
|
+
log(`getAuthInfo, returning account = ${devOpsAccount.name}`);
|
|
141
|
+
log(`getAuthInfo, returning token = ${result.token.substring(0, 5)}*****${result.token.substring(result.token.length - 5)}`);
|
|
142
|
+
log(`getAuthInfo, returning orgId = ${result.orgId}`);
|
|
143
|
+
log(`getAuthInfo, returning orgRegion = ${result.orgRegion}`);
|
|
144
|
+
log(`getAuthInfo, returning teamGuid = ${result.teamGuid}`);
|
|
145
|
+
return result;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
static getEnv() {
|
|
150
|
-
var
|
|
149
|
+
var _CoreConfigController, _CoreConfigController2;
|
|
151
150
|
|
|
152
|
-
return ((
|
|
151
|
+
return ((_CoreConfigController = CoreConfigController.devOpsAccount) === null || _CoreConfigController === void 0 ? void 0 : (_CoreConfigController2 = _CoreConfigController.auth) === null || _CoreConfigController2 === void 0 ? void 0 : _CoreConfigController2.env) || _types.Platforms.prod;
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
static getAuthUrl() {
|
|
156
|
-
var
|
|
155
|
+
var _CoreConfigController3, _CoreConfigController4;
|
|
157
156
|
|
|
158
|
-
return ((
|
|
157
|
+
return ((_CoreConfigController3 = CoreConfigController.devOpsAccount) === null || _CoreConfigController3 === void 0 ? void 0 : (_CoreConfigController4 = _CoreConfigController3.auth) === null || _CoreConfigController4 === void 0 ? void 0 : _CoreConfigController4.baseUrl) || _types.AuthUrls.Prod;
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
}
|
|
@@ -3,21 +3,72 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PlatformClient = void 0;
|
|
6
|
+
exports.PlatformTeamMemberRole = exports.PlatformServiceAccountRole = exports.PlatformClient = exports.PlatformAuthMethod = void 0;
|
|
7
7
|
|
|
8
8
|
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _types = require("./types");
|
|
10
|
+
var _amplifyCliUtils = require("@axway/amplify-cli-utils");
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
|
-
function
|
|
14
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
15
|
+
|
|
16
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
17
|
+
|
|
18
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
19
|
+
|
|
20
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
21
|
+
|
|
22
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
23
|
+
|
|
24
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
25
|
+
|
|
26
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
17
27
|
|
|
18
28
|
const {
|
|
19
29
|
log
|
|
20
30
|
} = (0, _snooplogg.default)('central:class.PlatformClient');
|
|
31
|
+
let PlatformAuthMethod;
|
|
32
|
+
exports.PlatformAuthMethod = PlatformAuthMethod;
|
|
33
|
+
|
|
34
|
+
(function (PlatformAuthMethod) {
|
|
35
|
+
PlatformAuthMethod["Certificate"] = "certificate";
|
|
36
|
+
PlatformAuthMethod["Secret"] = "secret";
|
|
37
|
+
})(PlatformAuthMethod || (exports.PlatformAuthMethod = PlatformAuthMethod = {}));
|
|
38
|
+
|
|
39
|
+
let PlatformServiceAccountRole;
|
|
40
|
+
exports.PlatformServiceAccountRole = PlatformServiceAccountRole;
|
|
41
|
+
|
|
42
|
+
(function (PlatformServiceAccountRole) {
|
|
43
|
+
PlatformServiceAccountRole["ApiCentralAdmin"] = "api_central_admin";
|
|
44
|
+
PlatformServiceAccountRole["FlowCentralAccessManager"] = "fc_access_manager";
|
|
45
|
+
PlatformServiceAccountRole["FlowCentralIntegration"] = "fc_integration";
|
|
46
|
+
PlatformServiceAccountRole["FlowCentralITAdmin"] = "fc_it_admin";
|
|
47
|
+
PlatformServiceAccountRole["FlowCentralProductsAdmin"] = "fc_products_admin";
|
|
48
|
+
PlatformServiceAccountRole["FlowCentralSpecOps"] = "fc_spec_ops";
|
|
49
|
+
PlatformServiceAccountRole["FlowCentralSubscriptionApprover"] = "fc_subscriptionapprover";
|
|
50
|
+
PlatformServiceAccountRole["FlowCentralSubscriptionSpecialist"] = "fc_subscriptionspecialist";
|
|
51
|
+
PlatformServiceAccountRole["FlowCentralTemplatePublisher"] = "fc_templatepublisher";
|
|
52
|
+
PlatformServiceAccountRole["FlowCentralCftAdmin"] = "fc_cft_admin";
|
|
53
|
+
})(PlatformServiceAccountRole || (exports.PlatformServiceAccountRole = PlatformServiceAccountRole = {}));
|
|
54
|
+
|
|
55
|
+
let PlatformTeamMemberRole;
|
|
56
|
+
exports.PlatformTeamMemberRole = PlatformTeamMemberRole;
|
|
57
|
+
|
|
58
|
+
(function (PlatformTeamMemberRole) {
|
|
59
|
+
PlatformTeamMemberRole["Admin"] = "administrator";
|
|
60
|
+
PlatformTeamMemberRole["Developer"] = "developer";
|
|
61
|
+
PlatformTeamMemberRole["Consumer"] = "consumer";
|
|
62
|
+
PlatformTeamMemberRole["CatalogManager"] = "catalog_manager";
|
|
63
|
+
})(PlatformTeamMemberRole || (exports.PlatformTeamMemberRole = PlatformTeamMemberRole = {}));
|
|
64
|
+
|
|
65
|
+
var _baseUrl = /*#__PURE__*/new WeakMap();
|
|
66
|
+
|
|
67
|
+
var _accountName = /*#__PURE__*/new WeakMap();
|
|
68
|
+
|
|
69
|
+
var _amplifyConfig = /*#__PURE__*/new WeakMap();
|
|
70
|
+
|
|
71
|
+
var _amplifySdk = /*#__PURE__*/new WeakMap();
|
|
21
72
|
|
|
22
73
|
class PlatformClient {
|
|
23
74
|
constructor({
|
|
@@ -25,41 +76,102 @@ class PlatformClient {
|
|
|
25
76
|
region,
|
|
26
77
|
account
|
|
27
78
|
} = {}) {
|
|
28
|
-
|
|
79
|
+
_classPrivateFieldInitSpec(this, _baseUrl, {
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
_classPrivateFieldInitSpec(this, _accountName, {
|
|
85
|
+
writable: true,
|
|
86
|
+
value: void 0
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
_classPrivateFieldInitSpec(this, _amplifyConfig, {
|
|
90
|
+
writable: true,
|
|
91
|
+
value: void 0
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
_classPrivateFieldInitSpec(this, _amplifySdk, {
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
29
98
|
|
|
30
|
-
|
|
99
|
+
log(`initializing client with params: baseUrl = ${baseUrl}, region = ${region}, account = ${account}`);
|
|
31
100
|
|
|
32
|
-
|
|
101
|
+
_classPrivateFieldSet(this, _baseUrl, baseUrl);
|
|
33
102
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
103
|
+
_classPrivateFieldSet(this, _accountName, account);
|
|
104
|
+
|
|
105
|
+
const initResult = (0, _amplifyCliUtils.initSDK)({
|
|
106
|
+
baseUrl: _classPrivateFieldGet(this, _baseUrl),
|
|
107
|
+
username: _classPrivateFieldGet(this, _accountName)
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
_classPrivateFieldSet(this, _amplifyConfig, initResult.config);
|
|
111
|
+
|
|
112
|
+
_classPrivateFieldSet(this, _amplifySdk, initResult.sdk);
|
|
38
113
|
}
|
|
39
114
|
|
|
40
|
-
async
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
result.data = response;
|
|
56
|
-
} catch (e) {
|
|
57
|
-
if (e.errors && Array.isArray(e.errors)) {
|
|
58
|
-
result.error = e.errors;
|
|
59
|
-
} else throw e;
|
|
115
|
+
async getAccountInfo() {
|
|
116
|
+
var _classPrivateFieldGet2;
|
|
117
|
+
|
|
118
|
+
// Get default teams from config.
|
|
119
|
+
const defaultTeams = _classPrivateFieldGet(this, _amplifyConfig).get(`${(0, _amplifyCliUtils.getAuthConfigEnvSpecifier)((_classPrivateFieldGet2 = _classPrivateFieldGet(this, _amplifySdk).env) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.name)}.defaultTeam`); // Fetch specified account or default account currently logged in.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
let accountInfo;
|
|
123
|
+
|
|
124
|
+
if (_classPrivateFieldGet(this, _accountName)) {
|
|
125
|
+
accountInfo = await _classPrivateFieldGet(this, _amplifySdk).auth.find(_classPrivateFieldGet(this, _accountName), defaultTeams);
|
|
126
|
+
|
|
127
|
+
if (!accountInfo) {
|
|
128
|
+
throw new Error(`Account "${_classPrivateFieldGet(this, _accountName)}" not found`);
|
|
129
|
+
}
|
|
60
130
|
}
|
|
61
131
|
|
|
62
|
-
|
|
132
|
+
if (!accountInfo) {
|
|
133
|
+
const accountArray = await _classPrivateFieldGet(this, _amplifySdk).auth.list({
|
|
134
|
+
defaultTeams,
|
|
135
|
+
validate: true
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (accountArray) {
|
|
139
|
+
accountInfo = accountArray.find(nextAccount => nextAccount.default) || accountArray[0];
|
|
140
|
+
}
|
|
141
|
+
} // Make sure "subscriptions" is defined since Amplify SDK requires it. (Will throw error if missing.)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if (accountInfo && accountInfo.org && !accountInfo.org.subscriptions) {
|
|
145
|
+
accountInfo.org.subscriptions = [];
|
|
146
|
+
} // Return account info if found.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
return accountInfo;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async createServiceAccount(options) {
|
|
153
|
+
const accountInfo = await this.getAccountInfo();
|
|
154
|
+
const result = await _classPrivateFieldGet(this, _amplifySdk).client.create(accountInfo, accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.org, options);
|
|
155
|
+
return result.client;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async getServiceAccounts() {
|
|
159
|
+
const result = await _classPrivateFieldGet(this, _amplifySdk).client.list(await this.getAccountInfo());
|
|
160
|
+
return result.clients || [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async getTeams() {
|
|
164
|
+
var _account$team, _teams$find;
|
|
165
|
+
|
|
166
|
+
log(`getTeams`);
|
|
167
|
+
const account = await this.getAccountInfo();
|
|
168
|
+
const {
|
|
169
|
+
teams
|
|
170
|
+
} = await _classPrivateFieldGet(this, _amplifySdk).team.list(account);
|
|
171
|
+
const teamGuid = ((_account$team = account.team) === null || _account$team === void 0 ? void 0 : _account$team.guid) && ((_teams$find = teams.find(team => team.guid === account.team.guid)) === null || _teams$find === void 0 ? void 0 : _teams$find.guid);
|
|
172
|
+
return teams.map(team => ({ ...team,
|
|
173
|
+
default: teamGuid && team.guid === teamGuid || !teamGuid && team.default
|
|
174
|
+
}));
|
|
63
175
|
}
|
|
64
176
|
|
|
65
177
|
}
|
|
@@ -84,22 +84,63 @@ const handleResponse = response => {
|
|
|
84
84
|
return /application\/json/.test(response.headers['content-type']) ? JSON.parse(response.body) : response.body;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
const updateRequestError = err => {
|
|
88
|
+
var _err$response;
|
|
89
|
+
|
|
90
|
+
// Do not change given object if it's a timeout error.
|
|
91
|
+
if (err instanceof _got.TimeoutError) {
|
|
92
|
+
return;
|
|
93
|
+
} // If we have a JSON HTTP body, then turn it into a dictionary.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
let jsonBody = null;
|
|
97
|
+
|
|
98
|
+
if (err instanceof _got.RequestError && (_err$response = err.response) !== null && _err$response !== void 0 && _err$response.body) {
|
|
99
|
+
jsonBody = handleResponse(err.response);
|
|
100
|
+
} // Turn given Error object into an "ApiServerError" or "ApiServerErrorResponse" object.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if (!jsonBody) {
|
|
104
|
+
// No response message received. Could be any kind of exception error.
|
|
105
|
+
// Turn given error into an "ApiServerErrorResponse" object.
|
|
106
|
+
err.errors = [err];
|
|
107
|
+
} else if (typeof jsonBody.code === 'number' && typeof jsonBody.description === 'string') {
|
|
108
|
+
// We received a "Platform" server error response.
|
|
109
|
+
err.status = jsonBody.code;
|
|
110
|
+
err.detail = jsonBody.description;
|
|
111
|
+
} else {
|
|
112
|
+
// Assume we received a "Central" server error response which should already conform to "ApiServerError".
|
|
113
|
+
Object.assign(err, jsonBody);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Creates an object with various functions communicating with the API Server.
|
|
118
|
+
* @param {String} clientId Client id to use.
|
|
119
|
+
* @param {String} [team] The preferred team to use. This value overrides the default from the Axway CLI config.
|
|
120
|
+
* @param {String} [region] The preferred region to use.
|
|
121
|
+
* @returns Object containing data retrieval functions.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
|
|
87
125
|
const dataService = async ({
|
|
88
126
|
account,
|
|
89
127
|
baseUrl,
|
|
90
128
|
basePath = _types.BasePaths.ApiServer,
|
|
91
129
|
clientId,
|
|
92
|
-
region
|
|
130
|
+
region,
|
|
131
|
+
team
|
|
93
132
|
}) => {
|
|
94
133
|
// see above
|
|
95
134
|
// await versionCheckWarning();
|
|
96
135
|
const {
|
|
97
136
|
orgId,
|
|
98
137
|
orgRegion,
|
|
138
|
+
teamGuid,
|
|
99
139
|
token
|
|
100
140
|
} = await new _CoreConfigController.CoreConfigController().getAuthInfo({
|
|
101
141
|
account,
|
|
102
|
-
clientId
|
|
142
|
+
clientId,
|
|
143
|
+
team
|
|
103
144
|
});
|
|
104
145
|
const url = await getBaseUrl(baseUrl, basePath, region, orgRegion);
|
|
105
146
|
const defaultHeaders = getDefaultHeaders({
|
|
@@ -110,6 +151,13 @@ const dataService = async ({
|
|
|
110
151
|
|
|
111
152
|
const fetch = async (method, url, params = {}) => {
|
|
112
153
|
try {
|
|
154
|
+
// add the team guid
|
|
155
|
+
if (teamGuid) {
|
|
156
|
+
const parsed = new _url.URL(url);
|
|
157
|
+
parsed.searchParams.set('query', `owner.id==${teamGuid}`);
|
|
158
|
+
url = parsed.toString();
|
|
159
|
+
}
|
|
160
|
+
|
|
113
161
|
const response = await got[method](url, {
|
|
114
162
|
followRedirect: false,
|
|
115
163
|
retry: 0,
|
|
@@ -124,14 +172,7 @@ const dataService = async ({
|
|
|
124
172
|
|
|
125
173
|
return response;
|
|
126
174
|
} catch (err) {
|
|
127
|
-
|
|
128
|
-
var _err$response;
|
|
129
|
-
|
|
130
|
-
Object.assign(err, ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.body) && handleResponse(err.response) || {
|
|
131
|
-
errors: [err]
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
175
|
+
updateRequestError(err);
|
|
135
176
|
throw err;
|
|
136
177
|
}
|
|
137
178
|
};
|
|
@@ -250,14 +291,7 @@ const dataService = async ({
|
|
|
250
291
|
stream.on('error', reject);
|
|
251
292
|
});
|
|
252
293
|
} catch (err) {
|
|
253
|
-
|
|
254
|
-
var _err$response2;
|
|
255
|
-
|
|
256
|
-
Object.assign(err, ((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.body) && handleResponse(err.response) || {
|
|
257
|
-
errors: [err]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
294
|
+
updateRequestError(err);
|
|
261
295
|
throw err;
|
|
262
296
|
}
|
|
263
297
|
}
|
package/dist/common/types.js
CHANGED
|
@@ -11,7 +11,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
11
11
|
|
|
12
12
|
const cliVersionHeader = 'x-axway-cli-version';
|
|
13
13
|
exports.cliVersionHeader = cliVersionHeader;
|
|
14
|
-
const docsUrl = 'https://docs.axway.com/bundle/
|
|
14
|
+
const docsUrl = 'https://docs.axway.com/bundle/amplify-central/page/docs/index.html';
|
|
15
15
|
exports.docsUrl = docsUrl;
|
|
16
16
|
const ABORT_TIMEOUT = process.env.NODE_ENV === 'test' ? 1e3 : 30e3;
|
|
17
17
|
exports.ABORT_TIMEOUT = ABORT_TIMEOUT;
|
|
@@ -149,9 +149,9 @@ const APICDeployments = {
|
|
|
149
149
|
};
|
|
150
150
|
exports.APICDeployments = APICDeployments;
|
|
151
151
|
const commonCmdArgsDescription = {
|
|
152
|
-
'--account [value]':
|
|
153
|
-
'--region [value]':
|
|
154
|
-
'--no-cache':
|
|
152
|
+
'--account [value]': 'Override your default account config',
|
|
153
|
+
'--region [value]': 'Override your region config',
|
|
154
|
+
'--no-cache': 'Do not use cache when communicating with the server',
|
|
155
155
|
'--base-url [value]': {
|
|
156
156
|
hidden: true
|
|
157
157
|
},
|
|
@@ -726,5 +726,7 @@ class IstioInstallValues {
|
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
}
|
|
729
|
+
/** Provides information for a platform team. */
|
|
730
|
+
|
|
729
731
|
|
|
730
732
|
exports.IstioInstallValues = IstioInstallValues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axway/axway-central-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Manage APIs, services and publish to the Unified Catalog",
|
|
5
5
|
"homepage": "https://platform.axway.com",
|
|
6
6
|
"author": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@axway/amplify-cli-utils": "^5.0.3",
|
|
45
45
|
"chalk": "^4.1.2",
|
|
46
|
-
"cli-kit": "^1.
|
|
46
|
+
"cli-kit": "^1.15.0",
|
|
47
47
|
"dayjs": "^1.10.7",
|
|
48
48
|
"easy-table": "^1.2.0",
|
|
49
49
|
"extract-zip": "^2.0.1",
|
|
@@ -60,42 +60,42 @@
|
|
|
60
60
|
"tmp": "^0.2.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@babel/cli": "^7.
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
66
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
67
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
68
|
-
"@babel/preset-env": "^7.
|
|
69
|
-
"@babel/preset-typescript": "^7.
|
|
63
|
+
"@babel/cli": "^7.16.0",
|
|
64
|
+
"@babel/core": "^7.16.0",
|
|
65
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
66
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
67
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
68
|
+
"@babel/preset-env": "^7.16.4",
|
|
69
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
70
70
|
"@types/chai": "^4.2.22",
|
|
71
71
|
"@types/chai-as-promised": "^7.1.4",
|
|
72
72
|
"@types/easy-table": "^0.0.33",
|
|
73
73
|
"@types/form-data": "^2.5.0",
|
|
74
74
|
"@types/fs-extra": "^9.0.13",
|
|
75
75
|
"@types/inquirer": "^8.1.3",
|
|
76
|
-
"@types/js-yaml": "^4.0.
|
|
77
|
-
"@types/lodash": "^4.14.
|
|
76
|
+
"@types/js-yaml": "^4.0.5",
|
|
77
|
+
"@types/lodash": "^4.14.177",
|
|
78
78
|
"@types/mocha": "^9.0.0",
|
|
79
|
-
"@types/node": "^16.11.
|
|
79
|
+
"@types/node": "^16.11.10",
|
|
80
80
|
"@types/rx": "^4.1.2",
|
|
81
81
|
"@types/semver": "^7.3.9",
|
|
82
|
-
"@types/sinon": "^10.0.
|
|
82
|
+
"@types/sinon": "^10.0.6",
|
|
83
83
|
"@types/tmp": "^0.2.2",
|
|
84
84
|
"@types/update-notifier": "^5.1.0",
|
|
85
|
-
"@types/uuid": "^8.3.
|
|
85
|
+
"@types/uuid": "^8.3.3",
|
|
86
86
|
"babel-plugin-lodash": "^3.3.4",
|
|
87
87
|
"chai": "^4.3.4",
|
|
88
88
|
"chai-as-promised": "^7.1.1",
|
|
89
|
-
"core-js": "^3.19.
|
|
89
|
+
"core-js": "^3.19.1",
|
|
90
90
|
"mocha": "^9.1.3",
|
|
91
|
-
"nock": "^13.1
|
|
92
|
-
"nodemon": "^2.0.
|
|
91
|
+
"nock": "^13.2.1",
|
|
92
|
+
"nodemon": "^2.0.15",
|
|
93
93
|
"nyc": "^15.1.0",
|
|
94
94
|
"prettier": "^2.4.1",
|
|
95
95
|
"sinon": "^11.1.2",
|
|
96
|
-
"source-map-support": "^0.5.
|
|
96
|
+
"source-map-support": "^0.5.21",
|
|
97
97
|
"ts-mocha": "^8.0.0",
|
|
98
|
-
"typescript": "^4.
|
|
98
|
+
"typescript": "^4.5.2"
|
|
99
99
|
},
|
|
100
100
|
"jest": {
|
|
101
101
|
"verbose": true,
|