
    i                         d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	m
Z
  e       Zej                  d      defd       Zej                  d      d	efd
       Zy)    )	APIRouterHTTPException)VueGraphContentPayload)fetch_vuegraph_contentsave_vuegraph_content)get_server_loggerLogTypez/api/vuegraphs/upload/contentpayloadc           	      ~  K   t               }	 t        | j                  | j                         |j                  dt        j                  | j                         | j                  dd	S # t        $ rH}|j                  dt        j                  | j                  t        |             t        dd      d }~ww xY ww)
Nz#Failed to persist Vue graph contentlog_typefilenameerror  zUnable to save graph contentstatus_codedetailzVue graph content savedr   r   saved)r   status)r   r   r   content	Exceptionr   r	   ERRORstrr   infoREQUEST)r
   loggerexcs      D/Users/bowang/.openclaw/workspace/ChatDev/server/routes/vuegraphs.pyupload_vuegraph_contentr    
   s      F	Tg..@ KK!!!  
  ((G<<  T1]]%%c(	 	 	
 4RSSTs(   B= A) ;B=)	B:2AB55B::B=z/api/vuegraphs/{filename}r   c           	      6  K   t               }	 t        |       }|t        dd      |j                  dt        j                  | 	       | |d
S # t        $ r>}|j                  dt        j
                  | t        |             t        dd      d }~ww xY ww)Nz Failed to load Vue graph contentr   r   zUnable to read graph contentr   i  zGraph content not foundzVue graph content fetchedr   )r   r   )
r   r   r   r   r	   r   r   r   r   r   )r   r   r   r   s       r   get_vuegraph_contentr"       s      F	T(2 4MNN
KK#  
 !W55#  T.]]c(	 	 	
 4RSSTs'   BA 6B	B9BBBN)fastapir   r   server.modelsr   !server.services.vuegraphs_storager   r   utils.structured_loggerr   r	   routerpostr    getr   r"        r   <module>r,      sc    , 0 [ >	 ,-=+A = .=* '(6 6 )6r+   