@adobe/aio-cli-plugin-api-mesh 4.1.0 → 5.0.0-alpha
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.
- package/oclif.manifest.json +1 -1
- package/package.json +3 -7
- package/src/commands/api-mesh/__tests__/create.test.js +217 -293
- package/src/commands/api-mesh/__tests__/delete.test.js +6 -6
- package/src/commands/api-mesh/__tests__/describe.test.js +2 -17
- package/src/commands/api-mesh/__tests__/get.test.js +9 -78
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +1 -1
- package/src/commands/api-mesh/__tests__/run.test.js +22 -25
- package/src/commands/api-mesh/__tests__/status.test.js +1 -1
- package/src/commands/api-mesh/__tests__/update.test.js +8 -9
- package/src/commands/api-mesh/create.js +6 -9
- package/src/commands/api-mesh/delete.js +5 -5
- package/src/commands/api-mesh/describe.js +3 -3
- package/src/commands/api-mesh/get.js +8 -11
- package/src/commands/api-mesh/init.js +0 -2
- package/src/commands/api-mesh/log-get-bulk.js +2 -2
- package/src/commands/api-mesh/log-get.js +2 -2
- package/src/commands/api-mesh/log-list.js +1 -1
- package/src/commands/api-mesh/run.js +9 -35
- package/src/commands/api-mesh/source/install.js +3 -2
- package/src/commands/api-mesh/status.js +4 -6
- package/src/commands/api-mesh/update.js +7 -9
- package/src/constants.js +2 -0
- package/src/lib/devConsole.js +38 -32
- package/src/server.js +198 -36
- package/src/serverUtils.js +3 -3
- package/src/cors.js +0 -28
- package/src/fixPlugins.js +0 -28
- package/src/index.js +0 -44
- package/src/plugins/complianceHeaders/complianceHeaders.js +0 -55
- package/src/plugins/complianceHeaders/index.js +0 -2
- package/src/plugins/httpDetailsExtensions/LICENSE +0 -21
- package/src/plugins/httpDetailsExtensions/index.js +0 -81
- package/src/secrets.js +0 -34
- package/src/served.js +0 -22
- package/src/templates/wrangler.toml +0 -14
- package/src/utils/logger.js +0 -42
- package/src/utils/requestId.js +0 -26
- package/src/wranglerServer.js +0 -80
|
@@ -16,7 +16,6 @@ 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');
|
|
20
19
|
|
|
21
20
|
require('dotenv').config();
|
|
22
21
|
class GetCommand extends Command {
|
|
@@ -38,7 +37,7 @@ class GetCommand extends Command {
|
|
|
38
37
|
const ignoreCache = await flags.ignoreCache;
|
|
39
38
|
const json = await flags.json;
|
|
40
39
|
|
|
41
|
-
const {
|
|
40
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
42
41
|
ignoreCache,
|
|
43
42
|
verbose: !json,
|
|
44
43
|
});
|
|
@@ -46,22 +45,20 @@ class GetCommand extends Command {
|
|
|
46
45
|
let meshId = null;
|
|
47
46
|
|
|
48
47
|
try {
|
|
49
|
-
meshId = await getMeshId(
|
|
48
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
50
49
|
} catch (err) {
|
|
51
50
|
this.error(
|
|
52
|
-
`Unable to get mesh ID.
|
|
51
|
+
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
if (meshId) {
|
|
57
56
|
try {
|
|
58
|
-
const mesh = await getMesh(
|
|
57
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
|
|
59
58
|
|
|
60
59
|
if (mesh) {
|
|
61
60
|
this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
|
|
62
61
|
|
|
63
|
-
const meshUrl = buildMeshUrl(meshId, workspaceName);
|
|
64
|
-
|
|
65
62
|
if (args.file) {
|
|
66
63
|
try {
|
|
67
64
|
const { meshConfig } = mesh;
|
|
@@ -75,10 +72,10 @@ class GetCommand extends Command {
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
return
|
|
75
|
+
return mesh;
|
|
79
76
|
} else {
|
|
80
77
|
logger.error(
|
|
81
|
-
`Unable to get mesh with the ID ${meshId}.
|
|
78
|
+
`Unable to get mesh with the ID ${meshId}. Check the mesh ID and try again. RequestId: ${global.requestId}`,
|
|
82
79
|
{ exit: false },
|
|
83
80
|
);
|
|
84
81
|
}
|
|
@@ -86,12 +83,12 @@ class GetCommand extends Command {
|
|
|
86
83
|
this.log(error.message);
|
|
87
84
|
|
|
88
85
|
this.error(
|
|
89
|
-
`Unable to get mesh.
|
|
86
|
+
`Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
90
87
|
);
|
|
91
88
|
}
|
|
92
89
|
} else {
|
|
93
90
|
this.error(
|
|
94
|
-
`Unable to get mesh config. No mesh found for Org(${
|
|
91
|
+
`Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
95
92
|
{ exit: false },
|
|
96
93
|
);
|
|
97
94
|
}
|
|
@@ -108,7 +108,6 @@ class InitCommand extends Command {
|
|
|
108
108
|
const readmePath = `${getAppRootDir()}/src/templates/readme.md`;
|
|
109
109
|
const sampleMeshConfigPath = `${getAppRootDir()}/src/templates/mesh.json`;
|
|
110
110
|
const newRelicConfigPath = `${getAppRootDir()}/src/templates/newrelic.cjs`;
|
|
111
|
-
const wranglerTomlTemplate = `${getAppRootDir()}/src/templates/wrangler.toml`;
|
|
112
111
|
const shouldCreateWorkspace = await promptConfirm(
|
|
113
112
|
`Do you want to create the workspace in ${absolutePath}`,
|
|
114
113
|
);
|
|
@@ -181,7 +180,6 @@ class InitCommand extends Command {
|
|
|
181
180
|
await this.cloneFile(readmePath, `${absolutePath}/README.md`);
|
|
182
181
|
await this.cloneFile(sampleMeshConfigPath, `${absolutePath}/mesh.json`);
|
|
183
182
|
await this.cloneFile(newRelicConfigPath, `${absolutePath}/newrelic.cjs`);
|
|
184
|
-
await this.cloneFile(wranglerTomlTemplate, `${absolutePath}/wrangler.toml`);
|
|
185
183
|
|
|
186
184
|
this.log(`Installing dependencies`);
|
|
187
185
|
|
|
@@ -147,14 +147,14 @@ class GetBulkLogCommand extends Command {
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
logger.info('Calling initSdk...');
|
|
150
|
-
const {
|
|
150
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
151
151
|
ignoreCache,
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
// Retrieve meshId
|
|
155
155
|
let meshId = null;
|
|
156
156
|
try {
|
|
157
|
-
meshId = await getMeshId(
|
|
157
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
158
158
|
} catch (err) {
|
|
159
159
|
this.error(`Unable to get mesh ID: ${err.message}.`);
|
|
160
160
|
}
|
|
@@ -31,13 +31,13 @@ class FetchLogsCommand extends Command {
|
|
|
31
31
|
const ignoreCache = flags.ignoreCache;
|
|
32
32
|
const rayId = args.rayId;
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const { imsOrgCode, projectId, workspaceId } = await initSdk({
|
|
35
35
|
ignoreCache,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
let meshId = null;
|
|
39
39
|
try {
|
|
40
|
-
meshId = await getMeshId(
|
|
40
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, meshId);
|
|
41
41
|
if (!meshId) {
|
|
42
42
|
throw new Error('MeshIdNotFound');
|
|
43
43
|
}
|
|
@@ -43,7 +43,7 @@ class ListLogsCommand extends Command {
|
|
|
43
43
|
let meshId = null;
|
|
44
44
|
|
|
45
45
|
try {
|
|
46
|
-
meshId = await getMeshId(
|
|
46
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
47
47
|
} catch (err) {
|
|
48
48
|
this.error(
|
|
49
49
|
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -26,10 +26,12 @@ 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');
|
|
29
30
|
const path = require('path');
|
|
30
31
|
const {
|
|
31
32
|
initSdk,
|
|
32
33
|
initRequestId,
|
|
34
|
+
startGraphqlServer,
|
|
33
35
|
importFiles,
|
|
34
36
|
setUpTenantFiles,
|
|
35
37
|
writeSecretsFile,
|
|
@@ -37,8 +39,6 @@ const {
|
|
|
37
39
|
const logger = require('../../classes/logger');
|
|
38
40
|
const { getMeshId, getMeshArtifact } = require('../../lib/devConsole');
|
|
39
41
|
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 {
|
|
85
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({});
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
|
-
meshId = await getMeshId(
|
|
88
|
+
meshId = await getMeshId(imsOrgCode, 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(
|
|
96
|
+
await getMeshArtifact(imsOrgCode, 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,12 +163,13 @@ class RunCommand extends Command {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//Generating unique mesh id
|
|
166
|
-
meshId =
|
|
166
|
+
meshId = UUID.newUuid().toString();
|
|
167
167
|
|
|
168
168
|
await validateMesh(data.meshConfig);
|
|
169
169
|
await buildMesh(meshId, data.meshConfig);
|
|
170
170
|
await compileMesh(meshId);
|
|
171
171
|
}
|
|
172
|
+
|
|
172
173
|
let portNo;
|
|
173
174
|
//secrets management
|
|
174
175
|
if (secretsFilePath) {
|
|
@@ -182,8 +183,6 @@ class RunCommand extends Command {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
await this.copyMeshContent(meshId);
|
|
186
|
-
|
|
187
186
|
//To set the port number using the environment file
|
|
188
187
|
if (process.env.PORT !== undefined) {
|
|
189
188
|
if (isNaN(process.env.PORT) || !Number.isInteger(parseInt(process.env.PORT))) {
|
|
@@ -202,9 +201,9 @@ class RunCommand extends Command {
|
|
|
202
201
|
if (!portNo) {
|
|
203
202
|
portNo = 5000;
|
|
204
203
|
}
|
|
204
|
+
|
|
205
205
|
this.log(`Starting server on port : ${portNo}`);
|
|
206
|
-
await
|
|
207
|
-
this.log(`Server is running on http://localhost:${portNo}/graphql`);
|
|
206
|
+
await startGraphqlServer(meshId, portNo, flags.debug);
|
|
208
207
|
} else {
|
|
209
208
|
throw new Error(
|
|
210
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.',
|
|
@@ -214,31 +213,6 @@ class RunCommand extends Command {
|
|
|
214
213
|
this.error(error.message);
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
|
-
|
|
218
|
-
async copyMeshContent(meshId) {
|
|
219
|
-
// Remove mesh artifact directory if exists
|
|
220
|
-
if (fs.existsSync('.mesh')) {
|
|
221
|
-
fs.rmSync('.mesh', { recursive: true });
|
|
222
|
-
}
|
|
223
|
-
// Move built mesh artifact to expect directory
|
|
224
|
-
fs.renameSync(`mesh-artifact/${meshId}`, '.mesh');
|
|
225
|
-
// Remove tenant files directory if exists
|
|
226
|
-
if (fs.existsSync('tenantFiles')) {
|
|
227
|
-
fs.rmSync('tenantFiles', { recursive: true });
|
|
228
|
-
}
|
|
229
|
-
// Move built tenant files if exists
|
|
230
|
-
if (fs.existsSync('mesh-artifact/tenantFiles')) {
|
|
231
|
-
fs.cpSync('mesh-artifact/tenantFiles', '.mesh/tenantFiles', { recursive: true });
|
|
232
|
-
fs.renameSync('mesh-artifact/tenantFiles', 'tenantFiles');
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
await fixPlugins('.mesh/index.js');
|
|
236
|
-
|
|
237
|
-
if (fs.existsSync(`${__dirname}/../../../.mesh`)) {
|
|
238
|
-
fs.rmSync(`${__dirname}/../../../.mesh`, { recursive: true });
|
|
239
|
-
}
|
|
240
|
-
fs.cpSync('.mesh', `${__dirname}/../../../.mesh`, { recursive: true });
|
|
241
|
-
}
|
|
242
216
|
}
|
|
243
217
|
|
|
244
218
|
module.exports = RunCommand;
|
|
@@ -38,6 +38,7 @@ class InstallCommand extends Command {
|
|
|
38
38
|
const ignoreCache = await flags.ignoreCache;
|
|
39
39
|
const {
|
|
40
40
|
imsOrgId,
|
|
41
|
+
imsOrgCode,
|
|
41
42
|
projectId,
|
|
42
43
|
workspaceId,
|
|
43
44
|
organizationName,
|
|
@@ -126,7 +127,7 @@ class InstallCommand extends Command {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
try {
|
|
129
|
-
meshId = await getMeshId(
|
|
130
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
130
131
|
} catch (err) {
|
|
131
132
|
this.error(
|
|
132
133
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -140,7 +141,7 @@ class InstallCommand extends Command {
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
try {
|
|
143
|
-
const mesh = await getMesh(
|
|
144
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, meshId, workspaceName);
|
|
144
145
|
|
|
145
146
|
if (!mesh) {
|
|
146
147
|
this.error(
|
|
@@ -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 {
|
|
21
|
+
const { 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(
|
|
28
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
// API Request failed
|
|
31
31
|
this.log(err.message);
|
|
@@ -37,17 +37,15 @@ 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(${
|
|
40
|
+
`Unable to get mesh status. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
try {
|
|
45
|
-
const mesh = await getMesh(
|
|
45
|
+
const mesh = await getMesh(imsOrgCode, 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, '*'));
|
|
49
|
-
|
|
50
|
-
return mesh;
|
|
51
49
|
} catch (err) {
|
|
52
50
|
// Error occurred while fetching/displaying the mesh status
|
|
53
51
|
this.error(
|
|
@@ -73,10 +73,10 @@ class UpdateCommand extends Command {
|
|
|
73
73
|
let meshId = null;
|
|
74
74
|
|
|
75
75
|
try {
|
|
76
|
-
meshId = await getMeshId(
|
|
76
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId);
|
|
77
77
|
} catch (err) {
|
|
78
78
|
this.error(
|
|
79
|
-
`Unable to get mesh ID.
|
|
79
|
+
`Unable to get mesh ID. 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.
|
|
93
|
+
this.error('Input mesh file is not a valid JSON. Check the file provided.');
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -109,9 +109,7 @@ 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(
|
|
113
|
-
'Unable to import the files in the mesh config. Please check the file and try again.',
|
|
114
|
-
);
|
|
112
|
+
this.error('Unable to import the files in the mesh config. Check the file and try again.');
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
|
|
@@ -125,7 +123,7 @@ class UpdateCommand extends Command {
|
|
|
125
123
|
data.secrets = encryptedSecrets;
|
|
126
124
|
} catch (err) {
|
|
127
125
|
this.log(err.message);
|
|
128
|
-
this.error('Unable to import secrets.
|
|
126
|
+
this.error('Unable to import secrets. Check the file and try again.');
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
|
|
@@ -141,7 +139,7 @@ class UpdateCommand extends Command {
|
|
|
141
139
|
if (shouldContinue) {
|
|
142
140
|
try {
|
|
143
141
|
const response = await updateMesh(
|
|
144
|
-
|
|
142
|
+
imsOrgCode,
|
|
145
143
|
projectId,
|
|
146
144
|
workspaceId,
|
|
147
145
|
workspaceName,
|
|
@@ -169,7 +167,7 @@ class UpdateCommand extends Command {
|
|
|
169
167
|
this.log(error.message);
|
|
170
168
|
|
|
171
169
|
this.error(
|
|
172
|
-
`Unable to update the mesh.
|
|
170
|
+
`Unable to update the mesh. Check the mesh configuration file and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
173
171
|
);
|
|
174
172
|
}
|
|
175
173
|
} else {
|
package/src/constants.js
CHANGED
|
@@ -9,6 +9,7 @@ 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',
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const ProdConstants = {
|
|
@@ -19,6 +20,7 @@ const ProdConstants = {
|
|
|
19
20
|
SMS_BASE_URL: 'https://graph.adobe.io/api-admin',
|
|
20
21
|
MESH_BASE_URL: 'https://edge-graph.adobe.io/api',
|
|
21
22
|
MESH_SANDBOX_BASE_URL: 'https://edge-sandbox-graph.adobe.io/api',
|
|
23
|
+
SMS_API_KEY: 'adobe-graph-prod',
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const envConstants = clientEnv === 'stage' ? StageConstants : ProdConstants;
|
package/src/lib/devConsole.js
CHANGED
|
@@ -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 } = CONSTANTS;
|
|
15
|
+
const { DEV_CONSOLE_TRANSPORTER_API_KEY, SMS_BASE_URL, SMS_API_KEY } = 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
|
|
116
|
+
const { accessToken } = 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
|
-
'
|
|
124
|
+
'x-api-key': SMS_API_KEY,
|
|
125
125
|
},
|
|
126
126
|
};
|
|
127
127
|
|
|
@@ -142,20 +142,21 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId) => {
|
|
145
|
-
const {
|
|
145
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
146
146
|
const config = {
|
|
147
147
|
method: 'get',
|
|
148
|
-
url: `${
|
|
148
|
+
url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
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,
|
|
153
154
|
},
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
logger.info(
|
|
157
158
|
'Initiating GET %s',
|
|
158
|
-
`${
|
|
159
|
+
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
159
160
|
);
|
|
160
161
|
|
|
161
162
|
try {
|
|
@@ -232,10 +233,10 @@ const createMesh = async (
|
|
|
232
233
|
projectName,
|
|
233
234
|
data,
|
|
234
235
|
) => {
|
|
235
|
-
const {
|
|
236
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
236
237
|
const config = {
|
|
237
238
|
method: 'post',
|
|
238
|
-
url: `${
|
|
239
|
+
url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes`,
|
|
239
240
|
headers: {
|
|
240
241
|
'Authorization': `Bearer ${accessToken}`,
|
|
241
242
|
'Content-Type': 'application/json',
|
|
@@ -243,13 +244,14 @@ const createMesh = async (
|
|
|
243
244
|
'workspaceName': workspaceName,
|
|
244
245
|
'orgName': orgName,
|
|
245
246
|
'projectName': projectName,
|
|
247
|
+
'x-api-key': SMS_API_KEY,
|
|
246
248
|
},
|
|
247
249
|
data: JSON.stringify(data),
|
|
248
250
|
};
|
|
249
251
|
|
|
250
252
|
logger.info(
|
|
251
253
|
'Initiating POST %s',
|
|
252
|
-
`${
|
|
254
|
+
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes`,
|
|
253
255
|
);
|
|
254
256
|
|
|
255
257
|
try {
|
|
@@ -343,10 +345,10 @@ const updateMesh = async (
|
|
|
343
345
|
meshId,
|
|
344
346
|
data,
|
|
345
347
|
) => {
|
|
346
|
-
const {
|
|
348
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
347
349
|
const config = {
|
|
348
350
|
method: 'put',
|
|
349
|
-
url: `${
|
|
351
|
+
url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
350
352
|
headers: {
|
|
351
353
|
'Authorization': `Bearer ${accessToken}`,
|
|
352
354
|
'Content-Type': 'application/json',
|
|
@@ -354,13 +356,14 @@ const updateMesh = async (
|
|
|
354
356
|
'workspaceName': workspaceName,
|
|
355
357
|
'orgName': orgName,
|
|
356
358
|
'projectName': projectName,
|
|
359
|
+
'x-api-key': SMS_API_KEY,
|
|
357
360
|
},
|
|
358
361
|
data: JSON.stringify(data),
|
|
359
362
|
};
|
|
360
363
|
|
|
361
364
|
logger.info(
|
|
362
365
|
'Initiating PUT %s',
|
|
363
|
-
`${
|
|
366
|
+
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
364
367
|
);
|
|
365
368
|
|
|
366
369
|
try {
|
|
@@ -433,19 +436,20 @@ const updateMesh = async (
|
|
|
433
436
|
};
|
|
434
437
|
|
|
435
438
|
const deleteMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
436
|
-
const {
|
|
439
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
437
440
|
const config = {
|
|
438
441
|
method: 'delete',
|
|
439
|
-
url: `${
|
|
442
|
+
url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
440
443
|
headers: {
|
|
441
444
|
'Authorization': `Bearer ${accessToken}`,
|
|
442
445
|
'x-request-id': global.requestId,
|
|
446
|
+
'x-api-key': SMS_API_KEY,
|
|
443
447
|
},
|
|
444
448
|
};
|
|
445
449
|
|
|
446
450
|
logger.info(
|
|
447
451
|
'Initiating DELETE %s',
|
|
448
|
-
`${
|
|
452
|
+
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
449
453
|
);
|
|
450
454
|
|
|
451
455
|
try {
|
|
@@ -517,23 +521,24 @@ const deleteMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
|
517
521
|
}
|
|
518
522
|
};
|
|
519
523
|
|
|
520
|
-
const getMeshId = async (
|
|
521
|
-
const {
|
|
524
|
+
const getMeshId = async (organizationCode, projectId, workspaceId, workspaceName) => {
|
|
525
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
522
526
|
logger.info('Initiating Mesh ID request');
|
|
523
527
|
|
|
524
528
|
const config = {
|
|
525
529
|
method: 'get',
|
|
526
|
-
url: `${
|
|
530
|
+
url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/mesh`,
|
|
527
531
|
headers: {
|
|
528
532
|
'Authorization': `Bearer ${accessToken}`,
|
|
529
533
|
'x-request-id': global.requestId,
|
|
530
534
|
'workspaceName': workspaceName,
|
|
535
|
+
'x-api-key': SMS_API_KEY,
|
|
531
536
|
},
|
|
532
537
|
};
|
|
533
538
|
|
|
534
539
|
logger.info(
|
|
535
540
|
'Initiating GET %s',
|
|
536
|
-
`${
|
|
541
|
+
`${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/mesh`,
|
|
537
542
|
);
|
|
538
543
|
|
|
539
544
|
try {
|
|
@@ -805,21 +810,22 @@ const unsubscribeCredentialFromMeshService = async (
|
|
|
805
810
|
};
|
|
806
811
|
|
|
807
812
|
const getMeshArtifact = async (organizationId, projectId, workspaceId, workspaceName, meshId) => {
|
|
808
|
-
const {
|
|
813
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
809
814
|
const config = {
|
|
810
815
|
method: 'get',
|
|
811
|
-
url: `${
|
|
816
|
+
url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact`,
|
|
812
817
|
headers: {
|
|
813
818
|
'Authorization': `Bearer ${accessToken}`,
|
|
814
819
|
'x-request-id': global.requestId,
|
|
815
820
|
'workspaceName': workspaceName,
|
|
821
|
+
'x-api-key': SMS_API_KEY,
|
|
816
822
|
},
|
|
817
823
|
responseType: 'arraybuffer',
|
|
818
824
|
};
|
|
819
825
|
|
|
820
826
|
logger.info(
|
|
821
827
|
'Initiating GET %s',
|
|
822
|
-
`${
|
|
828
|
+
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/artifact`,
|
|
823
829
|
);
|
|
824
830
|
|
|
825
831
|
try {
|
|
@@ -862,14 +868,14 @@ const getMeshArtifact = async (organizationId, projectId, workspaceId, workspace
|
|
|
862
868
|
* @returns {Promise<Object>}
|
|
863
869
|
*/
|
|
864
870
|
const getTenantFeatures = async organizationCode => {
|
|
865
|
-
const { accessToken
|
|
871
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
866
872
|
const config = {
|
|
867
873
|
method: 'get',
|
|
868
874
|
url: `${SMS_BASE_URL}/organizations/${organizationCode}/features`,
|
|
869
875
|
headers: {
|
|
870
876
|
'Authorization': `Bearer ${accessToken}`,
|
|
871
877
|
'x-request-id': global.requestId,
|
|
872
|
-
'
|
|
878
|
+
'x-api-key': SMS_API_KEY,
|
|
873
879
|
},
|
|
874
880
|
};
|
|
875
881
|
|
|
@@ -917,14 +923,14 @@ const getTenantFeatures = async organizationCode => {
|
|
|
917
923
|
* @returns {Promise<Object>}
|
|
918
924
|
*/
|
|
919
925
|
const getMeshDeployments = async (organizationCode, projectId, workspaceId, meshId) => {
|
|
920
|
-
const { accessToken
|
|
926
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
921
927
|
const config = {
|
|
922
928
|
method: 'get',
|
|
923
929
|
url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/deployments/latest`,
|
|
924
930
|
headers: {
|
|
925
931
|
'Authorization': `Bearer ${accessToken}`,
|
|
926
932
|
'x-request-id': global.requestId,
|
|
927
|
-
'
|
|
933
|
+
'x-api-key': SMS_API_KEY,
|
|
928
934
|
},
|
|
929
935
|
};
|
|
930
936
|
|
|
@@ -973,14 +979,14 @@ const getMeshDeployments = async (organizationCode, projectId, workspaceId, mesh
|
|
|
973
979
|
* @returns string
|
|
974
980
|
*/
|
|
975
981
|
const getPublicEncryptionKey = async organizationCode => {
|
|
976
|
-
const { accessToken
|
|
982
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
977
983
|
const config = {
|
|
978
984
|
method: 'get',
|
|
979
985
|
url: `${SMS_BASE_URL}/organizations/${organizationCode}/getPublicKey`,
|
|
980
986
|
headers: {
|
|
981
987
|
'Authorization': `Bearer ${accessToken}`,
|
|
982
988
|
'x-request-id': global.requestId,
|
|
983
|
-
'
|
|
989
|
+
'x-api-key': SMS_API_KEY,
|
|
984
990
|
},
|
|
985
991
|
};
|
|
986
992
|
logger.info(
|
|
@@ -1018,14 +1024,14 @@ const getPresignedUrls = async (
|
|
|
1018
1024
|
startTime,
|
|
1019
1025
|
endTime,
|
|
1020
1026
|
) => {
|
|
1021
|
-
const { accessToken
|
|
1027
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
1022
1028
|
const config = {
|
|
1023
1029
|
method: 'get',
|
|
1024
1030
|
url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/logs?startDateTime=${startTime}&endDateTime=${endTime}`,
|
|
1025
1031
|
headers: {
|
|
1026
1032
|
'Authorization': `Bearer ${accessToken}`,
|
|
1027
1033
|
'x-request-id': global.requestId,
|
|
1028
|
-
'
|
|
1034
|
+
'x-api-key': SMS_API_KEY,
|
|
1029
1035
|
},
|
|
1030
1036
|
};
|
|
1031
1037
|
|
|
@@ -1057,14 +1063,14 @@ const getPresignedUrls = async (
|
|
|
1057
1063
|
};
|
|
1058
1064
|
|
|
1059
1065
|
const getLogsByRayId = async (organizationCode, projectId, workspaceId, meshId, rayId) => {
|
|
1060
|
-
const { accessToken
|
|
1066
|
+
const { accessToken } = await getDevConsoleConfig();
|
|
1061
1067
|
const config = {
|
|
1062
1068
|
method: 'get',
|
|
1063
1069
|
url: `${SMS_BASE_URL}/organizations/${organizationCode}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}/logs/${rayId}`,
|
|
1064
1070
|
headers: {
|
|
1065
1071
|
'Authorization': `Bearer ${accessToken}`,
|
|
1066
1072
|
'x-request-id': global.requestId,
|
|
1067
|
-
'
|
|
1073
|
+
'x-api-key': SMS_API_KEY,
|
|
1068
1074
|
},
|
|
1069
1075
|
};
|
|
1070
1076
|
|