@adobe/aio-cli-plugin-api-mesh 5.2.3 → 5.2.4-alpha.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 +4 -2
- package/src/commands/api-mesh/__tests__/cache-purge.test.js +3 -4
- package/src/commands/api-mesh/__tests__/create.test.js +4 -19
- package/src/commands/api-mesh/__tests__/delete-log-forwarding.test.js +106 -0
- package/src/commands/api-mesh/__tests__/delete.test.js +3 -4
- package/src/commands/api-mesh/__tests__/describe.test.js +3 -5
- package/src/commands/api-mesh/__tests__/get-log-forwarding.test.js +149 -0
- package/src/commands/api-mesh/__tests__/get.test.js +4 -4
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +21 -215
- package/src/commands/api-mesh/__tests__/log-get.test.js +2 -2
- package/src/commands/api-mesh/__tests__/log-list.test.js +2 -2
- package/src/commands/api-mesh/__tests__/run.test.js +2 -2
- package/src/commands/api-mesh/__tests__/set-log-forwarding.test.js +246 -0
- package/src/commands/api-mesh/__tests__/status.test.js +2 -2
- package/src/commands/api-mesh/__tests__/update.test.js +6 -7
- package/src/commands/api-mesh/cache/purge.js +2 -4
- package/src/commands/api-mesh/config/delete/log-forwarding.js +80 -0
- package/src/commands/api-mesh/config/get/log-forwarding.js +78 -0
- package/src/commands/api-mesh/config/set/log-forwarding.js +156 -0
- package/src/commands/api-mesh/create.js +21 -4
- package/src/commands/api-mesh/delete.js +2 -4
- package/src/commands/api-mesh/describe.js +2 -4
- package/src/commands/api-mesh/get.js +2 -4
- package/src/commands/api-mesh/log-get-bulk.js +6 -27
- package/src/commands/api-mesh/log-get.js +2 -4
- package/src/commands/api-mesh/log-list.js +2 -4
- package/src/commands/api-mesh/run.js +2 -9
- package/src/commands/api-mesh/source/__tests__/install.test.js +2 -2
- package/src/commands/api-mesh/source/discover.js +2 -9
- package/src/commands/api-mesh/source/get.js +1 -8
- package/src/commands/api-mesh/source/install.js +2 -3
- package/src/commands/api-mesh/status.js +2 -3
- package/src/commands/api-mesh/update.js +20 -4
- package/src/helpers.js +72 -5
- package/src/hooks/initMetadata.js +8 -0
- package/src/lib/{devConsole.js → smsClient.js} +299 -0
- package/src/utils.js +60 -22
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.2.3","commands":{"api-mesh":{"id":"api-mesh","description":"Create, run, test, and deploy API Mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"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"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"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:log-get-bulk":{"id":"api-mesh:log-get-bulk","description":"Download all mesh logs for a selected time period.","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},"startTime":{"name":"startTime","type":"option","description":"Start time for the logs in UTC"},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC"},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true},"past":{"name":"past","type":"option","description":"Past time window in mins"},"from":{"name":"from","type":"option","description":"The from time in YYYY-MM-DD:HH:MM:SS format based on your system's time zone. It is used to fetch logs from the past and is the starting time for the past time duration."}},"args":[]},"api-mesh:log-get":{"id":"api-mesh:log-get","description":"Get the Log of a given mesh by RayId","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":[{"name":"rayId","description":"Fetch a single log by rayID","required":true}]},"api-mesh:log-list":{"id":"api-mesh:log-list","description":"Get recent logs of requests made to the API 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},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server","default":5000},"inspectPort":{"name":"inspectPort","type":"option","char":"i","description":"Port number for the local dev server inspector","default":9229},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"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},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file","description":"Mesh File"}]},"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"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:cache:purge":{"id":"api-mesh:cache:purge","description":"Cache purge for 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},"all":{"name":"all","type":"boolean","char":"a","description":"Purge all cache. CLI will purge all cache data.","required":true,"allowNo":false}},"args":[]},"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":"5.2.4-alpha.1","commands":{"api-mesh":{"id":"api-mesh","description":"Create, run, test, and deploy API Mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"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"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"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:log-get-bulk":{"id":"api-mesh:log-get-bulk","description":"Download all mesh logs for a selected time period.","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},"startTime":{"name":"startTime","type":"option","description":"Start time for the logs in UTC"},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC"},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true},"past":{"name":"past","type":"option","description":"Past time window in minutes"}},"args":[]},"api-mesh:log-get":{"id":"api-mesh:log-get","description":"Get the Log of a given mesh by RayId","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":[{"name":"rayId","description":"Fetch a single log by rayID","required":true}]},"api-mesh:log-list":{"id":"api-mesh:log-list","description":"Get recent logs of requests made to the API 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},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server","default":5000},"inspectPort":{"name":"inspectPort","type":"option","char":"i","description":"Port number for the local dev server inspector","default":9229},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"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},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file","description":"Mesh File"}]},"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"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:cache:purge":{"id":"api-mesh:cache:purge","description":"Cache purge for 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},"all":{"name":"all","type":"boolean","char":"a","description":"Purge all cache. CLI will purge all cache data.","required":true,"allowNo":false}},"args":[]},"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"}]},"api-mesh:config:delete:log-forwarding":{"id":"api-mesh:config:delete:log-forwarding","description":"Delete log forwarding details for 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:config:get:log-forwarding":{"id":"api-mesh:config:get:log-forwarding","description":"Get log forwarding details for 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":[]},"api-mesh:config:set:log-forwarding":{"id":"api-mesh:config:set:log-forwarding","description":"Sets the log forwarding destination for API mesh. \n- Select a log forwarding destination - Choose from available options (for example, New Relic).\n- Enter the base URI - Provide the URI for the log forwarding service. Ensure it includes the protocol (for example, if the hosted region of the New Relic account is the U.S, the base URI could be 'https://log-api.newrelic.com/log/v1').\n- Enter the license key - Provide the INGEST-LICENSE API key type.","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}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/aio-cli-plugin-api-mesh",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4-alpha.1",
|
|
4
4
|
"description": "Adobe I/O CLI plugin to develop and manage API mesh sources",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oclif-plugin"
|
|
@@ -91,7 +91,6 @@
|
|
|
91
91
|
"jsmin": "1.0.1",
|
|
92
92
|
"json-interpolate": "^1.0.3",
|
|
93
93
|
"lru-cache": "^7.14.1",
|
|
94
|
-
"ms": "^2.1.3",
|
|
95
94
|
"node-clipboardy": "^1.0.3",
|
|
96
95
|
"node-fetch": "2.6.1",
|
|
97
96
|
"pino": "^9.5.0",
|
|
@@ -147,6 +146,9 @@
|
|
|
147
146
|
"@oclif/plugin-help"
|
|
148
147
|
],
|
|
149
148
|
"hooks": {
|
|
149
|
+
"init": [
|
|
150
|
+
"./src/hooks/initMetadata.js"
|
|
151
|
+
],
|
|
150
152
|
"prerun": [
|
|
151
153
|
"./src/hooks/versionCompare.js"
|
|
152
154
|
]
|
|
@@ -23,20 +23,20 @@ jest.mock('../../../helpers', () => ({
|
|
|
23
23
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
24
24
|
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
25
25
|
}));
|
|
26
|
-
jest.mock('../../../lib/
|
|
26
|
+
jest.mock('../../../lib/smsClient');
|
|
27
27
|
const mockConsoleCLIInstance = {};
|
|
28
28
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
29
29
|
const selectedProject = { id: '5678', title: 'Project01' };
|
|
30
30
|
const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
31
31
|
const CachePurgeCommand = require('../cache/purge');
|
|
32
|
-
const { initSdk,
|
|
32
|
+
const { initSdk, promptConfirm } = require('../../../helpers');
|
|
33
33
|
const {
|
|
34
34
|
getMeshId,
|
|
35
35
|
deleteMesh,
|
|
36
36
|
getApiKeyCredential,
|
|
37
37
|
unsubscribeCredentialFromMeshService,
|
|
38
38
|
cachePurge,
|
|
39
|
-
} = require('../../../lib/
|
|
39
|
+
} = require('../../../lib/smsClient');
|
|
40
40
|
let logSpy = null;
|
|
41
41
|
let errorLogSpy = null;
|
|
42
42
|
let parseSpy = null;
|
|
@@ -229,7 +229,6 @@ describe('cache purge command tests', () => {
|
|
|
229
229
|
cachePurge.mockResolvedValueOnce({ success: true });
|
|
230
230
|
const runResult = await CachePurgeCommand.run();
|
|
231
231
|
|
|
232
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
233
232
|
expect(runResult).toMatchInlineSnapshot(`
|
|
234
233
|
{
|
|
235
234
|
"success": true,
|
|
@@ -27,24 +27,18 @@ jest.mock('../../../helpers', () => ({
|
|
|
27
27
|
interpolateMesh: jest.fn().mockResolvedValue({}),
|
|
28
28
|
importFiles: jest.fn().mockResolvedValue(),
|
|
29
29
|
}));
|
|
30
|
-
jest.mock('../../../lib/
|
|
30
|
+
jest.mock('../../../lib/smsClient');
|
|
31
31
|
|
|
32
32
|
const CreateCommand = require('../create');
|
|
33
33
|
const sampleCreateMeshConfig = require('../../__fixtures__/sample_mesh.json');
|
|
34
34
|
const meshConfigWithComposerFiles = require('../../__fixtures__/sample_mesh_with_composer_files.json');
|
|
35
|
-
const {
|
|
36
|
-
initSdk,
|
|
37
|
-
initRequestId,
|
|
38
|
-
promptConfirm,
|
|
39
|
-
interpolateMesh,
|
|
40
|
-
importFiles,
|
|
41
|
-
} = require('../../../helpers');
|
|
35
|
+
const { initSdk, promptConfirm, interpolateMesh, importFiles } = require('../../../helpers');
|
|
42
36
|
const {
|
|
43
37
|
getMesh,
|
|
44
38
|
createMesh,
|
|
45
39
|
getTenantFeatures,
|
|
46
40
|
getPublicEncryptionKey,
|
|
47
|
-
} = require('../../../lib/
|
|
41
|
+
} = require('../../../lib/smsClient');
|
|
48
42
|
|
|
49
43
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
50
44
|
|
|
@@ -69,7 +63,7 @@ jest.mock('../../../helpers', () => ({
|
|
|
69
63
|
interpolateMesh: jest.fn().mockResolvedValue({}),
|
|
70
64
|
importFiles: jest.fn().mockResolvedValue({}),
|
|
71
65
|
}));
|
|
72
|
-
jest.mock('../../../lib/
|
|
66
|
+
jest.mock('../../../lib/smsClient');
|
|
73
67
|
jest.mock('chalk', () => ({
|
|
74
68
|
red: jest.fn(text => text), // Return the input text without any color formatting
|
|
75
69
|
bold: jest.fn(text => text),
|
|
@@ -340,7 +334,6 @@ describe('create command tests', () => {
|
|
|
340
334
|
test('should create if a valid mesh config file is provided', async () => {
|
|
341
335
|
const runResult = await CreateCommand.run();
|
|
342
336
|
|
|
343
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
344
337
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
345
338
|
[
|
|
346
339
|
"CODE1234@AdobeOrg",
|
|
@@ -422,7 +415,6 @@ describe('create command tests', () => {
|
|
|
422
415
|
|
|
423
416
|
const runResult = await CreateCommand.run();
|
|
424
417
|
|
|
425
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
426
418
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
427
419
|
[
|
|
428
420
|
"CODE1234@AdobeOrg",
|
|
@@ -557,7 +549,6 @@ describe('create command tests', () => {
|
|
|
557
549
|
|
|
558
550
|
await CreateCommand.run();
|
|
559
551
|
|
|
560
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
561
552
|
expect(promptConfirm).not.toHaveBeenCalled();
|
|
562
553
|
expect(initSdk).toHaveBeenCalledWith({
|
|
563
554
|
ignoreCache: true,
|
|
@@ -594,7 +585,6 @@ describe('create command tests', () => {
|
|
|
594
585
|
|
|
595
586
|
await CreateCommand.run();
|
|
596
587
|
|
|
597
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
598
588
|
expect(promptConfirm).toHaveBeenCalled();
|
|
599
589
|
expect(initSdk).toHaveBeenCalledWith({
|
|
600
590
|
ignoreCache: true,
|
|
@@ -902,7 +892,6 @@ describe('create command tests', () => {
|
|
|
902
892
|
|
|
903
893
|
const output = await CreateCommand.run();
|
|
904
894
|
|
|
905
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
906
895
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
907
896
|
[
|
|
908
897
|
"CODE1234@AdobeOrg",
|
|
@@ -1164,7 +1153,6 @@ describe('create command tests', () => {
|
|
|
1164
1153
|
|
|
1165
1154
|
const output = await CreateCommand.run();
|
|
1166
1155
|
|
|
1167
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
1168
1156
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1169
1157
|
[
|
|
1170
1158
|
"1234",
|
|
@@ -1292,7 +1280,6 @@ describe('create command tests', () => {
|
|
|
1292
1280
|
|
|
1293
1281
|
const output = await CreateCommand.run();
|
|
1294
1282
|
|
|
1295
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
1296
1283
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1297
1284
|
[
|
|
1298
1285
|
"1234",
|
|
@@ -1422,7 +1409,6 @@ describe('create command tests', () => {
|
|
|
1422
1409
|
|
|
1423
1410
|
const output = await CreateCommand.run();
|
|
1424
1411
|
|
|
1425
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
1426
1412
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1427
1413
|
[
|
|
1428
1414
|
"CODE1234@AdobeOrg",
|
|
@@ -1552,7 +1538,6 @@ describe('create command tests', () => {
|
|
|
1552
1538
|
|
|
1553
1539
|
const output = await CreateCommand.run();
|
|
1554
1540
|
|
|
1555
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
1556
1541
|
expect(createMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
1557
1542
|
[
|
|
1558
1543
|
"CODE1234@AdobeOrg",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const DeleteLogForwardingCommand = require('../config/delete/log-forwarding');
|
|
14
|
+
const { initSdk, promptConfirm } = require('../../../helpers');
|
|
15
|
+
const { getMeshId, deleteLogForwarding } = require('../../../lib/smsClient');
|
|
16
|
+
|
|
17
|
+
jest.mock('../../../helpers', () => ({
|
|
18
|
+
initSdk: jest.fn().mockResolvedValue({}),
|
|
19
|
+
initRequestId: jest.fn().mockResolvedValue({}),
|
|
20
|
+
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
21
|
+
}));
|
|
22
|
+
jest.mock('../../../lib/smsClient');
|
|
23
|
+
|
|
24
|
+
let logSpy, errorLogSpy, parseSpy;
|
|
25
|
+
|
|
26
|
+
describe('delete log forwarding command tests', () => {
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
initSdk.mockResolvedValue({
|
|
29
|
+
imsOrgCode: 'mockOrgCode',
|
|
30
|
+
projectId: 'mockProjectId',
|
|
31
|
+
workspaceId: 'mockWorkspaceId',
|
|
32
|
+
workspaceName: 'mockWorkspaceName',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
getMeshId.mockResolvedValue('mockMeshId');
|
|
36
|
+
deleteLogForwarding.mockResolvedValue();
|
|
37
|
+
|
|
38
|
+
global.requestId = 'dummy_request_id';
|
|
39
|
+
|
|
40
|
+
logSpy = jest.spyOn(DeleteLogForwardingCommand.prototype, 'log');
|
|
41
|
+
errorLogSpy = jest.spyOn(DeleteLogForwardingCommand.prototype, 'error');
|
|
42
|
+
parseSpy = jest.spyOn(DeleteLogForwardingCommand.prototype, 'parse');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
jest.clearAllMocks();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('should fail if mesh ID is not found', async () => {
|
|
50
|
+
getMeshId.mockResolvedValueOnce(null);
|
|
51
|
+
|
|
52
|
+
await expect(DeleteLogForwardingCommand.run()).rejects.toThrow(
|
|
53
|
+
'Unable to delete log forwarding details. No mesh found for Org(mockOrgCode) -> Project(mockProjectId) -> Workspace(mockWorkspaceId). Check the details and try again.',
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(logSpy).not.toHaveBeenCalled();
|
|
57
|
+
expect(errorLogSpy).toHaveBeenCalledWith(
|
|
58
|
+
'Unable to delete log forwarding details. No mesh found for Org(mockOrgCode) -> Project(mockProjectId) -> Workspace(mockWorkspaceId). Check the details and try again.',
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('should skip confirmation if autoConfirmAction is set', async () => {
|
|
63
|
+
parseSpy.mockResolvedValueOnce({
|
|
64
|
+
flags: {
|
|
65
|
+
ignoreCache: false,
|
|
66
|
+
autoConfirmAction: true,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await DeleteLogForwardingCommand.run();
|
|
71
|
+
|
|
72
|
+
expect(promptConfirm).not.toHaveBeenCalled();
|
|
73
|
+
expect(deleteLogForwarding).toHaveBeenCalledWith(
|
|
74
|
+
'mockOrgCode',
|
|
75
|
+
'mockProjectId',
|
|
76
|
+
'mockWorkspaceId',
|
|
77
|
+
'mockMeshId',
|
|
78
|
+
);
|
|
79
|
+
expect(logSpy).toHaveBeenCalledWith('Successfully deleted log forwarding details');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('should fail if deleteLogForwarding throws an error', async () => {
|
|
83
|
+
deleteLogForwarding.mockRejectedValueOnce(new Error('Deletion failed'));
|
|
84
|
+
|
|
85
|
+
await expect(DeleteLogForwardingCommand.run()).rejects.toThrow(
|
|
86
|
+
'Unable to delete log forwarding details. Try again. RequestId: dummy_request_id',
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(logSpy).not.toHaveBeenCalledWith('Successfully deleted log forwarding details');
|
|
90
|
+
expect(errorLogSpy).toHaveBeenCalledWith(
|
|
91
|
+
'Unable to delete log forwarding details. Try again. RequestId: dummy_request_id',
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('should delete log forwarding details successfully', async () => {
|
|
96
|
+
await DeleteLogForwardingCommand.run();
|
|
97
|
+
|
|
98
|
+
expect(deleteLogForwarding).toHaveBeenCalledWith(
|
|
99
|
+
'mockOrgCode',
|
|
100
|
+
'mockProjectId',
|
|
101
|
+
'mockWorkspaceId',
|
|
102
|
+
'mockMeshId',
|
|
103
|
+
);
|
|
104
|
+
expect(logSpy).toHaveBeenCalledWith('Successfully deleted log forwarding details');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -23,7 +23,7 @@ jest.mock('../../../helpers', () => ({
|
|
|
23
23
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
24
24
|
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
25
25
|
}));
|
|
26
|
-
jest.mock('../../../lib/
|
|
26
|
+
jest.mock('../../../lib/smsClient');
|
|
27
27
|
|
|
28
28
|
const mockConsoleCLIInstance = {};
|
|
29
29
|
|
|
@@ -34,13 +34,13 @@ const selectedProject = { id: '5678', title: 'Project01' };
|
|
|
34
34
|
const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
35
35
|
|
|
36
36
|
const DeleteCommand = require('../delete');
|
|
37
|
-
const { initSdk,
|
|
37
|
+
const { initSdk, promptConfirm } = require('../../../helpers');
|
|
38
38
|
const {
|
|
39
39
|
getMeshId,
|
|
40
40
|
deleteMesh,
|
|
41
41
|
getApiKeyCredential,
|
|
42
42
|
unsubscribeCredentialFromMeshService,
|
|
43
|
-
} = require('../../../lib/
|
|
43
|
+
} = require('../../../lib/smsClient');
|
|
44
44
|
|
|
45
45
|
let logSpy = null;
|
|
46
46
|
let errorLogSpy = null;
|
|
@@ -203,7 +203,6 @@ describe('delete command tests', () => {
|
|
|
203
203
|
test('should delete mesh if correct args are provided', async () => {
|
|
204
204
|
const runResult = await DeleteCommand.run();
|
|
205
205
|
|
|
206
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
207
206
|
expect(runResult).toMatchInlineSnapshot(`
|
|
208
207
|
{
|
|
209
208
|
"status": "success",
|
|
@@ -23,7 +23,7 @@ jest.mock('@adobe/aio-cli-lib-console', () => ({
|
|
|
23
23
|
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
|
|
24
24
|
cleanStdOut: jest.fn(),
|
|
25
25
|
}));
|
|
26
|
-
jest.mock('../../../lib/
|
|
26
|
+
jest.mock('../../../lib/smsClient');
|
|
27
27
|
jest.mock('chalk', () => ({
|
|
28
28
|
bold: jest.fn(text => text), // Return the input text without any color formatting
|
|
29
29
|
underline: {
|
|
@@ -33,8 +33,8 @@ jest.mock('chalk', () => ({
|
|
|
33
33
|
}));
|
|
34
34
|
|
|
35
35
|
const DescribeCommand = require('../describe');
|
|
36
|
-
const { initSdk
|
|
37
|
-
const { describeMesh, getMesh, getTenantFeatures } = require('../../../lib/
|
|
36
|
+
const { initSdk } = require('../../../helpers');
|
|
37
|
+
const { describeMesh, getMesh, getTenantFeatures } = require('../../../lib/smsClient');
|
|
38
38
|
const sampleCreateMeshConfig = require('../../__fixtures__/sample_mesh.json');
|
|
39
39
|
|
|
40
40
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
@@ -202,7 +202,6 @@ describe('describe command tests', () => {
|
|
|
202
202
|
test('should return Non TI url if request is Non Ti', async () => {
|
|
203
203
|
const runResult = await DescribeCommand.run();
|
|
204
204
|
|
|
205
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
206
205
|
expect(describeMesh).toHaveBeenCalledWith(
|
|
207
206
|
selectedOrg.code,
|
|
208
207
|
selectedProject.id,
|
|
@@ -258,7 +257,6 @@ describe('describe command tests', () => {
|
|
|
258
257
|
getMesh.mockResolvedValue(fetchedMeshConfig);
|
|
259
258
|
const runResult = await DescribeCommand.run();
|
|
260
259
|
|
|
261
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
262
260
|
expect(describeMesh).toHaveBeenCalledWith(
|
|
263
261
|
selectedOrg.code,
|
|
264
262
|
selectedProject.id,
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const GetLogForwardingCommand = require('../config/get/log-forwarding');
|
|
14
|
+
const { initSdk, initRequestId } = require('../../../helpers');
|
|
15
|
+
const { getLogForwarding, getMeshId } = require('../../../lib/smsClient');
|
|
16
|
+
|
|
17
|
+
jest.mock('../../../helpers', () => ({
|
|
18
|
+
initSdk: jest.fn().mockResolvedValue({}),
|
|
19
|
+
initRequestId: jest.fn().mockResolvedValue({}),
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('../../../lib/smsClient');
|
|
22
|
+
jest.mock('../../../classes/logger');
|
|
23
|
+
|
|
24
|
+
describe('GetLogForwardingCommand', () => {
|
|
25
|
+
let logSpy;
|
|
26
|
+
let errorSpy;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
jest.spyOn(GetLogForwardingCommand.prototype, 'parse').mockResolvedValue({
|
|
30
|
+
flags: {
|
|
31
|
+
ignoreCache: false, // Set the default value for ignoreCache
|
|
32
|
+
json: false,
|
|
33
|
+
},
|
|
34
|
+
args: [],
|
|
35
|
+
});
|
|
36
|
+
logSpy = jest.spyOn(GetLogForwardingCommand.prototype, 'log');
|
|
37
|
+
errorSpy = jest.spyOn(GetLogForwardingCommand.prototype, 'error').mockImplementation(() => {
|
|
38
|
+
throw new Error(errorSpy.mock.calls[0][0]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
initRequestId.mockResolvedValue();
|
|
42
|
+
initSdk.mockResolvedValue({
|
|
43
|
+
imsOrgId: 'orgId',
|
|
44
|
+
imsOrgCode: 'orgCode',
|
|
45
|
+
projectId: 'projectId',
|
|
46
|
+
workspaceId: 'workspaceId',
|
|
47
|
+
workspaceName: 'workspaceName',
|
|
48
|
+
});
|
|
49
|
+
getMeshId.mockResolvedValue('meshId');
|
|
50
|
+
global.requestId = 'dummy_request_id';
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
jest.clearAllMocks();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('successfully retrieves log forwarding details', async () => {
|
|
58
|
+
const mockResponse = {
|
|
59
|
+
data: { destination: 'newrelic', config: { baseUri: 'https://example.com' } },
|
|
60
|
+
};
|
|
61
|
+
getLogForwarding.mockResolvedValue(mockResponse);
|
|
62
|
+
|
|
63
|
+
const command = new GetLogForwardingCommand([], {});
|
|
64
|
+
const result = await command.run();
|
|
65
|
+
|
|
66
|
+
expect(initRequestId).toHaveBeenCalled();
|
|
67
|
+
expect(getMeshId).toHaveBeenCalledWith('orgCode', 'projectId', 'workspaceId', 'workspaceName');
|
|
68
|
+
expect(getLogForwarding).toHaveBeenCalledWith('orgCode', 'projectId', 'workspaceId', 'meshId');
|
|
69
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
70
|
+
'Successfully retrieved log forwarding details: \n',
|
|
71
|
+
JSON.stringify(mockResponse.data, null, 2),
|
|
72
|
+
);
|
|
73
|
+
expect(result).toEqual({
|
|
74
|
+
imsOrgCode: 'orgCode',
|
|
75
|
+
projectId: 'projectId',
|
|
76
|
+
workspaceId: 'workspaceId',
|
|
77
|
+
workspaceName: 'workspaceName',
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('throws an error when getMeshId fails', async () => {
|
|
82
|
+
const errorMessage = 'Failed to fetch mesh ID';
|
|
83
|
+
getMeshId.mockRejectedValue(new Error(errorMessage));
|
|
84
|
+
|
|
85
|
+
const command = new GetLogForwardingCommand([], {});
|
|
86
|
+
await expect(command.run()).rejects.toThrow(
|
|
87
|
+
`Unable to get mesh ID. Check the details and try again. RequestId: dummy_request_id`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(logSpy).toHaveBeenCalledWith(errorMessage);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('throws an error when meshId is null', async () => {
|
|
94
|
+
getMeshId.mockResolvedValue(null);
|
|
95
|
+
|
|
96
|
+
const command = new GetLogForwardingCommand([], {});
|
|
97
|
+
await expect(command.run()).rejects.toThrow(
|
|
98
|
+
`Unable to get meshId. No mesh found for Org(orgCode) -> Project(projectId) -> Workspace(workspaceId). Check the details and try again.`,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('throws an error when getLogForwarding returns null', async () => {
|
|
103
|
+
getLogForwarding.mockResolvedValue(null);
|
|
104
|
+
|
|
105
|
+
const command = new GetLogForwardingCommand([], {});
|
|
106
|
+
await expect(command.run()).rejects.toThrow(
|
|
107
|
+
'Unable to get log forwarding details. Try again. RequestId: dummy_request_id',
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('throws an error when getLogForwarding fails', async () => {
|
|
112
|
+
const errorMessage = 'Failed to fetch log forwarding details';
|
|
113
|
+
getLogForwarding.mockRejectedValue(new Error(errorMessage));
|
|
114
|
+
|
|
115
|
+
const command = new GetLogForwardingCommand([], {});
|
|
116
|
+
await expect(command.run()).rejects.toThrow(
|
|
117
|
+
`Failed to get log forwarding details. Try again. RequestId: dummy_request_id`,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(logSpy).toHaveBeenCalledWith(errorMessage);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('handles 404 error when getLogForwarding returns null', async () => {
|
|
124
|
+
// Mock getLogForwarding to simulate a 404 error
|
|
125
|
+
getLogForwarding.mockImplementation(() => {
|
|
126
|
+
const error = new Error('Not Found');
|
|
127
|
+
error.response = { status: 404 };
|
|
128
|
+
throw error;
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const command = new GetLogForwardingCommand([], {});
|
|
132
|
+
|
|
133
|
+
await expect(command.run()).rejects.toThrow(
|
|
134
|
+
'Failed to get log forwarding details. Try again. RequestId: dummy_request_id',
|
|
135
|
+
);
|
|
136
|
+
expect(logSpy).toHaveBeenCalledWith('Not Found');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('when getLogForwarding returns null', async () => {
|
|
140
|
+
// Mock getLogForwarding to return null
|
|
141
|
+
getLogForwarding.mockResolvedValue(null);
|
|
142
|
+
|
|
143
|
+
const command = new GetLogForwardingCommand([], {});
|
|
144
|
+
|
|
145
|
+
await expect(command.run()).rejects.toThrow(
|
|
146
|
+
'Unable to get log forwarding details. Try again. RequestId: dummy_request_id',
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -23,7 +23,7 @@ jest.mock('../../../helpers', () => ({
|
|
|
23
23
|
initSdk: jest.fn().mockResolvedValue({}),
|
|
24
24
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
25
25
|
}));
|
|
26
|
-
jest.mock('../../../lib/
|
|
26
|
+
jest.mock('../../../lib/smsClient');
|
|
27
27
|
|
|
28
28
|
const mockConsoleCLIInstance = {};
|
|
29
29
|
const selectedOrg = { id: '1234', code: 'CODE1234@AdobeOrg', name: 'ORG01', type: 'entp' };
|
|
@@ -31,10 +31,10 @@ const selectedProject = { id: '5678', title: 'Project01' };
|
|
|
31
31
|
const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
32
32
|
|
|
33
33
|
const { writeFile } = require('fs/promises');
|
|
34
|
-
const { initSdk
|
|
34
|
+
const { initSdk } = require('../../../helpers');
|
|
35
35
|
const GetCommand = require('../get');
|
|
36
36
|
const mockGetMeshConfig = require('../../__fixtures__/sample_mesh.json');
|
|
37
|
-
const { getMeshId, getMesh } = require('../../../lib/
|
|
37
|
+
const { getMeshId, getMesh } = require('../../../lib/smsClient');
|
|
38
38
|
|
|
39
39
|
let logSpy = null;
|
|
40
40
|
let errorLogSpy = null;
|
|
@@ -192,7 +192,7 @@ describe('get command tests', () => {
|
|
|
192
192
|
ignoreCache: true,
|
|
193
193
|
verbose: true,
|
|
194
194
|
});
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
expect(runResult).toMatchInlineSnapshot(`
|
|
197
197
|
{
|
|
198
198
|
"imsOrgId": "1234",
|