<commit_before>/*
 * Copyright 2017-present, Converse.AI
 * All rights reserved.
 *
 * This source code is licensed under the license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

module.exports = (function() {


  class Payload {

    /**
    * Sets the error for the payload.
    * @param {Object} Error object for the response.
    * @param {Number} Error.httpStatus The HTTP status code for the response.
    * @param {String} Error.code The programmable error code for the response.
    * @param {String} Error.description The human readable error code for the response.
    * @public
    */
    setError({httpStatus, code, description}) {
      this.error = {
        httpStatus: httpStatus,
        code: code,
        description: description
      };
    }
  }

  class RegistrationDataPayload extends Payload {
    constructor(registrationData) {
      super();
      this.registrationData = registrationData
    }

    /**
    * Sets the registrationData for the payload.
    * @param {Object} registrationData The registration data for the plugin registration.
    * @public
    */
    setRegistrationData(registrationData) {
      this.registrationData = registrationData;
    }
  }

  class ModulePayload extends Payload {
    constructor() {
      super();
    }

    /**
    * Sets the comment for the payload.
    * @param {String[]} comment The comment array for the module response.
    * @public
    */
    setComment(comment) {
      this.comment = comment;
    }

    /**
    * Sets the value for the payload.
    * @param {Object} value The value of the module that shoulde be returned on the response.
    * @public
    */
    setValue(value) {
      this.value = value;
    }
  }

  class ExternalFunctionPayload extends Payload {
    constructor() {
      super();
      this.externalCallReturn = {};
    }

    /**
    * Sets the HTTP status to return.
    * @param {Number} httpStatus The http status number. E.g 200.
    * @public
    */
    setHTTPStatus(httpStatus && body !== null) {
      if (httpStatus !== undefined) {
        this.externalCallReturn = this.externalCallReturn || {};
        this.externalCallReturn.httpStatus = httpStatus;
      }
    }

    /**
    * Sets the HTTP body to return.
    * @param {Object} body The http body.
    * @public
    */
    setBody(body) {
      if (body !== undefined && body !== null) {
        this.externalCallReturn = this.externalCallReturn || {};

        if (typeof body === 'string') {
          this.externalCallReturn.body = body;<commit_msg>Ensuring that external responses cannot include undefined or null data.<commit_after>/*
 * Copyright 2017-present, Converse.AI
 * All rights reserved.
 *
 * This source code is licensed under the license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

module.exports = (function() {


  class Payload {

    /**
    * Sets the error for the payload.
    * @param {Object} Error object for the response.
    * @param {Number} Error.httpStatus The HTTP status code for the response.
    * @param {String} Error.code The programmable error code for the response.
    * @param {String} Error.description The human readable error code for the response.
    * @public
    */
    setError({httpStatus, code, description}) {
      this.error = {
        httpStatus: httpStatus,
        code: code,
        description: description
      };
    }
  }

  class RegistrationDataPayload extends Payload {
    constructor(registrationData) {
      super();
      this.registrationData = registrationData
    }

    /**
    * Sets the registrationData for the payload.
    * @param {Object} registrationData The registration data for the plugin registration.
    * @public
    */
    setRegistrationData(registrationData) {
      this.registrationData = registrationData;
    }
  }

  class ModulePayload extends Payload {
    constructor() {
      super();
    }

    /**
    * Sets the comment for the payload.
    * @param {String[]} comment The comment array for the module response.
    * @public
    */
    setComment(comment) {
      this.comment = comment;
    }

    /**
    * Sets the value for the payload.
    * @param {Object} value The value of the module that shoulde be returned on the response.
    * @public
    */
    setValue(value) {
      this.value = value;
    }
  }

  class ExternalFunctionPayload extends Payload {
    constructor() {
      super();
      this.externalCallReturn = {};
    }

    /**
    * Sets the HTTP status to return.
    * @param {Number} httpStatus The http status number. E.g 200.
    * @public
    */
    setHTTPStatus(httpStatus) {
      if (httpStatus !== undefined && body !== null) {
        this.externalCallReturn = this.externalCallReturn || {};
        this.externalCallReturn.httpStatus = httpStatus;
      }
    }

    /**
    * Sets the HTTP body to return.
    * @param {Object} body The http body.
    * @public
    */
    setBody(body) {
      if (body !== undefined && body !== null) {
        this.externalCallReturn = this.externalCallReturn || {};

        if (typeof body === 'string') {
          this.externalCallReturn.body = body;
{'fraction_non_alphanumeric': 0.10273708558211257, 'fraction_numerical': 0.0026985350809560524, 'mean_word_length': 2.4341495698213103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '296848', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1380, 'n_words': 461}