From 0571675fcd42568fc7abbeea76a86c48847b8dda Mon Sep 17 00:00:00 2001 From: Florent Vilmart <364568+flovilmart@users.noreply.github.com> Date: Thu, 9 Aug 2018 16:20:13 -0400 Subject: [PATCH] version 3.0.0 API Docs (#4943) * Adds documentation and docs generation upon merge * nits --- .gitignore | 4 + .travis.yml | 9 +- README.md | 2 +- jsdoc-conf.json | 23 ++++ package-lock.json | 135 +++++++++++++++++++++ package.json | 4 + release_docs.sh | 29 +++++ src/cloud-code/HTTPResponse.js | 10 +- src/cloud-code/Parse.Cloud.js | 215 +++++++++++++++++++++++++++++++++ src/cloud-code/httpRequest.js | 37 ++++++ 10 files changed, 465 insertions(+), 3 deletions(-) create mode 100644 jsdoc-conf.json create mode 100755 release_docs.sh diff --git a/.gitignore b/.gitignore index 4e4ee21c..b7d6200e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,10 @@ lib-cov coverage .nyc_output +# docs output +out +docs + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt diff --git a/.travis.yml b/.travis.yml index 3c6cb081..1c097a4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,8 +61,15 @@ jobs: env: before_script: skip after_script: skip - script: skip + script: + - ./release_docs.sh deploy: + - provider: pages + skip_cleanup: true + github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard + local_dir: docs/ + on: + all_branches: true - provider: npm skip_cleanup: true email: diff --git a/README.md b/README.md index 9b2d69e2..4c2be506 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Parse Server logo](.github/parse-server-logo.png?raw=true) +![Parse Server logo](https://github.com/parse-community/parse-server/raw/master/.github/parse-server-logo.png) [![Backers on Open Collective](https://opencollective.com/parse-server/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/parse-server/sponsors/badge.svg)](#sponsors) [![Build Status](https://img.shields.io/travis/parse-community/parse-server/master.svg?style=flat)](https://travis-ci.org/parse-community/parse-server) diff --git a/jsdoc-conf.json b/jsdoc-conf.json new file mode 100644 index 00000000..b6f6be01 --- /dev/null +++ b/jsdoc-conf.json @@ -0,0 +1,23 @@ +{ + "plugins": ["node_modules/jsdoc-babel", "plugins/markdown"], + "babel": { + "plugins": ["transform-flow-strip-types"] + }, + "source": { + "include": ["./README.md", "./src/cloud-code"], + "excludePattern": "(^|\\/|\\\\)_" + }, + "templates": { + "default": { + "outputSourceFiles": false + }, + "cleverLinks": false, + "monospaceLinks": false + }, + "opts": { + "recurse": true, + "template": "node_modules/minami", + "showInheritedInNav": false, + "useLongnameInNav": true + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index cc0e0890..f082213a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2580,6 +2580,15 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "catharsis": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.9.tgz", + "integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=", + "dev": true, + "requires": { + "underscore-contrib": "~0.3.0" + } + }, "caw": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/caw/-/caw-2.0.1.tgz", @@ -6275,12 +6284,74 @@ } } }, + "js2xmlparser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", + "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", + "dev": true, + "requires": { + "xmlcreate": "^1.0.1" + } + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "optional": true }, + "jsdoc": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", + "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", + "dev": true, + "requires": { + "babylon": "7.0.0-beta.19", + "bluebird": "~3.5.0", + "catharsis": "~0.8.9", + "escape-string-regexp": "~1.0.5", + "js2xmlparser": "~3.0.0", + "klaw": "~2.0.0", + "marked": "~0.3.6", + "mkdirp": "~0.5.1", + "requizzle": "~0.2.1", + "strip-json-comments": "~2.0.1", + "taffydb": "2.6.2", + "underscore": "~1.8.3" + }, + "dependencies": { + "babylon": { + "version": "7.0.0-beta.19", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", + "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", + "dev": true + }, + "klaw": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", + "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + } + } + }, + "jsdoc-babel": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/jsdoc-babel/-/jsdoc-babel-0.4.0.tgz", + "integrity": "sha512-KF3WTPvoPYc8ZyXzC1m+vvwi+2VCKkqZX/NkqcE1tFephp8RnZAxG52QB/wvz/zoDS6XU28aM8NItMPMad50PA==", + "dev": true, + "requires": { + "jsdoc-regex": "^1.0.1", + "lodash": "^4.13.1" + } + }, + "jsdoc-regex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/jsdoc-regex/-/jsdoc-regex-1.0.1.tgz", + "integrity": "sha1-hCRCjVtWOtjFx/vsB5uaiwnI3Po=", + "dev": true + }, "jsesc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", @@ -6671,6 +6742,12 @@ "object-visit": "1.0.1" } }, + "marked": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", + "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", + "dev": true + }, "math-random": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", @@ -6768,6 +6845,12 @@ "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=", "dev": true }, + "minami": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/minami/-/minami-1.2.3.tgz", + "integrity": "sha1-mbbc37LwpU2hycj3qjoyd4eq+fg=", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -10659,6 +10742,23 @@ "semver": "5.5.0" } }, + "requizzle": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", + "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", + "dev": true, + "requires": { + "underscore": "~1.6.0" + }, + "dependencies": { + "underscore": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", + "dev": true + } + } + }, "resolve-from": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", @@ -11413,6 +11513,12 @@ "connected-domain": "1.0.0" } }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", + "dev": true + }, "tar-stream": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.1.tgz", @@ -11726,6 +11832,29 @@ } } }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", + "dev": true + }, + "underscore-contrib": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", + "integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=", + "dev": true, + "requires": { + "underscore": "1.6.0" + }, + "dependencies": { + "underscore": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", + "dev": true + } + } + }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", @@ -12161,6 +12290,12 @@ "lodash": "4.17.5" } }, + "xmlcreate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", + "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", + "dev": true + }, "xmlhttprequest": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", diff --git a/package.json b/package.json index f96b0f4e..fe8fd614 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,9 @@ "gaze": "1.1.3", "jasmine": "3.1.0", "jasmine-spec-reporter": "^4.1.0", + "jsdoc": "^3.5.5", + "jsdoc-babel": "^0.4.0", + "minami": "^1.2.3", "mongodb-runner": "4.0.0", "nodemon": "1.18.3", "nyc": "^12.0.2", @@ -67,6 +70,7 @@ "supports-color": "^5.4.0" }, "scripts": { + "docs": "jsdoc -c ./jsdoc-conf.json", "dev": "npm run build && node bin/dev", "lint": "flow && eslint --cache ./", "build": "babel src/ -d lib/ --copy-files", diff --git a/release_docs.sh b/release_docs.sh new file mode 100755 index 00000000..845af3c7 --- /dev/null +++ b/release_docs.sh @@ -0,0 +1,29 @@ +#!/bin/sh -e +set -x +if [ "${TRAVIS_REPO_SLUG}" = "" ]; +then + echo "Cannot release docs without TRAVIS_REPO_SLUG set" + exit 0; +fi +REPO="https://github.com/${TRAVIS_REPO_SLUG}" + +rm -rf docs +git clone -b gh-pages --single-branch $REPO ./docs +cd docs +git pull origin gh-pages +cd .. + +DEST="master" + +if [ "${TRAVIS_TAG}" != "" ]; +then + DEST="${TRAVIS_TAG}" + # change the default page to the latest + echo "" > "docs/api/index.html" +fi + +npm run docs + +rm -rf docs/api/* +mkdir -p "docs/api/${DEST}" +cp -R out/* "docs/api/${DEST}" diff --git a/src/cloud-code/HTTPResponse.js b/src/cloud-code/HTTPResponse.js index 85613c87..aadabb1d 100644 --- a/src/cloud-code/HTTPResponse.js +++ b/src/cloud-code/HTTPResponse.js @@ -1,4 +1,12 @@ - +/** + * @typedef Parse.Cloud.HTTPResponse + * @property {Buffer} buffer The raw byte representation of the response body. Use this to receive binary data. See Buffer for more details. + * @property {Object} cookies The cookies sent by the server. The keys in this object are the names of the cookies. The values are Parse.Cloud.Cookie objects. + * @property {Object} data The parsed response body as a JavaScript object. This is only available when the response Content-Type is application/x-www-form-urlencoded or application/json. + * @property {Object} headers The headers sent by the server. The keys in this object are the names of the headers. We do not support multiple response headers with the same name. In the common case of Set-Cookie headers, please use the cookies field instead. + * @property {Number} status The status code. + * @property {String} text The raw text representation of the response body. + */ export default class HTTPResponse { constructor(response, body) { let _text, _data; diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index 7344f1d5..95281f82 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -8,40 +8,202 @@ function getClassName(parseClass) { return parseClass; } +/** @namespace + * @name Parse + * @description The Parse SDK. + * see [api docs](https://docs.parseplatform.org/js/api) and [guide](https://docs.parseplatform.org/js/guide) + */ + +/** @namespace + * @name Parse.Cloud + * @memberof Parse + * @description The Parse Cloud Code SDK. + */ + var ParseCloud = {}; +/** + * Defines a Cloud Function. + * + * **Available in Cloud Code only.** + + * @static + * @memberof Parse.Cloud + * @param {String} name The name of the Cloud Function + * @param {Function} data The Cloud Function to register. This function can be an async function and should take one parameter a {@link Parse.Cloud.FunctionRequest}. + */ ParseCloud.define = function(functionName, handler, validationHandler) { triggers.addFunction(functionName, handler, validationHandler, Parse.applicationId); }; +/** + * Defines a Background Job. + * + * **Available in Cloud Code only.** + * + * @method job + * @name Parse.Cloud.job + * @param {String} name The name of the Background Job + * @param {Function} func The Background Job to register. This function can be async should take a single parameters a {@link Parse.Cloud.JobRequest} + * + */ ParseCloud.job = function(functionName, handler) { triggers.addJob(functionName, handler, Parse.applicationId); }; +/** + * + * Registers a before save function. + * + * **Available in Cloud Code only.** + * + * If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * + * ``` + * Parse.Cloud.beforeSave('MyCustomClass', (request) => { + * // code here + * }) + * + * Parse.Cloud.beforeSave(Parse.User, (request) => { + * // code here + * }) + * ``` + * + * @method beforeSave + * @name Parse.Cloud.beforeSave + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run before a save. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; + */ ParseCloud.beforeSave = function(parseClass, handler) { var className = getClassName(parseClass); triggers.addTrigger(triggers.Types.beforeSave, className, handler, Parse.applicationId); }; +/** + * Registers a before delete function. + * + * **Available in Cloud Code only.** + * + * If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.beforeDelete('MyCustomClass', (request) => { + * // code here + * }) + * + * Parse.Cloud.beforeDelete(Parse.User, (request) => { + * // code here + * }) + *``` + * + * @method beforeDelete + * @name Parse.Cloud.beforeDelete + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run before a delete. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}. + */ ParseCloud.beforeDelete = function(parseClass, handler) { var className = getClassName(parseClass); triggers.addTrigger(triggers.Types.beforeDelete, className, handler, Parse.applicationId); }; +/** + * Registers an after save function. + * + * **Available in Cloud Code only.** + * + * If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * + * ``` + * Parse.Cloud.afterSave('MyCustomClass', async function(request) { + * // code here + * }) + * + * Parse.Cloud.afterSave(Parse.User, async function(request) { + * // code here + * }) + * ``` + * + * @method afterSave + * @name Parse.Cloud.afterSave + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run after a save. This function can be an async function and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + */ ParseCloud.afterSave = function(parseClass, handler) { var className = getClassName(parseClass); triggers.addTrigger(triggers.Types.afterSave, className, handler, Parse.applicationId); }; +/** + * Registers an after delete function. + * + * **Available in Cloud Code only.** + * + * If you want to use afterDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.afterDelete('MyCustomClass', async (request) => { + * // code here + * }) + * + * Parse.Cloud.afterDelete(Parse.User, async (request) => { + * // code here + * }) + *``` + * + * @method afterDelete + * @name Parse.Cloud.afterDelete + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run after a delete. This function can be async and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + */ ParseCloud.afterDelete = function(parseClass, handler) { var className = getClassName(parseClass); triggers.addTrigger(triggers.Types.afterDelete, className, handler, Parse.applicationId); }; +/** + * Registers a before find function. + * + * **Available in Cloud Code only.** + * + * If you want to use beforeFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.beforeFind('MyCustomClass', async (request) => { + * // code here + * }) + * + * Parse.Cloud.beforeFind(Parse.User, async (request) => { + * // code here + * }) + *``` + * + * @method beforeFind + * @name Parse.Cloud.beforeFind + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before find function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.BeforeFindRequest}. + */ ParseCloud.beforeFind = function(parseClass, handler) { var className = getClassName(parseClass); triggers.addTrigger(triggers.Types.beforeFind, className, handler, Parse.applicationId); }; +/** + * Registers an after find function. + * + * **Available in Cloud Code only.** + * + * If you want to use afterFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.afterFind('MyCustomClass', async (request) => { + * // code here + * }) + * + * Parse.Cloud.afterFind(Parse.User, async (request) => { + * // code here + * }) + *``` + * + * @method afterFind + * @name Parse.Cloud.afterFind + * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after find function for. This can instead be a String that is the className of the subclass. + * @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.AfterFindRequest}. + */ ParseCloud.afterFind = function(parseClass, handler) { const className = getClassName(parseClass); triggers.addTrigger(triggers.Types.afterFind, className, handler, Parse.applicationId); @@ -63,3 +225,56 @@ ParseCloud.useMasterKey = () => { ParseCloud.httpRequest = require("./httpRequest"); module.exports = ParseCloud; + +/** + * @typedef Parse.Cloud.TriggerRequest + * @property {String} installationId If set, the installationId triggering the request. + * @property {Boolean} master If true, means the master key was used. + * @property {Parse.User} user If set, the user that made the request. + * @property {Parse.Object} object The object triggering the hook. + * @property {String} ip The IP address of the client making the request. + * @property {Object} headers The original HTTP headers for the request. + * @property {String} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) + * @property {Object} log The current logger inside Parse Server. + * @property {Parse.Object} original If set, the object, as currently stored. + */ + +/** + * @typedef Parse.Cloud.BeforeFindRequest + * @property {String} installationId If set, the installationId triggering the request. + * @property {Boolean} master If true, means the master key was used. + * @property {Parse.User} user If set, the user that made the request. + * @property {Parse.Query} query The query triggering the hook. + * @property {String} ip The IP address of the client making the request. + * @property {Object} headers The original HTTP headers for the request. + * @property {String} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) + * @property {Object} log The current logger inside Parse Server. + * @property {Boolean} isGet wether the query a `get` or a `find` + */ + +/** + * @typedef Parse.Cloud.AfterFindRequest + * @property {String} installationId If set, the installationId triggering the request. + * @property {Boolean} master If true, means the master key was used. + * @property {Parse.User} user If set, the user that made the request. + * @property {Parse.Query} query The query triggering the hook. + * @property {Array} results The results the query yielded. + * @property {String} ip The IP address of the client making the request. + * @property {Object} headers The original HTTP headers for the request. + * @property {String} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) + * @property {Object} log The current logger inside Parse Server. + */ + +/** + * @typedef Parse.Cloud.FunctionRequest + * @property {String} installationId If set, the installationId triggering the request. + * @property {Boolean} master If true, means the master key was used. + * @property {Parse.User} user If set, the user that made the request. + * @property {Object} params The params passed to the cloud function. + */ + +/** + * @typedef Parse.Cloud.JobRequest + * @property {Object} params The params passed to the background job. + * @property {function} message If message is called with a string argument, will update the current message to be stored in the job status. + */ diff --git a/src/cloud-code/httpRequest.js b/src/cloud-code/httpRequest.js index 5fd8eae7..35bfc3fe 100644 --- a/src/cloud-code/httpRequest.js +++ b/src/cloud-code/httpRequest.js @@ -33,6 +33,31 @@ var encodeBody = function({body, headers = {}}) { return {body, headers}; } +/** + * Makes an HTTP Request. + * + * **Available in Cloud Code only.** + * + * By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the {@link Parse.Cloud.HTTPOptions} object to change this behavior. + * + * Sample request: + * ``` + * Parse.Cloud.httpRequest({ + * url: 'http://www.parse.com/' + * }).then(function(httpResponse) { + * // success + * console.log(httpResponse.text); + * },function(httpResponse) { + * // error + * console.error('Request failed with response code ' + httpResponse.status); + * }); + * ``` + * + * @method httpRequest + * @name Parse.Cloud.httpRequest + * @param {Parse.Cloud.HTTPOptions} options The Parse.Cloud.HTTPOptions object that makes the request. + * @return {Promise} A promise that will be resolved with a {@link Parse.Cloud.HTTPResponse} object when the request completes. + */ module.exports = function(options) { var callbacks = { success: options.success, @@ -78,4 +103,16 @@ module.exports = function(options) { }); }; +/** + * @typedef Parse.Cloud.HTTPOptions + * @property {String|Object} body The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. + * @property {function} error The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object. + * @property {Boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false. + * @property {Object} headers The headers for the request. + * @property {String} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified. + * @property {String|Object} params The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott. + * @property {function} success The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object. + * @property {string} url The url to send the request to. + */ + module.exports.encodeBody = encodeBody;