refactor(API): Migrate workflow activate and deactivate to the decorator pattern (no-changelog) - #36928
Draft
uddish wants to merge 5 commits into
Draft
Conversation
…tor pattern
Moves the deprecated `POST /workflows/{id}/activate` and
`POST /workflows/{id}/deactivate` aliases off the legacy
express-openapi-validator handler onto `WorkflowsPublicController`, the first
production use of `@Deprecated`.
Each alias mirrors its own non-deprecated twin rather than the other: activate
takes a body, `workflow:activate`/`workflow:publish` and the 409 publish
blocker, while deactivate takes none of those. Both delegate to the handler
method they alias, as the legacy tuples did by spreading `publishWorkflow`.
`workflows.handler.ts` loses both tuples and the `publishWorkflow` /
`unpublishWorkflow` bodies that existed only to serve them, and
`workflows.id.activate.yml` / `workflows.id.deactivate.yml` are deleted outright.
`workflow-publish-blocked.openapi.test.ts` read the activate YAML off disk, so
it now asserts the generated fragment's inline 409 the way its sibling publish
case already did.
Part of https://linear.app/n8n/issue/API-199
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Generator output from the full build. `publishWorkflow.generated.yml` shrinks because `WorkflowPublishPublicDto` now has a second consumer, so the generator hoists its 200 body into `shared/spec/schemas/workflowPublishPublicDto.generated.yml` and both routes `$ref` it. That hoist is what broke the bundled spec in #36450, when a `nullable` with no sibling `type` compiled inside a path but not inside a component. It is safe here: #35835 gave every field a real type, and the new component carries no bare `nullable`. Part of https://linear.app/n8n/issue/API-199 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`/activate` reused `PublishWorkflowPublicDto`, which describes its three fields in terms of publication. The route's hand-written YAML described them in terms of activation, so reusing the DTO changed three descriptions in the published spec on a route this PR only moves. `ActivateWorkflowPublicDto` restores that wording. It sits beside the publish schema rather than in its own file so the divergence is visible, and carries a note against collapsing the two. Part of https://linear.app/n8n/issue/API-199 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…kflow-activate-and-deactivate-to-the-decorator
Contributor
PR review overviewBased on ownership of the 13 changed files in this PR:
|
Bundle ReportChanges will increase total bundle size by 1.62kB (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: editor-ui-esmAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves
POST /workflows/{id}/activateandPOST /workflows/{id}/deactivateontoWorkflowsPublicController, and deletes their hand-written YAML. Both are deprecated aliases, so each one calls the route it aliases: activate calls publish, deactivate calls unpublish.Two things the diff raises:
ActivateWorkflowPublicDtoisPublishWorkflowPublicDtowith different field descriptions./activatedocuments its body in terms of activation,/publishin terms of publication, so they cannot share one DTO without changing the spec.Deprecationheader, where before it did not. The header is set before authentication runs instead of after. Successful responses are unchanged.How to test
POST /workflows/{id}/activateon a workflow with a trigger. It should return 200 with aDeprecationheader.POST /workflows/{id}/deactivateon a published workflow. It should return 200 with aDeprecationheader.POST /workflows/{id}/publishandPOST /workflows/{id}/unpublish. They should return 200 with noDeprecationheader./api/v1/docs. Publish a workflow and Deactivate a workflow should still be listed, struck through.Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/API-199
Part of https://linear.app/n8n/issue/API-84
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)🤖 PR Summary generated by AI