@output.ai/core 0.1.7 → 0.1.8-dev.pr156.05c9aa2
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
|
@@ -27,7 +27,17 @@ export const init = () => {
|
|
|
27
27
|
cleanupOldTempFiles();
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Get the base path for trace file storage
|
|
32
|
+
* @returns {string} The base path where traces should be written
|
|
33
|
+
*/
|
|
34
|
+
const getBasePath = () => {
|
|
35
|
+
return process.env.HOST_TRACE_PATH || join( process.cwd(), 'logs' );
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getOutputDir = workflowName => {
|
|
39
|
+
return join( getBasePath(), 'runs', workflowName );
|
|
40
|
+
};
|
|
31
41
|
|
|
32
42
|
const buildOutputFileName = ( { startTime, workflowId } ) => {
|
|
33
43
|
const timestamp = new Date( startTime ).toISOString().replace( /[:T.]/g, '-' );
|
|
@@ -56,12 +66,13 @@ export const exec = ( { entry, executionContext } ) => {
|
|
|
56
66
|
};
|
|
57
67
|
|
|
58
68
|
/**
|
|
59
|
-
* Returns where the trace is saved
|
|
69
|
+
* Returns where the trace is saved as an absolute path
|
|
60
70
|
* @param {object} args
|
|
61
71
|
* @param {string} args.startTime - The start time of the workflow
|
|
62
72
|
* @param {string} args.workflowId - The id of the workflow execution
|
|
63
73
|
* @param {string} args.workflowName - The name of the workflow
|
|
64
|
-
* @returns {string} The path where the trace will be saved
|
|
74
|
+
* @returns {string} The absolute path where the trace will be saved
|
|
65
75
|
*/
|
|
66
|
-
export const getDestination = ( { startTime, workflowId, workflowName } ) =>
|
|
67
|
-
join( getOutputDir( workflowName ), buildOutputFileName( { workflowId, startTime } ) );
|
|
76
|
+
export const getDestination = ( { startTime, workflowId, workflowName } ) => {
|
|
77
|
+
return join( getOutputDir( workflowName ), buildOutputFileName( { workflowId, startTime } ) );
|
|
78
|
+
};
|
|
@@ -60,8 +60,23 @@ describe( 'tracing/processors/local', () => {
|
|
|
60
60
|
|
|
61
61
|
expect( writeFileSyncMock ).toHaveBeenCalledTimes( 3 );
|
|
62
62
|
const [ writtenPath, content ] = writeFileSyncMock.mock.calls.at( -1 );
|
|
63
|
-
|
|
63
|
+
// Changed: Now uses process.cwd() + '/logs' fallback when HOST_TRACE_PATH not set
|
|
64
|
+
expect( writtenPath ).toMatch( /\/runs\/WF\// );
|
|
64
65
|
expect( JSON.parse( content.trim() ).count ).toBe( 3 );
|
|
65
66
|
} );
|
|
67
|
+
|
|
68
|
+
it( 'getDestination(): returns absolute path', async () => {
|
|
69
|
+
const { getDestination } = await import( './index.js' );
|
|
70
|
+
|
|
71
|
+
const startTime = Date.parse( '2020-01-02T03:04:05.678Z' );
|
|
72
|
+
const workflowId = 'workflow-id-123';
|
|
73
|
+
const workflowName = 'test-workflow';
|
|
74
|
+
|
|
75
|
+
const destination = getDestination( { startTime, workflowId, workflowName } );
|
|
76
|
+
|
|
77
|
+
// Should return an absolute path
|
|
78
|
+
expect( destination ).toMatch( /^\/|^[A-Z]:\\/i ); // Starting with / or Windows drive letter
|
|
79
|
+
expect( destination ).toContain( '/logs/runs/test-workflow/2020-01-02-03-04-05-678Z_workflow-id-123.json' );
|
|
80
|
+
} );
|
|
66
81
|
} );
|
|
67
82
|
|