@axway/axway-central-cli 4.2.0-rc.2 → 4.2.0-rc.4

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.
@@ -32,6 +32,7 @@ var graylogAgent = _interopRequireWildcard(require("./graylogAgent"));
32
32
  var ibmAPIConnectAgent = _interopRequireWildcard(require("./ibmAPIConnectAgents"));
33
33
  var softwareAGWebMethodsAgent = _interopRequireWildcard(require("./softwareAGWebMethodsAgents"));
34
34
  var traceableAgent = _interopRequireWildcard(require("./traceableAgents"));
35
+ var traceableSaaSAgents = _interopRequireWildcard(require("./traceableSaasAgents"));
35
36
  var platform = _interopRequireWildcard(require("./platform"));
36
37
  var backstageAgent = _interopRequireWildcard(require("./backstageAgents"));
37
38
  var sapApiPortalAgent = _interopRequireWildcard(require("./sapApiPortalAgents"));
@@ -71,7 +72,8 @@ const saasAgentInstallFlows = {
71
72
  [_types.SaaSGatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
72
73
  [_types.SaaSGatewayTypes.SWAGGERHUB]: swaggerHubAgents.SwaggerHubSaaSInstallMethods,
73
74
  [_types.GatewayTypes.AZURE_GATEWAY]: azureSaasAgents.AzureSaaSInstallMethods,
74
- [_types.GatewayTypes.AZURE_EVENTHUB]: azureSaasAgents.AzureSaaSInstallMethods
75
+ [_types.GatewayTypes.AZURE_EVENTHUB]: azureSaasAgents.AzureSaaSInstallMethods,
76
+ [_types.GatewayTypes.TRACEABLE]: traceableSaaSAgents.TraceableSaaSInstallMethods
75
77
  };
76
78
  const createConfigBackup = async (configFiles, gatewayType) => {
77
79
  // If current configurations exist, back them up
@@ -142,7 +144,7 @@ const agents = exports.agents = {
142
144
  installConfig.centralConfig.singleEntryPointUrl = _types.SingleEntryPointUrls[installConfig.centralConfig.region];
143
145
  let gatewayTypeChoices = [];
144
146
  Object.values(_types.GatewayTypes).forEach(v => gatewayTypeChoices.push(v));
145
- Object.values(_types.SaaSGatewayTypes).filter(v => v !== _types.SaaSGatewayTypes.AWS_GATEWAY && v !== _types.SaaSGatewayTypes.APIGEEX_GATEWAY).forEach(v => gatewayTypeChoices.push(v));
147
+ Object.values(_types.SaaSGatewayTypes).filter(v => v !== _types.SaaSGatewayTypes.AWS_GATEWAY && v !== _types.SaaSGatewayTypes.APIGEEX_GATEWAY && v !== _types.SaaSGatewayTypes.TRACEABLE).forEach(v => gatewayTypeChoices.push(v));
146
148
  let gatewayChoices = gatewayTypeChoices.sort().filter(v => v !== _types.GatewayTypes.EDGE_GATEWAY_ONLY);
147
149
  let gatewayType = await (0, _basicPrompts.askList)({
148
150
  msg: prompts.selectGatewayType,
@@ -150,7 +152,7 @@ const agents = exports.agents = {
150
152
  });
151
153
 
152
154
  // if this check gets bigger, may think about an array of agents that can be both ground and embedded until ground agents become obsolete
153
- if (gatewayType === _types.GatewayTypes.AWS_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_EVENTHUB || gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY) {
155
+ if (gatewayType === _types.GatewayTypes.AWS_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_GATEWAY || gatewayType === _types.GatewayTypes.AZURE_EVENTHUB || gatewayType === _types.GatewayTypes.APIGEEX_GATEWAY || gatewayType === _types.GatewayTypes.TRACEABLE) {
154
156
  // hosted vs on premise
155
157
  installConfig.switches.isHostedInstall = (await (0, _basicPrompts.askList)({
156
158
  msg: prompts.hostedAgentOption,
@@ -35,7 +35,6 @@ const ConfigFiles = exports.ConfigFiles = {
35
35
  // ApigeeXPrompts - prompts for user inputs
36
36
  const ApigeeXPrompts = {
37
37
  AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
38
- SETUP_CONTROL_PLANE_REGION: 'The APIGEE X Gateway service allows you to configure a regionalized control plane for a more specific service endpoint location. Do you want to configure that?',
39
38
  PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
40
39
  DEVELOPER_EMAIL_ADDRESS: 'Enter the APIGEE X Developer Email Address the agent will use',
41
40
  AUTH_FILE_NAME: 'Enter the GCP key file name (place in the same directory as your Axway public and private keys)',
@@ -47,7 +46,7 @@ const ApigeeXPrompts = {
47
46
  FILTER_METRICS: 'Do you want metrics filtering?',
48
47
  FILTERED_APIS: 'Enter APIs to filter metrics for',
49
48
  ENTER_MORE_APIS: 'Do you want to add another API?',
50
- ENVIRONMENT: 'Enter the Apigee Environment to filter discovered APIs/metrics'
49
+ ENVIRONMENT: 'Enter the Apigee Envirnoment to filter discovered APIs/metrics'
51
50
  };
52
51
  const askBundleType = async gateway => {
53
52
  console.log(gateway);
@@ -73,14 +72,6 @@ const askApigeeXProjectId = async () => await (0, _basicPrompts.askInput)({
73
72
  msg: ApigeeXPrompts.PROJECT_ID,
74
73
  validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
75
74
  });
76
- const askToCreateControlPlaneRegionSetup = async () => {
77
- return (await (0, _basicPrompts.askList)({
78
- msg: ApigeeXPrompts.SETUP_CONTROL_PLANE_REGION,
79
- choices: _types.YesNoChoices,
80
- default: _types.YesNo.Yes
81
- })) === _types.YesNo.Yes ? _types.YesNo.Yes : _types.YesNo.No;
82
- };
83
- const askApigeexControlPlaneRegion = async () => await helpers.askApigeexControlPlaneRegion();
84
75
  const askApigeeXDeveloperEmailAddress = async () => await (0, _basicPrompts.askInput)({
85
76
  msg: ApigeeXPrompts.DEVELOPER_EMAIL_ADDRESS
86
77
  });
@@ -183,14 +174,6 @@ const dockerSuccessMsg = installConfig => {
183
174
  async function askDiscoveryPrompts(apigeeXAgentValues) {
184
175
  // Apigee X ProjectId
185
176
  apigeeXAgentValues.projectId = await askApigeeXProjectId();
186
-
187
- // Ask if Control Plane Region support is needed
188
- let controlPlaneRegionSupport = await askToCreateControlPlaneRegionSetup();
189
- if (controlPlaneRegionSupport === _types.YesNo.Yes) {
190
- // Apigee X Control Plane Region
191
- apigeeXAgentValues.controlPlaneRegion = await askApigeexControlPlaneRegion();
192
- }
193
-
194
177
  // Apigee X Developer Email Address
195
178
  apigeeXAgentValues.developerEmailAddress = await askApigeeXDeveloperEmailAddress();
196
179
  // Apigee X Auth File Path
@@ -26,16 +26,13 @@ class DataplaneConfig {
26
26
  }
27
27
  }
28
28
  class APIGEEXDataplaneConfig extends DataplaneConfig {
29
- // super constructor to set the type to 'Apigee' since this is a specific type of dataplane for SaaS agents (enum) available
30
- constructor(controlPlaneRegion, projectID, developerEmail, mode, metricsFilter, environment) {
31
- super("Apigee");
32
- _defineProperty(this, "controlPlaneRegion", void 0);
29
+ constructor(projectID, developerEmail, mode, metricsFilter, environment) {
30
+ super("Apigee X");
33
31
  _defineProperty(this, "projectId", void 0);
34
32
  _defineProperty(this, "developerEmail", void 0);
35
33
  _defineProperty(this, "mode", void 0);
36
34
  _defineProperty(this, "metricsFilter", void 0);
37
35
  _defineProperty(this, "environment", void 0);
38
- this.controlPlaneRegion = controlPlaneRegion;
39
36
  this.projectId = projectID;
40
37
  this.developerEmail = developerEmail;
41
38
  this.mode = mode;
@@ -63,7 +60,6 @@ class SaasAPIGEEXAgentValues extends SaasAgentValues {
63
60
  _defineProperty(this, "authType", void 0);
64
61
  _defineProperty(this, "clientEmailAddress", void 0);
65
62
  _defineProperty(this, "credentialJSON", void 0);
66
- _defineProperty(this, "controlPlaneRegion", void 0);
67
63
  _defineProperty(this, "projectId", void 0);
68
64
  _defineProperty(this, "developerEmailAddress", void 0);
69
65
  _defineProperty(this, "mode", void 0);
@@ -73,7 +69,6 @@ class SaasAPIGEEXAgentValues extends SaasAgentValues {
73
69
  this.clientEmailAddress = '';
74
70
  this.credentialJSON = '';
75
71
  this.projectId = '';
76
- this.controlPlaneRegion = '';
77
72
  this.developerEmailAddress = '';
78
73
  this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
79
74
  this.metricsFilter = new _types.ApigeeMetricsFilterConfig(true, []);
@@ -97,7 +92,6 @@ const ConfigFiles = {};
97
92
  const SaasPrompts = {
98
93
  AUTHENTICATION_TYPE: 'Authenticate with an Impersonation of a Service Account or by providing a Credential File',
99
94
  PROJECT_ID: 'Enter the APIGEE X Project ID the agent will use',
100
- SETUP_CONTROL_PLANE_REGION: 'The APIGEE X Gateway service allows you to configure a regionalized control plane for a more specific service endpoint location. Do you want to configure that?',
101
95
  DEVELOPER_EMAIL_ADDRESS: 'Enter the APIGEE X Developer Email Address the agent will use',
102
96
  CLIENT_EMAIL_ADDRESS: 'Enter the Client Email Address the agent will use for the APIGEE X Service Account',
103
97
  UPLOAD_CREDENTIAL_FILE: 'Upload a JSON Credential file to be used for APIGEE X Authentication',
@@ -108,7 +102,7 @@ const SaasPrompts = {
108
102
  FILTER_METRICS: 'Do you want metrics filtering? (defaults to true)',
109
103
  FILTERED_APIS: 'Enter APIs to filter metrics for',
110
104
  ENTER_MORE_APIS: 'Do you want to add another API?',
111
- ENVIRONMENT: 'Enter the Apigee Envirnoment to filter discovered APIs/metrics'
105
+ ENVIRONMENT: 'Enter the Apigee Environment to filter discovered APIs/metrics'
112
106
  };
113
107
  const askBundleType = async () => {
114
108
  return await (0, _basicPrompts.askList)({
@@ -127,16 +121,6 @@ const askForAPIGEEXCredentials = async hostedAgentValues => {
127
121
  defaultValue: hostedAgentValues.projectId !== '' ? hostedAgentValues.projectId : undefined,
128
122
  validate: (0, _basicPrompts.validateRegex)(helpers.APIGEEXRegexPatterns.APIGEEX_REGEXP_PROJECT_ID, helpers.invalidValueExampleErrMsg('Project ID', 'rd-amplify-apigee-x'))
129
123
  });
130
- let controlPlaneRegionSupport = await (0, _basicPrompts.askList)({
131
- msg: SaasPrompts.SETUP_CONTROL_PLANE_REGION,
132
- default: _types.YesNo.No,
133
- choices: _types.YesNoChoices
134
- });
135
- if (controlPlaneRegionSupport === _types.YesNo.Yes) {
136
- hostedAgentValues.controlPlaneRegion = await helpers.askApigeexControlPlaneRegion();
137
- } else {
138
- hostedAgentValues.controlPlaneRegion = '';
139
- }
140
124
 
141
125
  // get developer email address
142
126
  hostedAgentValues.developerEmailAddress = await (0, _basicPrompts.askInput)({
@@ -267,18 +251,14 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
267
251
  production: installConfig.centralConfig.production
268
252
  }) : installConfig.centralConfig.ampcEnvInfo.name;
269
253
  if (installConfig.gatewayType === _types.SaaSGatewayTypes.APIGEEX_GATEWAY) {
270
- apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.controlPlaneRegion, apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode, apigeeXAgentValues.metricsFilter, apigeeXAgentValues.environment);
254
+ apigeeXAgentValues.dataplaneConfig = new APIGEEXDataplaneConfig(apigeeXAgentValues.projectId, apigeeXAgentValues.developerEmailAddress, apigeeXAgentValues.mode, apigeeXAgentValues.metricsFilter, apigeeXAgentValues.environment);
271
255
  }
272
256
 
273
257
  // create the data plane resource
274
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.DataPlaneNames.APIGEE,
275
- // hardcoded for APIGEE to match dataplane definitions
276
- apigeeXAgentValues.dataplaneConfig);
258
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], apigeeXAgentValues.dataplaneConfig);
277
259
  // create data plane secret resource
278
260
  try {
279
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.DataPlaneNames.APIGEE,
280
- // hardcoded for APIGEE to match dataplane definitions
281
- dataplaneRes.name, await createEncryptedAccessData(apigeeXAgentValues, dataplaneRes));
261
+ await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(apigeeXAgentValues, dataplaneRes));
282
262
  } catch (error) {
283
263
  console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
284
264
  if (installConfig.centralConfig.ampcEnvInfo.isNew) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectApigeexControlPlaneRegion = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.idpTestables = exports.idpMessages = exports.getCentralEnvironments = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterApigeexControlPlaneRegion = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askKeyValuePairLoop = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askForIDPConfiguration = exports.askForIDPAuthConfiguration = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askArrayLoop = exports.askApigeexControlPlaneRegion = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = exports.addIdentityProvider = void 0;
6
+ exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.selectAWSRegion = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.idpTestables = exports.idpMessages = exports.getCentralEnvironments = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.enterAWSRegion = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askServiceAccountName = exports.askReferencedEnvironments = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askKeyValuePairLoop = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askForIDPConfiguration = exports.askForIDPAuthConfiguration = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askArrayLoop = exports.askAgentName = exports.askAWSRegion = exports.agentMessages = exports.addIdentityProvider = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
9
  var _inquirer = _interopRequireDefault(require("inquirer"));
@@ -70,8 +70,6 @@ const selectIngestionProtocol = exports.selectIngestionProtocol = 'Select Tracea
70
70
  const serviceAccountNameAlreadyExists = exports.serviceAccountNameAlreadyExists = 'Service account already exists. Please enter a new name.';
71
71
  const selectAWSRegion = exports.selectAWSRegion = 'Select an AWS Region';
72
72
  const enterAWSRegion = exports.enterAWSRegion = 'Enter an AWS Region';
73
- const selectApigeexControlPlaneRegion = exports.selectApigeexControlPlaneRegion = 'Select an Apigeex Control Plane Region';
74
- const enterApigeexControlPlaneRegion = exports.enterApigeexControlPlaneRegion = 'Enter an Apigeex Control Plane Region';
75
73
  const askAWSRegion = async (region = '') => {
76
74
  let regions = Object.values(_types.AWSRegions).map(str => ({
77
75
  name: str,
@@ -94,28 +92,6 @@ const askAWSRegion = async (region = '') => {
94
92
  }
95
93
  };
96
94
  exports.askAWSRegion = askAWSRegion;
97
- const askApigeexControlPlaneRegion = async (region = '') => {
98
- let regions = Object.values(_types.ApigeexControlPlaneRegions).map(str => ({
99
- name: str,
100
- value: str
101
- }));
102
- let answer = await (0, _basicPrompts.askList)({
103
- msg: selectApigeexControlPlaneRegion,
104
- default: region,
105
- choices: [{
106
- name: 'Enter an Apigeex Control Plane Region not on the list',
107
- value: 'CREATE_NEW'
108
- }, ...regions]
109
- });
110
- if (answer === 'CREATE_NEW') {
111
- return await (0, _basicPrompts.askInput)({
112
- msg: enterApigeexControlPlaneRegion
113
- });
114
- } else {
115
- return answer;
116
- }
117
- };
118
- exports.askApigeexControlPlaneRegion = askApigeexControlPlaneRegion;
119
95
  const askServiceAccountName = async serviceAccountNames => {
120
96
  console.warn(_chalk.default.yellow(`WARNING: Creating a new service account will overwrite any existing "private_key.pem" and "public_key.pem" files in this directory`));
121
97
  const name = await (0, _basicPrompts.askInput)({
@@ -13,7 +13,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
13
13
  */
14
14
  class ApigeeXAgentValues {
15
15
  constructor() {
16
- _defineProperty(this, "controlPlaneRegion", void 0);
17
16
  _defineProperty(this, "projectId", void 0);
18
17
  _defineProperty(this, "developerEmailAddress", void 0);
19
18
  _defineProperty(this, "mode", void 0);
@@ -22,7 +21,6 @@ class ApigeeXAgentValues {
22
21
  _defineProperty(this, "metricsFilter", void 0);
23
22
  _defineProperty(this, "centralConfig", void 0);
24
23
  _defineProperty(this, "traceabilityConfig", void 0);
25
- this.controlPlaneRegion = "";
26
24
  this.projectId = "";
27
25
  this.developerEmailAddress = "";
28
26
  this.mode = _types.APIGEEXDISCOVERYMODES.PROXY;
@@ -40,9 +38,6 @@ class ApigeeXAgentValues {
40
38
  exports.ApigeeXAgentValues = ApigeeXAgentValues;
41
39
  const apigeeXTAEnvVarTemplate = () => {
42
40
  return `# ApigeeX configs
43
- {{#if controlPlaneRegion}}
44
- APIGEE_CONTROLPLANEREGION={{controlPlaneRegion}}
45
- {{/if}}
46
41
  APIGEE_PROJECTID={{projectId}}
47
42
  APIGEE_DEVELOPEREMAIL={{developerEmailAddress}}
48
43
  APIGEE_MODE={{mode}}
@@ -89,9 +84,6 @@ LOG_FILE_PATH=logs
89
84
  exports.apigeeXTAEnvVarTemplate = apigeeXTAEnvVarTemplate;
90
85
  const apigeeXDAEnvVarTemplate = () => {
91
86
  return `# Azure configs
92
- {{#if controlPlaneRegion}}
93
- APIGEE_CONTROLPLANEREGION={{controlPlaneRegion}}
94
- {{/if}}
95
87
  APIGEE_PROJECTID={{projectId}}
96
88
  APIGEE_DEVELOPEREMAIL={{developerEmailAddress}}
97
89
  APIGEE_MODE={{mode}}
@@ -35,9 +35,10 @@ const prompts = {
35
35
  agentNamespace: 'Enter the namespace to use for the Amplify Traceable Agents',
36
36
  enterToken: 'Enter the token that the agent will use',
37
37
  enterRegion: 'Enter the region that the agent will use',
38
- enterEnvironments: 'Enter an environment that the agent will use',
39
- enterMoreEnviroments: 'Do you want to enter another environment ?',
40
- selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Traceable Agent Environement'
38
+ enterEnvironments: 'Enter a Traceable environment',
39
+ enterMoreEnvironments: 'Do you want to enter another mapping?',
40
+ selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Traceable environment',
41
+ environmentsDescription: 'Configure a mapping of Traceable environment to Engage environment that the agent will use'
41
42
  };
42
43
  const askBundleType = async () => {
43
44
  return _types.BundleType.TRACEABILITY;
@@ -75,7 +76,7 @@ const askEnvironments = async (centralEnvs, traceableAgentValues) => {
75
76
  let askEnvs = true;
76
77
  let envs = [];
77
78
  let mappedCentralEnvs = [];
78
- console.log(_chalk.default.gray("An array of environments that the agent will use"));
79
+ console.log(_chalk.default.gray(prompts.environmentsDescription));
79
80
  while (askEnvs) {
80
81
  const env = await (0, _basicPrompts.askInput)({
81
82
  msg: prompts.enterEnvironments,
@@ -99,7 +100,7 @@ const askEnvironments = async (centralEnvs, traceableAgentValues) => {
99
100
  return ((_centralEnvs$find = centralEnvs.find(env => env.name === centralMappingEnv)) === null || _centralEnvs$find === void 0 ? void 0 : _centralEnvs$find.name) !== env.name;
100
101
  });
101
102
  askEnvs = (await (0, _basicPrompts.askList)({
102
- msg: prompts.enterMoreEnviroments,
103
+ msg: prompts.enterMoreEnvironments,
103
104
  default: _types.YesNo.No,
104
105
  choices: _types.YesNoChoices
105
106
  })) === _types.YesNo.Yes;
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testables = exports.askTraceableRegion = exports.askBundleType = exports.TraceableSaaSInstallMethods = void 0;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+ var _basicPrompts = require("../../common/basicPrompts");
10
+ var _types = require("../../common/types");
11
+ var _crypto = _interopRequireDefault(require("crypto"));
12
+ var helpers = _interopRequireWildcard(require("./helpers"));
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ 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; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
+ 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); }
19
+ const {
20
+ log
21
+ } = (0, _snooplogg.default)('engage: install: agents: saas');
22
+ class DataplaneConfig {
23
+ constructor(type) {
24
+ _defineProperty(this, "type", void 0);
25
+ this.type = type || '';
26
+ }
27
+ }
28
+ class TraceableDataplaneConfig extends DataplaneConfig {
29
+ constructor(region, environments) {
30
+ super("Traceable");
31
+ _defineProperty(this, "region", void 0);
32
+ _defineProperty(this, "environments", void 0);
33
+ this.region = region;
34
+ this.environments = environments;
35
+ }
36
+ }
37
+ class TraceableEnvironments {
38
+ constructor(traceable, environment) {
39
+ _defineProperty(this, "traceable", void 0);
40
+ _defineProperty(this, "environment", void 0);
41
+ this.traceable = traceable;
42
+ this.environment = environment;
43
+ }
44
+ }
45
+ class SaasAgentValues {
46
+ constructor() {
47
+ _defineProperty(this, "dataplaneConfig", void 0);
48
+ _defineProperty(this, "centralConfig", void 0);
49
+ this.dataplaneConfig = new DataplaneConfig();
50
+ this.centralConfig = new _types.CentralAgentConfig();
51
+ }
52
+ getAccessData() {
53
+ return '';
54
+ }
55
+ }
56
+ class SaasTraceableAgentValues extends SaasAgentValues {
57
+ constructor() {
58
+ super();
59
+ _defineProperty(this, "traceableToken", void 0);
60
+ _defineProperty(this, "traceableRegion", void 0);
61
+ _defineProperty(this, "environments", void 0);
62
+ _defineProperty(this, "centralEnvironments", void 0);
63
+ this.traceableToken = '';
64
+ this.traceableRegion = _types.TraceableRegionType.US;
65
+ this.environments = [];
66
+ this.centralEnvironments = [];
67
+ }
68
+ getAccessData() {
69
+ let data = JSON.stringify({
70
+ token: this.traceableToken
71
+ });
72
+ return data;
73
+ }
74
+ }
75
+
76
+ // ConfigFiles - all the config file that are used in the setup
77
+ const ConfigFiles = {};
78
+
79
+ // TraceableSaaSPrompts - all Traceable Saas prompts to the user for input
80
+ const SaasPrompts = {
81
+ configTypeMsg: 'Select the mode of installation',
82
+ agentNamespace: 'Enter the namespace to use for the Amplify Traceable Agents',
83
+ enterToken: 'Enter the token that the agent will use',
84
+ enterRegion: 'Enter the region that the agent will use',
85
+ enterEnvironments: 'Enter a Traceable environment',
86
+ enterMoreEnvironments: 'Do you want to enter another mapping?',
87
+ selectCentralMappingEnvironment: 'Select an Engage environment to map to the provided Traceable environment',
88
+ environmentsDescription: 'Configure a mapping of Traceable environment to Engage environment that the agent will use'
89
+ };
90
+ const askBundleType = async () => {
91
+ return _types.BundleType.TRACEABILITY;
92
+ };
93
+ exports.askBundleType = askBundleType;
94
+ const askConfigType = async () => {
95
+ return _types.AgentConfigTypes.HOSTED;
96
+ };
97
+ const askEnvironments = async (centralEnvs, hostedAgentValues) => {
98
+ let askEnvs = true;
99
+ let envs = [];
100
+ let mappedCentralEnvs = [];
101
+ console.log(_chalk.default.gray(SaasPrompts.environmentsDescription));
102
+ while (askEnvs) {
103
+ const env = await (0, _basicPrompts.askInput)({
104
+ msg: SaasPrompts.enterEnvironments,
105
+ allowEmptyInput: true
106
+ });
107
+ if (envs.length === 0 && env.toString().trim() === "") {
108
+ break;
109
+ }
110
+ if (env && env.toString().trim() !== "") {
111
+ envs.push(env);
112
+ }
113
+ const centralMappingEnv = await (0, _basicPrompts.askList)({
114
+ msg: SaasPrompts.selectCentralMappingEnvironment,
115
+ choices: centralEnvs.map(e => e.name)
116
+ });
117
+ if (centralMappingEnv && centralMappingEnv.toString().trim() !== "") {
118
+ mappedCentralEnvs.push(centralMappingEnv);
119
+ }
120
+ centralEnvs = centralEnvs.filter(env => {
121
+ var _centralEnvs$find;
122
+ return ((_centralEnvs$find = centralEnvs.find(env => env.name === centralMappingEnv)) === null || _centralEnvs$find === void 0 ? void 0 : _centralEnvs$find.name) !== env.name;
123
+ });
124
+ askEnvs = (await (0, _basicPrompts.askList)({
125
+ msg: SaasPrompts.enterMoreEnvironments,
126
+ default: _types.YesNo.No,
127
+ choices: _types.YesNoChoices
128
+ })) === _types.YesNo.Yes;
129
+ }
130
+ hostedAgentValues.environments = envs;
131
+ hostedAgentValues.centralEnvironments = mappedCentralEnvs;
132
+ };
133
+ const validateFrequency = () => input => {
134
+ let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
135
+ if (typeof val === "string") {
136
+ return val;
137
+ }
138
+ let r = input.toString().match(/^(\d*)m/);
139
+ if (r) {
140
+ // only minutes
141
+ let mins = r[1];
142
+ if (parseInt(mins, 10) < 30) {
143
+ return "Minimum frequency is 30m";
144
+ }
145
+ }
146
+ return true;
147
+ };
148
+
149
+ //
150
+ // Questions for the configuration of Traceable agent
151
+ //
152
+ const askToken = async () => await (0, _basicPrompts.askInput)({
153
+ msg: SaasPrompts.enterToken,
154
+ allowEmptyInput: false
155
+ });
156
+ const askTraceableRegion = async () => {
157
+ return await (0, _basicPrompts.askList)({
158
+ msg: SaasPrompts.enterRegion,
159
+ choices: Object.entries(_types.TraceableRegionType).reduce((accumulator, curr) => {
160
+ return accumulator.concat({
161
+ name: curr[0],
162
+ value: curr[1]
163
+ });
164
+ }, []),
165
+ default: _types.TraceableRegionType.US
166
+ });
167
+ };
168
+
169
+ // @ts-ignore
170
+ exports.askTraceableRegion = askTraceableRegion;
171
+ const gatewayConnectivity = async installConfig => {
172
+ console.log('\nCONNECTION TO TRACEABLE API GATEWAY:');
173
+ // DeploymentType
174
+ let hostedAgentValues = new SaasTraceableAgentValues();
175
+ if (installConfig.gatewayType === _types.SaaSGatewayTypes.TRACEABLE) {
176
+ log('gathering access details for traceable');
177
+ // Traceable connection details
178
+ hostedAgentValues = new SaasTraceableAgentValues();
179
+ hostedAgentValues.traceableToken = await askToken();
180
+ hostedAgentValues.traceableRegion = await askTraceableRegion();
181
+ await helpers.getCentralEnvironments(installConfig.centralConfig.apiServerClient, installConfig.centralConfig.definitionManager).then(async envs => {
182
+ if (envs) {
183
+ await askEnvironments(envs, hostedAgentValues);
184
+ }
185
+ });
186
+ }
187
+ return hostedAgentValues;
188
+ };
189
+ const generateOutput = async installConfig => {
190
+ return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
191
+ };
192
+ const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
193
+ var _dataplaneRes$securit, _dataplaneRes$securit2;
194
+ // grab key from data plane resource
195
+ let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
196
+ let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
197
+ if (key === "" || hash === "") {
198
+ throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
199
+ }
200
+ const accessData = hostedAgentValues.getAccessData();
201
+ let encData = _crypto.default.publicEncrypt({
202
+ key: key,
203
+ padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
204
+ oaepHash: hash
205
+ }, Buffer.from(accessData));
206
+ return encData.toString("base64");
207
+ };
208
+ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
209
+ /**
210
+ * Create agent resources
211
+ */
212
+ console.log("\n");
213
+ let traceableAgentValues = installConfig.gatewayConfig;
214
+
215
+ // create the environment, if necessary
216
+ installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
217
+ axwayManaged: installConfig.centralConfig.axwayManaged,
218
+ production: installConfig.centralConfig.production
219
+ }) : installConfig.centralConfig.ampcEnvInfo.name;
220
+ if (installConfig.gatewayType === _types.GatewayTypes.TRACEABLE) {
221
+ const traceableEnvObjs = (traceableAgentValues.environments || []).map((env, idx) => new TraceableEnvironments(env, traceableAgentValues.centralEnvironments[idx]));
222
+ traceableAgentValues.dataplaneConfig = new TraceableDataplaneConfig(traceableAgentValues.traceableRegion, traceableEnvObjs);
223
+ }
224
+
225
+ // create the data plane resource
226
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], traceableAgentValues.dataplaneConfig);
227
+ // create data plane secret resource
228
+ try {
229
+ await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(traceableAgentValues, dataplaneRes));
230
+ } catch (error) {
231
+ log(error);
232
+ console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
233
+ if (installConfig.centralConfig.ampcEnvInfo.isNew) {
234
+ await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
235
+ } else {
236
+ await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
237
+ }
238
+ return;
239
+ }
240
+
241
+ // create compliance agent resource
242
+ installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ca, _types.AgentTypes.ca, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Compliance Agent", dataplaneRes.name);
243
+ console.log(await generateOutput(installConfig));
244
+ };
245
+ const TraceableSaaSInstallMethods = exports.TraceableSaaSInstallMethods = {
246
+ GetBundleType: askBundleType,
247
+ GetDeploymentType: askConfigType,
248
+ AskGatewayQuestions: gatewayConnectivity,
249
+ FinalizeGatewayInstall: completeInstall,
250
+ ConfigFiles: [],
251
+ AgentNameMap: {
252
+ [_types.AgentTypes.ca]: _types.AgentNames.TRACEABLE_CA
253
+ },
254
+ GatewayDisplay: _types.GatewayTypes.TRACEABLE
255
+ };
256
+
257
+ // These are the items that are not exported, but need to be for testing
258
+ const testables = exports.testables = {
259
+ SaasAgentValues,
260
+ SaasTraceableAgentValues,
261
+ SaasPrompts,
262
+ ConfigFiles,
263
+ createEncryptedAccessData,
264
+ // <-- already exported
265
+ validateFrequency // <-- add this line for test access
266
+ };
@@ -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.TraceableRegionType = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = 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.LanguageTypes = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.IDPType = exports.IDPConfiguration = exports.IDPClientSecretAuthMethod = exports.IDPAuthType = exports.IDPAuthConfiguration = exports.IDPAuthClientSecret = exports.IDPAuthAccessToken = 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.AzureDataplaneMode = exports.AuthUrls = exports.ApigeexControlPlaneRegions = exports.ApigeeMetricsFilterConfig = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APIGEEXDISCOVERYMODES = exports.APIGEEXAuthType = 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.TraceableRegionType = exports.TraceabilityConfig = exports.SingleEntryPointUrls = exports.SaaSGatewayTypes = 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.LanguageTypes = exports.KindTypes = exports.Kind = exports.IstioProfileChoices = exports.IstioInstallValues = exports.IstioAgentValues = exports.IngestionProtocolToHosts = exports.IngestionProtocol = exports.IngestionHostsHTTP = exports.IngestionHosts = exports.IngestionHTTPHosts = exports.IDPType = exports.IDPConfiguration = exports.IDPClientSecretAuthMethod = exports.IDPAuthType = exports.IDPAuthConfiguration = exports.IDPAuthClientSecret = exports.IDPAuthAccessToken = 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.AzureDataplaneMode = exports.AuthUrls = exports.ApigeeMetricsFilterConfig = exports.AgentTypes = exports.AgentResourceKind = exports.AgentNames = exports.AgentInstallSwitches = exports.AgentInstallConfig = exports.AgentConfigTypes = exports.AWSRegions = exports.APIGEEXDISCOVERYMODES = exports.APIGEEXAuthType = exports.APICDeployments = exports.ABORT_TIMEOUT = void 0;
7
7
  var _dataService = require("./dataService");
8
8
  var _utils = require("./utils");
9
9
  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; }
@@ -274,11 +274,11 @@ let SaaSGatewayTypes = exports.SaaSGatewayTypes = /*#__PURE__*/function (SaaSGat
274
274
  SaaSGatewayTypes["APIGEEX_GATEWAY"] = "Apigee X Gateway";
275
275
  SaaSGatewayTypes["GITHUB"] = "GitHub";
276
276
  SaaSGatewayTypes["SWAGGERHUB"] = "SwaggerHub";
277
+ SaaSGatewayTypes["TRACEABLE"] = "Traceable";
277
278
  return SaaSGatewayTypes;
278
279
  }({});
279
280
  let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNames) {
280
281
  DataPlaneNames["APIGEEX"] = "Apigee X";
281
- DataPlaneNames["APIGEE"] = "Apigee";
282
282
  DataPlaneNames["AWS"] = "AWS";
283
283
  DataPlaneNames["GITHUB"] = "GitHub";
284
284
  DataPlaneNames["GITLAB"] = "GitLab";
@@ -339,20 +339,6 @@ let AWSRegions = exports.AWSRegions = /*#__PURE__*/function (AWSRegions) {
339
339
  AWSRegions["EU_WEST_2"] = "eu-west-2";
340
340
  AWSRegions["EU_WEST_3"] = "eu-west-3";
341
341
  return AWSRegions;
342
- }({}); // Apigee X Control Plane Regions
343
- let ApigeexControlPlaneRegions = exports.ApigeexControlPlaneRegions = /*#__PURE__*/function (ApigeexControlPlaneRegions) {
344
- ApigeexControlPlaneRegions["US"] = "us";
345
- ApigeexControlPlaneRegions["CANADA"] = "ca";
346
- ApigeexControlPlaneRegions["EUROPEAN_UNION"] = "eu";
347
- ApigeexControlPlaneRegions["GERMANY"] = "de";
348
- ApigeexControlPlaneRegions["FRANCE"] = "fr";
349
- ApigeexControlPlaneRegions["SWITZERLAND"] = "ch";
350
- ApigeexControlPlaneRegions["AUSTRALIA"] = "au";
351
- ApigeexControlPlaneRegions["INDIA"] = "in";
352
- ApigeexControlPlaneRegions["JAPAN"] = "jp";
353
- ApigeexControlPlaneRegions["SAUDI_ARABIA"] = "sa";
354
- ApigeexControlPlaneRegions["ISRAEL"] = "il";
355
- return ApigeexControlPlaneRegions;
356
342
  }({});
357
343
  let APIGEEXDISCOVERYMODES = exports.APIGEEXDISCOVERYMODES = /*#__PURE__*/function (APIGEEXDISCOVERYMODES) {
358
344
  APIGEEXDISCOVERYMODES["PROXY"] = "proxy";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "4.2.0-rc.2",
3
+ "version": "4.2.0-rc.4",
4
4
  "description": "Manage APIs, services and publish to the Amplify Marketplace",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {