From bd510153e1bb03800719bfd547c9e30b8dcdbfd7 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 16 May 2024 19:52:39 -0500 Subject: [PATCH] refactor: Run ESLint against TypeScript files --- .eslintrc.json | 14 +- package-lock.json | 285 ++++++++---------- package.json | 7 +- src/{Cloud.js => Cloud.ts} | 16 +- src/EventuallyQueue.js | 2 +- src/InstallationController.ts | 8 +- ...{LiveQueryClient.js => LiveQueryClient.ts} | 38 ++- src/{LocalDatastore.js => LocalDatastore.ts} | 20 +- ...js => LocalDatastoreController.default.ts} | 14 +- ... LocalDatastoreController.react-native.ts} | 18 +- ...tastoreUtils.js => LocalDatastoreUtils.ts} | 5 - src/Parse.ts | 2 +- src/{ParseCLP.js => ParseCLP.ts} | 34 +-- src/ParseFile.ts | 29 +- src/ParseInstallation.ts | 16 +- src/ParseObject.ts | 7 +- src/ParseOp.js | 42 +-- src/ParsePolygon.js | 2 +- src/ParseQuery.ts | 20 +- src/ParseSchema.js | 8 +- src/ParseUser.ts | 4 + src/RESTController.js | 2 +- src/SingleInstanceStateController.js | 2 +- src/UniqueInstanceStateController.js | 2 +- src/__tests__/LocalDatastore-test.js | 2 +- src/__tests__/ParseFile-test.js | 3 +- src/__tests__/ParseObject-test.js | 2 +- src/interfaces/AuthProvider.js | 2 +- src/interfaces/xmlhttprequest.js | 2 +- types/Cloud.d.ts | 13 +- types/LiveQueryClient.d.ts | 63 ++-- types/LocalDatastore.d.ts | 70 +++-- types/LocalDatastoreController.default.d.ts | 9 + ...LocalDatastoreController.react-native.d.ts | 10 +- types/LocalDatastoreUtils.d.ts | 13 +- types/ParseCLP.d.ts | 43 +-- types/ParseFile.d.ts | 21 +- types/ParseInstallation.d.ts | 26 +- types/ParseObject.d.ts | 7 +- types/ParseQuery.d.ts | 13 +- types/ParseUser.d.ts | 4 + 41 files changed, 468 insertions(+), 432 deletions(-) rename src/{Cloud.js => Cloud.ts} (91%) rename src/{LiveQueryClient.js => LiveQueryClient.ts} (93%) rename src/{LocalDatastore.js => LocalDatastore.ts} (97%) rename src/{LocalDatastoreController.default.js => LocalDatastoreController.default.ts} (86%) rename src/{LocalDatastoreController.react-native.js => LocalDatastoreController.react-native.ts} (87%) rename src/{LocalDatastoreUtils.js => LocalDatastoreUtils.ts} (92%) rename src/{ParseCLP.js => ParseCLP.ts} (95%) create mode 100644 types/LocalDatastoreController.default.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index dc4a0b0a5..8503d698d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,19 +3,21 @@ "extends": [ "eslint:recommended", "plugin:jsdoc/recommended", - "plugin:flowtype/recommended" + "plugin:flowtype/recommended", + "plugin:@typescript-eslint/recommended" ], "env": { "node": true, "es6": true }, - "parser": "@babel/eslint-parser", + "parser": "@typescript-eslint/parser", "globals": { "wx": true }, "plugins": [ "flowtype", - "jsdoc" + "jsdoc", + "@typescript-eslint" ], "parserOptions": { "ecmaVersion": 6, @@ -36,6 +38,12 @@ "no-console": 0, "no-prototype-builtins": "off", "require-atomic-updates": "off", + "prefer-spread": "off", + "prefer-rest-params": "off", + "@typescript-eslint/no-empty-function": "off", + "@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, diff --git a/package-lock.json b/package-lock.json index 6f1079b79..df8d02699 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ }, "devDependencies": { "@babel/core": "7.22.0", - "@babel/eslint-parser": "7.21.8", "@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", @@ -43,7 +42,7 @@ "codecov": "3.8.3", "core-js": "3.30.2", "cross-env": "7.0.2", - "eslint": "8.40.0", + "eslint": "8.56.0", "eslint-plugin-flowtype": "8.0.3", "eslint-plugin-jsdoc": "43.0.7", "express": "4.18.2", @@ -2970,23 +2969,23 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", - "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", - "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.2", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -3008,9 +3007,9 @@ "dev": true }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -3059,9 +3058,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.40.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.40.0.tgz", - "integrity": "sha512-ElyB54bJIhXQYVKjDSvCkPO1iU1tSAeVQJbllWJq1XQSmmA4dgFk8CbiBGpiOPxleE48vDogxCtmMYku4HSVLA==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3499,13 +3498,13 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { @@ -3526,9 +3525,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "node_modules/@isaacs/cliui": { @@ -6336,6 +6335,12 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@xmldom/xmldom": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.6.tgz", @@ -11269,27 +11274,28 @@ } }, "node_modules/eslint": { - "version": "8.40.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.40.0.tgz", - "integrity": "sha512-bvR+TsP9EHL3TqNtj9sCNJVAFK3fBN8Q7g5waghxyRsPLIMwL73XSKnZFK0hk/O2ANC+iAoq6PWMQ+IfBAJIiQ==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.40.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.0", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -11297,22 +11303,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -11406,9 +11409,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -11485,9 +11488,9 @@ } }, "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", - "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -11602,9 +11605,9 @@ } }, "node_modules/eslint/node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "dependencies": { "deep-is": "^0.1.3", @@ -11612,7 +11615,7 @@ "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "word-wrap": "^1.2.5" }, "engines": { "node": ">= 0.8.0" @@ -11657,18 +11660,6 @@ "node": ">= 0.8.0" } }, - "node_modules/eslint/node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -11706,12 +11697,12 @@ } }, "node_modules/espree": { - "version": "9.5.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", - "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, @@ -11723,9 +11714,9 @@ } }, "node_modules/espree/node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -13936,12 +13927,6 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -17985,16 +17970,6 @@ "url": "https://github.com/sponsors/panva" } }, - "node_modules/js-sdsl": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", - "integrity": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==", - "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -29708,9 +29683,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", - "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -32065,20 +32040,20 @@ } }, "@eslint-community/regexpp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", - "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", "dev": true }, "@eslint/eslintrc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", - "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.2", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -32094,9 +32069,9 @@ "dev": true }, "globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -32126,9 +32101,9 @@ } }, "@eslint/js": { - "version": "8.40.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.40.0.tgz", - "integrity": "sha512-ElyB54bJIhXQYVKjDSvCkPO1iU1tSAeVQJbllWJq1XQSmmA4dgFk8CbiBGpiOPxleE48vDogxCtmMYku4HSVLA==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", "dev": true }, "@fastify/busboy": { @@ -32488,13 +32463,13 @@ } }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" } }, @@ -32505,9 +32480,9 @@ "dev": true }, "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "@isaacs/cliui": { @@ -34685,6 +34660,12 @@ "eslint-visitor-keys": "^3.3.0" } }, + "@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "@xmldom/xmldom": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.6.tgz", @@ -38696,27 +38677,28 @@ } }, "eslint": { - "version": "8.40.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.40.0.tgz", - "integrity": "sha512-bvR+TsP9EHL3TqNtj9sCNJVAFK3fBN8Q7g5waghxyRsPLIMwL73XSKnZFK0hk/O2ANC+iAoq6PWMQ+IfBAJIiQ==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.40.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.0", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -38724,22 +38706,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "dependencies": { @@ -38790,9 +38769,9 @@ "dev": true }, "eslint-scope": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", - "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "requires": { "esrecurse": "^4.3.0", @@ -38868,9 +38847,9 @@ } }, "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "requires": { "deep-is": "^0.1.3", @@ -38878,7 +38857,7 @@ "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "word-wrap": "^1.2.5" } }, "p-limit": { @@ -38905,12 +38884,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -38991,26 +38964,26 @@ } }, "eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true }, "espree": { - "version": "9.5.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", - "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "requires": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, "dependencies": { "acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true } } @@ -40813,12 +40786,6 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, "graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -43889,12 +43856,6 @@ "integrity": "sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==", "dev": true }, - "js-sdsl": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", - "integrity": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==", - "dev": true - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -52931,9 +52892,9 @@ } }, "word-wrap": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", - "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wordwrap": { diff --git a/package.json b/package.json index 0a4f0f3e6..59ee3dc37 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ }, "devDependencies": { "@babel/core": "7.22.0", - "@babel/eslint-parser": "7.21.8", "@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", @@ -63,7 +62,7 @@ "codecov": "3.8.3", "core-js": "3.30.2", "cross-env": "7.0.2", - "eslint": "8.40.0", + "eslint": "8.56.0", "eslint-plugin-flowtype": "8.0.3", "eslint-plugin-jsdoc": "43.0.7", "express": "4.18.2", @@ -105,8 +104,8 @@ "test:mongodb:runnerstart": "mongodb-runner start -- --port 27017", "test:types": "dtslint --expectOnly types", "posttest:mongodb": "mongodb-runner stop --all", - "lint": "eslint --cache src/ integration/", - "lint:fix": "eslint --fix --cache src/ integration/", + "lint": "eslint --cache src/ integration/ --ext .js --ext .ts", + "lint:fix": "eslint --fix --cache src/ integration/ --ext .js --ext .ts", "lint:types": "dtslint types", "watch": "cross-env PARSE_BUILD=${PARSE_BUILD} gulp watch", "watch:browser": "cross-env PARSE_BUILD=browser npm run watch", diff --git a/src/Cloud.js b/src/Cloud.ts similarity index 91% rename from src/Cloud.js rename to src/Cloud.ts index 0d218843c..0df7ae95d 100644 --- a/src/Cloud.js +++ b/src/Cloud.ts @@ -1,7 +1,3 @@ -/** - * @flow - */ - import CoreManager from './CoreManager'; import decode from './decode'; import encode from './encode'; @@ -33,14 +29,14 @@ import type { RequestOptions } from './RESTController'; * @returns {Promise} A promise that will be resolved with the result * of the function. */ -export function run(name: string, data: mixed, options: RequestOptions): Promise { +export function run(name: string, data: any, options: RequestOptions): Promise { options = options || {}; if (typeof name !== 'string' || name.length === 0) { throw new TypeError('Cloud function name must be a string.'); } - const requestOptions = {}; + const requestOptions: RequestOptions = {}; if (options.useMasterKey) { requestOptions.useMasterKey = options.useMasterKey; } @@ -65,7 +61,7 @@ export function run(name: string, data: mixed, options: RequestOptions): Promise * @returns {Promise} A promise that will be resolved with the result * of the function. */ -export function getJobsData(): Promise { +export function getJobsData(): Promise { const requestOptions = { useMasterKey: true, }; @@ -82,7 +78,7 @@ export function getJobsData(): Promise { * @returns {Promise} A promise that will be resolved with the jobStatusId * of the job. */ -export function startJob(name: string, data: mixed): Promise { +export function startJob(name: string, data: any): Promise { if (typeof name !== 'string' || name.length === 0) { throw new TypeError('Cloud job name must be a string.'); } @@ -106,7 +102,7 @@ export function getJobStatus(jobStatusId: string): Promise { } const DefaultController = { - run(name, data, options: RequestOptions) { + run(name: string, data: any, options: RequestOptions) { const RESTController = CoreManager.getRESTController(); const payload = encode(data, true); @@ -131,7 +127,7 @@ const DefaultController = { return RESTController.request('GET', 'cloud_code/jobs/data', null, options); }, - async startJob(name, data, options: RequestOptions) { + async startJob(name: string, data: any, options: RequestOptions) { const RESTController = CoreManager.getRESTController(); const payload = encode(data, true); diff --git a/src/EventuallyQueue.js b/src/EventuallyQueue.js index 521d1e514..f37b4b291 100644 --- a/src/EventuallyQueue.js +++ b/src/EventuallyQueue.js @@ -303,7 +303,7 @@ const EventuallyQueue = { * @param [ms] Milliseconds to ping the server. Default 2000ms * @static */ - poll(ms?: number = 2000) { + poll(ms = 2000) { if (polling) { return; } diff --git a/src/InstallationController.ts b/src/InstallationController.ts index 419e55451..454b93ede 100644 --- a/src/InstallationController.ts +++ b/src/InstallationController.ts @@ -7,7 +7,7 @@ const CURRENT_INSTALLATION_KEY = 'currentInstallation'; const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId'; let iidCache: string | null = null; -let currentInstallationCache = null; +let currentInstallationCache: ParseInstallation | null = null; let currentInstallationCacheMatchesDisk = false; const InstallationController = { @@ -42,12 +42,12 @@ const InstallationController = { return null; } const path = Storage.generatePath(CURRENT_INSTALLATION_KEY); - let installationData = await Storage.getItemAsync(path); + let installationData: any = await Storage.getItemAsync(path); currentInstallationCacheMatchesDisk = true; if (installationData) { installationData = JSON.parse(installationData); installationData.className = '_Installation'; - const current = ParseInstallation.fromJSON(installationData); + const current = ParseInstallation.fromJSON(installationData) as ParseInstallation; currentInstallationCache = current; return current as ParseInstallation; } @@ -71,7 +71,7 @@ const InstallationController = { iidCache = iid; }, - _setCurrentInstallationCache(installation: ParseInstallation, matchesDisk: boolean = true) { + _setCurrentInstallationCache(installation: ParseInstallation, matchesDisk = true) { currentInstallationCache = installation; currentInstallationCacheMatchesDisk = matchesDisk; }, diff --git a/src/LiveQueryClient.js b/src/LiveQueryClient.ts similarity index 93% rename from src/LiveQueryClient.js rename to src/LiveQueryClient.ts index 9c65ef74d..d4c908a35 100644 --- a/src/LiveQueryClient.js +++ b/src/LiveQueryClient.ts @@ -1,8 +1,9 @@ -import CoreManager from './CoreManager'; +import CoreManager, { WebSocketController } from './CoreManager'; import ParseObject from './ParseObject'; import LiveQuerySubscription from './LiveQuerySubscription'; import { resolvingPromise } from './promiseUtils'; import ParseError from './ParseError'; +import type ParseQuery from './ParseQuery'; // The LiveQuery client inner state const CLIENT_STATE = { @@ -107,15 +108,19 @@ class LiveQueryClient { requestId: number; applicationId: string; serverURL: string; - javascriptKey: ?string; - masterKey: ?string; - sessionToken: ?string; - installationId: ?string; + javascriptKey?: string; + masterKey?: string; + sessionToken?: string; + installationId?: string; additionalProperties: boolean; - connectPromise: Promise; - subscriptions: Map; - socket: any; + connectPromise: any; + subscriptions: Map; + socket: WebSocketController & { closingPromise?: any }; state: string; + reconnectHandle: any; + emitter: any; + on: any; + emit: any; /** * @param {object} options @@ -178,11 +183,11 @@ class LiveQueryClient { * here for more details. The subscription you get is the same subscription you get * from our Standard API. * - * @param {object} query - the ParseQuery you want to subscribe to + * @param {ParseQuery} query - the ParseQuery you want to subscribe to * @param {string} sessionToken (optional) * @returns {LiveQuerySubscription | undefined} */ - subscribe(query: Object, sessionToken: ?string): LiveQuerySubscription { + subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined { if (!query) { return; } @@ -200,6 +205,7 @@ class LiveQueryClient { keys, watch, }, + sessionToken: undefined as string | undefined, }; if (sessionToken) { @@ -226,7 +232,7 @@ class LiveQueryClient { * @param {object} subscription - subscription you would like to unsubscribe from. * @returns {Promise | undefined} */ - unsubscribe(subscription: Object): ?Promise { + async unsubscribe(subscription: LiveQuerySubscription): Promise { if (!subscription) { return; } @@ -270,7 +276,7 @@ class LiveQueryClient { }; this.socket.onclose = (event) => { - this.socket.closingPromise.resolve(event); + this.socket.closingPromise?.resolve(event); this._handleWebSocketClose(); }; @@ -295,6 +301,7 @@ class LiveQueryClient { where, fields, }, + sessionToken: undefined as string | undefined, }; if (sessionToken) { @@ -313,7 +320,7 @@ class LiveQueryClient { * * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event} */ - close(): ?Promise { + async close(): Promise { if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) { return; } @@ -346,6 +353,7 @@ class LiveQueryClient { javascriptKey: this.javascriptKey, masterKey: this.masterKey, sessionToken: this.sessionToken, + installationId: undefined as string | undefined }; if (this.additionalProperties) { connectRequest.installationId = this.installationId; @@ -358,9 +366,9 @@ class LiveQueryClient { if (typeof data === 'string') { data = JSON.parse(data); } - let subscription = null; + let subscription: null | LiveQuerySubscription = null; if (data.requestId) { - subscription = this.subscriptions.get(data.requestId); + subscription = this.subscriptions.get(data.requestId) || null; } const response = { clientId: data.clientId, diff --git a/src/LocalDatastore.js b/src/LocalDatastore.ts similarity index 97% rename from src/LocalDatastore.js rename to src/LocalDatastore.ts index bf552d09d..f7df58614 100644 --- a/src/LocalDatastore.js +++ b/src/LocalDatastore.ts @@ -1,7 +1,3 @@ -/** - * @flow - */ - import CoreManager from './CoreManager'; import type ParseObject from './ParseObject'; @@ -32,33 +28,33 @@ const LocalDatastore = { isEnabled: false, isSyncing: false, - fromPinWithName(name: string): Promise> { + fromPinWithName(name: string): Promise> { const controller = CoreManager.getLocalDatastoreController(); return controller.fromPinWithName(name); }, - pinWithName(name: string, value: any): Promise { + async pinWithName(name: string, value: any): Promise { const controller = CoreManager.getLocalDatastoreController(); return controller.pinWithName(name, value); }, - unPinWithName(name: string): Promise { + async unPinWithName(name: string): Promise { const controller = CoreManager.getLocalDatastoreController(); return controller.unPinWithName(name); }, - _getAllContents(): Promise { + _getAllContents(): Promise { const controller = CoreManager.getLocalDatastoreController(); return controller.getAllContents(); }, // Use for testing - _getRawStorage(): Promise { + async _getRawStorage(): Promise { const controller = CoreManager.getLocalDatastoreController(); - return controller.getRawStorage(); + return (controller as any).getRawStorage(); }, - _clear(): Promise { + async _clear(): Promise { const controller = CoreManager.getLocalDatastoreController(); return controller.clear(); }, @@ -376,7 +372,7 @@ const LocalDatastore = { return `${OBJECT_PREFIX}${object.className}_${objectId}`; }, - getPinName(pinName: ?string) { + getPinName(pinName?: string) { if (!pinName || pinName === DEFAULT_PIN) { return DEFAULT_PIN; } diff --git a/src/LocalDatastoreController.default.js b/src/LocalDatastoreController.default.ts similarity index 86% rename from src/LocalDatastoreController.default.js rename to src/LocalDatastoreController.default.ts index 7116f28fd..29a1c36c8 100644 --- a/src/LocalDatastoreController.default.js +++ b/src/LocalDatastoreController.default.ts @@ -1,11 +1,8 @@ -/** - * @flow - */ import { isLocalDatastoreKey } from './LocalDatastoreUtils'; import Storage from './Storage'; const LocalDatastoreController = { - async fromPinWithName(name: string): Array { + async fromPinWithName(name: string): Promise> { const values = await Storage.getItemAsync(name); if (!values) { return []; @@ -23,7 +20,7 @@ const LocalDatastoreController = { return Storage.removeItemAsync(name); }, - async getAllContents(): Object { + async getAllContents(): Promise { const keys = await Storage.getAllKeysAsync(); return keys.reduce(async (previousPromise, key) => { const LDS = await previousPromise; @@ -40,7 +37,7 @@ const LocalDatastoreController = { }, // Used for testing - async getRawStorage(): Object { + async getRawStorage(): Promise { const keys = await Storage.getAllKeysAsync(); return keys.reduce(async (previousPromise, key) => { const LDS = await previousPromise; @@ -50,10 +47,10 @@ const LocalDatastoreController = { }, Promise.resolve({})); }, - async clear(): Promise { + async clear(): Promise { const keys = await Storage.getAllKeysAsync(); - const toRemove = []; + const toRemove: string[] = []; for (const key of keys) { if (isLocalDatastoreKey(key)) { toRemove.push(key); @@ -65,3 +62,4 @@ const LocalDatastoreController = { }; module.exports = LocalDatastoreController; +export default LocalDatastoreController; diff --git a/src/LocalDatastoreController.react-native.js b/src/LocalDatastoreController.react-native.ts similarity index 87% rename from src/LocalDatastoreController.react-native.js rename to src/LocalDatastoreController.react-native.ts index 74ebde95f..66324465f 100644 --- a/src/LocalDatastoreController.react-native.js +++ b/src/LocalDatastoreController.react-native.ts @@ -1,13 +1,8 @@ -/** - * @flow - * @private - */ - import { isLocalDatastoreKey } from './LocalDatastoreUtils'; const RNStorage = require('./StorageController.react-native'); const LocalDatastoreController = { - async fromPinWithName(name: string): Promise> { + async fromPinWithName(name: string): Promise> { const values = await RNStorage.getItemAsync(name); if (!values) { return []; @@ -30,9 +25,9 @@ const LocalDatastoreController = { return RNStorage.removeItemAsync(name); }, - async getAllContents(): Promise { + async getAllContents(): Promise { const keys = await RNStorage.getAllKeysAsync(); - const batch = []; + const batch: string[] = []; for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; if (isLocalDatastoreKey(key)) { @@ -40,7 +35,7 @@ const LocalDatastoreController = { } } const LDS = {}; - let results = []; + let results: any[] = []; try { results = await RNStorage.multiGet(batch); } catch (error) { @@ -59,7 +54,7 @@ const LocalDatastoreController = { }, // Used for testing - async getRawStorage(): Promise { + async getRawStorage(): Promise { const keys = await RNStorage.getAllKeysAsync(); const storage = {}; const results = await RNStorage.multiGet(keys); @@ -72,7 +67,7 @@ const LocalDatastoreController = { async clear(): Promise { const keys = await RNStorage.getAllKeysAsync(); - const batch = []; + const batch: string[] = []; for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; if (isLocalDatastoreKey(key)) { @@ -86,3 +81,4 @@ const LocalDatastoreController = { }; module.exports = LocalDatastoreController; +export default LocalDatastoreController; diff --git a/src/LocalDatastoreUtils.js b/src/LocalDatastoreUtils.ts similarity index 92% rename from src/LocalDatastoreUtils.js rename to src/LocalDatastoreUtils.ts index 9ce1fd4bc..bb165520d 100644 --- a/src/LocalDatastoreUtils.js +++ b/src/LocalDatastoreUtils.ts @@ -1,8 +1,3 @@ -/** - * @flow - * @private - */ - const DEFAULT_PIN = '_default'; const PIN_PREFIX = 'parsePin_'; const OBJECT_PREFIX = 'Parse_LDS_'; diff --git a/src/Parse.ts b/src/Parse.ts index 345efdcc9..a3f6de954 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -402,7 +402,7 @@ const Parse: ParseType = { * @param [ms] Milliseconds to ping the server. Default 2000ms * @static */ - enableLocalDatastore(polling = true, ms: number = 2000) { + enableLocalDatastore(polling = true, ms = 2000) { if (!this.applicationId) { console.log("'enableLocalDataStore' must be called after 'initialize'"); return; diff --git a/src/ParseCLP.js b/src/ParseCLP.ts similarity index 95% rename from src/ParseCLP.js rename to src/ParseCLP.ts index ff86e387a..541a3d149 100644 --- a/src/ParseCLP.js +++ b/src/ParseCLP.ts @@ -1,13 +1,9 @@ -/** - * @flow - */ - import ParseRole from './ParseRole'; import ParseUser from './ParseUser'; -type Entity = Entity; +type Entity = ParseUser | ParseRole | string; type UsersMap = { [userId: string]: boolean | any }; -export type PermissionsMap = { [permission: string]: UsersMap }; +export type PermissionsMap = { writeUserFields?: string[], readUserFields?: string[] } & { [permission: string]: UsersMap }; const PUBLIC_KEY = '*'; @@ -323,7 +319,7 @@ class ParseCLP { return permissions; } - _setArrayAccess(permission: string, userId: Entity, fields: string) { + _setArrayAccess(permission: string, userId: Entity, fields: string[]) { userId = this._parseEntity(userId); const permissions = this.permissionsMap[permission][userId]; @@ -356,8 +352,8 @@ class ParseCLP { } } - _getGroupPointerPermissions(operation: string): string[] { - return this.permissionsMap[operation]; + _getGroupPointerPermissions(operation: 'readUserFields' | 'writeUserFields'): string[] { + return this.permissionsMap[operation] || []; } /** @@ -373,7 +369,7 @@ class ParseCLP { * @returns {string[]} User pointer fields */ getReadUserFields(): string[] { - return this._getGroupPointerPermissions('readUserFields'); + return this._getGroupPointerPermissions('readUserFields') || []; } /** @@ -389,7 +385,7 @@ class ParseCLP { * @returns {string[]} User pointer fields */ getWriteUserFields(): string[] { - return this._getGroupPointerPermissions('writeUserFields'); + return this._getGroupPointerPermissions('writeUserFields') || []; } /** @@ -409,7 +405,7 @@ class ParseCLP { * @returns {string[]} */ getProtectedFields(userId: Entity): string[] { - return this._getAccess('protectedFields', userId, false); + return this._getAccess('protectedFields', userId, false) as string[]; } /** @@ -435,9 +431,9 @@ class ParseCLP { */ getReadAccess(userId: Entity): boolean { return ( - this._getAccess('find', userId) && - this._getAccess('get', userId) && - this._getAccess('count', userId) + this._getAccess('find', userId) as boolean && + this._getAccess('get', userId) as boolean && + this._getAccess('count', userId) as boolean ); } @@ -465,10 +461,10 @@ class ParseCLP { */ getWriteAccess(userId: Entity): boolean { return ( - this._getAccess('create', userId) && - this._getAccess('update', userId) && - this._getAccess('delete', userId) && - this._getAccess('addField', userId) + this._getAccess('create', userId) as boolean && + this._getAccess('update', userId) as boolean && + this._getAccess('delete', userId) as boolean && + this._getAccess('addField', userId) as boolean ); } diff --git a/src/ParseFile.ts b/src/ParseFile.ts index 8d8ae79b7..0d9ef880a 100644 --- a/src/ParseFile.ts +++ b/src/ParseFile.ts @@ -22,17 +22,17 @@ export type FileSource = | { format: 'file', file: Blob, - type: string, + type: string | undefined, } | { format: 'base64', base64: string, - type: string, + type: string | undefined, } | { format: 'uri', uri: string, - type: string, + type: string | undefined, }; function b64Digit(number: number): string { @@ -67,8 +67,8 @@ class ParseFile { _previousSave?: Promise; _data?: string; _requestTask?: any; - _metadata?: Object; - _tags?: Object; + _metadata?: object; + _tags?: object; /** * @param name {String} The file's name. This will be prefixed by a unique @@ -97,10 +97,10 @@ class ParseFile { * @param type {String} Optional Content-Type header to use for the file. If * this is omitted, the content type will be inferred from the name's * extension. - * @param metadata {Object} Optional key value pairs to be stored with file object - * @param tags {Object} Optional key value pairs to be stored with file object + * @param metadata {object} Optional key value pairs to be stored with file object + * @param tags {object} Optional key value pairs to be stored with file object */ - constructor(name: string, data?: FileData, type?: string, metadata?: Object, tags?: Object) { + constructor(name: string, data?: FileData, type?: string, metadata?: object, tags?: object) { const specifiedType = type || ''; this._name = name; @@ -184,6 +184,7 @@ class ParseFile { * after you get the file from a Parse.Object. * * @param {object} options An object to specify url options + * @param {boolean} [options.forceSecure] force the url to be secure * @returns {string | undefined} */ url(options?: { forceSecure?: boolean }): string | undefined { @@ -319,11 +320,11 @@ class ParseFile { } const destroyOptions = { useMasterKey: true }; if (options.hasOwnProperty('useMasterKey')) { - destroyOptions.useMasterKey = options.useMasterKey; + destroyOptions.useMasterKey = !!options.useMasterKey; } const controller = CoreManager.getFileController(); return controller.deleteFile(this._name, destroyOptions).then(() => { - this._data = null; + this._data = undefined; this._requestTask = null; return this; }); @@ -433,7 +434,7 @@ class ParseFile { } const DefaultController = { - saveFile: async function (name: string, source: FileSource, options?: FullOptions) { + saveFile: async function (name: string, source: FileSource, options?: FileSaveOptions) { if (source.format !== 'file') { throw new Error('saveFile can only be used with File-type sources.'); } @@ -452,17 +453,17 @@ const DefaultController = { const data = second ? second : first; const newSource = { format: 'base64' as const, - base64: data, + base64: data as string, type: source.type || (source.file ? source.file.type : undefined), }; return await DefaultController.saveBase64(name, newSource, options); }, - saveBase64: function (name: string, source: FileSource, options?: FullOptions) { + saveBase64: function (name: string, source: FileSource, options: FileSaveOptions = {}) { if (source.format !== 'base64') { throw new Error('saveBase64 can only be used with Base64-type sources.'); } - const data: { base64: any, _ContentType?: any, fileData: Object } = { + const data: { base64: any, _ContentType?: any, fileData: any } = { base64: source.base64, fileData: { metadata: { ...options.metadata }, diff --git a/src/ParseInstallation.ts b/src/ParseInstallation.ts index 8e9bce4da..ee7c580fc 100644 --- a/src/ParseInstallation.ts +++ b/src/ParseInstallation.ts @@ -51,6 +51,7 @@ class ParseInstallation extends ParseObject { * * @property {string} appIdentifier * @static + * @returns {string} */ get appIdentifier() { return this.get('appIdentifier'); @@ -61,6 +62,7 @@ class ParseInstallation extends ParseObject { * * @property {string} appVersion * @static + * @returns {string} */ get appVersion() { return this.get('appVersion'); @@ -71,6 +73,7 @@ class ParseInstallation extends ParseObject { * * @property {string} appName * @static + * @returns {string} */ get appName() { return this.get('appName'); @@ -83,6 +86,7 @@ class ParseInstallation extends ParseObject { * * @property {number} badge * @static + * @returns {number} */ get badge() { return this.get('badge'); @@ -93,6 +97,7 @@ class ParseInstallation extends ParseObject { * * @property {string[]} channels * @static + * @returns {string[]} */ get channels() { return this.get('channels'); @@ -103,6 +108,7 @@ class ParseInstallation extends ParseObject { * * @property {string} deviceToken * @static + * @returns {string} */ get deviceToken() { return this.get('deviceToken'); @@ -113,6 +119,7 @@ class ParseInstallation extends ParseObject { * * @property {string} deviceType * @static + * @returns {string} */ get deviceType() { return this.get('deviceType'); @@ -123,6 +130,7 @@ class ParseInstallation extends ParseObject { * * @property {string} GCMSenderId * @static + * @returns {string} */ get GCMSenderId() { return this.get('GCMSenderId'); @@ -133,6 +141,7 @@ class ParseInstallation extends ParseObject { * * @property {string} installationId * @static + * @returns {string} */ get installationId() { return this.get('installationId'); @@ -143,6 +152,7 @@ class ParseInstallation extends ParseObject { * * @property {string} localeIdentifier * @static + * @returns {string} */ get localeIdentifier() { return this.get('localeIdentifier'); @@ -153,6 +163,7 @@ class ParseInstallation extends ParseObject { * * @property {string} parseVersion * @static + * @returns {string} */ get parseVersion() { return this.get('parseVersion'); @@ -163,6 +174,7 @@ class ParseInstallation extends ParseObject { * * @property {string} pushType * @static + * @returns {string} */ get pushType() { return this.get('pushType'); @@ -173,6 +185,7 @@ class ParseInstallation extends ParseObject { * * @property {string} timeZone * @static + * @returns {string} */ get timeZone() { return this.get('timeZone'); @@ -192,6 +205,7 @@ class ParseInstallation extends ParseObject { * * @property {object} DEVICE_TYPES * @static + * @returns {object} */ static get DEVICE_TYPES(): DeviceInterface { return DEVICE_TYPES; @@ -232,7 +246,7 @@ class ParseInstallation extends ParseObject { async save(...args: Array): Promise { try { await super.save.apply(this, args); - } catch (e) { + } catch (e) { if (e.code !== ParseError.OBJECT_NOT_FOUND) { throw e; } diff --git a/src/ParseObject.ts b/src/ParseObject.ts index 0c3c9f4cd..3dd26eb7f 100644 --- a/src/ParseObject.ts +++ b/src/ParseObject.ts @@ -104,6 +104,7 @@ class ParseObject { * @param {string} className The class name for the object * @param {object} attributes The initial set of data to store in the object. * @param {object} options The options for this object instance. + * @param {boolean} [options.ignoreValidation=false] Set to `true` ignore any attribute validation errors. */ constructor( className?: string | { className: string, [attr: string]: any }, @@ -1192,7 +1193,7 @@ class ParseObject { * @returns {Promise} A promise that is fulfilled when the fetch * completes. */ - fetchWithInclude(keys: String | Array>, options: RequestOptions): Promise { + fetchWithInclude(keys: string | Array>, options: RequestOptions): Promise { options = options || {}; options.include = keys; return this.fetch(options); @@ -1605,7 +1606,7 @@ class ParseObject { */ static fetchAllWithInclude( list: Array, - keys: String | Array>, + keys: string | Array>, options: RequestOptions ) { options = options || {}; @@ -1645,7 +1646,7 @@ class ParseObject { */ static fetchAllIfNeededWithInclude( list: Array, - keys: String | Array>, + keys: string | Array>, options: RequestOptions ) { options = options || {}; diff --git a/src/ParseOp.js b/src/ParseOp.js index 2a0d4f494..d31a193a4 100644 --- a/src/ParseOp.js +++ b/src/ParseOp.js @@ -57,20 +57,20 @@ export function opFromJSON(json: { [key: string]: any }): ?Op { export class Op { // Empty parent class - applyTo(value: mixed): mixed {} /* eslint-disable-line no-unused-vars */ - mergeWith(previous: Op): ?Op {} /* eslint-disable-line no-unused-vars */ - toJSON(): mixed {} + applyTo(value: any): any {} /* eslint-disable-line @typescript-eslint/no-unused-vars */ + mergeWith(previous: Op): ?Op {} /* eslint-disable-line @typescript-eslint/no-unused-vars */ + toJSON(): any {} } export class SetOp extends Op { - _value: ?mixed; + _value: ?any; - constructor(value: mixed) { + constructor(value: any) { super(); this._value = value; } - applyTo(): mixed { + applyTo(): any { return this._value; } @@ -108,7 +108,7 @@ export class IncrementOp extends Op { this._amount = amount; } - applyTo(value: ?mixed): number { + applyTo(value: ?any): number { if (typeof value === 'undefined') { return this._amount; } @@ -140,14 +140,14 @@ export class IncrementOp extends Op { } export class AddOp extends Op { - _value: Array; + _value: Array; - constructor(value: mixed | Array) { + constructor(value: any | Array) { super(); this._value = Array.isArray(value) ? value : [value]; } - applyTo(value: mixed): Array { + applyTo(value: any): Array { if (value == null) { return this._value; } @@ -173,20 +173,20 @@ export class AddOp extends Op { throw new Error('Cannot merge Add Op with the previous Op'); } - toJSON(): { __op: string, objects: mixed } { + toJSON(): { __op: string, objects: any } { return { __op: 'Add', objects: encode(this._value, false, true) }; } } export class AddUniqueOp extends Op { - _value: Array; + _value: Array; - constructor(value: mixed | Array) { + constructor(value: any | Array) { super(); this._value = unique(Array.isArray(value) ? value : [value]); } - applyTo(value: mixed | Array): Array { + applyTo(value: any | Array): Array { if (value == null) { return this._value || []; } @@ -225,20 +225,20 @@ export class AddUniqueOp extends Op { throw new Error('Cannot merge AddUnique Op with the previous Op'); } - toJSON(): { __op: string, objects: mixed } { + toJSON(): { __op: string, objects: any } { return { __op: 'AddUnique', objects: encode(this._value, false, true) }; } } export class RemoveOp extends Op { - _value: Array; + _value: Array; - constructor(value: mixed | Array) { + constructor(value: any | Array) { super(); this._value = unique(Array.isArray(value) ? value : [value]); } - applyTo(value: mixed | Array): Array { + applyTo(value: any | Array): Array { if (value == null) { return []; } @@ -295,7 +295,7 @@ export class RemoveOp extends Op { throw new Error('Cannot merge Remove Op with the previous Op'); } - toJSON(): { __op: string, objects: mixed } { + toJSON(): { __op: string, objects: any } { return { __op: 'Remove', objects: encode(this._value, false, true) }; } } @@ -340,7 +340,7 @@ export class RelationOp extends Op { return obj.id; } - applyTo(value: mixed, parent: ParseObject, key?: string): ?ParseRelation { + applyTo(value: any, parent: ParseObject, key?: string): ?ParseRelation { if (!value) { if (!parent || !key) { throw new Error( @@ -425,7 +425,7 @@ export class RelationOp extends Op { throw new Error('Cannot merge Relation Op with the previous Op'); } - toJSON(): { __op?: string, objects?: mixed, ops?: mixed } { + toJSON(): { __op?: string, objects?: any, ops?: any } { const idToPointer = id => { return { __type: 'Pointer', diff --git a/src/ParsePolygon.js b/src/ParsePolygon.js index a7887ea02..828fb9594 100644 --- a/src/ParsePolygon.js +++ b/src/ParsePolygon.js @@ -67,7 +67,7 @@ class ParsePolygon { * @param {(Parse.Polygon | object)} other * @returns {boolean} */ - equals(other: mixed): boolean { + equals(other: any): boolean { if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) { return false; } diff --git a/src/ParseQuery.ts b/src/ParseQuery.ts index 47a548624..5da1a4c60 100644 --- a/src/ParseQuery.ts +++ b/src/ParseQuery.ts @@ -762,6 +762,8 @@ class ParseQuery { * Counts the number of objects that match this query. * * @param {object} options + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] * Valid options are:
    *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -799,10 +801,7 @@ class ParseQuery { * * @param {string} key A field to find distinct values * @param {object} options - * Valid options are:
      - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. * @returns {Promise} A promise that is resolved with the query completes. */ distinct(key: string, options?: { sessionToken?: string }): Promise> { @@ -830,10 +829,8 @@ class ParseQuery { * Executes an aggregate query and returns aggregate results * * @param {(Array|object)} pipeline Array or Object of stages to process query - * @param {object} options Valid options are:
      - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    + * @param {object} options + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. * @returns {Promise} A promise that is resolved with the query completes. */ aggregate(pipeline: any, options?: { sessionToken?: string }): Promise> { @@ -1087,7 +1084,7 @@ class ParseQuery { * @param {boolean} explain Used to toggle the information on the query plan. * @returns {Parse.Query} Returns the query, so you can chain this call. */ - explain(explain: boolean = true): ParseQuery { + explain(explain = true): ParseQuery { if (typeof explain !== 'boolean') { throw new Error('You can only set explain to a boolean value'); } @@ -1366,13 +1363,12 @@ class ParseQuery { * @returns {Parse.Query} Returns the query, so you can chain this call. */ containsAllStartingWith(key: string, values: Array): ParseQuery { - const _this = this; if (!Array.isArray(values)) { values = [values]; } const regexObject = values.map(value => { - return { $regex: _this._regexStartWith(value) }; + return { $regex: this._regexStartWith(value) }; }); return this.containsAll(key, regexObject); @@ -1871,7 +1867,7 @@ class ParseQuery { * @param {boolean} includeCount false - disable, true - enable. * @returns {Parse.Query} Returns the query, so you can chain this call. */ - withCount(includeCount: boolean = true): ParseQuery { + withCount(includeCount = true): ParseQuery { if (typeof includeCount !== 'boolean') { throw new Error('You can only set withCount to a boolean value'); } diff --git a/src/ParseSchema.js b/src/ParseSchema.js index 089cddd32..38cfc9ab4 100644 --- a/src/ParseSchema.js +++ b/src/ParseSchema.js @@ -25,7 +25,7 @@ const FIELD_TYPES = [ type FieldOptions = { required: boolean, - defaultValue: mixed, + defaultValue: any, }; /** @@ -47,9 +47,9 @@ type FieldOptions = { */ class ParseSchema { className: string; - _fields: { [key: string]: mixed }; - _indexes: { [key: string]: mixed }; - _clp: { [key: string]: mixed }; + _fields: { [key: string]: any }; + _indexes: { [key: string]: any }; + _clp: { [key: string]: any }; /** * @param {string} className Parse Class string. diff --git a/src/ParseUser.ts b/src/ParseUser.ts index 48a0c2a66..75756a70e 100644 --- a/src/ParseUser.ts +++ b/src/ParseUser.ts @@ -74,6 +74,7 @@ class ParseUser extends ParseObject { * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users} * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} * @param {object} options + * @param {object} [options.authData] AuthData to link with *
      *
    • If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData} *
    • If provider is AuthProvider, options is saveOpts @@ -148,6 +149,7 @@ class ParseUser extends ParseObject { /** * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} * @returns {Promise} @@ -795,6 +797,7 @@ class ParseUser extends ParseObject { * * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @static * @returns {Promise} @@ -977,6 +980,7 @@ class ParseUser extends ParseObject { /** * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith} * @static diff --git a/src/RESTController.js b/src/RESTController.js index 59090e76e..a6e8cec60 100644 --- a/src/RESTController.js +++ b/src/RESTController.js @@ -207,7 +207,7 @@ const RESTController = { return promise; }, - request(method: string, path: string, data: mixed, options?: RequestOptions) { + request(method: string, path: string, data: any, options?: RequestOptions) { options = options || {}; let url = CoreManager.get('SERVER_URL'); if (url[url.length - 1] !== '/') { diff --git a/src/SingleInstanceStateController.js b/src/SingleInstanceStateController.js index 01065bcde..9bf086860 100644 --- a/src/SingleInstanceStateController.js +++ b/src/SingleInstanceStateController.js @@ -99,7 +99,7 @@ export function getObjectCache(obj: ObjectIdentifier): ObjectCache { return {}; } -export function estimateAttribute(obj: ObjectIdentifier, attr: string): mixed { +export function estimateAttribute(obj: ObjectIdentifier, attr: string): any { const serverData = getServerData(obj); const pendingOps = getPendingOps(obj); return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr); diff --git a/src/UniqueInstanceStateController.js b/src/UniqueInstanceStateController.js index 7f82777af..24633ef9f 100644 --- a/src/UniqueInstanceStateController.js +++ b/src/UniqueInstanceStateController.js @@ -93,7 +93,7 @@ export function getObjectCache(obj: ParseObject): ObjectCache { return {}; } -export function estimateAttribute(obj: ParseObject, attr: string): mixed { +export function estimateAttribute(obj: ParseObject, attr: string): any { const serverData = getServerData(obj); const pendingOps = getPendingOps(obj); return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr); diff --git a/src/__tests__/LocalDatastore-test.js b/src/__tests__/LocalDatastore-test.js index 0cc944062..fa0fdf04f 100644 --- a/src/__tests__/LocalDatastore-test.js +++ b/src/__tests__/LocalDatastore-test.js @@ -723,7 +723,7 @@ describe('LocalDatastore', () => { expect(LocalDatastore.isSyncing).toBe(false); }); - it('updateFromServer on mixed object', async () => { + it('updateFromServer on any object', async () => { LocalDatastore.isEnabled = true; LocalDatastore.isSyncing = false; const testObject = new ParseObject('TestObject'); diff --git a/src/__tests__/ParseFile-test.js b/src/__tests__/ParseFile-test.js index c5d9e7465..f86b010df 100644 --- a/src/__tests__/ParseFile-test.js +++ b/src/__tests__/ParseFile-test.js @@ -1,4 +1,3 @@ -/* global File */ jest.autoMockOff(); jest.mock('http'); jest.mock('https'); @@ -20,8 +19,8 @@ const mockLocalDatastore = { if (!mockLocalDatastore.isEnabled) { return; } - /* eslint-disable no-unused-vars */ // (Taken from LocalDataStore source) This fails for nested objects that are not ParseObject + /* eslint-disable @typescript-eslint/no-unused-vars */ const objectKey = mockLocalDatastore.getKeyForObject(object); }), _updateObjectIfPinned: jest.fn(), diff --git a/src/__tests__/ParseObject-test.js b/src/__tests__/ParseObject-test.js index e608346a3..0a752cee1 100644 --- a/src/__tests__/ParseObject-test.js +++ b/src/__tests__/ParseObject-test.js @@ -121,7 +121,7 @@ const mockLocalDatastore = { if (!mockLocalDatastore.isEnabled) { return; } - /* eslint-disable no-unused-vars */ + /* eslint-disable @typescript-eslint/no-unused-vars */ // (Taken from LocalDataStore source) This fails for nested objects that are not ParseObject const objectKey = mockLocalDatastore.getKeyForObject(object); }), diff --git a/src/interfaces/AuthProvider.js b/src/interfaces/AuthProvider.js index 06df2afc3..933eb5b70 100644 --- a/src/interfaces/AuthProvider.js +++ b/src/interfaces/AuthProvider.js @@ -1,4 +1,4 @@ -/* eslint no-unused-vars: "off" */ +/* eslint-disable @typescript-eslint/no-unused-vars */ /** * @flow */ diff --git a/src/interfaces/xmlhttprequest.js b/src/interfaces/xmlhttprequest.js index afcba1d3f..271ae4e54 100644 --- a/src/interfaces/xmlhttprequest.js +++ b/src/interfaces/xmlhttprequest.js @@ -1,4 +1,4 @@ -/* eslint-disable no-unused-vars */ +/* eslint-disable */ declare module xmlhttprequest { declare var XMLHttpRequest: () => XMLHttpRequest; } diff --git a/types/Cloud.d.ts b/types/Cloud.d.ts index 7af0228fc..6c07bafdb 100644 --- a/types/Cloud.d.ts +++ b/types/Cloud.d.ts @@ -1,4 +1,5 @@ -// @ts-nocheck +import ParseObject from './ParseObject'; +import type { RequestOptions } from './RESTController'; /** * Contains functions for calling and declaring * cloud functions. @@ -21,7 +22,7 @@ * @returns {Promise} A promise that will be resolved with the result * of the function. */ -export function run(name: string, data: mixed, options: RequestOptions): Promise; +export declare function run(name: string, data: any, options: RequestOptions): Promise; /** * Gets data for the current set of cloud jobs. * @@ -30,7 +31,7 @@ export function run(name: string, data: mixed, options: RequestOptions): Promise * @returns {Promise} A promise that will be resolved with the result * of the function. */ -export function getJobsData(): Promise; +export declare function getJobsData(): Promise; /** * Starts a given cloud job, which will process asynchronously. * @@ -41,7 +42,7 @@ export function getJobsData(): Promise; * @returns {Promise} A promise that will be resolved with the jobStatusId * of the job. */ -export function startJob(name: string, data: mixed): Promise; +export declare function startJob(name: string, data: any): Promise; /** * Gets job status by Id * @@ -50,6 +51,4 @@ export function startJob(name: string, data: mixed): Promise; * @param {string} jobStatusId The Id of Job Status. * @returns {Parse.Object} Status of Job. */ -export function getJobStatus(jobStatusId: string): Promise; -import { RequestOptions } from './RESTController'; -import ParseObject from './ParseObject'; +export declare function getJobStatus(jobStatusId: string): Promise; diff --git a/types/LiveQueryClient.d.ts b/types/LiveQueryClient.d.ts index dc42292da..19f19c33f 100644 --- a/types/LiveQueryClient.d.ts +++ b/types/LiveQueryClient.d.ts @@ -1,8 +1,8 @@ -// @ts-nocheck -export default LiveQueryClient; +import { WebSocketController } from './CoreManager'; +import LiveQuerySubscription from './LiveQuerySubscription'; +import type ParseQuery from './ParseQuery'; /** * Creates a new LiveQueryClient. - * Extends events.EventEmitter * cloud functions. * * A wrapper of a standard WebSocket client. We add several useful methods to @@ -45,6 +45,26 @@ export default LiveQueryClient; * @alias Parse.LiveQueryClient */ declare class LiveQueryClient { + attempts: number; + id: number; + requestId: number; + applicationId: string; + serverURL: string; + javascriptKey?: string; + masterKey?: string; + sessionToken?: string; + installationId?: string; + additionalProperties: boolean; + connectPromise: any; + subscriptions: Map; + socket: WebSocketController & { + closingPromise?: any; + }; + state: string; + reconnectHandle: any; + emitter: any; + on: any; + emit: any; /** * @param {object} options * @param {string} options.applicationId - applicationId of your Parse app @@ -55,28 +75,13 @@ declare class LiveQueryClient { * @param {string} options.installationId (optional) */ constructor({ applicationId, serverURL, javascriptKey, masterKey, sessionToken, installationId, }: { - applicationId: string; - serverURL: string; - javascriptKey: string; - masterKey: string; - sessionToken: string; - installationId: string; + applicationId: any; + serverURL: any; + javascriptKey: any; + masterKey: any; + sessionToken: any; + installationId: any; }); - attempts: number; - id: number; - requestId: number; - applicationId: string; - serverURL: string; - javascriptKey: string | null; - masterKey: string | null; - sessionToken: string | null; - installationId: string | null; - additionalProperties: boolean; - connectPromise: Promise; - subscriptions: Map; - socket: any; - state: string; - reconnectHandle: NodeJS.Timeout; shouldOpen(): any; /** * Subscribes to a ParseQuery @@ -88,18 +93,18 @@ declare class LiveQueryClient { * here for more details. The subscription you get is the same subscription you get * from our Standard API. * - * @param {object} query - the ParseQuery you want to subscribe to + * @param {ParseQuery} query - the ParseQuery you want to subscribe to * @param {string} sessionToken (optional) * @returns {LiveQuerySubscription | undefined} */ - subscribe(query: Object, sessionToken: string | null): LiveQuerySubscription; + subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined; /** * After calling unsubscribe you'll stop receiving events from the subscription object. * * @param {object} subscription - subscription you would like to unsubscribe from. * @returns {Promise | undefined} */ - unsubscribe(subscription: Object): Promise | null; + unsubscribe(subscription: LiveQuerySubscription): Promise; /** * After open is called, the LiveQueryClient will try to send a connect request * to the LiveQuery server. @@ -113,7 +118,7 @@ declare class LiveQueryClient { * * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event} */ - close(): Promise | null; + close(): Promise; _handleReset(): void; _handleWebSocketOpen(): void; _handleWebSocketMessage(event: any): void; @@ -121,4 +126,4 @@ declare class LiveQueryClient { _handleWebSocketError(error: any): void; _handleReconnect(): void; } -import LiveQuerySubscription from './LiveQuerySubscription'; +export default LiveQueryClient; diff --git a/types/LocalDatastore.d.ts b/types/LocalDatastore.d.ts index c8f461765..8508577dd 100644 --- a/types/LocalDatastore.d.ts +++ b/types/LocalDatastore.d.ts @@ -1,22 +1,42 @@ -export default LocalDatastore; -declare namespace LocalDatastore { - let isEnabled: boolean; - let isSyncing: boolean; - function fromPinWithName(name: string): Promise; - function pinWithName(name: string, value: any): Promise; - function unPinWithName(name: string): Promise; - function _getAllContents(): Promise; - function _getRawStorage(): Promise; - function _clear(): Promise; - function _handlePinAllWithName(name: string, objects: ParseObject[]): Promise; - function _handleUnPinAllWithName(name: string, objects: ParseObject[]): Promise; - function _getChildren(object: ParseObject): {}; - function _traverse(object: any, encountered: any): void; - function _serializeObjectsFromPinName(name: string): Promise; - function _serializeObject(objectKey: string, localDatastore: any): Promise; - function _updateObjectIfPinned(object: ParseObject): Promise; - function _destroyObjectIfPinned(object: ParseObject): Promise; - function _updateLocalIdForObject(localId: string, object: ParseObject): Promise; +import type ParseObject from './ParseObject'; +/** + * Provides a local datastore which can be used to store and retrieve Parse.Object.
      + * To enable this functionality, call Parse.enableLocalDatastore(). + * + * Pin object to add to local datastore + * + *
      await object.pin();
      + *
      await object.pinWithName('pinName');
      + * + * Query pinned objects + * + *
      query.fromLocalDatastore();
      + *
      query.fromPin();
      + *
      query.fromPinWithName();
      + * + *
      const localObjects = await query.find();
      + * + * @class Parse.LocalDatastore + * @static + */ +declare const LocalDatastore: { + isEnabled: boolean; + isSyncing: boolean; + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + _getAllContents(): Promise; + _getRawStorage(): Promise; + _clear(): Promise; + _handlePinAllWithName(name: string, objects: Array): Promise; + _handleUnPinAllWithName(name: string, objects: Array): Promise; + _getChildren(object: ParseObject): {}; + _traverse(object: any, encountered: any): void; + _serializeObjectsFromPinName(name: string): Promise; + _serializeObject(objectKey: string, localDatastore: any): Promise; + _updateObjectIfPinned(object: ParseObject): Promise; + _destroyObjectIfPinned(object: ParseObject): Promise; + _updateLocalIdForObject(localId: string, object: ParseObject): Promise; /** * Updates Local Datastore from Server * @@ -28,9 +48,9 @@ declare namespace LocalDatastore { * @name Parse.LocalDatastore.updateFromServer * @static */ - function updateFromServer(): Promise; - function getKeyForObject(object: any): string; - function getPinName(pinName: string): string; - function checkIfEnabled(): boolean; -} -import ParseObject from './ParseObject'; + updateFromServer(): Promise; + getKeyForObject(object: any): string; + getPinName(pinName?: string): string; + checkIfEnabled(): any; +}; +export default LocalDatastore; diff --git a/types/LocalDatastoreController.default.d.ts b/types/LocalDatastoreController.default.d.ts new file mode 100644 index 000000000..8ccbb01b6 --- /dev/null +++ b/types/LocalDatastoreController.default.d.ts @@ -0,0 +1,9 @@ +declare const LocalDatastoreController: { + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): any; + unPinWithName(name: string): any; + getAllContents(): Promise; + getRawStorage(): Promise; + clear(): Promise; +}; +export default LocalDatastoreController; diff --git a/types/LocalDatastoreController.react-native.d.ts b/types/LocalDatastoreController.react-native.d.ts index cb0ff5c3b..2db09d794 100644 --- a/types/LocalDatastoreController.react-native.d.ts +++ b/types/LocalDatastoreController.react-native.d.ts @@ -1 +1,9 @@ -export {}; +declare const LocalDatastoreController: { + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + getAllContents(): Promise; + getRawStorage(): Promise; + clear(): Promise; +}; +export default LocalDatastoreController; diff --git a/types/LocalDatastoreUtils.d.ts b/types/LocalDatastoreUtils.d.ts index 3fba166c3..7472e6570 100644 --- a/types/LocalDatastoreUtils.d.ts +++ b/types/LocalDatastoreUtils.d.ts @@ -1,8 +1,5 @@ -/** - * @flow - * @private - */ -export const DEFAULT_PIN: "_default"; -export const PIN_PREFIX: "parsePin_"; -export const OBJECT_PREFIX: "Parse_LDS_"; -export function isLocalDatastoreKey(key: string): boolean; +declare const DEFAULT_PIN = "_default"; +declare const PIN_PREFIX = "parsePin_"; +declare const OBJECT_PREFIX = "Parse_LDS_"; +declare function isLocalDatastoreKey(key: string): boolean; +export { DEFAULT_PIN, PIN_PREFIX, OBJECT_PREFIX, isLocalDatastoreKey }; diff --git a/types/ParseCLP.d.ts b/types/ParseCLP.d.ts index 14b36e7d3..eaa7d6b26 100644 --- a/types/ParseCLP.d.ts +++ b/types/ParseCLP.d.ts @@ -1,11 +1,15 @@ -type PermissionsMap = { - [permission: string]: UsersMap; -}; -export default ParseCLP; +import ParseRole from './ParseRole'; +import ParseUser from './ParseUser'; +type Entity = ParseUser | ParseRole | string; type UsersMap = { - [userId: string]: any; + [userId: string]: boolean | any; +}; +export type PermissionsMap = { + writeUserFields?: string[]; + readUserFields?: string[]; +} & { + [permission: string]: UsersMap; }; -declare const UsersMap: any; /** * Creates a new CLP. * If no argument is given, the CLP has no permissions for anyone. @@ -99,11 +103,11 @@ declare const UsersMap: any; * @alias Parse.CLP */ declare class ParseCLP { + permissionsMap: PermissionsMap; /** * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for */ constructor(userId: ParseUser | ParseRole | PermissionsMap); - permissionsMap: PermissionsMap; /** * Returns a JSON-encoded version of the CLP. * @@ -118,12 +122,12 @@ declare class ParseCLP { */ equals(other: ParseCLP): boolean; _getRoleName(role: ParseRole | string): string; - _parseEntity(entity: any): string; - _setAccess(permission: string, userId: any, allowed: boolean): void; - _getAccess(permission: string, userId: any, returnBoolean?: boolean): boolean | string[]; - _setArrayAccess(permission: string, userId: any, fields: string): void; + _parseEntity(entity: Entity): string; + _setAccess(permission: string, userId: Entity, allowed: boolean): void; + _getAccess(permission: string, userId: Entity, returnBoolean?: boolean): boolean | string[]; + _setArrayAccess(permission: string, userId: Entity, fields: string[]): void; _setGroupPointerPermission(operation: string, pointerFields: string[]): void; - _getGroupPointerPermissions(operation: string): string[]; + _getGroupPointerPermissions(operation: 'readUserFields' | 'writeUserFields'): string[]; /** * Sets user pointer fields to allow permission for get/count/find operations. * @@ -150,21 +154,21 @@ declare class ParseCLP { * @param userId An instance of Parse.User or its objectId. * @param {string[]} fields fields to be protected */ - setProtectedFields(userId: any, fields: string[]): void; + setProtectedFields(userId: Entity, fields: string[]): void; /** * Returns array of fields are accessable to this user. * * @param userId An instance of Parse.User or its objectId, or a Parse.Role. * @returns {string[]} */ - getProtectedFields(userId: any): string[]; + getProtectedFields(userId: Entity): string[]; /** * Sets whether the given user is allowed to read from this class. * * @param userId An instance of Parse.User or its objectId. * @param {boolean} allowed whether that user should have read access. */ - setReadAccess(userId: any, allowed: boolean): void; + setReadAccess(userId: Entity, allowed: boolean): void; /** * Get whether the given user id is *explicitly* allowed to read from this class. * Even if this returns false, the user may still be able to access it if @@ -174,14 +178,14 @@ declare class ParseCLP { * @param userId An instance of Parse.User or its objectId, or a Parse.Role. * @returns {boolean} */ - getReadAccess(userId: any): boolean; + getReadAccess(userId: Entity): boolean; /** * Sets whether the given user id is allowed to write to this class. * * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. * @param {boolean} allowed Whether that user should have write access. */ - setWriteAccess(userId: any, allowed: boolean): void; + setWriteAccess(userId: Entity, allowed: boolean): void; /** * Gets whether the given user id is *explicitly* allowed to write to this class. * Even if this returns false, the user may still be able to write it if @@ -191,7 +195,7 @@ declare class ParseCLP { * @param userId An instance of Parse.User or its objectId, or a Parse.Role. * @returns {boolean} */ - getWriteAccess(userId: any): boolean; + getWriteAccess(userId: Entity): boolean; /** * Sets whether the public is allowed to read from this class. * @@ -286,5 +290,4 @@ declare class ParseCLP { */ setRoleProtectedFields(role: ParseRole | string, fields: string[]): void; } -import ParseRole from './ParseRole'; -import ParseUser from './ParseUser'; +export default ParseCLP; diff --git a/types/ParseFile.d.ts b/types/ParseFile.d.ts index ce3a09942..5ac7c3407 100644 --- a/types/ParseFile.d.ts +++ b/types/ParseFile.d.ts @@ -17,15 +17,15 @@ export type FileSaveOptions = FullOptions & { export type FileSource = { format: 'file'; file: Blob; - type: string; + type: string | undefined; } | { format: 'base64'; base64: string; - type: string; + type: string | undefined; } | { format: 'uri'; uri: string; - type: string; + type: string | undefined; }; /** * A Parse.File is a local representation of a file that is saved to the Parse @@ -40,8 +40,8 @@ declare class ParseFile { _previousSave?: Promise; _data?: string; _requestTask?: any; - _metadata?: Object; - _tags?: Object; + _metadata?: object; + _tags?: object; /** * @param name {String} The file's name. This will be prefixed by a unique * value once the file has finished saving. The file name must begin with @@ -69,10 +69,10 @@ declare class ParseFile { * @param type {String} Optional Content-Type header to use for the file. If * this is omitted, the content type will be inferred from the name's * extension. - * @param metadata {Object} Optional key value pairs to be stored with file object - * @param tags {Object} Optional key value pairs to be stored with file object + * @param metadata {object} Optional key value pairs to be stored with file object + * @param tags {object} Optional key value pairs to be stored with file object */ - constructor(name: string, data?: FileData, type?: string, metadata?: Object, tags?: Object); + constructor(name: string, data?: FileData, type?: string, metadata?: object, tags?: object); /** * Return the data for the file, downloading it if not already present. * Data is present if initialized with Byte Array, Base64 or Saved with Uri. @@ -94,6 +94,7 @@ declare class ParseFile { * after you get the file from a Parse.Object. * * @param {object} options An object to specify url options + * @param {boolean} [options.forceSecure] force the url to be secure * @returns {string | undefined} */ url(options?: { @@ -104,13 +105,13 @@ declare class ParseFile { * * @returns {object} */ - metadata(): Object; + metadata(): object; /** * Gets the tags of the file. * * @returns {object} */ - tags(): Object; + tags(): object; /** * Saves the file to the Parse cloud. * diff --git a/types/ParseInstallation.d.ts b/types/ParseInstallation.d.ts index a7c599fc3..2f07cd594 100644 --- a/types/ParseInstallation.d.ts +++ b/types/ParseInstallation.d.ts @@ -29,6 +29,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} appIdentifier * @static + * @returns {string} */ get appIdentifier(): any; /** @@ -36,6 +37,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} appVersion * @static + * @returns {string} */ get appVersion(): any; /** @@ -43,6 +45,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} appName * @static + * @returns {string} */ get appName(): any; /** @@ -52,6 +55,7 @@ declare class ParseInstallation extends ParseObject { * * @property {number} badge * @static + * @returns {number} */ get badge(): any; /** @@ -59,6 +63,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string[]} channels * @static + * @returns {string[]} */ get channels(): any; /** @@ -66,6 +71,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} deviceToken * @static + * @returns {string} */ get deviceToken(): any; /** @@ -73,6 +79,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} deviceType * @static + * @returns {string} */ get deviceType(): any; /** @@ -80,6 +87,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} GCMSenderId * @static + * @returns {string} */ get GCMSenderId(): any; /** @@ -87,6 +95,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} installationId * @static + * @returns {string} */ get installationId(): any; /** @@ -94,6 +103,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} localeIdentifier * @static + * @returns {string} */ get localeIdentifier(): any; /** @@ -101,6 +111,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} parseVersion * @static + * @returns {string} */ get parseVersion(): any; /** @@ -108,6 +119,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} pushType * @static + * @returns {string} */ get pushType(): any; /** @@ -115,6 +127,7 @@ declare class ParseInstallation extends ParseObject { * * @property {string} timeZone * @static + * @returns {string} */ get timeZone(): any; /** @@ -131,15 +144,26 @@ declare class ParseInstallation extends ParseObject { * * @property {object} DEVICE_TYPES * @static + * @returns {object} */ static get DEVICE_TYPES(): DeviceInterface; /** - * Wrap the default save behavior with functionality to save to local storage. + * Wrap the default fetch behavior with functionality to update local storage. + * If the installation is deleted on the server, retry the fetch as a save operation. + * + * @param {...any} args + * @returns {Promise} + */ + fetch(...args: Array): Promise; + /** + * Wrap the default save behavior with functionality to update the local storage. + * If the installation is deleted on the server, retry saving a new installation. * * @param {...any} args * @returns {Promise} */ save(...args: Array): Promise; + _markAllFieldsDirty(): void; /** * Get the current Parse.Installation from disk. If doesn't exists, create an new installation. * diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index 00c400d14..38dd2822a 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -50,6 +50,7 @@ declare class ParseObject { * @param {string} className The class name for the object * @param {object} attributes The initial set of data to store in the object. * @param {object} options The options for this object instance. + * @param {boolean} [options.ignoreValidation=false] Set to `true` ignore any attribute validation errors. */ constructor(className?: string | { className: string; @@ -440,7 +441,7 @@ declare class ParseObject { * @returns {Promise} A promise that is fulfilled when the fetch * completes. */ - fetchWithInclude(keys: String | Array>, options: RequestOptions): Promise; + fetchWithInclude(keys: string | Array>, options: RequestOptions): Promise; /** * Saves this object to the server at some unspecified time in the future, * even if Parse is currently inaccessible. @@ -706,7 +707,7 @@ declare class ParseObject { * @static * @returns {Parse.Object[]} */ - static fetchAllWithInclude(list: Array, keys: String | Array>, options: RequestOptions): Promise; + static fetchAllWithInclude(list: Array, keys: string | Array>, options: RequestOptions): Promise; /** * Fetches the given list of Parse.Object if needed. * If any error is encountered, stops and calls the error handler. @@ -737,7 +738,7 @@ declare class ParseObject { * @static * @returns {Parse.Object[]} */ - static fetchAllIfNeededWithInclude(list: Array, keys: String | Array>, options: RequestOptions): Promise; + static fetchAllIfNeededWithInclude(list: Array, keys: string | Array>, options: RequestOptions): Promise; /** * Fetches the given list of Parse.Object if needed. * If any error is encountered, stops and calls the error handler. diff --git a/types/ParseQuery.d.ts b/types/ParseQuery.d.ts index 0892a5bc0..35ab7d09a 100644 --- a/types/ParseQuery.d.ts +++ b/types/ParseQuery.d.ts @@ -246,6 +246,8 @@ declare class ParseQuery { * Counts the number of objects that match this query. * * @param {object} options + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] * Valid options are:
        *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -264,10 +266,7 @@ declare class ParseQuery { * * @param {string} key A field to find distinct values * @param {object} options - * Valid options are:
          - *
        • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
        + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. * @returns {Promise} A promise that is resolved with the query completes. */ distinct(key: string, options?: { @@ -277,10 +276,8 @@ declare class ParseQuery { * Executes an aggregate query and returns aggregate results * * @param {(Array|object)} pipeline Array or Object of stages to process query - * @param {object} options Valid options are:
          - *
        • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
        + * @param {object} options + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. * @returns {Promise} A promise that is resolved with the query completes. */ aggregate(pipeline: any, options?: { diff --git a/types/ParseUser.d.ts b/types/ParseUser.d.ts index c705f7e71..cf70506f0 100644 --- a/types/ParseUser.d.ts +++ b/types/ParseUser.d.ts @@ -44,6 +44,7 @@ declare class ParseUser extends ParseObject { * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users} * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} * @param {object} options + * @param {object} [options.authData] AuthData to link with *
          *
        • If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData} *
        • If provider is AuthProvider, options is saveOpts @@ -57,6 +58,7 @@ declare class ParseUser extends ParseObject { /** * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} * @returns {Promise} @@ -364,6 +366,7 @@ declare class ParseUser extends ParseObject { * * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @static * @returns {Promise} @@ -473,6 +476,7 @@ declare class ParseUser extends ParseObject { /** * @param provider * @param options + * @param {object} [options.authData] * @param saveOpts * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith} * @static