
    x
hj                     
   d dl mZmZ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mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ e
dedededededed	edededed
ediZddZddZddZ ddZ!d Z"d Z#d Z$d Z%d Z&d Z'd Z(y)    )absolute_importdivisionprint_functionunicode_literals)Backend)ApiNamespace)BooleanBytesFloat32Float64Int32Int64ListString	TimestampUInt32UInt64Voidis_aliasis_list_typeis_struct_typeis_map_typeis_user_defined_type	fmt_camelbooleanstringnumberArrayr   voidNc                 4    |dk7  r|nddt        | |      dS )z
    Converts the error type into a TypeScript type.
    inside_namespace should be set to the namespace that the reference
    occurs in, or None if this parameter is not relevant.
     Error<>)fmt_type)	data_typeinside_namespacewrap_error_ins      _/var/www/html/lionshead-backend/venv/lib/python3.12/site-packages/stone/backends/tsd_helpers.pyfmt_error_typer+   ,   s(     )B.W	<,-     c                    t        |       st        |       r@| j                  |k(  r| j                  S | j                  j                  d| j                  S t        j                  | j                  d      }t        |       r!|dt        | j                  |      z   dz   z  }|S t        |       r?t        j                  | j                  d      }t        | j                  |      }d|d|d}|S )	z
    Produces a TypeScript type name for the given data type.
    inside_namespace should be set to the namespace that the reference
    occurs in, or None if this parameter is not relevant.
    .Objectr$   r%   r   z{[key: z]: })r   r   	namespacename_base_type_tableget	__class__r   r&   r'   r   key_data_typefmt_type_namevalue_data_type)r'   r(   
fmted_typer6   r8   s        r*   r7   r7   7   s     I&(9*="22>>!'1166	GG%)))*=*=xH
	"#)<)<>N OORUUUJ
 	 #,001H1H(SM+I,E,EGWXO.;_MJr,   c                      t        | |      dz   S )z
    Produces a TypeScript type name for the meta-type that refers to the given
    struct, which belongs to an enumerated subtypes tree. This meta-type contains the
    .tag field that lets developers discriminate between subtypes.
    	Reference)r7   )r'   r(   s     r*   fmt_polymorphic_type_referencer<   L   s     $45CCr,   c                 *   t        |       r}| j                         rmg }| j                         }|D ]   \  }}|j                  t	        ||             " | j                         r|j                  t	        | |             t        |      S t        | |      S )z
    Returns a TypeScript type annotation for a data type.
    May contain a union of enumerated subtypes.
    inside_namespace should be set to the namespace that the type reference
    occurs in, or None if this parameter is not relevant.
    )r   has_enumerated_subtypesget_all_subtypes_with_tagsappendr<   is_catch_all	fmt_unionr7   )r'   r(   possible_typespossible_subtypes_subtypes         r*   r&   r&   X   s     i Y%F%F%H%@@B+JAw!!"@JZ"[\ ,!!#!!"@L\"]^((Y(899r,   c                 J    t        |       dkD  rdj                  |       S | d   S )z2
    Returns a union type of the given types.
       |r   )lenjoin)type_stringss    r*   rB   rB   j   s(     &)%6%:388L!OQOr,   c                 \    |dk(  rt        |       S t        |       dj                  |      z   S )NrH   zV{})r   format)r2   versions     r*   fmt_funcrP   p   s+    !|T?U\\'222r,   c                     t        |       S Nr   )r2   s    r*   fmt_varrS   v   s    T?r,   c                 8   |dk(  r|}d|vr| | j                   dz   |z   }|S |dk(  r6d|v r!|j                  dd      \  }}t        |      }nd}t        ||      dz   S |dk(  r|j	                  dd      \  }}d	|d
|dS |dk(  r|S |dk(  r|S t        d|z        )z.
    Processes a documentation reference.
    typer.   route:rH   z()link [z]{@link r0   valfieldzUnknown doc ref tag %r)r2   splitintrP   rsplitRuntimeError)cur_namespacetagr[   fq_valrO   anchorrX   s          r*   fmt_tagre   y   s     f}c>m7"''#-6F	#:99S!,LC'lGGW%,,	zz#q) $*400	
	
3c9::r,   c                     i }| j                   D ]K  }t        |j                  |j                        }||v r ||   }t	        dj                  ||            |||<   M y)z
    Check name conflicts among generated route definitions. Raise a runtime exception when a
    conflict is encountered.
    z.There is a name conflict between {!r} and {!r}N)routesrP   r2   rO   r`   rN   )r1   route_by_namerV   
route_nameother_routes        r*   check_route_name_conflictrk      si     M!!ejj%--8
&'
3K@GGUZ[] ]$)j! "r,   c                     |j                         }|sy |D ].  }| j                  dj                  ||j                               0 | j                          y )NzIimport * as {namespace_name} from '{module_name_prefix}{namespace_name}';)module_name_prefixnamespace_name)get_imported_namespacesemitrN   r2   )backendr1   rm   imported_namespacesnss        r*   *generate_imports_for_referenced_namespacesrt      sX     $;;=!W^^#5!ww _ 	
 " LLNr,   c                 4    | j                   | j                  z   S rR   )
data_typesaliases)r1   s    r*   get_data_types_for_namespacerx      s    )"3"333r,   )Nr"   rR   ))
__future__r   r   r   r   stone.backendr   stone.ir.apir   stone.irr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   stone.backends.helpersr   r3   r+   r7   r<   r&   rB   rP   rS   re   rk   rt   rx    r,   r*   <module>r      s    R R ! %    &
 Y	8XX	8	8'
H
H
H{&  	*
D:$P3;<*  4r,   