We need to create a normalizer (something like \Drupal\relaxed\Normalizer\RevsDiffNormalizer) and a new resource endpoint (something like \Drupal\relaxed\Plugin\rest\RevsDiffResource).
The resource should follow the following specification: http://docs.couchdb.org/en/latest/api/database/misc.html#db-revs-diff
To clarify the CouchDB documentation; In the example below the dictionary key (190f721ca3411be7aa9477db5f948bbb) is the document ID for the given revision IDs. This makes it so that you can post multiple document/revision combinations to the endpoint.
POST /db/_revs_diff HTTP/1.1
Accept: application/json
Content-Length: 113
Content-Type: application/json
Host: localhost:5984
{
"190f721ca3411be7aa9477db5f948bbb": [
"3-bb72a7682290f94a985f7afac8b27137",
"4-10265e5a26d807a3cfa459cf1a82ef2e",
"5-067a00dff5e02add41819138abb3284d"
]
}
We should use the \Drupal\multiversion\Entity\RevisionIndex to look up all the revisions. See this example of how it's used: https://github.com/dickolsson/drupal-relaxed/blob/8.x-1.x/src/ParamConve...
We can skip the possible_ancestors key for now and deal with that in #2344005: Implement the possible_ancestors key
For the normalizer we should create a new service class, something like this (totally untested):
class RevisionDiff implements RevisionDiffInterface {
public function __construct(RevisionIndex $rev_index) {
$this->revisionIndex = $rev_index;
}
public function entities(array $entity_keys) {
$this->entityKeys = $entity_keys;
return $this;
}
public function getMissing() {
$keys = array();
foreach ($this->EntityKeys as $entity_uuid => $revision_ids) {
foreach ($revision_ids as $revison_id) {
$keys[] = $entity_uuid . ':' . $revision_id;
}
}
$existing_revision_ids = $this->revisionIndex->getMultiple($keys);
// Do diff.
return $missing_revision_ids;
}
}
With this one could then do:
$entity_keys = array(
'123-some-uuid-456' => array(
'1-123-some-revision-id-567',
'2-890-some-revision-id-123',
// ...
),
);
$missing = $revDiff->entities($entity_keys)->getMissing();
Comments
Comment #1
dixon_Comment #2
dixon_Comment #3
dixon_Updates the issue summary with some more details.
Comment #4
dixon_Comment #5
dixon_Comment #6
dixon_Comment #7
dixon_Comment #8
dixon_Comment #9
dixon_Comment #10
jeqq commentedThe implementation will be done on the 2282287-_revs_diff-endpoint branch (https://github.com/dickolsson/drupal-relaxed/tree/2282287-_revs_diff-end...).
Comment #11
dixon_