@plotday/twister 0.48.0 → 0.49.0
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/bin/templates/AGENTS.template.md +8 -2
- package/cli/templates/AGENTS.template.md +8 -2
- package/dist/connector.d.ts +67 -7
- package/dist/connector.d.ts.map +1 -1
- package/dist/connector.js +15 -5
- package/dist/connector.js.map +1 -1
- package/dist/docs/assets/hierarchy.js +1 -1
- package/dist/docs/assets/navigation.js +1 -1
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/index.Connector.html +58 -49
- package/dist/docs/classes/index.Imap.html +1 -1
- package/dist/docs/classes/index.Options.html +1 -1
- package/dist/docs/classes/index.Smtp.html +1 -1
- package/dist/docs/classes/tools_ai.AI.html +1 -1
- package/dist/docs/classes/tools_callbacks.Callbacks.html +1 -1
- package/dist/docs/classes/tools_integrations.Integrations.html +21 -5
- package/dist/docs/classes/tools_network.Network.html +1 -1
- package/dist/docs/classes/tools_plot.Plot.html +1 -1
- package/dist/docs/classes/tools_store.Store.html +1 -1
- package/dist/docs/classes/tools_tasks.Tasks.html +1 -1
- package/dist/docs/classes/tools_twists.Twists.html +1 -1
- package/dist/docs/classes/twist.Twist.html +28 -28
- package/dist/docs/documents/Building_Connectors.html +8 -1
- package/dist/docs/enums/tag.Tag.html +11 -1
- package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/media/AGENTS.md +298 -775
- package/dist/docs/media/MULTI_USER_AUTH.md +6 -4
- package/dist/docs/media/SYNC_STRATEGIES.md +20 -14
- package/dist/docs/modules/index.html +1 -1
- package/dist/docs/types/index.CreateLinkDraft.html +7 -12
- package/dist/docs/types/index.NoteWriteBackResult.html +38 -0
- package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
- package/dist/docs/types/tools_integrations.AuthToken.html +4 -4
- package/dist/docs/types/tools_integrations.Authorization.html +4 -4
- package/dist/llm-docs/connector.d.ts +1 -1
- package/dist/llm-docs/connector.d.ts.map +1 -1
- package/dist/llm-docs/connector.js +1 -1
- package/dist/llm-docs/connector.js.map +1 -1
- package/dist/llm-docs/tag.d.ts +1 -1
- package/dist/llm-docs/tag.d.ts.map +1 -1
- package/dist/llm-docs/tag.js +1 -1
- package/dist/llm-docs/tag.js.map +1 -1
- package/dist/llm-docs/tools/integrations.d.ts +1 -1
- package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
- package/dist/llm-docs/tools/integrations.js +1 -1
- package/dist/llm-docs/tools/integrations.js.map +1 -1
- package/dist/llm-docs/twist-guide-template.d.ts +1 -1
- package/dist/llm-docs/twist-guide-template.d.ts.map +1 -1
- package/dist/llm-docs/twist-guide-template.js +1 -1
- package/dist/llm-docs/twist-guide-template.js.map +1 -1
- package/dist/llm-docs/twist.d.ts +1 -1
- package/dist/llm-docs/twist.d.ts.map +1 -1
- package/dist/llm-docs/twist.js +1 -1
- package/dist/llm-docs/twist.js.map +1 -1
- package/dist/tag.d.ts +11 -1
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +10 -0
- package/dist/tag.js.map +1 -1
- package/dist/tools/integrations.d.ts +22 -0
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js.map +1 -1
- package/dist/twist-guide.d.ts +1 -1
- package/dist/twist-guide.d.ts.map +1 -1
- package/dist/twist.d.ts +2 -1
- package/dist/twist.d.ts.map +1 -1
- package/dist/twist.js.map +1 -1
- package/dist/utils/markdown.d.ts +27 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +82 -0
- package/dist/utils/markdown.js.map +1 -0
- package/package.json +6 -1
- package/src/connector.ts +68 -7
- package/src/llm-docs/connector.ts +1 -1
- package/src/llm-docs/tag.ts +1 -1
- package/src/llm-docs/tools/integrations.ts +1 -1
- package/src/llm-docs/twist-guide-template.ts +1 -1
- package/src/llm-docs/twist.ts +1 -1
- package/src/tag.ts +10 -0
- package/src/tools/integrations.ts +24 -0
- package/src/twist.ts +2 -1
- package/src/utils/markdown.ts +94 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion helpers for connectors that bridge Plot markdown to external
|
|
3
|
+
* systems that store content as plain text (Google Drive comments, Todoist
|
|
4
|
+
* comments, Airtable cells, Attio notes, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Both functions are pure and run in-process inside the connector's twist
|
|
7
|
+
* runtime — no RPC boundary is crossed, so they are cheap to call on every
|
|
8
|
+
* `onNoteCreated` / `onNoteUpdated`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Render Markdown as plain text while preserving document structure.
|
|
13
|
+
*
|
|
14
|
+
* Numbered lists authored as `1. / 1. / 1.` in markdown are renumbered to
|
|
15
|
+
* `1. / 2. / 3.` so the plain-text reader sees real numbers. Bullet
|
|
16
|
+
* markers, headings content, blockquotes, and paragraph breaks survive;
|
|
17
|
+
* emphasis markers, code fences, and image syntax are dropped.
|
|
18
|
+
*
|
|
19
|
+
* Mentions `[Name](#@UUID)` render as `@Name`. Links `[text](url)`
|
|
20
|
+
* collapse to their label, falling back to the URL when the label is
|
|
21
|
+
* empty or identical to the URL.
|
|
22
|
+
*
|
|
23
|
+
* Use this when writing a Plot note to an external API that stores
|
|
24
|
+
* content verbatim as plain text. Pair the result with a matching
|
|
25
|
+
* `NoteWriteBackResult.externalContent` so the sync baseline round-trips.
|
|
26
|
+
*/
|
|
27
|
+
export function markdownToPlainText(markdown: string): string {
|
|
28
|
+
let text = markdown;
|
|
29
|
+
|
|
30
|
+
text = text.replace(/```[a-zA-Z0-9]*\n([\s\S]*?)```/g, "$1");
|
|
31
|
+
text = text.replace(/`([^`]+)`/g, "$1");
|
|
32
|
+
|
|
33
|
+
text = text.replace(/!\[[^\]]*\]\([^)]*\)/g, "");
|
|
34
|
+
|
|
35
|
+
text = text.replace(/\[([^\]]+)\]\(#@[^)]+\)/g, "@$1");
|
|
36
|
+
|
|
37
|
+
text = text.replace(/\[([^\]]*)\]\(<?([^>)]+)>?\)/g, (_, label, url) => {
|
|
38
|
+
if (!label) return url;
|
|
39
|
+
if (label === url) return url;
|
|
40
|
+
return label;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
text = text.replace(/^\s{0,3}#{1,6}\s+/gm, "");
|
|
44
|
+
text = text.replace(/^\s{0,3}>\s?/gm, "");
|
|
45
|
+
|
|
46
|
+
text = text.replace(/(\*\*|__)(.+?)\1/g, "$2");
|
|
47
|
+
text = text.replace(/(?<![*_])([*_])([^*_\n]+)\1(?![*_])/g, "$2");
|
|
48
|
+
text = text.replace(/~~(.+?)~~/g, "$1");
|
|
49
|
+
|
|
50
|
+
text = text.replace(/^\s{0,3}(?:-\s?){3,}\s*$/gm, "");
|
|
51
|
+
text = text.replace(/^\s{0,3}(?:\*\s?){3,}\s*$/gm, "");
|
|
52
|
+
text = text.replace(/^\s{0,3}(?:_\s?){3,}\s*$/gm, "");
|
|
53
|
+
|
|
54
|
+
text = renumberNumberedLists(text);
|
|
55
|
+
|
|
56
|
+
text = text
|
|
57
|
+
.replace(/&/g, "&")
|
|
58
|
+
.replace(/</g, "<")
|
|
59
|
+
.replace(/>/g, ">")
|
|
60
|
+
.replace(/"/g, '"')
|
|
61
|
+
.replace(/'/g, "'")
|
|
62
|
+
.replace(/ /g, " ");
|
|
63
|
+
|
|
64
|
+
text = text.replace(/\n{3,}/g, "\n\n");
|
|
65
|
+
|
|
66
|
+
return text.trim();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function renumberNumberedLists(text: string): string {
|
|
70
|
+
const lines = text.split("\n");
|
|
71
|
+
const numberedRe = /^(\s*)(\d+)\.(\s+)(.*)$/;
|
|
72
|
+
|
|
73
|
+
let currentIndent: string | null = null;
|
|
74
|
+
let counter = 0;
|
|
75
|
+
|
|
76
|
+
for (let i = 0; i < lines.length; i++) {
|
|
77
|
+
const match = numberedRe.exec(lines[i]);
|
|
78
|
+
if (!match) {
|
|
79
|
+
currentIndent = null;
|
|
80
|
+
counter = 0;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const [, indent, , space, content] = match;
|
|
84
|
+
if (indent !== currentIndent) {
|
|
85
|
+
currentIndent = indent;
|
|
86
|
+
counter = 1;
|
|
87
|
+
} else {
|
|
88
|
+
counter += 1;
|
|
89
|
+
}
|
|
90
|
+
lines[i] = `${indent}${counter}.${space}${content}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|