import { DeliveryClient , IDeliveryClientConfig , PropertyNameResolver } from '../../../lib' ; import { Context } from './context' ; const defaultProjectId = 'da5abe9f-fdad-4168-97cd-b3464be2ccb9' ; const defaultPreviewApiKey = 'ew0KICAiYWxnIjogIkhTMjU2IiwNCiAgInR5cCI6ICJKV1QiDQp9.ew0KICAidWlkIjogInVzcl8wdlFZQkNxQXZybm81cmlmSG5pWUVHIiwNCiAgImVtYWlsIjogInJpY2hhcmRzQGtlbnRpY28uY29tIiwNCiAgInByb2plY3RfaWQiOiAiZGE1YWJlOWYtZmRhZC00MTY4LTk3Y2QtYjM0NjRiZTJjY2I5IiwNCiAgImp0aSI6ICJpLXNFVWJlNmZPeUtBQmJOIiwNCiAgInZlciI6ICIxLjAuMCIsDQogICJnaXZlbl9uYW1lIjogIlJpY2hhcmQiLA0KICAiZmFtaWx5X25hbWUiOiAiU3VzdGVrIiwNCiAgImF1ZCI6ICJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSINCn0.jSq0owesXGAGf8l7e0Ue7wPkP28MT_--ZK5T02sO7yw' ; const defaultSecuredApiKey = 'securedApiKey' ; export const defaultPropertyNameResolver = ( type , element ) => { if ( type === 'actor' ) { if ( element === 'first_name' ) { return 'firstName' ; } if ( element === 'last_name' ) { return 'lastName' ; } } if ( type === 'movie' ) { if ( element === 'releasecategory' ) { return 'releaseCategory' ; } } return element ; } ; export function setup ( context ) { let projectId = defaultProjectId ; let previewApiKey = defaultPreviewApiKey ; let securedApiKey = defaultSecuredApiKey ; let propertyNameResolver = defaultPropertyNameResolver ; if ( context . projectId ) { projectId = context . projectId ; } if ( context . previewApiKey ) { previewApiKey = context . previewApiKey ; } if ( context . securedApiKey ) { securedApiKey = context . securedApiKey ; } if ( context . propertyNameResolver ) { propertyNameResolver = context . propertyNameResolver ; } const deliveryClientConfig = { projectId : projectId , propertyNameResolver : propertyNameResolver , secureApiKey : securedApiKey , previewApiKey : previewApiKey , defaultQueryConfig : context . defaultQueryConfig , defaultLanguage : context . defaultLanguage , proxy : { baseUrl : context . baseUrl , basePreviewUrl : context . basePreviewUrl , } , retryStrategy : context . retryStrategy , globalHeaders : context . globalHeaders , } ; context . projectId = projectId ; context . previewApiKey = previewApiKey ; context . propertyNameResolver = propertyNameResolver ; context . securedApiKey = securedApiKey ; context . deliveryClient = new DeliveryClient ( deliveryClientConfig ) ; }