How to get "rich text" for Text Suite from RTF record (JavaScript)?

Simple JavaScript example that should work:

(() => {
  const app = Application("DEVONthink 3");
  const rec = app.getRecordWithUuid("5A7B65E4-F969-43C2-8B93-EE5D15516F40");
  const txt = rec.richText();
  const paras = txt.paragraphs();
})()

(The record in question is of type RTF). Instead, it barfs at me that “paragraphs() is not a function”. True, since txt is simply of type string. But according to the documentation richText should deliver a Text object belonging to the (Extended) Text Suite. Which it does, when I use the equivalent AppleScript code:

tell application id "DNtp"
	set r to get record with uuid "5A7B65E4-F969-43C2-8B93-EE5D15516F40"
	set theText to rich text of r
	set paras to paragraphs of theText
	set c to count of paras
end tell

Nobody barfs, instead I get the lovely number of 3152 paragraphs.

Question: What would be the correct way to get at the paragraphs of an RTF record in JavaScript?

Since I’m at rich text already: It is a bit confusing that the method get rich text of seems to return the “rich text” of an HTML record (whatever that might mean - HTML seems to be rich enough already), whereas rich text (the property) seems to work on other record types as well.

Well, the correct way would be to not derefence rich text but instead do this:

const txt = rec.text;
const paras = txt.paragraphs();

(this may or may not work as well with richText, I didn’t try that yet.) Apple went “the extra mile” to make JXA apparently easier, but in fact it is really confusing sometimes. Especially in connection with a documentation that is kind of vague sometimes.

text is actually an addition to scripting of records since version 3.0. It’s also possible to directly change the rich text of records using this.

The next release will improve the description of the script suite.