2021-11-07 17:17:48 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								import  ScriptUtils  from  "./ScriptUtils" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  readFileSync ,  writeFileSync  }  from  "fs" 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  JsonSchema  }  from  "../UI/Studio/jsonSchema" 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function  WalkScheme < T > ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    onEach :  ( schemePart : JsonSchema ,  path : string [ ] )  = >  T , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    scheme : JsonSchema , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fullScheme : JsonSchema  &  {  definitions? : any  }  =  undefined , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    path : string [ ]  =  [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    isHandlingReference  =  [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    required : string [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) :  {  path : string [ ] ;  required : boolean ;  t : T  } [ ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  results :  {  path : string [ ] ;  required : boolean ;  t : T  } [ ]  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( scheme  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-17 01:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( scheme [ "$ref" ]  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  ref  =  scheme [ "$ref" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  prefix  =  "#/definitions/" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! ref . startsWith ( prefix ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            throw  "References is not relative!" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  definitionName  =  ref . substr ( prefix . length ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( isHandlingReference . indexOf ( definitionName )  >=  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-09 15:15:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  loadedScheme  =  fullScheme . definitions [ definitionName ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  WalkScheme ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            onEach , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            loadedScheme , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            fullScheme , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            path , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            [ . . . isHandlingReference ,  definitionName ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            required 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fullScheme  =  fullScheme  ? ?  scheme 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  t  =  onEach ( scheme ,  path ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( t  !==  undefined )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  isRequired  =  required ? . indexOf ( path . at ( - 1 ) )  >=  0 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        results . push ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            path , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            required : isRequired , 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            t , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    function  walk ( v : JsonSchema )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( v  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        results . push ( . . . WalkScheme ( onEach ,  v ,  fullScheme ,  path ,  isHandlingReference ,  v . required ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    function  walkEach ( scheme : JsonSchema [ ] )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( scheme  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-17 01:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        scheme . forEach ( ( v )  = >  walk ( v ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        walkEach ( scheme . enum ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        walkEach ( scheme . anyOf ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-17 01:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        walkEach ( scheme . allOf ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( Array . isArray ( scheme . items ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            walkEach ( < any > scheme . items ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            walk ( < any > scheme . items ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( const  key  in  scheme . properties )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  prop  =  scheme . properties [ key ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            results . push ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                . . . WalkScheme ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    onEach , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    prop , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    fullScheme , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    [ . . . path ,  key ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    isHandlingReference , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    scheme . required 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-31 00:39:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  results 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  addMetafields ( fieldnames : string [ ] ,  fullSchema : JsonSchema )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  onEach  =  ( schemePart ,  path )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( schemePart . description  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  type  =  schemePart . items ? . anyOf  ? ?  schemePart . type  ? ?  schemePart . anyOf 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  hints  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  description  =  schemePart . description . split ( "\n" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( const  fieldname  of  fieldnames )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  hintIndex  =  description . findIndex ( ( line )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                line 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    . trim ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    . toLocaleLowerCase ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    . startsWith ( fieldname  +  ":" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( hintIndex  <  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  hintLine  =  description [ hintIndex ] . substring ( ( fieldname  +  ":" ) . length ) . trim ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            description . splice ( hintIndex ,  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( fieldname  ===  "type" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                hints [ "typehint" ]  =  hintLine 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                hints [ fieldname ]  =  hintLine 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( hints [ "types" ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  numberOfExpectedSubtypes  =  hints [ "types" ] . split ( ";" ) . length 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( ! Array . isArray ( type ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                throw  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    "At "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    path . join ( "." )  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    "Invalid hint in the documentation: `types` indicates that there are "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    numberOfExpectedSubtypes  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    " subtypes, but object does not support subtypes. Did you mean `type` instead?\n\tTypes are: "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    hints [ "types" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  numberOfActualTypes  =  type . length 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( numberOfActualTypes  !==  numberOfExpectedSubtypes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                throw  ` At  ${ path . join ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    "." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ) } \ nInvalid  hint  in  the  documentation :  \ ` types \`  indicates that there are  ${ numberOfExpectedSubtypes }  subtypes, but there are  ${ numberOfActualTypes }  subtypes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								\ tTypes  are : $ { hints [ "types" ] } ` 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  {  hints ,  type ,  description : description.join ( "\n" )  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  WalkScheme ( onEach ,  fullSchema ,  fullSchema ,  [ ] ,  [ ] ,  fullSchema . required ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function  extractMeta ( typename : string ,  path : string )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  themeSchema : JsonSchema  =  JSON . parse ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        readFileSync ( "./Docs/Schemas/"  +  typename  +  ".schema.json" ,  {  encoding :  "utf8"  } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  metainfo  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        type :  "One of the inputValidator types" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        types :  "Is multiple types are allowed for this field, then first show a mapping to pick the appropriate subtype. `Types` should be `;`-separated and contain precisely the same amount of subtypes" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        group :  "A kind of label. Items with the same group name will be placed in the same region" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 17:13:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        default :  "The default value which is used if no value is specified" , 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        question :  "The question to ask in the tagRenderingConfig" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ifunset : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            "Only applicable if _not_ a required item. This will appear in the 'not set'-option as extra description" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        inline :  "A text, containing `{value}`. This will be used as freeform rendering and will be included into the rendering" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  metakeys  =  Array . from ( Object . keys ( metainfo ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  hints  =  addMetafields ( metakeys ,  themeSchema ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 00:44:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  paths  =  hints . map ( ( {  path ,  required ,  t  } )  = >  ( {  path ,  required ,  . . . t  } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    writeFileSync ( "./assets/"  +  path  +  ".json" ,  JSON . stringify ( paths ,  null ,  "  " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    console . log ( "Written meta to ./assets/"  +  path ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 17:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  main() { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  allSchemas  =  ScriptUtils . readDirRecSync ( "./Docs/Schemas" ) . filter ( ( pth )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        pth . endsWith ( "JSC.ts" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 17:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( const  path  of  allSchemas )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  dir  =  path . substring ( 0 ,  path . lastIndexOf ( "/" ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  name  =  path . substring ( path . lastIndexOf ( "/" ) ,  path . length  -  "JSC.ts" . length ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 23:28:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  content  =  readFileSync ( path ,  {  encoding :  "utf8"  } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 17:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        content  =  content . substring ( "export default " . length ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  parsed  =  JSON . parse ( content ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        parsed [ "additionalProperties" ]  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( const  key  in  parsed . definitions )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  def  =  parsed . definitions [ key ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( def . type  ===  "object" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                def [ "additionalProperties" ]  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 17:45:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        writeFileSync ( dir  +  "/"  +  name  +  ".schema.json" ,  JSON . stringify ( parsed ,  null ,  "  " ) ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            encoding :  "utf8" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 17:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 02:36:11 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    extractMeta ( "LayerConfigJson" ,  "layerconfigmeta" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-09 22:34:02 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    extractMeta ( "LayoutConfigJson" ,  "layoutconfigmeta" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    extractMeta ( "TagRenderingConfigJson" ,  "tagrenderingconfigmeta" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 17:17:38 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    extractMeta ( "QuestionableTagRenderingConfigJson" ,  "questionabletagrenderingconfigmeta" ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-07 17:52:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								main ( )