All files / src/server/metadata metadata.interactions.js

100% Statements 26/26
55% Branches 11/20
100% Functions 1/1
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58        5x 5x   56x 47x     9x     9x 9x     9x 9x     9x 9x     9x 9x     9x 9x     9x 9x     9x 9x     9x 9x     9x 9x       9x   9x     5x  
/**
 * Generate a list of interactions a particular profile can support
 * keep a local copy of interactions so this does not need to happen each time
 */
let profileInteractions = {};
let generateInteractions = (service, resourceType) => {
  // return from cache if it exists
  if (profileInteractions[resourceType]) {
    return profileInteractions[resourceType];
  }
 
  let interactions = [];
 
  // Test for the existence of a service method
  Eif (service.search) {
    interactions.push({ code: 'search-type' });
  }
 
  Eif (service.searchById) {
    interactions.push({ code: 'read' });
  }
 
  Eif (service.searchByVersionId) {
    interactions.push({ code: 'vread' });
  }
 
  Eif (service.create) {
    interactions.push({ code: 'create' });
  }
 
  Eif (service.update) {
    interactions.push({ code: 'update' });
  }
 
  Eif (service.remove) {
    interactions.push({ code: 'delete' });
  }
 
  Eif (service.history) {
    interactions.push({ code: 'history-type' });
  }
 
  Eif (service.historyById) {
    interactions.push({ code: 'history-instance' });
  }
 
  Eif (service.expandById) {
    interactions.push({ code: 'expand' });
  }
 
  // Save these interactions so we don't need to do this again
  profileInteractions[resourceType] = interactions;
 
  return interactions;
};
 
module.exports = generateInteractions;