mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-13 05:47:31 -08:00
feat(core): Add support for $("NodeName").isExecuted (#8683)
This commit is contained in:
parent
e2f2fc910d
commit
ad82f0c0c8
|
@ -922,10 +922,6 @@ export class WorkflowDataProxy {
|
||||||
throw createExpressionError(`"${nodeName}" node doesn't exist`);
|
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(
|
return new Proxy(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
|
@ -933,6 +929,7 @@ export class WorkflowDataProxy {
|
||||||
ownKeys() {
|
ownKeys() {
|
||||||
return [
|
return [
|
||||||
'pairedItem',
|
'pairedItem',
|
||||||
|
'isExecuted',
|
||||||
'itemMatching',
|
'itemMatching',
|
||||||
'item',
|
'item',
|
||||||
'first',
|
'first',
|
||||||
|
@ -945,6 +942,12 @@ export class WorkflowDataProxy {
|
||||||
get(target, property, receiver) {
|
get(target, property, receiver) {
|
||||||
if (property === 'isProxy') return true;
|
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)) {
|
if (['pairedItem', 'itemMatching', 'item'].includes(property as string)) {
|
||||||
const pairedItemMethod = (itemIndex?: number) => {
|
const pairedItemMethod = (itemIndex?: number) => {
|
||||||
if (itemIndex === undefined) {
|
if (itemIndex === undefined) {
|
||||||
|
|
|
@ -294,8 +294,9 @@ describe('WorkflowDataProxy', () => {
|
||||||
expect(() => proxy.$('doNotExist')).toThrowError(ExpressionError);
|
expect(() => proxy.$('doNotExist')).toThrowError(ExpressionError);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('$("NodeName")', () => {
|
test('test $("NodeName").isExecuted', () => {
|
||||||
expect(() => proxy.$('Set')).toThrowError(ExpressionError);
|
expect(proxy.$('Function').isExecuted).toEqual(true);
|
||||||
|
expect(proxy.$('Set').isExecuted).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test $input.all()', () => {
|
test('test $input.all()', () => {
|
||||||
|
|
Loading…
Reference in a new issue