1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 13:15:28 +03:00

feat(core): Add support for $("NodeName").isExecuted (#8683)

This commit is contained in:
Jan Oberhauser 2024-02-20 18:25:04 +01:00 committed by GitHub
parent e2f2fc910d
commit ad82f0c0c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -922,10 +922,6 @@ export class WorkflowDataProxy {
throw createExpressionError(`"${nodeName}" node doesn't exist`);
}
if (!that?.runExecutionData?.resultData?.runData.hasOwnProperty(nodeName)) {
throw createExpressionError(`no data, execute "${nodeName}" node first`);
}
return new Proxy(
{},
{
@ -933,6 +929,7 @@ export class WorkflowDataProxy {
ownKeys() {
return [
'pairedItem',
'isExecuted',
'itemMatching',
'item',
'first',
@ -945,6 +942,12 @@ export class WorkflowDataProxy {
get(target, property, receiver) {
if (property === 'isProxy') return true;
if (!that?.runExecutionData?.resultData?.runData.hasOwnProperty(nodeName)) {
if (property === 'isExecuted') return false;
throw createExpressionError(`no data, execute "${nodeName}" node first`);
}
if (property === 'isExecuted') return true;
if (['pairedItem', 'itemMatching', 'item'].includes(property as string)) {
const pairedItemMethod = (itemIndex?: number) => {
if (itemIndex === undefined) {

View File

@ -294,8 +294,9 @@ describe('WorkflowDataProxy', () => {
expect(() => proxy.$('doNotExist')).toThrowError(ExpressionError);
});
test('$("NodeName")', () => {
expect(() => proxy.$('Set')).toThrowError(ExpressionError);
test('test $("NodeName").isExecuted', () => {
expect(proxy.$('Function').isExecuted).toEqual(true);
expect(proxy.$('Set').isExecuted).toEqual(false);
});
test('test $input.all()', () => {