mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
chore: Enfore consistent file-name casing on all backend packages (#15755)
This commit is contained in:
committed by
GitHub
parent
66d339c0d8
commit
3a2a70f193
34
packages/workflow/src/metadata-utils.ts
Normal file
34
packages/workflow/src/metadata-utils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
|
||||
// This accounts for cases where the backend attaches the properties on plain errors
|
||||
// e.g. from custom nodes throwing literal `Error` or `ApplicationError` objects directly
|
||||
return parseErrorResponseWorkflowMetadata(error);
|
||||
}
|
||||
Reference in New Issue
Block a user