==Use case: raw content transformation==
Request to RESTBase: `POST /{domain}/v1/transform/html/to/wt`.
===TBD===
* [ ] Request content type, headers, body model
* [ ] Response status, content type, headers body model
==Use case: transformation of content from an existing page==
For html-to-wikitext support, we'll need to store the Wikitext in storage. See [[ https://github.com/wikimedia/parsoid/blob/master/lib/mediawiki.ApiRequest.js#L224 | how Parsoid gets wt from the MW API ]].
* Title and revision are passed: `POST /{domain}/v1/transform/html/to/wt/{title}/{revision}`
* An optional bodyOnly field causes the response to include only the `innerHTML` of the DOM body
===TBD===
* [ ] Request headers, body model
* [ ] Response status, content type, headers body model
==Implementation notes==
For html-to-wikitext support, we'll need to store the Wikitext in storage. See [[ https://github.com/wikimedia/parsoid/blob/master/lib/mediawiki.ApiRequest.js#L224 | how Parsoid gets wt from the MW API ]].
RESTBase retrieves the original html, wikitext & data-parsoid from storage & POSTs it to Parsoid:
```
POST parsoid/v2/{domain}/wt/{title}/{oldid}
{
"html": {
"headers": {
"content-type": "text/html;profile=mediawiki.org/specs/html/1.0.0"
},
"body": "<html>The modified HTML</html>"
},
"original": {
"revid": 12345,
"wikitext": {
"headers": {
"content-type": "text/plain;profile=mediawiki.org/specs/wikitext/1.0.0"
},
"body": "the original wikitext"
},
"html": {
"headers": {
"content-type": "text/html;profile=mediawiki.org/specs/html/1.0.0"
},
"body": "the original HTML"
},
"data-parsoid": {
"headers": {
"content-type": "application/json;profile=mediawiki.org/specs/data-parsoid/0.0.1"
},
"body": {
"ids": {}
}
}
}
}
```
If the modified `html` is just a string, then Parsoid is expected to assume that it's in the latest html version.
Parsoid returns the wikitext, which RESTBase returns to the client without any caching:
```
{
wikitext: {
headers: {
'content-type': 'text/plain;profile=mediawiki.org/specs/wikitext/1.0.0'
},
body: "the modified wikitext"
}
}
```
We could also just return the wikitext with the appropriate content-type header, but there is something to be said for consistency & the ability to return additional metadata (like warnings or errors) in the future.