text: import _ from 'lodash'
  
  const getEntity = (config, template_id) => {
    if(_.isPlainObject(config)) {
      if(config.id === template_id) return config
      return Object.values(config).reduce((found, value) => {
        if(found) return found
        return getEntity(value, template_id)
      }, null)
    }
    if(_.isArray(config)) {
      return config.reduce((found, value) => {
        if(found) return found
        return getEntity(value, template_id)
      }, null)
    }
    return null
  }
  
  export const contract = async(req, { value }) => {
    return {
      template_id: value.template_id
    }
  }
  
  export const expand = async (req, { value, template }) => {
    const entity = getEntity(template, value.template_id)
    return {
      template_id: value.template_id,
      ...entity
    } || {}
  }
  