feat(api): publish the order config flow's graph so consumers can sequence it - #300
Merged
Merged
Conversation
…uence it The public order-config resource projected each activity down to code, status, details, color, complete, pod_method and require_pod. Those describe an activity but say nothing about the flow's shape, so what reaches an API consumer is an unordered set of activities with no way to put them in order. The stored flow is a directed graph, and the fields that express it were the ones being dropped: `activities` names the codes an activity can transition to, `sequence` orders activities reachable from the same parent, and `logic` gates availability. OrderConfig::nextActivity walks exactly these server-side, and the console's internal resource returns the flow whole, so the gap is only visible from the public API. The consequence is not cosmetic. A client rendering progress from array position marks an order complete whenever `completed` happens to be declared before the order's current activity — the default transport config lists `completed` fourth and `dispatched` last, so a freshly dispatched order shows as finished and offers no next step at all. These describe the configured workflow rather than internal state, so there is nothing here a consumer of the config should not already see. Transitions are normalised to a list of codes, since flows have been authored both as bare codes and as objects carrying one, and the three fields are always present — null or empty rather than absent — so a client can read the contract instead of feeling for it.
…fields The compact-resource test pinned the pre-change flow entry, so adding sequence, activities and logic to the projection made its whole-array comparison fail and took PHP CI down. Update the expectation to the shape the resource now emits. Also cover projectTransitions' non-array guard, which no fixture reached — it was the one statement standing between the new code and the 100% gate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-v0.6.61 #300 +/- ##
===============================================
Coverage 100.00% 100.00%
- Complexity 9815 9823 +8
===============================================
Files 523 523
Lines 37888 37903 +15
===============================================
+ Hits 37888 37903 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The problem
Http/Resources/v1/OrderConfig::projectFlow()projects each activity down tocode,status,details,color,complete,pod_methodandrequire_pod.Those describe an activity. None of them describes the flow's shape, so what a
public API consumer receives is an unordered set of activities with no way to put
them in order.
The fields that express the shape are exactly the ones being dropped:
activitiessequencelogicand/or/notconditions gating availabilityOrderConfig::nextActivity()→Activity::getNext()walks precisely theseserver-side, and the console's internal resource returns
flowwhole — so thegap is invisible from the console and only bites API consumers.
Why it matters
It is not cosmetic. A client that renders progress from array position marks an
order complete whenever
completedhappens to be declared before the order'scurrent activity. The default transport config on a stock instance returns:
completedfourth,dispatchedlast. So a freshly dispatched order shows everystep as done, reports itself complete, and offers no next step at all — the
driver-facing screen's primary action disappears on a job that has not started.
This was found building the Navigator redesign against a live instance.
The change
projectFlow()now also publishessequence,activitiesandlogic.nothing here a consumer of the config should not already see.
bare codes and as objects carrying a
code, and a consumer should not have toguess which it was handed. Entries with neither are skipped.
nullor[]rather than absent — so aclient can read the contract rather than feel for it.
Tests
Three cases added to
server/tests/Unit/Http/Resources/OrderConfigResourceTest.php:order and a branch carrying
logicVerified they fail when the projection is wrong, not just pass when it is right.
server/tests/Feature/Http/Api/OrderConfigControllerTest.phpfatals locally on amissing
Illuminate\Foundation\Auth\Access\AuthorizesRequeststrait. Thatreproduces on a clean tree at this base commit and is unrelated to this change,
which touches only a Resource.