@adobe/aio-cli-plugin-api-mesh 2.3.2 → 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.
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/api-mesh/__tests__/create.test.js +63 -166
- package/src/commands/api-mesh/__tests__/delete.test.js +2 -2
- package/src/commands/api-mesh/__tests__/get.test.js +2 -2
- package/src/commands/api-mesh/__tests__/init.test.js +17 -17
- package/src/commands/api-mesh/__tests__/update.test.js +15 -15
- package/src/commands/api-mesh/create.js +22 -42
- package/src/commands/api-mesh/describe.js +9 -3
- package/src/constants.js +7 -2
- package/src/lib/devConsole.js +38 -1
- package/src/utils.js +1 -1
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
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
|
@@ -75,9 +75,14 @@ describe('create command tests', () => {
|
|
|
75
75
|
errorLogSpy = jest.spyOn(CreateCommand.prototype, 'error');
|
|
76
76
|
|
|
77
77
|
createMesh.mockResolvedValue({
|
|
78
|
-
|
|
79
|
-
|
|
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('
|
|
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.
|
|
115
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
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
|
-
"
|
|
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('
|
|
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.
|
|
698
|
-
|
|
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
|
-
"
|
|
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
|
-
|
|
934
|
-
|
|
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
|
-
"
|
|
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
|
-
|
|
1213
|
-
|
|
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
|
-
"
|
|
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
|
-
|
|
1362
|
-
|
|
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
|
-
"
|
|
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
|
-
|
|
1507
|
-
|
|
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
|
-
"
|
|
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
|
-
|
|
1638
|
-
|
|
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
|
-
"
|
|
1710
|
-
"apiKey": "dummy_api_key",
|
|
1711
|
-
"id": "dummy_id",
|
|
1712
|
-
},
|
|
1609
|
+
"apiKey": "dummy_api_key",
|
|
1713
1610
|
"mesh": {
|
|
1714
1611
|
"meshConfig": {
|
|
1715
1612
|
"files": [
|
|
@@ -112,7 +112,7 @@ describe('delete command tests', () => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
test('should fail if mesh id is missing', async () => {
|
|
115
|
-
getMeshId.
|
|
115
|
+
getMeshId.mockResolvedValueOnce(null);
|
|
116
116
|
const runResult = DeleteCommand.run();
|
|
117
117
|
|
|
118
118
|
return runResult.catch(err => {
|
|
@@ -147,7 +147,7 @@ describe('delete command tests', () => {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
test('should not ask for prompt if autoConfirmAction is set', async () => {
|
|
150
|
-
parseSpy.
|
|
150
|
+
parseSpy.mockResolvedValueOnce({
|
|
151
151
|
args: {},
|
|
152
152
|
flags: {
|
|
153
153
|
ignoreCache: mockIgnoreCacheFlag,
|
|
@@ -109,7 +109,7 @@ describe('get command tests', () => {
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
test('should fail if mesh id is missing', async () => {
|
|
112
|
-
getMeshId.
|
|
112
|
+
getMeshId.mockResolvedValueOnce(null);
|
|
113
113
|
const runResult = GetCommand.run();
|
|
114
114
|
|
|
115
115
|
return runResult.catch(err => {
|
|
@@ -128,7 +128,7 @@ describe('get command tests', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
test('should fail if getMeshId failed', async () => {
|
|
131
|
-
getMeshId.
|
|
131
|
+
getMeshId.mockRejectedValueOnce(new Error('getMeshId failed'));
|
|
132
132
|
const runResult = GetCommand.run();
|
|
133
133
|
|
|
134
134
|
return runResult.catch(err => {
|
|
@@ -95,7 +95,7 @@ describe('Workspace init command tests', () => {
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('Command should pass with no flags', async () => {
|
|
98
|
-
parseSpy.
|
|
98
|
+
parseSpy.mockResolvedValueOnce({
|
|
99
99
|
args: {
|
|
100
100
|
projectName: mockProjectName,
|
|
101
101
|
},
|
|
@@ -103,7 +103,7 @@ describe('Workspace init command tests', () => {
|
|
|
103
103
|
path: './template',
|
|
104
104
|
},
|
|
105
105
|
});
|
|
106
|
-
promptSelect.
|
|
106
|
+
promptSelect.mockResolvedValueOnce('yarn');
|
|
107
107
|
await InitCommand.run();
|
|
108
108
|
expect(promptConfirm).toHaveBeenCalled();
|
|
109
109
|
expect(promptSelect).toHaveBeenCalled();
|
|
@@ -121,7 +121,7 @@ describe('Workspace init command tests', () => {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
test('Command should pass and create git project if git flag is provided', async () => {
|
|
124
|
-
parseSpy.
|
|
124
|
+
parseSpy.mockResolvedValueOnce({
|
|
125
125
|
args: {
|
|
126
126
|
projectName: mockProjectName,
|
|
127
127
|
},
|
|
@@ -149,7 +149,7 @@ describe('Workspace init command tests', () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
test('Command should fail if git flag is provided and git init fails', async () => {
|
|
152
|
-
parseSpy.
|
|
152
|
+
parseSpy.mockResolvedValueOnce({
|
|
153
153
|
args: {
|
|
154
154
|
projectName: mockProjectName,
|
|
155
155
|
},
|
|
@@ -178,7 +178,7 @@ describe('Workspace init command tests', () => {
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
test('Command should pass and create yarn project if yarn is package manager', async () => {
|
|
181
|
-
parseSpy.
|
|
181
|
+
parseSpy.mockResolvedValueOnce({
|
|
182
182
|
args: {
|
|
183
183
|
projectName: mockProjectName,
|
|
184
184
|
},
|
|
@@ -203,7 +203,7 @@ describe('Workspace init command tests', () => {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
test('Command should pass and create yarn + git project if yarn is package manager and git flag is set', async () => {
|
|
206
|
-
parseSpy.
|
|
206
|
+
parseSpy.mockResolvedValueOnce({
|
|
207
207
|
args: {
|
|
208
208
|
projectName: mockProjectName,
|
|
209
209
|
},
|
|
@@ -227,7 +227,7 @@ describe('Workspace init command tests', () => {
|
|
|
227
227
|
});
|
|
228
228
|
|
|
229
229
|
test('Command should pass with creating the sub directory if the directory already exists', async () => {
|
|
230
|
-
parseSpy.
|
|
230
|
+
parseSpy.mockResolvedValueOnce({
|
|
231
231
|
args: {
|
|
232
232
|
projectName: mockProjectName,
|
|
233
233
|
},
|
|
@@ -237,7 +237,7 @@ describe('Workspace init command tests', () => {
|
|
|
237
237
|
packageManager: mockPMDefaultFlag,
|
|
238
238
|
},
|
|
239
239
|
});
|
|
240
|
-
access.
|
|
240
|
+
access.mockResolvedValueOnce({});
|
|
241
241
|
|
|
242
242
|
await InitCommand.run();
|
|
243
243
|
|
|
@@ -252,7 +252,7 @@ describe('Workspace init command tests', () => {
|
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
test('Command should fail if the directory already exists and sub directory of project name exists', async () => {
|
|
255
|
-
parseSpy.
|
|
255
|
+
parseSpy.mockResolvedValueOnce({
|
|
256
256
|
args: {
|
|
257
257
|
projectName: mockProjectName,
|
|
258
258
|
},
|
|
@@ -262,7 +262,7 @@ describe('Workspace init command tests', () => {
|
|
|
262
262
|
packageManager: mockPMDefaultFlag,
|
|
263
263
|
},
|
|
264
264
|
});
|
|
265
|
-
access.
|
|
265
|
+
access.mockResolvedValueOnce({});
|
|
266
266
|
mkdir.mockRejectedValue(new Error());
|
|
267
267
|
|
|
268
268
|
await expect(InitCommand.run()).rejects.toThrow();
|
|
@@ -280,7 +280,7 @@ describe('Workspace init command tests', () => {
|
|
|
280
280
|
});
|
|
281
281
|
|
|
282
282
|
test('Command should fail if directory creation fails', async () => {
|
|
283
|
-
parseSpy.
|
|
283
|
+
parseSpy.mockResolvedValueOnce({
|
|
284
284
|
args: {
|
|
285
285
|
projectName: mockProjectName,
|
|
286
286
|
},
|
|
@@ -306,7 +306,7 @@ describe('Workspace init command tests', () => {
|
|
|
306
306
|
});
|
|
307
307
|
|
|
308
308
|
test('Command should fail if npm install fails', async () => {
|
|
309
|
-
parseSpy.
|
|
309
|
+
parseSpy.mockResolvedValueOnce({
|
|
310
310
|
args: {
|
|
311
311
|
projectName: mockProjectName,
|
|
312
312
|
},
|
|
@@ -333,7 +333,7 @@ describe('Workspace init command tests', () => {
|
|
|
333
333
|
});
|
|
334
334
|
|
|
335
335
|
test('Command should fail if yarn install fails', async () => {
|
|
336
|
-
parseSpy.
|
|
336
|
+
parseSpy.mockResolvedValueOnce({
|
|
337
337
|
args: {
|
|
338
338
|
projectName: mockProjectName,
|
|
339
339
|
},
|
|
@@ -360,7 +360,7 @@ describe('Workspace init command tests', () => {
|
|
|
360
360
|
});
|
|
361
361
|
|
|
362
362
|
test('Command should exit if sub directory prompt is provided with no', async () => {
|
|
363
|
-
parseSpy.
|
|
363
|
+
parseSpy.mockResolvedValueOnce({
|
|
364
364
|
args: {
|
|
365
365
|
projectName: mockProjectName,
|
|
366
366
|
},
|
|
@@ -373,7 +373,7 @@ describe('Workspace init command tests', () => {
|
|
|
373
373
|
// create workspace prompt
|
|
374
374
|
promptConfirm.mockResolvedValueOnce(true);
|
|
375
375
|
// access passes
|
|
376
|
-
access.
|
|
376
|
+
access.mockResolvedValueOnce({});
|
|
377
377
|
// create in sub directory prompt
|
|
378
378
|
promptConfirm.mockResolvedValueOnce(false);
|
|
379
379
|
await InitCommand.run();
|
|
@@ -383,8 +383,8 @@ describe('Workspace init command tests', () => {
|
|
|
383
383
|
});
|
|
384
384
|
|
|
385
385
|
test('test createPackageJson', async () => {
|
|
386
|
-
jest.spyOn(fs, 'readFile').
|
|
387
|
-
jest.spyOn(fs, 'writeFile').
|
|
386
|
+
jest.spyOn(fs, 'readFile').mockResolvedValueOnce({});
|
|
387
|
+
jest.spyOn(fs, 'writeFile').mockResolvedValueOnce({});
|
|
388
388
|
|
|
389
389
|
await expect(InitCommand.prototype.createPackageJson()).resolves;
|
|
390
390
|
});
|
|
@@ -89,7 +89,7 @@ describe('update command tests', () => {
|
|
|
89
89
|
],
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
|
-
readFile.
|
|
92
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
93
93
|
|
|
94
94
|
parseSpy.mockResolvedValueOnce({
|
|
95
95
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -148,7 +148,7 @@ describe('update command tests', () => {
|
|
|
148
148
|
],
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
|
-
readFile.
|
|
151
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
152
152
|
|
|
153
153
|
parseSpy.mockResolvedValueOnce({
|
|
154
154
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -207,7 +207,7 @@ describe('update command tests', () => {
|
|
|
207
207
|
],
|
|
208
208
|
},
|
|
209
209
|
};
|
|
210
|
-
readFile.
|
|
210
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
211
211
|
|
|
212
212
|
parseSpy.mockResolvedValueOnce({
|
|
213
213
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -267,7 +267,7 @@ describe('update command tests', () => {
|
|
|
267
267
|
],
|
|
268
268
|
},
|
|
269
269
|
};
|
|
270
|
-
readFile.
|
|
270
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
271
271
|
|
|
272
272
|
parseSpy.mockResolvedValueOnce({
|
|
273
273
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -277,7 +277,7 @@ describe('update command tests', () => {
|
|
|
277
277
|
},
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
getMeshId.
|
|
280
|
+
getMeshId.mockResolvedValueOnce(null);
|
|
281
281
|
const runResult = UpdateCommand.run();
|
|
282
282
|
|
|
283
283
|
await expect(runResult).rejects.toMatchInlineSnapshot(
|
|
@@ -308,7 +308,7 @@ describe('update command tests', () => {
|
|
|
308
308
|
],
|
|
309
309
|
},
|
|
310
310
|
};
|
|
311
|
-
readFile.
|
|
311
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
312
312
|
|
|
313
313
|
parseSpy.mockResolvedValueOnce({
|
|
314
314
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -349,7 +349,7 @@ describe('update command tests', () => {
|
|
|
349
349
|
],
|
|
350
350
|
},
|
|
351
351
|
};
|
|
352
|
-
readFile.
|
|
352
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
353
353
|
|
|
354
354
|
parseSpy.mockResolvedValueOnce({
|
|
355
355
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -451,7 +451,7 @@ describe('update command tests', () => {
|
|
|
451
451
|
],
|
|
452
452
|
},
|
|
453
453
|
};
|
|
454
|
-
readFile.
|
|
454
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
455
455
|
|
|
456
456
|
parseSpy.mockResolvedValueOnce({
|
|
457
457
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
@@ -500,7 +500,7 @@ describe('update command tests', () => {
|
|
|
500
500
|
],
|
|
501
501
|
},
|
|
502
502
|
};
|
|
503
|
-
readFile.
|
|
503
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
504
504
|
|
|
505
505
|
let meshConfig = {
|
|
506
506
|
sources: [
|
|
@@ -530,12 +530,12 @@ describe('update command tests', () => {
|
|
|
530
530
|
],
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
-
updateMesh.
|
|
533
|
+
updateMesh.mockResolvedValueOnce({
|
|
534
534
|
meshId: 'dummy_mesh_id',
|
|
535
535
|
meshConfig: meshConfig,
|
|
536
536
|
});
|
|
537
537
|
|
|
538
|
-
parseSpy.
|
|
538
|
+
parseSpy.mockResolvedValueOnce({
|
|
539
539
|
args: { file: 'src/commands/__fixtures__/sample_mesh_files.json' },
|
|
540
540
|
flags: {
|
|
541
541
|
autoConfirmAction: mockAutoApproveAction,
|
|
@@ -645,9 +645,9 @@ describe('update command tests', () => {
|
|
|
645
645
|
],
|
|
646
646
|
},
|
|
647
647
|
};
|
|
648
|
-
readFile.
|
|
648
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
649
649
|
|
|
650
|
-
parseSpy.
|
|
650
|
+
parseSpy.mockResolvedValueOnce({
|
|
651
651
|
args: { file: 'src/commands/__fixtures__/sample_mesh_invalid_file_name.json' },
|
|
652
652
|
flags: {
|
|
653
653
|
ignoreCache: mockIgnoreCacheFlag,
|
|
@@ -700,9 +700,9 @@ describe('update command tests', () => {
|
|
|
700
700
|
],
|
|
701
701
|
},
|
|
702
702
|
};
|
|
703
|
-
readFile.
|
|
703
|
+
readFile.mockResolvedValueOnce(JSON.stringify(sampleMesh));
|
|
704
704
|
|
|
705
|
-
parseSpy.
|
|
705
|
+
parseSpy.mockResolvedValueOnce({
|
|
706
706
|
args: { file: 'src/commands/__fixtures__/sample_mesh_files.json' },
|
|
707
707
|
flags: {
|
|
708
708
|
ignoreCache: mockIgnoreCacheFlag,
|
|
@@ -10,7 +10,6 @@ governing permissions and limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const { Command } = require('@oclif/core');
|
|
13
|
-
|
|
14
13
|
const { initSdk, initRequestId, promptConfirm, importFiles } = require('../../helpers');
|
|
15
14
|
const logger = require('../../classes/logger');
|
|
16
15
|
const CONSTANTS = require('../../constants');
|
|
@@ -24,14 +23,9 @@ const {
|
|
|
24
23
|
readFileContents,
|
|
25
24
|
validateAndInterpolateMesh,
|
|
26
25
|
} = require('../../utils');
|
|
27
|
-
const {
|
|
28
|
-
getMesh,
|
|
29
|
-
createMesh,
|
|
30
|
-
createAPIMeshCredentials,
|
|
31
|
-
subscribeCredentialToMeshService,
|
|
32
|
-
} = require('../../lib/devConsole');
|
|
26
|
+
const { getMesh, createMesh } = require('../../lib/devConsole');
|
|
33
27
|
|
|
34
|
-
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL } = CONSTANTS;
|
|
28
|
+
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL, TMOConstants } = CONSTANTS;
|
|
35
29
|
|
|
36
30
|
class CreateCommand extends Command {
|
|
37
31
|
static args = [{ name: 'file' }];
|
|
@@ -110,9 +104,7 @@ class CreateCommand extends Command {
|
|
|
110
104
|
|
|
111
105
|
if (shouldContinue) {
|
|
112
106
|
try {
|
|
113
|
-
const mesh = await createMesh(imsOrgId, projectId, workspaceId, data);
|
|
114
|
-
|
|
115
|
-
let sdkList = [];
|
|
107
|
+
const { mesh, apiKey, sdkList } = await createMesh(imsOrgId, projectId, workspaceId, data);
|
|
116
108
|
|
|
117
109
|
if (mesh) {
|
|
118
110
|
this.log(
|
|
@@ -128,28 +120,11 @@ class CreateCommand extends Command {
|
|
|
128
120
|
'******************************************************************************************************',
|
|
129
121
|
);
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
imsOrgId,
|
|
134
|
-
projectId,
|
|
135
|
-
workspaceId,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
if (adobeIdIntegrationsForWorkspace) {
|
|
139
|
-
this.log('Successfully created API Key %s', adobeIdIntegrationsForWorkspace.apiKey);
|
|
140
|
-
// subscribe the credential to API mesh service
|
|
141
|
-
sdkList = await subscribeCredentialToMeshService(
|
|
142
|
-
imsOrgId,
|
|
143
|
-
projectId,
|
|
144
|
-
workspaceId,
|
|
145
|
-
adobeIdIntegrationsForWorkspace.id,
|
|
146
|
-
);
|
|
123
|
+
if (apiKey) {
|
|
124
|
+
this.log('Successfully created API Key %s', apiKey);
|
|
147
125
|
|
|
148
126
|
if (sdkList) {
|
|
149
|
-
this.log(
|
|
150
|
-
'Successfully subscribed API Key %s to API Mesh service',
|
|
151
|
-
adobeIdIntegrationsForWorkspace.apiKey,
|
|
152
|
-
);
|
|
127
|
+
this.log('Successfully subscribed API Key %s to API Mesh service', apiKey);
|
|
153
128
|
|
|
154
129
|
const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, mesh.meshId);
|
|
155
130
|
const meshUrl =
|
|
@@ -157,23 +132,28 @@ class CreateCommand extends Command {
|
|
|
157
132
|
? MULTITENANT_GRAPHQL_SERVER_BASE_URL
|
|
158
133
|
: meshURL;
|
|
159
134
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
135
|
+
if (
|
|
136
|
+
meshUrl === TMOConstants.TMO_STAGE_URL ||
|
|
137
|
+
meshUrl === TMOConstants.TMO_SANDBOX_URL ||
|
|
138
|
+
meshUrl === TMOConstants.TMO_PROD_URL
|
|
139
|
+
) {
|
|
140
|
+
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${mesh.meshId}/graphql`);
|
|
141
|
+
} else {
|
|
142
|
+
this.log(
|
|
143
|
+
'Mesh Endpoint: %s\n',
|
|
144
|
+
`${meshUrl}/${mesh.meshId}/graphql?api_key=${apiKey}`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
164
147
|
} else {
|
|
165
|
-
this.log(
|
|
166
|
-
'Unable to subscribe API Key %s to API Mesh service',
|
|
167
|
-
adobeIdIntegrationsForWorkspace.apiKey,
|
|
168
|
-
);
|
|
148
|
+
this.log('Unable to subscribe API Key %s to API Mesh service', apiKey);
|
|
169
149
|
}
|
|
170
150
|
} else {
|
|
171
151
|
this.log('Unable to create API Key');
|
|
172
152
|
}
|
|
173
|
-
//
|
|
174
|
-
//
|
|
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"
|
|
175
155
|
return {
|
|
176
|
-
|
|
156
|
+
apiKey,
|
|
177
157
|
sdkList,
|
|
178
158
|
mesh,
|
|
179
159
|
};
|
|
@@ -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 } = CONSTANTS;
|
|
22
|
+
const { MULTITENANT_GRAPHQL_SERVER_BASE_URL, TMOConstants } = CONSTANTS;
|
|
23
23
|
|
|
24
24
|
class DescribeCommand extends Command {
|
|
25
25
|
static flags = {
|
|
@@ -55,11 +55,17 @@ class DescribeCommand extends Command {
|
|
|
55
55
|
const { meshURL } = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
56
56
|
const meshUrl = meshURL === '' ? MULTITENANT_GRAPHQL_SERVER_BASE_URL : meshURL;
|
|
57
57
|
|
|
58
|
-
if (
|
|
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) {
|
|
59
66
|
this.log('API Key: %s', apiKey);
|
|
60
67
|
this.log('Mesh Endpoint: %s\n', `${meshUrl}/${meshId}/graphql?api_key=${apiKey}`);
|
|
61
68
|
}
|
|
62
|
-
|
|
63
69
|
return meshDetails;
|
|
64
70
|
} else {
|
|
65
71
|
logger.error(
|
package/src/constants.js
CHANGED
|
@@ -19,5 +19,10 @@ 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
|
-
|
|
22
|
+
const TMOConstants = {
|
|
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
|
+
};
|
|
27
|
+
const envConstants = clientEnv === 'stage' ? StageConstants : ProdConstants;
|
|
28
|
+
module.exports = { ...envConstants, TMOConstants };
|
package/src/lib/devConsole.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
package/src/utils.js
CHANGED
|
@@ -79,7 +79,7 @@ function getFilesInMeshConfig(data, meshConfigName) {
|
|
|
79
79
|
|
|
80
80
|
// Additional Resolvers
|
|
81
81
|
data.meshConfig.additionalResolvers?.forEach(additionalResolver => {
|
|
82
|
-
if (!fileURLRegex.test(additionalResolver)) {
|
|
82
|
+
if (typeof additionalResolver === 'string' && !fileURLRegex.test(additionalResolver)) {
|
|
83
83
|
filesList.push(additionalResolver);
|
|
84
84
|
}
|
|
85
85
|
});
|