@adobe/aio-cli-plugin-api-mesh 2.3.3 → 3.0.0

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":"2.3.3","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"}]}}}
1
+ {"version":"3.0.0","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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-plugin-api-mesh",
3
- "version": "2.3.3",
3
+ "version": "3.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -75,9 +75,14 @@ describe('create command tests', () => {
75
75
  errorLogSpy = jest.spyOn(CreateCommand.prototype, 'error');
76
76
 
77
77
  createMesh.mockResolvedValue({
78
- meshId: 'dummy_mesh_id',
79
- meshConfig: sampleCreateMeshConfig.meshConfig,
78
+ mesh: {
79
+ meshId: 'dummy_mesh_id',
80
+ meshConfig: sampleCreateMeshConfig.meshConfig,
81
+ },
82
+ apiKey: 'dummy_api_key',
83
+ sdkList: ['dummy_service'],
80
84
  });
85
+
81
86
  createAPIMeshCredentials.mockResolvedValue({
82
87
  apiKey: 'dummy_api_key',
83
88
  id: 'dummy_id',
@@ -109,11 +114,11 @@ describe('create command tests', () => {
109
114
  });
110
115
  const output = await CreateCommand.run();
111
116
  expect(output).toHaveProperty('mesh');
112
- expect(output).toHaveProperty('adobeIdIntegrationsForWorkspace');
117
+ expect(output).toHaveProperty('apiKey');
118
+ expect(output).toHaveProperty('sdkList');
113
119
  expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' }));
114
- expect(output.adobeIdIntegrationsForWorkspace).toEqual(
115
- expect.objectContaining({ apiKey: 'dummy_api_key' }),
116
- );
120
+ expect(output.apiKey).toEqual('dummy_api_key');
121
+ expect(output.sdkList).toEqual(['dummy_service']);
117
122
  });
118
123
 
119
124
  test('snapshot create command description', () => {
@@ -169,8 +174,12 @@ describe('create command tests', () => {
169
174
 
170
175
  test('should pass if a valid mesh config file with composer files are provided', async () => {
171
176
  createMesh.mockResolvedValueOnce({
172
- meshId: 'dummy_mesh_id',
173
- meshConfig: meshConfigWithComposerFiles.meshConfig,
177
+ mesh: {
178
+ meshId: 'dummy_mesh_id',
179
+ meshConfig: meshConfigWithComposerFiles.meshConfig,
180
+ },
181
+ apiKey: 'dummy_api_key',
182
+ sdkList: ['dummy_service'],
174
183
  });
175
184
 
176
185
  parseSpy.mockResolvedValueOnce({
@@ -184,10 +193,7 @@ describe('create command tests', () => {
184
193
 
185
194
  expect(output).toMatchInlineSnapshot(`
186
195
  {
187
- "adobeIdIntegrationsForWorkspace": {
188
- "apiKey": "dummy_api_key",
189
- "id": "dummy_id",
190
- },
196
+ "apiKey": "dummy_api_key",
191
197
  "mesh": {
192
198
  "meshConfig": {
193
199
  "files": [
@@ -287,28 +293,10 @@ describe('create command tests', () => {
287
293
  },
288
294
  },
289
295
  ]
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
296
  `);
306
297
  expect(runResult).toMatchInlineSnapshot(`
307
298
  {
308
- "adobeIdIntegrationsForWorkspace": {
309
- "apiKey": "dummy_api_key",
310
- "id": "dummy_id",
311
- },
299
+ "apiKey": "dummy_api_key",
312
300
  "mesh": {
313
301
  "meshConfig": {
314
302
  "sources": [
@@ -395,27 +383,10 @@ describe('create command tests', () => {
395
383
  },
396
384
  ]
397
385
  `);
398
- expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
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
- `);
386
+
413
387
  expect(runResult).toMatchInlineSnapshot(`
414
388
  {
415
- "adobeIdIntegrationsForWorkspace": {
416
- "apiKey": "dummy_api_key",
417
- "id": "dummy_id",
418
- },
389
+ "apiKey": "dummy_api_key",
419
390
  "mesh": {
420
391
  "meshConfig": {
421
392
  "sources": [
@@ -521,7 +492,7 @@ describe('create command tests', () => {
521
492
  `);
522
493
  });
523
494
 
524
- test('should fail if create api credential api has failed', async () => {
495
+ test.skip('should fail if create api credential api has failed', async () => {
525
496
  createAPIMeshCredentials.mockRejectedValue(new Error('create api credential api failed'));
526
497
 
527
498
  const runResult = CreateCommand.run();
@@ -563,7 +534,7 @@ describe('create command tests', () => {
563
534
  `);
564
535
  });
565
536
 
566
- test('should fail if subscribe credential to mesh service api has failed', async () => {
537
+ test.skip('should fail if subscribe credential to mesh service api has failed', async () => {
567
538
  subscribeCredentialToMeshService.mockRejectedValueOnce(
568
539
  new Error('subscribe credential to mesh service api failed'),
569
540
  );
@@ -692,11 +663,11 @@ describe('create command tests', () => {
692
663
  });
693
664
  const output = await CreateCommand.run();
694
665
  expect(output).toHaveProperty('mesh');
695
- expect(output).toHaveProperty('adobeIdIntegrationsForWorkspace');
666
+ expect(output).toHaveProperty('apiKey');
667
+ expect(output).toHaveProperty('sdkList');
696
668
  expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' }));
697
- expect(output.adobeIdIntegrationsForWorkspace).toEqual(
698
- expect.objectContaining({ apiKey: 'dummy_api_key' }),
699
- );
669
+ expect(output.apiKey).toEqual('dummy_api_key');
670
+ expect(output.sdkList).toEqual(['dummy_service']);
700
671
  });
701
672
 
702
673
  test('should return error if the mesh has placeholders and env file provided using --env flag is not found', async () => {
@@ -851,10 +822,7 @@ describe('create command tests', () => {
851
822
  expect(promptConfirm).toHaveBeenCalledWith('Are you sure you want to create a mesh?');
852
823
  expect(runResult).toMatchInlineSnapshot(`
853
824
  {
854
- "adobeIdIntegrationsForWorkspace": {
855
- "apiKey": "dummy_api_key",
856
- "id": "dummy_id",
857
- },
825
+ "apiKey": "dummy_api_key",
858
826
  "mesh": {
859
827
  "meshConfig": {
860
828
  "sources": [
@@ -930,8 +898,12 @@ describe('create command tests', () => {
930
898
  };
931
899
 
932
900
  createMesh.mockResolvedValueOnce({
933
- meshId: 'dummy_mesh_id',
934
- meshConfig: meshConfig,
901
+ mesh: {
902
+ meshId: 'dummy_mesh_id',
903
+ meshConfig: meshConfig,
904
+ },
905
+ apiKey: 'dummy_api_key',
906
+ sdkList: ['dummy_service'],
935
907
  });
936
908
 
937
909
  parseSpy.mockResolvedValueOnce({
@@ -984,28 +956,10 @@ describe('create command tests', () => {
984
956
  },
985
957
  ]
986
958
  `);
987
- expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
988
- [
989
- "1234",
990
- "5678",
991
- "123456789",
992
- ]
993
- `);
994
959
 
995
- expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
996
- [
997
- "1234",
998
- "5678",
999
- "123456789",
1000
- "dummy_id",
1001
- ]
1002
- `);
1003
960
  expect(output).toMatchInlineSnapshot(`
1004
961
  {
1005
- "adobeIdIntegrationsForWorkspace": {
1006
- "apiKey": "dummy_api_key",
1007
- "id": "dummy_id",
1008
- },
962
+ "apiKey": "dummy_api_key",
1009
963
  "mesh": {
1010
964
  "meshConfig": {
1011
965
  "files": [
@@ -1209,8 +1163,12 @@ describe('create command tests', () => {
1209
1163
  importFiles.mockResolvedValueOnce(meshConfig);
1210
1164
 
1211
1165
  createMesh.mockResolvedValueOnce({
1212
- meshId: 'dummy_mesh_id',
1213
- meshConfig: meshConfig,
1166
+ mesh: {
1167
+ meshId: 'dummy_mesh_id',
1168
+ meshConfig: meshConfig,
1169
+ },
1170
+ apiKey: 'dummy_api_key',
1171
+ sdkList: ['dummy_service'],
1214
1172
  });
1215
1173
 
1216
1174
  parseSpy.mockResolvedValueOnce({
@@ -1256,28 +1214,10 @@ describe('create command tests', () => {
1256
1214
  ],
1257
1215
  },
1258
1216
  ]
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
1217
  `);
1275
1218
  expect(output).toMatchInlineSnapshot(`
1276
1219
  {
1277
- "adobeIdIntegrationsForWorkspace": {
1278
- "apiKey": "dummy_api_key",
1279
- "id": "dummy_id",
1280
- },
1220
+ "apiKey": "dummy_api_key",
1281
1221
  "mesh": {
1282
1222
  "meshConfig": {
1283
1223
  "files": [
@@ -1358,8 +1298,12 @@ describe('create command tests', () => {
1358
1298
  });
1359
1299
 
1360
1300
  createMesh.mockResolvedValueOnce({
1361
- meshId: 'dummy_mesh_id',
1362
- meshConfig: meshConfig,
1301
+ mesh: {
1302
+ meshId: 'dummy_mesh_id',
1303
+ meshConfig: meshConfig,
1304
+ },
1305
+ apiKey: 'dummy_api_key',
1306
+ sdkList: ['dummy_service'],
1363
1307
  });
1364
1308
 
1365
1309
  const output = await CreateCommand.run();
@@ -1401,28 +1345,10 @@ describe('create command tests', () => {
1401
1345
  },
1402
1346
  ]
1403
1347
  `);
1404
- expect(createAPIMeshCredentials.mock.calls[0]).toMatchInlineSnapshot(`
1405
- [
1406
- "1234",
1407
- "5678",
1408
- "123456789",
1409
- ]
1410
- `);
1411
1348
 
1412
- expect(subscribeCredentialToMeshService.mock.calls[0]).toMatchInlineSnapshot(`
1413
- [
1414
- "1234",
1415
- "5678",
1416
- "123456789",
1417
- "dummy_id",
1418
- ]
1419
- `);
1420
1349
  expect(output).toMatchInlineSnapshot(`
1421
1350
  {
1422
- "adobeIdIntegrationsForWorkspace": {
1423
- "apiKey": "dummy_api_key",
1424
- "id": "dummy_id",
1425
- },
1351
+ "apiKey": "dummy_api_key",
1426
1352
  "mesh": {
1427
1353
  "meshConfig": {
1428
1354
  "files": [
@@ -1503,8 +1429,12 @@ describe('create command tests', () => {
1503
1429
  });
1504
1430
 
1505
1431
  createMesh.mockResolvedValueOnce({
1506
- meshId: 'dummy_mesh_id',
1507
- meshConfig: meshConfig,
1432
+ mesh: {
1433
+ meshId: 'dummy_mesh_id',
1434
+ meshConfig: meshConfig,
1435
+ },
1436
+ apiKey: 'dummy_api_key',
1437
+ sdkList: ['dummy_service'],
1508
1438
  });
1509
1439
 
1510
1440
  const output = await CreateCommand.run();
@@ -1545,28 +1475,10 @@ describe('create command tests', () => {
1545
1475
  },
1546
1476
  },
1547
1477
  ]
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
1478
  `);
1564
1479
  expect(output).toMatchInlineSnapshot(`
1565
1480
  {
1566
- "adobeIdIntegrationsForWorkspace": {
1567
- "apiKey": "dummy_api_key",
1568
- "id": "dummy_id",
1569
- },
1481
+ "apiKey": "dummy_api_key",
1570
1482
  "mesh": {
1571
1483
  "meshConfig": {
1572
1484
  "files": [
@@ -1634,8 +1546,12 @@ describe('create command tests', () => {
1634
1546
  };
1635
1547
 
1636
1548
  createMesh.mockResolvedValueOnce({
1637
- meshId: 'dummy_mesh_id',
1638
- meshConfig: meshConfig,
1549
+ mesh: {
1550
+ meshId: 'dummy_mesh_id',
1551
+ meshConfig: meshConfig,
1552
+ },
1553
+ apiKey: 'dummy_api_key',
1554
+ sdkList: ['dummy_service'],
1639
1555
  });
1640
1556
 
1641
1557
  parseSpy.mockResolvedValueOnce({
@@ -1688,28 +1604,9 @@ describe('create command tests', () => {
1688
1604
  },
1689
1605
  ]
1690
1606
  `);
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
1607
  expect(output).toMatchInlineSnapshot(`
1708
1608
  {
1709
- "adobeIdIntegrationsForWorkspace": {
1710
- "apiKey": "dummy_api_key",
1711
- "id": "dummy_id",
1712
- },
1609
+ "apiKey": "dummy_api_key",
1713
1610
  "mesh": {
1714
1611
  "meshConfig": {
1715
1612
  "files": [
@@ -23,12 +23,7 @@ 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
28
  const { MULTITENANT_GRAPHQL_SERVER_BASE_URL, TMOConstants } = CONSTANTS;
34
29
 
@@ -109,9 +104,7 @@ class CreateCommand extends Command {
109
104
 
110
105
  if (shouldContinue) {
111
106
  try {
112
- const mesh = await createMesh(imsOrgId, projectId, workspaceId, data);
113
-
114
- let sdkList = [];
107
+ const { mesh, apiKey, sdkList } = await createMesh(imsOrgId, projectId, workspaceId, data);
115
108
 
116
109
  if (mesh) {
117
110
  this.log(
@@ -127,28 +120,11 @@ class CreateCommand extends Command {
127
120
  '******************************************************************************************************',
128
121
  );
129
122
 
130
- // create API key credential
131
- const adobeIdIntegrationsForWorkspace = await createAPIMeshCredentials(
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
- );
123
+ if (apiKey) {
124
+ this.log('Successfully created API Key %s', apiKey);
146
125
 
147
126
  if (sdkList) {
148
- this.log(
149
- 'Successfully subscribed API Key %s to API Mesh service',
150
- adobeIdIntegrationsForWorkspace.apiKey,
151
- );
127
+ this.log('Successfully subscribed API Key %s to API Mesh service', apiKey);
152
128
 
153
129
  const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, mesh.meshId);
154
130
  const meshUrl =
@@ -165,22 +141,19 @@ class CreateCommand extends Command {
165
141
  } else {
166
142
  this.log(
167
143
  'Mesh Endpoint: %s\n',
168
- `${meshUrl}/${mesh.meshId}/graphql?api_key=${adobeIdIntegrationsForWorkspace.apiKey}`,
144
+ `${meshUrl}/${mesh.meshId}/graphql?api_key=${apiKey}`,
169
145
  );
170
146
  }
171
147
  } else {
172
- this.log(
173
- 'Unable to subscribe API Key %s to API Mesh service',
174
- adobeIdIntegrationsForWorkspace.apiKey,
175
- );
148
+ this.log('Unable to subscribe API Key %s to API Mesh service', apiKey);
176
149
  }
177
150
  } else {
178
151
  this.log('Unable to create API Key');
179
152
  }
180
- // Do not remove or rename return values.
181
- // Template adobe/generator-app-api-mesh relies on "mesh" & "adobeIdIntegrationsForWorkspace" obj structure
153
+ // When renaming the return values, make sure to make necessary changes to
154
+ // template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey"
182
155
  return {
183
- adobeIdIntegrationsForWorkspace,
156
+ apiKey,
184
157
  sdkList,
185
158
  mesh,
186
159
  };
@@ -212,7 +212,44 @@ const createMesh = async (organizationId, projectId, workspaceId, data) => {
212
212
 
213
213
  if (response && response.status === 201) {
214
214
  logger.info(`Mesh Config : ${objToString(response, ['data'])}`);
215
- return response.data;
215
+
216
+ let sdkList = [];
217
+ let credential;
218
+ let isApiKeyNew = false;
219
+
220
+ credential = await getApiKeyCredential(organizationId, projectId, workspaceId);
221
+ if (!credential) {
222
+ logger.info('API Key credential not found on workspace');
223
+
224
+ // try to create a new API key credential
225
+ credential = await createAPIMeshCredentials(organizationId, projectId, workspaceId);
226
+ isApiKeyNew = true;
227
+ }
228
+ // subscribe the credential to API mesh service
229
+ sdkList = await subscribeCredentialToMeshService(
230
+ organizationId,
231
+ projectId,
232
+ workspaceId,
233
+ isApiKeyNew ? credential.id : credential.id_integration,
234
+ );
235
+ const newlyCreatedOrExistingApiKey = isApiKeyNew ? credential.apiKey : credential.client_id;
236
+
237
+ if (sdkList) {
238
+ logger.info(
239
+ 'Successfully subscribed API Key %s to API Mesh service',
240
+ isApiKeyNew ? credential.apiKey : credential.client_id,
241
+ );
242
+ } else {
243
+ logger.error(
244
+ 'Unable to subscribe API Key %s to API Mesh service',
245
+ newlyCreatedOrExistingApiKey,
246
+ );
247
+ }
248
+ return {
249
+ mesh: response.data,
250
+ apiKey: newlyCreatedOrExistingApiKey,
251
+ sdkList,
252
+ };
216
253
  } else {
217
254
  // Non 201 response received
218
255
  logger.error(