"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.run = run;
exports.getJobsData = getJobsData;
exports.startJob = startJob;
exports.getJobStatus = getJobStatus;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
var _decode = _interopRequireDefault(require("./decode"));
var _encode = _interopRequireDefault(require("./encode"));
var _ParseError = _interopRequireDefault(require("./ParseError"));
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
/**
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
/**
* Contains functions for calling and declaring
* cloud functions.
*
* Some functions are only available from Cloud Code.
*
*
* @class Parse.Cloud
* @static
* @hideconstructor
*/
/**
* Makes a call to a cloud function.
* @method run
* @name Parse.Cloud.run
* @param {String} name The function name.
* @param {Object} data The parameters to send to the cloud function.
* @param {Object} options
* @return {Promise} A promise that will be resolved with the result
* of the function.
*/
function run(name
/*: string*/
, data
/*: mixed*/
, options
/*: RequestOptions*/
)
/*: Promise*/
{
options = options || {};
if (typeof name !== 'string' || name.length === 0) {
throw new TypeError('Cloud function name must be a string.');
}
var requestOptions = {};
if (options.useMasterKey) {
requestOptions.useMasterKey = options.useMasterKey;
}
if (options.sessionToken) {
requestOptions.sessionToken = options.sessionToken;
}
return _CoreManager.default.getCloudController().run(name, data, requestOptions);
}
/**
* Gets data for the current set of cloud jobs.
* @method getJobsData
* @name Parse.Cloud.getJobsData
* @return {Promise} A promise that will be resolved with the result
* of the function.
*/
function getJobsData()
/*: Promise