feat!: clean /platforms REST contract — ordered array, slug, filter fetch handlers#131
Merged
feat!: clean /platforms REST contract — ordered array, slug, filter fetch handlers#131
Conversation
…dlers, sort authenticated-first
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
GET /datamachine/v1/socials/platformsreturned a slug-keyed object with implicit ordering (a side effect of whichnew ()calls fired first indata-machine-socials.php), included Reddit (a fetch handler) in a "where can I publish socially" list, and required every client to normalize capability shape and synthesize aslugfield from object keys.This is the upstream cause of the studio sidebar ordering question and a chunk of mirrored client logic across consumers.
Breaking changes
Old shape
{ "twitter": { "label": "Twitter", "authenticated": true, ... }, "facebook": { "label": "Facebook", "authenticated": false, ... }, "instagram": { "label": "Instagram", "authenticated": true, ... }, "reddit": { "label": "Reddit", "type": "fetch", ... }, ... }New shape
{ "platforms": [ { "slug": "bluesky", "label": "Bluesky", "authenticated": true, ... }, { "slug": "instagram", "label": "Instagram", "authenticated": true, ... }, { "slug": "twitter", "label": "Twitter", "authenticated": true, ... }, { "slug": "facebook", "label": "Facebook", "authenticated": false, ... }, { "slug": "linkedin", "label": "LinkedIn", "authenticated": false, ... }, { "slug": "pinterest", "label": "Pinterest", "authenticated": false, ... }, { "slug": "threads", "label": "Threads", "authenticated": false, ... } ] }Server-side rules
slugon every entry. Clients no longer reconstruct it from object keys.capabilitiesto canonical[{slug, label}]. Legacy bare-string lists from older handlers are still accepted by the normaliser but converted; clients can rely on the canonical shape.{ platforms: [...] }envelope. Leaves room to add metadata (total,last_updated,version) without another breaking change.Verified locally
Coordinated rollout
This is PR A of a 3-PR cluster. Merge order matters:
data-machine-socialsextrachill-api-clienttypes +getPlatforms()signature updateextrachill-studioconsumes the new shapeStudio + api-client will break against this PR until B + C land. Internal
getPlatforms()export in DM Socials' ownsrc/utils/api.tsupdated in this PR for consistency (the export is unused by DM Socials' Gutenberg sidebar, which usesgetAuthStatusinstead, so no internal regression risk).Test plan
php -lclean