@realtimex/email-automator 2.4.5 → 2.6.4
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/api/src/routes/emails.ts +37 -1
- package/api/src/routes/rules.ts +7 -2
- package/api/src/services/gmail.ts +53 -166
- package/api/src/services/intelligence.ts +2 -1
- package/api/src/services/microsoft.ts +34 -29
- package/api/src/services/processor.ts +376 -106
- package/api/src/services/storage.ts +88 -0
- package/api/src/services/supabase.ts +6 -0
- package/api/src/utils/contentCleaner.ts +11 -6
- package/dist/api/src/routes/emails.js +27 -1
- package/dist/api/src/routes/rules.js +6 -2
- package/dist/api/src/services/gmail.js +49 -138
- package/dist/api/src/services/intelligence.js +2 -1
- package/dist/api/src/services/microsoft.js +28 -18
- package/dist/api/src/services/processor.js +335 -96
- package/dist/api/src/services/storage.js +81 -0
- package/dist/api/src/utils/contentCleaner.js +10 -6
- package/dist/assets/index-BSHZ3lFn.js +97 -0
- package/dist/assets/index-CRQKk5IW.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +3 -1
- package/supabase/functions/api-v1-accounts/index.ts +28 -7
- package/supabase/migrations/20260118000001_async_etl_storage.sql +24 -0
- package/dist/assets/index-C3PlbplS.css +0 -1
- package/dist/assets/index-DfGa9R7j.js +0 -97
|
@@ -6,9 +6,10 @@ export class ContentCleaner {
|
|
|
6
6
|
static cleanEmailBody(text) {
|
|
7
7
|
if (!text)
|
|
8
8
|
return "";
|
|
9
|
+
const originalText = text;
|
|
9
10
|
// 0. Lightweight HTML -> Markdown Conversion
|
|
10
11
|
// Structure: <br>, <p> -> Newlines
|
|
11
|
-
text = text.replace(/<br\s
|
|
12
|
+
text = text.replace(/<br\s*\/?>/gi, '\n');
|
|
12
13
|
text = text.replace(/<\/p>/gi, '\n\n');
|
|
13
14
|
text = text.replace(/<p.*?>/gi, ''); // Open p tags just gone
|
|
14
15
|
// Structure: Headers <h1>-<h6> -> # Title
|
|
@@ -58,12 +59,12 @@ export class ContentCleaner {
|
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
61
|
// 3. Check for specific reply separators
|
|
61
|
-
// If we hit a reply header, we truncate the rest
|
|
62
|
+
// If we hit a reply header, we truncate the rest
|
|
62
63
|
if (/^On .* wrote:$/i.test(lineStripped)) {
|
|
63
64
|
break;
|
|
64
65
|
}
|
|
65
|
-
// 4. Footer removal (
|
|
66
|
-
if (lineStripped.length <
|
|
66
|
+
// 4. Footer removal (only on very short lines to avoid stripping body content)
|
|
67
|
+
if (lineStripped.length < 60) {
|
|
67
68
|
let isFooter = false;
|
|
68
69
|
for (const pattern of footerPatterns) {
|
|
69
70
|
if (pattern.test(lineStripped)) {
|
|
@@ -79,10 +80,13 @@ export class ContentCleaner {
|
|
|
79
80
|
}
|
|
80
81
|
// Reassemble
|
|
81
82
|
text = cleanedLines.join('\n');
|
|
83
|
+
// Safety Fallback: If cleaning stripped everything, return original (truncated)
|
|
84
|
+
if (!text.trim() || text.length < 10) {
|
|
85
|
+
text = originalText.substring(0, 3000);
|
|
86
|
+
}
|
|
82
87
|
// Collapse multiple newlines
|
|
83
88
|
text = text.replace(/\n{3,}/g, '\n\n');
|
|
84
|
-
// Sanitize LLM Special Tokens
|
|
85
|
-
// Break sequences like <|channel|>, [INST], <s>
|
|
89
|
+
// Sanitize LLM Special Tokens
|
|
86
90
|
text = text.replace(/<\|/g, '< |');
|
|
87
91
|
text = text.replace(/\|>/g, '| >');
|
|
88
92
|
text = text.replace(/\[INST\]/gi, '[ INST ]');
|