scheme-sdk 0.3.1__tar.gz → 0.3.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scheme_sdk
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: The Scheme SDK provides connectors for ingesting conversations, messages, and files across communication platforms.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scheme_sdk"
7
- version = "0.3.1"
7
+ version = "0.3.2"
8
8
  description = "The Scheme SDK provides connectors for ingesting conversations, messages, and files across communication platforms."
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -18,33 +18,54 @@ class OutlookConnector(MessageConnector):
18
18
  self.base = "https://graph.microsoft.com/v1.0"
19
19
 
20
20
  def fetch_conversations(
21
- self, top: int = 50, since_iso: Optional[str] = None
21
+ self,
22
+ top: int = 50,
23
+ query: Optional[str] = None,
24
+ since_iso: Optional[str] = None,
22
25
  ) -> List[Dict]:
23
26
  url = f"{self.base}/me/messages"
27
+ page_size = min(max(top, 50), 200)
24
28
  params = {
25
29
  "$select": "id,conversationId,subject,from,receivedDateTime,hasAttachments",
26
30
  "$orderby": "receivedDateTime desc",
27
- "$top": str(top),
31
+ "$top": str(page_size),
28
32
  }
29
33
  if since_iso:
30
34
  params["$filter"] = f"receivedDateTime ge {since_iso}"
35
+ if query:
36
+ params["$search"] = query
31
37
 
32
- messages = self._get_paged(url, headers=self._headers(), params=params)
33
-
34
- # Dedupe by conversationId
38
+ # Dedupe by conversationId, fetching more pages until we have enough.
35
39
  threads_by_conv: Dict[str, Dict] = {}
36
- for m in messages:
37
- cid = m.get("conversationId")
38
- if not cid:
39
- continue
40
- if cid not in threads_by_conv:
40
+ next_url = url
41
+ next_params: Optional[Dict[str, str]] = params
42
+
43
+ while next_url and len(threads_by_conv) < top:
44
+ resp = self._request_with_throttling_retry(
45
+ next_url, headers=self._headers(), params=next_params
46
+ )
47
+ resp.raise_for_status()
48
+ data = resp.json()
49
+
50
+ for m in data.get("value", []):
51
+ cid = m.get("conversationId")
52
+ if not cid or cid in threads_by_conv:
53
+ continue
41
54
  threads_by_conv[cid] = m
55
+ if len(threads_by_conv) >= top:
56
+ break
57
+
58
+ # Per Graph guidance: use @odata.nextLink as-is
59
+ next_url = data.get("@odata.nextLink")
60
+ next_params = None # nextLink already includes the query string
42
61
 
43
62
  conv_list = list(threads_by_conv.values())
44
63
  return [self.normalize_conversation(c) for c in conv_list]
45
64
 
46
65
  def fetch_messages(
47
- self, conversation_id: str, since_iso: Optional[str] = None
66
+ self,
67
+ conversation_id: str,
68
+ since_iso: Optional[str] = None,
48
69
  ) -> List[Dict]:
49
70
  url = f"{self.base}/me/messages"
50
71
  filter_parts = [f"conversationId eq '{conversation_id}'"]
File without changes
File without changes