diff --git a/.gitignore b/.gitignore index 6cadcfc65..b07d5b3c7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ integration/test_logs .DS_Store .idea/ integration/test_logs +out/ diff --git a/.travis.yml b/.travis.yml index 28561741c..fc6cec052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: node_js node_js: -- '5' +- '6.11.4' branches: only: diff --git a/jsdoc-conf.json b/jsdoc-conf.json new file mode 100644 index 000000000..b6ad74174 --- /dev/null +++ b/jsdoc-conf.json @@ -0,0 +1,20 @@ +{ + "plugins": ["node_modules/jsdoc-babel"], + "babel": { + "plugins": ["transform-flow-strip-types"] + }, + "source": { + "include": ["./package.json", "./README.md"], + "excludePattern": "(^|\\/|\\\\)_" + }, + "templates": { + "default": { + "outputSourceFiles": false + }, + "cleverLinks": false, + "monospaceLinks": false + }, + "opts": { + "recurse": true + } +} \ No newline at end of file diff --git a/package.json b/package.json index b83f6e76c..a1c5b5c81 100644 --- a/package.json +++ b/package.json @@ -53,12 +53,15 @@ "gulp-uglify": "^2.1.2", "jasmine-reporters": "~2.2.1", "jest-cli": "^19.0.2", + "jsdoc": "^3.5.5", + "jsdoc-babel": "^0.3.0", "vinyl-source-stream": "^1.1.0" }, "scripts": { "build": "./build_releases.sh", "release": "./build_releases.sh && npm publish", - "test": "PARSE_BUILD=node jest" + "test": "PARSE_BUILD=node jest", + "docs": "jsdoc -c ./jsdoc-conf.json ./src" }, "jest": { "automock": true, diff --git a/src/Analytics.js b/src/Analytics.js index f3a21e40a..ed7d04d39 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -19,6 +19,7 @@ import type ParsePromise from './ParsePromise'; * * @class Parse.Analytics * @static + * @hideconstructor */ /** @@ -44,6 +45,7 @@ import type ParsePromise from './ParsePromise'; * There is a default limit of 8 dimensions per event tracked. * * @method track + * @name Parse.Analytics.track * @param {String} name The name of the custom event to report to Parse as * having happened. * @param {Object} dimensions The dictionary of information by which to diff --git a/src/Cloud.js b/src/Cloud.js index f2dc1ffd5..74c91fa4c 100644 --- a/src/Cloud.js +++ b/src/Cloud.js @@ -24,11 +24,13 @@ import ParsePromise from './ParsePromise'; * * @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 A Backbone-style options object diff --git a/src/CoreManager.js b/src/CoreManager.js index 8dac29644..020a9b8ae 100644 --- a/src/CoreManager.js +++ b/src/CoreManager.js @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-present, Parse, LLC. * All rights reserved. * diff --git a/src/FacebookUtils.js b/src/FacebookUtils.js index 0fb3ce4ab..090650834 100644 --- a/src/FacebookUtils.js +++ b/src/FacebookUtils.js @@ -93,6 +93,7 @@ var provider = { * Provides a set of utilities for using Parse with Facebook. * @class Parse.FacebookUtils * @static + * @hideconstructor */ var FacebookUtils = { /** @@ -105,6 +106,7 @@ var FacebookUtils = { * with these arguments. * * @method init + * @name Parse.FacebookUtils.init * @param {Object} options Facebook options argument as described here: * @@ -141,6 +143,7 @@ var FacebookUtils = { * Gets whether the user has their account linked to Facebook. * * @method isLinked + * @name Parse.FacebookUtils.isLinked * @param {Parse.User} user User to check for a facebook link. * The user must be logged in on this device. * @return {Boolean} true if the user has their account @@ -156,13 +159,15 @@ var FacebookUtils = { * creates, in the case where it is a new user) a Parse.User. * * @method logIn - * @param {String, Object} permissions The permissions required for Facebook + * @name Parse.FacebookUtils.logIn + * @param {(String|Object)} permissions The permissions required for Facebook * log in. This is a comma-separated string of permissions. * Alternatively, supply a Facebook authData object as described in our * REST API docs if you want to handle getting facebook auth tokens * yourself. * @param {Object} options Standard options object with success and error * callbacks. + * @returns {Parse.Promise} */ logIn(permissions, options) { if (!permissions || typeof permissions === 'string') { @@ -191,15 +196,17 @@ var FacebookUtils = { * the account to the Parse.User. * * @method link + * @name Parse.FacebookUtils.link * @param {Parse.User} user User to link to Facebook. This must be the * current user. - * @param {String, Object} permissions The permissions required for Facebook + * @param {(String|Object)} permissions The permissions required for Facebook * log in. This is a comma-separated string of permissions. * Alternatively, supply a Facebook authData object as described in our * REST API docs if you want to handle getting facebook auth tokens * yourself. * @param {Object} options Standard options object with success and error * callbacks. + * @returns {Parse.Promise} */ link(user, permissions, options) { if (!permissions || typeof permissions === 'string') { @@ -226,10 +233,12 @@ var FacebookUtils = { * Unlinks the Parse.User from a Facebook account. * * @method unlink + * @name Parse.FacebookUtils.unlink * @param {Parse.User} user User to unlink from Facebook. This must be the * current user. * @param {Object} options Standard options object with success and error * callbacks. + * @returns {Parse.Promise} */ unlink: function(user, options) { if (!initialized) { diff --git a/src/LiveQueryClient.js b/src/LiveQueryClient.js index e6a43a273..292f03c37 100644 --- a/src/LiveQueryClient.js +++ b/src/LiveQueryClient.js @@ -78,16 +78,6 @@ let generateInterval = (k) => { * * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries * to connect to the LiveQuery server - * - * @class Parse.LiveQueryClient - * @constructor - * @param {Object} options - * @param {string} options.applicationId - applicationId of your Parse app - * @param {string} options.serverURL - the URL of your LiveQuery server - * @param {string} options.javascriptKey (optional) - * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!) - * @param {string} options.sessionToken (optional) - * * * We expose three events to help you monitor the status of the LiveQueryClient. * @@ -119,10 +109,9 @@ let generateInterval = (k) => { * client.on('error', (error) => { * * }); - * - * + * @alias Parse.LiveQueryClient */ -export default class LiveQueryClient extends EventEmitter { +class LiveQueryClient extends EventEmitter { attempts: number; id: number; requestId: number; @@ -136,6 +125,14 @@ export default class LiveQueryClient extends EventEmitter { socket: any; state: string; + /** + * @param {Object} options + * @param {string} options.applicationId - applicationId of your Parse app + * @param {string} options.serverURL - the URL of your LiveQuery server + * @param {string} options.javascriptKey (optional) + * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!) + * @param {string} options.sessionToken (optional) + */ constructor({ applicationId, serverURL, @@ -177,7 +174,6 @@ export default class LiveQueryClient extends EventEmitter { * here for more details. The subscription you get is the same subscription you get * from our Standard API. * - * @method subscribe * @param {Object} query - the ParseQuery you want to subscribe to * @param {string} sessionToken (optional) * @return {Object} subscription @@ -218,7 +214,6 @@ export default class LiveQueryClient extends EventEmitter { /** * After calling unsubscribe you'll stop receiving events from the subscription object. * - * @method unsubscribe * @param {Object} subscription - subscription you would like to unsubscribe from. */ unsubscribe(subscription: Object) { @@ -240,7 +235,6 @@ export default class LiveQueryClient extends EventEmitter { * After open is called, the LiveQueryClient will try to send a connect request * to the LiveQuery server. * - * @method open */ open() { let WebSocketImplementation = this._getWebSocketImplementation(); @@ -303,7 +297,6 @@ export default class LiveQueryClient extends EventEmitter { * This method will close the WebSocket connection to this LiveQueryClient, * cancel the auto reconnect and unsubscribe all subscriptions based on it. * - * @method close */ close() { if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) { @@ -448,3 +441,5 @@ export default class LiveQueryClient extends EventEmitter { }).bind(this), time); } } + +export default LiveQueryClient; diff --git a/src/LiveQuerySubscription.js b/src/LiveQuerySubscription.js index 1df90182e..71850926f 100644 --- a/src/LiveQuerySubscription.js +++ b/src/LiveQuerySubscription.js @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-present, Parse, LLC. * All rights reserved. * @@ -16,10 +16,6 @@ import CoreManager from './CoreManager'; * Extends events.EventEmitter * cloud functions. * - * @constructor - * @param {string} id - subscription id - * @param {string} query - query to subscribe to - * @param {string} sessionToken - optional session token * *

Open Event - When you call query.subscribe(), we send a subscribe request to * the LiveQuery server, when we get the confirmation from the LiveQuery server, @@ -88,9 +84,14 @@ import CoreManager from './CoreManager'; * * });

* - * + * @alias Parse.LiveQuerySubscription */ -export default class Subscription extends EventEmitter { +class Subscription extends EventEmitter { + /* + * @param {string} id - subscription id + * @param {string} query - query to subscribe to + * @param {string} sessionToken - optional session token + */ constructor(id, query, sessionToken) { super(); this.id = id; @@ -99,7 +100,7 @@ export default class Subscription extends EventEmitter { } /** - * @method unsubscribe + * closes the subscription */ unsubscribe() { let _this = this; @@ -110,3 +111,5 @@ export default class Subscription extends EventEmitter { }); } } + +export default Subscription; diff --git a/src/Parse.js b/src/Parse.js index 872f4ae19..d5bfb809e 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -16,14 +16,15 @@ import RESTController from './RESTController'; /** * Contains all Parse API classes and functions. - * @class Parse * @static + * @global + * @class + * @hideconstructor */ var Parse = { /** * Call this method first to set up your authentication tokens for Parse. * You can get your keys from the Data Browser on parse.com. - * @method initialize * @param {String} applicationId Your Parse Application ID. * @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) * @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) @@ -48,6 +49,11 @@ var Parse = { }; /** These legacy setters may eventually be deprecated **/ +/** + * @member Parse.applicationId + * @type string + * @static + */ Object.defineProperty(Parse, 'applicationId', { get() { return CoreManager.get('APPLICATION_ID'); @@ -56,6 +62,12 @@ Object.defineProperty(Parse, 'applicationId', { CoreManager.set('APPLICATION_ID', value); } }); + +/** + * @member Parse.javaScriptKey + * @type string + * @static + */ Object.defineProperty(Parse, 'javaScriptKey', { get() { return CoreManager.get('JAVASCRIPT_KEY'); @@ -64,6 +76,12 @@ Object.defineProperty(Parse, 'javaScriptKey', { CoreManager.set('JAVASCRIPT_KEY', value); } }); + +/** + * @member Parse.masterKey + * @type string + * @static + */ Object.defineProperty(Parse, 'masterKey', { get() { return CoreManager.get('MASTER_KEY'); @@ -72,6 +90,12 @@ Object.defineProperty(Parse, 'masterKey', { CoreManager.set('MASTER_KEY', value); } }); + +/** + * @member Parse.serverURL + * @type string + * @static + */ Object.defineProperty(Parse, 'serverURL', { get() { return CoreManager.get('SERVER_URL'); @@ -80,6 +104,11 @@ Object.defineProperty(Parse, 'serverURL', { CoreManager.set('SERVER_URL', value); } }); +/** + * @member Parse.liveQueryServerURL + * @type string + * @static + */ Object.defineProperty(Parse, 'liveQueryServerURL', { get() { return CoreManager.get('LIVEQUERY_SERVER_URL'); @@ -88,7 +117,7 @@ Object.defineProperty(Parse, 'liveQueryServerURL', { CoreManager.set('LIVEQUERY_SERVER_URL', value); } }); -/** End setters **/ +/* End setters */ Parse.ACL = require('./ParseACL').default; Parse.Analytics = require('./Analytics'); diff --git a/src/ParseACL.js b/src/ParseACL.js index ba944a6f6..4b63edbc3 100644 --- a/src/ParseACL.js +++ b/src/ParseACL.js @@ -24,16 +24,18 @@ var PUBLIC_KEY = '*'; * permission for only that user. * If the argument is any other JSON object, that object will be interpretted * as a serialized ACL created with toJSON(). - * @class Parse.ACL - * @constructor - * + * *

An ACL, or Access Control List can be added to any * Parse.Object to restrict access to only a subset of users * of your application.

+ * @alias Parse.ACL */ -export default class ParseACL { +class ParseACL { permissionsById: ByIdMap; + /** + * @param {(Parse.User|Object)} user The user to initialize the ACL for + */ constructor(arg1: ParseUser | ByIdMap) { this.permissionsById = {}; if (arg1 && typeof arg1 === 'object') { @@ -74,7 +76,6 @@ export default class ParseACL { /** * Returns a JSON-encoded version of the ACL. - * @method toJSON * @return {Object} */ toJSON(): ByIdMap { @@ -87,7 +88,6 @@ export default class ParseACL { /** * Returns whether this ACL is equal to another object - * @method equals * @param other The other object to compare to * @return {Boolean} */ @@ -176,7 +176,6 @@ export default class ParseACL { /** * Sets whether the given user is allowed to read this object. - * @method setReadAccess * @param userId An instance of Parse.User or its objectId. * @param {Boolean} allowed Whether that user should have read access. */ @@ -189,7 +188,6 @@ export default class ParseACL { * Even if this returns false, the user may still be able to access it if * getPublicReadAccess returns true or a role that the user belongs to has * write access. - * @method getReadAccess * @param userId An instance of Parse.User or its objectId, or a Parse.Role. * @return {Boolean} */ @@ -199,7 +197,6 @@ export default class ParseACL { /** * Sets whether the given user id is allowed to write this object. - * @method setWriteAccess * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. * @param {Boolean} allowed Whether that user should have write access. */ @@ -212,7 +209,6 @@ export default class ParseACL { * Even if this returns false, the user may still be able to write it if * getPublicWriteAccess returns true or a role that the user belongs to has * write access. - * @method getWriteAccess * @param userId An instance of Parse.User or its objectId, or a Parse.Role. * @return {Boolean} */ @@ -222,7 +218,6 @@ export default class ParseACL { /** * Sets whether the public is allowed to read this object. - * @method setPublicReadAccess * @param {Boolean} allowed */ setPublicReadAccess(allowed: boolean) { @@ -231,7 +226,6 @@ export default class ParseACL { /** * Gets whether the public is allowed to read this object. - * @method getPublicReadAccess * @return {Boolean} */ getPublicReadAccess(): boolean { @@ -240,7 +234,6 @@ export default class ParseACL { /** * Sets whether the public is allowed to write this object. - * @method setPublicWriteAccess * @param {Boolean} allowed */ setPublicWriteAccess(allowed: boolean) { @@ -249,7 +242,6 @@ export default class ParseACL { /** * Gets whether the public is allowed to write this object. - * @method getPublicWriteAccess * @return {Boolean} */ getPublicWriteAccess(): boolean { @@ -261,7 +253,6 @@ export default class ParseACL { * to read this object. Even if this returns false, the role may * still be able to write it if a parent role has read access. * - * @method getRoleReadAccess * @param role The name of the role, or a Parse.Role object. * @return {Boolean} true if the role has read access. false otherwise. * @throws {TypeError} If role is neither a Parse.Role nor a String. @@ -284,7 +275,6 @@ export default class ParseACL { * to write this object. Even if this returns false, the role may * still be able to write it if a parent role has write access. * - * @method getRoleWriteAccess * @param role The name of the role, or a Parse.Role object. * @return {Boolean} true if the role has write access. false otherwise. * @throws {TypeError} If role is neither a Parse.Role nor a String. @@ -306,7 +296,6 @@ export default class ParseACL { * Sets whether users belonging to the given role are allowed * to read this object. * - * @method setRoleReadAccess * @param role The name of the role, or a Parse.Role object. * @param {Boolean} allowed Whether the given role can read this object. * @throws {TypeError} If role is neither a Parse.Role nor a String. @@ -328,7 +317,6 @@ export default class ParseACL { * Sets whether users belonging to the given role are allowed * to write this object. * - * @method setRoleWriteAccess * @param role The name of the role, or a Parse.Role object. * @param {Boolean} allowed Whether the given role can write this object. * @throws {TypeError} If role is neither a Parse.Role nor a String. @@ -346,3 +334,5 @@ export default class ParseACL { this.setWriteAccess('role:' + role, allowed); } } + +export default ParseACL; diff --git a/src/ParseConfig.js b/src/ParseConfig.js index 73ccabc67..bc9d7e3c7 100644 --- a/src/ParseConfig.js +++ b/src/ParseConfig.js @@ -21,11 +21,10 @@ import Storage from './Storage'; * Parse.Config is a local representation of configuration data that * can be set from the Parse dashboard. * - * @class Parse.Config - * @constructor + * @alias Parse.Config */ -export default class ParseConfig { +class ParseConfig { attributes: { [key: string]: any }; _escapedAttributes: { [key: string]: any }; @@ -36,7 +35,6 @@ export default class ParseConfig { /** * Gets the value of an attribute. - * @method get * @param {String} attr The name of an attribute. */ get(attr: string): any { @@ -45,7 +43,6 @@ export default class ParseConfig { /** * Gets the HTML-escaped value of an attribute. - * @method escape * @param {String} attr The name of an attribute. */ escape(attr: string): string { @@ -66,7 +63,6 @@ export default class ParseConfig { * Retrieves the most recently-fetched configuration object, either from * memory or from local storage if necessary. * - * @method current * @static * @return {Config} The most recently-fetched Parse.Config if it * exists, else an empty Parse.Config. @@ -78,7 +74,6 @@ export default class ParseConfig { /** * Gets a new configuration object from the server. - * @method get * @static * @param {Object} options A Backbone-style options object. * Valid options are: