@adobe/aio-cli-plugin-api-mesh 4.1.0-alpha → 4.1.0-beta.2

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.
@@ -16,6 +16,7 @@ const logger = require('../../classes/logger');
16
16
  const { initSdk, initRequestId } = require('../../helpers');
17
17
  const { ignoreCacheFlag, jsonFlag } = require('../../utils');
18
18
  const { getMeshId, getMesh } = require('../../lib/devConsole');
19
+ const { buildMeshUrl } = require('../../urlBuilder');
19
20
 
20
21
  require('dotenv').config();
21
22
  class GetCommand extends Command {
@@ -37,7 +38,7 @@ class GetCommand extends Command {
37
38
  const ignoreCache = await flags.ignoreCache;
38
39
  const json = await flags.json;
39
40
 
40
- const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
41
+ const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
41
42
  ignoreCache,
42
43
  verbose: !json,
43
44
  });
@@ -45,20 +46,22 @@ class GetCommand extends Command {
45
46
  let meshId = null;
46
47
 
47
48
  try {
48
- meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
49
+ meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
49
50
  } catch (err) {
50
51
  this.error(
51
- `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
52
+ `Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
52
53
  );
53
54
  }
54
55
 
55
56
  if (meshId) {
56
57
  try {
57
- const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
58
+ const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
58
59
 
59
60
  if (mesh) {
60
61
  this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
61
62
 
63
+ const meshUrl = buildMeshUrl(meshId, workspaceName);
64
+
62
65
  if (args.file) {
63
66
  try {
64
67
  const { meshConfig } = mesh;
@@ -72,10 +75,10 @@ class GetCommand extends Command {
72
75
  }
73
76
  }
74
77
 
75
- return mesh;
78
+ return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName };
76
79
  } else {
77
80
  logger.error(
78
- `Unable to get mesh with the ID ${meshId}. Check the mesh ID and try again. RequestId: ${global.requestId}`,
81
+ `Unable to get mesh with the ID ${meshId}. Please check the mesh ID and try again. RequestId: ${global.requestId}`,
79
82
  { exit: false },
80
83
  );
81
84
  }
@@ -83,12 +86,12 @@ class GetCommand extends Command {
83
86
  this.log(error.message);
84
87
 
85
88
  this.error(
86
- `Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
89
+ `Unable to get mesh. Please check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
87
90
  );
88
91
  }
89
92
  } else {
90
93
  this.error(
91
- `Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
94
+ `Unable to get mesh config. No mesh found for Org(${imsOrgId}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
92
95
  { exit: false },
93
96
  );
94
97
  }
@@ -26,12 +26,10 @@ const {
26
26
  } = require('../../utils');
27
27
  const meshBuilder = require('@adobe-apimesh/mesh-builder');
28
28
  const fs = require('fs');
29
- const UUID = require('../../uuid');
30
29
  const path = require('path');
31
30
  const {
32
31
  initSdk,
33
32
  initRequestId,
34
- startGraphqlServer,
35
33
  importFiles,
36
34
  setUpTenantFiles,
37
35
  writeSecretsFile,
@@ -39,6 +37,8 @@ const {
39
37
  const logger = require('../../classes/logger');
40
38
  const { getMeshId, getMeshArtifact } = require('../../lib/devConsole');
41
39
  require('dotenv').config();
40
+ const { runServer } = require('../../server');
41
+ const { fixPlugins } = require('../../fixPlugins');
42
42
 
43
43
  const { validateMesh, buildMesh, compileMesh } = meshBuilder.default;
44
44
 
@@ -82,10 +82,10 @@ class RunCommand extends Command {
82
82
  if (fs.existsSync(path.join(process.cwd(), 'package.json'))) {
83
83
  //If select flag is present then getMeshId for the specified org
84
84
  if (flags.select) {
85
- const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({});
85
+ const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({});
86
86
 
87
87
  try {
88
- meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
88
+ meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
89
89
  } catch (err) {
90
90
  throw new Error(
91
91
  `Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
@@ -93,7 +93,7 @@ class RunCommand extends Command {
93
93
  }
94
94
 
95
95
  try {
96
- await getMeshArtifact(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
96
+ await getMeshArtifact(imsOrgId, projectId, workspaceId, workspaceName, meshId);
97
97
  } catch (err) {
98
98
  throw new Error(
99
99
  `Unable to retrieve mesh. Please check the details and try again. RequestId: ${global.requestId}`,
@@ -163,13 +163,12 @@ class RunCommand extends Command {
163
163
  }
164
164
 
165
165
  //Generating unique mesh id
166
- meshId = UUID.newUuid().toString();
166
+ meshId = 'testMesh';
167
167
 
168
168
  await validateMesh(data.meshConfig);
169
169
  await buildMesh(meshId, data.meshConfig);
170
170
  await compileMesh(meshId);
171
171
  }
172
-
173
172
  let portNo;
174
173
  //secrets management
175
174
  if (secretsFilePath) {
@@ -183,6 +182,8 @@ class RunCommand extends Command {
183
182
  }
184
183
  }
185
184
 
185
+ await this.copyMeshContent(meshId);
186
+
186
187
  //To set the port number using the environment file
187
188
  if (process.env.PORT !== undefined) {
188
189
  if (isNaN(process.env.PORT) || !Number.isInteger(parseInt(process.env.PORT))) {
@@ -201,9 +202,8 @@ class RunCommand extends Command {
201
202
  if (!portNo) {
202
203
  portNo = 5000;
203
204
  }
204
-
205
- this.log(`Starting server on port : ${portNo}`);
206
- await startGraphqlServer(meshId, portNo, flags.debug);
205
+ meshId = '000000000000-0000-0000-0000-000000000000';
206
+ runServer(meshId, portNo);
207
207
  } else {
208
208
  throw new Error(
209
209
  '`aio api-mesh run` cannot be executed because there is no package.json file in the current directory. Use `aio api-mesh init` to set up a package.',
@@ -213,6 +213,31 @@ class RunCommand extends Command {
213
213
  this.error(error.message);
214
214
  }
215
215
  }
216
+
217
+ async copyMeshContent(meshId) {
218
+ // Remove mesh artifact directory if exists
219
+ if (fs.existsSync('.mesh')) {
220
+ fs.rmdirSync('.mesh', { recursive: true });
221
+ }
222
+ // Move built mesh artifact to expect directory
223
+ fs.renameSync(`mesh-artifact/${meshId}`, '.mesh');
224
+ // Remove tenant files directory if exists
225
+ if (fs.existsSync('tenantFiles')) {
226
+ fs.rmdirSync('tenantFiles', { recursive: true });
227
+ }
228
+ // Move built tenant files if exists
229
+ if (fs.existsSync('mesh-artifact/tenantFiles')) {
230
+ fs.cpSync('mesh-artifact/tenantFiles', '.mesh/tenantFiles', { recursive: true });
231
+ fs.renameSync('mesh-artifact/tenantFiles', 'tenantFiles');
232
+ }
233
+
234
+ await fixPlugins('.mesh/index.js');
235
+
236
+ if (fs.existsSync(`${__dirname}/../../../.mesh`)) {
237
+ fs.rmdirSync(`${__dirname}/../../../.mesh`, { recursive: true });
238
+ }
239
+ fs.cpSync('.mesh', `${__dirname}/../../../.mesh`, { recursive: true });
240
+ }
216
241
  }
217
242
 
218
243
  module.exports = RunCommand;
@@ -18,14 +18,14 @@ class StatusCommand extends Command {
18
18
 
19
19
  const { flags } = await this.parse(StatusCommand);
20
20
  const ignoreCache = await flags.ignoreCache;
21
- const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
21
+ const { imsOrgId, imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
22
22
  ignoreCache,
23
23
  });
24
24
 
25
25
  let meshId = null;
26
26
 
27
27
  try {
28
- meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
28
+ meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
29
29
  } catch (err) {
30
30
  // API Request failed
31
31
  this.log(err.message);
@@ -37,12 +37,12 @@ class StatusCommand extends Command {
37
37
  // API Request succeeded, but mesh could not be found
38
38
  if (!meshId) {
39
39
  this.error(
40
- `Unable to get mesh status. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
40
+ `Unable to get mesh status. No mesh found for Org(${imsOrgId}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
41
41
  );
42
42
  }
43
43
 
44
44
  try {
45
- const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
45
+ const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
46
46
  this.log(''.padEnd(102, '*'));
47
47
  await this.displayMeshStatus(mesh, imsOrgCode, projectId, workspaceId);
48
48
  this.log(''.padEnd(102, '*'));
@@ -73,10 +73,10 @@ class UpdateCommand extends Command {
73
73
  let meshId = null;
74
74
 
75
75
  try {
76
- meshId = await getMeshId(imsOrgCode, projectId, workspaceId);
76
+ meshId = await getMeshId(imsOrgId, projectId, workspaceId);
77
77
  } catch (err) {
78
78
  this.error(
79
- `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
79
+ `Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
80
80
  );
81
81
  }
82
82
 
@@ -90,7 +90,7 @@ class UpdateCommand extends Command {
90
90
  data = JSON.parse(inputMeshData);
91
91
  } catch (err) {
92
92
  this.log(err.message);
93
- this.error('Input mesh file is not a valid JSON. Check the file provided.');
93
+ this.error('Input mesh file is not a valid JSON. Please check the file provided.');
94
94
  }
95
95
  }
96
96
 
@@ -109,7 +109,9 @@ class UpdateCommand extends Command {
109
109
  data = await importFiles(data, filesList, args.file, flags.autoConfirmAction);
110
110
  } catch (err) {
111
111
  this.log(err.message);
112
- this.error('Unable to import the files in the mesh config. Check the file and try again.');
112
+ this.error(
113
+ 'Unable to import the files in the mesh config. Please check the file and try again.',
114
+ );
113
115
  }
114
116
  }
115
117
 
@@ -123,7 +125,7 @@ class UpdateCommand extends Command {
123
125
  data.secrets = encryptedSecrets;
124
126
  } catch (err) {
125
127
  this.log(err.message);
126
- this.error('Unable to import secrets. Check the file and try again.');
128
+ this.error('Unable to import secrets. Please check the file and try again.');
127
129
  }
128
130
  }
129
131
 
@@ -139,7 +141,7 @@ class UpdateCommand extends Command {
139
141
  if (shouldContinue) {
140
142
  try {
141
143
  const response = await updateMesh(
142
- imsOrgCode,
144
+ imsOrgId,
143
145
  projectId,
144
146
  workspaceId,
145
147
  workspaceName,
@@ -167,7 +169,7 @@ class UpdateCommand extends Command {
167
169
  this.log(error.message);
168
170
 
169
171
  this.error(
170
- `Unable to update the mesh. Check the mesh configuration file and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
172
+ `Unable to update the mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
171
173
  );
172
174
  }
173
175
  } else {
package/src/constants.js CHANGED
@@ -9,7 +9,6 @@ const StageConstants = {
9
9
  AIO_CLI_API_KEY: 'aio-cli-console-auth-stage',
10
10
  SMS_BASE_URL: 'https://graph-stage.adobe.io/api-admin',
11
11
  MESH_BASE_URL: 'https://edge-stage-graph.adobe.io/api',
12
- SMS_API_KEY: 'adobe-graph-stage-onboarding',
13
12
  };
14
13
 
15
14
  const ProdConstants = {
@@ -20,7 +19,6 @@ const ProdConstants = {
20
19
  SMS_BASE_URL: 'https://graph.adobe.io/api-admin',
21
20
  MESH_BASE_URL: 'https://edge-graph.adobe.io/api',
22
21
  MESH_SANDBOX_BASE_URL: 'https://edge-sandbox-graph.adobe.io/api',
23
- SMS_API_KEY: 'adobe-graph-prod',
24
22
  };
25
23
 
26
24
  const envConstants = clientEnv === 'stage' ? StageConstants : ProdConstants;
package/src/cors.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Get default CORS options.
3
+ * @param env Environment.
4
+ */
5
+ const getDefaultCorsOptions = env => {
6
+ return env.CORS_DEFAULT_URL
7
+ ? {
8
+ origin: env.CORS_DEFAULT_URL,
9
+ }
10
+ : {};
11
+ };
12
+
13
+ /**
14
+ * Get CORS options. Merges default CORS options with custom specific options if present in the mesh configuration.
15
+ * Custom CORS options overwrite the default options to ensure that specific requirements can be met without altering
16
+ * the default configuration.
17
+ * @param env Environment.
18
+ * @param meshConfig Mesh configuration.
19
+ */
20
+ const getCorsOptions = (env, meshConfig) => {
21
+ const defaultCorsOptions = getDefaultCorsOptions(env);
22
+ return {
23
+ ...defaultCorsOptions,
24
+ ...meshConfig.responseConfig?.CORS,
25
+ };
26
+ };
27
+
28
+ module.exports = { getCorsOptions };
@@ -0,0 +1,28 @@
1
+ /* eslint-disable no-console */
2
+ const fs = require('fs');
3
+ /**
4
+ * Modifies `index.js` of a mesh artifact to mutate plugin references for edge compatibility. Current forces
5
+ * `@graphql-mesh/plugin-http-details-extensions` to resolve to local fork instead.
6
+ */
7
+ async function fixPlugins(meshArtifactPath) {
8
+ try {
9
+ console.log('Modifying mesh artifact to fix plugins for edge compatibility.');
10
+ const data = fs.readFileSync(meshArtifactPath, 'utf8');
11
+ const updatedData = data.replace(
12
+ /@graphql-mesh\/plugin-http-details-extensions/g,
13
+ '../src/plugins/httpDetailsExtensions',
14
+ );
15
+ fs.writeFileSync(meshArtifactPath, updatedData, 'utf8');
16
+ } catch (err) {
17
+ console.error(err);
18
+ }
19
+ }
20
+
21
+ // Execute fixPlugins if run directly from CLI
22
+ if (require.main === module) {
23
+ fixPlugins();
24
+ }
25
+
26
+ module.exports = {
27
+ fixPlugins,
28
+ };
package/src/index.js ADDED
@@ -0,0 +1,44 @@
1
+ import { ServedTier, addServedHeader } from './served';
2
+ import { bindedlogger as logger } from './utils/logger';
3
+ import { getRequestId } from './utils/requestId';
4
+ import { buildServer } from './wranglerServer';
5
+
6
+ let server;
7
+
8
+ export default {
9
+ setServer(newServer) {
10
+ server = newServer;
11
+ },
12
+ /**
13
+ * Fetch.
14
+ * @param request Request.
15
+ * @param env Environment.
16
+ * @param ctx Event context.
17
+ */
18
+ async fetch(request, env, ctx) {
19
+ const requestId = getRequestId(request);
20
+ // Retrieve environment variables
21
+ const { MESH_ID: meshId, LOG_LEVEL: logLevel } = env;
22
+ const loggerInstance = logger({ logLevel, meshId, requestId });
23
+ const meshArtifacts = await import('../.mesh');
24
+ const rawMesh = await import('../.mesh/.meshrc.json');
25
+
26
+ if (!server) {
27
+ server = await this.buildAndCacheServer(env, loggerInstance, meshArtifacts, rawMesh);
28
+ }
29
+
30
+ loggerInstance.debug('WORKER HOT: Fetching via worker');
31
+ const response = await server.fetch(request, ctx);
32
+ addServedHeader(response, ServedTier.WORKER_HOT);
33
+ return response;
34
+ },
35
+ /**
36
+ * Build and cache mesh instance/server in global variable.
37
+ * @param env
38
+ * @param loggerInstance
39
+ */
40
+ async buildAndCacheServer(env, loggerInstance, meshArtifacts, meshConfig) {
41
+ server = await buildServer(loggerInstance, env, meshArtifacts, meshConfig);
42
+ return server;
43
+ },
44
+ };
@@ -12,7 +12,7 @@ const exec = util.promisify(require('child_process').exec);
12
12
  const contentDisposition = require('content-disposition');
13
13
  const chalk = require('chalk');
14
14
 
15
- const { DEV_CONSOLE_TRANSPORTER_API_KEY, SMS_BASE_URL, SMS_API_KEY } = CONSTANTS;
15
+ const { DEV_CONSOLE_TRANSPORTER_API_KEY, SMS_BASE_URL } = CONSTANTS;
16
16
 
17
17
  const { objToString, getDevConsoleConfig } = require('../helpers');
18
18
 
@@ -113,7 +113,7 @@ const describeMesh = async (organizationId, projectId, workspaceId, workspaceNam
113
113
  * @returns
114
114
  */
115
115
  const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileName) => {
116
- const { accessToken } = await getDevConsoleConfig();
116
+ const { accessToken, apiKey } = await getDevConsoleConfig();
117
117
  const url = `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/logs/list`;
118
118
  const config = {
119
119
  method: 'get',
@@ -121,7 +121,7 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa
121
121
  headers: {
122
122
  'Authorization': `Bearer ${accessToken}`,
123
123
  'x-request-id': global.requestId,
124
- 'x-api-key': SMS_API_KEY,
124
+ 'X-Api-Key': apiKey,
125
125
  },
126
126
  };
127
127
 
@@ -142,21 +142,20 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa
142
142
  };
143
143
 
144
144
  const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId) => {
145
- const { accessToken } = await getDevConsoleConfig();
145
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
146
146
  const config = {
147
147
  method: 'get',
148
- url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
148
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
149
149
  headers: {
150
150
  'Authorization': `Bearer ${accessToken}`,
151
151
  'x-request-id': global.requestId,
152
152
  'workspaceName': workspaceName,
153
- 'x-api-key': SMS_API_KEY,
154
153
  },
155
154
  };
156
155
 
157
156
  logger.info(
158
157
  'Initiating GET %s',
159
- `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
158
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
160
159
  );
161
160
 
162
161
  try {
@@ -233,10 +232,10 @@ const createMesh = async (
233
232
  projectName,
234
233
  data,
235
234
  ) => {
236
- const { accessToken } = await getDevConsoleConfig();
235
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
237
236
  const config = {
238
237
  method: 'post',
239
- url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes`,
238
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes?API_KEY=${apiKey}`,
240
239
  headers: {
241
240
  'Authorization': `Bearer ${accessToken}`,
242
241
  'Content-Type': 'application/json',
@@ -244,14 +243,13 @@ const createMesh = async (
244
243
  'workspaceName': workspaceName,
245
244
  'orgName': orgName,
246
245
  'projectName': projectName,
247
- 'x-api-key': SMS_API_KEY,
248
246
  },
249
247
  data: JSON.stringify(data),
250
248
  };
251
249
 
252
250
  logger.info(
253
251
  'Initiating POST %s',
254
- `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes`,
252
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes?API_KEY=${apiKey}`,
255
253
  );
256
254
 
257
255
  try {
@@ -345,10 +343,10 @@ const updateMesh = async (
345
343
  meshId,
346
344
  data,
347
345
  ) => {
348
- const { accessToken } = await getDevConsoleConfig();
346
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
349
347
  const config = {
350
348
  method: 'put',
351
- url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
349
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
352
350
  headers: {
353
351
  'Authorization': `Bearer ${accessToken}`,
354
352
  'Content-Type': 'application/json',
@@ -356,14 +354,13 @@ const updateMesh = async (
356
354
  'workspaceName': workspaceName,
357
355
  'orgName': orgName,
358
356
  'projectName': projectName,
359
- 'x-api-key': SMS_API_KEY,
360
357
  },
361
358
  data: JSON.stringify(data),
362
359
  };
363
360
 
364
361
  logger.info(
365
362
  'Initiating PUT %s',
366
- `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
363
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
367
364
  );
368
365
 
369
366
  try {
@@ -436,20 +433,19 @@ const updateMesh = async (
436
433
  };
437
434
 
438
435
  const deleteMesh = async (organizationId, projectId, workspaceId, meshId) => {
439
- const { accessToken } = await getDevConsoleConfig();
436
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
440
437
  const config = {
441
438
  method: 'delete',
442
- url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
439
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
443
440
  headers: {
444
441
  'Authorization': `Bearer ${accessToken}`,
445
442
  'x-request-id': global.requestId,
446
- 'x-api-key': SMS_API_KEY,
447
443
  },
448
444
  };
449
445
 
450
446
  logger.info(
451
447
  'Initiating DELETE %s',
452
- `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
448
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}?API_KEY=${apiKey}`,
453
449
  );
454
450
 
455
451
  try {
@@ -521,24 +517,23 @@ const deleteMesh = async (organizationId, projectId, workspaceId, meshId) => {
521
517
  }
522
518
  };
523
519
 
524
- const getMeshId = async (organizationCode, projectId, workspaceId, workspaceName) => {
525
- const { accessToken } = await getDevConsoleConfig();
520
+ const getMeshId = async (organizationId, projectId, workspaceId, workspaceName) => {
521
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
526
522
  logger.info('Initiating Mesh ID request');
527
523
 
528
524
  const config = {
529
525
  method: 'get',
530
- url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/mesh`,
526
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/describe?API_KEY=${apiKey}`,
531
527
  headers: {
532
528
  'Authorization': `Bearer ${accessToken}`,
533
529
  'x-request-id': global.requestId,
534
530
  'workspaceName': workspaceName,
535
- 'x-api-key': SMS_API_KEY,
536
531
  },
537
532
  };
538
533
 
539
534
  logger.info(
540
535
  'Initiating GET %s',
541
- `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/mesh`,
536
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/describe?API_KEY=${apiKey}`,
542
537
  );
543
538
 
544
539
  try {
@@ -810,22 +805,21 @@ const unsubscribeCredentialFromMeshService = async (
810
805
  };
811
806
 
812
807
  const getMeshArtifact = async (organizationId, projectId, workspaceId, workspaceName, meshId) => {
813
- const { accessToken } = await getDevConsoleConfig();
808
+ const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
814
809
  const config = {
815
810
  method: 'get',
816
- url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact`,
811
+ url: `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact?API_KEY=${apiKey}`,
817
812
  headers: {
818
813
  'Authorization': `Bearer ${accessToken}`,
819
814
  'x-request-id': global.requestId,
820
815
  'workspaceName': workspaceName,
821
- 'x-api-key': SMS_API_KEY,
822
816
  },
823
817
  responseType: 'arraybuffer',
824
818
  };
825
819
 
826
820
  logger.info(
827
821
  'Initiating GET %s',
828
- `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact`,
822
+ `${devConsoleUrl}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact?API_KEY=${apiKey}`,
829
823
  );
830
824
 
831
825
  try {
@@ -868,14 +862,14 @@ const getMeshArtifact = async (organizationId, projectId, workspaceId, workspace
868
862
  * @returns {Promise<Object>}
869
863
  */
870
864
  const getTenantFeatures = async organizationCode => {
871
- const { accessToken } = await getDevConsoleConfig();
865
+ const { accessToken, apiKey } = await getDevConsoleConfig();
872
866
  const config = {
873
867
  method: 'get',
874
868
  url: `${SMS_BASE_URL}/organizations/${organizationCode}/features`,
875
869
  headers: {
876
870
  'Authorization': `Bearer ${accessToken}`,
877
871
  'x-request-id': global.requestId,
878
- 'x-api-key': SMS_API_KEY,
872
+ 'X-Api-Key': apiKey,
879
873
  },
880
874
  };
881
875
 
@@ -923,14 +917,14 @@ const getTenantFeatures = async organizationCode => {
923
917
  * @returns {Promise<Object>}
924
918
  */
925
919
  const getMeshDeployments = async (organizationCode, projectId, workspaceId, meshId) => {
926
- const { accessToken } = await getDevConsoleConfig();
920
+ const { accessToken, apiKey } = await getDevConsoleConfig();
927
921
  const config = {
928
922
  method: 'get',
929
923
  url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/deployments/latest`,
930
924
  headers: {
931
925
  'Authorization': `Bearer ${accessToken}`,
932
926
  'x-request-id': global.requestId,
933
- 'x-api-key': SMS_API_KEY,
927
+ 'X-Api-Key': apiKey,
934
928
  },
935
929
  };
936
930
 
@@ -979,14 +973,14 @@ const getMeshDeployments = async (organizationCode, projectId, workspaceId, mesh
979
973
  * @returns string
980
974
  */
981
975
  const getPublicEncryptionKey = async organizationCode => {
982
- const { accessToken } = await getDevConsoleConfig();
976
+ const { accessToken, apiKey } = await getDevConsoleConfig();
983
977
  const config = {
984
978
  method: 'get',
985
979
  url: `${SMS_BASE_URL}/organizations/${organizationCode}/getPublicKey`,
986
980
  headers: {
987
981
  'Authorization': `Bearer ${accessToken}`,
988
982
  'x-request-id': global.requestId,
989
- 'x-api-key': SMS_API_KEY,
983
+ 'X-Api-Key': apiKey,
990
984
  },
991
985
  };
992
986
  logger.info(
@@ -1024,14 +1018,14 @@ const getPresignedUrls = async (
1024
1018
  startTime,
1025
1019
  endTime,
1026
1020
  ) => {
1027
- const { accessToken } = await getDevConsoleConfig();
1021
+ const { accessToken, apiKey } = await getDevConsoleConfig();
1028
1022
  const config = {
1029
1023
  method: 'get',
1030
1024
  url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/logs?startDateTime=${startTime}&endDateTime=${endTime}`,
1031
1025
  headers: {
1032
1026
  'Authorization': `Bearer ${accessToken}`,
1033
1027
  'x-request-id': global.requestId,
1034
- 'x-api-key': SMS_API_KEY,
1028
+ 'X-Api-Key': apiKey,
1035
1029
  },
1036
1030
  };
1037
1031
 
@@ -1063,14 +1057,14 @@ const getPresignedUrls = async (
1063
1057
  };
1064
1058
 
1065
1059
  const getLogsByRayId = async (organizationCode, projectId, workspaceId, meshId, rayId) => {
1066
- const { accessToken } = await getDevConsoleConfig();
1060
+ const { accessToken, apiKey } = await getDevConsoleConfig();
1067
1061
  const config = {
1068
1062
  method: 'get',
1069
1063
  url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/logs/${rayId}`,
1070
1064
  headers: {
1071
1065
  'Authorization': `Bearer ${accessToken}`,
1072
1066
  'x-request-id': global.requestId,
1073
- 'x-api-key': SMS_API_KEY,
1067
+ 'X-Api-Key': apiKey,
1074
1068
  },
1075
1069
  };
1076
1070