all files / dist/satellites/ params.js

96.23% Statements 51/53
64.29% Branches 9/14
100% Functions 12/12
100% Lines 36/36
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142                  18×                                                                                               36×         162×   171×     171× 153×                                                                                      
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
var _utils = require('../utils');
 
var _utils2 = _interopRequireDefault(_utils);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
/**
 * Manage the application secure params.
 */
 
var Params = function () {
 
  /**
   * Create a new instance of this class.
   *
   * @param api API reference.
   */
 
 
  /**
   * Special params we will always accept.
   *
   * @type {string[]}
   */
 
  function Params(api) {
    _classCallCheck(this, Params);
 
    this.api = null;
    this.globalSafeParams = ['file', 'apiVersion', 'callback', 'action'];
    this.api = api;
  }
 
  /**
   * Build the hash map with all safe application params.
   *
   * @returns {*}
   */
 
 
  /**
   * List with all save params.
   */
 
 
  /**
   * API reference object
   *
   * @type {null}
   */
 
 
  _createClass(Params, [{
    key: 'buildPostVariables',
    value: function buildPostVariables() {
      var self = this;
 
      var i = void 0,
          j = void 0;
      var postVariables = [];
 
      // push the global safe params for the 'postVariables'
      self.globalSafeParams.forEach(function (p) {
        return postVariables.push(p);
      });
 
      // iterate all actions files
      for (i in self.api.actions.actions) {
        // iterate all actions definitions
        for (j in self.api.actions.actions[i]) {
          // get current action
          var action = self.api.actions.actions[i][j];
 
          // iterate all inputs keys and add it to postVariables
          for (var key in action.inputs) {
            postVariables.push(key);
          }
        }
      }
 
      // remove the duplicated entries
      self.postVariables = _utils2.default.arrayUniqueify(postVariables);
 
      return self.postVariables;
    }
  }]);
 
  return Params;
}();
 
var _class = function () {
  function _class() {
    _classCallCheck(this, _class);
 
    this.loadPriority = 420;
  }
 
  /**
   * Initializer load priority.
   *
   * @type {number}
   */
 
 
  _createClass(_class, [{
    key: 'load',
 
 
    /**
     * Action to the executed on the initializer loading.
     *
     * @param api   Api reference.
     * @param next  Callback function.
     */
    value: function load(api, next) {
      // put the params API available to all platform
      api.params = new Params(api);
 
      // build the post variables
      api.params.buildPostVariables();
 
      // finish the initializer execution
      next();
    }
  }]);
 
  return _class;
}();
 
exports.default = _class;
//# sourceMappingURL=params.js.map