@@ -10,6 +10,37 @@ import db from "../db.js";
1010import { S3 } from "../s3.js" ;
1111import { getRepoDetails } from "../github.js" ;
1212
13+ function _trimSize ( value ) {
14+ // we dont want huge metadata in the registry
15+ if ( value . metadata [ 'package-i18n' ] ) {
16+ delete value . metadata [ 'package-i18n' ] ;
17+ }
18+
19+ // Trim title and description to less than 1k characters
20+ if ( typeof value . metadata . title === 'string' ) {
21+ value . metadata . title = value . metadata . title . slice ( 0 , 64 ) ;
22+ }
23+ if ( typeof value . metadata . description === 'string' ) {
24+ value . metadata . description = value . metadata . description . slice ( 0 , 256 ) ;
25+ }
26+
27+ // Limit each keyword string to max 256 characters
28+ if ( Array . isArray ( value . metadata . keywords ) ) {
29+ value . metadata . keywords = value . metadata . keywords . map ( keyword =>
30+ typeof keyword === 'string' ? keyword . slice ( 0 , 48 ) : keyword
31+ ) ;
32+ }
33+
34+ // Handle metadata.author field
35+ if ( value . metadata . author ) {
36+ if ( typeof value . metadata . author === 'string' ) {
37+ value . metadata . author = value . metadata . author . slice ( 0 , 256 ) ;
38+ } else if ( typeof value . metadata . author . name === 'string' ) {
39+ value . metadata . author . name = value . metadata . author . name . slice ( 0 , 256 ) ;
40+ }
41+ }
42+ }
43+
1344export async function syncRegistryDBToS3JSON ( ) {
1445 console . log ( "syncing non synced extension data in db to s3 extension.json" ) ;
1546 let pending = await db . query ( EXTENSIONS_DETAILS_TABLE , "$.syncPending='Y'" ) ;
@@ -29,6 +60,7 @@ export async function syncRegistryDBToS3JSON() {
2960 let newDoc = structuredClone ( document ) ;
3061 delete newDoc . documentId ;
3162 delete newDoc . syncPending ;
63+ _trimSize ( newDoc ) ;
3264 console . log ( "Updating Registry entry with[existing, new]: " , registry [ newDoc . metadata . name ] , newDoc ) ;
3365 registry [ newDoc . metadata . name ] = newDoc ;
3466 popularity [ newDoc . metadata . name ] = {
0 commit comments