ó
    ýÞ j²(  ã                  óx   • S r SSKJr  SSKJrJr  SSKJrJr  SSK	J
r
  SSKJr  SSKJrJrJrJr   " S S	5      rg
)z+Synchronous store client for LangGraph SDK.é    )Úannotations)ÚMappingÚSequence)ÚAnyÚLiteral)Ú_provided_vals)ÚSyncHttpClient)ÚItemÚListNamespaceResponseÚQueryParamTypesÚSearchItemsResponsec                  ó$  • \ rS rSrSrSS jr    S               SS jjrSSSS.           SS jjr  S         SS jjr       S                 SS	 jjr	     SSSS
.               SS jjjr
Srg)ÚSyncStoreClienté   a‚  A client for synchronous operations on a key-value store.

Provides methods to interact with a remote key-value store, allowing
storage and retrieval of items within namespaced hierarchies.

???+ example "Example"

    ```python
    client = get_sync_client(url="http://localhost:2024"))
    client.store.put_item(["users", "profiles"], "user123", {"name": "Alice", "age": 30})
    ```
c                ó   • Xl         g )N©Úhttp)Úselfr   s     ÚS/var/www/html/gaurav/venv/lib/python3.13/site-packages/langgraph_sdk/_sync/store.pyÚ__init__ÚSyncStoreClient.__init__    s   € Ø�	ó    Nc               ó˜   • U H  nSU;   d  M  [        SU S35      e   UUUUUS.n	U R                  R                  S[        U	5      XgS9  g)a<  Store or update an item.

Args:
    namespace: A list of strings representing the namespace path.
    key: The unique identifier for the item within the namespace.
    value: A dictionary containing the item's data.
    index: Controls search indexing - None (use defaults), False (disable), or list of field paths to index.
    ttl: Optional time-to-live in minutes for the item, or None for no expiration.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_sync_client(url="http://localhost:8123")
    client.store.put_item(
        ["documents", "user123"],
        key="item456",
        value={"title": "My Document", "content": "Hello World"}
    )
    ```
Ú.úInvalid namespace label 'ú1'. Namespace labels cannot contain periods ('.').)Ú	namespaceÚkeyÚvalueÚindexÚttlú/store/items©ÚjsonÚheadersÚparamsN)Ú
ValueErrorr   Úputr   )
r   r   r   r   r    r!   r%   r&   ÚlabelÚpayloads
             r   Úput_itemÚSyncStoreClient.put_item#   sk   € óH ˆEØ�e�|Ü Ø/°¨wÐ6gÐhóð ñ ð #ØØØØñ
ˆð 	�	‰	�‰Ø¤°Ó!8À'ð 	ò 	
r   )Úrefresh_ttlr%   r&   c              óØ   • U H  nSU;   d  M  [        SU S35      e   USR                  U5      S.nUb  X7S'   U(       a  UR                  U5        U R                  R	                  SXtS9$ )aœ  Retrieve a single item.

Args:
    key: The unique identifier for the item.
    namespace: Optional list of strings representing the namespace path.
    refresh_ttl: Whether to refresh the TTL on this read operation. If `None`, uses the store's default behavior.
    headers: Optional custom headers to include with the request.

Returns:
    The retrieved item.

???+ example "Example Usage"

    ```python
    client = get_sync_client(url="http://localhost:8123")
    item = client.store.get_item(
        ["documents", "user123"],
        key="item456",
    )
    print(item)
    ```

    ```shell
    ----------------------------------------------------------------

    {
        'namespace': ['documents', 'user123'],
        'key': 'item456',
        'value': {'title': 'My Document', 'content': 'Hello World'},
        'created_at': '2024-07-30T12:00:00Z',
        'updated_at': '2024-07-30T12:00:00Z'
    }
    ```
r   r   r   ©r   r   r-   r"   )r&   r%   )r'   ÚjoinÚupdater   Úget)r   r   r   r-   r%   r&   r)   Úquery_paramss           r   Úget_itemÚSyncStoreClient.get_itemW   s{   € óX ˆEØ�e�|Ü Ø/°¨wÐ6gÐhóð ñ ð 03ÀÇÁÈ)ÓATÑ'UˆØÑ"Ø*5˜Ñ'ÞØ×Ñ Ô'Ø�y‰y�}‰}˜^°Lˆ}ÐRÐRr   c               ó@   • U R                   R                  SX!S.UUS9  g)aó  Delete an item.

Args:
    key: The unique identifier for the item.
    namespace: Optional list of strings representing the namespace path.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_sync_client(url="http://localhost:8123")
    client.store.delete_item(
        ["documents", "user123"],
        key="item456",
    )
    ```
r"   r/   r#   N)r   Údelete)r   r   r   r%   r&   s        r   Údelete_itemÚSyncStoreClient.delete_item�   s*   € ð: 	�	‰	×ÑØØÑ5ØØð	 	ò 	
r   c	               ó^   • UUUUUUS.n	U R                   R                  S[        U	5      UUS9$ )aâ  Search for items within a namespace prefix.

Args:
    namespace_prefix: List of strings representing the namespace prefix.
    filter: Optional dictionary of key-value pairs to filter results.
    limit: Maximum number of items to return (default is 10).
    offset: Number of items to skip before returning results (default is 0).
    query: Optional query for natural language search.
    refresh_ttl: Whether to refresh the TTL on items returned by this search. If `None`, uses the store's default behavior.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    A list of items matching the search criteria.

???+ example "Example Usage"

    ```python
    client = get_sync_client(url="http://localhost:8123")
    items = client.store.search_items(
        ["documents"],
        filter={"author": "John Doe"},
        limit=5,
        offset=0
    )
    print(items)
    ```
    ```shell
    ----------------------------------------------------------------

    {
        "items": [
            {
                "namespace": ["documents", "user123"],
                "key": "item789",
                "value": {
                    "title": "Another Document",
                    "author": "John Doe"
                },
                "created_at": "2024-07-30T12:00:00Z",
                "updated_at": "2024-07-30T12:00:00Z"
            },
            # ... additional items ...
        ]
    }
    ```
)Únamespace_prefixÚfilterÚlimitÚoffsetÚqueryr-   z/store/items/searchr#   ©r   Úpostr   )
r   r;   r<   r=   r>   r?   r-   r%   r&   r*   s
             r   Úsearch_itemsÚSyncStoreClient.search_items´   sK   € ðx !1ØØØØØ&ñ
ˆð �y‰y�~‰~Ø!Ü Ó(ØØð	 ð 
ð 	
r   )r%   r&   c               ó\   • UUUUUS.nU R                   R                  S[        U5      UUS9$ )a$  List namespaces with optional match conditions.

Args:
    prefix: Optional list of strings representing the prefix to filter namespaces.
    suffix: Optional list of strings representing the suffix to filter namespaces.
    max_depth: Optional integer specifying the maximum depth of namespaces to return.
    limit: Maximum number of namespaces to return (default is 100).
    offset: Number of namespaces to skip before returning results (default is 0).
    headers: Optional custom headers to include with the request.

Returns:
    A list of namespaces matching the criteria.

???+ example "Example Usage"

    ```python
    client = get_sync_client(url="http://localhost:8123")
    namespaces = client.store.list_namespaces(
        prefix=["documents"],
        max_depth=3,
        limit=10,
        offset=0
    )
    print(namespaces)
    ```

    ```shell
    ----------------------------------------------------------------

    [
        ["documents", "user123", "reports"],
        ["documents", "user456", "invoices"],
        ...
    ]
    ```
)ÚprefixÚsuffixÚ	max_depthr=   r>   z/store/namespacesr#   r@   )	r   rE   rF   rG   r=   r>   r%   r&   r*   s	            r   Úlist_namespacesÚSyncStoreClient.list_namespacesþ   sH   € ð` ØØ"ØØñ
ˆð �y‰y�~‰~ØÜ Ó(ØØð	 ð 
ð 	
r   r   )r   r	   ÚreturnÚNone)NNNN)r   Ústrr   zMapping[str, Any]r    z!Literal[False] | list[str] | Noner!   ú
int | Noner%   úMapping[str, str] | Noner&   úQueryParamTypes | Noner   úSequence[str]rJ   rK   )r   rL   r   rP   r-   úbool | Noner%   rN   r&   rO   rJ   r
   )NN)
r   rL   r%   rN   r&   rO   r   rP   rJ   rK   )Né
   r   NNNN)r<   zMapping[str, Any] | Noner=   Úintr>   rS   r?   z
str | Noner-   rQ   r%   rN   r&   rO   r;   rP   rJ   r   )NNNéd   r   )rE   úlist[str] | NonerF   rU   rG   rM   r=   rS   r>   rS   r%   rN   r&   rO   rJ   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r+   r4   r8   rB   rH   Ú__static_attributes__© r   r   r   r      só  † ñôð 48ØØ,0Ø)-ð2
ð ð	2
ð
 !ð2
ð 1ð2
ð ð2
ð *ð2
ð 'ð2
à ð2
ð 
õ2
ðt $(Ø,0Ø)-ñ7Sð ð	7Sà ð7Sð !ð7Sð *ð7Sð 'ð7Sð 
õ7Sð| -1Ø)-ð"
ð ð	"
ð
 *ð"
ð 'ð"
à ð"
ð 
õ"
ðP ,0ØØØ Ø#'Ø,0Ø)-ðH
ð )ð	H
ð
 ðH
ð ðH
ð ðH
ð !ðH
ð *ðH
ð 'ðH
à'ðH
ð 
õH
ðX $(Ø#'Ø $ØØð;
ð -1Ø)-ñ;
à ð;
ð !ð;
ð ð	;
ð
 ð;
ð ð;
ð *ð;
ð 'ð;
ð 
÷;
ñ ;
r   r   N)rZ   Ú
__future__r   Úcollections.abcr   r   Útypingr   r   Úlanggraph_sdk._shared.utilitiesr   Úlanggraph_sdk._sync.httpr	   Úlanggraph_sdk.schemar
   r   r   r   r   r\   r   r   Ú<module>rc      s-   ðÙ 1å "ç -ß å :Ý 3÷ó ÷g
ò g
r   