
    x
hD                         d dl mZmZmZmZ d dlZd dl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 d dlmZ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 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_literalsN)BooleanBytesFloat32Float64Int32Int64ListString	TimestampUInt32UInt64Voidis_list_typeis_struct_typeis_user_defined_type)	fmt_camel
fmt_pascalbooleanstringnumberArrayr   voidc                     t        | t        j                        rt        |       j	                  d      S t        j                  | d      S )Nu   )indent)
isinstancesix	text_typereprlstripjsondumps)os    ^/var/www/html/lionshead-backend/venv/lib/python3.12/site-packages/stone/backends/js_helpers.pyfmt_objr*   ,   s4    !S]]#Aw~~c""zz!A&&    c                 2    |dk7  r|nddt        |       dS )z4
    Converts the error type into a JSDoc type.
     Error.<>)fmt_type)	data_typewrap_error_ins     r)   fmt_error_typer4   4   s%    
 )B.W	< r+   c                    t        |       r-t        | j                  j                  | j                        S t        j                  | j                  d      }t        |       r|dt        | j                        z   dz   z  }|S )zg
    Returns the JSDoc name for the given data type.
    (Does not attempt to enumerate subtypes.)
    Objectr/   r0   )
r   r   	namespacename_base_type_tableget	__class__r   r1   r2   )r2   
fmted_types     r)   fmt_type_namer=   >   sq    
 I&I$7$7$<$<innMNN%)))*=*=xH
	"$)*=*=!>>DDJr+   c                 $   t        |       r{| j                         rkg }| j                         }|D ]  \  }}|j                  t	        |             ! | j                         r|j                  t	        |              t        |      S t	        |       S )ze
    Returns a JSDoc annotation for a data type.
    May contain a union of enumerated subtypes.
    )r   has_enumerated_subtypesget_all_subtypes_with_tagsappendr=   is_catch_allfmt_jsdoc_union)r2   possible_typespossible_subtypes_subtypes        r)   r1   r1   L   s    
 i Y%F%F%H%@@B+JAw!!-"89 ,!!#!!-	":;~..Y''r+   c                 V    t        |       dkD  rddj                  |       z   dz   S | d   S )z:
    Returns a JSDoc union of the given type strings.
       (|)r   )lenjoin)type_stringss    r)   rC   rC   ]   s3     25\1BQ1F3,''#-[LYZO[r+   c                 \    |dk(  rt        |       S t        |       dj                  |      z   S )NrI   zV{})r   format)r8   versions     r)   fmt_funcrS   d   s+    !|T?U\\'222r+   c                 V    |dk7  rdj                  | ||      S dj                  | |      S )NrI   z	{}/{}_v{}z{}/{})rQ   )namespace_name
route_nameroute_versions      r)   fmt_urlrX   j   s0    !!.*mLL~~nj99r+   c                     t        |       S )N)r   )r8   s    r)   fmt_varrZ   q   s    T?r+   c                     i }| j                   D ]L  }t        |j                  |j                        }||v r ||   }t	        dj                  ||            |||<   N y)z
    Check name conflicts among generated route definitions. Raise a runtime exception when a
    conflict is encountered.
    )rR   z.There is a name conflict between {!r} and {!r}N)routesrS   r8   rR   RuntimeErrorrQ   )r7   route_by_namerouterV   other_routes        r)   check_route_name_conflictra   u   si     M!!ejj%--@
&'
3K@GGUZ[] ]$)j! "r+   )r-   )$
__future__r   r   r   r   r&   r"   stone.irr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   stone.backends.helpersr   r   r9   r*   r4   r=   r1   rC   rS   rX   rZ   ra    r+   r)   <module>rf      s    R R  
    " Y	8XX	8	8'
H
H
H{&  '("\3:*r+   