@adobe/aio-cli-plugin-api-mesh 2.3.3 → 3.0.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 +1 -1
- package/package.json +1 -1
- package/src/commands/api-mesh/__tests__/create.test.js +72 -167
- package/src/commands/api-mesh/__tests__/describe.test.js +9 -9
- package/src/commands/api-mesh/__tests__/get.test.js +1 -0
- package/src/commands/api-mesh/create.js +28 -47
- package/src/commands/api-mesh/describe.js +15 -14
- package/src/commands/api-mesh/get.js +3 -3
- package/src/commands/api-mesh/source/__tests__/install.test.js +2 -0
- package/src/commands/api-mesh/source/install.js +4 -4
- package/src/commands/api-mesh/status.js +3 -3
- package/src/constants.js +2 -6
- package/src/helpers.js +1 -0
- package/src/lib/devConsole.js +45 -6
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"3.0.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
|
@@ -67,6 +67,7 @@ describe('create command tests', () => {
|
|
|
67
67
|
imsOrgId: selectedOrg.id,
|
|
68
68
|
projectId: selectedProject.id,
|
|
69
69
|
workspaceId: selectedWorkspace.id,
|
|
70
|
+
workspaceName: selectedWorkspace.title,
|
|
70
71
|
});
|
|
71
72
|
|
|
72
73
|
global.requestId = 'dummy_request_id';
|
|
@@ -75,9 +76,14 @@ describe('create command tests', () => {
|
|
|
75
76
|
errorLogSpy = jest.spyOn(CreateCommand.prototype, 'error');
|
|
76
77
|
|
|
77
78
|
createMesh.mockResolvedValue({
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
mesh: {
|
|
80
|
+
meshId: 'dummy_mesh_id',
|
|
81
|
+
meshConfig: sampleCreateMeshConfig.meshConfig,
|
|
82
|
+
},
|
|
83
|
+
apiKey: 'dummy_api_key',
|
|
84
|
+
sdkList: ['dummy_service'],
|
|
80
85
|
});
|
|
86
|
+
|
|
81
87
|
createAPIMeshCredentials.mockResolvedValue({
|
|
82
88
|
apiKey: 'dummy_api_key',
|
|
83
89
|
id: 'dummy_id',
|
|
@@ -109,11 +115,11 @@ describe('create command tests', () => {
|
|
|
109
115
|
});
|
|
110
116
|
const output = await CreateCommand.run();
|
|
111
117
|
expect(output).toHaveProperty('mesh');
|
|
112
|
-
expect(output).toHaveProperty('
|
|
118
|
+
expect(output).toHaveProperty('apiKey');
|
|
119
|
+
expect(output).toHaveProperty('sdkList');
|
|
113
120
|
expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' }));
|
|
114
|
-
expect(output.
|
|
115
|
-
|
|
116
|
-
);
|
|
121
|
+
expect(output.apiKey).toEqual('dummy_api_key');
|
|
122
|
+
expect(output.sdkList).toEqual(['dummy_service']);
|
|
117
123
|
});
|
|
118
124
|
|
|
119
125
|
test('snapshot create command description', () => {
|
|
@@ -169,8 +175,12 @@ describe('create command tests', () => {
|
|
|
169
175
|
|
|
170
176
|
test('should pass if a valid mesh config file with composer files are provided', async () => {
|
|
171
177
|
createMesh.mockResolvedValueOnce({
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
mesh: {
|
|
179
|
+
meshId: 'dummy_mesh_id',
|
|
180
|
+
meshConfig: meshConfigWithComposerFiles.meshConfig,
|
|
181
|
+
},
|
|
182
|
+
apiKey: 'dummy_api_key',
|
|
183
|
+
sdkList: ['dummy_service'],
|
|
174
184
|
});
|
|
175
185
|
|
|
176
186
|
parseSpy.mockResolvedValueOnce({
|
|
@@ -184,10 +194,7 @@ describe('create command tests', () => {
|
|
|
184
194
|
|
|
185
195
|
expect(output).toMatchInlineSnapshot(`
|
|
186
196
|
{
|
|
187
|
-
"
|
|
188
|
-
"apiKey": "dummy_api_key",
|
|
189
|
-
"id": "dummy_id",
|
|
190
|
-
},
|
|
197
|
+
"apiKey": "dummy_api_key",
|
|
191
198
|
"mesh": {
|
|
192
199
|
"meshConfig": {
|
|
193
200
|
"files": [
|
|
@@ -272,6 +279,7 @@ describe('create command tests', () => {
|
|
|
272
279
|
"1234",
|
|
273
280
|
"5678",
|
|
274
281
|
"123456789",
|
|
282
|
+
"Workspace01",
|
|
275
283
|
{
|
|
276
284
|
"meshConfig": {
|
|
277
285
|
"sources": [
|
|
@@ -287,28 +295,10 @@ describe('create command tests', () => {
|
|
|
287
295
|
},
|
|
288
296
|
},
|
|
289
297
|
]
|
|
290
|
-
`);
|
|
291
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
292
|
-
[
|
|
293
|
-
"1234",
|
|
294
|
-
"5678",
|
|
295
|
-
"123456789",
|
|
296
|
-
]
|
|
297
|
-
`);
|
|
298
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
299
|
-
[
|
|
300
|
-
"1234",
|
|
301
|
-
"5678",
|
|
302
|
-
"123456789",
|
|
303
|
-
"dummy_id",
|
|
304
|
-
]
|
|
305
298
|
`);
|
|
306
299
|
expect(runResult).toMatchInlineSnapshot(`
|
|
307
300
|
{
|
|
308
|
-
"
|
|
309
|
-
"apiKey": "dummy_api_key",
|
|
310
|
-
"id": "dummy_id",
|
|
311
|
-
},
|
|
301
|
+
"apiKey": "dummy_api_key",
|
|
312
302
|
"mesh": {
|
|
313
303
|
"meshConfig": {
|
|
314
304
|
"sources": [
|
|
@@ -379,6 +369,7 @@ describe('create command tests', () => {
|
|
|
379
369
|
"1234",
|
|
380
370
|
"5678",
|
|
381
371
|
"123456789",
|
|
372
|
+
"Workspace01",
|
|
382
373
|
{
|
|
383
374
|
"meshConfig": {
|
|
384
375
|
"sources": [
|
|
@@ -395,27 +386,10 @@ describe('create command tests', () => {
|
|
|
395
386
|
},
|
|
396
387
|
]
|
|
397
388
|
`);
|
|
398
|
-
|
|
399
|
-
[
|
|
400
|
-
"1234",
|
|
401
|
-
"5678",
|
|
402
|
-
"123456789",
|
|
403
|
-
]
|
|
404
|
-
`);
|
|
405
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
406
|
-
[
|
|
407
|
-
"1234",
|
|
408
|
-
"5678",
|
|
409
|
-
"123456789",
|
|
410
|
-
"dummy_id",
|
|
411
|
-
]
|
|
412
|
-
`);
|
|
389
|
+
|
|
413
390
|
expect(runResult).toMatchInlineSnapshot(`
|
|
414
391
|
{
|
|
415
|
-
"
|
|
416
|
-
"apiKey": "dummy_api_key",
|
|
417
|
-
"id": "dummy_id",
|
|
418
|
-
},
|
|
392
|
+
"apiKey": "dummy_api_key",
|
|
419
393
|
"mesh": {
|
|
420
394
|
"meshConfig": {
|
|
421
395
|
"sources": [
|
|
@@ -465,7 +439,7 @@ describe('create command tests', () => {
|
|
|
465
439
|
[
|
|
466
440
|
"Mesh Endpoint: %s
|
|
467
441
|
",
|
|
468
|
-
"https://tigraph.adobe.io/dummy_mesh_id/graphql
|
|
442
|
+
"https://tigraph.adobe.io/dummy_mesh_id/graphql",
|
|
469
443
|
],
|
|
470
444
|
]
|
|
471
445
|
`);
|
|
@@ -521,7 +495,7 @@ describe('create command tests', () => {
|
|
|
521
495
|
`);
|
|
522
496
|
});
|
|
523
497
|
|
|
524
|
-
test('should fail if create api credential api has failed', async () => {
|
|
498
|
+
test.skip('should fail if create api credential api has failed', async () => {
|
|
525
499
|
createAPIMeshCredentials.mockRejectedValue(new Error('create api credential api failed'));
|
|
526
500
|
|
|
527
501
|
const runResult = CreateCommand.run();
|
|
@@ -563,7 +537,7 @@ describe('create command tests', () => {
|
|
|
563
537
|
`);
|
|
564
538
|
});
|
|
565
539
|
|
|
566
|
-
test('should fail if subscribe credential to mesh service api has failed', async () => {
|
|
540
|
+
test.skip('should fail if subscribe credential to mesh service api has failed', async () => {
|
|
567
541
|
subscribeCredentialToMeshService.mockRejectedValueOnce(
|
|
568
542
|
new Error('subscribe credential to mesh service api failed'),
|
|
569
543
|
);
|
|
@@ -692,11 +666,11 @@ describe('create command tests', () => {
|
|
|
692
666
|
});
|
|
693
667
|
const output = await CreateCommand.run();
|
|
694
668
|
expect(output).toHaveProperty('mesh');
|
|
695
|
-
expect(output).toHaveProperty('
|
|
669
|
+
expect(output).toHaveProperty('apiKey');
|
|
670
|
+
expect(output).toHaveProperty('sdkList');
|
|
696
671
|
expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' }));
|
|
697
|
-
expect(output.
|
|
698
|
-
|
|
699
|
-
);
|
|
672
|
+
expect(output.apiKey).toEqual('dummy_api_key');
|
|
673
|
+
expect(output.sdkList).toEqual(['dummy_service']);
|
|
700
674
|
});
|
|
701
675
|
|
|
702
676
|
test('should return error if the mesh has placeholders and env file provided using --env flag is not found', async () => {
|
|
@@ -851,10 +825,7 @@ describe('create command tests', () => {
|
|
|
851
825
|
expect(promptConfirm).toHaveBeenCalledWith('Are you sure you want to create a mesh?');
|
|
852
826
|
expect(runResult).toMatchInlineSnapshot(`
|
|
853
827
|
{
|
|
854
|
-
"
|
|
855
|
-
"apiKey": "dummy_api_key",
|
|
856
|
-
"id": "dummy_id",
|
|
857
|
-
},
|
|
828
|
+
"apiKey": "dummy_api_key",
|
|
858
829
|
"mesh": {
|
|
859
830
|
"meshConfig": {
|
|
860
831
|
"sources": [
|
|
@@ -930,8 +901,12 @@ describe('create command tests', () => {
|
|
|
930
901
|
};
|
|
931
902
|
|
|
932
903
|
createMesh.mockResolvedValueOnce({
|
|
933
|
-
|
|
934
|
-
|
|
904
|
+
mesh: {
|
|
905
|
+
meshId: 'dummy_mesh_id',
|
|
906
|
+
meshConfig: meshConfig,
|
|
907
|
+
},
|
|
908
|
+
apiKey: 'dummy_api_key',
|
|
909
|
+
sdkList: ['dummy_service'],
|
|
935
910
|
});
|
|
936
911
|
|
|
937
912
|
parseSpy.mockResolvedValueOnce({
|
|
@@ -953,6 +928,7 @@ describe('create command tests', () => {
|
|
|
953
928
|
"1234",
|
|
954
929
|
"5678",
|
|
955
930
|
"123456789",
|
|
931
|
+
"Workspace01",
|
|
956
932
|
{
|
|
957
933
|
"meshConfig": {
|
|
958
934
|
"files": [
|
|
@@ -984,28 +960,10 @@ describe('create command tests', () => {
|
|
|
984
960
|
},
|
|
985
961
|
]
|
|
986
962
|
`);
|
|
987
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
988
|
-
[
|
|
989
|
-
"1234",
|
|
990
|
-
"5678",
|
|
991
|
-
"123456789",
|
|
992
|
-
]
|
|
993
|
-
`);
|
|
994
963
|
|
|
995
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
996
|
-
[
|
|
997
|
-
"1234",
|
|
998
|
-
"5678",
|
|
999
|
-
"123456789",
|
|
1000
|
-
"dummy_id",
|
|
1001
|
-
]
|
|
1002
|
-
`);
|
|
1003
964
|
expect(output).toMatchInlineSnapshot(`
|
|
1004
965
|
{
|
|
1005
|
-
"
|
|
1006
|
-
"apiKey": "dummy_api_key",
|
|
1007
|
-
"id": "dummy_id",
|
|
1008
|
-
},
|
|
966
|
+
"apiKey": "dummy_api_key",
|
|
1009
967
|
"mesh": {
|
|
1010
968
|
"meshConfig": {
|
|
1011
969
|
"files": [
|
|
@@ -1209,8 +1167,12 @@ describe('create command tests', () => {
|
|
|
1209
1167
|
importFiles.mockResolvedValueOnce(meshConfig);
|
|
1210
1168
|
|
|
1211
1169
|
createMesh.mockResolvedValueOnce({
|
|
1212
|
-
|
|
1213
|
-
|
|
1170
|
+
mesh: {
|
|
1171
|
+
meshId: 'dummy_mesh_id',
|
|
1172
|
+
meshConfig: meshConfig,
|
|
1173
|
+
},
|
|
1174
|
+
apiKey: 'dummy_api_key',
|
|
1175
|
+
sdkList: ['dummy_service'],
|
|
1214
1176
|
});
|
|
1215
1177
|
|
|
1216
1178
|
parseSpy.mockResolvedValueOnce({
|
|
@@ -1228,6 +1190,7 @@ describe('create command tests', () => {
|
|
|
1228
1190
|
"1234",
|
|
1229
1191
|
"5678",
|
|
1230
1192
|
"123456789",
|
|
1193
|
+
"Workspace01",
|
|
1231
1194
|
{
|
|
1232
1195
|
"files": [
|
|
1233
1196
|
{
|
|
@@ -1256,28 +1219,10 @@ describe('create command tests', () => {
|
|
|
1256
1219
|
],
|
|
1257
1220
|
},
|
|
1258
1221
|
]
|
|
1259
|
-
`);
|
|
1260
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1261
|
-
[
|
|
1262
|
-
"1234",
|
|
1263
|
-
"5678",
|
|
1264
|
-
"123456789",
|
|
1265
|
-
]
|
|
1266
|
-
`);
|
|
1267
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1268
|
-
[
|
|
1269
|
-
"1234",
|
|
1270
|
-
"5678",
|
|
1271
|
-
"123456789",
|
|
1272
|
-
"dummy_id",
|
|
1273
|
-
]
|
|
1274
1222
|
`);
|
|
1275
1223
|
expect(output).toMatchInlineSnapshot(`
|
|
1276
1224
|
{
|
|
1277
|
-
"
|
|
1278
|
-
"apiKey": "dummy_api_key",
|
|
1279
|
-
"id": "dummy_id",
|
|
1280
|
-
},
|
|
1225
|
+
"apiKey": "dummy_api_key",
|
|
1281
1226
|
"mesh": {
|
|
1282
1227
|
"meshConfig": {
|
|
1283
1228
|
"files": [
|
|
@@ -1358,8 +1303,12 @@ describe('create command tests', () => {
|
|
|
1358
1303
|
});
|
|
1359
1304
|
|
|
1360
1305
|
createMesh.mockResolvedValueOnce({
|
|
1361
|
-
|
|
1362
|
-
|
|
1306
|
+
mesh: {
|
|
1307
|
+
meshId: 'dummy_mesh_id',
|
|
1308
|
+
meshConfig: meshConfig,
|
|
1309
|
+
},
|
|
1310
|
+
apiKey: 'dummy_api_key',
|
|
1311
|
+
sdkList: ['dummy_service'],
|
|
1363
1312
|
});
|
|
1364
1313
|
|
|
1365
1314
|
const output = await CreateCommand.run();
|
|
@@ -1370,6 +1319,7 @@ describe('create command tests', () => {
|
|
|
1370
1319
|
"1234",
|
|
1371
1320
|
"5678",
|
|
1372
1321
|
"123456789",
|
|
1322
|
+
"Workspace01",
|
|
1373
1323
|
{
|
|
1374
1324
|
"meshConfig": {
|
|
1375
1325
|
"files": [
|
|
@@ -1401,28 +1351,10 @@ describe('create command tests', () => {
|
|
|
1401
1351
|
},
|
|
1402
1352
|
]
|
|
1403
1353
|
`);
|
|
1404
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1405
|
-
[
|
|
1406
|
-
"1234",
|
|
1407
|
-
"5678",
|
|
1408
|
-
"123456789",
|
|
1409
|
-
]
|
|
1410
|
-
`);
|
|
1411
1354
|
|
|
1412
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1413
|
-
[
|
|
1414
|
-
"1234",
|
|
1415
|
-
"5678",
|
|
1416
|
-
"123456789",
|
|
1417
|
-
"dummy_id",
|
|
1418
|
-
]
|
|
1419
|
-
`);
|
|
1420
1355
|
expect(output).toMatchInlineSnapshot(`
|
|
1421
1356
|
{
|
|
1422
|
-
"
|
|
1423
|
-
"apiKey": "dummy_api_key",
|
|
1424
|
-
"id": "dummy_id",
|
|
1425
|
-
},
|
|
1357
|
+
"apiKey": "dummy_api_key",
|
|
1426
1358
|
"mesh": {
|
|
1427
1359
|
"meshConfig": {
|
|
1428
1360
|
"files": [
|
|
@@ -1503,8 +1435,12 @@ describe('create command tests', () => {
|
|
|
1503
1435
|
});
|
|
1504
1436
|
|
|
1505
1437
|
createMesh.mockResolvedValueOnce({
|
|
1506
|
-
|
|
1507
|
-
|
|
1438
|
+
mesh: {
|
|
1439
|
+
meshId: 'dummy_mesh_id',
|
|
1440
|
+
meshConfig: meshConfig,
|
|
1441
|
+
},
|
|
1442
|
+
apiKey: 'dummy_api_key',
|
|
1443
|
+
sdkList: ['dummy_service'],
|
|
1508
1444
|
});
|
|
1509
1445
|
|
|
1510
1446
|
const output = await CreateCommand.run();
|
|
@@ -1515,6 +1451,7 @@ describe('create command tests', () => {
|
|
|
1515
1451
|
"1234",
|
|
1516
1452
|
"5678",
|
|
1517
1453
|
"123456789",
|
|
1454
|
+
"Workspace01",
|
|
1518
1455
|
{
|
|
1519
1456
|
"meshConfig": {
|
|
1520
1457
|
"files": [
|
|
@@ -1545,28 +1482,10 @@ describe('create command tests', () => {
|
|
|
1545
1482
|
},
|
|
1546
1483
|
},
|
|
1547
1484
|
]
|
|
1548
|
-
`);
|
|
1549
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1550
|
-
[
|
|
1551
|
-
"1234",
|
|
1552
|
-
"5678",
|
|
1553
|
-
"123456789",
|
|
1554
|
-
]
|
|
1555
|
-
`);
|
|
1556
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1557
|
-
[
|
|
1558
|
-
"1234",
|
|
1559
|
-
"5678",
|
|
1560
|
-
"123456789",
|
|
1561
|
-
"dummy_id",
|
|
1562
|
-
]
|
|
1563
1485
|
`);
|
|
1564
1486
|
expect(output).toMatchInlineSnapshot(`
|
|
1565
1487
|
{
|
|
1566
|
-
"
|
|
1567
|
-
"apiKey": "dummy_api_key",
|
|
1568
|
-
"id": "dummy_id",
|
|
1569
|
-
},
|
|
1488
|
+
"apiKey": "dummy_api_key",
|
|
1570
1489
|
"mesh": {
|
|
1571
1490
|
"meshConfig": {
|
|
1572
1491
|
"files": [
|
|
@@ -1634,8 +1553,12 @@ describe('create command tests', () => {
|
|
|
1634
1553
|
};
|
|
1635
1554
|
|
|
1636
1555
|
createMesh.mockResolvedValueOnce({
|
|
1637
|
-
|
|
1638
|
-
|
|
1556
|
+
mesh: {
|
|
1557
|
+
meshId: 'dummy_mesh_id',
|
|
1558
|
+
meshConfig: meshConfig,
|
|
1559
|
+
},
|
|
1560
|
+
apiKey: 'dummy_api_key',
|
|
1561
|
+
sdkList: ['dummy_service'],
|
|
1639
1562
|
});
|
|
1640
1563
|
|
|
1641
1564
|
parseSpy.mockResolvedValueOnce({
|
|
@@ -1657,6 +1580,7 @@ describe('create command tests', () => {
|
|
|
1657
1580
|
"1234",
|
|
1658
1581
|
"5678",
|
|
1659
1582
|
"123456789",
|
|
1583
|
+
"Workspace01",
|
|
1660
1584
|
{
|
|
1661
1585
|
"meshConfig": {
|
|
1662
1586
|
"files": [
|
|
@@ -1688,28 +1612,9 @@ describe('create command tests', () => {
|
|
|
1688
1612
|
},
|
|
1689
1613
|
]
|
|
1690
1614
|
`);
|
|
1691
|
-
expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1692
|
-
[
|
|
1693
|
-
"1234",
|
|
1694
|
-
"5678",
|
|
1695
|
-
"123456789",
|
|
1696
|
-
]
|
|
1697
|
-
`);
|
|
1698
|
-
|
|
1699
|
-
expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1700
|
-
[
|
|
1701
|
-
"1234",
|
|
1702
|
-
"5678",
|
|
1703
|
-
"123456789",
|
|
1704
|
-
"dummy_id",
|
|
1705
|
-
]
|
|
1706
|
-
`);
|
|
1707
1615
|
expect(output).toMatchInlineSnapshot(`
|
|
1708
1616
|
{
|
|
1709
|
-
"
|
|
1710
|
-
"apiKey": "dummy_api_key",
|
|
1711
|
-
"id": "dummy_id",
|
|
1712
|
-
},
|
|
1617
|
+
"apiKey": "dummy_api_key",
|
|
1713
1618
|
"mesh": {
|
|
1714
1619
|
"meshConfig": {
|
|
1715
1620
|
"files": [
|
|
@@ -52,6 +52,7 @@ describe('describe command tests', () => {
|
|
|
52
52
|
imsOrgId: selectedOrg.id,
|
|
53
53
|
projectId: selectedProject.id,
|
|
54
54
|
workspaceId: selectedWorkspace.id,
|
|
55
|
+
workspaceName: selectedWorkspace.title,
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
global.requestId = 'dummy_request_id';
|
|
@@ -174,6 +175,11 @@ describe('describe command tests', () => {
|
|
|
174
175
|
"Mesh ID: %s",
|
|
175
176
|
"dummy_meshId",
|
|
176
177
|
],
|
|
178
|
+
[
|
|
179
|
+
"Mesh Endpoint: %s
|
|
180
|
+
",
|
|
181
|
+
"https://graph.adobe.io/api/dummy_meshId/graphql",
|
|
182
|
+
],
|
|
177
183
|
]
|
|
178
184
|
`);
|
|
179
185
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
@@ -187,6 +193,7 @@ describe('describe command tests', () => {
|
|
|
187
193
|
selectedOrg.id,
|
|
188
194
|
selectedProject.id,
|
|
189
195
|
selectedWorkspace.id,
|
|
196
|
+
selectedWorkspace.title,
|
|
190
197
|
);
|
|
191
198
|
expect(runResult).toMatchInlineSnapshot(`
|
|
192
199
|
{
|
|
@@ -216,10 +223,6 @@ describe('describe command tests', () => {
|
|
|
216
223
|
"Mesh ID: %s",
|
|
217
224
|
"dummy_meshId",
|
|
218
225
|
],
|
|
219
|
-
[
|
|
220
|
-
"API Key: %s",
|
|
221
|
-
"dummy_apiKey",
|
|
222
|
-
],
|
|
223
226
|
[
|
|
224
227
|
"Mesh Endpoint: %s
|
|
225
228
|
",
|
|
@@ -242,6 +245,7 @@ describe('describe command tests', () => {
|
|
|
242
245
|
selectedOrg.id,
|
|
243
246
|
selectedProject.id,
|
|
244
247
|
selectedWorkspace.id,
|
|
248
|
+
selectedWorkspace.title,
|
|
245
249
|
);
|
|
246
250
|
expect(runResult).toMatchInlineSnapshot(`
|
|
247
251
|
{
|
|
@@ -271,14 +275,10 @@ describe('describe command tests', () => {
|
|
|
271
275
|
"Mesh ID: %s",
|
|
272
276
|
"dummy_meshId",
|
|
273
277
|
],
|
|
274
|
-
[
|
|
275
|
-
"API Key: %s",
|
|
276
|
-
"dummy_apiKey",
|
|
277
|
-
],
|
|
278
278
|
[
|
|
279
279
|
"Mesh Endpoint: %s
|
|
280
280
|
",
|
|
281
|
-
"https://tigraph.adobe.io/dummy_meshId/graphql
|
|
281
|
+
"https://tigraph.adobe.io/dummy_meshId/graphql",
|
|
282
282
|
],
|
|
283
283
|
]
|
|
284
284
|
`);
|
|
@@ -23,14 +23,9 @@ const {
|
|
|
23
23
|
readFileContents,
|
|
24
24
|
validateAndInterpolateMesh,
|
|
25
25
|
} = require('../../utils');
|
|
26
|
-
const {
|
|
27
|
-
getMesh,
|
|
28
|
-
createMesh,
|
|
29
|
-
createAPIMeshCredentials,
|
|
30
|
-
subscribeCredentialToMeshService,
|
|
31
|
-
} = require('../../lib/devConsole');
|
|
26
|
+
const { getMesh, createMesh } = require('../../lib/devConsole');
|
|
32
27
|
|
|
33
|
-
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL
|
|
28
|
+
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL } = CONSTANTS;
|
|
34
29
|
|
|
35
30
|
class CreateCommand extends Command {
|
|
36
31
|
static args = [{ name: 'file' }];
|
|
@@ -59,7 +54,7 @@ class CreateCommand extends Command {
|
|
|
59
54
|
const ignoreCache = await flags.ignoreCache;
|
|
60
55
|
const autoConfirmAction = await flags.autoConfirmAction;
|
|
61
56
|
const envFilePath = await flags.env;
|
|
62
|
-
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
57
|
+
const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
|
|
63
58
|
ignoreCache,
|
|
64
59
|
});
|
|
65
60
|
|
|
@@ -109,9 +104,13 @@ class CreateCommand extends Command {
|
|
|
109
104
|
|
|
110
105
|
if (shouldContinue) {
|
|
111
106
|
try {
|
|
112
|
-
const mesh = await createMesh(
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
const { mesh, apiKey, sdkList } = await createMesh(
|
|
108
|
+
imsOrgId,
|
|
109
|
+
projectId,
|
|
110
|
+
workspaceId,
|
|
111
|
+
workspaceName,
|
|
112
|
+
data,
|
|
113
|
+
);
|
|
115
114
|
|
|
116
115
|
if (mesh) {
|
|
117
116
|
this.log(
|
|
@@ -127,60 +126,42 @@ class CreateCommand extends Command {
|
|
|
127
126
|
'******************************************************************************************************',
|
|
128
127
|
);
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
imsOrgId,
|
|
133
|
-
projectId,
|
|
134
|
-
workspaceId,
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
if (adobeIdIntegrationsForWorkspace) {
|
|
138
|
-
this.log('Successfully created API Key %s', adobeIdIntegrationsForWorkspace.apiKey);
|
|
139
|
-
// subscribe the credential to API mesh service
|
|
140
|
-
sdkList = await subscribeCredentialToMeshService(
|
|
141
|
-
imsOrgId,
|
|
142
|
-
projectId,
|
|
143
|
-
workspaceId,
|
|
144
|
-
adobeIdIntegrationsForWorkspace.id,
|
|
145
|
-
);
|
|
129
|
+
if (apiKey) {
|
|
130
|
+
this.log('Successfully created API Key %s', apiKey);
|
|
146
131
|
|
|
147
132
|
if (sdkList) {
|
|
148
|
-
this.log(
|
|
149
|
-
|
|
150
|
-
|
|
133
|
+
this.log('Successfully subscribed API Key %s to API Mesh service', apiKey);
|
|
134
|
+
|
|
135
|
+
const { meshURL } = await getMesh(
|
|
136
|
+
imsOrgId,
|
|
137
|
+
projectId,
|
|
138
|
+
workspaceId,
|
|
139
|
+
workspaceName,
|
|
140
|
+
mesh.meshId,
|
|
151
141
|
);
|
|
152
|
-
|
|
153
|
-
const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, mesh.meshId);
|
|
154
142
|
const meshUrl =
|
|
155
143
|
meshURL === '' || meshURL === undefined
|
|
156
144
|
? MULTITENANT_GRAPHQL_SERVER_BASE_URL
|
|
157
145
|
: meshURL;
|
|
158
146
|
|
|
159
|
-
if (
|
|
160
|
-
meshUrl === TMOConstants.TMO_STAGE_URL ||
|
|
161
|
-
meshUrl === TMOConstants.TMO_SANDBOX_URL ||
|
|
162
|
-
meshUrl === TMOConstants.TMO_PROD_URL
|
|
163
|
-
) {
|
|
164
|
-
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${mesh.meshId}/graphql`);
|
|
165
|
-
} else {
|
|
147
|
+
if (apiKey && MULTITENANT_GRAPHQL_SERVER_BASE_URL.includes(meshUrl)) {
|
|
166
148
|
this.log(
|
|
167
149
|
'Mesh Endpoint: %s\n',
|
|
168
|
-
`${meshUrl}/${mesh.meshId}/graphql?api_key=${
|
|
150
|
+
`${meshUrl}/${mesh.meshId}/graphql?api_key=${apiKey}`,
|
|
169
151
|
);
|
|
152
|
+
} else {
|
|
153
|
+
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${mesh.meshId}/graphql`);
|
|
170
154
|
}
|
|
171
155
|
} else {
|
|
172
|
-
this.log(
|
|
173
|
-
'Unable to subscribe API Key %s to API Mesh service',
|
|
174
|
-
adobeIdIntegrationsForWorkspace.apiKey,
|
|
175
|
-
);
|
|
156
|
+
this.log('Unable to subscribe API Key %s to API Mesh service', apiKey);
|
|
176
157
|
}
|
|
177
158
|
} else {
|
|
178
159
|
this.log('Unable to create API Key');
|
|
179
160
|
}
|
|
180
|
-
//
|
|
181
|
-
//
|
|
161
|
+
// When renaming the return values, make sure to make necessary changes to
|
|
162
|
+
// template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey"
|
|
182
163
|
return {
|
|
183
|
-
|
|
164
|
+
apiKey,
|
|
184
165
|
sdkList,
|
|
185
166
|
mesh,
|
|
186
167
|
};
|
|
@@ -19,7 +19,7 @@ const { describeMesh, getMesh } = require('../../lib/devConsole');
|
|
|
19
19
|
|
|
20
20
|
require('dotenv').config();
|
|
21
21
|
|
|
22
|
-
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL
|
|
22
|
+
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL } = CONSTANTS;
|
|
23
23
|
|
|
24
24
|
class DescribeCommand extends Command {
|
|
25
25
|
static flags = {
|
|
@@ -35,12 +35,12 @@ class DescribeCommand extends Command {
|
|
|
35
35
|
|
|
36
36
|
const ignoreCache = await flags.ignoreCache;
|
|
37
37
|
|
|
38
|
-
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
38
|
+
const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
|
|
39
39
|
ignoreCache,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
try {
|
|
43
|
-
const meshDetails = await describeMesh(imsOrgId, projectId, workspaceId);
|
|
43
|
+
const meshDetails = await describeMesh(imsOrgId, projectId, workspaceId, workspaceName);
|
|
44
44
|
|
|
45
45
|
if (meshDetails) {
|
|
46
46
|
const { meshId, apiKey } = meshDetails;
|
|
@@ -52,19 +52,20 @@ 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(
|
|
56
|
-
|
|
55
|
+
const { meshURL } = await getMesh(
|
|
56
|
+
imsOrgId,
|
|
57
|
+
projectId,
|
|
58
|
+
workspaceId,
|
|
59
|
+
workspaceName,
|
|
60
|
+
meshId,
|
|
61
|
+
);
|
|
62
|
+
const meshUrl =
|
|
63
|
+
meshURL === '' || meshURL === undefined ? MULTITENANT_GRAPHQL_SERVER_BASE_URL : meshURL;
|
|
57
64
|
|
|
58
|
-
if (
|
|
59
|
-
apiKey &&
|
|
60
|
-
(meshUrl === TMOConstants.TMO_STAGE_URL ||
|
|
61
|
-
meshUrl === TMOConstants.TMO_SANDBOX_URL ||
|
|
62
|
-
meshUrl === TMOConstants.TMO_PROD_URL)
|
|
63
|
-
) {
|
|
64
|
-
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${meshId}/graphql`);
|
|
65
|
-
} else if (apiKey) {
|
|
66
|
-
this.log('API Key: %s', apiKey);
|
|
65
|
+
if (apiKey && MULTITENANT_GRAPHQL_SERVER_BASE_URL.includes(meshUrl)) {
|
|
67
66
|
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${meshId}/graphql?api_key=${apiKey}`);
|
|
67
|
+
} else {
|
|
68
|
+
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${meshId}/graphql`);
|
|
68
69
|
}
|
|
69
70
|
return meshDetails;
|
|
70
71
|
} else {
|
|
@@ -38,7 +38,7 @@ class GetCommand extends Command {
|
|
|
38
38
|
const ignoreCache = await flags.ignoreCache;
|
|
39
39
|
const json = await flags.json;
|
|
40
40
|
|
|
41
|
-
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
41
|
+
const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
|
|
42
42
|
ignoreCache,
|
|
43
43
|
verbose: !json,
|
|
44
44
|
});
|
|
@@ -46,7 +46,7 @@ class GetCommand extends Command {
|
|
|
46
46
|
let meshId = null;
|
|
47
47
|
|
|
48
48
|
try {
|
|
49
|
-
meshId = await getMeshId(imsOrgId, projectId, workspaceId);
|
|
49
|
+
meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
|
|
50
50
|
} catch (err) {
|
|
51
51
|
this.error(
|
|
52
52
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -55,7 +55,7 @@ class GetCommand extends Command {
|
|
|
55
55
|
|
|
56
56
|
if (meshId) {
|
|
57
57
|
try {
|
|
58
|
-
const mesh = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
58
|
+
const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
|
|
59
59
|
|
|
60
60
|
if (mesh) {
|
|
61
61
|
this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
|
|
@@ -39,6 +39,7 @@ initSdk.mockResolvedValue({
|
|
|
39
39
|
imsOrgId: selectedOrg.id,
|
|
40
40
|
projectId: selectedProject.id,
|
|
41
41
|
workspaceId: selectedWorkspace.id,
|
|
42
|
+
workspaceName: selectedWorkspace.title,
|
|
42
43
|
});
|
|
43
44
|
initRequestId.mockResolvedValue({});
|
|
44
45
|
promptInput.mockResolvedValueOnce('test-03');
|
|
@@ -146,6 +147,7 @@ describe('source:install command tests', () => {
|
|
|
146
147
|
selectedOrg.id,
|
|
147
148
|
selectedProject.id,
|
|
148
149
|
selectedWorkspace.id,
|
|
150
|
+
selectedWorkspace.title,
|
|
149
151
|
'dummy_meshId',
|
|
150
152
|
res,
|
|
151
153
|
);
|
|
@@ -36,7 +36,7 @@ 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 } = await initSdk({ ignoreCache });
|
|
39
|
+
const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({ ignoreCache });
|
|
40
40
|
const filepath = flags['variable-file'];
|
|
41
41
|
let variables = flags.variable
|
|
42
42
|
? flags.variable.reduce((obj, val) => {
|
|
@@ -119,7 +119,7 @@ class InstallCommand extends Command {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
try {
|
|
122
|
-
meshId = await getMeshId(imsOrgId, projectId, workspaceId);
|
|
122
|
+
meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
|
|
123
123
|
} catch (err) {
|
|
124
124
|
this.error(
|
|
125
125
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -133,7 +133,7 @@ class InstallCommand extends Command {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
try {
|
|
136
|
-
const mesh = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
136
|
+
const mesh = await getMesh(imsOrgId, projectId, workspaceId, meshId, workspaceName);
|
|
137
137
|
|
|
138
138
|
if (!mesh) {
|
|
139
139
|
this.error(
|
|
@@ -199,7 +199,7 @@ class InstallCommand extends Command {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
try {
|
|
202
|
-
const response = await updateMesh(imsOrgId, projectId, workspaceId, meshId, {
|
|
202
|
+
const response = await updateMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId, {
|
|
203
203
|
meshConfig: mesh.meshConfig,
|
|
204
204
|
});
|
|
205
205
|
|
|
@@ -18,14 +18,14 @@ class StatusCommand extends Command {
|
|
|
18
18
|
const { flags } = await this.parse(StatusCommand);
|
|
19
19
|
const ignoreCache = await flags.ignoreCache;
|
|
20
20
|
|
|
21
|
-
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
21
|
+
const { imsOrgId, 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(imsOrgId, projectId, workspaceId);
|
|
28
|
+
meshId = await getMeshId(imsOrgId, projectId, workspaceId, workspaceName);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
this.log(err.message);
|
|
31
31
|
this.error(
|
|
@@ -35,7 +35,7 @@ class StatusCommand extends Command {
|
|
|
35
35
|
|
|
36
36
|
if (meshId) {
|
|
37
37
|
try {
|
|
38
|
-
const mesh = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
38
|
+
const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
|
|
39
39
|
switch (mesh.meshStatus) {
|
|
40
40
|
case 'success':
|
|
41
41
|
this.log(
|
package/src/constants.js
CHANGED
|
@@ -19,10 +19,6 @@ const ProdConstants = {
|
|
|
19
19
|
AIO_CLI_API_KEY: 'aio-cli-console-auth',
|
|
20
20
|
SMS_BASE_URL: 'https://graph.adobe.io/api-admin',
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
TMO_STAGE_URL: 'https://tigraph-dev.adobe.io/api',
|
|
24
|
-
TMO_SANDBOX_URL: 'https://tigraph-sandbox.adobe.io/api',
|
|
25
|
-
TMO_PROD_URL: 'https://tigraph.adobe.io/api',
|
|
26
|
-
};
|
|
22
|
+
|
|
27
23
|
const envConstants = clientEnv === 'stage' ? StageConstants : ProdConstants;
|
|
28
|
-
module.exports = { ...envConstants
|
|
24
|
+
module.exports = { ...envConstants };
|
package/src/helpers.js
CHANGED
package/src/lib/devConsole.js
CHANGED
|
@@ -76,11 +76,11 @@ const getApiKeyCredential = async (organizationId, projectId, workspaceId) => {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const describeMesh = async (organizationId, projectId, workspaceId) => {
|
|
79
|
+
const describeMesh = async (organizationId, projectId, workspaceId, workspaceName) => {
|
|
80
80
|
logger.info('Initiating Describe Mesh');
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
|
-
const meshId = await getMeshId(organizationId, projectId, workspaceId);
|
|
83
|
+
const meshId = await getMeshId(organizationId, projectId, workspaceId, workspaceName);
|
|
84
84
|
|
|
85
85
|
logger.info('Response from getMeshId %s', meshId);
|
|
86
86
|
|
|
@@ -106,7 +106,7 @@ const describeMesh = async (organizationId, projectId, workspaceId) => {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
const getMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
109
|
+
const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId) => {
|
|
110
110
|
const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
|
|
111
111
|
const config = {
|
|
112
112
|
method: 'get',
|
|
@@ -114,6 +114,7 @@ const getMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
|
114
114
|
headers: {
|
|
115
115
|
'Authorization': `Bearer ${accessToken}`,
|
|
116
116
|
'x-request-id': global.requestId,
|
|
117
|
+
'workspaceName': workspaceName,
|
|
117
118
|
},
|
|
118
119
|
};
|
|
119
120
|
|
|
@@ -187,7 +188,7 @@ const getMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
|
|
190
|
-
const createMesh = async (organizationId, projectId, workspaceId, data) => {
|
|
191
|
+
const createMesh = async (organizationId, projectId, workspaceId, workspaceName, data) => {
|
|
191
192
|
const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
|
|
192
193
|
const config = {
|
|
193
194
|
method: 'post',
|
|
@@ -212,7 +213,44 @@ const createMesh = async (organizationId, projectId, workspaceId, data) => {
|
|
|
212
213
|
|
|
213
214
|
if (response && response.status === 201) {
|
|
214
215
|
logger.info(`Mesh Config : ${objToString(response, ['data'])}`);
|
|
215
|
-
|
|
216
|
+
|
|
217
|
+
let sdkList = [];
|
|
218
|
+
let credential;
|
|
219
|
+
let isApiKeyNew = false;
|
|
220
|
+
|
|
221
|
+
credential = await getApiKeyCredential(organizationId, projectId, workspaceId);
|
|
222
|
+
if (!credential) {
|
|
223
|
+
logger.info('API Key credential not found on workspace');
|
|
224
|
+
|
|
225
|
+
// try to create a new API key credential
|
|
226
|
+
credential = await createAPIMeshCredentials(organizationId, projectId, workspaceId);
|
|
227
|
+
isApiKeyNew = true;
|
|
228
|
+
}
|
|
229
|
+
// subscribe the credential to API mesh service
|
|
230
|
+
sdkList = await subscribeCredentialToMeshService(
|
|
231
|
+
organizationId,
|
|
232
|
+
projectId,
|
|
233
|
+
workspaceId,
|
|
234
|
+
isApiKeyNew ? credential.id : credential.id_integration,
|
|
235
|
+
);
|
|
236
|
+
const newlyCreatedOrExistingApiKey = isApiKeyNew ? credential.apiKey : credential.client_id;
|
|
237
|
+
|
|
238
|
+
if (sdkList) {
|
|
239
|
+
logger.info(
|
|
240
|
+
'Successfully subscribed API Key %s to API Mesh service',
|
|
241
|
+
isApiKeyNew ? credential.apiKey : credential.client_id,
|
|
242
|
+
);
|
|
243
|
+
} else {
|
|
244
|
+
logger.error(
|
|
245
|
+
'Unable to subscribe API Key %s to API Mesh service',
|
|
246
|
+
newlyCreatedOrExistingApiKey,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
mesh: response.data,
|
|
251
|
+
apiKey: newlyCreatedOrExistingApiKey,
|
|
252
|
+
sdkList,
|
|
253
|
+
};
|
|
216
254
|
} else {
|
|
217
255
|
// Non 201 response received
|
|
218
256
|
logger.error(
|
|
@@ -443,7 +481,7 @@ const deleteMesh = async (organizationId, projectId, workspaceId, meshId) => {
|
|
|
443
481
|
}
|
|
444
482
|
};
|
|
445
483
|
|
|
446
|
-
const getMeshId = async (organizationId, projectId, workspaceId) => {
|
|
484
|
+
const getMeshId = async (organizationId, projectId, workspaceId, workspaceName) => {
|
|
447
485
|
const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
|
|
448
486
|
logger.info('Initiating Mesh ID request');
|
|
449
487
|
|
|
@@ -453,6 +491,7 @@ const getMeshId = async (organizationId, projectId, workspaceId) => {
|
|
|
453
491
|
headers: {
|
|
454
492
|
'Authorization': `Bearer ${accessToken}`,
|
|
455
493
|
'x-request-id': global.requestId,
|
|
494
|
+
'workspaceName': workspaceName,
|
|
456
495
|
},
|
|
457
496
|
};
|
|
458
497
|
|