
    Ng'                     J   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dS )    )AnyCallableIteratorMappingOptional)Document)guard_import)
BaseLoaderc                       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dS )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                            | _        || _        || _	        d	S )
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                   8    e Zd ZdZd dee         deffdZdS )1AirbyteCDKLoader.__init__.<locals>.CDKIntegrationz%A wrapper around the CDK integration.recordidr   c                 L    r ||          S t          d|j                  S )N )page_contentmetadata)r   data)selfr   r   r   s      h/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/document_loaders/airbyte.py_handle_recordz@AirbyteCDKLoader.__init__.<locals>.CDKIntegration._handle_record*   s4     " 6)>&"555R&+FFFF    N)__name__
__module____qualname____doc__r   strr   r"   )r   r   s   r!   CDKIntegrationr   '   s`        77G2G8@GG G G G G G 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__   s    & 	MLLLLL	
 	
 	
 	
 	
 	
 	BAAAAA	G 	G 	G 	G 	G 	G 	G 	G4 	G 	G 	G +N9LLNN9NOOO
 
 
 (r#   c                 N    | 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N 37#( (S!( ( 	(
 !/( }( 
( ( ( (T
8H- 
 
 
 

 ,C , , , X, , ,r#   r   c                   f     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                                          |||||           dS )  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   a    " $'?
 
 

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

 }
 

 
 
 
 
 
 
 
 
 
r#   r?   c                   f     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                                          |||||           dS )rA   source_stripezairbyte-source-striperC   rE   N)r	   SourceStriperG   r3   rH   s         r!   r3   zAirbyteStripeLoader.__init__e   sa    " $&=
 
 

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

 }
 

 
 
 
 
 
 
 
 
 
r#   rP   c                   f     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                                          |||||           dS )rA   source_typeformzairbyte-source-typeformrC   rE   N)r	   SourceTypeformrG   r3   rH   s         r!   r3   zAirbyteTypeformLoader.__init__   sa    " $(A
 
 

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

 }
 

 
 
 
 
 
 
 
 
 
r#   rU   c                   f     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                                          |||||           dS )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      s        JJ 37#
 
S!
 
 !/	

 }
 

 
 
 
 
 
 
 
 
 
r#   rZ   c                   f     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                                          |||||           dS )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                   f     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                                          |||||           dS )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      s        EE 37#
 
S!
 
 !/	

 }
 

 
 
 
 
 
 
 
 
 
r#   rd   c                   f     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                                          |||||           dS )rA   source_gongzairbyte-source-gongrC   rE   N)r	   
SourceGongrG   r3   rH   s         r!   r3   zAirbyteGongLoader.__init__  sa    " $$9
 
 

 	 	%#) 	 	
 	
 	
 	
 	
r#   r:   rK   rM   s   @r!   ri   ri     s        ?? 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 3 3 3 3 3 @ @ @ @ @ @#x}-x784, 4, 4, 4, 4,z 4, 4, 4,n
 
 
 
 
+ 
 
 
@
 
 
 
 
* 
 
 
@
 
 
 
 
, 
 
 
@
 
 
 
 
"2 
 
 
@
 
 
 
 
+ 
 
 
@
 
 
 
 
. 
 
 
@
 
 
 
 
( 
 
 
 
 
r#   