mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
feat(editor): Expose View Execution links for erroneous sub-executions (#13185)
This commit is contained in:
31
packages/workflow/src/MetadataUtils.ts
Normal file
31
packages/workflow/src/MetadataUtils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { ITaskMetadata } from '.';
|
||||
import { hasKey } from './utils';
|
||||
|
||||
function responseHasSubworkflowData(
|
||||
response: unknown,
|
||||
): response is { executionId: string; workflowId: string } {
|
||||
return ['executionId', 'workflowId'].every(
|
||||
(x) => hasKey(response, x) && typeof response[x] === 'string',
|
||||
);
|
||||
}
|
||||
|
||||
type ISubWorkflowMetadata = Required<Pick<ITaskMetadata, 'subExecution' | 'subExecutionsCount'>>;
|
||||
|
||||
function parseErrorResponseWorkflowMetadata(response: unknown): ISubWorkflowMetadata | undefined {
|
||||
if (!responseHasSubworkflowData(response)) return undefined;
|
||||
|
||||
return {
|
||||
subExecution: {
|
||||
executionId: response.executionId,
|
||||
workflowId: response.workflowId,
|
||||
},
|
||||
subExecutionsCount: 1,
|
||||
};
|
||||
}
|
||||
|
||||
export function parseErrorMetadata(error: unknown): ISubWorkflowMetadata | undefined {
|
||||
if (hasKey(error, 'errorResponse')) {
|
||||
return parseErrorResponseWorkflowMetadata(error.errorResponse);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user