@axway/axway-central-cli 2.12.1 → 2.12.3

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.
@@ -133,14 +133,13 @@ ${defsManager.getDefsTableForHelpMsg()}`);
133
133
 
134
134
  (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
135
135
  /**
136
- 1) Execute getByName or getList calls for every definition that match scope name/kind if a user provides -s
137
- param to the cli.
138
- 2) It is possible to execute list (get all) api calls for scoped resources without providing the scope in
139
- the path so api-server returns the entire list in all scopes, for example for "Document" kind calling
136
+ 1) If "scope" param provided: execute getByName or getList calls for every definition that match this scope name/kind.
137
+ 2) If "scope" param is not provided: execute list (get all) api calls for scoped resources without providing the scope in
138
+ the path so api-server returns the entire list in all scopes. For example, using "Document" kind and calling
140
139
  https://apicentral.axway.com/apis/catalog/v1alpha1/documents returns a list of documents in Asset and AssetRelease
141
- scopes in a single api call. So take the first resource definition + cli definition and do call, if user is
142
- not providing the "scope" param. Note: this logic might have some edge cases if same kind can be used for
143
- "scoped" and "scope" resources and api-server is not handling this case correctly anymore.
140
+ scopes in a single api call. So getting unique list of groups and finding first matching definitions to do a call
141
+ Note: this logic might have some edge cases if same kind can be used for "scoped" and "scope" resources and api-server is
142
+ not handling this case correctly anymore.
144
143
  */
145
144
 
146
145
  if (scope) {
@@ -158,10 +157,24 @@ ${defsManager.getDefsTableForHelpMsg()}`);
158
157
  });
159
158
  });
160
159
  } else {
161
- let response = await getListOrByName(defs[0].resource, client, undefined, resourceName, undefined, query, progressListener);
162
- getResults.push({
163
- columns: defs[0].cli.spec.columns,
164
- response
160
+ const defsMatchingGroup = {};
161
+ defs.forEach(def => {
162
+ if (!defsMatchingGroup[def.resource.metadata.scope.name]) {
163
+ defsMatchingGroup[def.resource.metadata.scope.name] = def;
164
+ }
165
+ });
166
+ const results = await Promise.all(Object.values(defsMatchingGroup).map(async defs => ({
167
+ response: await getListOrByName(defs.resource, client, undefined, resourceName, undefined, query, progressListener),
168
+ cli: defs.cli
169
+ })));
170
+ results.forEach(({
171
+ response,
172
+ cli
173
+ }) => {
174
+ getResults.push({
175
+ columns: cli.spec.columns,
176
+ response
177
+ });
165
178
  });
166
179
  }
167
180
  } // resolve team guids
@@ -998,8 +998,6 @@ class ApiServerClient {
998
998
  } else {
999
999
  throw e;
1000
1000
  }
1001
-
1002
- ;
1003
1001
  }
1004
1002
  }
1005
1003
 
@@ -28,10 +28,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
28
28
  const {
29
29
  log
30
30
  } = (0, _snooplogg.default)('central:class.DefinitionsManager');
31
+
31
32
  /**
32
33
  * Get / fetch / set specs.
33
34
  */
34
-
35
35
  class DefinitionsManager {
36
36
  constructor(apiServerClient) {
37
37
  _defineProperty(this, "apiServerClient", void 0);
@@ -282,6 +282,22 @@ class DefinitionsManager {
282
282
  });
283
283
  return t.sort(['RESOURCE']).toString();
284
284
  }
285
+
286
+ findDefsByKind(kind) {
287
+ log('findDefsByKind: ', kind);
288
+ const res = [...this.resources].reduce((a, [_, def]) => {
289
+ if (def.spec.kind === kind) {
290
+ a.push({
291
+ resource: def,
292
+ cli: [...this.cli].find(([_, cliDef]) => cliDef.spec.resourceDefinition === def.name)[1],
293
+ scope: def.spec.scope ? [...this.resources].find(([_, resDef]) => resDef.spec.kind === def.spec.scope.kind)[1] : undefined
294
+ });
295
+ }
296
+
297
+ return a;
298
+ }, []);
299
+ return res.length ? res : null;
300
+ }
285
301
  /**
286
302
  * Returns set of related definitions if word is known.
287
303
  * @param word word to search for
@@ -307,12 +323,15 @@ class DefinitionsManager {
307
323
  var _cliDef$spec$names$sh;
308
324
 
309
325
  if (cliDef.spec.names.plural === word || cliDef.spec.names.singular === word || cliDef.spec.names.shortNames.includes(word) || (_cliDef$spec$names$sh = cliDef.spec.names.shortNamesAlias) !== null && _cliDef$spec$names$sh !== void 0 && _cliDef$spec$names$sh.includes(word)) {
326
+ var _this$findDefsByKind;
327
+
310
328
  // note: mind non-null assertion
311
329
  const resource = this.resources.get(cliDef.spec.resourceDefinition);
330
+ const scope = resource.spec.scope ? (_this$findDefsByKind = this.findDefsByKind(resource.spec.scope.kind)) === null || _this$findDefsByKind === void 0 ? void 0 : _this$findDefsByKind[0].resource : null;
312
331
  a.push({
313
332
  resource,
314
333
  cli: cliDef,
315
- scope: resource.spec.scope ? this.resources.get(resource === null || resource === void 0 ? void 0 : resource.spec.scope.kind.toLowerCase()) : undefined
334
+ scope: !!scope ? scope : undefined
316
335
  });
317
336
  }
318
337
 
@@ -79,6 +79,8 @@ const parseAsTable = (response, columns) => {
79
79
  value = (0, _dayjs.default)(value).fromNow();
80
80
  } else if (col.type === 'teamGuid' && !value) {
81
81
  value = _chalk.default.gray('---');
82
+ } else if (value && value.length > _types.MAX_TABLE_STRING_LENGTH + 3) {
83
+ value = value.substring(0, _types.MAX_TABLE_STRING_LENGTH / 2) + '...' + value.substring(value.length - _types.MAX_TABLE_STRING_LENGTH / 2);
82
84
  }
83
85
 
84
86
  t.cell(col.name.toUpperCase(), value);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
6
+ exports.docsUrl = exports.commonCmdArgsDescription = exports.cliVersionHeader = exports.YesNoChoices = exports.YesNo = exports.WAIT_TIMEOUT = exports.TrueFalseChoices = exports.TrueFalse = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.Regions = exports.PublicRepoUrl = exports.PublicDockerRepoBaseUrl = exports.Protocol = exports.ProdBaseUrls = exports.Platforms = exports.OutputTypes = exports.MAX_TABLE_STRING_LENGTH = exports.MAX_FILE_SIZE = exports.MAX_CACHE_FILE_SIZE = exports.LoggingSource = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.GatewayTypes = exports.GatewayTypeToDataPlane = exports.GatewayMode = exports.EnvironmentConfigInfo = exports.DosaAccount = exports.DataPlaneNames = exports.DOSAConfigInfo = exports.ConfigTypes = exports.CloudFormationConfig = exports.Certificate = exports.CentralAgentConfig = exports.CACHE_FILE_TTL_MILLISECONDS = exports.BundleType = exports.BasePaths = exports.AuthUrls = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
7
7
 
8
8
  var _dataService = require("./dataService");
9
9
 
@@ -15,6 +15,8 @@ const docsUrl = 'https://docs.axway.com/bundle/amplify-central/page/docs/index.h
15
15
  exports.docsUrl = docsUrl;
16
16
  const ABORT_TIMEOUT = process.env.NODE_ENV === 'test' ? 1e3 : process.env.DEBUG || process.env.SNOOPLOGG ? 1e9 : 30e3;
17
17
  exports.ABORT_TIMEOUT = ABORT_TIMEOUT;
18
+ const MAX_TABLE_STRING_LENGTH = 50;
19
+ exports.MAX_TABLE_STRING_LENGTH = MAX_TABLE_STRING_LENGTH;
18
20
  const MAX_FILE_SIZE = process.env.NODE_ENV === 'test' ? 1e5 : 20 * 1024 * 1024;
19
21
  exports.MAX_FILE_SIZE = MAX_FILE_SIZE;
20
22
  const MAX_CACHE_FILE_SIZE = 5 * 1024 * 1024; // 12 hours
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "2.12.1",
3
+ "version": "2.12.3",
4
4
  "description": "Manage APIs, services and publish to the Unified Catalog",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {