refactor(plugins): dedup workflow engine handlers into shared helpers#102
Open
SamTolmay wants to merge 2 commits into
Open
refactor(plugins): dedup workflow engine handlers into shared helpers#102SamTolmay wants to merge 2 commits into
SamTolmay wants to merge 2 commits into
Conversation
Extract the logic that was copy-pasted across the WorkflowAPI handlers into shared, single-source helpers (no behavior change): - shared/collectionNames.js — collection-name defaults, previously repeated in 8 files (schema-default drift risk). - shared/findWorkflowConfig.js — workflowsConfig lookup by type, previously repeated in 6 files. - shared/render/resolveActionAccess.js — add hasAnyVerb + selectVisibleActions (the access-filter + link-collapse + annotate loop repeated in the three card-rendering read handlers). - shared/render/pruneFormData.js — the ~50-line form_data pruning block duplicated verbatim in GetWorkflowOverview and GetWorkflowActionGroupOverview. - shared/render/buildEntityLink.js — the entity_link chrome built in four handlers. - shared/render/collectActionGroups.js — the action_group grouping + declaration-order/unseen-group indexing duplicated in GetEntityWorkflows and GetWorkflowOverview. - WorkflowAPI/shared/terminateWorkflow.js — the identical sweep → recompute → references-merge → event → change-log → tracker-fire → commit → cascade tail of CancelWorkflow and CloseWorkflow; the handlers now declare only their documented deltas (lifecycle stage, event/tracker signals, sweep exception). Structural cleanup: - Move GetEventsTimeline under connections/EventsTimeline/ — it is registered on the EventsTimeline connection, not WorkflowAPI. - Move dispatchNotifications to shared/phases/ — its only caller is commitPlan, which previously imported it from inside WorkflowAPI (inverted dependency). - Delete SubmitWorkflowAction/UserError.js — dead code, never imported. - GetEventsTimeline: fold the two card branches (workflow / non-workflow) into one card shape with a conditional access gate. - GetWorkflowAction: fix the out-of-order step comments; build entity_link from the guarded entityId (no TypeError when a doc lacks entity). - WorkflowAPI schema: eventsCollection is read by GetWorkflowAction only (GetEventsTimeline belongs to the EventsTimeline connection). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh
GetEntityWorkflows spread the raw workflow doc into its response, which shipped the whole form_data map to any user holding a verb on any of the workflow's actions. GetWorkflowOverview and GetWorkflowActionGroupOverview already prune form_data to view-visible actions precisely so denied slices (e.g. a keyed sibling the user cannot see) never reach the client — this closes the same gap on the entity read. The module's own consumer (actions-on-entity) reads only title/_id/groups, and visible actions' slices still ship unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh
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.
Extract the logic that was copy-pasted across the WorkflowAPI handlers
into shared, single-source helpers (no behavior change):
repeated in 8 files (schema-default drift risk).
previously repeated in 6 files.
selectVisibleActions (the access-filter + link-collapse + annotate
loop repeated in the three card-rendering read handlers).
duplicated verbatim in GetWorkflowOverview and
GetWorkflowActionGroupOverview.
four handlers.
declaration-order/unseen-group indexing duplicated in
GetEntityWorkflows and GetWorkflowOverview.
sweep → recompute → references-merge → event → change-log →
tracker-fire → commit → cascade tail of CancelWorkflow and
CloseWorkflow; the handlers now declare only their documented deltas
(lifecycle stage, event/tracker signals, sweep exception).
Structural cleanup:
registered on the EventsTimeline connection, not WorkflowAPI.
commitPlan, which previously imported it from inside WorkflowAPI
(inverted dependency).
into one card shape with a conditional access gate.
entity_link from the guarded entityId (no TypeError when a doc lacks
entity).
(GetEventsTimeline belongs to the EventsTimeline connection).
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh