import { createAskSdkError } from 'ask-sdk-core' ; import { RequestEnvelope } from 'ask-sdk-model' ; /**
 * Type definition of function used by  S3PersistenceAdapter to extract attributes id from  RequestEnvelope .
  export type ObjectKeyGenerator = ( requestEnvelope : RequestEnvelope ) => string ; /**
 * Object containing implementations of  ObjectKeyGenerator .
  export const ObjectKeyGenerators = { param { RequestEnvelope } requestEnvelope returns { string } userId ( requestEnvelope ) { if ( ! ( requestEnvelope && requestEnvelope . context && requestEnvelope . context . System && requestEnvelope . context . System . user && requestEnvelope . context . System . user . userId ) ) { throw createAskSdkError ( 'PartitionKeyGenerators' , 'Cannot retrieve user id from request envelope!' ) ; } return requestEnvelope . context . System . user . userId ; } , param { RequestEnvelope } requestEnvelope returns { string } deviceId ( requestEnvelope ) { if ( ! ( requestEnvelope && requestEnvelope . context && requestEnvelope . context . System && requestEnvelope . context . System . device && requestEnvelope . context . System . device . deviceId ) ) { throw createAskSdkError ( 'PartitionKeyGenerators' , 'Cannot retrieve device id from request envelope!' ) ; } return requestEnvelope . context . System . device . deviceId ; } , } ;