@adobe/aio-cli-plugin-api-mesh 2.3.0 → 2.3.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.
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.3.
|
|
1
|
+
{"version":"2.3.1","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: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
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
importFiles,
|
|
23
23
|
} = require('../../../helpers');
|
|
24
24
|
const {
|
|
25
|
+
getMesh,
|
|
25
26
|
createMesh,
|
|
26
27
|
createAPIMeshCredentials,
|
|
27
28
|
subscribeCredentialToMeshService,
|
|
@@ -82,6 +83,12 @@ describe('create command tests', () => {
|
|
|
82
83
|
});
|
|
83
84
|
subscribeCredentialToMeshService.mockResolvedValue(['dummy_service']);
|
|
84
85
|
|
|
86
|
+
let fetchedMeshConfig = sampleCreateMeshConfig;
|
|
87
|
+
fetchedMeshConfig.meshId = 'dummy_id';
|
|
88
|
+
fetchedMeshConfig.meshURL = '';
|
|
89
|
+
|
|
90
|
+
getMesh.mockResolvedValue(fetchedMeshConfig);
|
|
91
|
+
|
|
85
92
|
parseSpy = jest.spyOn(CreateCommand.prototype, 'parse');
|
|
86
93
|
parseSpy.mockResolvedValue({
|
|
87
94
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -284,6 +291,113 @@ describe('create command tests', () => {
|
|
|
284
291
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
285
292
|
});
|
|
286
293
|
|
|
294
|
+
test('should create and return Ti mesh url if a valid mesh config file for TI client is provided', async () => {
|
|
295
|
+
let fetchedMeshConfig = sampleCreateMeshConfig;
|
|
296
|
+
fetchedMeshConfig.meshId = 'dummy_id';
|
|
297
|
+
fetchedMeshConfig.meshURL = 'https://tigraph.adobe.io';
|
|
298
|
+
getMesh.mockResolvedValue(fetchedMeshConfig);
|
|
299
|
+
|
|
300
|
+
const runResult = await CreateCommand.run();
|
|
301
|
+
|
|
302
|
+
expect(initRequestId).toHaveBeenCalled();
|
|
303
|
+
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
304
|
+
[
|
|
305
|
+
"1234",
|
|
306
|
+
"5678",
|
|
307
|
+
"123456789",
|
|
308
|
+
{
|
|
309
|
+
"meshConfig": {
|
|
310
|
+
"sources": [
|
|
311
|
+
{
|
|
312
|
+
"handler": {
|
|
313
|
+
"graphql": {
|
|
314
|
+
"endpoint": "<gql_endpoint>",
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
"name": "<api_name>",
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
]
|
|
323
|
+
`);
|
|
324
|
+
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
325
|
+
[
|
|
326
|
+
"1234",
|
|
327
|
+
"5678",
|
|
328
|
+
"123456789",
|
|
329
|
+
]
|
|
330
|
+
`);
|
|
331
|
+
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
332
|
+
[
|
|
333
|
+
"1234",
|
|
334
|
+
"5678",
|
|
335
|
+
"123456789",
|
|
336
|
+
"dummy_id",
|
|
337
|
+
]
|
|
338
|
+
`);
|
|
339
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
340
|
+
{
|
|
341
|
+
"adobeIdIntegrationsForWorkspace": {
|
|
342
|
+
"apiKey": "dummy_api_key",
|
|
343
|
+
"id": "dummy_id",
|
|
344
|
+
},
|
|
345
|
+
"mesh": {
|
|
346
|
+
"meshConfig": {
|
|
347
|
+
"sources": [
|
|
348
|
+
{
|
|
349
|
+
"handler": {
|
|
350
|
+
"graphql": {
|
|
351
|
+
"endpoint": "<gql_endpoint>",
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
"name": "<api_name>",
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
"meshId": "dummy_mesh_id",
|
|
359
|
+
},
|
|
360
|
+
"sdkList": [
|
|
361
|
+
"dummy_service",
|
|
362
|
+
],
|
|
363
|
+
}
|
|
364
|
+
`);
|
|
365
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
366
|
+
[
|
|
367
|
+
[
|
|
368
|
+
"******************************************************************************************************",
|
|
369
|
+
],
|
|
370
|
+
[
|
|
371
|
+
"Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s",
|
|
372
|
+
"dummy_mesh_id",
|
|
373
|
+
],
|
|
374
|
+
[
|
|
375
|
+
"To check the status of your mesh, run:",
|
|
376
|
+
],
|
|
377
|
+
[
|
|
378
|
+
"aio api-mesh:status",
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
"******************************************************************************************************",
|
|
382
|
+
],
|
|
383
|
+
[
|
|
384
|
+
"Successfully created API Key %s",
|
|
385
|
+
"dummy_api_key",
|
|
386
|
+
],
|
|
387
|
+
[
|
|
388
|
+
"Successfully subscribed API Key %s to API Mesh service",
|
|
389
|
+
"dummy_api_key",
|
|
390
|
+
],
|
|
391
|
+
[
|
|
392
|
+
"Mesh Endpoint: %s
|
|
393
|
+
",
|
|
394
|
+
"https://tigraph.adobe.io/dummy_mesh_id/graphql?api_key=dummy_api_key",
|
|
395
|
+
],
|
|
396
|
+
]
|
|
397
|
+
`);
|
|
398
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
399
|
+
});
|
|
400
|
+
|
|
287
401
|
test('should fail if mesh config file arg is missing', async () => {
|
|
288
402
|
parseSpy.mockResolvedValueOnce({
|
|
289
403
|
args: {},
|
|
@@ -28,7 +28,8 @@ jest.mock('../../../lib/devConsole');
|
|
|
28
28
|
|
|
29
29
|
const DescribeCommand = require('../describe');
|
|
30
30
|
const { initSdk, initRequestId } = require('../../../helpers');
|
|
31
|
-
const { describeMesh } = require('../../../lib/devConsole');
|
|
31
|
+
const { describeMesh, getMesh } = require('../../../lib/devConsole');
|
|
32
|
+
const sampleCreateMeshConfig = require('../../__fixtures__/sample_mesh.json');
|
|
32
33
|
|
|
33
34
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
34
35
|
const selectedProject = { id: '5678', title: 'Project01' };
|
|
@@ -64,6 +65,12 @@ describe('describe command tests', () => {
|
|
|
64
65
|
ignoreCache: mockIgnoreCacheFlag,
|
|
65
66
|
},
|
|
66
67
|
});
|
|
68
|
+
|
|
69
|
+
let fetchedMeshConfig = sampleCreateMeshConfig;
|
|
70
|
+
fetchedMeshConfig.meshId = 'dummy_id';
|
|
71
|
+
fetchedMeshConfig.meshURL = '';
|
|
72
|
+
|
|
73
|
+
getMesh.mockResolvedValue(fetchedMeshConfig);
|
|
67
74
|
});
|
|
68
75
|
|
|
69
76
|
afterEach(() => {
|
|
@@ -172,7 +179,7 @@ describe('describe command tests', () => {
|
|
|
172
179
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
173
180
|
});
|
|
174
181
|
|
|
175
|
-
test('should
|
|
182
|
+
test('should return Non TI url if request is Non Ti', async () => {
|
|
176
183
|
const runResult = await DescribeCommand.run();
|
|
177
184
|
|
|
178
185
|
expect(initRequestId).toHaveBeenCalled();
|
|
@@ -219,6 +226,61 @@ describe('describe command tests', () => {
|
|
|
219
226
|
"https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey",
|
|
220
227
|
],
|
|
221
228
|
]
|
|
229
|
+
`);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test('should return Ti URL if api return TI url', async () => {
|
|
233
|
+
let fetchedMeshConfig = sampleCreateMeshConfig;
|
|
234
|
+
fetchedMeshConfig.meshId = 'dummy_id';
|
|
235
|
+
fetchedMeshConfig.meshURL = 'https://tigraph.adobe.io';
|
|
236
|
+
|
|
237
|
+
getMesh.mockResolvedValue(fetchedMeshConfig);
|
|
238
|
+
const runResult = await DescribeCommand.run();
|
|
239
|
+
|
|
240
|
+
expect(initRequestId).toHaveBeenCalled();
|
|
241
|
+
expect(describeMesh).toHaveBeenCalledWith(
|
|
242
|
+
selectedOrg.id,
|
|
243
|
+
selectedProject.id,
|
|
244
|
+
selectedWorkspace.id,
|
|
245
|
+
);
|
|
246
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
247
|
+
{
|
|
248
|
+
"apiKey": "dummy_apiKey",
|
|
249
|
+
"meshId": "dummy_meshId",
|
|
250
|
+
}
|
|
251
|
+
`);
|
|
252
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
253
|
+
[
|
|
254
|
+
[
|
|
255
|
+
"Successfully retrieved mesh details
|
|
256
|
+
",
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
"Org ID: %s",
|
|
260
|
+
"1234",
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
"Project ID: %s",
|
|
264
|
+
"5678",
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
"Workspace ID: %s",
|
|
268
|
+
"123456789",
|
|
269
|
+
],
|
|
270
|
+
[
|
|
271
|
+
"Mesh ID: %s",
|
|
272
|
+
"dummy_meshId",
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
"API Key: %s",
|
|
276
|
+
"dummy_apiKey",
|
|
277
|
+
],
|
|
278
|
+
[
|
|
279
|
+
"Mesh Endpoint: %s
|
|
280
|
+
",
|
|
281
|
+
"https://tigraph.adobe.io/dummy_meshId/graphql?api_key=dummy_apiKey",
|
|
282
|
+
],
|
|
283
|
+
]
|
|
222
284
|
`);
|
|
223
285
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
224
286
|
});
|
|
@@ -25,6 +25,7 @@ const {
|
|
|
25
25
|
validateAndInterpolateMesh,
|
|
26
26
|
} = require('../../utils');
|
|
27
27
|
const {
|
|
28
|
+
getMesh,
|
|
28
29
|
createMesh,
|
|
29
30
|
createAPIMeshCredentials,
|
|
30
31
|
subscribeCredentialToMeshService,
|
|
@@ -150,9 +151,15 @@ class CreateCommand extends Command {
|
|
|
150
151
|
adobeIdIntegrationsForWorkspace.apiKey,
|
|
151
152
|
);
|
|
152
153
|
|
|
154
|
+
const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, mesh.meshId);
|
|
155
|
+
const meshUrl =
|
|
156
|
+
meshURL === '' || meshURL === undefined
|
|
157
|
+
? MULTITENANT_GRAPHQL_SERVER_BASE_URL
|
|
158
|
+
: meshURL;
|
|
159
|
+
|
|
153
160
|
this.log(
|
|
154
161
|
'Mesh Endpoint: %s\n',
|
|
155
|
-
`${
|
|
162
|
+
`${meshUrl}/${mesh.meshId}/graphql?api_key=${adobeIdIntegrationsForWorkspace.apiKey}`,
|
|
156
163
|
);
|
|
157
164
|
} else {
|
|
158
165
|
this.log(
|
|
@@ -15,7 +15,7 @@ const logger = require('../../classes/logger');
|
|
|
15
15
|
const { initSdk, initRequestId } = require('../../helpers');
|
|
16
16
|
const CONSTANTS = require('../../constants');
|
|
17
17
|
const { ignoreCacheFlag } = require('../../utils');
|
|
18
|
-
const { describeMesh } = require('../../lib/devConsole');
|
|
18
|
+
const { describeMesh, getMesh } = require('../../lib/devConsole');
|
|
19
19
|
|
|
20
20
|
require('dotenv').config();
|
|
21
21
|
|
|
@@ -52,12 +52,12 @@ class DescribeCommand extends Command {
|
|
|
52
52
|
this.log('Workspace ID: %s', workspaceId);
|
|
53
53
|
this.log('Mesh ID: %s', meshId);
|
|
54
54
|
|
|
55
|
+
const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
56
|
+
const meshUrl = meshURL === '' ? MULTITENANT_GRAPHQL_SERVER_BASE_URL : meshURL;
|
|
57
|
+
|
|
55
58
|
if (apiKey) {
|
|
56
59
|
this.log('API Key: %s', apiKey);
|
|
57
|
-
this.log(
|
|
58
|
-
'Mesh Endpoint: %s\n',
|
|
59
|
-
`${MULTITENANT_GRAPHQL_SERVER_BASE_URL}/${meshId}/graphql?api_key=${apiKey}`,
|
|
60
|
-
);
|
|
60
|
+
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${meshId}/graphql?api_key=${apiKey}`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return meshDetails;
|