File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed 
libs/json-rpc/nestjs-json-rpc/src/lib/types Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 11import  {  z  }  from  'zod' ; 
22
3- const  literalSchema  =  z . union ( [ z . string ( ) ,  z . number ( ) ,  z . boolean ( ) ,  z . null ( ) ] ) ; 
4- type  Literal  =  z . infer < typeof  literalSchema > ; 
5- type  Json  =  Literal  |  {  [ key : string ] : Json  }  |  Json [ ] ; 
6- const  jsonSchema : z . ZodType < Json >  =  z . lazy ( ( )  => 
7-  z . union ( [ literalSchema ,  z . array ( jsonSchema ) ,  z . record ( jsonSchema ) ] ) 
8- ) ; 
9- 
103const  zParams  =  z . union ( [ 
114 z . string ( ) , 
125 z . number ( ) , 
136 z . boolean ( ) , 
147 z . null ( ) , 
15-  jsonSchema , 
8+  z . json ( ) , 
169] ) ; 
1710
1811export  const  zVersion  =  z . literal ( '2.0' ) ; 
1912const  zMethod  =  z . string ( ) . transform ( ( params ,  ctx )  =>  { 
2013 const  result  =  params . split ( '.' ) ; 
2114 if  ( result . length  !==  2 )  { 
2215 ctx . addIssue ( { 
23-  code : z . ZodIssueCode . custom , 
16+  code : ' custom' , 
2417 message : 'Not a 2 items' , 
2518 } ) ; 
2619 return  z . NEVER ; 
@@ -32,7 +25,7 @@ const zMethod = z.string().transform((params, ctx) => {
3225} ) ; 
3326
3427const  zRpcParams  =  z 
35-  . union ( [ z . array ( zParams ) ,  z . record ( zParams ) ] ) 
28+  . union ( [ z . array ( zParams ) ,  z . record ( z . string ( ) ,   zParams ) ] ) 
3629 . transform ( ( params )  => 
3730 Array . isArray ( params )  ? params  : Object . values ( params ) 
3831 ) ; 
                         You can’t perform that action at this time. 
           
                  
0 commit comments