@output.ai/core 0.1.7 → 0.1.9-dev.pr156.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/package.json
CHANGED
|
@@ -29,6 +29,8 @@ export const init = () => {
|
|
|
29
29
|
|
|
30
30
|
const getOutputDir = workflowName => join( process.argv[2], 'logs', 'runs', workflowName );
|
|
31
31
|
|
|
32
|
+
const getRelativeOutputDir = workflowName => join( 'logs', 'runs', workflowName );
|
|
33
|
+
|
|
32
34
|
const buildOutputFileName = ( { startTime, workflowId } ) => {
|
|
33
35
|
const timestamp = new Date( startTime ).toISOString().replace( /[:T.]/g, '-' );
|
|
34
36
|
return `${timestamp}_${workflowId}.json`;
|
|
@@ -56,12 +58,12 @@ export const exec = ( { entry, executionContext } ) => {
|
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
|
-
* Returns where the trace is saved
|
|
61
|
+
* Returns where the trace is saved (as a relative path)
|
|
60
62
|
* @param {object} args
|
|
61
63
|
* @param {string} args.startTime - The start time of the workflow
|
|
62
64
|
* @param {string} args.workflowId - The id of the workflow execution
|
|
63
65
|
* @param {string} args.workflowName - The name of the workflow
|
|
64
|
-
* @returns {string} The path where the trace will be saved
|
|
66
|
+
* @returns {string} The relative path where the trace will be saved
|
|
65
67
|
*/
|
|
66
68
|
export const getDestination = ( { startTime, workflowId, workflowName } ) =>
|
|
67
|
-
join(
|
|
69
|
+
join( getRelativeOutputDir( workflowName ), buildOutputFileName( { workflowId, startTime } ) );
|
|
@@ -63,5 +63,19 @@ describe( 'tracing/processors/local', () => {
|
|
|
63
63
|
expect( writtenPath ).toMatch( /\/logs\/runs\/WF\// );
|
|
64
64
|
expect( JSON.parse( content.trim() ).count ).toBe( 3 );
|
|
65
65
|
} );
|
|
66
|
+
|
|
67
|
+
it( 'getDestination(): returns relative path', async () => {
|
|
68
|
+
const { getDestination } = await import( './index.js' );
|
|
69
|
+
|
|
70
|
+
const startTime = Date.parse( '2020-01-02T03:04:05.678Z' );
|
|
71
|
+
const workflowId = 'workflow-id-123';
|
|
72
|
+
const workflowName = 'test-workflow';
|
|
73
|
+
|
|
74
|
+
const destination = getDestination( { startTime, workflowId, workflowName } );
|
|
75
|
+
|
|
76
|
+
// Should return a relative path, not an absolute path
|
|
77
|
+
expect( destination ).not.toMatch( /^\/|^[A-Z]:\\/i ); // Not starting with / or Windows drive letter
|
|
78
|
+
expect( destination ).toBe( 'logs/runs/test-workflow/2020-01-02-03-04-05-678Z_workflow-id-123.json' );
|
|
79
|
+
} );
|
|
66
80
|
} );
|
|
67
81
|
|