@adobe/aio-cli-plugin-api-mesh 3.3.0-alpha → 3.3.0-alpha.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.
@@ -1 +1 @@
1
- {"version":"3.3.0-alpha","commands":{"PLUGINNAME":{"id":"PLUGINNAME","description":"Your description here","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio PLUGINNAME:some_command"],"flags":{"someflag":{"name":"someflag","type":"option","char":"f","description":"this is some flag"}},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server"},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]}}}
1
+ {"version":"3.3.0-alpha.2","commands":{"PLUGINNAME":{"id":"PLUGINNAME","description":"Your description here","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio PLUGINNAME:some_command"],"flags":{"someflag":{"name":"someflag","type":"option","char":"f","description":"this is some flag"}},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server"},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-plugin-api-mesh",
3
- "version": "3.3.0-alpha",
3
+ "version": "3.3.0-alpha.2",
4
4
  "description": "Adobe I/O CLI plugin to develop and manage API mesh sources",
5
5
  "keywords": [
6
6
  "oclif-plugin"
@@ -52,6 +52,9 @@ describe('update command tests', () => {
52
52
  imsOrgId: selectedOrg.id,
53
53
  projectId: selectedProject.id,
54
54
  workspaceId: selectedWorkspace.id,
55
+ workspaceName: selectedWorkspace.title,
56
+ orgName: selectedOrg.name,
57
+ projectName: selectedProject.title,
55
58
  });
56
59
 
57
60
  global.requestId = 'dummy_request_id';
@@ -554,6 +557,9 @@ describe('update command tests', () => {
554
557
  "1234",
555
558
  "5678",
556
559
  "123456789",
560
+ "Workspace01",
561
+ "ORG01",
562
+ "Project01",
557
563
  "mesh_id",
558
564
  {
559
565
  "meshConfig": {
@@ -40,6 +40,8 @@ initSdk.mockResolvedValue({
40
40
  projectId: selectedProject.id,
41
41
  workspaceId: selectedWorkspace.id,
42
42
  workspaceName: selectedWorkspace.title,
43
+ organizationName: selectedOrg.name,
44
+ projectName: selectedProject.title,
43
45
  });
44
46
  initRequestId.mockResolvedValue({});
45
47
  promptInput.mockResolvedValueOnce('test-03');
@@ -148,6 +150,8 @@ describe('source:install command tests', () => {
148
150
  selectedProject.id,
149
151
  selectedWorkspace.id,
150
152
  selectedWorkspace.title,
153
+ selectedOrg.name,
154
+ selectedProject.title,
151
155
  'dummy_meshId',
152
156
  res,
153
157
  );
@@ -36,7 +36,14 @@ class InstallCommand extends Command {
36
36
  await initRequestId();
37
37
  logger.info(`RequestId: ${global.requestId}`);
38
38
  const ignoreCache = await flags.ignoreCache;
39
- const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({ ignoreCache });
39
+ const {
40
+ imsOrgId,
41
+ projectId,
42
+ workspaceId,
43
+ organizationName,
44
+ projectName,
45
+ workspaceName,
46
+ } = await initSdk({ ignoreCache });
40
47
  const filepath = flags['variable-file'];
41
48
  let variables = flags.variable
42
49
  ? flags.variable.reduce((obj, val) => {
@@ -199,9 +206,18 @@ class InstallCommand extends Command {
199
206
  }
200
207
 
201
208
  try {
202
- const response = await updateMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId, {
203
- meshConfig: mesh.meshConfig,
204
- });
209
+ const response = await updateMesh(
210
+ imsOrgId,
211
+ projectId,
212
+ workspaceId,
213
+ workspaceName,
214
+ organizationName,
215
+ projectName,
216
+ meshId,
217
+ {
218
+ meshConfig: mesh.meshConfig,
219
+ },
220
+ );
205
221
 
206
222
  this.log('Successfully updated the mesh with the id: %s', meshId);
207
223
 
@@ -1,7 +1,14 @@
1
1
  const { Command } = require('@oclif/core');
2
+ const chalk = require('chalk');
3
+
2
4
  const logger = require('../../classes/logger');
3
5
  const { initRequestId, initSdk } = require('../../helpers');
4
- const { getMeshId, getMesh } = require('../../lib/devConsole');
6
+ const {
7
+ getMeshId,
8
+ getMesh,
9
+ getTenantFeatures,
10
+ getMeshDeployments,
11
+ } = require('../../lib/devConsole');
5
12
  const { ignoreCacheFlag } = require('../../utils');
6
13
 
7
14
  require('dotenv').config();
@@ -18,7 +25,7 @@ class StatusCommand extends Command {
18
25
  const { flags } = await this.parse(StatusCommand);
19
26
  const ignoreCache = await flags.ignoreCache;
20
27
 
21
- const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
28
+ const { imsOrgId, imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
22
29
  ignoreCache,
23
30
  });
24
31
 
@@ -35,47 +42,79 @@ class StatusCommand extends Command {
35
42
 
36
43
  if (meshId) {
37
44
  try {
45
+ const { showCloudflareURL: showEdgeMeshUrl } = await getTenantFeatures(imsOrgCode);
38
46
  const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
47
+ this.log(
48
+ '******************************************************************************************************',
49
+ );
39
50
  switch (mesh.meshStatus) {
40
51
  case 'success':
41
- this.log(
42
- '******************************************************************************************************',
43
- );
44
- this.log('Your mesh has been successfully built.');
45
- this.log(
46
- '******************************************************************************************************',
47
- );
52
+ this.log(`${chalk.bold(`Legacy Mesh:`)} has been successfully built.`);
48
53
  break;
49
54
  case 'pending':
50
- this.log(
51
- '******************************************************************************************************',
52
- );
53
- this.log('Your mesh is awaiting processing.');
54
- this.log(
55
- '******************************************************************************************************',
56
- );
55
+ this.log(`${chalk.bold(`Legacy Mesh:`)} is awaiting processing.`);
57
56
  break;
58
57
  case 'building':
59
58
  this.log(
60
- '******************************************************************************************************',
61
- );
62
- this.log(
63
- 'Your mesh is currently being provisioned. Please wait a few minutes before checking again.',
64
- );
65
- this.log(
66
- '******************************************************************************************************',
59
+ `${chalk.bold(
60
+ `Legacy Mesh:`,
61
+ )} is currently being provisioned. Please wait a few minutes before checking again.`,
67
62
  );
68
63
  break;
69
64
  case 'error':
70
- this.log(
71
- '******************************************************************************************************',
72
- );
73
- this.log('Your mesh errored out with the following error. ', mesh.error);
74
- this.log(
75
- '******************************************************************************************************',
76
- );
65
+ this.log(`${chalk.bold(`Legacy Mesh:`)} build has errors.`);
66
+ this.log(mesh.error);
77
67
  break;
78
68
  }
69
+ if (showEdgeMeshUrl) {
70
+ if (mesh.meshStatus == 'error') {
71
+ this.log(`${chalk.bold(`Edge Mesh:`)} build has errors.`);
72
+ this.log(mesh.error);
73
+ } else {
74
+ const meshDeployments = await getMeshDeployments(
75
+ imsOrgCode,
76
+ projectId,
77
+ workspaceId,
78
+ meshId,
79
+ );
80
+ switch (String(meshDeployments.status).toLowerCase()) {
81
+ case 'success':
82
+ this.log(`${chalk.bold(`Edge Mesh:`)} has been successfully built.`);
83
+ break;
84
+ case 'provisioning':
85
+ this.log(
86
+ `${chalk.bold(
87
+ `Edge Mesh:`,
88
+ )} is currently being provisioned. Please wait a few minutes before checking again.`,
89
+ );
90
+ break;
91
+ case 'de-provisioning':
92
+ this.log(
93
+ `${chalk.bold(
94
+ `Edge Mesh:`,
95
+ )} is currently being de-provisioned. Please wait a few minutes before checking again.`,
96
+ );
97
+ break;
98
+ case 'error':
99
+ if (meshDeployments.error.includes(`Mesh status is not available`))
100
+ this.log(`${chalk.bold(`Edge Mesh:`)} ${meshDeployments.error}`);
101
+ else {
102
+ this.log(`${chalk.bold(`Edge Mesh:`)} build has errors.`);
103
+ this.log(meshDeployments.error);
104
+ }
105
+ break;
106
+ default:
107
+ this.log(
108
+ `${chalk.bold(
109
+ `Edge Mesh:`,
110
+ )} Mesh status is not available. Please wait for a while and try again.`,
111
+ );
112
+ }
113
+ }
114
+ }
115
+ this.log(
116
+ '******************************************************************************************************',
117
+ );
79
118
  } catch (err) {
80
119
  this.log(err.message);
81
120
 
@@ -49,9 +49,11 @@ class UpdateCommand extends Command {
49
49
  const autoConfirmAction = await flags.autoConfirmAction;
50
50
  const envFilePath = await flags.env;
51
51
 
52
- const { imsOrgId, projectId, workspaceId } = await initSdk({
53
- ignoreCache,
54
- });
52
+ const { imsOrgId, projectId, workspaceId, orgName, projectName, workspaceName } = await initSdk(
53
+ {
54
+ ignoreCache,
55
+ },
56
+ );
55
57
 
56
58
  //Input the mesh data from the input file
57
59
  let inputMeshData = await readFileContents(args.file, this, 'mesh');
@@ -112,7 +114,16 @@ class UpdateCommand extends Command {
112
114
 
113
115
  if (shouldContinue) {
114
116
  try {
115
- const response = await updateMesh(imsOrgId, projectId, workspaceId, meshId, data);
117
+ const response = await updateMesh(
118
+ imsOrgId,
119
+ projectId,
120
+ workspaceId,
121
+ workspaceName,
122
+ orgName,
123
+ projectName,
124
+ meshId,
125
+ data,
126
+ );
116
127
 
117
128
  this.log(
118
129
  '******************************************************************************************************',
@@ -325,7 +325,28 @@ const createMesh = async (
325
325
  }
326
326
  };
327
327
 
328
- const updateMesh = async (organizationId, projectId, workspaceId, meshId, data) => {
328
+ /**
329
+ * Update an API Mesh.
330
+ * @param {string} organizationId Organization identifier.
331
+ * @param {string} projectId Project identifier.
332
+ * @param {string} workspaceId Workspace identifier.
333
+ * @param {string} workspaceName Workspace Name.
334
+ * @param {string} orgName Organization name.
335
+ * @param {string} projectName Project name.
336
+ * @param {string} meshId Mesh identifier.
337
+ * @param {unknown} data Mesh configuration data.
338
+ * @returns {Promise<any>}
339
+ */
340
+ const updateMesh = async (
341
+ organizationId,
342
+ projectId,
343
+ workspaceId,
344
+ workspaceName,
345
+ orgName,
346
+ projectName,
347
+ meshId,
348
+ data,
349
+ ) => {
329
350
  const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
330
351
  const config = {
331
352
  method: 'put',
@@ -334,6 +355,9 @@ const updateMesh = async (organizationId, projectId, workspaceId, meshId, data)
334
355
  'Authorization': `Bearer ${accessToken}`,
335
356
  'Content-Type': 'application/json',
336
357
  'x-request-id': global.requestId,
358
+ 'workspaceName': workspaceName,
359
+ 'orgName': orgName,
360
+ 'projectName': projectName,
337
361
  },
338
362
  data: JSON.stringify(data),
339
363
  };
@@ -886,6 +910,64 @@ const getTenantFeatures = async organizationCode => {
886
910
  }
887
911
  };
888
912
 
913
+ /**
914
+ * Gets the deployments value for mesh.
915
+ *
916
+ * This request bypasses the Dev Console and is sent directly to the Schema Management Service.
917
+ * As a result, we provide the orgCode instead of orgId since Dev Console usually performs the translation.
918
+ * The near-term goal is to stop using Dev Console as a proxy for all routes.
919
+ * @param organizationCode
920
+ * @param projectId
921
+ * @param workspaceId
922
+ * @param meshId
923
+ * @returns {Promise<Object>}
924
+ */
925
+ const getMeshDeployments = async (organizationCode, projectId, workspaceId, meshId) => {
926
+ const { accessToken, apiKey } = await getDevConsoleConfig();
927
+ const config = {
928
+ method: 'get',
929
+ url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/deployments/latest?API_KEY=${apiKey}`,
930
+ headers: {
931
+ 'Authorization': `Bearer ${accessToken}`,
932
+ 'x-request-id': global.requestId,
933
+ },
934
+ };
935
+
936
+ logger.info(
937
+ 'Initiating GET %s',
938
+ `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/deployments/latest?API_KEY=${apiKey}`,
939
+ );
940
+
941
+ try {
942
+ const response = await axios(config);
943
+
944
+ logger.info('Response from GET %s', response.status);
945
+
946
+ if (response?.status === 200) {
947
+ logger.info(`Tenant mesh deployments : ${objToString(response, ['data'])}`);
948
+
949
+ return response.data;
950
+ } else {
951
+ let errorMessage = `Something went wrong: ${objToString(
952
+ response,
953
+ ['data'],
954
+ 'Unable to get mesh deployment.',
955
+ )}`;
956
+ logger.error(`${errorMessage}. Received ${response.status} response instead of 200`);
957
+
958
+ throw new Error(errorMessage);
959
+ }
960
+ } catch (error) {
961
+ logger.error(`Error fetching deployments for mesh: ${meshId}`);
962
+
963
+ return {
964
+ status: 'ERROR',
965
+ meshId: meshId,
966
+ error: 'Mesh status is not available.',
967
+ };
968
+ }
969
+ };
970
+
889
971
  module.exports = {
890
972
  getApiKeyCredential,
891
973
  describeMesh,
@@ -901,4 +983,5 @@ module.exports = {
901
983
  unsubscribeCredentialFromMeshService,
902
984
  getMeshArtifact,
903
985
  getTenantFeatures,
986
+ getMeshDeployments,
904
987
  };