From 7351cc125e7c418d18776667801d57f7fbe1692f Mon Sep 17 00:00:00 2001
From: Diamond Lewis
Date: Sun, 19 May 2024 19:35:53 -0500
Subject: [PATCH 1/2] refactor: Remove Flow Type
---
.eslintrc.json | 12 -
CONTRIBUTING.md | 1 -
babel-jest.js | 1 -
gulpfile.js | 8 +-
jsdoc-conf.json | 1 -
package-lock.json | 73 +--
package.json | 3 -
src/.flowconfig | 10 -
...{EventuallyQueue.js => EventuallyQueue.ts} | 32 +-
...oller.js => IndexedDBStorageController.ts} | 15 +-
...bscription.js => LiveQuerySubscription.ts} | 16 +-
src/Parse.ts | 6 +-
src/{ParseACL.js => ParseACL.ts} | 26 +-
src/ParseError.js | 551 -----------------
src/ParseError.ts | 556 ++++++++++++++++++
src/{ParseLiveQuery.js => ParseLiveQuery.ts} | 15 +-
src/ParseObject.ts | 8 +-
src/{ParseRelation.js => ParseRelation.ts} | 14 +-
...er.js => SingleInstanceStateController.ts} | 46 +-
...er.js => UniqueInstanceStateController.ts} | 12 +-
.../{AuthProvider.js => AuthProvider.ts} | 4 -
.../{react-native.js => react-native.ts} | 0
.../{xmlhttprequest.js => xmlhttprequest.ts} | 0
types/EventuallyQueue.d.ts | 93 +--
types/IndexedDBStorageController.d.ts | 2 +
types/LiveQuerySubscription.d.ts | 23 +-
types/ParseACL.d.ts | 20 +-
types/ParseError.d.ts | 531 ++++++++++++++---
types/ParseLiveQuery.d.ts | 22 +-
types/ParseObject.d.ts | 6 +-
types/ParseRelation.d.ts | 14 +-
types/SingleInstanceStateController.d.ts | 47 +-
types/UniqueInstanceStateController.d.ts | 43 +-
33 files changed, 1257 insertions(+), 954 deletions(-)
delete mode 100644 src/.flowconfig
rename src/{EventuallyQueue.js => EventuallyQueue.ts} (96%)
rename src/{IndexedDBStorageController.js => IndexedDBStorageController.ts} (74%)
rename src/{LiveQuerySubscription.js => LiveQuerySubscription.ts} (91%)
rename src/{ParseACL.js => ParseACL.ts} (94%)
delete mode 100644 src/ParseError.js
create mode 100644 src/ParseError.ts
rename src/{ParseLiveQuery.js => ParseLiveQuery.ts} (93%)
rename src/{ParseRelation.js => ParseRelation.ts} (95%)
rename src/{SingleInstanceStateController.js => SingleInstanceStateController.ts} (63%)
rename src/{UniqueInstanceStateController.js => UniqueInstanceStateController.ts} (94%)
rename src/interfaces/{AuthProvider.js => AuthProvider.ts} (98%)
rename src/interfaces/{react-native.js => react-native.ts} (100%)
rename src/interfaces/{xmlhttprequest.js => xmlhttprequest.ts} (100%)
create mode 100644 types/IndexedDBStorageController.d.ts
diff --git a/.eslintrc.json b/.eslintrc.json
index 757b9a816..997cae317 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -3,7 +3,6 @@
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended",
- "plugin:flowtype/recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
@@ -15,7 +14,6 @@
"wx": true
},
"plugins": [
- "flowtype",
"jsdoc",
"@typescript-eslint"
],
@@ -46,7 +44,6 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
- "flowtype/no-types-missing-file-annotation": 0,
"jsdoc/require-jsdoc": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/require-param-description": 0,
@@ -59,15 +56,6 @@
"allowExtraTrailingParamDocs": true
}
],
- "jsdoc/check-tag-names": [
- "error",
- {
- "definedTags": [
- "flow",
- "flow-weak"
- ]
- }
- ],
"jsdoc/no-undefined-types": [
"error",
{
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d36f5f600..e2035ca1b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -98,7 +98,6 @@ Parse Community has a [responsible Vulnerability Disclosure Program](https://git
## Coding Style
* Most importantly, match the existing code style as much as possible.
-* We use [Flow](http://flowtype.org/) and ES6 for this codebase. Use modern syntax whenever possible.
* Keep lines within 80 characters.
* Always end lines with semicolons.
diff --git a/babel-jest.js b/babel-jest.js
index e17601e2a..9249b1a05 100644
--- a/babel-jest.js
+++ b/babel-jest.js
@@ -8,5 +8,4 @@ module.exports = babelJest.createTransformer({
useBuiltIns: 'entry',
corejs: 3,
}]],
- plugins: ['@babel/plugin-transform-flow-comments'],
});
diff --git a/gulpfile.js b/gulpfile.js
index 90a4f9d93..667562399 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -32,12 +32,12 @@ const PRESETS = {
'react-native': ["@babel/preset-typescript", 'module:metro-react-native-babel-preset'],
};
const PLUGINS = {
- 'browser': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
+ 'browser': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
- 'weapp': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
+ 'weapp': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
- 'node': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables'],
- 'react-native': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables']
+ 'node': ['inline-package-json', 'transform-inline-environment-variables'],
+ 'react-native': ['inline-package-json', 'transform-inline-environment-variables']
};
const DEV_HEADER = (
diff --git a/jsdoc-conf.json b/jsdoc-conf.json
index 107f9e9a8..f351f6f5e 100644
--- a/jsdoc-conf.json
+++ b/jsdoc-conf.json
@@ -3,7 +3,6 @@
"babel": {
"babelrc": false,
"extensions": ["js", "ts", "jsx", "tsx"],
- "plugins": ["@babel/plugin-transform-flow-comments"],
"presets": ["@babel/preset-typescript"]
},
"source": {
diff --git a/package-lock.json b/package-lock.json
index 349c6838d..9e12c786e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,14 +13,12 @@
"idb-keyval": "6.2.1",
"react-native-crypto-js": "1.0.0",
"uuid": "9.0.1",
- "ws": "^8.17.0",
+ "ws": "8.17.0",
"xmlhttprequest": "1.8.0"
},
"devDependencies": {
"@babel/core": "7.22.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
- "@babel/plugin-transform-flow-comments": "7.22.5",
- "@babel/plugin-transform-flow-strip-types": "7.21.0",
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.5",
"@babel/preset-react": "7.22.5",
@@ -44,7 +42,6 @@
"core-js": "3.30.2",
"cross-env": "7.0.2",
"eslint": "8.56.0",
- "eslint-plugin-flowtype": "8.0.3",
"eslint-plugin-jsdoc": "48.2.5",
"express": "4.18.2",
"gulp": "4.0.2",
@@ -1725,23 +1722,6 @@
"@babel/core": "^7.0.0-0"
}
},
- "node_modules/@babel/plugin-transform-flow-comments": {
- "version": "7.22.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-comments/-/plugin-transform-flow-comments-7.22.5.tgz",
- "integrity": "sha512-e2lp78CXh9N2Xu0BKVibzLooLNkr1pGrSuigKBDFefibKnEuBW1uTWZVbJm7ptteOekftR27Afupm7nB74rs6w==",
- "dev": true,
- "dependencies": {
- "@babel/generator": "^7.22.5",
- "@babel/helper-plugin-utils": "^7.22.5",
- "@babel/plugin-syntax-flow": "^7.22.5"
- },
- "engines": {
- "node": ">=6.9.0"
- },
- "peerDependencies": {
- "@babel/core": "^7.0.0-0"
- }
- },
"node_modules/@babel/plugin-transform-flow-strip-types": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.21.0.tgz",
@@ -11293,24 +11273,6 @@
"url": "https://opencollective.com/eslint"
}
},
- "node_modules/eslint-plugin-flowtype": {
- "version": "8.0.3",
- "resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-8.0.3.tgz",
- "integrity": "sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==",
- "dev": true,
- "dependencies": {
- "lodash": "^4.17.21",
- "string-natural-compare": "^3.0.1"
- },
- "engines": {
- "node": ">=12.0.0"
- },
- "peerDependencies": {
- "@babel/plugin-syntax-flow": "^7.14.5",
- "@babel/plugin-transform-react-jsx": "^7.14.9",
- "eslint": "^8.1.0"
- }
- },
"node_modules/eslint-plugin-jsdoc": {
"version": "48.2.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.2.5.tgz",
@@ -27766,12 +27728,6 @@
"node": ">=10"
}
},
- "node_modules/string-natural-compare": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz",
- "integrity": "sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==",
- "dev": true
- },
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
@@ -31246,17 +31202,6 @@
"@babel/helper-plugin-utils": "^7.18.6"
}
},
- "@babel/plugin-transform-flow-comments": {
- "version": "7.22.5",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-comments/-/plugin-transform-flow-comments-7.22.5.tgz",
- "integrity": "sha512-e2lp78CXh9N2Xu0BKVibzLooLNkr1pGrSuigKBDFefibKnEuBW1uTWZVbJm7ptteOekftR27Afupm7nB74rs6w==",
- "dev": true,
- "requires": {
- "@babel/generator": "^7.22.5",
- "@babel/helper-plugin-utils": "^7.22.5",
- "@babel/plugin-syntax-flow": "^7.22.5"
- }
- },
"@babel/plugin-transform-flow-strip-types": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.21.0.tgz",
@@ -39027,16 +38972,6 @@
}
}
},
- "eslint-plugin-flowtype": {
- "version": "8.0.3",
- "resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-8.0.3.tgz",
- "integrity": "sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==",
- "dev": true,
- "requires": {
- "lodash": "^4.17.21",
- "string-natural-compare": "^3.0.1"
- }
- },
"eslint-plugin-jsdoc": {
"version": "48.2.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-48.2.5.tgz",
@@ -51426,12 +51361,6 @@
"strip-ansi": "^6.0.0"
}
},
- "string-natural-compare": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz",
- "integrity": "sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==",
- "dev": true
- },
"string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
diff --git a/package.json b/package.json
index 87cad67d9..40ac1e465 100644
--- a/package.json
+++ b/package.json
@@ -39,8 +39,6 @@
"devDependencies": {
"@babel/core": "7.22.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
- "@babel/plugin-transform-flow-comments": "7.22.5",
- "@babel/plugin-transform-flow-strip-types": "7.21.0",
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.5",
"@babel/preset-react": "7.22.5",
@@ -64,7 +62,6 @@
"core-js": "3.30.2",
"cross-env": "7.0.2",
"eslint": "8.56.0",
- "eslint-plugin-flowtype": "8.0.3",
"eslint-plugin-jsdoc": "48.2.5",
"express": "4.18.2",
"gulp": "4.0.2",
diff --git a/src/.flowconfig b/src/.flowconfig
deleted file mode 100644
index e36f40442..000000000
--- a/src/.flowconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-[ignore]
-.*/node_modules/
-.*/lib/
-
-[include]
-
-[libs]
-
-[options]
-suppress_comment= \\(.\\|\n\\)*\\@flow-disable-next
diff --git a/src/EventuallyQueue.js b/src/EventuallyQueue.ts
similarity index 96%
rename from src/EventuallyQueue.js
rename to src/EventuallyQueue.ts
index f4b59ffb5..a4cdb0ed8 100644
--- a/src/EventuallyQueue.js
+++ b/src/EventuallyQueue.ts
@@ -1,9 +1,3 @@
-/**
- * https://github.com/francimedia/parse-js-local-storage
- *
- * @flow
- */
-
import CoreManager from './CoreManager';
import ParseError from './ParseError';
import ParseObject from './ParseObject';
@@ -27,9 +21,9 @@ type QueueObject = {
type Queue = Array;
const QUEUE_KEY = 'Parse/Eventually/Queue';
-let queueCache = [];
+let queueCache: QueueObject[] = [];
let dirtyCache = true;
-let polling = undefined;
+let polling: ReturnType | undefined = undefined;
/**
* Provides utility functions to queue objects that will be
@@ -50,7 +44,7 @@ const EventuallyQueue = {
* @static
* @see Parse.Object#saveEventually
*/
- save(object: ParseObject, serverOptions: SaveOptions = {}): Promise {
+ save(object: ParseObject, serverOptions: SaveOptions = {}): Promise {
return this.enqueue('save', object, serverOptions);
},
@@ -65,7 +59,7 @@ const EventuallyQueue = {
* @static
* @see Parse.Object#destroyEventually
*/
- destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise {
+ destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise {
return this.enqueue('destroy', object, serverOptions);
},
@@ -99,7 +93,7 @@ const EventuallyQueue = {
action: string,
object: ParseObject,
serverOptions: SaveOptions | RequestOptions
- ): Promise {
+ ): Promise {
const queueData = await this.getQueue();
const queueId = this.generateQueueId(action, object);
@@ -127,7 +121,7 @@ const EventuallyQueue = {
return this.setQueue(queueData);
},
- store(data) {
+ store(data: QueueObject[]) {
return Storage.setItemAsync(QUEUE_KEY, JSON.stringify(data));
},
@@ -140,10 +134,10 @@ const EventuallyQueue = {
*
* @function getQueue
* @name Parse.EventuallyQueue.getQueue
- * @returns {Promise}
+ * @returns {Promise}
* @static
*/
- async getQueue(): Promise {
+ async getQueue(): Promise {
if (dirtyCache) {
queueCache = JSON.parse((await this.load()) || '[]');
dirtyCache = false;
@@ -189,7 +183,7 @@ const EventuallyQueue = {
* @returns {Promise} A promise that is fulfilled when queue is cleared.
* @static
*/
- clear(): Promise {
+ clear(): Promise {
queueCache = [];
return this.store([]);
},
@@ -212,10 +206,10 @@ const EventuallyQueue = {
*
* @function length
* @name Parse.EventuallyQueue.length
- * @returns {number}
+ * @returns {Promise}
* @static
*/
- async length(): number {
+ async length(): Promise {
const queueData = await this.getQueue();
return queueData.length;
},
@@ -268,7 +262,7 @@ const EventuallyQueue = {
// Queued update was overwritten by other request. Do not save
if (
typeof object.updatedAt !== 'undefined' &&
- object.updatedAt > new Date(queueObject.object.createdAt)
+ object.updatedAt > new Date(queueObject.object.createdAt as Date)
) {
return this.remove(queueObject.queueId);
}
@@ -345,7 +339,7 @@ const EventuallyQueue = {
},
_setPolling(flag: boolean) {
- polling = flag;
+ polling = flag as any;
},
process: {
diff --git a/src/IndexedDBStorageController.js b/src/IndexedDBStorageController.ts
similarity index 74%
rename from src/IndexedDBStorageController.js
rename to src/IndexedDBStorageController.ts
index da2d2e973..30a6726f6 100644
--- a/src/IndexedDBStorageController.js
+++ b/src/IndexedDBStorageController.ts
@@ -1,15 +1,14 @@
-/**
- * @flow
- */
/* global window */
import { createStore, del, set, get, clear, keys } from 'idb-keyval';
+let IndexedDBStorageController: any;
+
if (typeof window !== 'undefined' && window.indexedDB) {
try {
const ParseStore = createStore('parseDB', 'parseStore');
- const IndexedDBStorageController = {
+ IndexedDBStorageController = {
async: 1,
getItemAsync(path: string) {
return get(path, ParseStore);
@@ -27,13 +26,13 @@ if (typeof window !== 'undefined' && window.indexedDB) {
return clear(ParseStore);
},
};
-
- module.exports = IndexedDBStorageController;
} catch (_) {
// IndexedDB not accessible
- module.exports = undefined;
+ IndexedDBStorageController = undefined;
}
} else {
// IndexedDB not supported
- module.exports = undefined;
+ IndexedDBStorageController = undefined;
}
+module.exports = IndexedDBStorageController;
+export default IndexedDBStorageController;
diff --git a/src/LiveQuerySubscription.js b/src/LiveQuerySubscription.ts
similarity index 91%
rename from src/LiveQuerySubscription.js
rename to src/LiveQuerySubscription.ts
index 8a1368eb8..6b4c8a0c1 100644
--- a/src/LiveQuerySubscription.js
+++ b/src/LiveQuerySubscription.ts
@@ -1,5 +1,6 @@
import CoreManager from './CoreManager';
import { resolvingPromise } from './promiseUtils';
+import type ParseQuery from './ParseQuery';
/**
* Creates a new LiveQuery Subscription.
@@ -84,12 +85,21 @@ import { resolvingPromise } from './promiseUtils';
* });
*/
class Subscription {
+ id: string | number;
+ query: ParseQuery;
+ sessionToken?: string;
+ subscribePromise: any;
+ unsubscribePromise: any;
+ subscribed: boolean;
+ emitter: any;
+ on: any;
+ emit: any;
/*
- * @param {string} id - subscription id
+ * @param {string | number} id - subscription id
* @param {string} query - query to subscribe to
* @param {string} sessionToken - optional session token
*/
- constructor(id, query, sessionToken) {
+ constructor(id: string | number, query: ParseQuery, sessionToken?: string) {
this.id = id;
this.query = query;
this.sessionToken = sessionToken;
@@ -111,7 +121,7 @@ class Subscription {
*
* @returns {Promise}
*/
- unsubscribe(): Promise {
+ unsubscribe(): Promise {
return CoreManager.getLiveQueryController()
.getDefaultLiveQueryClient()
.then(liveQueryClient => {
diff --git a/src/Parse.ts b/src/Parse.ts
index 142c3fe04..1ff3cce27 100644
--- a/src/Parse.ts
+++ b/src/Parse.ts
@@ -159,11 +159,11 @@ const Parse: ParseType = {
* @member {EventuallyQueue} Parse.EventuallyQueue
* @static
*/
- set EventuallyQueue(queue: EventuallyQueue) {
+ set EventuallyQueue(queue: typeof EventuallyQueue) {
CoreManager.setEventuallyQueue(queue);
},
- get EventuallyQueue() {
+ get EventuallyQueue(): any {
return CoreManager.getEventuallyQueue();
},
@@ -316,7 +316,7 @@ const Parse: ParseType = {
* @member {ParseLiveQuery} Parse.LiveQuery
* @static
*/
- set LiveQuery(liveQuery: ParseLiveQuery) {
+ set LiveQuery(liveQuery: typeof ParseLiveQuery) {
CoreManager.setLiveQuery(liveQuery);
},
get LiveQuery() {
diff --git a/src/ParseACL.js b/src/ParseACL.ts
similarity index 94%
rename from src/ParseACL.js
rename to src/ParseACL.ts
index 42f9ffb25..aab488941 100644
--- a/src/ParseACL.js
+++ b/src/ParseACL.ts
@@ -1,7 +1,3 @@
-/**
- * @flow
- */
-
import CoreManager from './CoreManager';
import type ParseRole from './ParseRole';
import type ParseUser from './ParseUser';
@@ -36,8 +32,8 @@ class ParseACL {
if (arg1 && typeof arg1 === 'object') {
const ParseUser = CoreManager.getParseUser();
if (arg1 instanceof ParseUser) {
- this.setReadAccess(arg1, true);
- this.setWriteAccess(arg1, true);
+ this.setReadAccess(arg1 as ParseUser, true);
+ this.setWriteAccess(arg1 as ParseUser, true);
} else {
for (const userId in arg1) {
const accessList = arg1[userId];
@@ -105,9 +101,9 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
const ParseUser = CoreManager.getParseUser();
if (userId instanceof ParseUser) {
- userId = userId.id;
+ userId = (userId as ParseUser).id!;
} else if (userId instanceof ParseRole) {
- const name = userId.getName();
+ const name = (userId as ParseRole).getName();
if (!name) {
throw new TypeError('Role must have a name');
}
@@ -144,18 +140,18 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
const ParseUser = CoreManager.getParseUser();
if (userId instanceof ParseUser) {
- userId = userId.id;
+ userId = (userId as ParseUser).id!;
if (!userId) {
throw new Error('Cannot get access for a ParseUser without an ID');
}
} else if (userId instanceof ParseRole) {
- const name = userId.getName();
+ const name = (userId as ParseRole).getName();
if (!name) {
throw new TypeError('Role must have a name');
}
userId = 'role:' + name;
}
- const permissions = this.permissionsById[userId];
+ const permissions = this.permissionsById[userId as string];
if (!permissions) {
return false;
}
@@ -257,7 +253,7 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
if (role instanceof ParseRole) {
// Normalize to the String name
- role = role.getName();
+ role = (role as ParseRole).getName()!;
}
if (typeof role !== 'string') {
throw new TypeError('role must be a ParseRole or a String');
@@ -278,7 +274,7 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
if (role instanceof ParseRole) {
// Normalize to the String name
- role = role.getName();
+ role = (role as ParseRole).getName()!;
}
if (typeof role !== 'string') {
throw new TypeError('role must be a ParseRole or a String');
@@ -298,7 +294,7 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
if (role instanceof ParseRole) {
// Normalize to the String name
- role = role.getName();
+ role = (role as ParseRole).getName()!;
}
if (typeof role !== 'string') {
throw new TypeError('role must be a ParseRole or a String');
@@ -318,7 +314,7 @@ class ParseACL {
const ParseRole = CoreManager.getParseRole();
if (role instanceof ParseRole) {
// Normalize to the String name
- role = role.getName();
+ role = (role as ParseRole).getName()!;
}
if (typeof role !== 'string') {
throw new TypeError('role must be a ParseRole or a String');
diff --git a/src/ParseError.js b/src/ParseError.js
deleted file mode 100644
index c98227477..000000000
--- a/src/ParseError.js
+++ /dev/null
@@ -1,551 +0,0 @@
-import CoreManager from './CoreManager';
-
-/**
- * Constructs a new Parse.Error object with the given code and message.
- *
- * Parse.CoreManager.set('PARSE_ERRORS', [{ code, message }]) can be use to override error messages.
- *
- * @alias Parse.Error
- */
-class ParseError extends Error {
- /**
- * @param {number} code An error code constant from Parse.Error
.
- * @param {string} message A detailed description of the error.
- */
- constructor(code, message) {
- super(message);
- this.code = code;
- let customMessage = message;
- CoreManager.get('PARSE_ERRORS').forEach(error => {
- if (error.code === code && error.code) {
- customMessage = error.message;
- }
- });
- Object.defineProperty(this, 'message', {
- enumerable: true,
- value: customMessage,
- });
- }
-
- toString() {
- return 'ParseError: ' + this.code + ' ' + this.message;
- }
-}
-
-/**
- * Error code indicating some error other than those enumerated here.
- *
- * @property {number} OTHER_CAUSE
- * @static
- */
-ParseError.OTHER_CAUSE = -1;
-
-/**
- * Error code indicating that something has gone wrong with the server.
- *
- * @property {number} INTERNAL_SERVER_ERROR
- * @static
- */
-ParseError.INTERNAL_SERVER_ERROR = 1;
-
-/**
- * Error code indicating the connection to the Parse servers failed.
- *
- * @property {number} CONNECTION_FAILED
- * @static
- */
-ParseError.CONNECTION_FAILED = 100;
-
-/**
- * Error code indicating the specified object doesn't exist.
- *
- * @property {number} OBJECT_NOT_FOUND
- * @static
- */
-ParseError.OBJECT_NOT_FOUND = 101;
-
-/**
- * Error code indicating you tried to query with a datatype that doesn't
- * support it, like exact matching an array or object.
- *
- * @property {number} INVALID_QUERY
- * @static
- */
-ParseError.INVALID_QUERY = 102;
-
-/**
- * Error code indicating a missing or invalid classname. Classnames are
- * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
- * only valid characters.
- *
- * @property {number} INVALID_CLASS_NAME
- * @static
- */
-ParseError.INVALID_CLASS_NAME = 103;
-
-/**
- * Error code indicating an unspecified object id.
- *
- * @property {number} MISSING_OBJECT_ID
- * @static
- */
-ParseError.MISSING_OBJECT_ID = 104;
-
-/**
- * Error code indicating an invalid key name. Keys are case-sensitive. They
- * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
- *
- * @property {number} INVALID_KEY_NAME
- * @static
- */
-ParseError.INVALID_KEY_NAME = 105;
-
-/**
- * Error code indicating a malformed pointer. You should not see this unless
- * you have been mucking about changing internal Parse code.
- *
- * @property {number} INVALID_POINTER
- * @static
- */
-ParseError.INVALID_POINTER = 106;
-
-/**
- * Error code indicating that badly formed JSON was received upstream. This
- * either indicates you have done something unusual with modifying how
- * things encode to JSON, or the network is failing badly.
- *
- * @property {number} INVALID_JSON
- * @static
- */
-ParseError.INVALID_JSON = 107;
-
-/**
- * Error code indicating that the feature you tried to access is only
- * available internally for testing purposes.
- *
- * @property {number} COMMAND_UNAVAILABLE
- * @static
- */
-ParseError.COMMAND_UNAVAILABLE = 108;
-
-/**
- * You must call Parse.initialize before using the Parse library.
- *
- * @property {number} NOT_INITIALIZED
- * @static
- */
-ParseError.NOT_INITIALIZED = 109;
-
-/**
- * Error code indicating that a field was set to an inconsistent type.
- *
- * @property {number} INCORRECT_TYPE
- * @static
- */
-ParseError.INCORRECT_TYPE = 111;
-
-/**
- * Error code indicating an invalid channel name. A channel name is either
- * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
- * characters and starts with a letter.
- *
- * @property {number} INVALID_CHANNEL_NAME
- * @static
- */
-ParseError.INVALID_CHANNEL_NAME = 112;
-
-/**
- * Error code indicating that push is misconfigured.
- *
- * @property {number} PUSH_MISCONFIGURED
- * @static
- */
-ParseError.PUSH_MISCONFIGURED = 115;
-
-/**
- * Error code indicating that the object is too large.
- *
- * @property {number} OBJECT_TOO_LARGE
- * @static
- */
-ParseError.OBJECT_TOO_LARGE = 116;
-
-/**
- * Error code indicating that the operation isn't allowed for clients.
- *
- * @property {number} OPERATION_FORBIDDEN
- * @static
- */
-ParseError.OPERATION_FORBIDDEN = 119;
-
-/**
- * Error code indicating the result was not found in the cache.
- *
- * @property {number} CACHE_MISS
- * @static
- */
-ParseError.CACHE_MISS = 120;
-
-/**
- * Error code indicating that an invalid key was used in a nested
- * JSONObject.
- *
- * @property {number} INVALID_NESTED_KEY
- * @static
- */
-ParseError.INVALID_NESTED_KEY = 121;
-
-/**
- * Error code indicating that an invalid filename was used for ParseFile.
- * A valid file name contains only a-zA-Z0-9_. characters and is between 1
- * and 128 characters.
- *
- * @property {number} INVALID_FILE_NAME
- * @static
- */
-ParseError.INVALID_FILE_NAME = 122;
-
-/**
- * Error code indicating an invalid ACL was provided.
- *
- * @property {number} INVALID_ACL
- * @static
- */
-ParseError.INVALID_ACL = 123;
-
-/**
- * Error code indicating that the request timed out on the server. Typically
- * this indicates that the request is too expensive to run.
- *
- * @property {number} TIMEOUT
- * @static
- */
-ParseError.TIMEOUT = 124;
-
-/**
- * Error code indicating that the email address was invalid.
- *
- * @property {number} INVALID_EMAIL_ADDRESS
- * @static
- */
-ParseError.INVALID_EMAIL_ADDRESS = 125;
-
-/**
- * Error code indicating a missing content type.
- *
- * @property {number} MISSING_CONTENT_TYPE
- * @static
- */
-ParseError.MISSING_CONTENT_TYPE = 126;
-
-/**
- * Error code indicating a missing content length.
- *
- * @property {number} MISSING_CONTENT_LENGTH
- * @static
- */
-ParseError.MISSING_CONTENT_LENGTH = 127;
-
-/**
- * Error code indicating an invalid content length.
- *
- * @property {number} INVALID_CONTENT_LENGTH
- * @static
- */
-ParseError.INVALID_CONTENT_LENGTH = 128;
-
-/**
- * Error code indicating a file that was too large.
- *
- * @property {number} FILE_TOO_LARGE
- * @static
- */
-ParseError.FILE_TOO_LARGE = 129;
-
-/**
- * Error code indicating an error saving a file.
- *
- * @property {number} FILE_SAVE_ERROR
- * @static
- */
-ParseError.FILE_SAVE_ERROR = 130;
-
-/**
- * Error code indicating that a unique field was given a value that is
- * already taken.
- *
- * @property {number} DUPLICATE_VALUE
- * @static
- */
-ParseError.DUPLICATE_VALUE = 137;
-
-/**
- * Error code indicating that a role's name is invalid.
- *
- * @property {number} INVALID_ROLE_NAME
- * @static
- */
-ParseError.INVALID_ROLE_NAME = 139;
-
-/**
- * Error code indicating that an application quota was exceeded. Upgrade to
- * resolve.
- *
- * @property {number} EXCEEDED_QUOTA
- * @static
- */
-ParseError.EXCEEDED_QUOTA = 140;
-
-/**
- * Error code indicating that a Cloud Code script failed.
- *
- * @property {number} SCRIPT_FAILED
- * @static
- */
-ParseError.SCRIPT_FAILED = 141;
-
-/**
- * Error code indicating that a Cloud Code validation failed.
- *
- * @property {number} VALIDATION_ERROR
- * @static
- */
-ParseError.VALIDATION_ERROR = 142;
-
-/**
- * Error code indicating that invalid image data was provided.
- *
- * @property {number} INVALID_IMAGE_DATA
- * @static
- */
-ParseError.INVALID_IMAGE_DATA = 143;
-
-/**
- * Error code indicating an unsaved file.
- *
- * @property {number} UNSAVED_FILE_ERROR
- * @static
- */
-ParseError.UNSAVED_FILE_ERROR = 151;
-
-/**
- * Error code indicating an invalid push time.
- *
- * @property {number} INVALID_PUSH_TIME_ERROR
- * @static
- */
-ParseError.INVALID_PUSH_TIME_ERROR = 152;
-
-/**
- * Error code indicating an error deleting a file.
- *
- * @property {number} FILE_DELETE_ERROR
- * @static
- */
-ParseError.FILE_DELETE_ERROR = 153;
-
-/**
- * Error code indicating an error deleting an unnamed file.
- *
- * @property {number} FILE_DELETE_UNNAMED_ERROR
- * @static
- */
-ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
-
-/**
- * Error code indicating that the application has exceeded its request
- * limit.
- *
- * @property {number} REQUEST_LIMIT_EXCEEDED
- * @static
- */
-ParseError.REQUEST_LIMIT_EXCEEDED = 155;
-
-/**
- * Error code indicating that the request was a duplicate and has been discarded due to
- * idempotency rules.
- *
- * @property {number} DUPLICATE_REQUEST
- * @static
- */
-ParseError.DUPLICATE_REQUEST = 159;
-
-/**
- * Error code indicating an invalid event name.
- *
- * @property {number} INVALID_EVENT_NAME
- * @static
- */
-ParseError.INVALID_EVENT_NAME = 160;
-
-/**
- * Error code indicating that a field had an invalid value.
- *
- * @property {number} INVALID_VALUE
- * @static
- */
-ParseError.INVALID_VALUE = 162;
-
-/**
- * Error code indicating that the username is missing or empty.
- *
- * @property {number} USERNAME_MISSING
- * @static
- */
-ParseError.USERNAME_MISSING = 200;
-
-/**
- * Error code indicating that the password is missing or empty.
- *
- * @property {number} PASSWORD_MISSING
- * @static
- */
-ParseError.PASSWORD_MISSING = 201;
-
-/**
- * Error code indicating that the username has already been taken.
- *
- * @property {number} USERNAME_TAKEN
- * @static
- */
-ParseError.USERNAME_TAKEN = 202;
-
-/**
- * Error code indicating that the email has already been taken.
- *
- * @property {number} EMAIL_TAKEN
- * @static
- */
-ParseError.EMAIL_TAKEN = 203;
-
-/**
- * Error code indicating that the email is missing, but must be specified.
- *
- * @property {number} EMAIL_MISSING
- * @static
- */
-ParseError.EMAIL_MISSING = 204;
-
-/**
- * Error code indicating that a user with the specified email was not found.
- *
- * @property {number} EMAIL_NOT_FOUND
- * @static
- */
-ParseError.EMAIL_NOT_FOUND = 205;
-
-/**
- * Error code indicating that a user object without a valid session could
- * not be altered.
- *
- * @property {number} SESSION_MISSING
- * @static
- */
-ParseError.SESSION_MISSING = 206;
-
-/**
- * Error code indicating that a user can only be created through signup.
- *
- * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
- * @static
- */
-ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
-
-/**
- * Error code indicating that an an account being linked is already linked
- * to another user.
- *
- * @property {number} ACCOUNT_ALREADY_LINKED
- * @static
- */
-ParseError.ACCOUNT_ALREADY_LINKED = 208;
-
-/**
- * Error code indicating that the current session token is invalid.
- *
- * @property {number} INVALID_SESSION_TOKEN
- * @static
- */
-ParseError.INVALID_SESSION_TOKEN = 209;
-
-/**
- * Error code indicating an error enabling or verifying MFA
- *
- * @property {number} MFA_ERROR
- * @static
- */
-ParseError.MFA_ERROR = 210;
-
-/**
- * Error code indicating that a valid MFA token must be provided
- *
- * @property {number} MFA_TOKEN_REQUIRED
- * @static
- */
-ParseError.MFA_TOKEN_REQUIRED = 211;
-
-/**
- * Error code indicating that a user cannot be linked to an account because
- * that account's id could not be found.
- *
- * @property {number} LINKED_ID_MISSING
- * @static
- */
-ParseError.LINKED_ID_MISSING = 250;
-
-/**
- * Error code indicating that a user with a linked (e.g. Facebook) account
- * has an invalid session.
- *
- * @property {number} INVALID_LINKED_SESSION
- * @static
- */
-ParseError.INVALID_LINKED_SESSION = 251;
-
-/**
- * Error code indicating that a service being linked (e.g. Facebook or
- * Twitter) is unsupported.
- *
- * @property {number} UNSUPPORTED_SERVICE
- * @static
- */
-ParseError.UNSUPPORTED_SERVICE = 252;
-
-/**
- * Error code indicating an invalid operation occured on schema
- *
- * @property {number} INVALID_SCHEMA_OPERATION
- * @static
- */
-ParseError.INVALID_SCHEMA_OPERATION = 255;
-
-/**
- * Error code indicating that there were multiple errors. Aggregate errors
- * have an "errors" property, which is an array of error objects with more
- * detail about each error that occurred.
- *
- * @property {number} AGGREGATE_ERROR
- * @static
- */
-ParseError.AGGREGATE_ERROR = 600;
-
-/**
- * Error code indicating the client was unable to read an input file.
- *
- * @property {number} FILE_READ_ERROR
- * @static
- */
-ParseError.FILE_READ_ERROR = 601;
-
-/**
- * Error code indicating a real error code is unavailable because
- * we had to use an XDomainRequest object to allow CORS requests in
- * Internet Explorer, which strips the body from HTTP responses that have
- * a non-2XX status code.
- *
- * @property {number} X_DOMAIN_REQUEST
- * @static
- */
-ParseError.X_DOMAIN_REQUEST = 602;
-
-export default ParseError;
diff --git a/src/ParseError.ts b/src/ParseError.ts
new file mode 100644
index 000000000..498e5a2fa
--- /dev/null
+++ b/src/ParseError.ts
@@ -0,0 +1,556 @@
+import CoreManager from './CoreManager';
+import type ParseObject from './ParseObject';
+
+/**
+ * Constructs a new Parse.Error object with the given code and message.
+ *
+ * Parse.CoreManager.set('PARSE_ERRORS', [{ code, message }]) can be use to override error messages.
+ *
+ * @alias Parse.Error
+ */
+class ParseError extends Error {
+ code: number;
+ message: string;
+ object?: ParseObject;
+ errors?: Error[];
+ /**
+ * @param {number} code An error code constant from Parse.Error
.
+ * @param {string} message A detailed description of the error.
+ */
+ constructor(code: number, message?: string) {
+ super(message);
+ this.code = code;
+ let customMessage = message;
+ CoreManager.get('PARSE_ERRORS').forEach(error => {
+ if (error.code === code && error.code) {
+ customMessage = error.message;
+ }
+ });
+ Object.defineProperty(this, 'message', {
+ enumerable: true,
+ value: customMessage,
+ });
+ }
+
+ toString() {
+ return 'ParseError: ' + this.code + ' ' + this.message;
+ }
+
+ /**
+ * Error code indicating some error other than those enumerated here.
+ *
+ * @property {number} OTHER_CAUSE
+ * @static
+ */
+ static OTHER_CAUSE = -1;
+
+ /**
+ * Error code indicating that something has gone wrong with the server.
+ *
+ * @property {number} INTERNAL_SERVER_ERROR
+ * @static
+ */
+ static INTERNAL_SERVER_ERROR = 1;
+
+ /**
+ * Error code indicating the connection to the Parse servers failed.
+ *
+ * @property {number} CONNECTION_FAILED
+ * @static
+ */
+ static CONNECTION_FAILED = 100;
+
+ /**
+ * Error code indicating the specified object doesn't exist.
+ *
+ * @property {number} OBJECT_NOT_FOUND
+ * @static
+ */
+ static OBJECT_NOT_FOUND = 101;
+
+ /**
+ * Error code indicating you tried to query with a datatype that doesn't
+ * support it, like exact matching an array or object.
+ *
+ * @property {number} INVALID_QUERY
+ * @static
+ */
+ static INVALID_QUERY = 102;
+
+ /**
+ * Error code indicating a missing or invalid classname. Classnames are
+ * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
+ * only valid characters.
+ *
+ * @property {number} INVALID_CLASS_NAME
+ * @static
+ */
+ static INVALID_CLASS_NAME = 103;
+
+ /**
+ * Error code indicating an unspecified object id.
+ *
+ * @property {number} MISSING_OBJECT_ID
+ * @static
+ */
+ static MISSING_OBJECT_ID = 104;
+
+ /**
+ * Error code indicating an invalid key name. Keys are case-sensitive. They
+ * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
+ *
+ * @property {number} INVALID_KEY_NAME
+ * @static
+ */
+ static INVALID_KEY_NAME = 105;
+
+ /**
+ * Error code indicating a malformed pointer. You should not see this unless
+ * you have been mucking about changing internal Parse code.
+ *
+ * @property {number} INVALID_POINTER
+ * @static
+ */
+ static INVALID_POINTER = 106;
+
+ /**
+ * Error code indicating that badly formed JSON was received upstream. This
+ * either indicates you have done something unusual with modifying how
+ * things encode to JSON, or the network is failing badly.
+ *
+ * @property {number} INVALID_JSON
+ * @static
+ */
+ static INVALID_JSON = 107;
+
+ /**
+ * Error code indicating that the feature you tried to access is only
+ * available internally for testing purposes.
+ *
+ * @property {number} COMMAND_UNAVAILABLE
+ * @static
+ */
+ static COMMAND_UNAVAILABLE = 108;
+
+ /**
+ * You must call Parse.initialize before using the Parse library.
+ *
+ * @property {number} NOT_INITIALIZED
+ * @static
+ */
+ static NOT_INITIALIZED = 109;
+
+ /**
+ * Error code indicating that a field was set to an inconsistent type.
+ *
+ * @property {number} INCORRECT_TYPE
+ * @static
+ */
+ static INCORRECT_TYPE = 111;
+
+ /**
+ * Error code indicating an invalid channel name. A channel name is either
+ * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
+ * characters and starts with a letter.
+ *
+ * @property {number} INVALID_CHANNEL_NAME
+ * @static
+ */
+ static INVALID_CHANNEL_NAME = 112;
+
+ /**
+ * Error code indicating that push is misconfigured.
+ *
+ * @property {number} PUSH_MISCONFIGURED
+ * @static
+ */
+ static PUSH_MISCONFIGURED = 115;
+
+ /**
+ * Error code indicating that the object is too large.
+ *
+ * @property {number} OBJECT_TOO_LARGE
+ * @static
+ */
+ static OBJECT_TOO_LARGE = 116;
+
+ /**
+ * Error code indicating that the operation isn't allowed for clients.
+ *
+ * @property {number} OPERATION_FORBIDDEN
+ * @static
+ */
+ static OPERATION_FORBIDDEN = 119;
+
+ /**
+ * Error code indicating the result was not found in the cache.
+ *
+ * @property {number} CACHE_MISS
+ * @static
+ */
+ static CACHE_MISS = 120;
+
+ /**
+ * Error code indicating that an invalid key was used in a nested
+ * JSONObject.
+ *
+ * @property {number} INVALID_NESTED_KEY
+ * @static
+ */
+ static INVALID_NESTED_KEY = 121;
+
+ /**
+ * Error code indicating that an invalid filename was used for ParseFile.
+ * A valid file name contains only a-zA-Z0-9_. characters and is between 1
+ * and 128 characters.
+ *
+ * @property {number} INVALID_FILE_NAME
+ * @static
+ */
+ static INVALID_FILE_NAME = 122;
+
+ /**
+ * Error code indicating an invalid ACL was provided.
+ *
+ * @property {number} INVALID_ACL
+ * @static
+ */
+ static INVALID_ACL = 123;
+
+ /**
+ * Error code indicating that the request timed out on the server. Typically
+ * this indicates that the request is too expensive to run.
+ *
+ * @property {number} TIMEOUT
+ * @static
+ */
+ static TIMEOUT = 124;
+
+ /**
+ * Error code indicating that the email address was invalid.
+ *
+ * @property {number} INVALID_EMAIL_ADDRESS
+ * @static
+ */
+ static INVALID_EMAIL_ADDRESS = 125;
+
+ /**
+ * Error code indicating a missing content type.
+ *
+ * @property {number} MISSING_CONTENT_TYPE
+ * @static
+ */
+ static MISSING_CONTENT_TYPE = 126;
+
+ /**
+ * Error code indicating a missing content length.
+ *
+ * @property {number} MISSING_CONTENT_LENGTH
+ * @static
+ */
+ static MISSING_CONTENT_LENGTH = 127;
+
+ /**
+ * Error code indicating an invalid content length.
+ *
+ * @property {number} INVALID_CONTENT_LENGTH
+ * @static
+ */
+ static INVALID_CONTENT_LENGTH = 128;
+
+ /**
+ * Error code indicating a file that was too large.
+ *
+ * @property {number} FILE_TOO_LARGE
+ * @static
+ */
+ static FILE_TOO_LARGE = 129;
+
+ /**
+ * Error code indicating an error saving a file.
+ *
+ * @property {number} FILE_SAVE_ERROR
+ * @static
+ */
+ static FILE_SAVE_ERROR = 130;
+
+ /**
+ * Error code indicating that a unique field was given a value that is
+ * already taken.
+ *
+ * @property {number} DUPLICATE_VALUE
+ * @static
+ */
+ static DUPLICATE_VALUE = 137;
+
+ /**
+ * Error code indicating that a role's name is invalid.
+ *
+ * @property {number} INVALID_ROLE_NAME
+ * @static
+ */
+ static INVALID_ROLE_NAME = 139;
+
+ /**
+ * Error code indicating that an application quota was exceeded. Upgrade to
+ * resolve.
+ *
+ * @property {number} EXCEEDED_QUOTA
+ * @static
+ */
+ static EXCEEDED_QUOTA = 140;
+
+ /**
+ * Error code indicating that a Cloud Code script failed.
+ *
+ * @property {number} SCRIPT_FAILED
+ * @static
+ */
+ static SCRIPT_FAILED = 141;
+
+ /**
+ * Error code indicating that a Cloud Code validation failed.
+ *
+ * @property {number} VALIDATION_ERROR
+ * @static
+ */
+ static VALIDATION_ERROR = 142;
+
+ /**
+ * Error code indicating that invalid image data was provided.
+ *
+ * @property {number} INVALID_IMAGE_DATA
+ * @static
+ */
+ static INVALID_IMAGE_DATA = 143;
+
+ /**
+ * Error code indicating an unsaved file.
+ *
+ * @property {number} UNSAVED_FILE_ERROR
+ * @static
+ */
+ static UNSAVED_FILE_ERROR = 151;
+
+ /**
+ * Error code indicating an invalid push time.
+ *
+ * @property {number} INVALID_PUSH_TIME_ERROR
+ * @static
+ */
+ static INVALID_PUSH_TIME_ERROR = 152;
+
+ /**
+ * Error code indicating an error deleting a file.
+ *
+ * @property {number} FILE_DELETE_ERROR
+ * @static
+ */
+ static FILE_DELETE_ERROR = 153;
+
+ /**
+ * Error code indicating an error deleting an unnamed file.
+ *
+ * @property {number} FILE_DELETE_UNNAMED_ERROR
+ * @static
+ */
+ static FILE_DELETE_UNNAMED_ERROR = 161;
+
+ /**
+ * Error code indicating that the application has exceeded its request
+ * limit.
+ *
+ * @property {number} REQUEST_LIMIT_EXCEEDED
+ * @static
+ */
+ static REQUEST_LIMIT_EXCEEDED = 155;
+
+ /**
+ * Error code indicating that the request was a duplicate and has been discarded due to
+ * idempotency rules.
+ *
+ * @property {number} DUPLICATE_REQUEST
+ * @static
+ */
+ static DUPLICATE_REQUEST = 159;
+
+ /**
+ * Error code indicating an invalid event name.
+ *
+ * @property {number} INVALID_EVENT_NAME
+ * @static
+ */
+ static INVALID_EVENT_NAME = 160;
+
+ /**
+ * Error code indicating that a field had an invalid value.
+ *
+ * @property {number} INVALID_VALUE
+ * @static
+ */
+ static INVALID_VALUE = 162;
+
+ /**
+ * Error code indicating that the username is missing or empty.
+ *
+ * @property {number} USERNAME_MISSING
+ * @static
+ */
+ static USERNAME_MISSING = 200;
+
+ /**
+ * Error code indicating that the password is missing or empty.
+ *
+ * @property {number} PASSWORD_MISSING
+ * @static
+ */
+ static PASSWORD_MISSING = 201;
+
+ /**
+ * Error code indicating that the username has already been taken.
+ *
+ * @property {number} USERNAME_TAKEN
+ * @static
+ */
+ static USERNAME_TAKEN = 202;
+
+ /**
+ * Error code indicating that the email has already been taken.
+ *
+ * @property {number} EMAIL_TAKEN
+ * @static
+ */
+ static EMAIL_TAKEN = 203;
+
+ /**
+ * Error code indicating that the email is missing, but must be specified.
+ *
+ * @property {number} EMAIL_MISSING
+ * @static
+ */
+ static EMAIL_MISSING = 204;
+
+ /**
+ * Error code indicating that a user with the specified email was not found.
+ *
+ * @property {number} EMAIL_NOT_FOUND
+ * @static
+ */
+ static EMAIL_NOT_FOUND = 205;
+
+ /**
+ * Error code indicating that a user object without a valid session could
+ * not be altered.
+ *
+ * @property {number} SESSION_MISSING
+ * @static
+ */
+ static SESSION_MISSING = 206;
+
+ /**
+ * Error code indicating that a user can only be created through signup.
+ *
+ * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
+ * @static
+ */
+ static MUST_CREATE_USER_THROUGH_SIGNUP = 207;
+
+ /**
+ * Error code indicating that an an account being linked is already linked
+ * to another user.
+ *
+ * @property {number} ACCOUNT_ALREADY_LINKED
+ * @static
+ */
+ static ACCOUNT_ALREADY_LINKED = 208;
+
+ /**
+ * Error code indicating that the current session token is invalid.
+ *
+ * @property {number} INVALID_SESSION_TOKEN
+ * @static
+ */
+ static INVALID_SESSION_TOKEN = 209;
+
+ /**
+ * Error code indicating an error enabling or verifying MFA
+ *
+ * @property {number} MFA_ERROR
+ * @static
+ */
+ static MFA_ERROR = 210;
+
+ /**
+ * Error code indicating that a valid MFA token must be provided
+ *
+ * @property {number} MFA_TOKEN_REQUIRED
+ * @static
+ */
+ static MFA_TOKEN_REQUIRED = 211;
+
+ /**
+ * Error code indicating that a user cannot be linked to an account because
+ * that account's id could not be found.
+ *
+ * @property {number} LINKED_ID_MISSING
+ * @static
+ */
+ static LINKED_ID_MISSING = 250;
+
+ /**
+ * Error code indicating that a user with a linked (e.g. Facebook) account
+ * has an invalid session.
+ *
+ * @property {number} INVALID_LINKED_SESSION
+ * @static
+ */
+ static INVALID_LINKED_SESSION = 251;
+
+ /**
+ * Error code indicating that a service being linked (e.g. Facebook or
+ * Twitter) is unsupported.
+ *
+ * @property {number} UNSUPPORTED_SERVICE
+ * @static
+ */
+ static UNSUPPORTED_SERVICE = 252;
+
+ /**
+ * Error code indicating an invalid operation occured on schema
+ *
+ * @property {number} INVALID_SCHEMA_OPERATION
+ * @static
+ */
+ static INVALID_SCHEMA_OPERATION = 255;
+
+ /**
+ * Error code indicating that there were multiple errors. Aggregate errors
+ * have an "errors" property, which is an array of error objects with more
+ * detail about each error that occurred.
+ *
+ * @property {number} AGGREGATE_ERROR
+ * @static
+ */
+ static AGGREGATE_ERROR = 600;
+
+ /**
+ * Error code indicating the client was unable to read an input file.
+ *
+ * @property {number} FILE_READ_ERROR
+ * @static
+ */
+ static FILE_READ_ERROR = 601;
+
+ /**
+ * Error code indicating a real error code is unavailable because
+ * we had to use an XDomainRequest object to allow CORS requests in
+ * Internet Explorer, which strips the body from HTTP responses that have
+ * a non-2XX status code.
+ *
+ * @property {number} X_DOMAIN_REQUEST
+ * @static
+ */
+ static X_DOMAIN_REQUEST = 602;
+}
+
+export default ParseError;
diff --git a/src/ParseLiveQuery.js b/src/ParseLiveQuery.ts
similarity index 93%
rename from src/ParseLiveQuery.js
rename to src/ParseLiveQuery.ts
index c293133c7..8c7e8188f 100644
--- a/src/ParseLiveQuery.js
+++ b/src/ParseLiveQuery.ts
@@ -1,6 +1,3 @@
-/**
- * @flow
- */
import LiveQueryClient from './LiveQueryClient';
import CoreManager from './CoreManager';
@@ -36,11 +33,15 @@ function getLiveQueryClient(): Promise {
* @static
*/
class LiveQuery {
+ emitter: any;
+ on: any;
+ emit: any;
+
constructor() {
const EventEmitter = CoreManager.getEventEmitter();
this.emitter = new EventEmitter();
- this.on = (eventName, listener) => this.emitter.on(eventName, listener);
- this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
+ this.on = (eventName: string, listener: any) => this.emitter.on(eventName, listener);
+ this.emit = (eventName: string, ...args: any) => this.emitter.emit(eventName, ...args);
// adding listener so process does not crash
// best practice is for developer to register their own listener
this.on('error', () => {});
@@ -50,7 +51,7 @@ class LiveQuery {
* After open is called, the LiveQuery will try to send a connect request
* to the LiveQuery server.
*/
- async open(): void {
+ async open(): Promise {
const liveQueryClient = await getLiveQueryClient();
liveQueryClient.open();
}
@@ -62,7 +63,7 @@ class LiveQuery {
* If you call query.subscribe() after this, we'll create a new WebSocket
* connection to the LiveQuery server.
*/
- async close(): void {
+ async close(): Promise {
const liveQueryClient = await getLiveQueryClient();
liveQueryClient.close();
}
diff --git a/src/ParseObject.ts b/src/ParseObject.ts
index 700c4fdae..6c78fa4e6 100644
--- a/src/ParseObject.ts
+++ b/src/ParseObject.ts
@@ -1946,13 +1946,13 @@ class ParseObject {
* });
*
* @param {string} className The name of the Parse class backing this model.
- * @param {object} protoProps Instance properties to add to instances of the
+ * @param {object} [protoProps] Instance properties to add to instances of the
* class returned from this method.
- * @param {object} classProps Class properties to add the class returned from
+ * @param {object} [classProps] Class properties to add the class returned from
* this method.
* @returns {Parse.Object} A new subclass of Parse.Object.
*/
- static extend(className: any, protoProps: any, classProps: any) {
+ static extend(className: any, protoProps?: any, classProps?: any) {
if (typeof className !== 'string') {
if (className && typeof className.className === 'string') {
return ParseObject.extend(className.className, className, protoProps);
@@ -2539,7 +2539,7 @@ const DefaultController = {
// generate _localId in case if cascadeSave=false
target._getId();
const localId = target._localId;
- // copying target lets Flow guarantee the pointer isn't modified elsewhere
+ // copying target lets guarantee the pointer isn't modified elsewhere
const targetCopy = target;
const task = function () {
const params = targetCopy._getSaveParams();
diff --git a/src/ParseRelation.js b/src/ParseRelation.ts
similarity index 95%
rename from src/ParseRelation.js
rename to src/ParseRelation.ts
index fde1b1ec9..d53126d98 100644
--- a/src/ParseRelation.js
+++ b/src/ParseRelation.ts
@@ -1,7 +1,3 @@
-/**
- * @flow
- */
-
import type ParseObject from './ParseObject';
import type ParseQuery from './ParseQuery';
import CoreManager from './CoreManager';
@@ -20,15 +16,15 @@ import CoreManager from './CoreManager';
* @alias Parse.Relation
*/
class ParseRelation {
- parent: ?ParseObject;
- key: ?string;
- targetClassName: ?string;
+ parent?: ParseObject;
+ key?: string;
+ targetClassName?: string | null;
/**
* @param {Parse.Object} parent The parent of this relation.
* @param {string} key The key for this relation on the parent.
*/
- constructor(parent: ?ParseObject, key: ?string) {
+ constructor(parent?: ParseObject, key?: string) {
this.parent = parent;
this.key = key;
this.targetClassName = null;
@@ -108,7 +104,7 @@ class ParseRelation {
*
* @returns {object} JSON representation of Relation
*/
- toJSON(): { __type: 'Relation'; className: ?string } {
+ toJSON(): { __type: 'Relation'; className: string | null } {
return {
__type: 'Relation',
className: this.targetClassName,
diff --git a/src/SingleInstanceStateController.js b/src/SingleInstanceStateController.ts
similarity index 63%
rename from src/SingleInstanceStateController.js
rename to src/SingleInstanceStateController.ts
index dfc51cb00..8e78775fb 100644
--- a/src/SingleInstanceStateController.js
+++ b/src/SingleInstanceStateController.ts
@@ -1,32 +1,24 @@
-/**
- * @flow
- */
-
import * as ObjectStateMutations from './ObjectStateMutations';
import type { Op } from './ParseOp';
+import type ParseObject from './ParseObject';
import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';
-type ObjectIdentifier = {
- className: string;
- id: string;
-};
-
let objectState: {
[className: string]: {
[id: string]: State;
};
} = {};
-export function getState(obj: ObjectIdentifier): ?State {
+export function getState(obj: ParseObject): State | null {
const classData = objectState[obj.className];
if (classData) {
- return classData[obj.id] || null;
+ return classData[obj.id!] || null;
}
return null;
}
-export function initializeState(obj: ObjectIdentifier, initial?: State): State {
+export function initializeState(obj: ParseObject, initial?: State): State {
let state = getState(obj);
if (state) {
return state;
@@ -37,20 +29,20 @@ export function initializeState(obj: ObjectIdentifier, initial?: State): State {
if (!initial) {
initial = ObjectStateMutations.defaultState();
}
- state = objectState[obj.className][obj.id] = initial;
+ state = objectState[obj.className][obj.id!] = initial;
return state;
}
-export function removeState(obj: ObjectIdentifier): ?State {
+export function removeState(obj: ParseObject): State | null {
const state = getState(obj);
if (state === null) {
return null;
}
- delete objectState[obj.className][obj.id];
+ delete objectState[obj.className][obj.id!];
return state;
}
-export function getServerData(obj: ObjectIdentifier): AttributeMap {
+export function getServerData(obj: ParseObject): AttributeMap {
const state = getState(obj);
if (state) {
return state.serverData;
@@ -58,12 +50,12 @@ export function getServerData(obj: ObjectIdentifier): AttributeMap {
return {};
}
-export function setServerData(obj: ObjectIdentifier, attributes: AttributeMap) {
+export function setServerData(obj: ParseObject, attributes: AttributeMap) {
const serverData = initializeState(obj).serverData;
ObjectStateMutations.setServerData(serverData, attributes);
}
-export function getPendingOps(obj: ObjectIdentifier): Array {
+export function getPendingOps(obj: ParseObject): Array {
const state = getState(obj);
if (state) {
return state.pendingOps;
@@ -71,27 +63,27 @@ export function getPendingOps(obj: ObjectIdentifier): Array {
return [{}];
}
-export function setPendingOp(obj: ObjectIdentifier, attr: string, op: ?Op) {
+export function setPendingOp(obj: ParseObject, attr: string, op?: Op) {
const pendingOps = initializeState(obj).pendingOps;
ObjectStateMutations.setPendingOp(pendingOps, attr, op);
}
-export function pushPendingState(obj: ObjectIdentifier) {
+export function pushPendingState(obj: ParseObject) {
const pendingOps = initializeState(obj).pendingOps;
ObjectStateMutations.pushPendingState(pendingOps);
}
-export function popPendingState(obj: ObjectIdentifier): OpsMap {
+export function popPendingState(obj: ParseObject): OpsMap {
const pendingOps = initializeState(obj).pendingOps;
return ObjectStateMutations.popPendingState(pendingOps);
}
-export function mergeFirstPendingState(obj: ObjectIdentifier) {
+export function mergeFirstPendingState(obj: ParseObject) {
const pendingOps = getPendingOps(obj);
ObjectStateMutations.mergeFirstPendingState(pendingOps);
}
-export function getObjectCache(obj: ObjectIdentifier): ObjectCache {
+export function getObjectCache(obj: ParseObject): ObjectCache {
const state = getState(obj);
if (state) {
return state.objectCache;
@@ -99,24 +91,24 @@ export function getObjectCache(obj: ObjectIdentifier): ObjectCache {
return {};
}
-export function estimateAttribute(obj: ObjectIdentifier, attr: string): any {
+export function estimateAttribute(obj: ParseObject, attr: string): any {
const serverData = getServerData(obj);
const pendingOps = getPendingOps(obj);
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
}
-export function estimateAttributes(obj: ObjectIdentifier): AttributeMap {
+export function estimateAttributes(obj: ParseObject): AttributeMap {
const serverData = getServerData(obj);
const pendingOps = getPendingOps(obj);
return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
}
-export function commitServerChanges(obj: ObjectIdentifier, changes: AttributeMap) {
+export function commitServerChanges(obj: ParseObject, changes: AttributeMap) {
const state = initializeState(obj);
ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
}
-export function enqueueTask(obj: ObjectIdentifier, task: () => Promise): Promise {
+export function enqueueTask(obj: ParseObject, task: () => Promise): Promise {
const state = initializeState(obj);
return state.tasks.enqueue(task);
}
diff --git a/src/UniqueInstanceStateController.js b/src/UniqueInstanceStateController.ts
similarity index 94%
rename from src/UniqueInstanceStateController.js
rename to src/UniqueInstanceStateController.ts
index 24633ef9f..9ad9e4d65 100644
--- a/src/UniqueInstanceStateController.js
+++ b/src/UniqueInstanceStateController.ts
@@ -1,7 +1,3 @@
-/**
- * @flow
- */
-
import * as ObjectStateMutations from './ObjectStateMutations';
import TaskQueue from './TaskQueue';
@@ -11,7 +7,7 @@ import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMuta
let objectState = new WeakMap();
-export function getState(obj: ParseObject): ?State {
+export function getState(obj: ParseObject): State | null {
const classData = objectState.get(obj);
return classData || null;
}
@@ -35,7 +31,7 @@ export function initializeState(obj: ParseObject, initial?: State): State {
return state;
}
-export function removeState(obj: ParseObject): ?State {
+export function removeState(obj: ParseObject): State | null {
const state = getState(obj);
if (state === null) {
return null;
@@ -65,7 +61,7 @@ export function getPendingOps(obj: ParseObject): Array {
return [{}];
}
-export function setPendingOp(obj: ParseObject, attr: string, op: ?Op) {
+export function setPendingOp(obj: ParseObject, attr: string, op?: Op) {
const pendingOps = initializeState(obj).pendingOps;
ObjectStateMutations.setPendingOp(pendingOps, attr, op);
}
@@ -110,7 +106,7 @@ export function commitServerChanges(obj: ParseObject, changes: AttributeMap) {
ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
}
-export function enqueueTask(obj: ParseObject, task: () => Promise): Promise {
+export function enqueueTask(obj: ParseObject, task: () => Promise): Promise {
const state = initializeState(obj);
return state.tasks.enqueue(task);
}
diff --git a/src/interfaces/AuthProvider.js b/src/interfaces/AuthProvider.ts
similarity index 98%
rename from src/interfaces/AuthProvider.js
rename to src/interfaces/AuthProvider.ts
index 933eb5b70..443776d46 100644
--- a/src/interfaces/AuthProvider.js
+++ b/src/interfaces/AuthProvider.ts
@@ -1,8 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-/**
- * @flow
- */
-
/**
* Interface declaration for Authentication Providers
*
diff --git a/src/interfaces/react-native.js b/src/interfaces/react-native.ts
similarity index 100%
rename from src/interfaces/react-native.js
rename to src/interfaces/react-native.ts
diff --git a/src/interfaces/xmlhttprequest.js b/src/interfaces/xmlhttprequest.ts
similarity index 100%
rename from src/interfaces/xmlhttprequest.js
rename to src/interfaces/xmlhttprequest.ts
diff --git a/types/EventuallyQueue.d.ts b/types/EventuallyQueue.d.ts
index c00dca73d..78d76d077 100644
--- a/types/EventuallyQueue.d.ts
+++ b/types/EventuallyQueue.d.ts
@@ -1,5 +1,25 @@
-export default EventuallyQueue;
-declare namespace EventuallyQueue {
+import ParseObject from './ParseObject';
+import type { SaveOptions } from './ParseObject';
+import type { RequestOptions } from './RESTController';
+type QueueObject = {
+ queueId: string;
+ action: string;
+ object: ParseObject;
+ serverOptions: SaveOptions | RequestOptions;
+ id: string;
+ className: string;
+ hash: string;
+ createdAt: Date;
+};
+type Queue = Array;
+/**
+ * Provides utility functions to queue objects that will be
+ * saved to the server at a later date.
+ *
+ * @class Parse.EventuallyQueue
+ * @static
+ */
+declare const EventuallyQueue: {
/**
* Add object to queue with save operation.
*
@@ -11,7 +31,7 @@ declare namespace EventuallyQueue {
* @static
* @see Parse.Object#saveEventually
*/
- function save(object: ParseObject, serverOptions?: SaveOptions): Promise;
+ save(object: ParseObject, serverOptions?: SaveOptions): Promise;
/**
* Add object to queue with save operation.
*
@@ -23,7 +43,7 @@ declare namespace EventuallyQueue {
* @static
* @see Parse.Object#destroyEventually
*/
- function destroy(object: ParseObject, serverOptions?: RequestOptions): Promise;
+ destroy(object: ParseObject, serverOptions?: RequestOptions): Promise;
/**
* Generate unique identifier to avoid duplicates and maintain previous state.
*
@@ -33,7 +53,7 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function generateQueueId(action: string, object: ParseObject): string;
+ generateQueueId(action: string, object: ParseObject): string;
/**
* Build queue object and add to queue.
*
@@ -44,22 +64,22 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function enqueue(
+ enqueue(
action: string,
object: ParseObject,
- serverOptions?: RequestOptions | SaveOptions
- ): Promise;
- function store(data: any): Promise;
- function load(): Promise;
+ serverOptions: SaveOptions | RequestOptions
+ ): Promise;
+ store(data: QueueObject[]): Promise;
+ load(): Promise;
/**
* Sets the in-memory queue from local storage and returns.
*
* @function getQueue
* @name Parse.EventuallyQueue.getQueue
- * @returns {Promise}
+ * @returns {Promise}
* @static
*/
- function getQueue(): Promise;
+ getQueue(): Promise;
/**
* Saves the queue to local storage
*
@@ -68,7 +88,7 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function setQueue(queue: Queue): Promise;
+ setQueue(queue: Queue): Promise;
/**
* Removes Parse.Object data from queue.
*
@@ -77,7 +97,7 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function remove(queueId: string): Promise;
+ remove(queueId: string): Promise;
/**
* Removes all objects from queue.
*
@@ -86,7 +106,7 @@ declare namespace EventuallyQueue {
* @returns {Promise} A promise that is fulfilled when queue is cleared.
* @static
*/
- function clear(): Promise;
+ clear(): Promise;
/**
* Return the index of a queueId in the queue. Returns -1 if not found.
*
@@ -96,16 +116,16 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function queueItemExists(queue: Queue, queueId: string): number;
+ queueItemExists(queue: Queue, queueId: string): number;
/**
* Return the number of objects in the queue.
*
* @function length
* @name Parse.EventuallyQueue.length
- * @returns {number}
+ * @returns {Promise}
* @static
*/
- function length(): number;
+ length(): Promise;
/**
* Sends the queue to the server.
*
@@ -114,7 +134,7 @@ declare namespace EventuallyQueue {
* @returns {Promise} Returns true if queue was sent successfully.
* @static
*/
- function sendQueue(): Promise;
+ sendQueue(): Promise;
/**
* Build queue object and add to queue.
*
@@ -124,7 +144,7 @@ declare namespace EventuallyQueue {
* @static
* @ignore
*/
- function sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise;
+ sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise;
/**
* Start polling server for network connection.
* Will send queue if connection is established.
@@ -134,7 +154,7 @@ declare namespace EventuallyQueue {
* @param [ms] Milliseconds to ping the server. Default 2000ms
* @static
*/
- function poll(ms?: number): void;
+ poll(ms?: number): void;
/**
* Turns off polling.
*
@@ -142,7 +162,7 @@ declare namespace EventuallyQueue {
* @name Parse.EventuallyQueue.stopPoll
* @static
*/
- function stopPoll(): void;
+ stopPoll(): void;
/**
* Return true if pinging the server.
*
@@ -151,25 +171,12 @@ declare namespace EventuallyQueue {
* @returns {boolean}
* @static
*/
- function isPolling(): boolean;
- function _setPolling(flag: boolean): void;
- namespace process {
- function create(ObjectType: any, queueObject: any): Promise;
- function byId(ObjectType: any, queueObject: any): Promise;
- function byHash(ObjectType: any, queueObject: any): Promise;
- }
-}
-import ParseObject from './ParseObject';
-import { SaveOptions } from './ParseObject';
-import { RequestOptions } from './RESTController';
-type Queue = QueueObject[];
-type QueueObject = {
- queueId: string;
- action: string;
- object: ParseObject;
- serverOptions: RequestOptions | SaveOptions;
- id: string;
- className: string;
- hash: string;
- createdAt: Date;
+ isPolling(): boolean;
+ _setPolling(flag: boolean): void;
+ process: {
+ create(ObjectType: any, queueObject: any): Promise;
+ byId(ObjectType: any, queueObject: any): Promise;
+ byHash(ObjectType: any, queueObject: any): Promise;
+ };
};
+export default EventuallyQueue;
diff --git a/types/IndexedDBStorageController.d.ts b/types/IndexedDBStorageController.d.ts
new file mode 100644
index 000000000..b159d7961
--- /dev/null
+++ b/types/IndexedDBStorageController.d.ts
@@ -0,0 +1,2 @@
+declare let IndexedDBStorageController: any;
+export default IndexedDBStorageController;
diff --git a/types/LiveQuerySubscription.d.ts b/types/LiveQuerySubscription.d.ts
index 06a4ed154..e312d2a86 100644
--- a/types/LiveQuerySubscription.d.ts
+++ b/types/LiveQuerySubscription.d.ts
@@ -1,7 +1,6 @@
-export default Subscription;
+import type ParseQuery from './ParseQuery';
/**
* Creates a new LiveQuery Subscription.
- * Extends events.EventEmitter
* cloud functions.
*
* Response Object - Contains data from the client that made the request
@@ -81,21 +80,23 @@ export default Subscription;
* subscription.on('close', () => {
*
* });
- *
- * @alias Parse.LiveQuerySubscription
*/
declare class Subscription {
- constructor(id: any, query: any, sessionToken: any);
- id: any;
- query: any;
- sessionToken: any;
- subscribePromise: Promise;
- unsubscribePromise: Promise;
+ id: string | number;
+ query: ParseQuery;
+ sessionToken?: string;
+ subscribePromise: any;
+ unsubscribePromise: any;
subscribed: boolean;
+ emitter: any;
+ on: any;
+ emit: any;
+ constructor(id: string | number, query: ParseQuery, sessionToken?: string);
/**
* Close the subscription
*
* @returns {Promise}
*/
- unsubscribe(): Promise;
+ unsubscribe(): Promise;
}
+export default Subscription;
diff --git a/types/ParseACL.d.ts b/types/ParseACL.d.ts
index 0a17992b5..fc8da8570 100644
--- a/types/ParseACL.d.ts
+++ b/types/ParseACL.d.ts
@@ -1,4 +1,11 @@
-export default ParseACL;
+import type ParseRole from './ParseRole';
+import type ParseUser from './ParseUser';
+type PermissionsMap = {
+ [permission: string]: boolean;
+};
+type ByIdMap = {
+ [userId: string]: PermissionsMap;
+};
/**
* Creates a new ACL.
* If no argument is given, the ACL has no permissions for anyone.
@@ -14,11 +21,11 @@ export default ParseACL;
* @alias Parse.ACL
*/
declare class ParseACL {
+ permissionsById: ByIdMap;
/**
* @param {(Parse.User | object)} arg1 The user to initialize the ACL for
*/
constructor(arg1: ParseUser | ByIdMap);
- permissionsById: ByIdMap;
/**
* Returns a JSON-encoded version of the ACL.
*
@@ -131,11 +138,4 @@ declare class ParseACL {
*/
setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void;
}
-type ByIdMap = {
- [userId: string]: PermissionsMap;
-};
-import ParseUser from './ParseUser';
-import ParseRole from './ParseRole';
-type PermissionsMap = {
- [permission: string]: boolean;
-};
+export default ParseACL;
diff --git a/types/ParseError.d.ts b/types/ParseError.d.ts
index 167e9addb..5147fd681 100644
--- a/types/ParseError.d.ts
+++ b/types/ParseError.d.ts
@@ -1,77 +1,476 @@
-export default ParseError;
+import type ParseObject from './ParseObject';
/**
* Constructs a new Parse.Error object with the given code and message.
*
+ * Parse.CoreManager.set('PARSE_ERRORS', [{ code, message }]) can be use to override error messages.
+ *
* @alias Parse.Error
*/
declare class ParseError extends Error {
+ code: number;
+ message: string;
+ object?: ParseObject;
+ errors?: Error[];
/**
* @param {number} code An error code constant from Parse.Error
.
* @param {string} message A detailed description of the error.
*/
- constructor(code: number, message: string);
- code: number;
-}
-declare namespace ParseError {
- let OTHER_CAUSE: number;
- let INTERNAL_SERVER_ERROR: number;
- let CONNECTION_FAILED: number;
- let OBJECT_NOT_FOUND: number;
- let INVALID_QUERY: number;
- let INVALID_CLASS_NAME: number;
- let MISSING_OBJECT_ID: number;
- let INVALID_KEY_NAME: number;
- let INVALID_POINTER: number;
- let INVALID_JSON: number;
- let COMMAND_UNAVAILABLE: number;
- let NOT_INITIALIZED: number;
- let INCORRECT_TYPE: number;
- let INVALID_CHANNEL_NAME: number;
- let PUSH_MISCONFIGURED: number;
- let OBJECT_TOO_LARGE: number;
- let OPERATION_FORBIDDEN: number;
- let CACHE_MISS: number;
- let INVALID_NESTED_KEY: number;
- let INVALID_FILE_NAME: number;
- let INVALID_ACL: number;
- let TIMEOUT: number;
- let INVALID_EMAIL_ADDRESS: number;
- let MISSING_CONTENT_TYPE: number;
- let MISSING_CONTENT_LENGTH: number;
- let INVALID_CONTENT_LENGTH: number;
- let FILE_TOO_LARGE: number;
- let FILE_SAVE_ERROR: number;
- let DUPLICATE_VALUE: number;
- let INVALID_ROLE_NAME: number;
- let EXCEEDED_QUOTA: number;
- let SCRIPT_FAILED: number;
- let VALIDATION_ERROR: number;
- let INVALID_IMAGE_DATA: number;
- let UNSAVED_FILE_ERROR: number;
- let INVALID_PUSH_TIME_ERROR: number;
- let FILE_DELETE_ERROR: number;
- let FILE_DELETE_UNNAMED_ERROR: number;
- let REQUEST_LIMIT_EXCEEDED: number;
- let DUPLICATE_REQUEST: number;
- let INVALID_EVENT_NAME: number;
- let INVALID_VALUE: number;
- let USERNAME_MISSING: number;
- let PASSWORD_MISSING: number;
- let USERNAME_TAKEN: number;
- let EMAIL_TAKEN: number;
- let EMAIL_MISSING: number;
- let EMAIL_NOT_FOUND: number;
- let SESSION_MISSING: number;
- let MUST_CREATE_USER_THROUGH_SIGNUP: number;
- let ACCOUNT_ALREADY_LINKED: number;
- let INVALID_SESSION_TOKEN: number;
- let MFA_ERROR: number;
- let MFA_TOKEN_REQUIRED: number;
- let LINKED_ID_MISSING: number;
- let INVALID_LINKED_SESSION: number;
- let UNSUPPORTED_SERVICE: number;
- let INVALID_SCHEMA_OPERATION: number;
- let AGGREGATE_ERROR: number;
- let FILE_READ_ERROR: number;
- let X_DOMAIN_REQUEST: number;
+ constructor(code: number, message?: string);
+ toString(): string;
+ /**
+ * Error code indicating some error other than those enumerated here.
+ *
+ * @property {number} OTHER_CAUSE
+ * @static
+ */
+ static OTHER_CAUSE: number;
+ /**
+ * Error code indicating that something has gone wrong with the server.
+ *
+ * @property {number} INTERNAL_SERVER_ERROR
+ * @static
+ */
+ static INTERNAL_SERVER_ERROR: number;
+ /**
+ * Error code indicating the connection to the Parse servers failed.
+ *
+ * @property {number} CONNECTION_FAILED
+ * @static
+ */
+ static CONNECTION_FAILED: number;
+ /**
+ * Error code indicating the specified object doesn't exist.
+ *
+ * @property {number} OBJECT_NOT_FOUND
+ * @static
+ */
+ static OBJECT_NOT_FOUND: number;
+ /**
+ * Error code indicating you tried to query with a datatype that doesn't
+ * support it, like exact matching an array or object.
+ *
+ * @property {number} INVALID_QUERY
+ * @static
+ */
+ static INVALID_QUERY: number;
+ /**
+ * Error code indicating a missing or invalid classname. Classnames are
+ * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
+ * only valid characters.
+ *
+ * @property {number} INVALID_CLASS_NAME
+ * @static
+ */
+ static INVALID_CLASS_NAME: number;
+ /**
+ * Error code indicating an unspecified object id.
+ *
+ * @property {number} MISSING_OBJECT_ID
+ * @static
+ */
+ static MISSING_OBJECT_ID: number;
+ /**
+ * Error code indicating an invalid key name. Keys are case-sensitive. They
+ * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
+ *
+ * @property {number} INVALID_KEY_NAME
+ * @static
+ */
+ static INVALID_KEY_NAME: number;
+ /**
+ * Error code indicating a malformed pointer. You should not see this unless
+ * you have been mucking about changing internal Parse code.
+ *
+ * @property {number} INVALID_POINTER
+ * @static
+ */
+ static INVALID_POINTER: number;
+ /**
+ * Error code indicating that badly formed JSON was received upstream. This
+ * either indicates you have done something unusual with modifying how
+ * things encode to JSON, or the network is failing badly.
+ *
+ * @property {number} INVALID_JSON
+ * @static
+ */
+ static INVALID_JSON: number;
+ /**
+ * Error code indicating that the feature you tried to access is only
+ * available internally for testing purposes.
+ *
+ * @property {number} COMMAND_UNAVAILABLE
+ * @static
+ */
+ static COMMAND_UNAVAILABLE: number;
+ /**
+ * You must call Parse.initialize before using the Parse library.
+ *
+ * @property {number} NOT_INITIALIZED
+ * @static
+ */
+ static NOT_INITIALIZED: number;
+ /**
+ * Error code indicating that a field was set to an inconsistent type.
+ *
+ * @property {number} INCORRECT_TYPE
+ * @static
+ */
+ static INCORRECT_TYPE: number;
+ /**
+ * Error code indicating an invalid channel name. A channel name is either
+ * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
+ * characters and starts with a letter.
+ *
+ * @property {number} INVALID_CHANNEL_NAME
+ * @static
+ */
+ static INVALID_CHANNEL_NAME: number;
+ /**
+ * Error code indicating that push is misconfigured.
+ *
+ * @property {number} PUSH_MISCONFIGURED
+ * @static
+ */
+ static PUSH_MISCONFIGURED: number;
+ /**
+ * Error code indicating that the object is too large.
+ *
+ * @property {number} OBJECT_TOO_LARGE
+ * @static
+ */
+ static OBJECT_TOO_LARGE: number;
+ /**
+ * Error code indicating that the operation isn't allowed for clients.
+ *
+ * @property {number} OPERATION_FORBIDDEN
+ * @static
+ */
+ static OPERATION_FORBIDDEN: number;
+ /**
+ * Error code indicating the result was not found in the cache.
+ *
+ * @property {number} CACHE_MISS
+ * @static
+ */
+ static CACHE_MISS: number;
+ /**
+ * Error code indicating that an invalid key was used in a nested
+ * JSONObject.
+ *
+ * @property {number} INVALID_NESTED_KEY
+ * @static
+ */
+ static INVALID_NESTED_KEY: number;
+ /**
+ * Error code indicating that an invalid filename was used for ParseFile.
+ * A valid file name contains only a-zA-Z0-9_. characters and is between 1
+ * and 128 characters.
+ *
+ * @property {number} INVALID_FILE_NAME
+ * @static
+ */
+ static INVALID_FILE_NAME: number;
+ /**
+ * Error code indicating an invalid ACL was provided.
+ *
+ * @property {number} INVALID_ACL
+ * @static
+ */
+ static INVALID_ACL: number;
+ /**
+ * Error code indicating that the request timed out on the server. Typically
+ * this indicates that the request is too expensive to run.
+ *
+ * @property {number} TIMEOUT
+ * @static
+ */
+ static TIMEOUT: number;
+ /**
+ * Error code indicating that the email address was invalid.
+ *
+ * @property {number} INVALID_EMAIL_ADDRESS
+ * @static
+ */
+ static INVALID_EMAIL_ADDRESS: number;
+ /**
+ * Error code indicating a missing content type.
+ *
+ * @property {number} MISSING_CONTENT_TYPE
+ * @static
+ */
+ static MISSING_CONTENT_TYPE: number;
+ /**
+ * Error code indicating a missing content length.
+ *
+ * @property {number} MISSING_CONTENT_LENGTH
+ * @static
+ */
+ static MISSING_CONTENT_LENGTH: number;
+ /**
+ * Error code indicating an invalid content length.
+ *
+ * @property {number} INVALID_CONTENT_LENGTH
+ * @static
+ */
+ static INVALID_CONTENT_LENGTH: number;
+ /**
+ * Error code indicating a file that was too large.
+ *
+ * @property {number} FILE_TOO_LARGE
+ * @static
+ */
+ static FILE_TOO_LARGE: number;
+ /**
+ * Error code indicating an error saving a file.
+ *
+ * @property {number} FILE_SAVE_ERROR
+ * @static
+ */
+ static FILE_SAVE_ERROR: number;
+ /**
+ * Error code indicating that a unique field was given a value that is
+ * already taken.
+ *
+ * @property {number} DUPLICATE_VALUE
+ * @static
+ */
+ static DUPLICATE_VALUE: number;
+ /**
+ * Error code indicating that a role's name is invalid.
+ *
+ * @property {number} INVALID_ROLE_NAME
+ * @static
+ */
+ static INVALID_ROLE_NAME: number;
+ /**
+ * Error code indicating that an application quota was exceeded. Upgrade to
+ * resolve.
+ *
+ * @property {number} EXCEEDED_QUOTA
+ * @static
+ */
+ static EXCEEDED_QUOTA: number;
+ /**
+ * Error code indicating that a Cloud Code script failed.
+ *
+ * @property {number} SCRIPT_FAILED
+ * @static
+ */
+ static SCRIPT_FAILED: number;
+ /**
+ * Error code indicating that a Cloud Code validation failed.
+ *
+ * @property {number} VALIDATION_ERROR
+ * @static
+ */
+ static VALIDATION_ERROR: number;
+ /**
+ * Error code indicating that invalid image data was provided.
+ *
+ * @property {number} INVALID_IMAGE_DATA
+ * @static
+ */
+ static INVALID_IMAGE_DATA: number;
+ /**
+ * Error code indicating an unsaved file.
+ *
+ * @property {number} UNSAVED_FILE_ERROR
+ * @static
+ */
+ static UNSAVED_FILE_ERROR: number;
+ /**
+ * Error code indicating an invalid push time.
+ *
+ * @property {number} INVALID_PUSH_TIME_ERROR
+ * @static
+ */
+ static INVALID_PUSH_TIME_ERROR: number;
+ /**
+ * Error code indicating an error deleting a file.
+ *
+ * @property {number} FILE_DELETE_ERROR
+ * @static
+ */
+ static FILE_DELETE_ERROR: number;
+ /**
+ * Error code indicating an error deleting an unnamed file.
+ *
+ * @property {number} FILE_DELETE_UNNAMED_ERROR
+ * @static
+ */
+ static FILE_DELETE_UNNAMED_ERROR: number;
+ /**
+ * Error code indicating that the application has exceeded its request
+ * limit.
+ *
+ * @property {number} REQUEST_LIMIT_EXCEEDED
+ * @static
+ */
+ static REQUEST_LIMIT_EXCEEDED: number;
+ /**
+ * Error code indicating that the request was a duplicate and has been discarded due to
+ * idempotency rules.
+ *
+ * @property {number} DUPLICATE_REQUEST
+ * @static
+ */
+ static DUPLICATE_REQUEST: number;
+ /**
+ * Error code indicating an invalid event name.
+ *
+ * @property {number} INVALID_EVENT_NAME
+ * @static
+ */
+ static INVALID_EVENT_NAME: number;
+ /**
+ * Error code indicating that a field had an invalid value.
+ *
+ * @property {number} INVALID_VALUE
+ * @static
+ */
+ static INVALID_VALUE: number;
+ /**
+ * Error code indicating that the username is missing or empty.
+ *
+ * @property {number} USERNAME_MISSING
+ * @static
+ */
+ static USERNAME_MISSING: number;
+ /**
+ * Error code indicating that the password is missing or empty.
+ *
+ * @property {number} PASSWORD_MISSING
+ * @static
+ */
+ static PASSWORD_MISSING: number;
+ /**
+ * Error code indicating that the username has already been taken.
+ *
+ * @property {number} USERNAME_TAKEN
+ * @static
+ */
+ static USERNAME_TAKEN: number;
+ /**
+ * Error code indicating that the email has already been taken.
+ *
+ * @property {number} EMAIL_TAKEN
+ * @static
+ */
+ static EMAIL_TAKEN: number;
+ /**
+ * Error code indicating that the email is missing, but must be specified.
+ *
+ * @property {number} EMAIL_MISSING
+ * @static
+ */
+ static EMAIL_MISSING: number;
+ /**
+ * Error code indicating that a user with the specified email was not found.
+ *
+ * @property {number} EMAIL_NOT_FOUND
+ * @static
+ */
+ static EMAIL_NOT_FOUND: number;
+ /**
+ * Error code indicating that a user object without a valid session could
+ * not be altered.
+ *
+ * @property {number} SESSION_MISSING
+ * @static
+ */
+ static SESSION_MISSING: number;
+ /**
+ * Error code indicating that a user can only be created through signup.
+ *
+ * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
+ * @static
+ */
+ static MUST_CREATE_USER_THROUGH_SIGNUP: number;
+ /**
+ * Error code indicating that an an account being linked is already linked
+ * to another user.
+ *
+ * @property {number} ACCOUNT_ALREADY_LINKED
+ * @static
+ */
+ static ACCOUNT_ALREADY_LINKED: number;
+ /**
+ * Error code indicating that the current session token is invalid.
+ *
+ * @property {number} INVALID_SESSION_TOKEN
+ * @static
+ */
+ static INVALID_SESSION_TOKEN: number;
+ /**
+ * Error code indicating an error enabling or verifying MFA
+ *
+ * @property {number} MFA_ERROR
+ * @static
+ */
+ static MFA_ERROR: number;
+ /**
+ * Error code indicating that a valid MFA token must be provided
+ *
+ * @property {number} MFA_TOKEN_REQUIRED
+ * @static
+ */
+ static MFA_TOKEN_REQUIRED: number;
+ /**
+ * Error code indicating that a user cannot be linked to an account because
+ * that account's id could not be found.
+ *
+ * @property {number} LINKED_ID_MISSING
+ * @static
+ */
+ static LINKED_ID_MISSING: number;
+ /**
+ * Error code indicating that a user with a linked (e.g. Facebook) account
+ * has an invalid session.
+ *
+ * @property {number} INVALID_LINKED_SESSION
+ * @static
+ */
+ static INVALID_LINKED_SESSION: number;
+ /**
+ * Error code indicating that a service being linked (e.g. Facebook or
+ * Twitter) is unsupported.
+ *
+ * @property {number} UNSUPPORTED_SERVICE
+ * @static
+ */
+ static UNSUPPORTED_SERVICE: number;
+ /**
+ * Error code indicating an invalid operation occured on schema
+ *
+ * @property {number} INVALID_SCHEMA_OPERATION
+ * @static
+ */
+ static INVALID_SCHEMA_OPERATION: number;
+ /**
+ * Error code indicating that there were multiple errors. Aggregate errors
+ * have an "errors" property, which is an array of error objects with more
+ * detail about each error that occurred.
+ *
+ * @property {number} AGGREGATE_ERROR
+ * @static
+ */
+ static AGGREGATE_ERROR: number;
+ /**
+ * Error code indicating the client was unable to read an input file.
+ *
+ * @property {number} FILE_READ_ERROR
+ * @static
+ */
+ static FILE_READ_ERROR: number;
+ /**
+ * Error code indicating a real error code is unavailable because
+ * we had to use an XDomainRequest object to allow CORS requests in
+ * Internet Explorer, which strips the body from HTTP responses that have
+ * a non-2XX status code.
+ *
+ * @property {number} X_DOMAIN_REQUEST
+ * @static
+ */
+ static X_DOMAIN_REQUEST: number;
}
+export default ParseError;
diff --git a/types/ParseLiveQuery.d.ts b/types/ParseLiveQuery.d.ts
index 6e98e68c1..ac9aa3495 100644
--- a/types/ParseLiveQuery.d.ts
+++ b/types/ParseLiveQuery.d.ts
@@ -1,4 +1,3 @@
-export default LiveQuery;
/**
* We expose three events to help you monitor the status of the WebSocket connection:
*
@@ -26,4 +25,23 @@ export default LiveQuery;
* @class Parse.LiveQuery
* @static
*/
-declare const LiveQuery: any;
+declare class LiveQuery {
+ emitter: any;
+ on: any;
+ emit: any;
+ constructor();
+ /**
+ * After open is called, the LiveQuery will try to send a connect request
+ * to the LiveQuery server.
+ */
+ open(): Promise;
+ /**
+ * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
+ * This function will close the WebSocket connection to the LiveQuery server,
+ * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
+ * If you call query.subscribe() after this, we'll create a new WebSocket
+ * connection to the LiveQuery server.
+ */
+ close(): Promise;
+}
+export default LiveQuery;
diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts
index 3fbaf71be..881aadca5 100644
--- a/types/ParseObject.d.ts
+++ b/types/ParseObject.d.ts
@@ -940,13 +940,13 @@ declare class ParseObject {
* });
*
* @param {string} className The name of the Parse class backing this model.
- * @param {object} protoProps Instance properties to add to instances of the
+ * @param {object} [protoProps] Instance properties to add to instances of the
* class returned from this method.
- * @param {object} classProps Class properties to add the class returned from
+ * @param {object} [classProps] Class properties to add the class returned from
* this method.
* @returns {Parse.Object} A new subclass of Parse.Object.
*/
- static extend(className: any, protoProps: any, classProps: any): any;
+ static extend(className: any, protoProps?: any, classProps?: any): any;
/**
* Enable single instance objects, where any local objects with the same Id
* share the same attributes, and stay synchronized with each other.
diff --git a/types/ParseRelation.d.ts b/types/ParseRelation.d.ts
index 6ef474475..5426f7c83 100644
--- a/types/ParseRelation.d.ts
+++ b/types/ParseRelation.d.ts
@@ -1,4 +1,5 @@
-export default ParseRelation;
+import type ParseObject from './ParseObject';
+import type ParseQuery from './ParseQuery';
/**
* Creates a new Relation for the given parent object and key. This
* constructor should rarely be used directly, but rather created by
@@ -13,14 +14,14 @@ export default ParseRelation;
* @alias Parse.Relation
*/
declare class ParseRelation {
+ parent?: ParseObject;
+ key?: string;
+ targetClassName?: string | null;
/**
* @param {Parse.Object} parent The parent of this relation.
* @param {string} key The key for this relation on the parent.
*/
- constructor(parent: ParseObject | null, key: string | null);
- parent: ParseObject | null;
- key: string | null;
- targetClassName: string | null;
+ constructor(parent?: ParseObject, key?: string);
_ensureParentAndKey(parent: ParseObject, key: string): void;
/**
* Adds a Parse.Object or an array of Parse.Objects to the relation.
@@ -52,5 +53,4 @@ declare class ParseRelation {
*/
query(): ParseQuery;
}
-import ParseObject from './ParseObject';
-import ParseQuery from './ParseQuery';
+export default ParseRelation;
diff --git a/types/SingleInstanceStateController.d.ts b/types/SingleInstanceStateController.d.ts
index 55bf5a304..1b93bff1f 100644
--- a/types/SingleInstanceStateController.d.ts
+++ b/types/SingleInstanceStateController.d.ts
@@ -1,20 +1,23 @@
-export function getState(obj: ObjectIdentifier): State | null;
-export function initializeState(obj: ObjectIdentifier, initial?: State): State;
-export function removeState(obj: ObjectIdentifier): State | null;
-export function getServerData(obj: ObjectIdentifier): AttributeMap;
-export function setServerData(obj: ObjectIdentifier, attributes: AttributeMap): void;
-export function getPendingOps(obj: ObjectIdentifier): Array;
-export function setPendingOp(obj: ObjectIdentifier, attr: string, op: Op | null): void;
-export function pushPendingState(obj: ObjectIdentifier): void;
-export function popPendingState(obj: ObjectIdentifier): OpsMap;
-export function mergeFirstPendingState(obj: ObjectIdentifier): void;
-export function getObjectCache(obj: ObjectIdentifier): ObjectCache;
-export function estimateAttribute(obj: ObjectIdentifier, attr: string): mixed;
-export function estimateAttributes(obj: ObjectIdentifier): AttributeMap;
-export function commitServerChanges(obj: ObjectIdentifier, changes: AttributeMap): void;
-export function enqueueTask(obj: ObjectIdentifier, task: () => Promise): Promise;
-export function clearAllState(): void;
-export function duplicateState(
+import type { Op } from './ParseOp';
+import type ParseObject from './ParseObject';
+import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';
+export declare function getState(obj: ParseObject): State | null;
+export declare function initializeState(obj: ParseObject, initial?: State): State;
+export declare function removeState(obj: ParseObject): State | null;
+export declare function getServerData(obj: ParseObject): AttributeMap;
+export declare function setServerData(obj: ParseObject, attributes: AttributeMap): void;
+export declare function getPendingOps(obj: ParseObject): Array;
+export declare function setPendingOp(obj: ParseObject, attr: string, op?: Op): void;
+export declare function pushPendingState(obj: ParseObject): void;
+export declare function popPendingState(obj: ParseObject): OpsMap;
+export declare function mergeFirstPendingState(obj: ParseObject): void;
+export declare function getObjectCache(obj: ParseObject): ObjectCache;
+export declare function estimateAttribute(obj: ParseObject, attr: string): any;
+export declare function estimateAttributes(obj: ParseObject): AttributeMap;
+export declare function commitServerChanges(obj: ParseObject, changes: AttributeMap): void;
+export declare function enqueueTask(obj: ParseObject, task: () => Promise): Promise;
+export declare function clearAllState(): void;
+export declare function duplicateState(
source: {
id: string;
},
@@ -22,13 +25,3 @@ export function duplicateState(
id: string;
}
): void;
-type ObjectIdentifier = {
- className: string;
- id: string;
-};
-import { State } from './ObjectStateMutations';
-import { AttributeMap } from './ObjectStateMutations';
-import { OpsMap } from './ObjectStateMutations';
-import { Op } from './ParseOp';
-import { ObjectCache } from './ObjectStateMutations';
-export {};
diff --git a/types/UniqueInstanceStateController.d.ts b/types/UniqueInstanceStateController.d.ts
index f3e2ccf60..7aff646fd 100644
--- a/types/UniqueInstanceStateController.d.ts
+++ b/types/UniqueInstanceStateController.d.ts
@@ -1,23 +1,20 @@
-export function getState(obj: ParseObject): State | null;
-export function initializeState(obj: ParseObject, initial?: State): State;
-export function removeState(obj: ParseObject): State | null;
-export function getServerData(obj: ParseObject): AttributeMap;
-export function setServerData(obj: ParseObject, attributes: AttributeMap): void;
-export function getPendingOps(obj: ParseObject): Array;
-export function setPendingOp(obj: ParseObject, attr: string, op: Op | null): void;
-export function pushPendingState(obj: ParseObject): void;
-export function popPendingState(obj: ParseObject): OpsMap;
-export function mergeFirstPendingState(obj: ParseObject): void;
-export function getObjectCache(obj: ParseObject): ObjectCache;
-export function estimateAttribute(obj: ParseObject, attr: string): mixed;
-export function estimateAttributes(obj: ParseObject): AttributeMap;
-export function commitServerChanges(obj: ParseObject, changes: AttributeMap): void;
-export function enqueueTask(obj: ParseObject, task: () => Promise): Promise;
-export function duplicateState(source: ParseObject, dest: ParseObject): void;
-export function clearAllState(): void;
-import ParseObject from './ParseObject';
-import { State } from './ObjectStateMutations';
-import { AttributeMap } from './ObjectStateMutations';
-import { OpsMap } from './ObjectStateMutations';
-import { Op } from './ParseOp';
-import { ObjectCache } from './ObjectStateMutations';
+import type { Op } from './ParseOp';
+import type ParseObject from './ParseObject';
+import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';
+export declare function getState(obj: ParseObject): State | null;
+export declare function initializeState(obj: ParseObject, initial?: State): State;
+export declare function removeState(obj: ParseObject): State | null;
+export declare function getServerData(obj: ParseObject): AttributeMap;
+export declare function setServerData(obj: ParseObject, attributes: AttributeMap): void;
+export declare function getPendingOps(obj: ParseObject): Array;
+export declare function setPendingOp(obj: ParseObject, attr: string, op?: Op): void;
+export declare function pushPendingState(obj: ParseObject): void;
+export declare function popPendingState(obj: ParseObject): OpsMap;
+export declare function mergeFirstPendingState(obj: ParseObject): void;
+export declare function getObjectCache(obj: ParseObject): ObjectCache;
+export declare function estimateAttribute(obj: ParseObject, attr: string): any;
+export declare function estimateAttributes(obj: ParseObject): AttributeMap;
+export declare function commitServerChanges(obj: ParseObject, changes: AttributeMap): void;
+export declare function enqueueTask(obj: ParseObject, task: () => Promise): Promise;
+export declare function duplicateState(source: ParseObject, dest: ParseObject): void;
+export declare function clearAllState(): void;
From 46f93cf8989c9ffd0f909de61bdbbaa231b235f7 Mon Sep 17 00:00:00 2001
From: Diamond Lewis
Date: Sun, 19 May 2024 19:44:47 -0500
Subject: [PATCH 2/2] Update CONTRIBUTING.md
---
CONTRIBUTING.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e2035ca1b..df4119263 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -98,6 +98,7 @@ Parse Community has a [responsible Vulnerability Disclosure Program](https://git
## Coding Style
* Most importantly, match the existing code style as much as possible.
+* We use ES6 for this codebase. Use modern syntax whenever possible.
* Keep lines within 80 characters.
* Always end lines with semicolons.