const RulesetSchema = require ( "../../../../../Ruleset.schema.json" ) ; import { Ruleset } from "../../../presentation-common" ; type IndexedType = { [ key ] : any ; } | { [ key ] : any ; } ; const hasIndexSignature = ( obj ) : obj is IndexedType => { return typeof obj === "object" || Array . isArray ( obj ) ; } ; const fixEmptyStrings = ( obj ) => { for ( const key in obj ) { if ( ! obj . hasOwnProperty ( key ) ) continue ; const value = obj [ key ] ; if ( hasIndexSignature ( value ) ) { fixEmptyStrings ( value ) ; } else if ( typeof value === "string" ) { obj [ key ] = value . trim ( ) ; if ( obj [ key ] === "" ) obj [ key ] = "was empty string" ; } } } ; internal export const createRandomRuleset = async ( ) => { const jsf = require ( "json-schema-faker" ) ; jsf . option ( { optionalsProbability : 0.8 , maxItems : 5 , maxLength : 20 } ) ; const ruleset = jsf . generate ( RulesetSchema ) ; jsf . reset ( ) ; fixEmptyStrings ( ruleset ) ; return ruleset ; } ;