§
    ™Štjy)  ã                  ó€   — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZmZmZmZ  G d„ d	¦  «        Zd
S )z%Async Store client for LangGraph SDK.é    )Úannotations)ÚMappingÚSequence)ÚAnyÚLiteral)Ú
HttpClient)Ú_provided_vals)ÚItemÚListNamespaceResponseÚQueryParamTypesÚSearchItemsResponsec                  ó|   — e Zd ZdZd0d„Z	 	 	 	 d1d2d„Zddddœd3d„Z	 	 d4d5d„Z	 	 	 	 	 	 	 d6d7d(„Z	 	 	 	 	 	 	 d8d9d/„Z	dS ):ÚStoreClientaÂ  Client for interacting with the graph's shared storage.

    The Store provides a key-value storage system for persisting data across graph executions,
    allowing for stateful operations and data sharing across threads.

    ???+ example "Example"

        ```python
        client = get_client(url="http://localhost:2024")
        await client.store.put_item(["users", "user123"], "mem-123451342", {"name": "Alice", "score": 100})
        ```
    Úhttpr   ÚreturnÚNonec                ó   — || _         d S )N)r   )Úselfr   s     úX/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph_sdk/_async/store.pyÚ__init__zStoreClient.__init__    s   € ØˆŒ	ˆ	ˆ	ó    NÚkeyÚstrÚvalueúMapping[str, Any]Úindexú!Literal[False] | list[str] | NoneÚttlú
int | NoneÚheadersúMapping[str, str] | NoneÚparamsúQueryParamTypes | NoneÚ	namespaceúSequence[str]c             ƒ  ó´   K  — |D ]}d|v rt          d|› d�¦  «        ‚Œ|||||dœ}	| j                             dt          |	¦  «        ||¬¦  «        ƒ d{V —† dS )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_client(url="http://localhost:2024")
            await client.store.put_item(
                ["documents", "user123"],
                key="item456",
                value={"title": "My Document", "content": "Hello World"}
            )
            ```
        ú.úInvalid namespace label 'ú1'. Namespace labels cannot contain periods ('.').)r$   r   r   r   r   ú/store/items©Újsonr    r"   N)Ú
ValueErrorr   Úputr	   )
r   r$   r   r   r   r   r    r"   ÚlabelÚpayloads
             r   Úput_itemzStoreClient.put_item#   s¼   è è € ðH ð 	ð 	ˆEØ�eˆ|ˆ|Ý Øh°ÐhÐhÐhñô ð ð ð
 #ØØØØð
ð 
ˆð Œi�mŠmØ¥°Ñ!8Ô!8À'ÐRXð ñ 
ô 
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
r   )Úrefresh_ttlr    r"   r2   úbool | Noner
   c            ƒ  óì   K  — |D ]}d|v rt          d|› d�¦  «        ‚Œd                     |¦  «        |dœ}|�||d<   |ri |¥t          |¦  «        ¥}| j                             d||¬¦  «        ƒ d{V —†S )	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.

        Returns:
            Item: The retrieved item.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            item = await 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   Nr2   r*   )r"   r    )r-   ÚjoinÚdictr   Úget)r   r$   r   r2   r    r"   r/   Ú
get_paramss           r   Úget_itemzStoreClient.get_itemW   sº   è è € ðZ ð 	ð 	ˆEØ�eˆ|ˆ|Ý Øh°ÐhÐhÐhñô ð ð ð 47·8²8¸IÑ3FÔ3FÈsÐ%SÐ%Sˆ
ØÐ"Ø(3ˆJ�}Ñ%Øð 	8Ø7˜JÐ7­$¨v©,¬,Ð7ˆJØ”Y—]’] >¸*Èg�]ÑVÔVÐVÐVÐVÐVÐVÐVÐVr   c             ƒ  óX   K  — | j                              d||dœ||¬¦  «        ƒ d{V —† dS )at  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_client(url="http://localhost:2024")
            await client.store.delete_item(
                ["documents", "user123"],
                key="item456",
            )
            ```
        r*   r5   r+   N)r   Údelete)r   r$   r   r    r"   s        r   Údelete_itemzStoreClient.delete_item�   sc   è è € ð: Œi×ÒØØ(°Ð5Ð5ØØð	 ñ 
ô 
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
r   é
   r   ÚfilterúMapping[str, Any] | NoneÚlimitÚintÚoffsetÚqueryú
str | NoneÚnamespace_prefixr   c	             ƒ  óz   K  — ||||||dœ}	| j                              dt          |	¦  «        ||¬¦  «        ƒ d{V —†S )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_client(url="http://localhost:2024")
            items = await 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 ...
                ]
            }
            ```
        )rF   r?   rA   rC   rD   r2   z/store/items/searchr+   N©r   Úpostr	   )
r   rF   r?   rA   rC   rD   r2   r    r"   r0   s
             r   Úsearch_itemszStoreClient.search_items´   sx   è è € ðz !1ØØØØØ&ð
ð 
ˆð ”Y—^’^Ø!Ý Ñ(Ô(ØØð	 $ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
r   éd   Úprefixúlist[str] | NoneÚsuffixÚ	max_depthr   c              ƒ  óx   K  — |||||dœ}| j                              dt          |¦  «        ||¬¦  «        ƒ d{V —†S )a3  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.
            params: Optional query parameters to include with the request.

        Returns:
            A list of namespaces matching the criteria.

        ???+ example "Example Usage"

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

            ----------------------------------------------------------------

            [
                ["documents", "user123", "reports"],
                ["documents", "user456", "invoices"],
                ...
            ]
            ```
        )rL   rN   rO   rA   rC   z/store/namespacesr+   NrH   )	r   rL   rN   rO   rA   rC   r    r"   r0   s	            r   Úlist_namespaceszStoreClient.list_namespaces   su   è è € ð\ ØØ"ØØð
ð 
ˆð ”Y—^’^ØÝ Ñ(Ô(ØØð	 $ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
r   )r   r   r   r   )NNNN)r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   r   )r   r   r$   r%   r2   r3   r    r!   r"   r#   r   r
   )NN)
r   r   r    r!   r"   r#   r$   r%   r   r   )Nr>   r   NNNN)r?   r@   rA   rB   rC   rB   rD   rE   r2   r3   r    r!   r"   r#   rF   r%   r   r   )NNNrK   r   NN)rL   rM   rN   rM   rO   r   rA   rB   rC   rB   r    r!   r"   r#   r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r1   r:   r=   rJ   rQ   © r   r   r   r      s  € € € € € ðð ðð ð ð ð 48ØØ,0Ø)-ð2
ð 2
ð 2
ð 2
ð 2
ðt $(Ø,0Ø)-ð7Wð 7Wð 7Wð 7Wð 7Wð 7Wð| -1Ø)-ð"
ð "
ð "
ð "
ð "
ðP ,0ØØØ Ø#'Ø,0Ø)-ðJ
ð J
ð J
ð J
ð J
ð\ $(Ø#'Ø $ØØØ,0Ø)-ð9
ð 9
ð 9
ð 9
ð 9
ð 9
ð 9
r   r   N)rU   Ú
__future__r   Úcollections.abcr   r   Útypingr   r   Úlanggraph_sdk._async.httpr   Úlanggraph_sdk._shared.utilitiesr	   Úlanggraph_sdk.schemar
   r   r   r   r   rV   r   r   ú<module>r]      sé   ðØ +Ð +à "Ð "Ð "Ð "Ð "Ð "à -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð Ð Ð à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø :Ð :Ð :Ð :Ð :Ð :ðð ð ð ð ð ð ð ð ð ð ð ðg
ð g
ð g
ð g
ð g
ñ g
ô g
ð g
ð g
ð g
r   