
    7|h'                        d dl mZmZmZmZmZ d dlmZ d dlm	Z	 d dl
mZ eeee   gef   Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)    )AnyCallableIteratorMappingOptional)Document)guard_import)
BaseLoaderc                   t    e Zd ZdZ	 	 ddeeef   dededee   dee   ddfd	Z	de
e   fd
Zedefd       Zy)AirbyteCDKLoaderzDLoad with an `Airbyte` source connector implemented using the `CDK`.Nconfigsource_classstream_namerecord_handlerstatereturnc                    	 ddl m	 ddlm} ddlm}  G 	fdd|      } || | |       |j                              | _        || _        || _	        y	)
a  Initializes the loader.

        Args:
            config: The config to pass to the source connector.
            source_class: The source connector class.
            stream_name: The name of the stream to load.
            record_handler: A function that takes in a record and an optional id and
                returns a Document. If None, the record will be used as the document.
                Defaults to None.
            state: The state to pass to the source connector. Defaults to None.
        r   )AirbyteRecordMessage)BaseEmbeddedIntegration)	CDKRunnerc                   2    e Zd ZdZdW  dee   deffdZy)1AirbyteCDKLoader.__init__.<locals>.CDKIntegrationz%A wrapper around the CDK integration.recordidr   c                 H    r	 ||      S t        d|j                        S )N )page_contentmetadata)r   data)selfr   r   r   s      k/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/document_loaders/airbyte.py_handle_recordz@AirbyteCDKLoader.__init__.<locals>.CDKIntegration._handle_record*   s&     ")&"55R&++FF    N)__name__
__module____qualname____doc__r   strr   r"   )r   r   s   r!   CDKIntegrationr   '   s+    7G2G8@GGr#   r)   )sourcename)r   runnerN)
#airbyte_cdk.models.airbyte_protocolr   -airbyte_cdk.sources.embedded.base_integrationr   #airbyte_cdk.sources.embedded.runnerr   r$   _integration_stream_name_state)
r    r   r   r   r   r   r   r   r)   r   s
       `    @r!   __init__zAirbyteCDKLoader.__init__   sX    & 	M	
 	B	G4 	G +LN9N9NO
 (r#   c                 d    | j                   j                  | j                  | j                        S )N)r   r   )r0   
_load_datar1   r2   r    s    r!   	lazy_loadzAirbyteCDKLoader.lazy_load8   s/      ++)) , 
 	
r#   c                 .    | j                   j                  S )N)r0   
last_stater6   s    r!   r9   zAirbyteCDKLoader.last_state=   s      +++r#   NN)r$   r%   r&   r'   r   r(   r   r   RecordHandlerr3   r   r   r7   propertyr9    r#   r!   r   r      s    N 37#(S!( ( 	(
 !/( }( 
(T
8H- 

 ,C , ,r#   r   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteHubspotLoaderz8Load from `Hubspot` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)  Initializes the loader.

        Args:
            config: The config to pass to the source connector.
            stream_name: The name of the stream to load.
            record_handler: A function that takes in a record and an optional id and
                returns a Document. If None, the record will be used as the document.
                Defaults to None.
            state: The state to pass to the source connector. Defaults to None.
        source_hubspotzairbyte-source-hubspotpip_namer   r   r   r   r   N)r	   SourceHubspotsuperr3   r    r   r   r   r   r   	__class__s         r!   r3   zAirbyteHubspotLoader.__init__E   @    " $'?

- 	 	%#) 	 	
r#   r:   r$   r%   r&   r'   r   r(   r   r   r;   r3   __classcell__rI   s   @r!   r?   r?   B   Z    B 37#
S!
 
 !/	

 }
 

 
r#   r?   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteStripeLoaderz7Load from `Stripe` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_stripezairbyte-source-striperC   rE   N)r	   SourceStriperG   r3   rH   s         r!   r3   zAirbyteStripeLoader.__init__e   s@    " $&=

, 	 	%#) 	 	
r#   r:   rK   rM   s   @r!   rP   rP   b   sZ    A 37#
S!
 
 !/	

 }
 

 
r#   rP   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteTypeformLoaderz9Load from `Typeform` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_typeformzairbyte-source-typeformrC   rE   N)r	   SourceTypeformrG   r3   rH   s         r!   r3   zAirbyteTypeformLoader.__init__   s@    " $(A

. 	 	%#) 	 	
r#   r:   rK   rM   s   @r!   rU   rU      sZ    C 37#
S!
 
 !/	

 }
 

 
r#   rU   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteZendeskSupportLoaderz@Load from `Zendesk Support` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_zendesk_supportzairbyte-source-zendesk-supportrC   rE   N)r	   SourceZendeskSupportrG   r3   rH   s         r!   r3   z$AirbyteZendeskSupportLoader.__init__   sA    " $$/O


 	 	%#) 	 	
r#   r:   rK   rM   s   @r!   rZ   rZ      sZ    J 37#
S!
 
 !/	

 }
 

 
r#   rZ   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteShopifyLoaderz8Load from `Shopify` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_shopifyzairbyte-source-shopifyrC   rE   N)r	   SourceShopifyrG   r3   rH   s         r!   r3   zAirbyteShopifyLoader.__init__   rJ   r#   r:   rK   rM   s   @r!   r_   r_      rN   r#   r_   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteSalesforceLoaderz;Load from `Salesforce` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_salesforcezairbyte-source-salesforcerC   rE   N)r	   SourceSalesforcerG   r3   rH   s         r!   r3   z AirbyteSalesforceLoader.__init__   sA    " $*E


 	 	%#) 	 	
r#   r:   rK   rM   s   @r!   rd   rd      sZ    E 37#
S!
 
 !/	

 }
 

 
r#   rd   c                   T     e Zd ZdZ	 	 d	deeef   dedee   dee   ddf
 fdZ	 xZ
S )
AirbyteGongLoaderz5Load from `Gong` using an `Airbyte` source connector.Nr   r   r   r   r   c                 \    t        dd      j                  }t        |   |||||       y)rA   source_gongzairbyte-source-gongrC   rE   N)r	   
SourceGongrG   r3   rH   s         r!   r3   zAirbyteGongLoader.__init__  s@    " $$9

* 	 	%#) 	 	
r#   r:   rK   rM   s   @r!   ri   ri     sZ    ? 37#
S!
 
 !/	

 }
 

 
r#   ri   N)typingr   r   r   r   r   langchain_core.documentsr   langchain_core.utils.utilsr	   )langchain_community.document_loaders.baser
   r(   r;   r   r?   rP   rU   rZ   r_   rd   ri   r=   r#   r!   <module>rq      s    = = - 3 @#x}-x784,z 4,n
+ 
@
* 
@
, 
@
"2 
@
+ 
@
. 
@
( 
r#   