@adobe/aio-cli-plugin-api-mesh 5.2.3 → 5.2.4-alpha.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.
Files changed (38) hide show
  1. package/oclif.manifest.json +1 -1
  2. package/package.json +4 -2
  3. package/src/commands/api-mesh/__tests__/cache-purge.test.js +3 -4
  4. package/src/commands/api-mesh/__tests__/create.test.js +4 -19
  5. package/src/commands/api-mesh/__tests__/delete-log-forwarding.test.js +106 -0
  6. package/src/commands/api-mesh/__tests__/delete.test.js +3 -4
  7. package/src/commands/api-mesh/__tests__/describe.test.js +3 -5
  8. package/src/commands/api-mesh/__tests__/get-log-forwarding.test.js +149 -0
  9. package/src/commands/api-mesh/__tests__/get.test.js +4 -4
  10. package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +21 -215
  11. package/src/commands/api-mesh/__tests__/log-get.test.js +2 -2
  12. package/src/commands/api-mesh/__tests__/log-list.test.js +2 -2
  13. package/src/commands/api-mesh/__tests__/run.test.js +2 -2
  14. package/src/commands/api-mesh/__tests__/set-log-forwarding.test.js +246 -0
  15. package/src/commands/api-mesh/__tests__/status.test.js +2 -2
  16. package/src/commands/api-mesh/__tests__/update.test.js +6 -7
  17. package/src/commands/api-mesh/cache/purge.js +2 -4
  18. package/src/commands/api-mesh/config/delete/log-forwarding.js +80 -0
  19. package/src/commands/api-mesh/config/get/log-forwarding.js +78 -0
  20. package/src/commands/api-mesh/config/set/log-forwarding.js +156 -0
  21. package/src/commands/api-mesh/create.js +21 -4
  22. package/src/commands/api-mesh/delete.js +2 -4
  23. package/src/commands/api-mesh/describe.js +2 -4
  24. package/src/commands/api-mesh/get.js +2 -4
  25. package/src/commands/api-mesh/log-get-bulk.js +6 -27
  26. package/src/commands/api-mesh/log-get.js +2 -4
  27. package/src/commands/api-mesh/log-list.js +2 -4
  28. package/src/commands/api-mesh/run.js +2 -9
  29. package/src/commands/api-mesh/source/__tests__/install.test.js +2 -2
  30. package/src/commands/api-mesh/source/discover.js +2 -9
  31. package/src/commands/api-mesh/source/get.js +1 -8
  32. package/src/commands/api-mesh/source/install.js +2 -3
  33. package/src/commands/api-mesh/status.js +2 -3
  34. package/src/commands/api-mesh/update.js +20 -4
  35. package/src/helpers.js +72 -5
  36. package/src/hooks/initMetadata.js +8 -0
  37. package/src/lib/{devConsole.js → smsClient.js} +299 -0
  38. package/src/utils.js +60 -22
@@ -0,0 +1,80 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ Unless required by applicable law or agreed to in writing, software distributed under
7
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ OF ANY KIND, either express or implied. See the License for the specific language
9
+ governing permissions and limitations under the License.
10
+ */
11
+
12
+ const { Command } = require('@oclif/core');
13
+ const logger = require('../../../../classes/logger');
14
+ const { initSdk, promptConfirm } = require('../../../../helpers');
15
+ const { ignoreCacheFlag, autoConfirmActionFlag } = require('../../../../utils');
16
+ const { deleteLogForwarding, getMeshId } = require('../../../../lib/smsClient');
17
+
18
+ class DeleteLogForwardingCommand extends Command {
19
+ static flags = {
20
+ ignoreCache: ignoreCacheFlag,
21
+ autoConfirmAction: autoConfirmActionFlag,
22
+ };
23
+
24
+ async run() {
25
+ logger.info(`RequestId: ${global.requestId}`);
26
+
27
+ const { flags } = await this.parse(DeleteLogForwardingCommand);
28
+
29
+ const ignoreCache = await flags.ignoreCache;
30
+ const autoConfirmAction = await flags.autoConfirmAction;
31
+
32
+ const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
33
+ ignoreCache,
34
+ });
35
+
36
+ let meshId = null;
37
+
38
+ try {
39
+ meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
40
+ } catch (err) {
41
+ this.error(
42
+ `Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
43
+ );
44
+ }
45
+
46
+ // mesh could not be found
47
+ if (!meshId) {
48
+ this.error(
49
+ `Unable to delete log forwarding details. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
50
+ );
51
+ }
52
+
53
+ let shouldContinue = true;
54
+
55
+ if (!autoConfirmAction) {
56
+ shouldContinue = await promptConfirm(
57
+ `Are you sure you want to delete the log forwarding details for mesh: ${meshId}?`,
58
+ );
59
+ }
60
+
61
+ if (shouldContinue) {
62
+ try {
63
+ await deleteLogForwarding(imsOrgCode, projectId, workspaceId, meshId);
64
+ this.log('Successfully deleted log forwarding details');
65
+ } catch (error) {
66
+ this.log(error.message);
67
+ this.error(
68
+ `Unable to delete log forwarding details. Try again. RequestId: ${global.requestId}`,
69
+ );
70
+ }
71
+ } else {
72
+ this.log('delete log-forwarding cancelled');
73
+ return 'delete log-forwarding cancelled';
74
+ }
75
+ }
76
+ }
77
+
78
+ DeleteLogForwardingCommand.description = 'Delete log forwarding details for a given mesh';
79
+
80
+ module.exports = DeleteLogForwardingCommand;
@@ -0,0 +1,78 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ Unless required by applicable law or agreed to in writing, software distributed under
7
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ OF ANY KIND, either express or implied. See the License for the specific language
9
+ governing permissions and limitations under the License.
10
+ */
11
+
12
+ const { Command } = require('@oclif/core');
13
+ const { initSdk, initRequestId } = require('../../../../helpers');
14
+ const logger = require('../../../../classes/logger');
15
+ const { ignoreCacheFlag, jsonFlag } = require('../../../../utils');
16
+ const { getLogForwarding, getMeshId } = require('../../../../lib/smsClient');
17
+
18
+ class GetLogForwardingCommand extends Command {
19
+ static flags = {
20
+ ignoreCache: ignoreCacheFlag,
21
+ json: jsonFlag,
22
+ };
23
+
24
+ static enableJsonFlag = true;
25
+
26
+ async run() {
27
+ await initRequestId();
28
+
29
+ logger.info(`RequestId: ${global.requestId}`);
30
+
31
+ const { flags } = await this.parse(GetLogForwardingCommand);
32
+
33
+ const ignoreCache = await flags.ignoreCache;
34
+
35
+ const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
36
+ ignoreCache,
37
+ });
38
+
39
+ let meshId = null;
40
+
41
+ try {
42
+ meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
43
+ } catch (err) {
44
+ this.log(err.message);
45
+ this.error(
46
+ `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
47
+ );
48
+ }
49
+ // mesh could not be found
50
+ if (!meshId) {
51
+ this.error(
52
+ `Unable to get meshId. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
53
+ );
54
+ }
55
+ try {
56
+ const response = await getLogForwarding(imsOrgCode, projectId, workspaceId, meshId);
57
+ if (response && response.data) {
58
+ this.log(
59
+ 'Successfully retrieved log forwarding details: \n',
60
+ JSON.stringify(response.data, null, 2),
61
+ );
62
+ return { imsOrgCode, projectId, workspaceId, workspaceName };
63
+ } else {
64
+ this.error(
65
+ `Unable to get log forwarding details. Try again. RequestId: ${global.requestId}`,
66
+ );
67
+ return;
68
+ }
69
+ } catch (error) {
70
+ this.log(error.message);
71
+ this.error(`Failed to get log forwarding details. Try again. RequestId: ${global.requestId}`);
72
+ }
73
+ }
74
+ }
75
+
76
+ GetLogForwardingCommand.description = `Get log forwarding details for a given mesh`;
77
+
78
+ module.exports = GetLogForwardingCommand;
@@ -0,0 +1,156 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ Unless required by applicable law or agreed to in writing, software distributed under
7
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ OF ANY KIND, either express or implied. See the License for the specific language
9
+ governing permissions and limitations under the License.
10
+ */
11
+
12
+ const { Command } = require('@oclif/core');
13
+ const {
14
+ initSdk,
15
+ initRequestId,
16
+ promptConfirm,
17
+ promptSelect,
18
+ promptInput,
19
+ promptInputSecret,
20
+ } = require('../../../../helpers');
21
+ const logger = require('../../../../classes/logger');
22
+ const {
23
+ ignoreCacheFlag,
24
+ autoConfirmActionFlag,
25
+ jsonFlag,
26
+ destinations,
27
+ } = require('../../../../utils');
28
+ const { setLogForwarding, getMeshId } = require('../../../../lib/smsClient');
29
+
30
+ class SetLogForwardingCommand extends Command {
31
+ static flags = {
32
+ ignoreCache: ignoreCacheFlag,
33
+ autoConfirmAction: autoConfirmActionFlag,
34
+ json: jsonFlag,
35
+ };
36
+
37
+ static enableJsonFlag = true;
38
+
39
+ async run() {
40
+ await initRequestId();
41
+
42
+ logger.info(`RequestId: ${global.requestId}`);
43
+
44
+ const { flags } = await this.parse(SetLogForwardingCommand);
45
+
46
+ const ignoreCache = await flags.ignoreCache;
47
+ const autoConfirmAction = await flags.autoConfirmAction;
48
+
49
+ let destinationConfig;
50
+ try {
51
+ destinationConfig = await this.inputAndValidateConfigs(destinations);
52
+ } catch (error) {
53
+ this.error(error.message);
54
+ return;
55
+ }
56
+ const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
57
+ ignoreCache,
58
+ });
59
+
60
+ let meshId = null;
61
+
62
+ try {
63
+ meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
64
+ } catch (err) {
65
+ this.log(err.message);
66
+ this.error(
67
+ `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
68
+ );
69
+ }
70
+
71
+ // mesh could not be found
72
+ if (!meshId) {
73
+ this.error(
74
+ `Unable to get meshId. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
75
+ );
76
+ }
77
+
78
+ let shouldContinue = true;
79
+
80
+ if (!autoConfirmAction) {
81
+ shouldContinue = await promptConfirm(
82
+ `Are you sure you want to set log forwarding to ${destinationConfig.destination}?`,
83
+ );
84
+ }
85
+
86
+ if (shouldContinue) {
87
+ try {
88
+ const response = await setLogForwarding(
89
+ imsOrgCode,
90
+ projectId,
91
+ workspaceId,
92
+ meshId,
93
+ destinationConfig,
94
+ );
95
+ if (response && response.result) {
96
+ this.log(`Log forwarding set successfully for ${meshId}`);
97
+ return { destinationConfig, imsOrgCode, projectId, workspaceId, workspaceName };
98
+ } else {
99
+ this.error(
100
+ `Unable to set log forwarding details. Try again. RequestId: ${global.requestId}`,
101
+ );
102
+ return;
103
+ }
104
+ } catch (error) {
105
+ this.log(error.message);
106
+ this.error(
107
+ `Failed to set log forwarding details. Try again. RequestId: ${global.requestId}`,
108
+ );
109
+ }
110
+ } else {
111
+ this.log('log-forwarding cancelled');
112
+ return 'set-log-forwarding cancelled';
113
+ }
114
+ }
115
+
116
+ async inputAndValidateConfigs(destinations) {
117
+ // Prompt for destination
118
+ const destinationKey = await promptSelect(
119
+ 'Select log forwarding destination:',
120
+ Object.keys(destinations),
121
+ );
122
+ if (!destinationKey) {
123
+ throw new Error('Destination is required');
124
+ }
125
+
126
+ const destinationConfig = destinations[destinationKey];
127
+ const inputs = {};
128
+
129
+ // For each input defined in the destination config, prompt and validate
130
+ for (const inputConfig of destinationConfig.inputs) {
131
+ // Prompt for input value (regular or secret based on config)
132
+ const promptFn = inputConfig.isSecret ? promptInputSecret : promptInput;
133
+ const value = await promptFn(inputConfig.promptMessage);
134
+
135
+ // Validate the input
136
+ if (inputConfig.validate) {
137
+ inputConfig.validate(value);
138
+ }
139
+
140
+ // Store the validated input
141
+ inputs[inputConfig.name] = value;
142
+ }
143
+
144
+ return {
145
+ destination: destinationConfig.name,
146
+ config: inputs,
147
+ };
148
+ }
149
+ }
150
+
151
+ SetLogForwardingCommand.description = `Sets the log forwarding destination for API mesh.
152
+ - Select a log forwarding destination - Choose from available options (for example, New Relic).
153
+ - Enter the base URI - Provide the URI for the log forwarding service. Ensure it includes the protocol (for example, if the hosted region of the New Relic account is the U.S, the base URI could be 'https://log-api.newrelic.com/log/v1').
154
+ - Enter the license key - Provide the INGEST-LICENSE API key type.`;
155
+
156
+ module.exports = SetLogForwardingCommand;
@@ -10,7 +10,9 @@ governing permissions and limitations under the License.
10
10
  */
11
11
 
12
12
  const { Command } = require('@oclif/core');
13
- const { initSdk, initRequestId, promptConfirm, importFiles } = require('../../helpers');
13
+ const chalk = require('chalk');
14
+
15
+ const { initSdk, promptConfirm, importFiles } = require('../../helpers');
14
16
  const logger = require('../../classes/logger');
15
17
  const {
16
18
  ignoreCacheFlag,
@@ -26,7 +28,7 @@ const {
26
28
  validateSecretsFile,
27
29
  encryptSecrets,
28
30
  } = require('../../utils');
29
- const { createMesh, getPublicEncryptionKey } = require('../../lib/devConsole');
31
+ const { createMesh, getPublicEncryptionKey } = require('../../lib/smsClient');
30
32
  const { buildMeshUrl } = require('../../urlBuilder');
31
33
 
32
34
  class CreateCommand extends Command {
@@ -42,8 +44,6 @@ class CreateCommand extends Command {
42
44
  static enableJsonFlag = true;
43
45
 
44
46
  async run() {
45
- await initRequestId();
46
-
47
47
  logger.info(`RequestId: ${global.requestId}`);
48
48
 
49
49
  const { args, flags } = await this.parse(CreateCommand);
@@ -121,6 +121,23 @@ class CreateCommand extends Command {
121
121
 
122
122
  let shouldContinue = true;
123
123
 
124
+ if (
125
+ data?.meshConfig?.responseConfig?.includeHTTPDetails &&
126
+ workspaceName.toLowerCase() === 'production'
127
+ ) {
128
+ this.warn(
129
+ `Your mesh has ${chalk.yellowBright('includeHTTPDetails')} set to ${chalk.redBright(
130
+ 'true',
131
+ )}. This is a security risk and should not be used in production.\n` +
132
+ `When ${chalk.yellowBright('includeHTTPDetails')} is set to ${chalk.redBright(
133
+ 'true',
134
+ )} it exposes HTTP request and response details in the mesh logs, which can cause sensitive information to be exposed.\n` +
135
+ `Consider setting ${chalk.yellowBright('includeHTTPDetails')} to ${chalk.greenBright(
136
+ 'false',
137
+ )} in your mesh configuration file.`,
138
+ );
139
+ }
140
+
124
141
  if (!autoConfirmAction) {
125
142
  shouldContinue = await promptConfirm(`Are you sure you want to create a mesh?`);
126
143
  }
@@ -12,9 +12,9 @@ governing permissions and limitations under the License.
12
12
  const { Command } = require('@oclif/command');
13
13
 
14
14
  const logger = require('../../classes/logger');
15
- const { initSdk, initRequestId, promptConfirm } = require('../../helpers');
15
+ const { initSdk, promptConfirm } = require('../../helpers');
16
16
  const { ignoreCacheFlag, autoConfirmActionFlag } = require('../../utils');
17
- const { getMeshId, deleteMesh } = require('../../lib/devConsole');
17
+ const { getMeshId, deleteMesh } = require('../../lib/smsClient');
18
18
 
19
19
  require('dotenv').config();
20
20
 
@@ -25,8 +25,6 @@ class DeleteCommand extends Command {
25
25
  };
26
26
 
27
27
  async run() {
28
- await initRequestId();
29
-
30
28
  logger.info(`RequestId: ${global.requestId}`);
31
29
 
32
30
  const { flags } = await this.parse(DeleteCommand);
@@ -11,9 +11,9 @@ governing permissions and limitations under the License.
11
11
 
12
12
  const { Command } = require('@oclif/command');
13
13
  const logger = require('../../classes/logger');
14
- const { initSdk, initRequestId } = require('../../helpers');
14
+ const { initSdk } = require('../../helpers');
15
15
  const { ignoreCacheFlag } = require('../../utils');
16
- const { describeMesh } = require('../../lib/devConsole');
16
+ const { describeMesh } = require('../../lib/smsClient');
17
17
  const { buildMeshUrl } = require('../../urlBuilder');
18
18
 
19
19
  require('dotenv').config();
@@ -24,8 +24,6 @@ class DescribeCommand extends Command {
24
24
  };
25
25
 
26
26
  async run() {
27
- await initRequestId();
28
-
29
27
  logger.info(`RequestId: ${global.requestId}`);
30
28
 
31
29
  const { flags } = await this.parse(DescribeCommand);
@@ -13,9 +13,9 @@ const { Command } = require('@oclif/core');
13
13
  const { writeFile } = require('fs/promises');
14
14
 
15
15
  const logger = require('../../classes/logger');
16
- const { initSdk, initRequestId } = require('../../helpers');
16
+ const { initSdk } = require('../../helpers');
17
17
  const { ignoreCacheFlag, jsonFlag } = require('../../utils');
18
- const { getMeshId, getMesh } = require('../../lib/devConsole');
18
+ const { getMeshId, getMesh } = require('../../lib/smsClient');
19
19
  const { buildMeshUrl } = require('../../urlBuilder');
20
20
 
21
21
  require('dotenv').config();
@@ -29,8 +29,6 @@ class GetCommand extends Command {
29
29
  static enableJsonFlag = true;
30
30
 
31
31
  async run() {
32
- await initRequestId();
33
-
34
32
  logger.info(`RequestId: ${global.requestId}`);
35
33
 
36
34
  const { args, flags } = await this.parse(GetCommand);
@@ -1,8 +1,8 @@
1
1
  const { Command } = require('@oclif/core');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
- const { initRequestId, initSdk, promptConfirm } = require('../../helpers');
5
- const { getMeshId, getPresignedUrls } = require('../../lib/devConsole');
4
+ const { initSdk, promptConfirm } = require('../../helpers');
5
+ const { getMeshId, getPresignedUrls } = require('../../lib/smsClient');
6
6
  const logger = require('../../classes/logger');
7
7
  const axios = require('axios');
8
8
  const {
@@ -11,12 +11,10 @@ const {
11
11
  endTimeFlag,
12
12
  logFilenameFlag,
13
13
  pastFlag,
14
- fromFlag,
15
14
  suggestCorrectedDateFormat,
16
15
  parsePastDuration,
17
16
  validateDateTimeRange,
18
17
  validateDateTimeFormat,
19
- localToUTCTime,
20
18
  } = require('../../utils');
21
19
 
22
20
  require('dotenv').config();
@@ -28,7 +26,6 @@ class GetBulkLogCommand extends Command {
28
26
  endTime: endTimeFlag,
29
27
  filename: logFilenameFlag,
30
28
  past: pastFlag,
31
- from: fromFlag,
32
29
  };
33
30
 
34
31
  async run() {
@@ -36,7 +33,6 @@ class GetBulkLogCommand extends Command {
36
33
  const columnHeaders =
37
34
  'EventTimestampMs,Exceptions,Logs,Outcome,MeshId,RayID,URL,Request Method,Response Status,Level';
38
35
 
39
- await initRequestId();
40
36
  logger.info(`RequestId: ${global.requestId}`);
41
37
  const { flags } = await this.parse(GetBulkLogCommand);
42
38
  const ignoreCache = await flags.ignoreCache;
@@ -90,26 +86,9 @@ class GetBulkLogCommand extends Command {
90
86
  formattedEndTime = flags.endTime.replace(/-|:|Z/g, '').replace('T', 'T');
91
87
  } else if (flags.past) {
92
88
  const pastTimeWindow = parsePastDuration(flags.past);
93
- if (flags.from) {
94
- let convertedTime;
95
- const dateTimeRegex = /^\d{4}-\d{2}-\d{2}:\d{2}:\d{2}:\d{2}$/;
96
- if (!dateTimeRegex.test(flags.from)) {
97
- this.error('Invalid format. Use the format YYYY-MM-DD:HH:MM:SS for --from.');
98
- } else {
99
- try {
100
- convertedTime = await localToUTCTime(flags.from.toString());
101
- } catch (error) {
102
- this.error(`Invalid date components passed in --from. Correct the date.`);
103
- }
104
- }
105
- // add the past window to the converted time to get the end time to fetch logs from the past
106
- calculatedStartTime = new Date(convertedTime);
107
- calculatedEndTime = new Date(calculatedStartTime.getTime() + pastTimeWindow);
108
- } else {
109
- // subtract the past window from the current time to get the start time to fetch recent logs from now
110
- calculatedEndTime = new Date();
111
- calculatedStartTime = new Date(calculatedEndTime.getTime() - pastTimeWindow);
112
- }
89
+ // Subtract the past window from the current time to get the start time to fetch recent logs from now
90
+ calculatedEndTime = new Date();
91
+ calculatedStartTime = new Date(calculatedEndTime.getTime() - pastTimeWindow);
113
92
 
114
93
  // Validate the calculated start and end times range
115
94
  validateDateTimeRange(calculatedStartTime, calculatedEndTime);
@@ -121,7 +100,7 @@ class GetBulkLogCommand extends Command {
121
100
  return;
122
101
  } else {
123
102
  this.error(
124
- 'Missing required flags. Provide at least one flag --startTime, --endTime, or --past --from or type `mesh log:get-bulk --help` for more information.',
103
+ 'Missing required flags. Provide a time range with --startTime and --endTime flags, or use the --past flag for more recent logs. Use the `mesh log:get-bulk --help` command for more information.',
125
104
  );
126
105
  return;
127
106
  }
@@ -10,9 +10,9 @@ governing permissions and limitations under the License.
10
10
  */
11
11
  const { Command } = require('@oclif/core');
12
12
  const logger = require('../../classes/logger');
13
- const { initSdk, initRequestId } = require('../../helpers');
13
+ const { initSdk } = require('../../helpers');
14
14
  const { ignoreCacheFlag } = require('../../utils');
15
- const { getMeshId, getLogsByRayId } = require('../../lib/devConsole');
15
+ const { getMeshId, getLogsByRayId } = require('../../lib/smsClient');
16
16
  require('dotenv').config();
17
17
 
18
18
  class FetchLogsCommand extends Command {
@@ -22,8 +22,6 @@ class FetchLogsCommand extends Command {
22
22
  };
23
23
 
24
24
  async run() {
25
- await initRequestId();
26
-
27
25
  logger.info(`RequestId: ${global.requestId}`);
28
26
 
29
27
  const { args, flags } = await this.parse(FetchLogsCommand);
@@ -1,9 +1,9 @@
1
1
  const { Command } = require('@oclif/core');
2
2
 
3
3
  const logger = require('../../classes/logger');
4
- const { initSdk, initRequestId } = require('../../helpers');
4
+ const { initSdk } = require('../../helpers');
5
5
  const { ignoreCacheFlag, fileNameFlag } = require('../../utils');
6
- const { getMeshId, listLogs } = require('../../lib/devConsole');
6
+ const { getMeshId, listLogs } = require('../../lib/smsClient');
7
7
  const { appendFileSync, existsSync } = require('fs');
8
8
  const { ux } = require('@oclif/core/lib/cli-ux');
9
9
  const path = require('path');
@@ -18,8 +18,6 @@ class ListLogsCommand extends Command {
18
18
  static enableJsonFlag = true;
19
19
 
20
20
  async run() {
21
- await initRequestId();
22
-
23
21
  logger.info(`RequestId: ${global.requestId}`);
24
22
 
25
23
  const { flags } = await this.parse(ListLogsCommand);
@@ -28,15 +28,9 @@ const {
28
28
  const meshBuilder = require('@adobe-apimesh/mesh-builder');
29
29
  const fs = require('fs');
30
30
  const path = require('path');
31
- const {
32
- initSdk,
33
- initRequestId,
34
- importFiles,
35
- setUpTenantFiles,
36
- writeSecretsFile,
37
- } = require('../../helpers');
31
+ const { initSdk, importFiles, setUpTenantFiles, writeSecretsFile } = require('../../helpers');
38
32
  const logger = require('../../classes/logger');
39
- const { getMeshId, getMeshArtifact } = require('../../lib/devConsole');
33
+ const { getMeshId, getMeshArtifact } = require('../../lib/smsClient');
40
34
  require('dotenv').config();
41
35
  const { start } = require('../../wranglerCli');
42
36
  const {
@@ -257,7 +251,6 @@ class RunCommand extends Command {
257
251
 
258
252
  async run() {
259
253
  try {
260
- await initRequestId();
261
254
  logger.info(`RequestId: ${global.requestId}`);
262
255
 
263
256
  const { args, flags } = await this.parse(RunCommand);
@@ -20,13 +20,13 @@ const mockSources = { '0.0.1-test-03': mockSourceTest03v1Fixture };
20
20
  jest.mock('source-registry-storage-adapter');
21
21
  jest.mock('../../../../helpers');
22
22
  const InstallCommand = require('../install');
23
- const { getMeshId, getMesh, updateMesh } = require('../../../../lib/devConsole');
23
+ const { getMeshId, getMesh, updateMesh } = require('../../../../lib/smsClient');
24
24
  const mockGetMeshConfig = require('../../../__fixtures__/sample_mesh.json');
25
25
  const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
26
26
  const selectedProject = { id: '5678', title: 'Project01' };
27
27
  const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
28
28
  global.requestId = 'dummy_request_id';
29
- jest.mock('../../../../lib/devConsole');
29
+ jest.mock('../../../../lib/smsClient');
30
30
  mockAdapter.mockImplementation(() => ({
31
31
  get: jest.fn().mockResolvedValue(mockSources[`0.0.1-test-03`]),
32
32
  getList: jest.fn().mockImplementation(() => mockMetadataFixture),
@@ -10,12 +10,7 @@ governing permissions and limitations under the License.
10
10
  */
11
11
 
12
12
  const { Command, CliUx, Flags } = require('@oclif/core');
13
- const {
14
- promptConfirm,
15
- initRequestId,
16
- promptMultiselect,
17
- promptSelect,
18
- } = require('../../../helpers');
13
+ const { promptConfirm, promptMultiselect, promptSelect } = require('../../../helpers');
19
14
  const SourceRegistryStorage = require('source-registry-storage-adapter');
20
15
  const config = require('@adobe/aio-lib-core-config');
21
16
  const logger = require('../../../classes/logger');
@@ -24,8 +19,6 @@ const InstallCommand = require('./install');
24
19
  class DiscoverCommand extends Command {
25
20
  async run() {
26
21
  try {
27
- await initRequestId();
28
-
29
22
  logger.info(`RequestId: ${global.requestId}`);
30
23
  const { flags } = await this.parse(DiscoverCommand);
31
24
  const srs = new SourceRegistryStorage(config.get('api-mesh.sourceRegistry.path'));
@@ -58,7 +51,7 @@ class DiscoverCommand extends Command {
58
51
  } catch (error) {
59
52
  logger.error(error);
60
53
  this.error(`
61
- Something went wrong with "discover" command. Please try again later.
54
+ Something went wrong with "discover" command. Please try again later.
62
55
  ${error}
63
56
  `);
64
57
  }
@@ -12,12 +12,7 @@ governing permissions and limitations under the License.
12
12
 
13
13
  const { Command, Flags } = require('@oclif/core');
14
14
  const SourceRegistryStorage = require('source-registry-storage-adapter');
15
- const {
16
- promptMultiselect,
17
- promptSelect,
18
- promptConfirm,
19
- initRequestId,
20
- } = require('../../../helpers');
15
+ const { promptMultiselect, promptSelect, promptConfirm } = require('../../../helpers');
21
16
  const ncp = require('node-clipboardy');
22
17
  const chalk = require('chalk');
23
18
  const config = require('@adobe/aio-lib-core-config');
@@ -33,8 +28,6 @@ class GetCommand extends Command {
33
28
 
34
29
  async run() {
35
30
  try {
36
- await initRequestId();
37
-
38
31
  logger.info(`RequestId: ${global.requestId}`);
39
32
  let list;
40
33
  try {
@@ -12,13 +12,13 @@ governing permissions and limitations under the License.
12
12
 
13
13
  const { Command, Flags } = require('@oclif/core');
14
14
  const SourceRegistryStorage = require('source-registry-storage-adapter');
15
- const { promptConfirm, promptInput, initRequestId, initSdk } = require('../../../helpers');
15
+ const { promptConfirm, promptInput, initSdk } = require('../../../helpers');
16
16
  const { ignoreCacheFlag } = require('../../../utils');
17
17
  const config = require('@adobe/aio-lib-core-config');
18
18
  const logger = require('../../../classes/logger');
19
19
  const { readFile } = require('fs/promises');
20
20
  const chalk = require('chalk');
21
- const { getMeshId, getMesh, updateMesh } = require('../../../lib/devConsole');
21
+ const { getMeshId, getMesh, updateMesh } = require('../../../lib/smsClient');
22
22
  const JsonInterpolate = require('json-interpolate');
23
23
 
24
24
  class InstallCommand extends Command {
@@ -33,7 +33,6 @@ class InstallCommand extends Command {
33
33
 
34
34
  async run() {
35
35
  const { flags, args } = await this.parse(InstallCommand);
36
- await initRequestId();
37
36
  logger.info(`RequestId: ${global.requestId}`);
38
37
  const ignoreCache = await flags.ignoreCache;
39
38
  const {