Skip to content

Commit d5cb6c2

Browse files
feat(api): remove limit from list routes
1 parent 2443524 commit d5cb6c2

File tree

9 files changed

+125
-91
lines changed

9 files changed

+125
-91
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-803a4423d75f7a43582319924f0770153fd5ec313b9466c290513b9a891c2653.yml
3-
openapi_spec_hash: f32dfbf172bb043fd8c961cba5f73765
4-
config_hash: fc42f6a9efd6f34ca68f1c4328272acf
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-a3fb0de6dd98f8a51d73e3fdf51de6143f2e8e764048246392624a56b4a3a481.yml
3+
openapi_spec_hash: 50e1001c340cb0bd3436b6329240769b
4+
config_hash: 2e31d02f28a11ef29eb747bcf559786a

api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ Methods:
5454

5555
- <code title="post /v1/chats">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">create</a>(\*\*<a href="src/beeper_desktop_api/types/chat_create_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat_create_response.py">ChatCreateResponse</a></code>
5656
- <code title="get /v1/chats/{chatID}">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">retrieve</a>(chat_id, \*\*<a href="src/beeper_desktop_api/types/chat_retrieve_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat.py">Chat</a></code>
57-
- <code title="get /v1/chats">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">list</a>(\*\*<a href="src/beeper_desktop_api/types/chat_list_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat_list_response.py">SyncCursor[ChatListResponse]</a></code>
57+
- <code title="get /v1/chats">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">list</a>(\*\*<a href="src/beeper_desktop_api/types/chat_list_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat_list_response.py">SyncCursorList[ChatListResponse]</a></code>
5858
- <code title="post /v1/chats/{chatID}/archive">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">archive</a>(chat_id, \*\*<a href="src/beeper_desktop_api/types/chat_archive_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/shared/base_response.py">BaseResponse</a></code>
59-
- <code title="get /v1/chats/search">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">search</a>(\*\*<a href="src/beeper_desktop_api/types/chat_search_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat.py">SyncCursor[Chat]</a></code>
59+
- <code title="get /v1/chats/search">client.chats.<a href="./src/beeper_desktop_api/resources/chats/chats.py">search</a>(\*\*<a href="src/beeper_desktop_api/types/chat_search_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/chat.py">SyncCursorSearch[Chat]</a></code>
6060

6161
## Reminders
6262

@@ -75,6 +75,6 @@ from beeper_desktop_api.types import MessageSendResponse
7575

7676
Methods:
7777

78-
- <code title="get /v1/messages">client.messages.<a href="./src/beeper_desktop_api/resources/messages.py">list</a>(\*\*<a href="src/beeper_desktop_api/types/message_list_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/shared/message.py">SyncCursor[Message]</a></code>
79-
- <code title="get /v1/messages/search">client.messages.<a href="./src/beeper_desktop_api/resources/messages.py">search</a>(\*\*<a href="src/beeper_desktop_api/types/message_search_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/shared/message.py">SyncCursor[Message]</a></code>
78+
- <code title="get /v1/messages">client.messages.<a href="./src/beeper_desktop_api/resources/messages.py">list</a>(\*\*<a href="src/beeper_desktop_api/types/message_list_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/shared/message.py">SyncCursorList[Message]</a></code>
79+
- <code title="get /v1/messages/search">client.messages.<a href="./src/beeper_desktop_api/resources/messages.py">search</a>(\*\*<a href="src/beeper_desktop_api/types/message_search_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/shared/message.py">SyncCursorSearch[Message]</a></code>
8080
- <code title="post /v1/messages">client.messages.<a href="./src/beeper_desktop_api/resources/messages.py">send</a>(\*\*<a href="src/beeper_desktop_api/types/message_send_params.py">params</a>) -> <a href="./src/beeper_desktop_api/types/message_send_response.py">MessageSendResponse</a></code>

src/beeper_desktop_api/pagination.py

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
99

10-
__all__ = ["SyncCursor", "AsyncCursor"]
10+
__all__ = ["SyncCursorSearch", "AsyncCursorSearch", "SyncCursorList", "AsyncCursorList"]
1111

1212
_T = TypeVar("_T")
1313

1414

15-
class SyncCursor(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
15+
class SyncCursorSearch(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
1616
items: List[_T]
1717
has_more: Optional[bool] = FieldInfo(alias="hasMore", default=None)
1818
oldest_cursor: Optional[str] = FieldInfo(alias="oldestCursor", default=None)
@@ -42,7 +42,67 @@ def next_page_info(self) -> Optional[PageInfo]:
4242
return PageInfo(params={"cursor": oldest_cursor})
4343

4444

45-
class AsyncCursor(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
45+
class AsyncCursorSearch(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
46+
items: List[_T]
47+
has_more: Optional[bool] = FieldInfo(alias="hasMore", default=None)
48+
oldest_cursor: Optional[str] = FieldInfo(alias="oldestCursor", default=None)
49+
newest_cursor: Optional[str] = FieldInfo(alias="newestCursor", default=None)
50+
51+
@override
52+
def _get_page_items(self) -> List[_T]:
53+
items = self.items
54+
if not items:
55+
return []
56+
return items
57+
58+
@override
59+
def has_next_page(self) -> bool:
60+
has_more = self.has_more
61+
if has_more is not None and has_more is False:
62+
return False
63+
64+
return super().has_next_page()
65+
66+
@override
67+
def next_page_info(self) -> Optional[PageInfo]:
68+
oldest_cursor = self.oldest_cursor
69+
if not oldest_cursor:
70+
return None
71+
72+
return PageInfo(params={"cursor": oldest_cursor})
73+
74+
75+
class SyncCursorList(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
76+
items: List[_T]
77+
has_more: Optional[bool] = FieldInfo(alias="hasMore", default=None)
78+
oldest_cursor: Optional[str] = FieldInfo(alias="oldestCursor", default=None)
79+
newest_cursor: Optional[str] = FieldInfo(alias="newestCursor", default=None)
80+
81+
@override
82+
def _get_page_items(self) -> List[_T]:
83+
items = self.items
84+
if not items:
85+
return []
86+
return items
87+
88+
@override
89+
def has_next_page(self) -> bool:
90+
has_more = self.has_more
91+
if has_more is not None and has_more is False:
92+
return False
93+
94+
return super().has_next_page()
95+
96+
@override
97+
def next_page_info(self) -> Optional[PageInfo]:
98+
oldest_cursor = self.oldest_cursor
99+
if not oldest_cursor:
100+
return None
101+
102+
return PageInfo(params={"cursor": oldest_cursor})
103+
104+
105+
class AsyncCursorList(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
46106
items: List[_T]
47107
has_more: Optional[bool] = FieldInfo(alias="hasMore", default=None)
48108
oldest_cursor: Optional[str] = FieldInfo(alias="oldestCursor", default=None)

src/beeper_desktop_api/resources/chats/chats.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
async_to_raw_response_wrapper,
2828
async_to_streamed_response_wrapper,
2929
)
30-
from ...pagination import SyncCursor, AsyncCursor
30+
from ...pagination import SyncCursorList, AsyncCursorList, SyncCursorSearch, AsyncCursorSearch
3131
from ...types.chat import Chat
3232
from ..._base_client import AsyncPaginator, make_request_options
3333
from ...types.chat_list_response import ChatListResponse
@@ -173,14 +173,13 @@ def list(
173173
account_ids: SequenceNotStr[str] | Omit = omit,
174174
cursor: str | Omit = omit,
175175
direction: Literal["after", "before"] | Omit = omit,
176-
limit: int | Omit = omit,
177176
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
178177
# The extra values given here take precedence over values defined on the client or passed to this method.
179178
extra_headers: Headers | None = None,
180179
extra_query: Query | None = None,
181180
extra_body: Body | None = None,
182181
timeout: float | httpx.Timeout | None | NotGiven = not_given,
183-
) -> SyncCursor[ChatListResponse]:
182+
) -> SyncCursorList[ChatListResponse]:
184183
"""List all chats sorted by last activity (most recent first).
185184
186185
Combines all
@@ -195,8 +194,6 @@ def list(
195194
direction: Pagination direction used with 'cursor': 'before' fetches older results, 'after'
196195
fetches newer results. Defaults to 'before' when only 'cursor' is provided.
197196
198-
limit: Maximum number of chats to return (1–200). Defaults to 50.
199-
200197
extra_headers: Send extra headers
201198
202199
extra_query: Add additional query parameters to the request
@@ -207,7 +204,7 @@ def list(
207204
"""
208205
return self._get_api_list(
209206
"/v1/chats",
210-
page=SyncCursor[ChatListResponse],
207+
page=SyncCursorList[ChatListResponse],
211208
options=make_request_options(
212209
extra_headers=extra_headers,
213210
extra_query=extra_query,
@@ -218,7 +215,6 @@ def list(
218215
"account_ids": account_ids,
219216
"cursor": cursor,
220217
"direction": direction,
221-
"limit": limit,
222218
},
223219
chat_list_params.ChatListParams,
224220
),
@@ -289,7 +285,7 @@ def search(
289285
extra_query: Query | None = None,
290286
extra_body: Body | None = None,
291287
timeout: float | httpx.Timeout | None | NotGiven = not_given,
292-
) -> SyncCursor[Chat]:
288+
) -> SyncCursorSearch[Chat]:
293289
"""
294290
Search chats by title/network or participants using Beeper Desktop's renderer
295291
algorithm.
@@ -338,7 +334,7 @@ def search(
338334
"""
339335
return self._get_api_list(
340336
"/v1/chats/search",
341-
page=SyncCursor[Chat],
337+
page=SyncCursorSearch[Chat],
342338
options=make_request_options(
343339
extra_headers=extra_headers,
344340
extra_query=extra_query,
@@ -502,14 +498,13 @@ def list(
502498
account_ids: SequenceNotStr[str] | Omit = omit,
503499
cursor: str | Omit = omit,
504500
direction: Literal["after", "before"] | Omit = omit,
505-
limit: int | Omit = omit,
506501
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
507502
# The extra values given here take precedence over values defined on the client or passed to this method.
508503
extra_headers: Headers | None = None,
509504
extra_query: Query | None = None,
510505
extra_body: Body | None = None,
511506
timeout: float | httpx.Timeout | None | NotGiven = not_given,
512-
) -> AsyncPaginator[ChatListResponse, AsyncCursor[ChatListResponse]]:
507+
) -> AsyncPaginator[ChatListResponse, AsyncCursorList[ChatListResponse]]:
513508
"""List all chats sorted by last activity (most recent first).
514509
515510
Combines all
@@ -524,8 +519,6 @@ def list(
524519
direction: Pagination direction used with 'cursor': 'before' fetches older results, 'after'
525520
fetches newer results. Defaults to 'before' when only 'cursor' is provided.
526521
527-
limit: Maximum number of chats to return (1–200). Defaults to 50.
528-
529522
extra_headers: Send extra headers
530523
531524
extra_query: Add additional query parameters to the request
@@ -536,7 +529,7 @@ def list(
536529
"""
537530
return self._get_api_list(
538531
"/v1/chats",
539-
page=AsyncCursor[ChatListResponse],
532+
page=AsyncCursorList[ChatListResponse],
540533
options=make_request_options(
541534
extra_headers=extra_headers,
542535
extra_query=extra_query,
@@ -547,7 +540,6 @@ def list(
547540
"account_ids": account_ids,
548541
"cursor": cursor,
549542
"direction": direction,
550-
"limit": limit,
551543
},
552544
chat_list_params.ChatListParams,
553545
),
@@ -618,7 +610,7 @@ def search(
618610
extra_query: Query | None = None,
619611
extra_body: Body | None = None,
620612
timeout: float | httpx.Timeout | None | NotGiven = not_given,
621-
) -> AsyncPaginator[Chat, AsyncCursor[Chat]]:
613+
) -> AsyncPaginator[Chat, AsyncCursorSearch[Chat]]:
622614
"""
623615
Search chats by title/network or participants using Beeper Desktop's renderer
624616
algorithm.
@@ -667,7 +659,7 @@ def search(
667659
"""
668660
return self._get_api_list(
669661
"/v1/chats/search",
670-
page=AsyncCursor[Chat],
662+
page=AsyncCursorSearch[Chat],
671663
options=make_request_options(
672664
extra_headers=extra_headers,
673665
extra_query=extra_query,

src/beeper_desktop_api/resources/messages.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
async_to_raw_response_wrapper,
2020
async_to_streamed_response_wrapper,
2121
)
22-
from ..pagination import SyncCursor, AsyncCursor
22+
from ..pagination import SyncCursorList, AsyncCursorList, SyncCursorSearch, AsyncCursorSearch
2323
from .._base_client import AsyncPaginator, make_request_options
2424
from ..types.shared.message import Message
2525
from ..types.message_send_response import MessageSendResponse
@@ -55,29 +55,26 @@ def list(
5555
chat_id: str,
5656
cursor: str | Omit = omit,
5757
direction: Literal["after", "before"] | Omit = omit,
58-
limit: int | Omit = omit,
5958
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6059
# The extra values given here take precedence over values defined on the client or passed to this method.
6160
extra_headers: Headers | None = None,
6261
extra_query: Query | None = None,
6362
extra_body: Body | None = None,
6463
timeout: float | httpx.Timeout | None | NotGiven = not_given,
65-
) -> SyncCursor[Message]:
64+
) -> SyncCursorList[Message]:
6665
"""List all messages in a chat with cursor-based pagination.
6766
6867
Sorted by timestamp.
6968
7069
Args:
71-
chat_id: The chat ID to list messages from
70+
chat_id: Chat ID to list messages from
7271
7372
cursor: Message cursor for pagination. Use with direction to navigate results.
7473
7574
direction: Pagination direction used with 'cursor': 'before' fetches older messages,
7675
'after' fetches newer messages. Defaults to 'before' when only 'cursor' is
7776
provided.
7877
79-
limit: Maximum number of messages to return (1–500). Defaults to 50.
80-
8178
extra_headers: Send extra headers
8279
8380
extra_query: Add additional query parameters to the request
@@ -88,7 +85,7 @@ def list(
8885
"""
8986
return self._get_api_list(
9087
"/v1/messages",
91-
page=SyncCursor[Message],
88+
page=SyncCursorList[Message],
9289
options=make_request_options(
9390
extra_headers=extra_headers,
9491
extra_query=extra_query,
@@ -99,7 +96,6 @@ def list(
9996
"chat_id": chat_id,
10097
"cursor": cursor,
10198
"direction": direction,
102-
"limit": limit,
10399
},
104100
message_list_params.MessageListParams,
105101
),
@@ -129,7 +125,7 @@ def search(
129125
extra_query: Query | None = None,
130126
extra_body: Body | None = None,
131127
timeout: float | httpx.Timeout | None | NotGiven = not_given,
132-
) -> SyncCursor[Message]:
128+
) -> SyncCursorSearch[Message]:
133129
"""
134130
Search messages across chats using Beeper's message index
135131
@@ -181,7 +177,7 @@ def search(
181177
"""
182178
return self._get_api_list(
183179
"/v1/messages/search",
184-
page=SyncCursor[Message],
180+
page=SyncCursorSearch[Message],
185181
options=make_request_options(
186182
extra_headers=extra_headers,
187183
extra_query=extra_query,
@@ -287,29 +283,26 @@ def list(
287283
chat_id: str,
288284
cursor: str | Omit = omit,
289285
direction: Literal["after", "before"] | Omit = omit,
290-
limit: int | Omit = omit,
291286
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
292287
# The extra values given here take precedence over values defined on the client or passed to this method.
293288
extra_headers: Headers | None = None,
294289
extra_query: Query | None = None,
295290
extra_body: Body | None = None,
296291
timeout: float | httpx.Timeout | None | NotGiven = not_given,
297-
) -> AsyncPaginator[Message, AsyncCursor[Message]]:
292+
) -> AsyncPaginator[Message, AsyncCursorList[Message]]:
298293
"""List all messages in a chat with cursor-based pagination.
299294
300295
Sorted by timestamp.
301296
302297
Args:
303-
chat_id: The chat ID to list messages from
298+
chat_id: Chat ID to list messages from
304299
305300
cursor: Message cursor for pagination. Use with direction to navigate results.
306301
307302
direction: Pagination direction used with 'cursor': 'before' fetches older messages,
308303
'after' fetches newer messages. Defaults to 'before' when only 'cursor' is
309304
provided.
310305
311-
limit: Maximum number of messages to return (1–500). Defaults to 50.
312-
313306
extra_headers: Send extra headers
314307
315308
extra_query: Add additional query parameters to the request
@@ -320,7 +313,7 @@ def list(
320313
"""
321314
return self._get_api_list(
322315
"/v1/messages",
323-
page=AsyncCursor[Message],
316+
page=AsyncCursorList[Message],
324317
options=make_request_options(
325318
extra_headers=extra_headers,
326319
extra_query=extra_query,
@@ -331,7 +324,6 @@ def list(
331324
"chat_id": chat_id,
332325
"cursor": cursor,
333326
"direction": direction,
334-
"limit": limit,
335327
},
336328
message_list_params.MessageListParams,
337329
),
@@ -361,7 +353,7 @@ def search(
361353
extra_query: Query | None = None,
362354
extra_body: Body | None = None,
363355
timeout: float | httpx.Timeout | None | NotGiven = not_given,
364-
) -> AsyncPaginator[Message, AsyncCursor[Message]]:
356+
) -> AsyncPaginator[Message, AsyncCursorSearch[Message]]:
365357
"""
366358
Search messages across chats using Beeper's message index
367359
@@ -413,7 +405,7 @@ def search(
413405
"""
414406
return self._get_api_list(
415407
"/v1/messages/search",
416-
page=AsyncCursor[Message],
408+
page=AsyncCursorSearch[Message],
417409
options=make_request_options(
418410
extra_headers=extra_headers,
419411
extra_query=extra_query,

src/beeper_desktop_api/types/chat_list_params.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ class ChatListParams(TypedDict, total=False):
2525
Pagination direction used with 'cursor': 'before' fetches older results, 'after'
2626
fetches newer results. Defaults to 'before' when only 'cursor' is provided.
2727
"""
28-
29-
limit: int
30-
"""Maximum number of chats to return (1–200). Defaults to 50."""

0 commit comments

Comments
 (0)