Refactor auto-save endpoint response to encapsulate entries in top-level "data" key, like JSON:API, to enable adding errors later
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3588038. --> Reported by: [f.mazeikis](https://www.drupal.org/user/3513671) Related to !1047 >>> <h3 id="overview">Overview</h3> <p>Currently <code>auto-saves/pending</code> endpoint returns auto-save entries as a collection of objects:</p> <pre>{<br>&nbsp; 'entry_key:1' : {entry_1}, <br>&nbsp; 'entry_key:2' : {entry_2}<br>}</pre><p>This worked fine until now, but going forward we should stick closer to JSON:API response structure, specifically the <a href="https://jsonapi.org/format/#document-top-level" title="JSON:API format documentation">document top level format</a>. Specifically, we should encapsulate the entries in <code>data</code> property on HTTP 200 responses:</p> <pre>{<br> 'data' : {<br>&nbsp;&nbsp; 'entry_key:1' : {entry_1}, <br>&nbsp;&nbsp; 'entry_key:2' : {entry_2}<br> }<br>}</pre><p>Doing this will allow us to return HTTP 409 <code>errors</code> as well as <code>data</code> when we will be adding an ability to recover from some of the HTTP 409 responses using Canvas UI without forcing page refresh as part of <a href="https://www.drupal.org/project/canvas/issues/3587587">[#3587587]</a></p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>Modify the controller, tests and openapi response definition for <code>auto-saves/pending</code> HTTP 200 response to be encapsulated in a <code>data</code> property at the top level.</p> <h3 id="ui-changes">User interface changes</h3> <p>Minor change in React code to support new response structure, no changes that affect end-user.</p> > Related issue: [Issue #3588923](https://www.drupal.org/node/3588923) > Related issue: [Issue #3587587](https://www.drupal.org/node/3587587)
issue