@axway/axway-central-cli 3.9.0-rc.2 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.security-profile.json +18 -0
- package/dist/commands/get/index.js +27 -6
- package/dist/commands/install/awsSaasAgents.js +7 -6
- package/dist/commands/install/azureSaasAgents.js +7 -6
- package/dist/common/ApiServerClient.js +60 -64
- package/dist/common/dataService.js +19 -16
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0",
|
|
3
|
+
"project": "Amplify - APIC CLI",
|
|
4
|
+
"repo_url": "https://git.ecd.axway.org/apigov/apicentral-cli",
|
|
5
|
+
"security_guide": "https://docs.axway.com/bundle/axway_resources/page/amplify_api_management_platform_security_white_paper.html",
|
|
6
|
+
"requirements": {
|
|
7
|
+
"fortify": true,
|
|
8
|
+
"irius-risk": false,
|
|
9
|
+
"pentest": false,
|
|
10
|
+
"twistlock": false,
|
|
11
|
+
"blackduck": false,
|
|
12
|
+
"third-party-policy-violation": false,
|
|
13
|
+
"appspider": false,
|
|
14
|
+
"insightvm": false
|
|
15
|
+
},
|
|
16
|
+
"suppressions": [
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -16,14 +16,15 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
16
16
|
const {
|
|
17
17
|
log
|
|
18
18
|
} = (0, _snooplogg.default)('central: get');
|
|
19
|
-
const getListOrByName = async (resourceDef, client, scopeName, resourceName, scopeDef, query, progressListener, expand, langDef) => {
|
|
19
|
+
const getListOrByName = async (resourceDef, client, scopeName, resourceName, scopeDef, query, progressListener, expand, langDef, fieldSet) => {
|
|
20
20
|
return resourceName ? await client.getResourceByName({
|
|
21
21
|
resourceDef,
|
|
22
22
|
resourceName,
|
|
23
23
|
scopeDef,
|
|
24
24
|
scopeName,
|
|
25
25
|
expand,
|
|
26
|
-
langDef
|
|
26
|
+
langDef,
|
|
27
|
+
fieldSet
|
|
27
28
|
}) : await client.getResourcesList({
|
|
28
29
|
resourceDef,
|
|
29
30
|
scopeDef,
|
|
@@ -31,7 +32,8 @@ const getListOrByName = async (resourceDef, client, scopeName, resourceName, sco
|
|
|
31
32
|
query,
|
|
32
33
|
progressListener,
|
|
33
34
|
expand,
|
|
34
|
-
langDef
|
|
35
|
+
langDef,
|
|
36
|
+
fieldSet
|
|
35
37
|
});
|
|
36
38
|
};
|
|
37
39
|
const get = exports.get = {
|
|
@@ -159,7 +161,7 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
159
161
|
*/
|
|
160
162
|
if (scope) {
|
|
161
163
|
const results = await Promise.all(defs.filter(defs => !scope.kind || !defs.scope || defs.scope.spec.kind === scope.kind).map(async defs => ({
|
|
162
|
-
response: await getListOrByName(defs.resource, client, scope.name, resourceName, defs.scope, query, progressListener, languageExpand, languageDefinition),
|
|
164
|
+
response: await getListOrByName(defs.resource, client, scope.name, resourceName, defs.scope, query, progressListener, languageExpand, languageDefinition, argv.output ? undefined : getFieldSetFromDefinitionColumns(defs)),
|
|
163
165
|
cli: defs.cli
|
|
164
166
|
})));
|
|
165
167
|
results.forEach(({
|
|
@@ -179,7 +181,7 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
179
181
|
}
|
|
180
182
|
});
|
|
181
183
|
const results = await Promise.all(Object.values(defsMatchingGroup).map(async defs => ({
|
|
182
|
-
response: await getListOrByName(defs.resource, client, undefined, resourceName, undefined, query, progressListener, languageExpand, languageDefinition),
|
|
184
|
+
response: await getListOrByName(defs.resource, client, undefined, resourceName, undefined, query, progressListener, languageExpand, languageDefinition, argv.output ? undefined : getFieldSetFromDefinitionColumns(defs)),
|
|
183
185
|
cli: defs.cli
|
|
184
186
|
})));
|
|
185
187
|
results.forEach(({
|
|
@@ -248,4 +250,23 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
248
250
|
desc: `Show the language definition constraint of the returned object. One of: Comma Separated values of ${_types.LanguageTypes.French} | ${_types.LanguageTypes.US} | ${_types.LanguageTypes.German} | ${_types.LanguageTypes.Portugese}`
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
|
-
};
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Gets the resource field names to be shown when outputting the resource as a table.
|
|
257
|
+
* These names are to be assigned to the api-server HTTP GET request's "fields" query param.
|
|
258
|
+
* @param def The resource definition providing the columns to be shown in the outputed table.
|
|
259
|
+
* @returns Returns a set set of field names.
|
|
260
|
+
*/
|
|
261
|
+
function getFieldSetFromDefinitionColumns(def) {
|
|
262
|
+
var _def$cli, _def$cli$spec, _def$cli$spec$columns;
|
|
263
|
+
const fieldSet = new Set();
|
|
264
|
+
(_def$cli = def.cli) === null || _def$cli === void 0 ? void 0 : (_def$cli$spec = _def$cli.spec) === null || _def$cli$spec === void 0 ? void 0 : (_def$cli$spec$columns = _def$cli$spec.columns) === null || _def$cli$spec$columns === void 0 ? void 0 : _def$cli$spec$columns.forEach(column => {
|
|
265
|
+
let fieldName = column.jsonPath;
|
|
266
|
+
if (fieldName.startsWith('.')) {
|
|
267
|
+
fieldName = fieldName.substring(1);
|
|
268
|
+
}
|
|
269
|
+
fieldSet.add(fieldName);
|
|
270
|
+
});
|
|
271
|
+
return fieldSet;
|
|
272
|
+
}
|
|
@@ -39,9 +39,9 @@ class AWSDataplaneConfig extends DataplaneConfig {
|
|
|
39
39
|
class Sampling {
|
|
40
40
|
constructor() {
|
|
41
41
|
_defineProperty(this, "percentage", void 0);
|
|
42
|
-
_defineProperty(this, "
|
|
42
|
+
_defineProperty(this, "onlyErrors", void 0);
|
|
43
43
|
this.percentage = 1;
|
|
44
|
-
this.
|
|
44
|
+
this.onlyErrors = true;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
class Sanitize {
|
|
@@ -156,7 +156,7 @@ const SaasPrompts = {
|
|
|
156
156
|
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
157
157
|
QUEUE: 'Do you want to discover immediately after installation',
|
|
158
158
|
SAMP_PERCENTAGE: 'Enter the percentage of transactions to sample',
|
|
159
|
-
|
|
159
|
+
SAMP_ONLY_ERRS: 'Do you want to sample only the error transactions for Business and Consumer Insights',
|
|
160
160
|
REDACT_SHOW: 'Enter a regular expression for {0}s that may be shown',
|
|
161
161
|
ENTER_SANITIZE_RULE: 'Do you want to add sanitization rules for {0}s',
|
|
162
162
|
SANITIZE_KEY: 'Enter a regular expression for {0} keys that values should be sanitized',
|
|
@@ -266,9 +266,10 @@ const askForSampling = async hostedAgentValues => {
|
|
|
266
266
|
});
|
|
267
267
|
|
|
268
268
|
// ask sampling all errorsSN
|
|
269
|
-
hostedAgentValues.sampling.
|
|
270
|
-
msg: SaasPrompts.
|
|
271
|
-
choices: _types.YesNoChoices
|
|
269
|
+
hostedAgentValues.sampling.onlyErrors = (await (0, _basicPrompts.askList)({
|
|
270
|
+
msg: SaasPrompts.SAMP_ONLY_ERRS,
|
|
271
|
+
choices: _types.YesNoChoices,
|
|
272
|
+
default: _types.YesNo.No
|
|
272
273
|
})) === _types.YesNo.Yes;
|
|
273
274
|
return hostedAgentValues;
|
|
274
275
|
};
|
|
@@ -54,9 +54,9 @@ class AzureDataplaneConfig extends DataplaneConfig {
|
|
|
54
54
|
class Sampling {
|
|
55
55
|
constructor() {
|
|
56
56
|
_defineProperty(this, "percentage", void 0);
|
|
57
|
-
_defineProperty(this, "
|
|
57
|
+
_defineProperty(this, "onlyErrors", void 0);
|
|
58
58
|
this.percentage = 1;
|
|
59
|
-
this.
|
|
59
|
+
this.onlyErrors = true;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
class Sanitize {
|
|
@@ -174,7 +174,7 @@ const SaasPrompts = {
|
|
|
174
174
|
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
175
175
|
QUEUE: 'Do you want to discover immediately after installation',
|
|
176
176
|
SAMP_PERCENTAGE: 'Enter the percentage of transactions to sample',
|
|
177
|
-
|
|
177
|
+
SAMP_ONLY_ERRS: 'Do you want to sample only the error transactions for Business and Consumer Insights',
|
|
178
178
|
REDACT_SHOW: 'Enter a regular expression for {0}s that may be shown',
|
|
179
179
|
ENTER_SANITIZE_RULE: 'Do you want to add sanitization rules for {0}s',
|
|
180
180
|
SANITIZE_KEY: 'Enter a regular expression for {0} keys that values should be sanitized',
|
|
@@ -288,9 +288,10 @@ const askForSampling = async hostedAgentValues => {
|
|
|
288
288
|
});
|
|
289
289
|
|
|
290
290
|
// ask sampling all errorsSN
|
|
291
|
-
hostedAgentValues.sampling.
|
|
292
|
-
msg: SaasPrompts.
|
|
293
|
-
choices: _types.YesNoChoices
|
|
291
|
+
hostedAgentValues.sampling.onlyErrors = (await (0, _basicPrompts.askList)({
|
|
292
|
+
msg: SaasPrompts.SAMP_ONLY_ERRS,
|
|
293
|
+
choices: _types.YesNoChoices,
|
|
294
|
+
default: _types.YesNo.No
|
|
294
295
|
})) === _types.YesNo.Yes;
|
|
295
296
|
return hostedAgentValues;
|
|
296
297
|
};
|
|
@@ -59,8 +59,9 @@ class ApiServerClient {
|
|
|
59
59
|
/**
|
|
60
60
|
* Build resource url based on its ResourceDefinition and passed scope def and name.
|
|
61
61
|
* Note that for scope url part both name and def needed.
|
|
62
|
+
* The returned URL path is expected to be appended to the base URL.
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
buildResourceUrlPath({
|
|
64
65
|
resourceDef,
|
|
65
66
|
resourceName,
|
|
66
67
|
scopeDef,
|
|
@@ -68,60 +69,51 @@ class ApiServerClient {
|
|
|
68
69
|
version = ApiServerVersions.v1alpha1,
|
|
69
70
|
forceDelete = false,
|
|
70
71
|
expand,
|
|
71
|
-
langDef
|
|
72
|
+
langDef,
|
|
73
|
+
fieldSet
|
|
72
74
|
}) {
|
|
73
75
|
const groupUrl = `/${resourceDef.metadata.scope.name}/${version}`;
|
|
74
76
|
const scopeUrl = scopeName && scopeDef ? `/${scopeDef.spec.plural}/${encodeURIComponent(scopeName)}` : '';
|
|
75
77
|
const resourceUrl = `/${resourceDef.spec.plural}`;
|
|
76
78
|
const nameUrl = resourceName ? `/${encodeURIComponent(resourceName)}` : '';
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* Build language definition url based on the language code.
|
|
93
|
-
*/
|
|
94
|
-
buildLanguageDefinitionUrl({
|
|
95
|
-
langCode
|
|
96
|
-
}) {
|
|
97
|
-
let langDefUrl = '';
|
|
98
|
-
let i = 0;
|
|
99
|
-
let embed = '?embed=';
|
|
100
|
-
let expand = '&expand=languages,';
|
|
101
|
-
let fields = '&fields=languages,group,apiVersion,name,kind,metadata,';
|
|
102
|
-
const langCodeArr = langCode.split(',');
|
|
103
|
-
let languageTypesArr = [];
|
|
104
|
-
Object.keys(_types.LanguageTypes).forEach(key => languageTypesArr.push((0, _utils.ValueFromKey)(_types.LanguageTypes, key)));
|
|
105
|
-
langCodeArr.forEach(code => {
|
|
106
|
-
if (code.trim() != '') {
|
|
107
|
-
if (!languageTypesArr.includes(code)) {
|
|
79
|
+
const embedSet = new Set();
|
|
80
|
+
const expandSet = new Set(expand === null || expand === void 0 ? void 0 : expand.split(','));
|
|
81
|
+
if (langDef) {
|
|
82
|
+
var _fieldSet;
|
|
83
|
+
(_fieldSet = fieldSet) !== null && _fieldSet !== void 0 ? _fieldSet : fieldSet = new Set();
|
|
84
|
+
fieldSet.add('languages').add('group').add('apiVersion').add('name').add('kind').add('metadata');
|
|
85
|
+
expandSet.add('languages');
|
|
86
|
+
let languageTypesArr = [];
|
|
87
|
+
Object.keys(_types.LanguageTypes).forEach(key => languageTypesArr.push((0, _utils.ValueFromKey)(_types.LanguageTypes, key)));
|
|
88
|
+
langDef.split(',').forEach(code => {
|
|
89
|
+
if (languageTypesArr.includes(code)) {
|
|
90
|
+
embedSet.add(`languages-${code.trim()}.resource`);
|
|
91
|
+
expandSet.add(`languages-${code.trim()}`);
|
|
92
|
+
fieldSet.add(`languages-${code.trim()}.values`);
|
|
93
|
+
} else if (code.trim().length > 0) {
|
|
108
94
|
console.log(_chalk.default.yellow(`\n\'${code}\' language code is not supported. Allowed language codes: ${_types.LanguageTypes.French} | ${_types.LanguageTypes.German} | ${_types.LanguageTypes.US} | ${_types.LanguageTypes.Portugese}.'`));
|
|
109
|
-
} else {
|
|
110
|
-
if (i < langCodeArr.length - 1) {
|
|
111
|
-
embed = embed + `languages-${code.trim()}.resource` + ",";
|
|
112
|
-
expand = expand + `languages-${code.trim()}` + ",";
|
|
113
|
-
fields = fields + `languages-${code.trim()}.values` + ",";
|
|
114
|
-
} else {
|
|
115
|
-
embed = embed + `languages-${code.trim()}.resource`;
|
|
116
|
-
expand = expand + `languages-${code.trim()}`;
|
|
117
|
-
fields = fields + `languages-${code.trim()}.values`;
|
|
118
|
-
}
|
|
119
95
|
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
let url = `${groupUrl}${scopeUrl}${resourceUrl}${nameUrl}`;
|
|
99
|
+
if (forceDelete || embedSet.size || expandSet.size || fieldSet) {
|
|
100
|
+
const queryParams = [];
|
|
101
|
+
if (forceDelete) {
|
|
102
|
+
queryParams.push('forceDelete=true');
|
|
120
103
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
if (embedSet.size) {
|
|
105
|
+
queryParams.push('embed=' + [...embedSet].join(','));
|
|
106
|
+
}
|
|
107
|
+
if (expandSet.size) {
|
|
108
|
+
queryParams.push('expand=' + [...expandSet].join(','));
|
|
109
|
+
}
|
|
110
|
+
if (fieldSet) {
|
|
111
|
+
// If field set is empty, then return no fields. This is intentional.
|
|
112
|
+
queryParams.push('fields=' + [...fieldSet].join(','));
|
|
113
|
+
}
|
|
114
|
+
url += '?' + queryParams.join('&');
|
|
115
|
+
}
|
|
116
|
+
return url;
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
/**
|
|
@@ -156,7 +148,7 @@ class ApiServerClient {
|
|
|
156
148
|
account: this.account,
|
|
157
149
|
team: this.team
|
|
158
150
|
});
|
|
159
|
-
const
|
|
151
|
+
const urlPath = this.buildResourceUrlPath({
|
|
160
152
|
resourceDef,
|
|
161
153
|
resourceName,
|
|
162
154
|
scopeDef,
|
|
@@ -195,7 +187,7 @@ class ApiServerClient {
|
|
|
195
187
|
return (0, _isEmpty.default)(foundSubResources) ? null : Object.keys(foundSubResources).map(key => {
|
|
196
188
|
return {
|
|
197
189
|
name: key,
|
|
198
|
-
operation: () => service.put(`${
|
|
190
|
+
operation: () => service.put(`${urlPath}/${key}?fields=${key}`, {
|
|
199
191
|
[key]: foundSubResources[key]
|
|
200
192
|
}).catch(err => Promise.reject({
|
|
201
193
|
name: key,
|
|
@@ -314,13 +306,13 @@ class ApiServerClient {
|
|
|
314
306
|
team: this.team
|
|
315
307
|
});
|
|
316
308
|
const version = resource.apiVersion === undefined ? (0, _utils.getLatestServedAPIVersion)(resourceDef) : resource.apiVersion;
|
|
317
|
-
const
|
|
309
|
+
const urlPath = this.buildResourceUrlPath({
|
|
318
310
|
resourceDef,
|
|
319
311
|
scopeDef,
|
|
320
312
|
scopeName,
|
|
321
313
|
version
|
|
322
314
|
});
|
|
323
|
-
const response = await service.post(
|
|
315
|
+
const response = await service.post(urlPath, (0, _utils.sanitizeMetadata)(resource));
|
|
324
316
|
if (!resource.name) {
|
|
325
317
|
log('createResource, resource does not have a logical name');
|
|
326
318
|
result.warning = true;
|
|
@@ -389,14 +381,14 @@ class ApiServerClient {
|
|
|
389
381
|
account: this.account,
|
|
390
382
|
team: this.team
|
|
391
383
|
});
|
|
392
|
-
const
|
|
384
|
+
const urlPath = this.buildResourceUrlPath({
|
|
393
385
|
resourceDef,
|
|
394
386
|
resourceName: resource.name,
|
|
395
387
|
scopeDef,
|
|
396
388
|
scopeName,
|
|
397
389
|
version
|
|
398
390
|
});
|
|
399
|
-
result.data = await service.put(
|
|
391
|
+
result.data = await service.put(urlPath, (0, _utils.sanitizeMetadata)(resource));
|
|
400
392
|
} catch (e) {
|
|
401
393
|
log('updateResource, error', e);
|
|
402
394
|
// expecting only a valid ApiServer error response here
|
|
@@ -469,14 +461,14 @@ class ApiServerClient {
|
|
|
469
461
|
const knownSubResourcesNames = (_resourceDef$spec$sub3 = (_resourceDef$spec$sub4 = resourceDef.spec.subResources) === null || _resourceDef$spec$sub4 === void 0 ? void 0 : _resourceDef$spec$sub4.names) !== null && _resourceDef$spec$sub3 !== void 0 ? _resourceDef$spec$sub3 : [];
|
|
470
462
|
const foundSubResources = (0, _pickBy.default)(resource, (_, key) => subResourceName == key && knownSubResourcesNames.includes(key));
|
|
471
463
|
const resourceName = resource.name;
|
|
472
|
-
const
|
|
464
|
+
const urlPath = this.buildResourceUrlPath({
|
|
473
465
|
resourceDef,
|
|
474
466
|
resourceName,
|
|
475
467
|
scopeDef,
|
|
476
468
|
scopeName,
|
|
477
469
|
version
|
|
478
470
|
});
|
|
479
|
-
service.put(`${
|
|
471
|
+
service.put(`${urlPath}/${subResourceName}?fields=${subResourceName}`, {
|
|
480
472
|
[subResourceName]: foundSubResources[subResourceName]
|
|
481
473
|
});
|
|
482
474
|
} catch (e) {
|
|
@@ -524,7 +516,7 @@ class ApiServerClient {
|
|
|
524
516
|
account: this.account,
|
|
525
517
|
team: this.team
|
|
526
518
|
});
|
|
527
|
-
const
|
|
519
|
+
const urlPath = this.buildResourceUrlPath({
|
|
528
520
|
resourceDef,
|
|
529
521
|
resourceName,
|
|
530
522
|
scopeDef,
|
|
@@ -532,7 +524,7 @@ class ApiServerClient {
|
|
|
532
524
|
version,
|
|
533
525
|
forceDelete
|
|
534
526
|
});
|
|
535
|
-
const response = await service.delete(
|
|
527
|
+
const response = await service.delete(urlPath);
|
|
536
528
|
// note: delete "response" value from api-server is translated to an empty string currently.
|
|
537
529
|
// If its true, constructing a simple representation from provided data (definition, name, scope name)
|
|
538
530
|
// and manually set it as the "data" key.
|
|
@@ -588,7 +580,8 @@ class ApiServerClient {
|
|
|
588
580
|
query,
|
|
589
581
|
progressListener,
|
|
590
582
|
expand,
|
|
591
|
-
langDef
|
|
583
|
+
langDef,
|
|
584
|
+
fieldSet
|
|
592
585
|
}) {
|
|
593
586
|
log(`getResourcesList, spec.kind = ${resourceDef.spec.kind}`);
|
|
594
587
|
const version = (0, _utils.getLatestServedAPIVersion)(resourceDef);
|
|
@@ -603,15 +596,16 @@ class ApiServerClient {
|
|
|
603
596
|
account: this.account,
|
|
604
597
|
team: this.team
|
|
605
598
|
});
|
|
606
|
-
const
|
|
599
|
+
const urlPath = this.buildResourceUrlPath({
|
|
607
600
|
resourceDef,
|
|
608
601
|
scopeDef,
|
|
609
602
|
scopeName,
|
|
610
603
|
version,
|
|
611
604
|
expand,
|
|
612
|
-
langDef
|
|
605
|
+
langDef,
|
|
606
|
+
fieldSet
|
|
613
607
|
});
|
|
614
|
-
const response = await service.getWithPagination(
|
|
608
|
+
const response = await service.getWithPagination(urlPath, query, 50, {}, progressListener);
|
|
615
609
|
result.data = response;
|
|
616
610
|
} catch (e) {
|
|
617
611
|
log('getResourcesList, error: ', e);
|
|
@@ -641,6 +635,7 @@ class ApiServerClient {
|
|
|
641
635
|
scopeName,
|
|
642
636
|
expand,
|
|
643
637
|
langDef,
|
|
638
|
+
fieldSet,
|
|
644
639
|
resourceVersion
|
|
645
640
|
}) {
|
|
646
641
|
log(`getResourceByName, spec.kind = ${resourceDef.spec.kind}, name = ${resourceName}`);
|
|
@@ -656,16 +651,17 @@ class ApiServerClient {
|
|
|
656
651
|
account: this.account,
|
|
657
652
|
team: this.team
|
|
658
653
|
});
|
|
659
|
-
const
|
|
654
|
+
const urlPath = this.buildResourceUrlPath({
|
|
660
655
|
resourceDef,
|
|
661
656
|
resourceName,
|
|
662
657
|
scopeDef,
|
|
663
658
|
scopeName,
|
|
664
659
|
version,
|
|
665
660
|
expand,
|
|
666
|
-
langDef
|
|
661
|
+
langDef,
|
|
662
|
+
fieldSet
|
|
667
663
|
});
|
|
668
|
-
const response = await service.get(
|
|
664
|
+
const response = await service.get(urlPath);
|
|
669
665
|
result.data = response;
|
|
670
666
|
} catch (e) {
|
|
671
667
|
log('getResourceByName, error: ', e);
|
|
@@ -126,7 +126,7 @@ const dataService = async ({
|
|
|
126
126
|
clientId,
|
|
127
127
|
team
|
|
128
128
|
});
|
|
129
|
-
|
|
129
|
+
baseUrl = await getBaseUrl(baseUrl, basePath, region, orgRegion);
|
|
130
130
|
const defaultHeaders = getDefaultHeaders({
|
|
131
131
|
orgId,
|
|
132
132
|
token
|
|
@@ -158,8 +158,8 @@ const dataService = async ({
|
|
|
158
158
|
};
|
|
159
159
|
return {
|
|
160
160
|
postFormData: (route, body, headers = {}) => {
|
|
161
|
-
log(`POST (from data): ${
|
|
162
|
-
return fetch('post',
|
|
161
|
+
log(`POST (from data): ${baseUrl + route}`);
|
|
162
|
+
return fetch('post', baseUrl + route, {
|
|
163
163
|
headers: {
|
|
164
164
|
...defaultHeaders,
|
|
165
165
|
...body.getHeaders(),
|
|
@@ -169,9 +169,9 @@ const dataService = async ({
|
|
|
169
169
|
}).then(handleResponse);
|
|
170
170
|
},
|
|
171
171
|
post: (route, data, headers = {}) => {
|
|
172
|
-
log(`POST: ${
|
|
172
|
+
log(`POST: ${baseUrl + route}`);
|
|
173
173
|
log(data);
|
|
174
|
-
return fetch('post',
|
|
174
|
+
return fetch('post', baseUrl + route, {
|
|
175
175
|
headers: {
|
|
176
176
|
...defaultHeaders,
|
|
177
177
|
...headers
|
|
@@ -180,8 +180,8 @@ const dataService = async ({
|
|
|
180
180
|
}).then(handleResponse);
|
|
181
181
|
},
|
|
182
182
|
put: (route, data, headers = {}) => {
|
|
183
|
-
log(`PUT: ${
|
|
184
|
-
return fetch('put',
|
|
183
|
+
log(`PUT: ${baseUrl + route}`);
|
|
184
|
+
return fetch('put', baseUrl + route, {
|
|
185
185
|
headers: {
|
|
186
186
|
...defaultHeaders,
|
|
187
187
|
...headers
|
|
@@ -194,8 +194,8 @@ const dataService = async ({
|
|
|
194
194
|
...defaultHeaders,
|
|
195
195
|
...headers
|
|
196
196
|
};
|
|
197
|
-
log(`GET: ${
|
|
198
|
-
return fetch('get',
|
|
197
|
+
log(`GET: ${baseUrl + route}`, h);
|
|
198
|
+
return fetch('get', baseUrl + route, {
|
|
199
199
|
headers: h
|
|
200
200
|
}).then(handleResponse);
|
|
201
201
|
},
|
|
@@ -210,7 +210,10 @@ const dataService = async ({
|
|
|
210
210
|
* @param progressListener invoked multiple times where argument is assigned progress value 0-100
|
|
211
211
|
*/
|
|
212
212
|
getWithPagination: async function (route, queryParams = '', pageSize = 50, headers = {}, progressListener) {
|
|
213
|
-
const fullUrl =
|
|
213
|
+
const fullUrl = new _url.URL(baseUrl + route);
|
|
214
|
+
if (queryParams) {
|
|
215
|
+
fullUrl.searchParams.set('query', queryParams);
|
|
216
|
+
}
|
|
214
217
|
fullUrl.searchParams.set('pageSize', `${pageSize}`);
|
|
215
218
|
log(`GET (with auto-pagination): ${fullUrl.href}`);
|
|
216
219
|
const response = await fetch('get', fullUrl.toString(), {
|
|
@@ -241,9 +244,9 @@ const dataService = async ({
|
|
|
241
244
|
for (let pageIndex = 1; pageIndex < totalPages; pageIndex++) {
|
|
242
245
|
const thisPageIndex = pageIndex;
|
|
243
246
|
fullUrl.searchParams.set('page', `${thisPageIndex + 1}`);
|
|
244
|
-
const
|
|
247
|
+
const nextRoute = fullUrl.href.substring(baseUrl.length);
|
|
245
248
|
otherPagesCalls.push(limit(async () => {
|
|
246
|
-
allPages[thisPageIndex] = await this.get(
|
|
249
|
+
allPages[thisPageIndex] = await this.get(nextRoute, headers);
|
|
247
250
|
pageDownloadCount++;
|
|
248
251
|
updateProgress();
|
|
249
252
|
}));
|
|
@@ -253,8 +256,8 @@ const dataService = async ({
|
|
|
253
256
|
return (0, _flatten.default)(allPages);
|
|
254
257
|
},
|
|
255
258
|
delete: (route, headers = {}) => {
|
|
256
|
-
log(`DELETE: ${
|
|
257
|
-
return fetch('delete',
|
|
259
|
+
log(`DELETE: ${baseUrl + route}`);
|
|
260
|
+
return fetch('delete', baseUrl + route, {
|
|
258
261
|
headers: {
|
|
259
262
|
...defaultHeaders,
|
|
260
263
|
...headers
|
|
@@ -264,8 +267,8 @@ const dataService = async ({
|
|
|
264
267
|
download: async route => {
|
|
265
268
|
try {
|
|
266
269
|
return await new Promise((resolve, reject) => {
|
|
267
|
-
log(`DOWNLOAD: ${
|
|
268
|
-
const stream = got.stream(
|
|
270
|
+
log(`DOWNLOAD: ${baseUrl + route}`);
|
|
271
|
+
const stream = got.stream(baseUrl + route, {
|
|
269
272
|
retry: 0,
|
|
270
273
|
timeout: _types.ABORT_TIMEOUT
|
|
271
274
|
});
|