@segmentstream/ontology 0.196.0 → 0.196.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.196.1
|
|
4
|
+
|
|
5
|
+
A Telegram rich message the ontology sends shows a table written on the line right after text as a
|
|
6
|
+
table. Markdown reads such a table as a block of its own, while Telegram took it as more of the
|
|
7
|
+
text before it and showed its rows as one line of pipes; the rich message now has the Markdown's
|
|
8
|
+
blocks a blank line apart, each as written.
|
|
9
|
+
|
|
3
10
|
## 0.196.0
|
|
4
11
|
|
|
5
12
|
Allow chat persona rules to match a trusted registration time. A workspace can change the initial persona for new groups while preserving inherited settings in established groups.
|
|
@@ -12,9 +12,10 @@ export { TELEGRAM_MESSAGE_LIMIT };
|
|
|
12
12
|
export declare function renderTelegram(markdown: string, attribution: string, separator?: string, links?: ReadonlyMap<string, string>): string;
|
|
13
13
|
/**
|
|
14
14
|
* The message as one Telegram rich message, for Markdown with a table, which MarkdownV2 shows only
|
|
15
|
-
* as code: the member's Markdown, its
|
|
16
|
-
* attribution. Undefined without a table, beyond what one
|
|
17
|
-
* Markdown leaves open, such as a code fence it never
|
|
15
|
+
* as code: the member's Markdown, its blocks a blank line apart and its links to the app as
|
|
16
|
+
* `renderTelegram` points them, then the attribution. Undefined without a table, beyond what one
|
|
17
|
+
* rich message takes, or when a block the Markdown leaves open, such as a code fence it never
|
|
18
|
+
* closes, would take the attribution in.
|
|
18
19
|
*/
|
|
19
20
|
export declare function telegramRichMarkdown(markdown: string, attribution: string, separator?: string, links?: ReadonlyMap<string, string>): string | undefined;
|
|
20
21
|
/** Buttons as Telegram shows them: an inline keyboard, a workspace button's data `ws:<token>`. */
|
|
@@ -75,18 +75,35 @@ function richShape(tree) {
|
|
|
75
75
|
}
|
|
76
76
|
return shape;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The Markdown's blocks, each as written, a blank line apart. Markdown takes a table on the line
|
|
80
|
+
* after a paragraph's text as a block of its own; Telegram's rich message takes it as more of the
|
|
81
|
+
* paragraph's text, so a table is sent apart from the text before it, as it was read here.
|
|
82
|
+
*/
|
|
83
|
+
function markdownBlocksApart(markdown) {
|
|
84
|
+
const blocks = converter.toAst(markdown).children.map((node) => {
|
|
85
|
+
const start = node.position?.start.offset;
|
|
86
|
+
const end = node.position?.end.offset;
|
|
87
|
+
return start === undefined || end === undefined ? undefined : markdown.slice(start, end);
|
|
88
|
+
});
|
|
89
|
+
return blocks.every((block) => block !== undefined) ? blocks.join("\n\n") : markdown;
|
|
90
|
+
}
|
|
78
91
|
/**
|
|
79
92
|
* The message as one Telegram rich message, for Markdown with a table, which MarkdownV2 shows only
|
|
80
|
-
* as code: the member's Markdown, its
|
|
81
|
-
* attribution. Undefined without a table, beyond what one
|
|
82
|
-
* Markdown leaves open, such as a code fence it never
|
|
93
|
+
* as code: the member's Markdown, its blocks a blank line apart and its links to the app as
|
|
94
|
+
* `renderTelegram` points them, then the attribution. Undefined without a table, beyond what one
|
|
95
|
+
* rich message takes, or when a block the Markdown leaves open, such as a code fence it never
|
|
96
|
+
* closes, would take the attribution in.
|
|
83
97
|
*/
|
|
84
98
|
export function telegramRichMarkdown(markdown, attribution, separator = "\n\n", links = new Map()) {
|
|
85
99
|
// A table has pipes: Markdown without one is not parsed again.
|
|
86
100
|
if (!markdown.includes("|")) {
|
|
87
101
|
return undefined;
|
|
88
102
|
}
|
|
89
|
-
|
|
103
|
+
// Written back from its tree, Markdown with links to the app has its blocks apart already.
|
|
104
|
+
const body = links.size === 0
|
|
105
|
+
? markdownBlocksApart(markdown)
|
|
106
|
+
: stringifyMarkdown(telegramMarkdownWithLinks(markdown, links));
|
|
90
107
|
const signed = attribution === "" ? "" : markdownAttribution(attribution, separator);
|
|
91
108
|
const rich = signed === "" ? body : `${body}\n\n${signed}`;
|
|
92
109
|
const tree = converter.toAst(rich);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.196.
|
|
3
|
+
"version": "0.196.1",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|