@adobe/aio-cli-plugin-api-mesh 3.8.0-alpha.1 → 3.8.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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.8.0
|
|
1
|
+
{"version":"3.8.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"},"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","required":true},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC","required":true},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true}},"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"},"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: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
|
@@ -61,7 +61,7 @@ describe('GetBulkLogCommand', () => {
|
|
|
61
61
|
// Create dynamic startTime and endTime
|
|
62
62
|
const startTime = new Date(now);
|
|
63
63
|
const endTime = new Date(now);
|
|
64
|
-
|
|
64
|
+
startTime.setMinutes(startTime.getMinutes() - 45); // Set endTime to 45 minutes after startTime
|
|
65
65
|
|
|
66
66
|
const formattedStartTime = startTime.toISOString().slice(0, 19) + 'Z';
|
|
67
67
|
const formattedEndTime = endTime.toISOString().slice(0, 19) + 'Z';
|
|
@@ -81,6 +81,37 @@ describe('GetBulkLogCommand', () => {
|
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
test('throws an error if the endTime is greater than current time(now)', async () => {
|
|
85
|
+
// Mock the file system checks even if they are not the focus of this test
|
|
86
|
+
fs.existsSync.mockReturnValue(true); // Assume the file exists
|
|
87
|
+
fs.statSync.mockReturnValue({ size: 0 }); // Assume the file is empty
|
|
88
|
+
|
|
89
|
+
// Get the current date and time
|
|
90
|
+
const now = new Date();
|
|
91
|
+
|
|
92
|
+
// Create dynamic startTime and endTime
|
|
93
|
+
const startTime = new Date(now);
|
|
94
|
+
const endTime = new Date(now);
|
|
95
|
+
endTime.setMinutes(startTime.getMinutes() + 45); // Set endTime to 45 minutes after startTime
|
|
96
|
+
|
|
97
|
+
const formattedStartTime = startTime.toISOString().slice(0, 19) + 'Z';
|
|
98
|
+
const formattedEndTime = endTime.toISOString().slice(0, 19) + 'Z';
|
|
99
|
+
|
|
100
|
+
parseSpy.mockResolvedValueOnce({
|
|
101
|
+
flags: {
|
|
102
|
+
startTime: formattedStartTime,
|
|
103
|
+
endTime: formattedEndTime,
|
|
104
|
+
filename: 'test.csv',
|
|
105
|
+
ignoreCache: false,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const command = new GetBulkLogCommand([], {});
|
|
110
|
+
await expect(command.run()).rejects.toThrow(
|
|
111
|
+
'endTime cannot be in the future. Provide a valid endTime.',
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
84
115
|
test('throws an error if startTime format is invalid', async () => {
|
|
85
116
|
parseSpy.mockResolvedValueOnce({
|
|
86
117
|
flags: {
|
|
@@ -78,6 +78,7 @@ class GetBulkLogCommand extends Command {
|
|
|
78
78
|
// Convert formatted times to Date objects for comparison
|
|
79
79
|
const startTime = new Date(flags.startTime);
|
|
80
80
|
const endTime = new Date(flags.endTime);
|
|
81
|
+
const now = new Date(); // Current time
|
|
81
82
|
|
|
82
83
|
// Require both startTime and endTime
|
|
83
84
|
if (!startTime || !endTime) {
|
|
@@ -122,6 +123,11 @@ class GetBulkLogCommand extends Command {
|
|
|
122
123
|
if (startTime > endTime) {
|
|
123
124
|
this.error('endTime must be greater than startTime');
|
|
124
125
|
}
|
|
126
|
+
// Validate that endTime is not greater than the current time (now)
|
|
127
|
+
if (endTime > now) {
|
|
128
|
+
this.error('endTime cannot be in the future. Provide a valid endTime.');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
125
131
|
|
|
126
132
|
// 4. Check if the duration between start and end times is greater than 30 minutes (1800 seconds)
|
|
127
133
|
const timeDifferenceInSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
@@ -198,8 +204,6 @@ class GetBulkLogCommand extends Command {
|
|
|
198
204
|
fileContentStream.on('end', resolve);
|
|
199
205
|
fileContentStream.on('error', reject);
|
|
200
206
|
});
|
|
201
|
-
// write a newline after each file write
|
|
202
|
-
writer.write('\n');
|
|
203
207
|
|
|
204
208
|
logger.info(`${key} content appended successfully.`);
|
|
205
209
|
} catch (error) {
|