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

feat(core): Initial workflow history API #7234

Merged
merged 7 commits into from
Sep 27, 2023

Conversation

valya
Copy link
Contributor

@valya valya commented Sep 21, 2023

Github issue / Community forum post (link here to close automatically):

@valya valya requested a review from krynble September 21, 2023 19:10
@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Make sure to check off this list before asking for review.

@valya valya changed the title feat(workflows): Initial workflow history API feat(core): Initial workflow history API Sep 21, 2023
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (d936ca0) 32.98% compared to head (7a0a790) 33.00%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7234      +/-   ##
==========================================
+ Coverage   32.98%   33.00%   +0.01%     
==========================================
  Files        3358     3359       +1     
  Lines      200231   200304      +73     
  Branches    21974    21990      +16     
==========================================
+ Hits        66048    66111      +63     
- Misses     133074   133084      +10     
  Partials     1109     1109              
Files Coverage Δ
...ages/cli/src/databases/entities/WorkflowHistory.ts 81.81% <100.00%> (ø)
...src/databases/repositories/execution.repository.ts 40.54% <100.00%> (-4.33%) ⬇️
packages/cli/src/requests.ts 100.00% <ø> (ø)
...kflows/workflowHistory/workflowHistoryHelper.ee.ts 100.00% <100.00%> (+100.00%) ⬆️
...blicApi/v1/handlers/workflows/workflows.handler.ts 82.88% <50.00%> (-1.23%) ⬇️
packages/cli/src/Server.ts 0.00% <0.00%> (ø)
packages/cli/src/workflows/workflows.services.ts 55.05% <50.00%> (-0.12%) ⬇️
...lows/workflowHistory/workflowHistory.service.ee.ts 85.71% <85.71%> (ø)
...s/workflowHistory/workflowHistory.controller.ee.ts 83.78% <83.78%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Sep 21, 2023
packages/cli/src/requests.ts Outdated Show resolved Hide resolved
private readonly sharedWorkflowRepository: SharedWorkflowRepository,
) {}

private async getSharedWorkflow(user: User, workflowId: string): Promise<SharedWorkflow | null> {
Copy link
Contributor

@ivov ivov Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can omit the inferrable return type. Same for others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have them. I find having them there helps in case of refactors or similar changes.

): Promise<Array<Omit<WorkflowHistory, 'nodes' | 'connections'>>> {
const sharedWorkflow = await this.getSharedWorkflow(user, workflowId);
if (!sharedWorkflow) {
throw new SharedWorkflowNotFoundError();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More details for debuggability? And logging? Same below for HistoryVersionNotFoundError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are simply there so I'm not throwing HTTP errors from the service. I prefer not to mix in HTTP logic with my business logic if I'm doing a controller and service. I'm not quite sure what I'd add to these.

name: 'Start',
parameters: {},
position: [-20, 260],
type: 'n8n-nodes-base.start',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: Ideally let's not use deprecated nodes in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I just copy and pasted this from elsewhere since I just needed some kind of data for it.

packages/cli/test/integration/workflowHistory.api.test.ts Outdated Show resolved Hide resolved
Comment on lines +89 to +95
const versions = await Promise.all(
new Array(10)
.fill(undefined)
.map(async (_, i) =>
testDb.createWorkflowHistoryItem(workflow.id, { createdAt: new Date(Date.now() + i) }),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might come in handy to have a helper to create multiple versions.

@valya valya requested a review from ivov September 27, 2023 12:44
@cypress
Copy link

cypress bot commented Sep 27, 2023

Passing run #2294 ↗︎

0 242 3 0 Flakiness 0

Details:

🌳 pay-675-api-endpoint-to-list-existing-workflow-versions 🖥️ browsers:node18.1...
Project: n8n Commit: 7a0a790385
Status: Passed Duration: 07:53 💡
Started: Sep 27, 2023 2:05 PM Ended: Sep 27, 2023 2:13 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@valya valya merged commit 0083a9e into master Sep 27, 2023
18 checks passed
@valya valya deleted the pay-675-api-endpoint-to-list-existing-workflow-versions branch September 27, 2023 14:22
This was referenced Sep 27, 2023
@luizeof
Copy link
Contributor

luizeof commented Sep 28, 2023

@valya this will be an Enterprise feature ?

netroy added a commit that referenced this pull request Sep 28, 2023
# [1.9.0](https://github.com/n8n-io/n8n/compare/n8n@1.8.0...n8n@1.9.0)
(2023-09-28)


### Bug Fixes

* **Airtable Node:** Attachments field type fix
([#7227](#7227))
([2af967c](2af967c))
* **core:** Change WorkflowHistory nodes/connections columns to be json
([#7282](#7282))
([a80abad](a80abad))
* **core:** Fix binary data manager check on pruning
([#7251](#7251))
([484035e](484035e))
* **core:** Fix missing execution ID in webhook-based workflow producing
binary data ([#7244](#7244))
([33991e9](33991e9))
* **core:** Handle filename* with quotes in Content-Disposition header
([#7229](#7229))
([67b985f](67b985f))
* **core:** Make DNS resolution order configurable
([#7272](#7272))
([5b3121c](5b3121c))
* **core:** Make senderId required for all command messages
([#7252](#7252))
([4b01428](4b01428))
* **core:** Prevent executions from displaying Running status
incorrectly ([#7261](#7261))
([861cac5](861cac5))
* **core:** Use consistent timezone-aware timestamps in postgres
([#6948](#6948))
([0132514](0132514)),
closes [#2178](#2178)
[#2810](#2810)
[#3855](#3855)
[#2813](#2813)
* **editor:** Add debug feature docs link
([#7240](#7240))
([4614e1e](4614e1e))
* **editor:** Fix SQL editor issue
([#7236](#7236))
([647fc6c](647fc6c))
* **editor:** Ensure new Set node is on top of search list
([#7215](#7215))
([2491ccf](2491ccf))
* **editor:** Forbid password reset when cloud account is limited in the
number of users [7188](#7188)
([303bc8e](303bc8e))
* **HTTP Request Node:** Add suggestion how to fix '429 - too many
requests' errors ([#7293](#7293))
([0bc33b1](0bc33b1))
* **Item Lists Node:** Concatenate operation pairedItems fix
([#7286](#7286))
([cde23a1](cde23a1))
* **Respond to Webhook Node:** JSON output from expression fix
([#7294](#7294))
([8bc369d](8bc369d))


### Features

* Add onboarding flow
([#7212](#7212))
([01e9340](01e9340))
* **core:** Add secrets provider reload and refactor
([#7277](#7277))
([53a7502](53a7502))
* **core:** Add Tournament as the new default expression evaluator
([#6964](#6964))
([bf74f09](bf74f09))
* **core:** Initial workflow history API
([#7234](#7234))
([0083a9e](0083a9e))
* **core:** Introduce object store service
([#7225](#7225))
([fa84545](fa84545))
* **editor:** Add user cloud ID to telemetry
[#7232](#7232)
([60c152d](60c152d))
* **editor:** Rework banners framework and add email confirmation banner
([#7205](#7205))
([b0e98b5](b0e98b5))
* **MISP Node:** Update credential to support HTTP Request node
([#7268](#7268))
([e4c302c](e4c302c))


### Performance Improvements

* **core:** Skip unneeded calls on every pruning cycle
([#7260](#7260))
([db01164](db01164))

Co-authored-by: netroy <netroy@users.noreply.github.com>
@janober
Copy link
Member

janober commented Sep 28, 2023

Got released with n8n@1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants