d i f f   - - g i t   a / d i f f . t x t   b / d i f f . t x t 
 
 i n d e x   8 6 4 c 3 9 6 . . e 6 9 d e 2 9   1 0 0 6 4 4 
 
 B i n a r y   f i l e s   a / d i f f . t x t   a n d   b / d i f f . t x t   d i f f e r 
 
 d i f f   - - g i t   a / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / d e n o . j s o n   b / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / d e n o . j s o n 
 
 i n d e x   f 5 d b 2 8 0 . . 8 b 2 0 4 c a   1 0 0 6 4 4 
 
 - - -   a / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / d e n o . j s o n 
 
 + + +   b / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / d e n o . j s o n 
 
 @ @   - 1 , 5   + 1 , 8   @ @ 
 
   { 
 
       " i m p o r t s " :   { 
 
 -         " z o d " :   " h t t p s : / / d e n o . l a n d / x / z o d @ v 3 . 2 2 . 4 / m o d . t s " 
 
 +         " z o d " :   " h t t p s : / / d e n o . l a n d / x / z o d @ v 3 . 2 2 . 4 / m o d . t s " , 
 
 +         " o p e n a i " :   " n p m : o p e n a i @ 6 . 1 6 . 0 " , 
 
 +         " @ s u p a b a s e / s u p a b a s e - j s " :   " n p m : @ s u p a b a s e / s u p a b a s e - j s @ 2 " , 
 
 +         " @ s u p a b a s e / f u n c t i o n s - j s / e d g e - r u n t i m e . d . t s " :   " j s r : @ s u p a b a s e / f u n c t i o n s - j s @ ^ 2 / e d g e - r u n t i m e . d . t s " 
 
       } 
 
   } 
 
 d i f f   - - g i t   a / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / i n d e x . t s   b / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / i n d e x . t s 
 
 i n d e x   f 4 e 6 1 c 1 . . 0 f 3 1 8 5 b   1 0 0 6 4 4 
 
 - - -   a / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / i n d e x . t s 
 
 + + +   b / s u p a b a s e / f u n c t i o n s / a i - g e n e r a t e - p l a n / i n d e x . t s 
 
 @ @   - 5 , 6   + 5 , 7   @ @ 
 
   / /   S e t u p   t y p e   d e f i n i t i o n s   f o r   b u i l t - i n   S u p a b a s e   R u n t i m e   A P I s 
 
   i m p o r t   " j s r : @ s u p a b a s e / f u n c t i o n s - j s / e d g e - r u n t i m e . d . t s " ; 
 
   i m p o r t   {   c o r s H e a d e r s   }   f r o m   " . . / _ s h a r e d / c o r s . t s " ; 
 
 + i m p o r t   {   H t t p E r r o r ,   s e n d E r r o r ,   s e n d S u c c e s s   }   f r o m   " . . / _ s h a r e d / u t i l s . t s " ; 
 
   i m p o r t   {   c r e a t e C l i e n t   }   f r o m   " n p m : @ s u p a b a s e / s u p a b a s e - j s @ 2 " ; 
 
   i m p o r t   t y p e   {   D a t a b a s e ,   J s o n   }   f r o m   " . . / _ s h a r e d / d a t a b a s e . t y p e s . t s " ; 
 
   i m p o r t   t y p e   {   A I G e n e r a t e P l a n I n p u t   }   f r o m   " . / t y p e s . t s " ; 
 
 @ @   - 1 8 , 7   + 1 9 , 7   @ @   t y p e   N i v e l T y p e   = 
 
   t y p e   T i p o C i c l o T y p e   = 
 
       D a t a b a s e [ " p u b l i c " ] [ " T a b l e s " ] [ " p l a n e s _ e s t u d i o " ] [ " I n s e r t " ] [ " t i p o _ c i c l o " ] ; 
 
   
 
 - D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
 + D e n o . s e r v e ( a s y n c   ( r e q :   R e q u e s t ) :   P r o m i s e < R e s p o n s e >   = >   { 
 
       c o n s t   u r l   =   n e w   U R L ( r e q . u r l ) ; 
 
       c o n s t   f u n c t i o n N a m e   =   u r l . p a t h n a m e . s p l i t ( " / " ) . p o p ( ) ; 
 
       c o n s o l e . l o g ( 
 
 @ @   - 3 7 , 1 2   + 3 8 , 1 1   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
                       n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
                   } ] [ $ { f u n c t i o n N a m e } ] :   I n v a l i d   m e t h o d :   $ { m e t h o d } ` , 
 
               ) ; 
 
 -             r e t u r n   n e w   R e s p o n s e ( 
 
 -                 J S O N . s t r i n g i f y ( {   e r r o r :   " M e t h o d   n o t   a l l o w e d "   } ) , 
 
 -                 { 
 
 -                     h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -                     s t a t u s :   4 0 5 , 
 
 -                 } , 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 4 0 5 , 
 
 +                 " M % t o d o   n o   p e r m i t i d o . " , 
 
 +                 " M E T H O D _ N O T _ A L L O W E D " , 
 
 +                 {   m e t h o d   } , 
 
               ) ; 
 
           } 
 
   
 
 @ @   - 5 4 , 1 2   + 5 4 , 1 1   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
                       n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
                   } ] [ $ { f u n c t i o n N a m e } ] :   M i s s i n g   A u t h o r i z a t i o n   h e a d e r ` , 
 
               ) ; 
 
 -             r e t u r n   n e w   R e s p o n s e ( 
 
 -                 J S O N . s t r i n g i f y ( {   e r r o r :   " A u t h o r i z a t i o n   h e a d e r   m i s s i n g "   } ) , 
 
 -                 { 
 
 -                     h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -                     s t a t u s :   4 0 1 , 
 
 -                 } , 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 4 0 1 , 
 
 +                 " N o   a u t o r i z a d o . " , 
 
 +                 " U N A U T H O R I Z E D " , 
 
 +                 {   r e a s o n :   " m i s s i n g _ a u t h o r i z a t i o n _ h e a d e r "   } , 
 
               ) ; 
 
           } 
 
   
 
 @ @   - 7 0 , 1 9   + 6 9 , 2 8   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
                       n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
                   } ] [ $ { f u n c t i o n N a m e } ] :   U n s u p p o r t e d   c o n t e n t   t y p e :   $ { c o n t e n t T y p e } ` , 
 
               ) ; 
 
 -             r e t u r n   n e w   R e s p o n s e ( 
 
 -                 J S O N . s t r i n g i f y ( {   e r r o r :   " U n s u p p o r t e d   c o n t e n t   t y p e "   } ) , 
 
 -                 { 
 
 -                     h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -                     s t a t u s :   4 0 0 , 
 
 -                 } , 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 4 1 5 , 
 
 +                 " C o n t e n t - T y p e   n o   s o p o r t a d o . " , 
 
 +                 " U N S U P P O R T E D _ M E D I A _ T Y P E " , 
 
 +                 {   c o n t e n t T y p e   } , 
 
               ) ; 
 
           } 
 
   
 
           c o n s t   S U P A B A S E _ U R L   =   D e n o . e n v . g e t ( " S U P A B A S E _ U R L " ) ; 
 
           c o n s t   S U P A B A S E _ A N O N _ K E Y   =   D e n o . e n v . g e t ( " S U P A B A S E _ A N O N _ K E Y " ) ; 
 
           i f   ( ! S U P A B A S E _ U R L   | |   ! S U P A B A S E _ A N O N _ K E Y )   { 
 
 -             t h r o w   n e w   E r r o r ( " S u p a b a s e   e n v i r o n m e n t   v a r i a b l e s   a r e   n o t   s e t " ) ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 0 , 
 
 +                 " C o n f i g u r a c i %%n   d e l   s e r v i d o r   i n c o m p l e t a . " , 
 
 +                 " M I S S I N G _ E N V " , 
 
 +                 { 
 
 +                     m i s s i n g :   [ 
 
 +                         ! S U P A B A S E _ U R L   ?   " S U P A B A S E _ U R L "   :   n u l l , 
 
 +                         ! S U P A B A S E _ A N O N _ K E Y   ?   " S U P A B A S E _ A N O N _ K E Y "   :   n u l l , 
 
 +                     ] . f i l t e r ( B o o l e a n ) , 
 
 +                 } , 
 
 +             ) ; 
 
           } 
 
   
 
           / /   I f   n e e d e d   f o r   R L S - p r o t e c t e d   r e a d s ,   c r e a t e   a n   a n o n   c l i e n t   w i t h   u s e r ' s   J W T 
 
 @ @   - 9 7 , 7   + 1 0 5 , 1 2   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
   
 
           c o n s t   S E R V I C E _ R O L E _ K E Y   =   D e n o . e n v . g e t ( " S U P A B A S E _ S E R V I C E _ R O L E _ K E Y " ) ; 
 
           i f   ( ! S E R V I C E _ R O L E _ K E Y )   { 
 
 -             t h r o w   n e w   E r r o r ( " S U P A B A S E _ S E R V I C E _ R O L E _ K E Y   i s   n o t   s e t " ) ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 0 , 
 
 +                 " C o n f i g u r a c i %%n   d e l   s e r v i d o r   i n c o m p l e t a . " , 
 
 +                 " M I S S I N G _ E N V " , 
 
 +                 {   m i s s i n g :   [ " S U P A B A S E _ S E R V I C E _ R O L E _ K E Y " ]   } , 
 
 +             ) ; 
 
           } 
 
   
 
           c o n s t   s u p a b a s e S e r v i c e   =   c r e a t e C l i e n t < D a t a b a s e > ( 
 
 @ @   - 1 1 2 , 1 2   + 1 2 5 , 1 5   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
                   ` [ $ { n e w   D a t e ( ) . t o I S O S t r i n g ( ) } ] [ $ { f u n c t i o n N a m e } ] :   V a l i d a t i o n   e r r o r s : ` , 
 
                   v a l i d a t i o n . e r r o r s , 
 
               ) ; 
 
 -             r e t u r n   n e w   R e s p o n s e ( 
 
 -                 J S O N . s t r i n g i f y ( {   e r r o r s :   v a l i d a t i o n . e r r o r s   } ) , 
 
 -                 { 
 
 -                     h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -                     s t a t u s :   4 0 0 , 
 
 -                 } , 
 
 +             c o n s t   m e s s a g e   =   v a l i d a t i o n . e r r o r s 
 
 +                 . m a p ( ( e ,   i )   = >   ` ( $ { i   +   1 } )   $ { e } ` ) 
 
 +                 . j o i n ( " \ n " ) ; 
 
 + 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 4 2 2 , 
 
 +                 m e s s a g e , 
 
 +                 " V A L I D A T I O N _ E R R O R " , 
 
 +                 {   e r r o r s :   v a l i d a t i o n . e r r o r s   } , 
 
               ) ; 
 
           } 
 
   
 
 @ @   - 1 3 0 , 8   + 1 4 6 , 2 3   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
                   . e q ( " i d " ,   p a y l o a d . d a t o s B a s i c o s . e s t r u c t u r a P l a n I d ) 
 
                   . s i n g l e ( ) ; 
 
           i f   ( e s t r u c t u r a P l a n E r r o r )   { 
 
 -             t h r o w   n e w   E r r o r ( 
 
 -                 " E r r o r   f e t c h i n g   e s t r u c t u r a P l a n :   "   +   e s t r u c t u r a P l a n E r r o r . m e s s a g e , 
 
 +             c o n s t   m a y b e C o d e   =   ( e s t r u c t u r a P l a n E r r o r   a s   {   c o d e ? :   s t r i n g   } ) . c o d e ; 
 
 +             i f   ( m a y b e C o d e   = = =   " P G R S T 1 1 6 " )   { 
 
 +                 t h r o w   n e w   H t t p E r r o r ( 
 
 +                     4 0 4 , 
 
 +                     " N o   s e   e n c o n t r %%  l a   e s t r u c t u r a   d e l   p l a n . " , 
 
 +                     " N O T _ F O U N D " , 
 
 +                     { 
 
 +                         t a b l e :   " e s t r u c t u r a s _ p l a n " , 
 
 +                         i d :   p a y l o a d . d a t o s B a s i c o s . e s t r u c t u r a P l a n I d , 
 
 +                     } , 
 
 +                 ) ; 
 
 +             } 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 0 , 
 
 +                 " N o   s e   p u d o   o b t e n e r   l a   e s t r u c t u r a   d e l   p l a n . " , 
 
 +                 " S U P A B A S E _ Q U E R Y _ F A I L E D " , 
 
 +                 e s t r u c t u r a P l a n E r r o r , 
 
               ) ; 
 
           } 
 
   
 
 @ @   - 1 7 2 , 2 5   + 2 0 3 , 6 4   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
           / /   U s e   s h a r e d   O p e n A I   s e r v i c e   d i r e c t l y   ( n o   H T T P   i n v o k e ) 
 
           c o n s t   s v c   =   O p e n A I S e r v i c e . f r o m E n v ( ) ; 
 
           i f   ( ! ( s v c   i n s t a n c e o f   O p e n A I S e r v i c e ) )   { 
 
 -             t h r o w   n e w   E r r o r ( ` O p e n A I   s e r v i c e   m i s c o n f i g u r a t i o n :   $ { s v c . m e s s a g e } ` ) ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 0 , 
 
 +                 " C o n f i g u r a c i %%n   d e l   s e r v i d o r   i n c o m p l e t a . " , 
 
 +                 " O P E N A I _ M I S C O N F I G U R E D " , 
 
 +                 s v c , 
 
 +             ) ; 
 
           } 
 
   
 
 +         / /   I N I C I O   D E   C % D I G O   P A R A   D E B B U G G I N G 
 
 +         / /   c o n s o l e . l o g ( 
 
 +         / /       ` [ $ { 
 
 +         / /           n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
 +         / /       } ] [ $ { f u n c t i o n N a m e } ] :   R e q u e s t   p r o c e s s e d   s u c c e s s f u l l y ` , 
 
 +         / /   ) ; 
 
 +         / /   c o n s t   {   d a t a :   p l a n _ d e b u g   }   =   a w a i t   s u p a b a s e S e r v i c e 
 
 +         / /       . f r o m ( " p l a n e s _ e s t u d i o " ) 
 
 +         / /       . s e l e c t ( " * " ) 
 
 +         / /       . e q ( " i d " ,   " 7 c e 6 5 7 b 1 - 1 a b f - 4 9 7 2 - 8 5 8 d - 5 f f f e 1 d 5 1 4 9 9 " ) 
 
 +         / /       . m a y b e S i n g l e ( ) ; 
 
 +         / /   r e t u r n   s e n d S u c c e s s ( p l a n _ d e b u g ) ; 
 
 +         / /   F I N   D E   C % D I G O   P A R A   D E B B U G G I N G 
 
 + 
 
           c o n s t   a i R e s u l t   =   a w a i t   s v c . c r e a t e S t r u c t u r e d R e s p o n s e ( 
 
               a i S t r u c t u r e d P a y l o a d , 
 
               p a y l o a d . a r c h i v o s A d j u n t o s , 
 
           ) ; 
 
           i f   ( ! a i R e s u l t . o k )   { 
 
 -             t h r o w   n e w   E r r o r ( 
 
 -                 ` O p e n A I   c a l l   f a i l e d   [ $ { a i R e s u l t . c o d e } ] :   $ { a i R e s u l t . m e s s a g e } ` , 
 
 +             c o n s t   s t a t u s   =   a i R e s u l t . c o d e   = = =   " M i s s i n g E n v "   ?   5 0 0   :   5 0 2 ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 s t a t u s , 
 
 +                 " N o   s e   p u d o   g e n e r a r   e l   p l a n   c o n   I A . " , 
 
 +                 " O P E N A I _ R E Q U E S T _ F A I L E D " , 
 
 +                 a i R e s u l t , 
 
               ) ; 
 
           } 
 
   
 
           / /   P r e f e r   p a r s e d   o u t p u t ;   f a l l b a c k   t o   p a r s e   o u t p u t T e x t 
 
 -         c o n s t   a i O u t p u t   =   a i R e s u l t . o u t p u t   ? ? 
 
 -             ( a i R e s u l t . o u t p u t T e x t   ?   J S O N . p a r s e ( a i R e s u l t . o u t p u t T e x t )   :   n u l l ) ; 
 
 +         l e t   a i O u t p u t   =   a i R e s u l t . o u t p u t   ? ?   n u l l ; 
 
 +         i f   ( a i O u t p u t   = =   n u l l   & &   a i R e s u l t . o u t p u t T e x t )   { 
 
 +             t r y   { 
 
 +                 a i O u t p u t   =   J S O N . p a r s e ( a i R e s u l t . o u t p u t T e x t ) ; 
 
 +             }   c a t c h   { 
 
 +                 t h r o w   n e w   H t t p E r r o r ( 
 
 +                     5 0 2 , 
 
 +                     " L a   r e s p u e s t a   d e   l a   I A   n o   e s   J S O N   v % l i d o . " , 
 
 +                     " O P E N A I _ I N V A L I D _ J S O N " , 
 
 +                     {   o u t p u t T e x t :   a i R e s u l t . o u t p u t T e x t   } , 
 
 +                 ) ; 
 
 +             } 
 
 +         } 
 
           c o n s t   a i O u t p u t J s o n :   J s o n   =   a i O u t p u t   a s   u n k n o w n   a s   J s o n ; 
 
           i f   ( ! a i O u t p u t )   { 
 
 -             t h r o w   n e w   E r r o r ( " O p e n A I   r e s p o n s e   d i d   n o t   c o n t a i n   s t r u c t u r e d   o u t p u t " ) ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 2 , 
 
 +                 " L a   r e s p u e s t a   d e   l a   I A   n o   c o n t i e n e   s a l i d a   e s t r u c t u r a d a . " , 
 
 +                 " O P E N A I _ M I S S I N G _ S T R U C T U R E D _ O U T P U T " , 
 
 +                 {   o u t p u t T e x t :   a i R e s u l t . o u t p u t T e x t   ? ?   n u l l   } , 
 
 +             ) ; 
 
           } 
 
   
 
           / /   T O D O :   I n s e r t a r   i n t e r a c c i o n e s   c o n   I A   y   q u i z a s   f o r z a r   a   q u e   l a   i n f o r m a c i o n   d e   d a t o s B a s i c o s   s e a   l a   m i s m a   q u e   l a   r e c i b i d a 
 
 @ @   - 2 0 9 , 7   + 2 7 9 , 2 0   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
               . e q ( " i d " ,   p a y l o a d . d a t o s B a s i c o s . c a r r e r a I d ) 
 
               . m a y b e S i n g l e ( ) ; 
 
           i f   ( c a r r e r a E r r o r )   { 
 
 -             t h r o w   n e w   E r r o r ( " E r r o r   f e t c h i n g   c a r r e r a :   "   +   c a r r e r a E r r o r . m e s s a g e ) ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 5 0 0 , 
 
 +                 " N o   s e   p u d o   o b t e n e r   l a   c a r r e r a . " , 
 
 +                 " S U P A B A S E _ Q U E R Y _ F A I L E D " , 
 
 +                 c a r r e r a E r r o r , 
 
 +             ) ; 
 
 +         } 
 
 +         i f   ( ! c a r r e r a )   { 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 4 0 4 , 
 
 +                 " N o   s e   e n c o n t r %%  l a   c a r r e r a . " , 
 
 +                 " N O T _ F O U N D " , 
 
 +                 {   t a b l e :   " c a r r e r a s " ,   i d :   p a y l o a d . d a t o s B a s i c o s . c a r r e r a I d   } , 
 
 +             ) ; 
 
           } 
 
   
 
           c o n s t   p l a n I n s e r t :   D a t a b a s e [ " p u b l i c " ] [ " T a b l e s " ] [ " p l a n e s _ e s t u d i o " ] [ " I n s e r t " ]   = 
 
 @ @   - 2 5 7 , 4 2   + 3 4 0 , 6 2   @ @   D e n o . s e r v e ( a s y n c   ( r e q )   = >   { 
 
           / /   T O D O :   i n t e r a c c i o n   c o n   I A   y   c a m b i o   d e   e s t a d o 
 
   
 
           i f   ( p l a n E r r o r )   { 
 
 -             t h r o w   n e w   E r r o r ( " E r r o r   i n s e r t i n g   p l a n :   "   +   p l a n E r r o r . m e s s a g e ) ; 
 
 +             c o n s t   m a y b e C o d e   =   ( p l a n E r r o r   a s   {   c o d e ? :   s t r i n g   } ) . c o d e ; 
 
 +             / /   C o m m o n   c a s e s : 
 
 +             / /   -   f o r e i g n   k e y   /   c o n s t r a i n t   v i o l a t i o n s   - >   4 0 9 
 
 +             / /   -   o t h e r s   - >   5 0 0 
 
 +             c o n s t   s t a t u s   =   m a y b e C o d e   ?   4 0 9   :   5 0 0 ; 
 
 +             t h r o w   n e w   H t t p E r r o r ( 
 
 +                 s t a t u s , 
 
 +                 " N o   s e   p u d o   g u a r d a r   e l   p l a n   d e   e s t u d i o s . " , 
 
 +                 " S U P A B A S E _ I N S E R T _ F A I L E D " , 
 
 +                 {   . . . p l a n E r r o r ,   c o d e :   m a y b e C o d e   } , 
 
 +             ) ; 
 
           } 
 
   
 
           / /   T O D O :   u p d a t e   a   i n t e r a c c i o n _ i a   y   e   i n s e r t   a   c a m b i o s _ p l a n   c o n   i d   d e   p l a n   g e n e r a d o 
 
 -         c o n s t   j s o n R e s p o n s e   =   { 
 
 -             o k :   t r u e , 
 
 -             p l a n , 
 
 -         } ; 
 
   
 
           c o n s o l e . l o g ( 
 
               ` [ $ { 
 
                   n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
               } ] [ $ { f u n c t i o n N a m e } ] :   R e q u e s t   p r o c e s s e d   s u c c e s s f u l l y ` , 
 
           ) ; 
 
 -         r e t u r n   n e w   R e s p o n s e ( 
 
 -             J S O N . s t r i n g i f y ( j s o n R e s p o n s e ) , 
 
 -             { 
 
 -                 h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -                 s t a t u s :   2 0 0 , 
 
 -             } , 
 
 -         ) ; 
 
 +         r e t u r n   s e n d S u c c e s s ( p l a n ) ; 
 
       }   c a t c h   ( e r r o r )   { 
 
 -         / /   L o g   f u l l   e r r o r   s e r v e r - s i d e   f o r   d i a g n o s t i c s 
 
 -         i f   ( e r r o r   i n s t a n c e o f   E r r o r )   { 
 
 +         i f   ( e r r o r   i n s t a n c e o f   H t t p E r r o r )   { 
 
               c o n s o l e . e r r o r ( 
 
 -                 ` [ $ { 
 
 -                     n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
 -                 } ] [ $ { f u n c t i o n N a m e } ] :   R e q u e s t   h a n d l e r   e r r o r : ` , 
 
 -                 e r r o r . m e s s a g e , 
 
 +                 ` [ $ { n e w   D a t e ( ) . t o I S O S t r i n g ( ) } ] [ $ { f u n c t i o n N a m e } ]           H a n d l e d   E r r o r : ` , 
 
 +                 { 
 
 +                     m e s s a g e :   e r r o r . m e s s a g e , 
 
 +                     c o d e :   e r r o r . c o d e , 
 
 +                     i n t e r n a l D e t a i l s :   e r r o r . i n t e r n a l D e t a i l s   | |   " N / A " , 
 
 +                 } , 
 
               ) ; 
 
 + 
 
 +             / /   R E S P O N S E :   S o l o   e n v i a m o s   e l   m e n s a j e   l i m p i o   y   e l   c %%d i g o 
 
 +             r e t u r n   s e n d E r r o r ( e r r o r . s t a t u s ,   e r r o r . m e s s a g e ,   e r r o r . c o d e ) ; 
 
           } 
 
 -         c o n s t   m e s s a g e   =   e r r o r   i n s t a n c e o f   E r r o r   ?   e r r o r . m e s s a g e   :   S t r i n g ( e r r o r ) ; 
 
 -         r e t u r n   n e w   R e s p o n s e ( J S O N . s t r i n g i f y ( {   e r r o r :   m e s s a g e   } ) ,   { 
 
 -             h e a d e r s :   {   . . . c o r s H e a d e r s ,   " C o n t e n t - T y p e " :   " a p p l i c a t i o n / j s o n "   } , 
 
 -             s t a t u s :   4 0 0 , 
 
 -         } ) ; 
 
 + 
 
 +         / /   C A S O   B :   E r r o r   I n e s p e r a d o   ( C r a s h ,   B u g ,   S y n t a x   E r r o r ,   e t c . ) 
 
 +         / /   E l   u s u a r i o   N O   d e b e   v e r   e s t o . 
 
 +         c o n s t   u n e x p e c t e d E r r o r   =   e r r o r   i n s t a n c e o f   E r r o r 
 
 +             ?   e r r o r 
 
 +             :   n e w   E r r o r ( S t r i n g ( e r r o r ) ) ; 
 
 + 
 
 +         / /   L O G :   F u l l   s t a c k   t r a c e   y   m e n s a j e   r e a l 
 
 +         c o n s o l e . e r r o r ( 
 
 +             ` [ $ { 
 
 +                 n e w   D a t e ( ) . t o I S O S t r i n g ( ) 
 
 +             } ] [ $ { f u n c t i o n N a m e } ]        C R I T I C A L   U N H A N D L E D   E R R O R : ` , 
 
 +             u n e x p e c t e d E r r o r . s t a c k   | |   u n e x p e c t e d E r r o r . m e s s a g e ,   / /   E s t o   e s   l o   q u e   n e c e s i t a s   p a r a   d e b u g u e a r 
 
 +         ) ; 
 
 + 
 
 +         / /   R E S P O N S E :   M e n s a j e   g e n % r i c o   y   s e g u r o 
 
 +         r e t u r n   s e n d E r r o r ( 
 
 +             5 0 0 , 
 
 +             " O c u r r i %%  u n   e r r o r   i n e s p e r a d o   e n   e l   s e r v i d o r . " , 
 
 +             " I N T E R N A L _ S E R V E R _ E R R O R " , 
 
 +         ) ; 
 
       } 
 
   } ) ; 
 
   
 
 @ @   - 3 2 4 , 1 0   + 4 2 7 , 7   @ @   c o n s t   D a t o s B a s i c o s S c h e m a :   z . Z o d T y p e < A I G e n e r a t e P l a n I n p u t [ " d a t o s B a s i c o s " ] >   =   z 
 
       } ) ; 
 
   
 
   c o n s t   I A C o n f i g S c h e m a :   z . Z o d T y p e < A I G e n e r a t e P l a n I n p u t [ " i a C o n f i g " ] >   =   z . o b j e c t ( { 
 
 -     d e s c r i p c i o n E n f o q u e A c a d e m i c o :   z . s t r i n g ( ) . m i n ( 
 
 -         1 0 , 
 
 -         " L a   d e s c r i p c i %%n   e s   m u y   c o r t a " , 
 
 -     ) , 
 
 +     d e s c r i p c i o n E n f o q u e A c a d e m i c o :   z . s t r i n g ( ) , 
 
       i n s t r u c c i o n e s A d i c i o n a l e s I A :   z . s t r i n g ( ) . o p t i o n a l ( ) , 
 
       a r c h i v o s R e f e r e n c i a :   z . a r r a y ( z . s t r i n g ( ) . u u i d ( ) ) . o p t i o n a l ( ) , 
 
       r e p o s i t o r i o s I d s :   z . a r r a y ( z . s t r i n g ( ) . u u i d ( ) ) . o p t i o n a l ( ) , 
 
 d i f f   - - g i t   a / s u p a b a s e / f u n c t i o n s / t e s t s / a i - s t r u c t u r e d - t e s t . t s   b / s u p a b a s e / f u n c t i o n s / t e s t s / a i - s t r u c t u r e d - t e s t . t s 
 
 i n d e x   5 a 5 2 e 1 e . . 0 1 4 5 f 7 d   1 0 0 6 4 4 
 
 - - -   a / s u p a b a s e / f u n c t i o n s / t e s t s / a i - s t r u c t u r e d - t e s t . t s 
 
 + + +   b / s u p a b a s e / f u n c t i o n s / t e s t s / a i - s t r u c t u r e d - t e s t . t s 
 
 @ @   - 2 5 , 9   + 2 5 , 6   @ @   f u n c t i o n   m u s t E n v ( )   { 
 
       i f   ( ! S U P A B A S E _ A N O N _ K E Y )   t h r o w   n e w   E r r o r ( " S U P A B A S E _ A N O N _ K E Y   i s   r e q u i r e d " ) ; 
 
   } 
 
   
 
 - a s y n c   f u n c t i o n   g e t A u t h e d C l i e n t ( ) :   P r o m i s e < 
 
 -     {   c l i e n t :   S u p a b a s e C l i e n t ;   a c c e s s T o k e n :   s t r i n g   } 
 
 - >   { 
 
   a s y n c   f u n c t i o n   g e t A u t h e d C l i e n t ( ) :   P r o m i s e < 
 
       {   c l i e n t :   S u p a b a s e C l i e n t ;   a c c e s s T o k e n :   s t r i n g   } 
 
   >   { 
 
 