updated mcp
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-03-08 17:57:34 +05:30
parent 9191de9dff
commit 0e49f02c4c
167 changed files with 7632 additions and 98942 deletions

View File

@@ -1170,31 +1170,32 @@
<div class="doc doc-contents first">
<p>Message parsing utilities for Mail Intake.</p>
<hr />
<h4 id="mail_intake.parsers--summary">Summary</h4>
<h3 id="mail_intake.parsers--summary">Summary</h3>
<p>Message parsing utilities for Mail Intake.</p>
<p>This package contains <strong>provider-aware but adapter-agnostic parsing helpers</strong>
used to extract and normalize structured information from raw mail payloads.</p>
<p>Parsers in this package are responsible for:
- Interpreting provider-native message structures
- Extracting meaningful fields such as headers, body text, and subjects
- Normalizing data into consistent internal representations</p>
<p>This package does not:
- Perform network or IO operations
- Contain provider API logic
- Construct domain models directly</p>
<p>Parsers in this package are responsible for:</p>
<ul>
<li>Interpreting provider-native message structures.</li>
<li>Extracting meaningful fields such as headers, body text, and subjects.</li>
<li>Normalizing data into consistent internal representations.</li>
</ul>
<p>This package does not:</p>
<ul>
<li>Perform network or IO operations.</li>
<li>Contain provider API logic.</li>
<li>Construct domain models directly.</li>
</ul>
<p>Parsing functions are designed to be composable and are orchestrated by the
ingestion layer.</p>
<hr />
<h4 id="mail_intake.parsers--public-api">Public API</h4>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>extract_body
parse_headers
extract_sender
normalize_subject
</code></pre></div></td></tr></table></div>
<h3 id="mail_intake.parsers--public-api">Public API</h3>
<ul>
<li><code>extract_body</code></li>
<li><code>parse_headers</code></li>
<li><code>extract_sender</code></li>
<li><code>normalize_subject</code></li>
</ul>
<hr />
@@ -1223,11 +1224,13 @@ normalize_subject
<div class="doc doc-contents ">
<p>Extract the best-effort message body from a Gmail payload.</p>
<p>Priority:
1. text/plain
2. text/html (stripped to text)
3. Single-part body
4. empty string (if nothing usable found)</p>
<p>Priority:</p>
<ol>
<li><code>text/plain</code></li>
<li><code>text/html</code> (stripped to text)</li>
<li>Single-part body</li>
<li>Empty string (if nothing usable found)</li>
</ol>
<p><span class="doc-section-title">Parameters:</span></p>
@@ -1263,13 +1266,13 @@ normalize_subject
<table>
<thead>
<tr>
<th>Type</th>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<td><code>str</code></td> <td>
<code>str</code>
</td>
<td>
@@ -1319,7 +1322,7 @@ normalize_subject
</td>
<td>
<div class="doc-md-description">
<p>Normalized header dictionary as returned by :func:<code>parse_headers</code>.</p>
<p>Normalized header dictionary as returned by <code>parse_headers()</code>.</p>
</div>
</td>
<td>
@@ -1346,7 +1349,8 @@ normalize_subject
<td>
<div class="doc-md-description">
<p>Tuple[str, Optional[str]]:
A tuple <code>(email, name)</code> where <code>email</code> is the sender email address and <code>name</code> is the display name, or <code>None</code> if unavailable.</p>
A tuple <code>(email, name)</code> where <code>email</code> is the sender email address
and <code>name</code> is the display name, or <code>None</code> if unavailable.</p>
</div>
</td>
</tr>
@@ -1357,17 +1361,19 @@ A tuple <code>(email, name)</code> where <code>email</code> is the sender email
<details class="notes" open>
<summary>Notes</summary>
<p><strong>Responsibilities:</strong></p>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>- This function parses the ``From`` header and attempts to extract sender email address and optional human-readable display name
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>- This function parses the `From` header and attempts to extract
sender email address and optional human-readable display name.
</code></pre></div></td></tr></table></div>
</details>
<details class="example" open>
<summary>Example</summary>
<p>Typical values:</p>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>``&quot;John Doe &lt;john@example.com&gt;&quot;`` -&gt; ``(&quot;john@example.com&quot;, &quot;John Doe&quot;)``
``&quot;john@example.com&quot;`` -&gt; ``(&quot;john@example.com&quot;, None)``
</code></pre></div></td></tr></table></div>
<ul>
<li><code>"John Doe &lt;john@example.com&gt;"</code> -&gt; <code>("john@example.com", "John Doe")</code></li>
<li><code>"john@example.com"</code> -&gt; <code>("john@example.com", None)</code></li>
</ul>
</details>
</div>
@@ -1447,13 +1453,15 @@ A tuple <code>(email, name)</code> where <code>email</code> is the sender email
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- Strips common prefixes such as ``Re:``, ``Fwd:``, and ``FW:``
- Repeats prefix stripping to handle stacked prefixes
- Collapses excessive whitespace
- Preserves original casing (no lowercasing)
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.
- Repeats prefix stripping to handle stacked prefixes.
- Collapses excessive whitespace.
- Preserves original casing (no lowercasing).
</code></pre></div></td></tr></table></div>
<p><strong>Guarantees:</strong></p>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>- This function is intentionally conservative and avoids aggressive transformations that could alter the semantic meaning of the subject
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>- This function is intentionally conservative and avoids aggressive
transformations that could alter the semantic meaning of the subject.
</code></pre></div></td></tr></table></div>
</details>
</div>
@@ -1533,36 +1541,40 @@ Dictionary mapping lowercase header names to stripped values.</p>
<summary>Notes</summary>
<p><strong>Guarantees:</strong></p>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>- Provider payloads (such as Gmail) typically represent headers as a list of name/value mappings
- This function normalizes them into a case-insensitive dictionary keyed by lowercase header names
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- Provider payloads (such as Gmail) typically represent headers as a
list of name/value mappings.
- This function normalizes them into a case-insensitive dictionary
keyed by lowercase header names.
</code></pre></div></td></tr></table></div>
</details>
<details class="example" open>
<summary>Example</summary>
<p>Typical usage:</p>
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span></pre></div></td><td class="code"><div><pre><span></span><code>Input:
[
{&quot;name&quot;: &quot;From&quot;, &quot;value&quot;: &quot;John Doe &lt;john@example.com&gt;&quot;},
{&quot;name&quot;: &quot;Subject&quot;, &quot;value&quot;: &quot;Re: Interview Update&quot;},
]
Output:
{
&quot;from&quot;: &quot;John Doe &lt;john@example.com&gt;&quot;,
&quot;subject&quot;: &quot;Re: Interview Update&quot;,
}
</code></pre></div></td></tr></table></div>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1"> 1</a></span>
<span class="normal"><a href="#__codelineno-0-2"> 2</a></span>
<span class="normal"><a href="#__codelineno-0-3"> 3</a></span>
<span class="normal"><a href="#__codelineno-0-4"> 4</a></span>
<span class="normal"><a href="#__codelineno-0-5"> 5</a></span>
<span class="normal"><a href="#__codelineno-0-6"> 6</a></span>
<span class="normal"><a href="#__codelineno-0-7"> 7</a></span>
<span class="normal"><a href="#__codelineno-0-8"> 8</a></span>
<span class="normal"><a href="#__codelineno-0-9"> 9</a></span>
<span class="normal"><a href="#__codelineno-0-10">10</a></span>
<span class="normal"><a href="#__codelineno-0-11">11</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="n">Input</span><span class="p">:</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="p">[</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;From&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="s2">&quot;John Doe &lt;john@example.com&gt;&quot;</span><span class="p">},</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4"></a> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Subject&quot;</span><span class="p">,</span> <span class="s2">&quot;value&quot;</span><span class="p">:</span> <span class="s2">&quot;Re: Interview Update&quot;</span><span class="p">},</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5"></a> <span class="p">]</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6"></a>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7"></a><span class="n">Output</span><span class="p">:</span>
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8"></a> <span class="p">{</span>
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9"></a> <span class="s2">&quot;from&quot;</span><span class="p">:</span> <span class="s2">&quot;John Doe &lt;john@example.com&gt;&quot;</span><span class="p">,</span>
</span><span id="__span-0-10"><a id="__codelineno-0-10" name="__codelineno-0-10"></a> <span class="s2">&quot;subject&quot;</span><span class="p">:</span> <span class="s2">&quot;Re: Interview Update&quot;</span><span class="p">,</span>
</span><span id="__span-0-11"><a id="__codelineno-0-11" name="__codelineno-0-11"></a> <span class="p">}</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>