Detect conflicts for Page entities during the handling of auto-saves/pending calls
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3589076. -->
Reported by: [f.mazeikis](https://www.drupal.org/user/3513671)
Related to !1107
>>>
<h3 id="overview">Overview</h3>
<p>As a first small step towards <a href="https://www.drupal.org/node/3587587">#3587587</a> we should start detecting conflicts during the polling of auto-save endpoint.<br>
More specifically, conflicts that are caused by updating entity for which there is already an auto-save entry in Canvas.</p>
<p>Current <code>openapi</code> definition of the <code>auto-saves/pending</code> endpoint only describes a HTTP 200 response.<br>
That is correct, as <code>ApiAutoSaveController::get()</code> does not perform validation or conflict detection and currently only returns HTTP 200 responses.<br>
This issue aims to change that by adding ability to detect certain types of conflicts and respond with HTTP 409.<br>
This will allow Canvas UI to be notified about a conflict, even if the user is not performing any actions that would previously trigger a conflict detection.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<ol>
<li>Add <code>openapi</code> definition for HTTP 409 response from the <code>auto-saves/pending</code> endpoint.</li>
<li>Start storing "original hash" during auto-save entry save, as this allows us to detect if the underlying entry has been updated since and there is a conflict between what auto-save assumes about the entity and the actual entity state.</li>
<li>Make AutoSaveManager to check for conflicts during fetching of the auto-save entry list, add relevant conflict metadata (<code>conflictId</code> and <code>timestamp</code>) to the entries.</li>
<li>Make <code>ApiAutoSaveController::get()</code> check entries for Page entities in the list and respond with HTTP 409 if at least one such entry has a conflict</li>
<li>As we will be making it possible to recover from some of detected conflicts, on conflicts caused by the change of the underlying auto-save entry entity we will return HTTP 409 and the response body will contain both:
<ul>
<li><code>error</code> with a new error code for errors describing auto-save entries with conflicts</li>
<li><code>data</code> with all the auto-save entries, including the entries with detected conflicts (thanks to <a class="project-issue-issue-link project-issue-status-info project-issue-status-2" href="https://www.drupal.org/project/canvas/issues/3588038">#3588038: Refactor auto-save endpoint response to encapsulate entries in top-level "data" key, like JSON:API, to enable adding errors later</a>)</li>
</ul>
</li>
<li>Add tests for all of this as well as update any existing tests that might start break due to unexpected HTTP 409</li>
</ol>
<h3 id="ui-changes">User interface changes</h3>
<p>For brief period of time until <a href="https://www.drupal.org/project/canvas/issues/3585970">#3585970: UI changes for detection of conflicts caused by external updates to underlying entity of auto-save entry</a> is merged there will be a possibility to encounter a situation where Canvas UI forces to refresh the page based on the conflict detection during auto-save endpoint polling.<br>
No other UI changes are introduced in this issue.</p>
> Related issue: [Issue #3587587](https://www.drupal.org/node/3587587)
task