Ë
    ÌiÃ  ã                  óª   — d Z ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZ er"ddlZddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ  G d„ de	«      Zy)z”
.. warning::
    **Preview API**: Firestore Pipelines is currently in preview and is
    subject to potential breaking changes in future releases.
é    )Úannotations)ÚTYPE_CHECKING)Úpipeline_stages)Ú_BasePipeline)ÚPipelineResultÚPipelineSnapshotÚPipelineStreamN)ÚClient)ÚConstant)ÚPipelineExplainOptions)ÚTransaction)ÚValuec                  óp   ‡ — e Zd ZdZdˆ fd„Zdddi dœ	 	 	 	 	 	 	 	 	 dd„Zdddi dœ	 	 	 	 	 	 	 	 	 d	d„Zˆ xZS )
ÚPipelineam  
    Pipelines allow for complex data transformations and queries involving
    multiple stages like filtering, projection, aggregation, and vector search.

    Usage Example:
        >>> from google.cloud.firestore_v1.pipeline_expressions import Field
        >>>
        >>> def run_pipeline():
        ...     client = Client(...)
        ...     pipeline = client.pipeline()
        ...                      .collection("books")
        ...                      .where(Field.of("published").gt(1980))
        ...                      .select("title", "author")
        ...     for result in pipeline.execute():
        ...         print(result)

    Use `client.pipeline()` to create instances of this class.

    .. warning::
        **Preview API**: Firestore Pipelines is currently in preview and is
        subject to potential breaking changes in future releases.
    c                ó&   •— t        ‰| �  |g|¢­Ž  y)z®
        Initializes a Pipeline.

        Args:
            client: The `Client` instance to use for execution.
            *stages: Initial stages for the pipeline.
        N)ÚsuperÚ__init__)ÚselfÚclientÚstagesÚ	__class__s      €úc/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/google/cloud/firestore_v1/pipeline.pyr   zPipeline.__init__B   s   ø€ ô 	‰Ñ˜Ð) &Ô)ó    N)ÚtransactionÚ	read_timeÚexplain_optionsÚadditional_optionsc               óÒ   — t        «       j                  «       D ��ci c]  \  }}|dk7  sŒ||“Œ }}}t        t        | fi |¤Ž}|D �	cg c]  }	|	‘Œ }
}	t	        |
|«      S c c}}w c c}	w )a(  
        Executes this pipeline and returns results as a list

        Args:
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that this query will run in.
                If a ``transaction`` is used and it already has write operations
                added, this method cannot be used (i.e. read-after-write is not
                allowed).
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a microsecond precision timestamp within the past one hour, or
                if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp
                within the past 7 days. For the most accurate results, use UTC timezone.
            explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned list.
            additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
                These options will take precedence over method argument if there is a conflict (e.g. explain_options)
        r   )ÚlocalsÚitemsr	   r   r   )r   r   r   r   r   ÚkÚvÚkwargsÚstreamÚresultÚresultss              r   ÚexecutezPipeline.executeL   sh   € ô6 $*£8§>¡>Ó#3×C™4˜1˜a°q¸F³{�!�Q‘$ÐCˆÑCÜ¤°Ñ?¸Ñ?ˆØ(.Ö/˜f’6Ð/ˆÐ/Ü ¨Ó0Ð0ùó Dùâ/s   œAªAÁ	A$c               ó’   — t        «       j                  «       D ��ci c]  \  }}|dk7  sŒ||“Œ }}}t        t        | fi |¤ŽS c c}}w )aA  
        Process this pipeline as a stream, providing results through an Iterable

        Args:
            transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.Transaction`]):
                An existing transaction that this query will run in.
                If a ``transaction`` is used and it already has write operations
                added, this method cannot be used (i.e. read-after-write is not
                allowed).
            read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
                time. This must be a microsecond precision timestamp within the past one hour, or
                if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp
                within the past 7 days. For the most accurate results, use UTC timezone.
            explain_options (Optional[:class:`~google.cloud.firestore_v1.query_profile.PipelineExplainOptions`]):
                Options to enable query profiling for this query. When set,
                explain_metrics will be available on the returned generator.
            additional_options (Optional[dict[str, Value | Constant]]): Additional options to pass to the query.
                These options will take precedence over method argument if there is a conflict (e.g. explain_options)
        r   )r   r    r	   r   )r   r   r   r   r   r!   r"   r#   s           r   r$   zPipeline.streaml   sF   € ô6 $*£8§>¡>Ó#3×C™4˜1˜a°q¸F³{�!�Q‘$ÐCˆÑCÜœn¨dÑ=°fÑ=Ð=ùó Ds
   œAªA)r   r
   r   zstages.Stage)
r   ú'Transaction' | Noner   údatetime.datetime | Noner   úPipelineExplainOptions | Noner   údict[str, Value | Constant]Úreturnz PipelineSnapshot[PipelineResult])
r   r)   r   r*   r   r+   r   r,   r-   zPipelineStream[PipelineResult])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   r$   Ú__classcell__)r   s   @r   r   r   *   s˜   ø„ ñõ.*ð -1Ø.2Ø9=Ø:<ñ1ð *ð1ð ,ð	1ð
 7ð1ð 8ð1ð 
*ó1ðF -1Ø.2Ø9=Ø:<ñ>ð *ð>ð ,ð	>ð
 7ð>ð 8ð>ð 
(÷>r   r   )r1   Ú
__future__r   Útypingr   Úgoogle.cloud.firestore_v1r   r   Ú'google.cloud.firestore_v1.base_pipeliner   Ú)google.cloud.firestore_v1.pipeline_resultr   r   r	   ÚdatetimeÚ google.cloud.firestore_v1.clientr
   Ú.google.cloud.firestore_v1.pipeline_expressionsr   Ú'google.cloud.firestore_v1.query_profiler   Ú%google.cloud.firestore_v1.transactionr   Ú(google.cloud.firestore_v1.types.documentr   r   © r   r   ú<module>r?      sG   ðñõ #å  å ?Ý A÷ñ ñ Ûå7ÝGÝNÝAÝ>ô^>ˆ}õ ^>r   