Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data pinning #3512

Merged
merged 244 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
6f9a3f5
refactor: Aligned n8n-button usage inside of editor-ui.
alexgrozav May 27, 2022
3bec550
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
c0645e8
feat: Extracted code editor into separate form component.
alexgrozav May 31, 2022
3d4465d
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
f1fb2ce
feat: Added pinData and edit mode methods.
alexgrozav Jun 14, 2022
0f1fc44
:fire: Remove conflict markers
ivov Jun 15, 2022
5128ba9
:pencil2: Update i18n keys
ivov Jun 15, 2022
69a0df9
:zap: Add JSON validation
ivov Jun 15, 2022
bf931e5
:card_file_box: Add `pinData` column to `workflow_entity`
ivov Jun 1, 2022
80ac532
:blue_book: Tighten type
ivov Jun 1, 2022
9608f2a
:zap: Make `pinData` column nullable
ivov Jun 1, 2022
da69262
:zap: Adjust workflow endpoints for pin data
ivov Jun 2, 2022
f40ae8a
:blue_book: Improve types
ivov Jun 2, 2022
a9c8cb4
:pencil2: Improve wording
ivov Jun 2, 2022
ad89610
Inject pindata into items flow (#3420)
ivov Jun 14, 2022
52a2757
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
65fdfa9
feat: Extracted code editor into separate form component.
alexgrozav May 31, 2022
93609dc
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
5d6c7cb
fix: Fixed rebase conflicts.
alexgrozav Jun 14, 2022
e2c32c0
:rewind: Undo button change
ivov Jun 15, 2022
7895a83
:bug: Fix runNode call
ivov Jun 15, 2022
d597291
:test_tube: Fix workflow tests
ivov Jun 15, 2022
c9bc119
:bug: More merge conflict fixes
ivov Jun 15, 2022
47975ba
feat: Added pin/unpin button and store mutations.
alexgrozav Jun 15, 2022
de2a6e4
feat: Size check. Various design and ux improvements.
alexgrozav Jun 21, 2022
45bf1d9
:zap: Add transformer
ivov Jun 22, 2022
2c843e6
:zap: Hoist pin data
ivov Jun 22, 2022
768d547
:zap: Adjust endpoints for hoisted pin data
ivov Jun 22, 2022
5cb4159
:blue_book: Expand interface
ivov Jun 22, 2022
27275d7
:bug: Fix stray array
ivov Jun 22, 2022
050cbf5
:shirt: Fix build
ivov Jun 22, 2022
28b5345
:shirt: Add lint exception
ivov Jun 22, 2022
d3537a4
:shirt: Fix header
ivov Jun 22, 2022
186c215
:art: Add color secondary tints
ivov Jun 15, 2022
b8aea6b
:sparkles: Create `HeaderMessage` component
ivov Jun 15, 2022
aa06eef
:zap: Adjust `InfoTip` component
ivov Jun 15, 2022
8580bc4
:sparkles: Add `HeaderMessage` to `RunData`
ivov Jun 15, 2022
8a4ed7e
:bug: Fix console error
ivov Jun 15, 2022
8d1e1fd
:shirt: Fix lint
ivov Jun 15, 2022
fe905d2
:zap: Consolidate `HeaderMessage` and `Callout`
ivov Jun 20, 2022
996ddbe
:rewind: Undo `InfoTip` changes
ivov Jun 20, 2022
ee49ca7
:fire: Remove duplicate icons
ivov Jun 20, 2022
3f2eb27
:zap: Simplify template
ivov Jun 20, 2022
8ea901c
:art: Change cursor for action text
ivov Jun 20, 2022
2f0254b
:shirt: Fix lint
ivov Jun 20, 2022
501d6bb
:zap: Add URL
ivov Jun 20, 2022
d2f9991
:bug: Fix handler name
ivov Jun 20, 2022
31be434
:zap: Use constant
ivov Jun 20, 2022
431beb1
:recycle: Refactor per feedback
ivov Jun 20, 2022
f03d0b2
fix: Various fixes after data pinning relocation.
alexgrozav Jun 22, 2022
c9f4258
fix: Added store mutation for setting pinned data.
alexgrozav Jun 23, 2022
42f55ce
feat: Added pinned state for workflow canvas node.
alexgrozav Jun 23, 2022
1774e23
fix: Fixed workflow saving.
alexgrozav Jun 23, 2022
b2e6305
fix: Removed pinData hoisting (no longer necessary).
alexgrozav Jun 23, 2022
85def0d
feat: Added canPinData flag to hide for input pane and binary data. F…
alexgrozav Jun 23, 2022
be13203
:zap: Fixes for canvas pin data (#3587)
ivov Jun 23, 2022
5b3a1e3
feat: Updated pinData mixin to no longer include extra fields.
alexgrozav Jun 24, 2022
c2f3fcb
chore: Merge data-pinning-2 into n8n-3939-workflow-canvas-node-design…
alexgrozav Jun 24, 2022
5878c90
:zap: Output same pindata for every run
ivov Jun 24, 2022
3f09c93
:art: Fix cropping
ivov Jun 24, 2022
d1680ab
:fire: Remove unrelated logging
ivov Jun 24, 2022
5152310
feat: Moved edit button next to pin button.
alexgrozav Jun 24, 2022
5ac4b32
feat: Changed data to be inserted for empty state.
alexgrozav Jun 24, 2022
9134de3
chore: Changed invalid editor output translation.
alexgrozav Jun 24, 2022
7758928
feat: Added error line reporting on JSON Validation.
alexgrozav Jun 24, 2022
4c27fc9
feat: Migrated pinData edit mode to store.
alexgrozav Jun 24, 2022
db99e9a
chore: Merged duplicate node border color condition.
alexgrozav Jun 24, 2022
3d27f35
Merge pull request #3582 from n8n-io/n8n-3939-workflow-canvas-node-de…
alexgrozav Jun 24, 2022
de05a14
chore: Merged data-pinning-2 to n8n-3942-pending-data-pinning-fronten…
alexgrozav Jun 24, 2022
0ee5c31
feat: Moved pin data validation to mixin. Added check before closing …
alexgrozav Jun 24, 2022
e6d51d8
fix: Changed pinned data size calculation to discard active node pin …
alexgrozav Jun 24, 2022
1a0101f
Merge pull request #3595 from n8n-io/n8n-3945-output-identical-pindat…
alexgrozav Jun 24, 2022
77e97f9
feat: Added support for rename and delete node with pin data.
alexgrozav Jun 24, 2022
8052ca4
Merge branch 'data-pinning-2' into n8n-3942-pending-data-pinning-fron…
alexgrozav Jun 24, 2022
61299ef
feat: Simplified editing state. Fixed edit mode in input panel after …
alexgrozav Jun 24, 2022
0f91f4a
feat: Various data pinning improvements.
alexgrozav Jun 28, 2022
76d9265
fix: Fixed callout link underline.
alexgrozav Jun 28, 2022
a5da3f5
refactor: Added support for both string and objects for data size check.
alexgrozav Jun 28, 2022
519bab1
feat: Added disabled node check for input panel. Fixed monaco editor …
alexgrozav Jun 28, 2022
c98fe6a
fix: Fixed edit mode footer size.
alexgrozav Jun 28, 2022
45db969
:zap: Fix pindata items per run
ivov Jun 29, 2022
a327421
:shirt: Remove unneeded exception
ivov Jun 29, 2022
74880c8
Merge pull request #3611 from n8n-io/fix-pindata-items-per-run
alexgrozav Jun 29, 2022
57aeafd
refactor: Added isValidPinData() helper method.
alexgrozav Jun 29, 2022
e05864a
refactor: Changed how string size in bytes in calculated.g
alexgrozav Jun 29, 2022
193919b
refactor: Updated pinData mixin interface.
alexgrozav Jun 29, 2022
847e538
refactor: Merged filter and reduce in pinDataSize calculation.
alexgrozav Jun 29, 2022
b06d45f
fix: Changed code-editor to correct type.
alexgrozav Jun 29, 2022
4103c7c
fix: Added insert test data message to trigger nodes.
alexgrozav Jun 29, 2022
cecc18a
feat: Disabled data pinning for multiple output nodes.
alexgrozav Jun 29, 2022
31ca144
refactor: Updated ndv.input.disabled translation to include node name.
alexgrozav Jun 29, 2022
b88a7d5
refactor: Aligned n8n-button usage inside of editor-ui.
alexgrozav May 27, 2022
882b81a
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
856340d
feat: Extracted code editor into separate form component.
alexgrozav May 31, 2022
2027e66
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
cd019cd
feat: Added pinData and edit mode methods.
alexgrozav Jun 14, 2022
17640e7
:fire: Remove conflict markers
ivov Jun 15, 2022
79a157c
:pencil2: Update i18n keys
ivov Jun 15, 2022
d3f7bd0
:zap: Add JSON validation
ivov Jun 15, 2022
a33be57
:card_file_box: Add `pinData` column to `workflow_entity`
ivov Jun 1, 2022
0a2243d
:blue_book: Tighten type
ivov Jun 1, 2022
e81b657
:zap: Make `pinData` column nullable
ivov Jun 1, 2022
6739216
:zap: Adjust workflow endpoints for pin data
ivov Jun 2, 2022
976a1f1
:blue_book: Improve types
ivov Jun 2, 2022
07759e0
:pencil2: Improve wording
ivov Jun 2, 2022
aa34753
Inject pindata into items flow (#3420)
ivov Jun 14, 2022
c867707
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
e0ccf60
feat: Extracted code editor into separate form component.
alexgrozav May 31, 2022
c065a28
feat: Added edit data button on json hover.
alexgrozav May 26, 2022
d1c85bd
fix: Fixed rebase conflicts.
alexgrozav Jun 14, 2022
3a72f52
:rewind: Undo button change
ivov Jun 15, 2022
4f4692b
:bug: Fix runNode call
ivov Jun 15, 2022
3f32c98
:test_tube: Fix workflow tests
ivov Jun 15, 2022
44f1044
:bug: More merge conflict fixes
ivov Jun 15, 2022
4ba9c9d
feat: Added pin/unpin button and store mutations.
alexgrozav Jun 15, 2022
4fb4dc4
feat: Size check. Various design and ux improvements.
alexgrozav Jun 21, 2022
c23456e
:zap: Add transformer
ivov Jun 22, 2022
d796c5b
:zap: Hoist pin data
ivov Jun 22, 2022
4a51e6d
:zap: Adjust endpoints for hoisted pin data
ivov Jun 22, 2022
19e6f1d
:blue_book: Expand interface
ivov Jun 22, 2022
095bc5c
:bug: Fix stray array
ivov Jun 22, 2022
86c4e4b
:shirt: Fix build
ivov Jun 22, 2022
7606747
:art: Add color secondary tints
ivov Jun 15, 2022
a6a4b06
:sparkles: Create `HeaderMessage` component
ivov Jun 15, 2022
a369b1f
:zap: Adjust `InfoTip` component
ivov Jun 15, 2022
bb664a3
:sparkles: Add `HeaderMessage` to `RunData`
ivov Jun 15, 2022
cff1460
:bug: Fix console error
ivov Jun 15, 2022
a3b5763
:shirt: Fix lint
ivov Jun 15, 2022
6300203
:zap: Consolidate `HeaderMessage` and `Callout`
ivov Jun 20, 2022
0346b5a
:rewind: Undo `InfoTip` changes
ivov Jun 20, 2022
4cd9d4e
:fire: Remove duplicate icons
ivov Jun 20, 2022
e46fe78
:zap: Simplify template
ivov Jun 20, 2022
b0c6c6e
:art: Change cursor for action text
ivov Jun 20, 2022
198a854
:shirt: Fix lint
ivov Jun 20, 2022
73dc956
:zap: Add URL
ivov Jun 20, 2022
63d9bc8
:bug: Fix handler name
ivov Jun 20, 2022
64556b9
:zap: Use constant
ivov Jun 20, 2022
ebaf172
:recycle: Refactor per feedback
ivov Jun 20, 2022
0bebadb
fix: Various fixes after data pinning relocation.
alexgrozav Jun 22, 2022
2ba3e39
fix: Added store mutation for setting pinned data.
alexgrozav Jun 23, 2022
90d8d78
feat: Added pinned state for workflow canvas node.
alexgrozav Jun 23, 2022
4c6d006
:zap: Fixes for canvas pin data (#3587)
ivov Jun 23, 2022
875c12f
feat: Updated pinData mixin to no longer include extra fields.
alexgrozav Jun 24, 2022
8707012
fix: Removed pinData hoisting (no longer necessary).
alexgrozav Jun 23, 2022
c867019
chore: Merged duplicate node border color condition.
alexgrozav Jun 24, 2022
1d6ed2e
:zap: Output same pindata for every run
ivov Jun 24, 2022
4f75898
:art: Fix cropping
ivov Jun 24, 2022
2cdc219
chore: Merged data-pinning-2 into n8n-3942-pending-data-pinning-front…
alexgrozav Jun 29, 2022
922057f
:bug: Fix excess closing template tag
ivov Jun 29, 2022
331bc6b
fix: Removed rogue template tag after merge.
alexgrozav Jun 30, 2022
8a8b683
Merge branch 'n8n-3942-pending-data-pinning-frontend-tasks' of github…
alexgrozav Jun 30, 2022
92c701b
fix: Fixed code-editor resizing when moving ndv panel.
alexgrozav Jun 30, 2022
1ff7a4d
feat: Added node duplication pin data.
alexgrozav Jun 30, 2022
89fc6c6
:zap: Implement telemetry
ivov Jun 30, 2022
eac41f0
:twisted_rightwards_arrows: Merge parent branch
ivov Jun 30, 2022
88278de
:recycle: Add clarifications from call
ivov Jun 30, 2022
faef086
Merge pull request #3619 from n8n-io/n8n-3749-telemetry-for-pinned-data
alexgrozav Jun 30, 2022
bef8a1e
Merge pull request #3585 from n8n-io/n8n-3942-pending-data-pinning-fr…
alexgrozav Jun 30, 2022
0c62e41
fix: Fixed run data header height.
alexgrozav Jun 30, 2022
7e9d6ac
feat: Removed border from pin data callout.
alexgrozav Jun 30, 2022
308b23f
feat: Added line-break before 'or insert pin data'.
alexgrozav Jun 30, 2022
03c08d0
feat: Changed enterEditMode to always insert test data if there's no …
alexgrozav Jun 30, 2022
d09e37c
feat: Removed copy output tooltip.
alexgrozav Jun 30, 2022
5081e5c
feat: Removed unpin tooltip.
alexgrozav Jun 30, 2022
5ce1223
fix: Removed thumbtack icon rotation.
alexgrozav Jun 30, 2022
722043b
fix: Removed run info from Edit Output title.
alexgrozav Jun 30, 2022
57976b9
feat: Hid edit and pin buttons when editing.
alexgrozav Jun 30, 2022
0c0d748
feat: Updated monaco code-editor padding and borders.
alexgrozav Jun 30, 2022
4d9ed97
feat: Progress on pinData error message format
alexgrozav Jul 1, 2022
f22d8eb
feat: Updated copy feature to work without any selected value.
alexgrozav Jul 5, 2022
c16b69d
feat: Moved save and cancel buttons. Cleared notifications on save.
alexgrozav Jul 5, 2022
c3b4e75
feat: Changed pin data beforeClosing confirm text.
alexgrozav Jul 5, 2022
7b768b7
feat: Closing ndv when discarding or saving pindata on close.
alexgrozav Jul 5, 2022
5c9a57a
feat: Added split in batches node to pin data denylist.
alexgrozav Jul 5, 2022
a13c5e0
fix: Added missing margin-bottom to webhook node.
alexgrozav Jul 5, 2022
8c366c9
feat: Moved thumbtack icon to the right, replacing the checkmark.
alexgrozav Jul 5, 2022
6fa7821
fix: Hid pagination while editing.
alexgrozav Jul 5, 2022
b42f84e
feat: Added pin data discovery flow.
alexgrozav Jul 5, 2022
7aacfa2
feat: Changed pin data discovery flow to avoid tooltip glitching.
alexgrozav Jul 5, 2022
1325b61
fix: Changed copy selection to copy all input data.
alexgrozav Jul 5, 2022
7f38260
feat: Updated pin data validation error message for unexpected single…
alexgrozav Jul 6, 2022
353c2b8
fix: Replaced :manual='true' prop with manual shorthand.
alexgrozav Jul 6, 2022
ed88a3d
fix: Removed unused variable.
alexgrozav Jul 6, 2022
7be0473
chore: Renamed translation key to node.discovery.pinData.
alexgrozav Jul 6, 2022
492c5a7
refactor: Extracted isPinDataNodeType to pinData mixin.
alexgrozav Jul 6, 2022
529019c
fix: Updated watch condition to improve performance.
alexgrozav Jul 6, 2022
ae014ad
refactor: Renamed some pin data variables and methods as per review.
alexgrozav Jul 7, 2022
4ff6798
fix: Added partial translation for JSON.parse pin data error messages.
alexgrozav Jul 7, 2022
917b4ed
Merge pull request #3665 from n8n-io/n8n-3994-post-review-data-pinnin…
alexgrozav Jul 7, 2022
7a66229
chore: Merged n8n-3750-redesign-button-component-2 into data-pinning-2
alexgrozav Jul 7, 2022
3b9c7f4
chore: Temporarily disabled failing unit test.
alexgrozav Jul 7, 2022
a88109a
:test_tube: Fix data pinning workflow retrieval test
ivov Jul 7, 2022
14ad279
:fire: Remove unused imports
ivov Jul 7, 2022
0f84d6f
:fire: Remove leftover line
ivov Jul 7, 2022
d52b05a
Merge pull request #3671 from n8n-io/fix-data-pinning-workflow-retrie…
alexgrozav Jul 7, 2022
dde4a2c
:zap: Skip pindata node issues on BE
ivov Jul 7, 2022
7b4c77e
:zap: Skip pindata node issues on FE
ivov Jul 7, 2022
c4b1b83
:zap: Hide `RunInfo` for pindata node
ivov Jul 8, 2022
a5b571d
:zap: Hide purple banner in edit output mode
ivov Jul 8, 2022
b76be3b
Merge pull request #3674 from n8n-io/n8n-4065-validation-blocks-pinda…
alexgrozav Jul 11, 2022
77f911f
Merge pull request #3683 from n8n-io/data-pinning-post-bash-frontend-…
alexgrozav Jul 11, 2022
bf4a836
feat: Updated data pinning discoverability flow.
alexgrozav Jul 11, 2022
0f10b36
fix: Fixed paginated data pinning.
alexgrozav Jul 11, 2022
7a6ae43
Merge pull request #3688 from n8n-io/n8n-4078-pin-paginated-data-pins…
alexgrozav Jul 11, 2022
aeec130
fix: Disabled pin data in read only mode.
alexgrozav Jul 11, 2022
2881e4d
:bug: Fix runtime error with non-array
ivov Jul 11, 2022
3c863ae
fix: Loading pin data when opening execution.
alexgrozav Jul 11, 2022
522b893
:zap: Adjust stale data warning for pinned data
ivov Jul 12, 2022
656c4ab
Merge pull request #3696 from n8n-io/adjust-stale-data-warning-for-pi…
alexgrozav Jul 12, 2022
5f24f11
Merge pull request #3689 from n8n-io/fix-runtime-error-with-non-array
alexgrozav Jul 12, 2022
47120b1
Merge pull request #3687 from n8n-io/n8n-4077-data-pinning-discoverab…
alexgrozav Jul 12, 2022
545b79b
:zap: Skip auth in endpoint
ivov Jul 12, 2022
19e0d6b
:zap: Mark start node for pinned trigger
ivov Jul 12, 2022
2628f5d
:pencil2: Comment on passthrough
ivov Jul 12, 2022
fbdc559
:fire: Remove comment
ivov Jul 12, 2022
4d71d40
Final pindata metrics changes (#3673)
ivov Jul 13, 2022
714b152
fix: Added pin data handling when importing workflow. (#3698)
alexgrozav Jul 13, 2022
e86863f
:fire: Remove helper from WorkflowExecute
ivov Jul 13, 2022
22c0431
:zap: Add logic for single pinned trigger
ivov Jul 13, 2022
b524c5c
:shirt: Remove lint exception
ivov Jul 13, 2022
372b342
Merge branch 'data-pinning-2' into n8n-4079-pin-data-enabled-in-read-…
alexgrozav Jul 13, 2022
5913c3f
fix: Added pin data handling in importWorkflowExact.
alexgrozav Jul 13, 2022
cd1c5c0
Merge pull request #3690 from n8n-io/n8n-4079-pin-data-enabled-in-rea…
alexgrozav Jul 13, 2022
d7e5a5c
N8N-4077 data pinning discoverability part 2 (#3701)
alexgrozav Jul 13, 2022
a3e6bcf
Fix data pinning build (#3702)
ivov Jul 13, 2022
e8e5532
:zap: Disable edit button for disabled node
ivov Jul 13, 2022
8473f68
:zap: Ensure disabled pinned nodes are passthrough
ivov Jul 13, 2022
ed6f8d4
:bug: Fix JSON key unfurling in edit mode
ivov Jul 13, 2022
b45039c
:zap: Improve implementation
ivov Jul 13, 2022
00f0ec4
Merge pull request #3705 from n8n-io/fix-json-key-unfurling-in-edit-mode
alexgrozav Jul 14, 2022
667a6c6
Merge pull request #3699 from n8n-io/fix-auth-on-pinned-triggers
alexgrozav Jul 14, 2022
c4e4fa1
:bug: Fix console error
ivov Jul 14, 2022
75da9fa
Merge pull request #3710 from n8n-io/n8n-4104-enabling-disabling-node…
alexgrozav Jul 14, 2022
218ce9c
Merge pull request #3704 from n8n-io/ensure-disabled-pinned-nodes-pas…
alexgrozav Jul 14, 2022
b82c1ac
fix: Fixed copying pinned output data. (#3715)
alexgrozav Jul 14, 2022
bdd2d34
:twisted_rightwards_arrows: Merge master
ivov Jul 15, 2022
9eb216e
Fix pinning for webhook responding with output from last node (#3719)
ivov Jul 15, 2022
724f700
chore: Merged branch n8n-3750-redesign-button-component-2 into data-p…
alexgrozav Jul 18, 2022
cf099bf
fix: Fixed entering edit mode after refresh.
alexgrozav Jul 18, 2022
227ff01
fix: Fixed type error during build.
alexgrozav Jul 18, 2022
9ca0a6e
fix: RunData import formatting.
alexgrozav Jul 18, 2022
eb4486f
chore: Updated pin data types.
alexgrozav Jul 18, 2022
465032f
fix: Added missing type to stringSizeInBytes.
alexgrozav Jul 18, 2022
7083829
Merge pull request #3729 from n8n-io/fix-pin-data-enter-edit-mode
alexgrozav Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ITelemetrySettings,
ITelemetryTrackProperties,
IWorkflowBase as IWorkflowBaseWorkflow,
PinData,
Workflow,
WorkflowExecuteMode,
} from 'n8n-workflow';
Expand Down Expand Up @@ -646,6 +647,7 @@ export interface IWorkflowExecutionDataProcess {
executionMode: WorkflowExecuteMode;
executionData?: IRunExecutionData;
runData?: IRunData;
pinData?: PinData;
retryOf?: number | string;
sessionId?: string;
startNodes?: string[];
Expand Down
154 changes: 37 additions & 117 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
IWorkflowBase,
LoggerProxy,
NodeHelpers,
PinData,
WebhookHttpMethod,
Workflow,
WorkflowExecuteMode,
Expand Down Expand Up @@ -129,6 +130,7 @@ import {
WorkflowRunner,
getCredentialForUser,
getCredentialWithoutUser,
IWorkflowDb,
} from '.';

import config from '../config';
Expand Down Expand Up @@ -156,16 +158,17 @@ import type {
} from './requests';
import { DEFAULT_EXECUTIONS_GET_ALL_LIMIT, validateEntity } from './GenericHelpers';
import { ExecutionEntity } from './databases/entities/ExecutionEntity';
import { SharedWorkflow } from './databases/entities/SharedWorkflow';
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES } from './constants';
import { credentialsController } from './api/credentials.api';
import { workflowsController } from './api/workflows.api';
import { oauth2CredentialController } from './api/oauth2Credential.api';
import {
getInstanceBaseUrl,
isEmailSetUp,
isUserManagementEnabled,
} from './UserManagement/UserManagementHelper';
import { loadPublicApiVersions } from './PublicApi';
import { SharedWorkflow } from './databases/entities/SharedWorkflow';

require('body-parser-xml')(bodyParser);

Expand Down Expand Up @@ -754,74 +757,6 @@ class App {
// Workflow
// ----------------------------------------

// Creates a new workflow
this.app.post(
`/${this.restEndpoint}/workflows`,
ResponseHelper.send(async (req: WorkflowRequest.Create) => {
delete req.body.id; // delete if sent

const newWorkflow = new WorkflowEntity();

Object.assign(newWorkflow, req.body);

await validateEntity(newWorkflow);

await this.externalHooks.run('workflow.create', [newWorkflow]);

const { tags: tagIds } = req.body;

if (tagIds?.length && !config.getEnv('workflowTagsDisabled')) {
newWorkflow.tags = await Db.collections.Tag.findByIds(tagIds, {
select: ['id', 'name'],
});
}

await WorkflowHelpers.replaceInvalidCredentials(newWorkflow);

let savedWorkflow: undefined | WorkflowEntity;

await getConnection().transaction(async (transactionManager) => {
savedWorkflow = await transactionManager.save<WorkflowEntity>(newWorkflow);

const role = await Db.collections.Role.findOneOrFail({
name: 'owner',
scope: 'workflow',
});

const newSharedWorkflow = new SharedWorkflow();

Object.assign(newSharedWorkflow, {
role,
user: req.user,
workflow: savedWorkflow,
});

await transactionManager.save<SharedWorkflow>(newSharedWorkflow);
});

if (!savedWorkflow) {
LoggerProxy.error('Failed to create workflow', { userId: req.user.id });
throw new ResponseHelper.ResponseError('Failed to save workflow');
}

if (tagIds && !config.getEnv('workflowTagsDisabled')) {
savedWorkflow.tags = TagHelpers.sortByRequestOrder(savedWorkflow.tags, {
requestOrder: tagIds,
});
}

await this.externalHooks.run('workflow.afterCreate', [savedWorkflow]);
void InternalHooksManager.getInstance().onWorkflowCreated(req.user.id, newWorkflow, false);

const { id, ...rest } = savedWorkflow;

return {
id: id.toString(),
...rest,
};
}),
);

// Reads and returns workflow data from an URL
this.app.get(
`/${this.restEndpoint}/workflows/from-url`,
Expand Down Expand Up @@ -947,50 +882,6 @@ class App {
}),
);

// Returns a specific workflow
this.app.get(
`/${this.restEndpoint}/workflows/:id`,
ResponseHelper.send(async (req: WorkflowRequest.Get) => {
const { id: workflowId } = req.params;

let relations = ['workflow', 'workflow.tags'];

if (config.getEnv('workflowTagsDisabled')) {
relations = relations.filter((relation) => relation !== 'workflow.tags');
}

const shared = await Db.collections.SharedWorkflow.findOne({
relations,
where: whereClause({
user: req.user,
entityType: 'workflow',
entityId: workflowId,
}),
});

if (!shared) {
LoggerProxy.info('User attempted to access a workflow without permissions', {
workflowId,
userId: req.user.id,
});
throw new ResponseHelper.ResponseError(
`Workflow with ID "${workflowId}" could not be found.`,
undefined,
404,
);
}

const {
workflow: { id, ...rest },
} = shared;

return {
id: id.toString(),
...rest,
};
}),
);

// Updates an existing workflow
this.app.patch(
`/${this.restEndpoint}/workflows/:id`,
Expand Down Expand Up @@ -1189,19 +1080,23 @@ class App {
): Promise<IExecutionPushResponse> => {
const { workflowData } = req.body;
const { runData } = req.body;
const { pinData } = req.body;
const { startNodes } = req.body;
const { destinationNode } = req.body;
const executionMode = 'manual';
const activationMode = 'manual';

const sessionId = GenericHelpers.getSessionId(req);

const pinnedTrigger = findFirstPinnedTrigger(workflowData, pinData);

// If webhooks nodes exist and are active we have to wait for till we receive a call
if (
runData === undefined ||
startNodes === undefined ||
startNodes.length === 0 ||
destinationNode === undefined
pinnedTrigger === undefined &&
(runData === undefined ||
startNodes === undefined ||
startNodes.length === 0 ||
destinationNode === undefined)
) {
const additionalData = await WorkflowExecuteAdditionalData.getBase(req.user.id);
const nodeTypes = NodeTypes();
Expand Down Expand Up @@ -1239,11 +1134,17 @@ class App {
destinationNode,
executionMode,
runData,
pinData,
sessionId,
startNodes,
workflowData,
userId: req.user.id,
};

if (pinnedTrigger) {
data.startNodes = [pinnedTrigger.name];
}

const workflowRunner = new WorkflowRunner();
const executionId = await workflowRunner.run(data);

Expand All @@ -1254,6 +1155,8 @@ class App {
),
);

this.app.use(`/${this.restEndpoint}/workflows`, workflowsController);

// Retrieves all tags, with or without usage count
this.app.get(
`/${this.restEndpoint}/tags`,
Expand Down Expand Up @@ -2912,3 +2815,20 @@ function isOAuth(credType: ICredentialType) {
)
);
}

const TRIGGER_NODE_SUFFIXES = ['trigger', 'webhook'];

const isTrigger = (str: string) =>
TRIGGER_NODE_SUFFIXES.some((suffix) => str.toLowerCase().includes(suffix));

function findFirstPinnedTrigger(workflow: IWorkflowDb, pinData?: PinData) {
if (!pinData) return;

const firstPinnedTriggerName = Object.keys(pinData).find(isTrigger);

if (!firstPinnedTriggerName) return;

return workflow.nodes.find(
({ type, name }) => isTrigger(type) && name === firstPinnedTriggerName,
);
}
4 changes: 4 additions & 0 deletions packages/cli/src/WebhookHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ export async function executeWebhook(
return undefined;
}

if (workflowData.pinData) {
data.data.resultData.pinData = workflowData.pinData;
}

const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);
if (data.data.resultData.error || returnData?.error !== undefined) {
if (!didSendResponse) {
Expand Down
23 changes: 21 additions & 2 deletions packages/cli/src/WorkflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
* @returns {(ITaskData | undefined)}
*/
export function getDataLastExecutedNodeData(inputData: IRun): ITaskData | undefined {
const { runData } = inputData.data.resultData;
const { runData, pinData = {} } = inputData.data.resultData;
const { lastNodeExecuted } = inputData.data.resultData;

if (lastNodeExecuted === undefined) {
Expand All @@ -61,7 +61,26 @@ export function getDataLastExecutedNodeData(inputData: IRun): ITaskData | undefi
return undefined;
}

return runData[lastNodeExecuted][runData[lastNodeExecuted].length - 1];
const lastNodeRunData = runData[lastNodeExecuted][runData[lastNodeExecuted].length - 1];

let lastNodePinData = pinData[lastNodeExecuted];

if (lastNodePinData) {
if (!Array.isArray(lastNodePinData)) lastNodePinData = [lastNodePinData];

const itemsPerRun = lastNodePinData.map((item, index) => {
return { json: item, pairedItem: { item: index } };
});

return {
startTime: 0,
executionTime: 0,
data: { main: [itemsPerRun] },
source: lastNodeRunData.source,
};
}

return lastNodeRunData;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/WorkflowRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ export class WorkflowRunner {

// Can execute without webhook so go on
const workflowExecute = new WorkflowExecute(additionalData, data.executionMode);
workflowExecution = workflowExecute.run(workflow, undefined, data.destinationNode);
workflowExecution = workflowExecute.run(
workflow,
undefined,
data.destinationNode,
data.pinData,
);
} else {
Logger.debug(`Execution ID ${executionId} is a partial execution.`, { executionId });
// Execute only the nodes between start and destination nodes
Expand All @@ -320,6 +325,7 @@ export class WorkflowRunner {
data.runData,
data.startNodes,
data.destinationNode,
data.pinData,
);
}

Expand Down
16 changes: 15 additions & 1 deletion packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,22 @@ export class WorkflowRunnerProcess {
) {
// Execute all nodes

let startNode;
if (
this.data.startNodes?.length === 1 &&
Object.keys(this.data.pinData ?? {}).includes(this.data.startNodes[0])
) {
startNode = this.workflow.getNode(this.data.startNodes[0]) ?? undefined;
}

// Can execute without webhook so go on
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
return this.workflowExecute.run(this.workflow, undefined, this.data.destinationNode);
return this.workflowExecute.run(
this.workflow,
startNode,
this.data.destinationNode,
this.data.pinData,
);
}
// Execute only the nodes between start and destination nodes
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
Expand All @@ -356,6 +369,7 @@ export class WorkflowRunnerProcess {
this.data.runData,
this.data.startNodes,
this.data.destinationNode,
this.data.pinData,
);
}

Expand Down
Loading