Skip to content

Commit

Permalink
feat(core): Add support for $("NodeName").isExecuted (#8683)
Browse files Browse the repository at this point in the history
  • Loading branch information
janober authored Feb 20, 2024
1 parent e2f2fc9 commit ad82f0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/workflow/src/WorkflowDataProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,17 +922,14 @@ 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(
{},
{
has: () => true,
ownKeys() {
return [
'pairedItem',
'isExecuted',
'itemMatching',
'item',
'first',
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions packages/workflow/test/WorkflowDataProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down

0 comments on commit ad82f0c

Please sign in to comment.