o
    wi@                     @  s   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZ e	dZ	 G d	d
 d
eZG dd deee ZG dd deee ZG dd dee ee ZdS )zUtilities for client-side handling of "relay-style" GraphQL pagination.

For formal specs and definitions, see https://relay.dev/graphql/connections.htm.
    )annotations)Iterator)GenericLiteralOptionalTypeVar)NonNegativeInt   )	GQLResultNodeTc                   @  s0   e Zd ZU dZd Zded< ded< 	 ded< dS )	PageInfozHPagination metadata returned by the server for a single page of results.zLiteral['PageInfo']
typename__Optional[str]
end_cursorboolhas_next_pageN)__name__
__module____qualname____doc__r   __annotations__ r   r   N/home/ubuntu/.local/lib/python3.10/site-packages/wandb/_pydantic/pagination.pyr      s   
 r   c                   @     e Zd ZU dZded< dS )Edgea>  A wrapper around a single result item in a paginated response.

    In relay-style pagination, individual items are wrapped in "edges" which can
    carry additional metadata, e.g., per-item cursors. This base implementation
    only exposes the `node` (the actual result item, like a GraphQL `Run` or `Project`).
    r   nodeNr   r   r   r   r   r   r   r   r   r      s   
 r   c                   @  sZ   e Zd ZU dZded< 	 ded< 	 dZded< 	 dddZedddZedddZ	dS )
Connectiona6  A page of results from the response of a paginated GraphQL query.

    This follows the "Relay Connection" specification, which is a standard
    way to paginate large result sets in GraphQL. Instead of returning all
    results at once, the server returns one page at a time. Each "page" is
    represented by a `Connection` object that includes:

    - A list of `edges`, each wrapping a single result item (`node`).
    - A `page_info` object with metadata for fetching subsequent pages.
    - Optionally, a `total_count` of all results (not just this page).
    zlist[Edge[NodeT]]edgesr   	page_infoNzOptional[NonNegativeInt]total_countreturnIterator[NodeT]c                   s    fdd| j D S )z5Returns an iterator over the nodes in the connection.c                 3  s    | ]
}|j   r V  qd S )Nr   ).0edger#   r   r   	<genexpr>C   s    z#Connection.nodes.<locals>.<genexpr>)r   selfr   r#   r   nodesA   s   zConnection.nodesr   c                 C     | j jS )z.Returns True if there are more pages to fetch.)r   r   r'   r   r   r   has_nextE      zConnection.has_nextr   c                 C  r*   )zEThe cursor value to pass as the `after` arg in the next page request.)r   r   r'   r   r   r   next_cursorJ   r,   zConnection.next_cursor)r!   r"   )r!   r   )r!   r   )
r   r   r   r   r   r    r)   propertyr+   r-   r   r   r   r   r   +   s   
 
r   c                   @  r   )ConnectionWithTotala+  A `Connection` where the `totalCount` field must be present.

    Use this INSTEAD of `Connection` when the paginated query is expected
    to return a finite `totalCount` field, i.e. when `totalCount` is:
    - explicitly requested in the GraphQL query
    - non-nullable in the GraphQL schema
    r   r    Nr   r   r   r   r   r/   P   s   
 r/   N)r   
__future__r   collections.abcr   typingr   r   r   r   pydanticr   baser
   r   r   r   r   r/   r   r   r   r   <module>   s    %