Ë
    Ìi6  ã                   óÂ   — d dl Z d dlmZ d dlmZmZmZmZmZm	Z	 d dl
mZ d dlmZ eegef   Z G d„ d«      Z e«       Z G d„ d	e«      Z G d
„ de j&                  «      Zy)é    N)Úwraps)ÚAnyÚCallableÚDictÚ	FrozenSetÚOptionalÚSet)Úwarn_or_error)ÚAdapterDeprecationWarningc                   ój   — e Zd Zdedefd„Zdedefd„Z	 ddedee   defd„Z	dedefd	„Z
dedefd
„Zy)Ú
_AvailableÚfuncÚreturnc                 ó   — d|_         |S )NT)Ú_is_available_)Úselfr   s     úW/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/dbt/adapters/base/meta.pyÚ__call__z_Available.__call__   s   € Ø"ˆÔØˆó    Úparse_replacementc                 ó   ‡ ‡— ˆˆ fd„}|S )a  A decorator factory to indicate that a method on the adapter will be
        exposed to the database wrapper, and will be stubbed out at parse time
        with the given function.

        @available.parse()
        def my_method(self, a, b):
            if something:
                return None
            return big_expensive_db_query()

        @available.parse(lambda *args, **args: {})
        def my_other_method(self, a, b):
            x = {}
            x.update(big_expensive_db_query())
            return x
        c                 ó"   •— ‰| _          ‰| «      S ©N)Ú_parse_replacement_)r   r   r   s    €€r   Úinnerz_Available.parse.<locals>.inner$   s   ø€ Ø'8ˆDÔ$Ù˜“:Ðr   © )r   r   r   s   `` r   Úparsez_Available.parse   s   ù€ õ$	ð ˆr   NÚsupported_namec                 ó   ‡ ‡‡— ˆˆ ˆfd„}|S )a
  A decorator that marks a function as available, but also prints a
        deprecation warning. Use like

        @available.deprecated('my_new_method')
        def my_old_method(self, arg):
            args = compatability_shim(arg)
            return self.my_new_method(*args)

        @available.deprecated('my_new_slow_method', lambda *a, **k: (0, ''))
        def my_old_slow_method(self, arg):
            args = compatibility_shim(arg)
            return self.my_new_slow_method(*args)

        To make `adapter.my_old_method` available but also print out a warning
        on use directing users to `my_new_method`.

        The optional parse_replacement, if provided, will provide a parse-time
        replacement for the actual method (see `available.parse`).
        c                 ó†   •‡ ‡— ‰ j                   Št        ‰ «      ˆ ˆˆfd„«       }‰r‰j                  ‰«      }n‰} ||«      S )Nc                  ó@   •— t        t        ‰‰¬«      «        ‰| i |¤ŽS )N)Úold_nameÚnew_name)r
   r   )ÚargsÚkwargsr   Ú	func_namer   s     €€€r   r   z5_Available.deprecated.<locals>.wrapper.<locals>.innerD   s'   ø€ äÜ-°yÈ>ÔZôñ ˜TÐ, VÑ,Ð,r   )Ú__name__r   r   )r   r   Úavailable_functionr&   r   r   r   s   `  @€€€r   Úwrapperz&_Available.deprecated.<locals>.wrapperA   sH   ú€ ØŸ™ˆIä�4‹[õ-ó ð-ñ !Ø%)§Z¡ZÐ0AÓ%BÑ"à%)Ð"Ù% eÓ,Ð,r   r   )r   r   r   r)   s   ``` r   Ú
deprecatedz_Available.deprecated*   s   ú€ ö.	-ð  ˆr   c                 ó6   — | j                  d„ «      } ||«      S )Nc                   ó   — y r   r   ©ÚaÚks     r   ú<lambda>z'_Available.parse_none.<locals>.<lambda>T   s   � r   ©r   ©r   r   r)   s      r   Ú
parse_nonez_Available.parse_noneS   s   € Ø—*‘*Ñ1Ó2ˆÙ�t‹}Ðr   c                 ó6   — | j                  d„ «      } ||«      S )Nc                  ó   — g S r   r   r-   s     r   r0   z'_Available.parse_list.<locals>.<lambda>X   s   € ¨R€ r   r1   r2   s      r   Ú
parse_listz_Available.parse_listW   s   € Ø—*‘*Ñ/Ó0ˆÙ�t‹}Ðr   r   )r'   Ú
__module__Ú__qualname__r   r   Ú	Decoratorr   Ústrr   r*   r3   r6   r   r   r   r   r      sx   „ ð˜Xð ¨(ó ð xð °Ió ð2 LPñ'Ø!ð'Ø6>¸xÑ6Hð'à	ó'ðR˜xð ¨Hó ð˜xð ¨Hô r   r   c                   ó   — e Zd ZdZdZy)Úavailable_propertyaÖ  
    This supports making dynamic properties (`@property`) available in the jinja context.

    We use `@available` to make methods available in the jinja context, but this mechanism relies on the method being callable.
    Intuitively, we should be able to use both `@available` and `@property` to create a dynamic property that's available in the jinja context.

    Using the `@property` decorator as the inner decorator supplies `@available` with something that is not callable.
    Instead of returning the method, `@property` returns the value itself, not the method that is called to create the value.

    Using the `@available` decorator as the inner decorator adds `_is_available_ = True` to the function.
    However, when the `@property` decorator executes, it returns a `property` object which does not have the `_is_available_` attribute.

    This decorator solves this problem by simply adding `_is_available_ = True` as an attribute on the `property` built-in.
    TN)r'   r7   r8   Ú__doc__r   r   r   r   r<   r<   _   s   „ ñð �Nr   r<   c                   ó:   — e Zd ZU ee   ed<   eeef   ed<   dd„Zy)ÚAdapterMetaÚ_available_Ú_parse_replacements_c           	      óÆ  — t        j                  j                  | |||fi |¤Ž}t        «       }i }|D ]J  }|j	                  t        |dt        «       «      «       |j	                  t        |dt        «       «      «       ŒL |j                  «       D ]8  \  }}	t        |	dd«      r|j                  |«       t        |	dd «      }
|
€Œ4|
||<   Œ: t        |«      |_	        ||_
        |S )Nr@   rA   r   Fr   )ÚabcÚABCMetaÚ__new__ÚsetÚupdateÚgetattrÚitemsÚaddÚ	frozensetr@   rA   )ÚmclsÚnameÚbasesÚ	namespacer%   ÚclsÚ	availableÚreplacementsÚbaseÚvaluer   s              r   rE   zAdapterMeta.__new__v   sç   € ô �k‰k×!Ñ! $¨¨e°YÑIÀ&ÑIˆô "›eˆ	Ø')ˆð ò 	NˆDØ×ÑœW T¨=¼#»%Ó@ÔAØ×Ñ¤¨Ð.DÄcÃeÓ LÕMð	Nð
 %Ÿ?™?Ó,ò 	7‰KˆD�%Ü�uÐ.°Ô6Ø—‘˜dÔ#Ü '¨Ð/DÀdÓ KÐØ Ñ,Ø%6�˜TÒ"ð	7ô $ IÓ.ˆŒà#/ˆÔ Øˆ
r   N)r   r?   )	r'   r7   r8   r   r:   Ú__annotations__r   r   rE   r   r   r   r?   r?   r   s    … Ø˜3‘ÓØ˜s H˜}Ñ-Ó-ô r   r?   )rC   Ú	functoolsr   Útypingr   r   r   r   r   r	   Údbt_common.events.functionsr
   Údbt.adapters.events.typesr   r9   r   rQ   Úpropertyr<   rD   r?   r   r   r   ú<module>r[      s[   ðÛ 
Ý ß @× @å 5å ?ð �c�U˜H�_Ñ%€	÷Lñ Lñ^ ‹L€	ô˜ô ô&$�#—+‘+õ $r   