1- import { CIP_100 , CIP_108 , CIP_119 } from "@/consts" ;
2-
3- type StandardReference = typeof CIP_100 | typeof CIP_108 | typeof CIP_119 ;
4-
51type MetadataConfig = {
62 data : Record < string , unknown > ;
73 acceptedKeys : string [ ] ;
8- standardReference : StandardReference ;
94} ;
105
116/**
@@ -18,27 +13,25 @@ type MetadataConfig = {
1813export const generateMetadataBody = ( {
1914 data,
2015 acceptedKeys,
21- standardReference,
2216} : MetadataConfig ) => {
2317 const filteredData = Object . entries ( data )
24- . filter ( ( [ key ] ) => acceptedKeys . includes ( key ) )
25- . map ( ( [ key , value ] ) => [ standardReference + key , value ] ) ;
18+ . filter ( ( [ key , value ] ) => value && acceptedKeys . includes ( key ) )
19+ . map ( ( [ key , value ] ) => [ key , value ] ) ;
2620
2721 const references = data ?. references
2822 ? // uri should not be optional. It is just not yet supported on govtool
2923 ( data . references as Array < Partial < Reference > > )
3024 . filter ( ( link ) => link . uri )
3125 . map ( ( link ) => ( {
3226 "@type" : link [ "@type" ] ?? "Other" ,
33- [ ` ${ CIP_100 } reference- label` ] : link . label || "Label" ,
34- [ ` ${ CIP_100 } reference- uri` ] : link . uri ,
27+ label : link . label || "Label" ,
28+ uri : link . uri ,
3529 } ) )
3630 : undefined ;
3731
3832 const body = Object . fromEntries ( filteredData ) ;
39-
40- if ( references ) {
41- body [ `${ standardReference } references` ] = references ;
33+ if ( references ?. length ) {
34+ body . references = references ;
4235 }
4336
4437 return body ;
0 commit comments