|
18 | 18 | "AsyncBenchmarksCursorIDPage", |
19 | 19 | "SyncAgentsCursorIDPage", |
20 | 20 | "AsyncAgentsCursorIDPage", |
| 21 | + "SyncAxonsCursorIDPage", |
| 22 | + "AsyncAxonsCursorIDPage", |
21 | 23 | "SyncBenchmarkRunsCursorIDPage", |
22 | 24 | "AsyncBenchmarkRunsCursorIDPage", |
23 | 25 | "SyncScenariosCursorIDPage", |
@@ -69,6 +71,11 @@ class AgentsCursorIDPageItem(Protocol): |
69 | 71 | id: str |
70 | 72 |
|
71 | 73 |
|
| 74 | +@runtime_checkable |
| 75 | +class AxonsCursorIDPageItem(Protocol): |
| 76 | + id: str |
| 77 | + |
| 78 | + |
72 | 79 | @runtime_checkable |
73 | 80 | class BenchmarkRunsCursorIDPageItem(Protocol): |
74 | 81 | id: str |
@@ -517,6 +524,74 @@ def next_page_info(self) -> Optional[PageInfo]: |
517 | 524 | return PageInfo(params={"starting_after": item.id}) |
518 | 525 |
|
519 | 526 |
|
| 527 | +class SyncAxonsCursorIDPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]): |
| 528 | + axons: List[_T] |
| 529 | + has_more: Optional[bool] = None |
| 530 | + total_count: Optional[int] = None |
| 531 | + |
| 532 | + @override |
| 533 | + def _get_page_items(self) -> List[_T]: |
| 534 | + axons = self.axons |
| 535 | + if not axons: |
| 536 | + return [] |
| 537 | + return axons |
| 538 | + |
| 539 | + @override |
| 540 | + def has_next_page(self) -> bool: |
| 541 | + has_more = self.has_more |
| 542 | + if has_more is not None and has_more is False: |
| 543 | + return False |
| 544 | + |
| 545 | + return super().has_next_page() |
| 546 | + |
| 547 | + @override |
| 548 | + def next_page_info(self) -> Optional[PageInfo]: |
| 549 | + axons = self.axons |
| 550 | + if not axons: |
| 551 | + return None |
| 552 | + |
| 553 | + item = cast(Any, axons[-1]) |
| 554 | + if not isinstance(item, AxonsCursorIDPageItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison] |
| 555 | + # TODO emit warning log |
| 556 | + return None |
| 557 | + |
| 558 | + return PageInfo(params={"starting_after": item.id}) |
| 559 | + |
| 560 | + |
| 561 | +class AsyncAxonsCursorIDPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): |
| 562 | + axons: List[_T] |
| 563 | + has_more: Optional[bool] = None |
| 564 | + total_count: Optional[int] = None |
| 565 | + |
| 566 | + @override |
| 567 | + def _get_page_items(self) -> List[_T]: |
| 568 | + axons = self.axons |
| 569 | + if not axons: |
| 570 | + return [] |
| 571 | + return axons |
| 572 | + |
| 573 | + @override |
| 574 | + def has_next_page(self) -> bool: |
| 575 | + has_more = self.has_more |
| 576 | + if has_more is not None and has_more is False: |
| 577 | + return False |
| 578 | + |
| 579 | + return super().has_next_page() |
| 580 | + |
| 581 | + @override |
| 582 | + def next_page_info(self) -> Optional[PageInfo]: |
| 583 | + axons = self.axons |
| 584 | + if not axons: |
| 585 | + return None |
| 586 | + |
| 587 | + item = cast(Any, axons[-1]) |
| 588 | + if not isinstance(item, AxonsCursorIDPageItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison] |
| 589 | + # TODO emit warning log |
| 590 | + return None |
| 591 | + |
| 592 | + return PageInfo(params={"starting_after": item.id}) |
| 593 | + |
| 594 | + |
520 | 595 | class SyncBenchmarkRunsCursorIDPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]): |
521 | 596 | runs: List[_T] |
522 | 597 | has_more: Optional[bool] = None |
|
0 commit comments