From 728fe64d4e4e2196fe6b24a99951928b87cde09e Mon Sep 17 00:00:00 2001 From: dblythy Date: Fri, 28 Jul 2023 12:55:14 +1000 Subject: [PATCH 01/13] feat: add typescript support --- .github/workflows/ci.yml | 9 + babel-jest.js | 2 +- gulpfile.js | 14 +- package-lock.json | 2461 +++++++++++++++-- package.json | 7 +- src/Parse.js | 343 --- src/Parse.ts | 449 +++ tsconfig.json | 12 + types/Analytics.d.ts | 42 + types/AnonymousUtils.d.ts | 56 + types/Cloud.d.ts | 54 + types/CoreManager.d.ts | 1 + types/CryptoController.d.ts | 2 + types/EventEmitter.d.ts | 2 + types/EventuallyQueue.d.ts | 1 + types/FacebookUtils.d.ts | 92 + types/InstallationController.d.ts | 1 + types/LiveQueryClient.d.ts | 123 + types/LiveQuerySubscription.d.ts | 101 + types/LocalDatastore.d.ts | 1 + types/LocalDatastoreController.d.ts | 1 + ...LocalDatastoreController.react-native.d.ts | 1 + types/LocalDatastoreUtils.d.ts | 8 + types/ObjectStateMutations.d.ts | 27 + types/OfflineQuery.d.ts | 17 + types/Parse.d.ts | 103 + types/ParseACL.d.ts | 141 + types/ParseCLP.d.ts | 290 ++ types/ParseConfig.d.ts | 76 + types/ParseError.d.ts | 77 + types/ParseFile.d.ts | 180 ++ types/ParseGeoPoint.d.ts | 97 + types/ParseInstallation.d.ts | 5 + types/ParseLiveQuery.d.ts | 29 + types/ParseObject.d.ts | 1006 +++++++ types/ParseOp.d.ts | 76 + types/ParsePolygon.d.ts | 67 + types/ParseQuery.d.ts | 924 +++++++ types/ParseRelation.d.ts | 56 + types/ParseRole.d.ts | 78 + types/ParseSchema.d.ts | 227 ++ types/ParseSession.d.ts | 45 + types/ParseUser.d.ts | 470 ++++ types/Push.d.ts | 58 + types/RESTController.d.ts | 21 + types/SingleInstanceStateController.d.ts | 31 + types/Socket.weapp.d.ts | 10 + types/Storage.d.ts | 1 + types/StorageController.browser.d.ts | 6 + types/StorageController.default.d.ts | 6 + types/StorageController.react-native.d.ts | 1 + types/StorageController.weapp.d.ts | 6 + types/TaskQueue.d.ts | 1 + types/UniqueInstanceStateController.d.ts | 23 + types/Xhr.weapp.d.ts | 28 + types/arrayContainsObject.d.ts | 2 + types/canBeSerialized.d.ts | 2 + types/decode.d.ts | 1 + types/encode.d.ts | 1 + types/equals.d.ts | 1 + types/escape.d.ts | 1 + types/index.d.ts | 2 + types/isRevocableSession.d.ts | 4 + types/node.d.ts | 2 + types/parseDate.d.ts | 4 + types/promiseUtils.d.ts | 3 + types/react-native.d.ts | 2 + types/tests.ts | 2170 +++++++++++++++ types/tsconfig.json | 21 + types/tslint.json | 10 + types/unique.d.ts | 1 + types/unsavedChildren.d.ts | 11 + types/uuid.d.ts | 2 + 73 files changed, 9669 insertions(+), 537 deletions(-) delete mode 100644 src/Parse.js create mode 100644 src/Parse.ts create mode 100644 tsconfig.json create mode 100644 types/Analytics.d.ts create mode 100644 types/AnonymousUtils.d.ts create mode 100644 types/Cloud.d.ts create mode 100644 types/CoreManager.d.ts create mode 100644 types/CryptoController.d.ts create mode 100644 types/EventEmitter.d.ts create mode 100644 types/EventuallyQueue.d.ts create mode 100644 types/FacebookUtils.d.ts create mode 100644 types/InstallationController.d.ts create mode 100644 types/LiveQueryClient.d.ts create mode 100644 types/LiveQuerySubscription.d.ts create mode 100644 types/LocalDatastore.d.ts create mode 100644 types/LocalDatastoreController.d.ts create mode 100644 types/LocalDatastoreController.react-native.d.ts create mode 100644 types/LocalDatastoreUtils.d.ts create mode 100644 types/ObjectStateMutations.d.ts create mode 100644 types/OfflineQuery.d.ts create mode 100644 types/Parse.d.ts create mode 100644 types/ParseACL.d.ts create mode 100644 types/ParseCLP.d.ts create mode 100644 types/ParseConfig.d.ts create mode 100644 types/ParseError.d.ts create mode 100644 types/ParseFile.d.ts create mode 100644 types/ParseGeoPoint.d.ts create mode 100644 types/ParseInstallation.d.ts create mode 100644 types/ParseLiveQuery.d.ts create mode 100644 types/ParseObject.d.ts create mode 100644 types/ParseOp.d.ts create mode 100644 types/ParsePolygon.d.ts create mode 100644 types/ParseQuery.d.ts create mode 100644 types/ParseRelation.d.ts create mode 100644 types/ParseRole.d.ts create mode 100644 types/ParseSchema.d.ts create mode 100644 types/ParseSession.d.ts create mode 100644 types/ParseUser.d.ts create mode 100644 types/Push.d.ts create mode 100644 types/RESTController.d.ts create mode 100644 types/SingleInstanceStateController.d.ts create mode 100644 types/Socket.weapp.d.ts create mode 100644 types/Storage.d.ts create mode 100644 types/StorageController.browser.d.ts create mode 100644 types/StorageController.default.d.ts create mode 100644 types/StorageController.react-native.d.ts create mode 100644 types/StorageController.weapp.d.ts create mode 100644 types/TaskQueue.d.ts create mode 100644 types/UniqueInstanceStateController.d.ts create mode 100644 types/Xhr.weapp.d.ts create mode 100644 types/arrayContainsObject.d.ts create mode 100644 types/canBeSerialized.d.ts create mode 100644 types/decode.d.ts create mode 100644 types/encode.d.ts create mode 100644 types/equals.d.ts create mode 100644 types/escape.d.ts create mode 100644 types/index.d.ts create mode 100644 types/isRevocableSession.d.ts create mode 100644 types/node.d.ts create mode 100644 types/parseDate.d.ts create mode 100644 types/promiseUtils.d.ts create mode 100644 types/react-native.d.ts create mode 100644 types/tests.ts create mode 100644 types/tsconfig.json create mode 100644 types/tslint.json create mode 100644 types/unique.d.ts create mode 100644 types/unsavedChildren.d.ts create mode 100644 types/uuid.d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74ef1f029..dacfb9e48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,15 @@ jobs: uses: mansona/npm-lockfile-version@v1 with: version: 2 + check-types: + name: Check types + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm ci + - name: Check types + run: npm run test:types build: runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/babel-jest.js b/babel-jest.js index 3e65cec9f..e17601e2a 100644 --- a/babel-jest.js +++ b/babel-jest.js @@ -1,7 +1,7 @@ const babelJest = require('babel-jest'); module.exports = babelJest.createTransformer({ - presets: [["@babel/preset-env", { + presets: ["@babel/preset-typescript", ["@babel/preset-env", { "targets": { "node": "14" }, diff --git a/gulpfile.js b/gulpfile.js index e79632709..90a4f9d93 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,16 +20,16 @@ const transformRuntime = ["@babel/plugin-transform-runtime", { }]; const PRESETS = { - 'browser': [["@babel/preset-env", { + 'browser': ["@babel/preset-typescript", ["@babel/preset-env", { "targets": "> 0.25%, not dead" }]], - 'weapp': [["@babel/preset-env", { + 'weapp': ["@babel/preset-typescript", ["@babel/preset-env", { "targets": "> 0.25%, not dead" }], '@babel/react'], - 'node': [["@babel/preset-env", { + 'node': ["@babel/preset-typescript", ["@babel/preset-env", { "targets": { "node": "14" } }]], - 'react-native': ['module:metro-react-native-babel-preset'], + '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', @@ -79,7 +79,7 @@ function compileTask(stream) { } gulp.task('compile', function() { - return compileTask(gulp.src('src/*.js')); + return compileTask(gulp.src('src/*.*(js|ts)')); }); gulp.task('browserify', function(cb) { @@ -137,7 +137,7 @@ gulp.task('minify-weapp', function() { gulp.task('watch', function() { if (BUILD === 'browser') { - const watcher = gulp.watch('src/*.js', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify')); + const watcher = gulp.watch('src/*.*(js|ts)', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify')); watcher.on('add', function(path) { console.log(`File ${path} was added`); }); @@ -146,5 +146,5 @@ gulp.task('watch', function() { }); return watcher; } - return compileTask(watch('src/*.js', { ignoreInitial: false, verbose: true })); + return compileTask(watch('src/*.*(js|ts)', { ignoreInitial: false, verbose: true })); }); diff --git a/package-lock.json b/package-lock.json index 304a82ce5..f88935f9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "4.2.0-alpha.4", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "^7.22.5", + "@babel/runtime-corejs3": "7.22.5", "idb-keyval": "6.2.1", "react-native-crypto-js": "1.0.0", "uuid": "9.0.0", @@ -25,6 +25,8 @@ "@babel/plugin-transform-runtime": "7.21.4", "@babel/preset-env": "7.21.5", "@babel/preset-react": "7.22.5", + "@babel/preset-typescript": "7.22.5", + "@definitelytyped/dtslint": "0.0.163", "@parse/minami": "1.0.0", "@saithodev/semantic-release-backmerge": "2.1.3", "@semantic-release/changelog": "6.0.3", @@ -104,12 +106,12 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -283,19 +285,20 @@ "dev": true }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.4.tgz", - "integrity": "sha512-46QrX2CQlaFRF4TkwfTt6nJD7IHq8539cCL7SDpqWSDeJKY1xylKKY5F/33mJhLZ3mFvKv2gGrVS6NkyF6qs+Q==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.9.tgz", + "integrity": "sha512-Pwyi89uO4YrGKxL/eNJ8lfEH55DnRloGPOseaA8NFNL6jAUnn+KccaISiFazCj5IolPPDjGSdzQzXVzODVRqUQ==", "dev": true, "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-member-expression-to-functions": "^7.21.0", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/helper-replace-supers": "^7.20.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/helper-split-export-declaration": "^7.18.6" + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -304,6 +307,15 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-regexp-features-plugin": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.20.5.tgz", @@ -412,9 +424,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", - "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", "dev": true, "engines": { "node": ">=6.9.0" @@ -433,13 +445,13 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -458,12 +470,12 @@ } }, "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.0.tgz", - "integrity": "sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.22.5.tgz", + "integrity": "sha512-aBiH1NKMG0H2cGZqspNvsaBe6wNGjbJjuLy29aU+eDZjSbbN53BaxlpB02xm9v34pLTZ1nIQPFYn2qMZoa5BQQ==", "dev": true, "dependencies": { - "@babel/types": "^7.21.0" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -482,31 +494,31 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.0.tgz", - "integrity": "sha512-drsR5/3eHuYs31uYLIXRK91+THB9+VAd2s3/4TY87Os5qrwr6YesM6GcNX5aEpCF6e9iKK0ZvTBTKqNyntEkvQ==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", + "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", "dev": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-simple-access": "^7.21.5", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.21.9", - "@babel/traverse": "^7.22.0", - "@babel/types": "^7.22.0" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.5" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", - "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz", + "integrity": "sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -540,53 +552,53 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.20.7.tgz", - "integrity": "sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", + "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", "dev": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-member-expression-to-functions": "^7.20.7", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-simple-access": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", - "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, "dependencies": { - "@babel/types": "^7.21.5" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", - "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz", + "integrity": "sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==", "dev": true, "dependencies": { - "@babel/types": "^7.20.0" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -649,12 +661,12 @@ } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -663,9 +675,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.0.tgz", - "integrity": "sha512-DA65VCJRetcFmJnt9/hEmRvXNCwk0V86dxG6p6N13hzDazaLRjGdTGPGgjxZOtLuFgWzOSRX4grybmRXwQ9bSg==", + "version": "7.22.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", + "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1233,12 +1245,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz", - "integrity": "sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", + "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.19.0" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -1522,14 +1534,14 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.5.tgz", - "integrity": "sha512-OVryBEgKUbtqMoB7eG2rs6UFexJi6Zj6FDXx+esBLPTCxCNxAY9o+8Di7IsUGJ+AVhp5ncK0fxWUBd0/1gPhrQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.22.5.tgz", + "integrity": "sha512-B4pzOXj+ONRmuaQTg05b3y/4DuFz3WcCNAXPLb2Q0GT0TrGKGxNKV4jwsXts+StaM0LQczZbOpj8o1DLPDJIiA==", "dev": true, "dependencies": { - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/helper-simple-access": "^7.21.5" + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -1881,14 +1893,15 @@ } }, "node_modules/@babel/plugin-transform-typescript": { - "version": "7.20.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.20.13.tgz", - "integrity": "sha512-O7I/THxarGcDZxkgWKMUrk7NK1/WbHAg3Xx86gqS6x9MTrNL6AwIluuZ96ms4xeDe6AVx6rjHbWHP7x26EPQBA==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.9.tgz", + "integrity": "sha512-BnVR1CpKiuD0iobHPaM1iLvcwPYN2uVFAqoLVSpEDKWuOikoCv5HbKLxclhKYUXlWkX86DoZGtqI4XhbOsyrMg==", "dev": true, "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.20.12", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-typescript": "^7.20.0" + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-create-class-features-plugin": "^7.22.9", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-typescript": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -2116,6 +2129,25 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz", + "integrity": "sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "@babel/plugin-transform-modules-commonjs": "^7.22.5", + "@babel/plugin-transform-typescript": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/runtime": { "version": "7.21.5", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz", @@ -2141,14 +2173,14 @@ } }, "node_modules/@babel/template": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.21.9.tgz", - "integrity": "sha512-MK0X5k8NKOuWRamiEfc3KEJiHMTkGZNUjzMipqCGDDc6ijRl/B7RGSKVGncu4Ro/HdyzzY6cmoXuKI2Gffk7vQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/parser": "^7.21.9", - "@babel/types": "^7.21.5" + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -2215,6 +2247,377 @@ "kuler": "^2.0.0" } }, + "node_modules/@definitelytyped/dts-critic": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/dts-critic/-/dts-critic-0.0.163.tgz", + "integrity": "sha512-HsTvylj8x2gQaawsOCcN2Xk2Cx0wgV9kaj83hgsO9SITZSPd7dA0UkHyNRadbMkMwqNDKcnizcmWdz0+0gIo8A==", + "dev": true, + "dependencies": { + "@definitelytyped/header-parser": "^0.0.163", + "command-exists": "^1.2.8", + "rimraf": "^3.0.2", + "semver": "^6.2.0", + "tmp": "^0.2.1", + "yargs": "^15.3.1" + }, + "engines": { + "node": ">=10.17.0" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@definitelytyped/dts-critic/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "node_modules/@definitelytyped/dts-critic/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/@definitelytyped/dts-critic/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@definitelytyped/dts-critic/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@definitelytyped/dtslint": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/dtslint/-/dtslint-0.0.163.tgz", + "integrity": "sha512-U0uw7Zu0QdYSuBMYgxvRYjkhkeulTEg8vDgJ7TiYQUv/wODeujSAmGahQn51E5hOlSMYUw7A9utdbUukxE02SQ==", + "dev": true, + "dependencies": { + "@definitelytyped/dts-critic": "^0.0.163", + "@definitelytyped/header-parser": "^0.0.163", + "@definitelytyped/typescript-versions": "^0.0.163", + "@definitelytyped/utils": "^0.0.163", + "@typescript-eslint/eslint-plugin": "^5.55.0", + "@typescript-eslint/parser": "^5.55.0", + "@typescript-eslint/types": "^5.56.0", + "@typescript-eslint/typescript-estree": "^5.55.0", + "@typescript-eslint/utils": "^5.55.0", + "eslint": "^8.17.0", + "fs-extra": "^6.0.1", + "json-stable-stringify": "^1.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "5.14.0", + "yargs": "^15.1.0" + }, + "bin": { + "dtslint": "dist/index.js" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "typescript": ">= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev || >=5.0.0-dev" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@definitelytyped/dtslint/node_modules/fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "node_modules/@definitelytyped/dtslint/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/@definitelytyped/dtslint/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@definitelytyped/dtslint/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@definitelytyped/header-parser": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/header-parser/-/header-parser-0.0.163.tgz", + "integrity": "sha512-Jr+/q+ESfc7uWldz/j11BfpjIN/gB4WmwhFENhWaMwM0W/9p0ShF+OiUqGhk2Q3Iz8v/oyWzSsxyxgasg9kCxQ==", + "dev": true, + "dependencies": { + "@definitelytyped/typescript-versions": "^0.0.163", + "@types/parsimmon": "^1.10.1", + "parsimmon": "^1.13.0" + } + }, + "node_modules/@definitelytyped/typescript-versions": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.163.tgz", + "integrity": "sha512-+GWtJhC+7UaCUnJ+ZkA7bfGuPd6ZbJKEjbHqh76/gOXsqAUOMEa49ufsLlIPUbkEeQlnDNoTHCegE5X/Q+u+/A==", + "dev": true + }, + "node_modules/@definitelytyped/utils": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.163.tgz", + "integrity": "sha512-6MX5TxaQbG/j2RkCWbcbLvv+YNipKqY0eQJafDhwC/RprUocpg+uYVNlH8XzdKRWOGJ0pq7SZOsJD4C3A01ZXg==", + "dev": true, + "dependencies": { + "@definitelytyped/typescript-versions": "^0.0.163", + "@qiwi/npm-registry-client": "^8.9.1", + "@types/node": "^14.14.35", + "charm": "^1.0.2", + "fs-extra": "^8.1.0", + "fstream": "^1.0.12", + "tar": "^6.1.11", + "tar-stream": "^2.1.4" + } + }, + "node_modules/@definitelytyped/utils/node_modules/@types/node": { + "version": "14.18.54", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.54.tgz", + "integrity": "sha512-uq7O52wvo2Lggsx1x21tKZgqkJpvwCseBBPtX/nKQfpVlEsLOb11zZ1CRsWUKvJF0+lzuA9jwvA7Pr2Wt7i3xw==", + "dev": true + }, + "node_modules/@definitelytyped/utils/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/@definitelytyped/utils/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/@definitelytyped/utils/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/@envelop/core": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/@envelop/core/-/core-2.6.0.tgz", @@ -4250,6 +4653,72 @@ "node": ">=12" } }, + "node_modules/@qiwi/npm-registry-client": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@qiwi/npm-registry-client/-/npm-registry-client-8.9.1.tgz", + "integrity": "sha512-rZF+mG+NfijR0SHphhTLHRr4aM4gtfdwoAMY6we2VGQam8vkN1cxGG1Lg/Llrj8Dd0Mu6VjdFQRyMMRZxtZR2A==", + "dev": true, + "dependencies": { + "concat-stream": "^2.0.0", + "graceful-fs": "^4.2.4", + "normalize-package-data": "~1.0.1 || ^2.0.0 || ^3.0.0", + "npm-package-arg": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^8.0.0", + "once": "^1.4.0", + "request": "^2.88.2", + "retry": "^0.12.0", + "safe-buffer": "^5.2.1", + "semver": "2 >=2.2.1 || 3.x || 4 || 5 || 7", + "slide": "^1.1.6", + "ssri": "^8.0.0" + }, + "optionalDependencies": { + "npmlog": "2 || ^3.1.0 || ^4.0.0" + } + }, + "node_modules/@qiwi/npm-registry-client/node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "dev": true, + "engines": [ + "node >= 6.0" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/@qiwi/npm-registry-client/node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/@qiwi/npm-registry-client/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/@repeaterjs/repeater": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", @@ -4608,6 +5077,12 @@ "parse5": "^7.0.0" } }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", + "dev": true + }, "node_modules/@types/jsonwebtoken": { "version": "8.5.9", "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz", @@ -4669,6 +5144,12 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "node_modules/@types/parsimmon": { + "version": "1.10.6", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.6.tgz", + "integrity": "sha512-FwAQwMRbkhx0J6YELkwIpciVzCcgEqXEbIrIn3a2P5d3kGEHQ3wVhlN3YdVepYP+bZzCYO6OjmD4o9TGOZ40rA==", + "dev": true + }, "node_modules/@types/prettier": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", @@ -4693,6 +5174,12 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, "node_modules/@types/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", @@ -4756,6 +5243,239 @@ "@types/node": "*" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", + "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/type-utils": "5.62.0", + "@typescript-eslint/utils": "5.62.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", + "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", + "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", + "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/utils": "5.62.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", + "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", + "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", + "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "eslint-scope": "^5.1.1", + "semver": "^7.3.7" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", + "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@xmldom/xmldom": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.6.tgz", @@ -5583,6 +6303,78 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, + "node_modules/babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", + "dev": true, + "dependencies": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + } + }, + "node_modules/babel-code-frame/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", + "dev": true, + "dependencies": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==", + "dev": true + }, + "node_modules/babel-code-frame/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/babel-helper-evaluate-path": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.5.0.tgz", @@ -6555,12 +7347,27 @@ "node": ">=8.12.0" } }, + "node_modules/builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "node_modules/builtins": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", + "integrity": "sha512-uYBjakWipfaO/bXI7E8rq6kpwHRZK5cNYrUv2OzZSI/FvmdMyXJ2tG9dKcjEC5YHmHpUAwsargWIZNWdxb/bnQ==", + "dev": true + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -6726,6 +7533,15 @@ "node": ">=10" } }, + "node_modules/charm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/charm/-/charm-1.0.2.tgz", + "integrity": "sha512-wqW3VdPnlSWT4eRiYX+hcs+C6ViBPUWk1qTCd+37qw9kEm/a5n2qcyQDMBWvSYKN/ctqZzeXNQaeBjOetJJUkw==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1" + } + }, "node_modules/chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", @@ -7362,6 +8178,12 @@ "node": ">= 0.8" } }, + "node_modules/command-exists": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", + "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", + "dev": true + }, "node_modules/commander": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", @@ -8865,6 +9687,15 @@ "integrity": "sha512-39fCpE3Z78IaIPChJsP6Lhmkbf4dWXOmzLk/KFTdRkNk/0JymRIfUynDVRndV9HoDz8PyalK1UH21ST/ivwW5Q==", "dev": true }, + "node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -11244,6 +12075,45 @@ "node": ">= 4.0" } }, + "node_modules/fstream": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + }, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/fstream/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/fstream/node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -11779,6 +12649,12 @@ "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", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -12612,6 +13488,27 @@ "node": ">= 0.4.0" } }, + "node_modules/has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-ansi/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -15989,6 +16886,18 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "node_modules/json-stable-stringify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.2.tgz", + "integrity": "sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g==", + "dev": true, + "dependencies": { + "jsonify": "^0.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -16025,6 +16934,15 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -17998,6 +18916,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -18334,6 +19258,35 @@ "node": "^12.13.0 || ^14.15.0 || >=16" } }, + "node_modules/npm-package-arg": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", + "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "dev": true, + "dependencies": { + "hosted-git-info": "^4.0.1", + "semver": "^7.3.4", + "validate-npm-package-name": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/npm-package-arg/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -21690,6 +22643,12 @@ "node": ">= 0.8" } }, + "node_modules/parsimmon": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.18.1.tgz", + "integrity": "sha512-u7p959wLfGAhJpSDJVYXoyMCXWYwHia78HhRBWqk7AIbxdmlrfdp5wX0l3xv/iTSH5HvhN9K7o26hwwpgS5Nmw==", + "dev": true + }, "node_modules/pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -23252,6 +24211,57 @@ "node": ">= 0.10" } }, + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", + "dev": true, + "dependencies": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/request/node_modules/qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/request/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "dev": true, + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -23974,6 +24984,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/slide": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", + "integrity": "sha512-NwrtjCg+lZoqhFU8fOwl4ay2ei8PaqCBOUV3/ektPY9trO1yQ1oXEfmHAhKArUVUr/hOHvy5f6AdP17dCM0zMw==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -24349,6 +25368,30 @@ "node": ">=0.10.0" } }, + "node_modules/ssri": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", + "integrity": "sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==", + "dev": true, + "dependencies": { + "minipass": "^3.1.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/ssri/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -25174,6 +26217,18 @@ "next-tick": "1" } }, + "node_modules/tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "dev": true, + "dependencies": { + "rimraf": "^3.0.0" + }, + "engines": { + "node": ">=8.17.0" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -25314,6 +26369,28 @@ "node": ">=0.6" } }, + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "dependencies": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/tough-cookie/node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -25350,6 +26427,93 @@ "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", "dev": true }, + "node_modules/tslint": { + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.14.0.tgz", + "integrity": "sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==", + "dev": true, + "dependencies": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + }, + "bin": { + "tslint": "bin/tslint" + }, + "engines": { + "node": ">=4.8.0" + }, + "peerDependencies": { + "typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev" + } + }, + "node_modules/tslint/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/tslint/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/tslint/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/tslint/node_modules/tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "peerDependencies": { + "typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev" + } + }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -25441,6 +26605,20 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "node_modules/typescript": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -25877,6 +27055,15 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/validate-npm-package-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", + "integrity": "sha512-M6w37eVCMMouJ9V/sdPGnC5H4uDr73/+xdq0FBLO3TFFX1+7wiUY6Es328NN+y43tmY+doUdN9g9J21vqB7iLw==", + "dev": true, + "dependencies": { + "builtins": "^1.0.3" + } + }, "node_modules/value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", @@ -26678,12 +27865,12 @@ } }, "@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", "dev": true, "requires": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.22.5" } }, "@babel/compat-data": { @@ -26816,19 +28003,28 @@ } }, "@babel/helper-create-class-features-plugin": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.4.tgz", - "integrity": "sha512-46QrX2CQlaFRF4TkwfTt6nJD7IHq8539cCL7SDpqWSDeJKY1xylKKY5F/33mJhLZ3mFvKv2gGrVS6NkyF6qs+Q==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.9.tgz", + "integrity": "sha512-Pwyi89uO4YrGKxL/eNJ8lfEH55DnRloGPOseaA8NFNL6jAUnn+KccaISiFazCj5IolPPDjGSdzQzXVzODVRqUQ==", "dev": true, "requires": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-member-expression-to-functions": "^7.21.0", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/helper-replace-supers": "^7.20.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/helper-split-export-declaration": "^7.18.6" + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "semver": "^6.3.1" + }, + "dependencies": { + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + } } }, "@babel/helper-create-regexp-features-plugin": { @@ -26916,9 +28112,9 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.21.5.tgz", - "integrity": "sha512-IYl4gZ3ETsWocUWgsFZLM5i1BYx9SoemminVEXadgLBa9TdeorzgLKm8wWLA6J1N/kT3Kch8XIk1laNzYoHKvQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", "dev": true }, "@babel/helper-explode-assignable-expression": { @@ -26931,13 +28127,13 @@ } }, "@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", "dev": true, "requires": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/helper-hoist-variables": { @@ -26950,12 +28146,12 @@ } }, "@babel/helper-member-expression-to-functions": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.0.tgz", - "integrity": "sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.22.5.tgz", + "integrity": "sha512-aBiH1NKMG0H2cGZqspNvsaBe6wNGjbJjuLy29aU+eDZjSbbN53BaxlpB02xm9v34pLTZ1nIQPFYn2qMZoa5BQQ==", "dev": true, "requires": { - "@babel/types": "^7.21.0" + "@babel/types": "^7.22.5" } }, "@babel/helper-module-imports": { @@ -26968,28 +28164,25 @@ } }, "@babel/helper-module-transforms": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.0.tgz", - "integrity": "sha512-drsR5/3eHuYs31uYLIXRK91+THB9+VAd2s3/4TY87Os5qrwr6YesM6GcNX5aEpCF6e9iKK0ZvTBTKqNyntEkvQ==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", + "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", "dev": true, "requires": { - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-module-imports": "^7.21.4", - "@babel/helper-simple-access": "^7.21.5", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.21.9", - "@babel/traverse": "^7.22.0", - "@babel/types": "^7.22.0" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.5" } }, "@babel/helper-optimise-call-expression": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", - "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz", + "integrity": "sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-plugin-utils": { @@ -27011,44 +28204,41 @@ } }, "@babel/helper-replace-supers": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.20.7.tgz", - "integrity": "sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", + "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", "dev": true, "requires": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-member-expression-to-functions": "^7.20.7", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5" } }, "@babel/helper-simple-access": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.21.5.tgz", - "integrity": "sha512-ENPDAMC1wAjR0uaCUwliBdiSl1KBJAVnMTzXqi64c2MG8MPR6ii4qf7bSXDqSFbr4W6W028/rf5ivoHop5/mkg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, "requires": { - "@babel/types": "^7.21.5" + "@babel/types": "^7.22.5" } }, "@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", - "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz", + "integrity": "sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==", "dev": true, "requires": { - "@babel/types": "^7.20.0" + "@babel/types": "^7.22.5" } }, "@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "requires": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" } }, "@babel/helper-string-parser": { @@ -27093,20 +28283,20 @@ } }, "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.18.6", + "@babel/helper-validator-identifier": "^7.22.5", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.0.tgz", - "integrity": "sha512-DA65VCJRetcFmJnt9/hEmRvXNCwk0V86dxG6p6N13hzDazaLRjGdTGPGgjxZOtLuFgWzOSRX4grybmRXwQ9bSg==", + "version": "7.22.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", + "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -27479,12 +28669,12 @@ } }, "@babel/plugin-syntax-typescript": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz", - "integrity": "sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", + "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.19.0" + "@babel/helper-plugin-utils": "^7.22.5" } }, "@babel/plugin-transform-arrow-functions": { @@ -27660,14 +28850,14 @@ } }, "@babel/plugin-transform-modules-commonjs": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.5.tgz", - "integrity": "sha512-OVryBEgKUbtqMoB7eG2rs6UFexJi6Zj6FDXx+esBLPTCxCNxAY9o+8Di7IsUGJ+AVhp5ncK0fxWUBd0/1gPhrQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.22.5.tgz", + "integrity": "sha512-B4pzOXj+ONRmuaQTg05b3y/4DuFz3WcCNAXPLb2Q0GT0TrGKGxNKV4jwsXts+StaM0LQczZbOpj8o1DLPDJIiA==", "dev": true, "requires": { - "@babel/helper-module-transforms": "^7.21.5", - "@babel/helper-plugin-utils": "^7.21.5", - "@babel/helper-simple-access": "^7.21.5" + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5" } }, "@babel/plugin-transform-modules-systemjs": { @@ -27886,14 +29076,15 @@ } }, "@babel/plugin-transform-typescript": { - "version": "7.20.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.20.13.tgz", - "integrity": "sha512-O7I/THxarGcDZxkgWKMUrk7NK1/WbHAg3Xx86gqS6x9MTrNL6AwIluuZ96ms4xeDe6AVx6rjHbWHP7x26EPQBA==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.9.tgz", + "integrity": "sha512-BnVR1CpKiuD0iobHPaM1iLvcwPYN2uVFAqoLVSpEDKWuOikoCv5HbKLxclhKYUXlWkX86DoZGtqI4XhbOsyrMg==", "dev": true, "requires": { - "@babel/helper-create-class-features-plugin": "^7.20.12", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-typescript": "^7.20.0" + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-create-class-features-plugin": "^7.22.9", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-typescript": "^7.22.5" } }, "@babel/plugin-transform-unicode-escapes": { @@ -28069,6 +29260,19 @@ "@babel/plugin-transform-react-pure-annotations": "^7.22.5" } }, + "@babel/preset-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz", + "integrity": "sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "@babel/plugin-transform-modules-commonjs": "^7.22.5", + "@babel/plugin-transform-typescript": "^7.22.5" + } + }, "@babel/runtime": { "version": "7.21.5", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz", @@ -28088,14 +29292,14 @@ } }, "@babel/template": { - "version": "7.21.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.21.9.tgz", - "integrity": "sha512-MK0X5k8NKOuWRamiEfc3KEJiHMTkGZNUjzMipqCGDDc6ijRl/B7RGSKVGncu4Ro/HdyzzY6cmoXuKI2Gffk7vQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", "dev": true, "requires": { - "@babel/code-frame": "^7.21.4", - "@babel/parser": "^7.21.9", - "@babel/types": "^7.21.5" + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" } }, "@babel/traverse": { @@ -28150,6 +29354,320 @@ "kuler": "^2.0.0" } }, + "@definitelytyped/dts-critic": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/dts-critic/-/dts-critic-0.0.163.tgz", + "integrity": "sha512-HsTvylj8x2gQaawsOCcN2Xk2Cx0wgV9kaj83hgsO9SITZSPd7dA0UkHyNRadbMkMwqNDKcnizcmWdz0+0gIo8A==", + "dev": true, + "requires": { + "@definitelytyped/header-parser": "^0.0.163", + "command-exists": "^1.2.8", + "rimraf": "^3.0.2", + "semver": "^6.2.0", + "tmp": "^0.2.1", + "yargs": "^15.3.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + }, + "which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "@definitelytyped/dtslint": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/dtslint/-/dtslint-0.0.163.tgz", + "integrity": "sha512-U0uw7Zu0QdYSuBMYgxvRYjkhkeulTEg8vDgJ7TiYQUv/wODeujSAmGahQn51E5hOlSMYUw7A9utdbUukxE02SQ==", + "dev": true, + "requires": { + "@definitelytyped/dts-critic": "^0.0.163", + "@definitelytyped/header-parser": "^0.0.163", + "@definitelytyped/typescript-versions": "^0.0.163", + "@definitelytyped/utils": "^0.0.163", + "@typescript-eslint/eslint-plugin": "^5.55.0", + "@typescript-eslint/parser": "^5.55.0", + "@typescript-eslint/types": "^5.56.0", + "@typescript-eslint/typescript-estree": "^5.55.0", + "@typescript-eslint/utils": "^5.55.0", + "eslint": "^8.17.0", + "fs-extra": "^6.0.1", + "json-stable-stringify": "^1.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "5.14.0", + "yargs": "^15.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "fs-extra": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, + "@definitelytyped/header-parser": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/header-parser/-/header-parser-0.0.163.tgz", + "integrity": "sha512-Jr+/q+ESfc7uWldz/j11BfpjIN/gB4WmwhFENhWaMwM0W/9p0ShF+OiUqGhk2Q3Iz8v/oyWzSsxyxgasg9kCxQ==", + "dev": true, + "requires": { + "@definitelytyped/typescript-versions": "^0.0.163", + "@types/parsimmon": "^1.10.1", + "parsimmon": "^1.13.0" + } + }, + "@definitelytyped/typescript-versions": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.163.tgz", + "integrity": "sha512-+GWtJhC+7UaCUnJ+ZkA7bfGuPd6ZbJKEjbHqh76/gOXsqAUOMEa49ufsLlIPUbkEeQlnDNoTHCegE5X/Q+u+/A==", + "dev": true + }, + "@definitelytyped/utils": { + "version": "0.0.163", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.163.tgz", + "integrity": "sha512-6MX5TxaQbG/j2RkCWbcbLvv+YNipKqY0eQJafDhwC/RprUocpg+uYVNlH8XzdKRWOGJ0pq7SZOsJD4C3A01ZXg==", + "dev": true, + "requires": { + "@definitelytyped/typescript-versions": "^0.0.163", + "@qiwi/npm-registry-client": "^8.9.1", + "@types/node": "^14.14.35", + "charm": "^1.0.2", + "fs-extra": "^8.1.0", + "fstream": "^1.0.12", + "tar": "^6.1.11", + "tar-stream": "^2.1.4" + }, + "dependencies": { + "@types/node": { + "version": "14.18.54", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.54.tgz", + "integrity": "sha512-uq7O52wvo2Lggsx1x21tKZgqkJpvwCseBBPtX/nKQfpVlEsLOb11zZ1CRsWUKvJF0+lzuA9jwvA7Pr2Wt7i3xw==", + "dev": true + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + } + } + }, "@envelop/core": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/@envelop/core/-/core-2.6.0.tgz", @@ -29652,6 +31170,52 @@ } } }, + "@qiwi/npm-registry-client": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@qiwi/npm-registry-client/-/npm-registry-client-8.9.1.tgz", + "integrity": "sha512-rZF+mG+NfijR0SHphhTLHRr4aM4gtfdwoAMY6we2VGQam8vkN1cxGG1Lg/Llrj8Dd0Mu6VjdFQRyMMRZxtZR2A==", + "dev": true, + "requires": { + "concat-stream": "^2.0.0", + "graceful-fs": "^4.2.4", + "normalize-package-data": "~1.0.1 || ^2.0.0 || ^3.0.0", + "npm-package-arg": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^8.0.0", + "npmlog": "2 || ^3.1.0 || ^4.0.0", + "once": "^1.4.0", + "request": "^2.88.2", + "retry": "^0.12.0", + "safe-buffer": "^5.2.1", + "semver": "2 >=2.2.1 || 3.x || 4 || 5 || 7", + "slide": "^1.1.6", + "ssri": "^8.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + } + } + }, "@repeaterjs/repeater": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", @@ -29961,6 +31525,12 @@ "parse5": "^7.0.0" } }, + "@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", + "dev": true + }, "@types/jsonwebtoken": { "version": "8.5.9", "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz", @@ -30022,6 +31592,12 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "@types/parsimmon": { + "version": "1.10.6", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.6.tgz", + "integrity": "sha512-FwAQwMRbkhx0J6YELkwIpciVzCcgEqXEbIrIn3a2P5d3kGEHQ3wVhlN3YdVepYP+bZzCYO6OjmD4o9TGOZ40rA==", + "dev": true + }, "@types/prettier": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", @@ -30046,6 +31622,12 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "dev": true }, + "@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, "@types/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", @@ -30109,6 +31691,138 @@ "@types/node": "*" } }, + "@typescript-eslint/eslint-plugin": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", + "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", + "dev": true, + "requires": { + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/type-utils": "5.62.0", + "@typescript-eslint/utils": "5.62.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "dependencies": { + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/parser": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", + "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", + "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", + "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/utils": "5.62.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", + "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", + "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "dependencies": { + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/utils": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", + "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "eslint-scope": "^5.1.1", + "semver": "^7.3.7" + }, + "dependencies": { + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", + "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.62.0", + "eslint-visitor-keys": "^3.3.0" + } + }, "@xmldom/xmldom": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.6.tgz", @@ -30776,6 +32490,65 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true + } + } + }, "babel-helper-evaluate-path": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.5.0.tgz", @@ -31584,12 +33357,24 @@ "readable-stream": "^3.4.0" } }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", + "dev": true + }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "builtins": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", + "integrity": "sha512-uYBjakWipfaO/bXI7E8rq6kpwHRZK5cNYrUv2OzZSI/FvmdMyXJ2tG9dKcjEC5YHmHpUAwsargWIZNWdxb/bnQ==", + "dev": true + }, "busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -31709,6 +33494,15 @@ "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true }, + "charm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/charm/-/charm-1.0.2.tgz", + "integrity": "sha512-wqW3VdPnlSWT4eRiYX+hcs+C6ViBPUWk1qTCd+37qw9kEm/a5n2qcyQDMBWvSYKN/ctqZzeXNQaeBjOetJJUkw==", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", @@ -32217,6 +34011,12 @@ "delayed-stream": "~1.0.0" } }, + "command-exists": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", + "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", + "dev": true + }, "commander": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", @@ -33420,6 +35220,12 @@ "integrity": "sha512-39fCpE3Z78IaIPChJsP6Lhmkbf4dWXOmzLk/KFTdRkNk/0JymRIfUynDVRndV9HoDz8PyalK1UH21ST/ivwW5Q==", "dev": true }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, "diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -35334,6 +37140,38 @@ "nan": "^2.12.1" } }, + "fstream": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -35784,6 +37622,12 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -36487,6 +38331,23 @@ "function-bind": "^1.1.1" } }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true + } + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -38994,6 +40855,15 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "json-stable-stringify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.2.tgz", + "integrity": "sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g==", + "dev": true, + "requires": { + "jsonify": "^0.0.1" + } + }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -39022,6 +40892,12 @@ "universalify": "^2.0.0" } }, + "jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true + }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -40586,6 +42462,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -42494,6 +44376,28 @@ } } }, + "npm-package-arg": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", + "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "dev": true, + "requires": { + "hosted-git-info": "^4.0.1", + "semver": "^7.3.4", + "validate-npm-package-name": "^3.0.0" + }, + "dependencies": { + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -43222,6 +45126,12 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, + "parsimmon": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.18.1.tgz", + "integrity": "sha512-u7p959wLfGAhJpSDJVYXoyMCXWYwHia78HhRBWqk7AIbxdmlrfdp5wX0l3xv/iTSH5HvhN9K7o26hwwpgS5Nmw==", + "dev": true + }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -44456,6 +46366,48 @@ "remove-trailing-separator": "^1.1.0" } }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "dev": true + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -45024,6 +46976,12 @@ } } }, + "slide": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", + "integrity": "sha512-NwrtjCg+lZoqhFU8fOwl4ay2ei8PaqCBOUV3/ektPY9trO1yQ1oXEfmHAhKArUVUr/hOHvy5f6AdP17dCM0zMw==", + "dev": true + }, "smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -45337,6 +47295,26 @@ "tweetnacl": "~0.14.0" } }, + "ssri": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", + "integrity": "sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==", + "dev": true, + "requires": { + "minipass": "^3.1.1" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + } + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -46022,6 +48000,15 @@ "next-tick": "1" } }, + "tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "dev": true, + "requires": { + "rimraf": "^3.0.0" + } + }, "tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -46142,6 +48129,24 @@ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "dependencies": { + "punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true + } + } + }, "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -46172,6 +48177,76 @@ "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", "dev": true }, + "tslint": { + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.14.0.tgz", + "integrity": "sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==", + "dev": true, + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.29.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + } + } + }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } + } + }, "tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -46242,6 +48317,13 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true, + "peer": true + }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -46592,6 +48674,15 @@ "spdx-expression-parse": "^3.0.0" } }, + "validate-npm-package-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", + "integrity": "sha512-M6w37eVCMMouJ9V/sdPGnC5H4uDr73/+xdq0FBLO3TFFX1+7wiUY6Es328NN+y43tmY+doUdN9g9J21vqB7iLw==", + "dev": true, + "requires": { + "builtins": "^1.0.3" + } + }, "value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", diff --git a/package.json b/package.json index b8e5c8fb3..8d22dad95 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "lib/", "LICENSE", "NOTICE", - "README.md" + "README.md", + "types/index.d.ts" ], "browser": { "react-native": false @@ -45,6 +46,8 @@ "@babel/plugin-transform-runtime": "7.21.4", "@babel/preset-env": "7.21.5", "@babel/preset-react": "7.22.5", + "@babel/preset-typescript": "7.22.5", + "@definitelytyped/dtslint": "0.0.163", "@parse/minami": "1.0.0", "@saithodev/semantic-release-backmerge": "2.1.3", "@semantic-release/changelog": "6.0.3", @@ -95,10 +98,12 @@ }, "scripts": { "build": "node build_releases.js", + "build:types": "tsc", "release": "node build_releases.js && npm publish", "test": "cross-env PARSE_BUILD=node jest", "test:mongodb": "npm run test:mongodb:runnerstart && npm run integration", "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/", diff --git a/src/Parse.js b/src/Parse.js deleted file mode 100644 index 606ad731a..000000000 --- a/src/Parse.js +++ /dev/null @@ -1,343 +0,0 @@ -import decode from './decode'; -import encode from './encode'; -import CoreManager from './CoreManager'; -import CryptoController from './CryptoController'; -import EventuallyQueue from './EventuallyQueue'; -import InstallationController from './InstallationController'; -import * as ParseOp from './ParseOp'; -import RESTController from './RESTController'; - -/** - * Contains all Parse API classes and functions. - * - * @static - * @global - * @class - * @hideconstructor - */ -const Parse = { - /** - * Call this method first to set up your authentication tokens for Parse. - * - * @param {string} applicationId Your Parse Application ID. - * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server) - * @param {string} [masterKey] Your Parse Master Key. (Node.js only!) - * @static - */ - initialize(applicationId: string, javaScriptKey: string) { - if ( - process.env.PARSE_BUILD === 'browser' && - CoreManager.get('IS_NODE') && - !process.env.SERVER_RENDERING - ) { - /* eslint-disable no-console */ - console.log( - "It looks like you're using the browser version of the SDK in a " + - "node.js environment. You should require('parse/node') instead." - ); - /* eslint-enable no-console */ - } - Parse._initialize(applicationId, javaScriptKey); - }, - - _initialize(applicationId: string, javaScriptKey: string, masterKey: string) { - CoreManager.set('APPLICATION_ID', applicationId); - CoreManager.set('JAVASCRIPT_KEY', javaScriptKey); - CoreManager.set('MASTER_KEY', masterKey); - CoreManager.set('USE_MASTER_KEY', false); - }, - - /** - * Call this method to set your AsyncStorage engine - * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module - * is not provided at a stable path and changes over versions. - * - * @param {AsyncStorage} storage a react native async storage. - * @static - */ - setAsyncStorage(storage: any) { - CoreManager.setAsyncStorage(storage); - }, - - /** - * Call this method to set your LocalDatastoreStorage engine - * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} - * - * @param {LocalDatastoreController} controller a data storage. - * @static - */ - setLocalDatastoreController(controller: any) { - CoreManager.setLocalDatastoreController(controller); - }, - - /** - * Returns information regarding the current server's health - * - * @returns {Promise} - * @static - */ - getServerHealth() { - return CoreManager.getRESTController().request('GET', 'health'); - }, - - /** - * @member {string} Parse.applicationId - * @static - */ - set applicationId(value) { - CoreManager.set('APPLICATION_ID', value); - }, - get applicationId() { - return CoreManager.get('APPLICATION_ID'); - }, - - /** - * @member {string} Parse.javaScriptKey - * @static - */ - set javaScriptKey(value) { - CoreManager.set('JAVASCRIPT_KEY', value); - }, - get javaScriptKey() { - return CoreManager.get('JAVASCRIPT_KEY'); - }, - - /** - * @member {string} Parse.masterKey - * @static - */ - set masterKey(value) { - CoreManager.set('MASTER_KEY', value); - }, - get masterKey() { - return CoreManager.get('MASTER_KEY'); - }, - - /** - * @member {string} Parse.serverURL - * @static - */ - set serverURL(value) { - CoreManager.set('SERVER_URL', value); - }, - get serverURL() { - return CoreManager.get('SERVER_URL'); - }, - - /** - * @member {string} Parse.serverAuthToken - * @static - */ - set serverAuthToken(value) { - CoreManager.set('SERVER_AUTH_TOKEN', value); - }, - get serverAuthToken() { - return CoreManager.get('SERVER_AUTH_TOKEN'); - }, - - /** - * @member {string} Parse.serverAuthType - * @static - */ - set serverAuthType(value) { - CoreManager.set('SERVER_AUTH_TYPE', value); - }, - get serverAuthType() { - return CoreManager.get('SERVER_AUTH_TYPE'); - }, - - /** - * @member {string} Parse.liveQueryServerURL - * @static - */ - set liveQueryServerURL(value) { - CoreManager.set('LIVEQUERY_SERVER_URL', value); - }, - get liveQueryServerURL() { - return CoreManager.get('LIVEQUERY_SERVER_URL'); - }, - - /** - * @member {string} Parse.encryptedUser - * @static - */ - set encryptedUser(value) { - CoreManager.set('ENCRYPTED_USER', value); - }, - get encryptedUser() { - return CoreManager.get('ENCRYPTED_USER'); - }, - - /** - * @member {string} Parse.secret - * @static - */ - set secret(value) { - CoreManager.set('ENCRYPTED_KEY', value); - }, - get secret() { - return CoreManager.get('ENCRYPTED_KEY'); - }, - - /** - * @member {boolean} Parse.idempotency - * @static - */ - set idempotency(value) { - CoreManager.set('IDEMPOTENCY', value); - }, - get idempotency() { - return CoreManager.get('IDEMPOTENCY'); - }, - - /** - * @member {boolean} Parse.allowCustomObjectId - * @static - */ - set allowCustomObjectId(value) { - CoreManager.set('ALLOW_CUSTOM_OBJECT_ID', value); - }, - get allowCustomObjectId() { - return CoreManager.get('ALLOW_CUSTOM_OBJECT_ID'); - }, -}; - -Parse.ACL = require('./ParseACL').default; -Parse.Analytics = require('./Analytics'); -Parse.AnonymousUtils = require('./AnonymousUtils').default; -Parse.Cloud = require('./Cloud'); -Parse.CLP = require('./ParseCLP').default; -Parse.CoreManager = require('./CoreManager'); -Parse.Config = require('./ParseConfig').default; -Parse.Error = require('./ParseError').default; -Parse.EventuallyQueue = EventuallyQueue; -Parse.FacebookUtils = require('./FacebookUtils').default; -Parse.File = require('./ParseFile').default; -Parse.GeoPoint = require('./ParseGeoPoint').default; -Parse.Polygon = require('./ParsePolygon').default; -Parse.Installation = require('./ParseInstallation').default; -Parse.LocalDatastore = require('./LocalDatastore'); -Parse.Object = require('./ParseObject').default; -Parse.Op = { - Set: ParseOp.SetOp, - Unset: ParseOp.UnsetOp, - Increment: ParseOp.IncrementOp, - Add: ParseOp.AddOp, - Remove: ParseOp.RemoveOp, - AddUnique: ParseOp.AddUniqueOp, - Relation: ParseOp.RelationOp, -}; -Parse.Push = require('./Push'); -Parse.Query = require('./ParseQuery').default; -Parse.Relation = require('./ParseRelation').default; -Parse.Role = require('./ParseRole').default; -Parse.Schema = require('./ParseSchema').default; -Parse.Session = require('./ParseSession').default; -Parse.Storage = require('./Storage'); -Parse.User = require('./ParseUser').default; -Parse.LiveQuery = require('./ParseLiveQuery').default; -Parse.LiveQueryClient = require('./LiveQueryClient').default; -if (process.env.PARSE_BUILD === 'browser') { - Parse.IndexedDB = require('./IndexedDBStorageController'); -} -Parse._request = function (...args) { - return CoreManager.getRESTController().request.apply(null, args); -}; -Parse._ajax = function (...args) { - return CoreManager.getRESTController().ajax.apply(null, args); -}; -// We attempt to match the signatures of the legacy versions of these methods -Parse._decode = function (_, value) { - return decode(value); -}; -Parse._encode = function (value, _, disallowObjects) { - return encode(value, disallowObjects); -}; -Parse._getInstallationId = function () { - return CoreManager.getInstallationController().currentInstallationId(); -}; -/** - * Enable pinning in your application. - * This must be called after `Parse.initialize` in your application. - * - * @param [polling] Allow pinging the server /health endpoint. Default true - * @param [ms] Milliseconds to ping the server. Default 2000ms - * @static - */ -Parse.enableLocalDatastore = function (polling = true, ms: number = 2000) { - if (!Parse.applicationId) { - console.log("'enableLocalDataStore' must be called after 'initialize'"); - return; - } - if (!Parse.LocalDatastore.isEnabled) { - Parse.LocalDatastore.isEnabled = true; - if (polling) { - EventuallyQueue.poll(ms); - } - } -}; -/** - * Flag that indicates whether Local Datastore is enabled. - * - * @static - * @returns {boolean} - */ -Parse.isLocalDatastoreEnabled = function () { - return Parse.LocalDatastore.isEnabled; -}; -/** - * Gets all contents from Local Datastore - * - *
- * await Parse.dumpLocalDatastore();
- * 
- * - * @static - * @returns {object} - */ -Parse.dumpLocalDatastore = function () { - if (!Parse.LocalDatastore.isEnabled) { - console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console - return Promise.resolve({}); - } else { - return Parse.LocalDatastore._getAllContents(); - } -}; - -/** - * Enable the current user encryption. - * This must be called before login any user. - * - * @static - */ -Parse.enableEncryptedUser = function () { - Parse.encryptedUser = true; -}; - -/** - * Flag that indicates whether Encrypted User is enabled. - * - * @static - * @returns {boolean} - */ -Parse.isEncryptedUserEnabled = function () { - return Parse.encryptedUser; -}; - -CoreManager.setCryptoController(CryptoController); -CoreManager.setInstallationController(InstallationController); -CoreManager.setRESTController(RESTController); - -if (process.env.PARSE_BUILD === 'node') { - Parse.initialize = Parse._initialize; - Parse.Cloud = Parse.Cloud || {}; - Parse.Cloud.useMasterKey = function () { - CoreManager.set('USE_MASTER_KEY', true); - }; - Parse.Hooks = require('./ParseHooks'); -} - -// For legacy requires, of the form `var Parse = require('parse').Parse` -Parse.Parse = Parse; - -module.exports = Parse; diff --git a/src/Parse.ts b/src/Parse.ts new file mode 100644 index 000000000..eee273629 --- /dev/null +++ b/src/Parse.ts @@ -0,0 +1,449 @@ +import decode from './decode'; +import encode from './encode'; +import CryptoController from './CryptoController'; +import EventuallyQueue from './EventuallyQueue'; +import InstallationController from './InstallationController'; +import * as ParseOp from './ParseOp'; +import RESTController from './RESTController'; +import ACL from './ParseACL'; +import * as Analytics from './Analytics' +import AnonymousUtils from './AnonymousUtils' +import * as Cloud from './Cloud'; +import CLP from './ParseCLP'; +import CoreManager from './CoreManager'; +import Config from './ParseConfig' +import ParseError from './ParseError' +import FacebookUtils from './FacebookUtils' +import File from './ParseFile' +import GeoPoint from './ParseGeoPoint' +import Polygon from './ParsePolygon' +import Installation from './ParseInstallation' +import LocalDatastore from './LocalDatastore' +import Object from './ParseObject' +import * as Push from './Push' +import Query from './ParseQuery' +import Relation from './ParseRelation' +import Role from './ParseRole' +import Schema from './ParseSchema' +import Session from './ParseSession' +import Storage from './Storage' +import User from './ParseUser' +import LiveQuery from './ParseLiveQuery' +import LiveQueryClient from './LiveQueryClient' + +/** + * Contains all Parse API classes and functions. + * + * @static + * @global + * @class + * @hideconstructor +*/ + +interface ParseType { + ACL: typeof ACL, + Parse?: ParseType, + Analytics: typeof Analytics, + AnonymousUtils: typeof AnonymousUtils, + Cloud: typeof Cloud, + CLP: typeof CLP, + CoreManager: typeof CoreManager, + Config: typeof Config, + Error: typeof ParseError, + EventuallyQueue: typeof EventuallyQueue, + FacebookUtils: typeof FacebookUtils, + File: typeof File, + GeoPoint: typeof GeoPoint, + Hooks?: any, + Polygon: typeof Polygon, + Installation: typeof Installation, + LocalDatastore: typeof LocalDatastore, + Object: typeof Object, + Op: { + Set: typeof ParseOp.SetOp, + Unset: typeof ParseOp.UnsetOp, + Increment: typeof ParseOp.IncrementOp, + Add: typeof ParseOp.AddOp, + Remove: typeof ParseOp.RemoveOp, + AddUnique: typeof ParseOp.AddUniqueOp, + Relation: typeof ParseOp.RelationOp, + }; + Push: typeof Push, + Query: typeof Query, + Relation: typeof Relation, + Role: typeof Role, + Schema: typeof Schema, + Session: typeof Session, + Storage: typeof Storage, + User: typeof User, + LiveQuery: typeof LiveQuery, + LiveQueryClient: typeof LiveQueryClient, + + initialize(applicationId: string, javaScriptKey: string): void, + _initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void, + setAsyncStorage(storage: any): void, + setLocalDatastoreController(controller: any): void, + getServerHealth(): Promise + + applicationId: string, + javaScriptKey: string, + masterKey: string, + serverURL: string, + serverAuthToken: string, + serverAuthType: string, + liveQueryServerURL: string, + encryptedUser: boolean, + secret: string, + idempotency: boolean, + allowCustomObjectId: boolean, + IndexedDB?: any, + _request(...args: any[]): void, + _ajax(...args: any[]): void, + _decode(...args: any[]): void, + _encode(...args: any[]): void, + _getInstallationId?(): string, + enableLocalDatastore(polling: boolean, ms: number): void, + isLocalDatastoreEnabled(): boolean, + dumpLocalDatastore(): void, + enableEncryptedUser(): void, + isEncryptedUserEnabled(): void, +} + +const Parse: ParseType = { + ACL: ACL, + Analytics: Analytics, + AnonymousUtils: AnonymousUtils, + Cloud: Cloud, + CLP: CLP, + CoreManager: CoreManager, + Config: Config, + Error: ParseError, + EventuallyQueue: EventuallyQueue, + FacebookUtils: FacebookUtils, + File: File, + GeoPoint: GeoPoint, + Polygon: Polygon, + Installation: Installation, + LocalDatastore: LocalDatastore, + Object: Object, + Op: { + Set: ParseOp.SetOp, + Unset: ParseOp.UnsetOp, + Increment: ParseOp.IncrementOp, + Add: ParseOp.AddOp, + Remove: ParseOp.RemoveOp, + AddUnique: ParseOp.AddUniqueOp, + Relation: ParseOp.RelationOp, + }, + Push: Push, + Query: Query, + Relation: Relation, + Role: Role, + Schema: Schema, + Session: Session, + Storage: Storage, + User: User, + LiveQuery: LiveQuery, + LiveQueryClient: LiveQueryClient, + IndexedDB: undefined, + Hooks: undefined, + Parse: undefined, + + + /** + * Call this method first to set up your authentication tokens for Parse. + * + * @param {string} applicationId Your Parse Application ID. + * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server) + * @param {string} [masterKey] Your Parse Master Key. (Node.js only!) + * @static + */ + initialize(applicationId: string, javaScriptKey: string) { + if ( + process.env.PARSE_BUILD === 'browser' && + CoreManager.get('IS_NODE') && + !process.env.SERVER_RENDERING + ) { + /* eslint-disable no-console */ + console.log( + "It looks like you're using the browser version of the SDK in a " + + "node.js environment. You should require('parse/node') instead." + ); + /* eslint-enable no-console */ + } + Parse._initialize(applicationId, javaScriptKey); + }, + + _initialize(applicationId: string, javaScriptKey: string, masterKey?: string) { + CoreManager.set('APPLICATION_ID', applicationId); + CoreManager.set('JAVASCRIPT_KEY', javaScriptKey); + CoreManager.set('MASTER_KEY', masterKey); + CoreManager.set('USE_MASTER_KEY', false); + }, + + /** + * Call this method to set your AsyncStorage engine + * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module + * is not provided at a stable path and changes over versions. + * + * @param {AsyncStorage} storage a react native async storage. + * @static + */ + setAsyncStorage(storage: any) { + CoreManager.setAsyncStorage(storage); + }, + + /** + * Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} + * + * @param {LocalDatastoreController} controller a data storage. + * @static + */ + setLocalDatastoreController(controller: any) { + CoreManager.setLocalDatastoreController(controller); + }, + + /** + * Returns information regarding the current server's health + * + * @returns {Promise} + * @static + */ + getServerHealth() { + return CoreManager.getRESTController().request('GET', 'health'); + }, + + /** + * @member {string} Parse.applicationId + * @static + */ + set applicationId(value) { + CoreManager.set('APPLICATION_ID', value); + }, + get applicationId() { + return CoreManager.get('APPLICATION_ID'); + }, + + /** + * @member {string} Parse.javaScriptKey + * @static + */ + set javaScriptKey(value) { + CoreManager.set('JAVASCRIPT_KEY', value); + }, + get javaScriptKey() { + return CoreManager.get('JAVASCRIPT_KEY'); + }, + + /** + * @member {string} Parse.masterKey + * @static + */ + set masterKey(value) { + CoreManager.set('MASTER_KEY', value); + }, + get masterKey() { + return CoreManager.get('MASTER_KEY'); + }, + + /** + * @member {string} Parse.serverURL + * @static + */ + set serverURL(value) { + CoreManager.set('SERVER_URL', value); + }, + get serverURL() { + return CoreManager.get('SERVER_URL'); + }, + + /** + * @member {string} Parse.serverAuthToken + * @static + */ + set serverAuthToken(value) { + CoreManager.set('SERVER_AUTH_TOKEN', value); + }, + get serverAuthToken() { + return CoreManager.get('SERVER_AUTH_TOKEN'); + }, + + /** + * @member {string} Parse.serverAuthType + * @static + */ + set serverAuthType(value) { + CoreManager.set('SERVER_AUTH_TYPE', value); + }, + get serverAuthType() { + return CoreManager.get('SERVER_AUTH_TYPE'); + }, + + /** + * @member {string} Parse.liveQueryServerURL + * @static + */ + set liveQueryServerURL(value) { + CoreManager.set('LIVEQUERY_SERVER_URL', value); + }, + get liveQueryServerURL() { + return CoreManager.get('LIVEQUERY_SERVER_URL'); + }, + + /** + * @member {boolean} Parse.encryptedUser + * @static + */ + set encryptedUser(value: boolean) { + CoreManager.set('ENCRYPTED_USER', value); + }, + get encryptedUser() { + return CoreManager.get('ENCRYPTED_USER'); + }, + + /** + * @member {string} Parse.secret + * @static + */ + set secret(value) { + CoreManager.set('ENCRYPTED_KEY', value); + }, + get secret() { + return CoreManager.get('ENCRYPTED_KEY'); + }, + + /** + * @member {boolean} Parse.idempotency + * @static + */ + set idempotency(value) { + CoreManager.set('IDEMPOTENCY', value); + }, + get idempotency() { + return CoreManager.get('IDEMPOTENCY'); + }, + + /** + * @member {boolean} Parse.allowCustomObjectId + * @static + */ + set allowCustomObjectId(value) { + CoreManager.set('ALLOW_CUSTOM_OBJECT_ID', value); + }, + get allowCustomObjectId() { + return CoreManager.get('ALLOW_CUSTOM_OBJECT_ID'); + }, + + _request(...args) { + return CoreManager.getRESTController().request.apply(null, args); + }, + + _ajax(...args) { + return CoreManager.getRESTController().ajax.apply(null, args); + }, + + // We attempt to match the signatures of the legacy versions of these methods + _decode(_, value) { + return decode(value); + }, + + _encode(value, _, disallowObjects) { + return encode(value, disallowObjects); + }, + + _getInstallationId () { + return CoreManager.getInstallationController().currentInstallationId(); + }, + /** + * Enable pinning in your application. + * This must be called after `Parse.initialize` in your application. + * + * @param [polling] Allow pinging the server /health endpoint. Default true + * @param [ms] Milliseconds to ping the server. Default 2000ms + * @static + */ + enableLocalDatastore(polling = true, ms: number = 2000) { + if (!this.applicationId) { + console.log("'enableLocalDataStore' must be called after 'initialize'"); + return; + } + if (!this.LocalDatastore.isEnabled) { + this.LocalDatastore.isEnabled = true; + if (polling) { + EventuallyQueue.poll(ms); + } + } + }, + /** + * Flag that indicates whether Local Datastore is enabled. + * + * @static + * @returns {boolean} + */ + isLocalDatastoreEnabled () { + return this.LocalDatastore.isEnabled; + }, + /** + * Gets all contents from Local Datastore + * + *
+   * await Parse.dumpLocalDatastore();
+   * 
+ * + * @static + * @returns {object} + */ + dumpLocalDatastore() { + if (!this.LocalDatastore.isEnabled) { + console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console + return Promise.resolve({}); + } else { + return Parse.LocalDatastore._getAllContents(); + } + }, + + /** + * Enable the current user encryption. + * This must be called before login any user. + * + * @static + */ + enableEncryptedUser () { + this.encryptedUser = true; + }, + + /** + * Flag that indicates whether Encrypted User is enabled. + * + * @static + * @returns {boolean} + */ + isEncryptedUserEnabled () { + return this.encryptedUser; + }, + +}; + +if (process.env.PARSE_BUILD === 'browser') { + Parse.IndexedDB = require('./IndexedDBStorageController'); +} + +CoreManager.setCryptoController(CryptoController); +CoreManager.setInstallationController(InstallationController); +CoreManager.setRESTController(RESTController); + +if (process.env.PARSE_BUILD === 'node') { + Parse.initialize = Parse._initialize; + Parse.Cloud = Parse.Cloud || {}; + Parse.Cloud.useMasterKey = function () { + CoreManager.set('USE_MASTER_KEY', true); + }; + Parse.Hooks = require('./ParseHooks'); +} + +// For legacy requires, of the form `var Parse = require('parse').Parse` +Parse.Parse = Parse; + +module.exports = Parse; +export default Parse; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..570b49f91 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2015", + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "types", + "noImplicitAny": false, + "allowJs": true + }, + "include": ["src/Parse.ts"] +} \ No newline at end of file diff --git a/types/Analytics.d.ts b/types/Analytics.d.ts new file mode 100644 index 000000000..015d22a76 --- /dev/null +++ b/types/Analytics.d.ts @@ -0,0 +1,42 @@ +/** + * Parse.Analytics provides an interface to Parse's logging and analytics + * backend. + * + * @class Parse.Analytics + * @static + * @hideconstructor + */ +/** + * Tracks the occurrence of a custom event with additional dimensions. + * Parse will store a data point at the time of invocation with the given + * event name. + * + * Dimensions will allow segmentation of the occurrences of this custom + * event. Keys and values should be {@code String}s, and will throw + * otherwise. + * + * To track a user signup along with additional metadata, consider the + * following: + *
+ * var dimensions = {
+ *  gender: 'm',
+ *  source: 'web',
+ *  dayType: 'weekend'
+ * };
+ * Parse.Analytics.track('signup', dimensions);
+ * 
+ * + * There is a default limit of 8 dimensions per event tracked. + * + * @function track + * @name Parse.Analytics.track + * @param {string} name The name of the custom event to report to Parse as + * having happened. + * @param {object} dimensions The dictionary of information by which to + * segment this event. + * @returns {Promise} A promise that is resolved when the round-trip + * to the server completes. + */ +export function track(name: string, dimensions: { + [key: string]: string; +}): Promise; diff --git a/types/AnonymousUtils.d.ts b/types/AnonymousUtils.d.ts new file mode 100644 index 000000000..8637c2083 --- /dev/null +++ b/types/AnonymousUtils.d.ts @@ -0,0 +1,56 @@ +export default AnonymousUtils; +declare namespace AnonymousUtils { + /** + * Gets whether the user has their account linked to anonymous user. + * + * @function isLinked + * @name Parse.AnonymousUtils.isLinked + * @param {Parse.User} user User to check for. + * The user must be logged in on this device. + * @returns {boolean} true if the user has their account + * linked to an anonymous user. + * @static + */ + function isLinked(user: ParseUser): boolean; + /** + * Logs in a user Anonymously. + * + * @function logIn + * @name Parse.AnonymousUtils.logIn + * @param {object} options MasterKey / SessionToken. + * @returns {Promise} Logged in user + * @static + */ + function logIn(options?: RequestOptions): Promise; + /** + * Links Anonymous User to an existing PFUser. + * + * @function link + * @name Parse.AnonymousUtils.link + * @param {Parse.User} user User to link. This must be the current user. + * @param {object} options MasterKey / SessionToken. + * @returns {Promise} Linked with User + * @static + */ + function link(user: ParseUser, options?: RequestOptions): Promise; + /** + * Returns true if Authentication Provider has been registered for use. + * + * @function isRegistered + * @name Parse.AnonymousUtils.isRegistered + * @returns {boolean} + * @static + */ + function isRegistered(): boolean; + function _getAuthProvider(): { + restoreAuthentication(): boolean; + getAuthType(): string; + getAuthData(): { + authData: { + id: any; + }; + }; + }; +} +import ParseUser from './ParseUser'; +import { RequestOptions } from './RESTController'; diff --git a/types/Cloud.d.ts b/types/Cloud.d.ts new file mode 100644 index 000000000..e47654fb3 --- /dev/null +++ b/types/Cloud.d.ts @@ -0,0 +1,54 @@ +/** + * Contains functions for calling and declaring + * cloud functions. + *

+ * Some functions are only available from Cloud Code. + *

+ * + * @class Parse.Cloud + * @static + * @hideconstructor + */ +/** + * Makes a call to a cloud function. + * + * @function run + * @name Parse.Cloud.run + * @param {string} name The function name. + * @param {object} data The parameters to send to the cloud function. + * @param {object} options + * @returns {Promise} A promise that will be resolved with the result + * of the function. + */ +export function run(name: string, data: mixed, options: RequestOptions): Promise; +/** + * Gets data for the current set of cloud jobs. + * + * @function getJobsData + * @name Parse.Cloud.getJobsData + * @returns {Promise} A promise that will be resolved with the result + * of the function. + */ +export function getJobsData(): Promise; +/** + * Starts a given cloud job, which will process asynchronously. + * + * @function startJob + * @name Parse.Cloud.startJob + * @param {string} name The function name. + * @param {object} data The parameters to send to the cloud function. + * @returns {Promise} A promise that will be resolved with the jobStatusId + * of the job. + */ +export function startJob(name: string, data: mixed): Promise; +/** + * Gets job status by Id + * + * @function getJobStatus + * @name Parse.Cloud.getJobStatus + * @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'; diff --git a/types/CoreManager.d.ts b/types/CoreManager.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/CoreManager.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/CryptoController.d.ts b/types/CryptoController.d.ts new file mode 100644 index 000000000..0cebcbf5f --- /dev/null +++ b/types/CryptoController.d.ts @@ -0,0 +1,2 @@ +export function encrypt(obj: any, secretKey: string): string; +export function decrypt(encryptedText: string, secretKey: string): string; diff --git a/types/EventEmitter.d.ts b/types/EventEmitter.d.ts new file mode 100644 index 000000000..14840f3fb --- /dev/null +++ b/types/EventEmitter.d.ts @@ -0,0 +1,2 @@ +export = EventEmitter; +export = EventEmitter; diff --git a/types/EventuallyQueue.d.ts b/types/EventuallyQueue.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/EventuallyQueue.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/FacebookUtils.d.ts b/types/FacebookUtils.d.ts new file mode 100644 index 000000000..02ba4d614 --- /dev/null +++ b/types/FacebookUtils.d.ts @@ -0,0 +1,92 @@ +export default FacebookUtils; +declare namespace FacebookUtils { + /** + * Initializes Parse Facebook integration. Call this function after you + * have loaded the Facebook Javascript SDK with the same parameters + * as you would pass to + * + * FB.init(). Parse.FacebookUtils will invoke FB.init() for you + * with these arguments. + * + * @function init + * @name Parse.FacebookUtils.init + * @param {object} options Facebook options argument as described here: + * + * FB.init(). The status flag will be coerced to 'false' because it + * interferes with Parse Facebook integration. Call FB.getLoginStatus() + * explicitly if this behavior is required by your application. + */ + function init(options: any): void; + /** + * Gets whether the user has their account linked to Facebook. + * + * @function isLinked + * @name Parse.FacebookUtils.isLinked + * @param {Parse.User} user User to check for a facebook link. + * The user must be logged in on this device. + * @returns {boolean} true if the user has their account + * linked to Facebook. + */ + function isLinked(user: Parse.User): boolean; + /** + * Logs in a user using Facebook. This method delegates to the Facebook + * SDK to authenticate the user, and then automatically logs in (or + * creates, in the case where it is a new user) a Parse.User. + * + * Standard API: + * + * logIn(permission: string, authData: Object); + * + * Advanced API: Used for handling your own oAuth tokens + * {@link https://docs.parseplatform.org/rest/guide/#linking-users} + * + * logIn(authData: Object, options?: Object); + * + * @function logIn + * @name Parse.FacebookUtils.logIn + * @param {(string | object)} permissions The permissions required for Facebook + * log in. This is a comma-separated string of permissions. + * Alternatively, supply a Facebook authData object as described in our + * REST API docs if you want to handle getting facebook auth tokens + * yourself. + * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string + * @returns {Promise} + */ + function logIn(permissions: any, options: any): Promise; + /** + * Links Facebook to an existing PFUser. This method delegates to the + * Facebook SDK to authenticate the user, and then automatically links + * the account to the Parse.User. + * + * Standard API: + * + * link(user: Parse.User, permission: string, authData?: Object); + * + * Advanced API: Used for handling your own oAuth tokens + * {@link https://docs.parseplatform.org/rest/guide/#linking-users} + * + * link(user: Parse.User, authData: Object, options?: FullOptions); + * + * @function link + * @name Parse.FacebookUtils.link + * @param {Parse.User} user User to link to Facebook. This must be the + * current user. + * @param {(string | object)} permissions The permissions required for Facebook + * log in. This is a comma-separated string of permissions. + * Alternatively, supply a Facebook authData object as described in our + * REST API docs if you want to handle getting facebook auth tokens + * yourself. + * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string + * @returns {Promise} + */ + function link(user: Parse.User, permissions: any, options: any): Promise; + function unlink(user: Parse.User, options: any): Promise; + function _getAuthProvider(): { + authenticate(options: any): void; + restoreAuthentication(authData: any): boolean; + getAuthType(): string; + deauthenticate(): void; + }; +} diff --git a/types/InstallationController.d.ts b/types/InstallationController.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/InstallationController.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/LiveQueryClient.d.ts b/types/LiveQueryClient.d.ts new file mode 100644 index 000000000..1b464b7c9 --- /dev/null +++ b/types/LiveQueryClient.d.ts @@ -0,0 +1,123 @@ +export default LiveQueryClient; +/** + * Creates a new LiveQueryClient. + * Extends events.EventEmitter + * cloud functions. + * + * A wrapper of a standard WebSocket client. We add several useful methods to + * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily. + * + * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries + * to connect to the LiveQuery server + * + * We expose three events to help you monitor the status of the LiveQueryClient. + * + *
+ * let Parse = require('parse/node');
+ * let LiveQueryClient = Parse.LiveQueryClient;
+ * let client = new LiveQueryClient({
+ *   applicationId: '',
+ *   serverURL: '',
+ *   javascriptKey: '',
+ *   masterKey: ''
+ *  });
+ * 
+ * + * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event. + *
+ * client.on('open', () => {
+ *
+ * });
+ * + * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event. + *
+ * client.on('close', () => {
+ *
+ * });
+ * + * Error - When some network error or LiveQuery server error happens, you'll get this event. + *
+ * client.on('error', (error) => {
+ *
+ * });
+ * + * @alias Parse.LiveQueryClient + */ +declare class LiveQueryClient { + /** + * @param {object} options + * @param {string} options.applicationId - applicationId of your Parse app + * @param {string} options.serverURL - the URL of your LiveQuery server + * @param {string} options.javascriptKey (optional) + * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!) + * @param {string} options.sessionToken (optional) + * @param {string} options.installationId (optional) + */ + constructor({ applicationId, serverURL, javascriptKey, masterKey, sessionToken, installationId, }: { + applicationId: string; + serverURL: string; + javascriptKey: string; + masterKey: string; + sessionToken: string; + installationId: string; + }); + 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 + * + * If you provide the sessionToken, when the LiveQuery server gets ParseObject's + * updates from parse server, it'll try to check whether the sessionToken fulfills + * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose + * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol + * 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 {string} sessionToken (optional) + * @returns {LiveQuerySubscription | undefined} + */ + subscribe(query: Object, sessionToken: string | null): LiveQuerySubscription; + /** + * 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; + /** + * After open is called, the LiveQueryClient will try to send a connect request + * to the LiveQuery server. + * + */ + open(): void; + resubscribe(): void; + /** + * This method will close the WebSocket connection to this LiveQueryClient, + * cancel the auto reconnect and unsubscribe all subscriptions based on it. + * + * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event} + */ + close(): Promise | null; + _handleReset(): void; + _handleWebSocketOpen(): void; + _handleWebSocketMessage(event: any): void; + _handleWebSocketClose(): void; + _handleWebSocketError(error: any): void; + _handleReconnect(): void; +} +import LiveQuerySubscription from './LiveQuerySubscription'; diff --git a/types/LiveQuerySubscription.d.ts b/types/LiveQuerySubscription.d.ts new file mode 100644 index 000000000..b393ab8a0 --- /dev/null +++ b/types/LiveQuerySubscription.d.ts @@ -0,0 +1,101 @@ +export default Subscription; +/** + * Creates a new LiveQuery Subscription. + * Extends events.EventEmitter + * cloud functions. + * + *

Response Object - Contains data from the client that made the request + *

    + *
  • clientId
  • + *
  • installationId - requires Parse Server 4.0.0+
  • + *
+ *

+ * + *

Open Event - When you call query.subscribe(), we send a subscribe request to + * the LiveQuery server, when we get the confirmation from the LiveQuery server, + * this event will be emitted. When the client loses WebSocket connection to the + * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we + * reconnect the LiveQuery server and successfully resubscribe the ParseQuery, + * you'll also get this event. + * + *

+ * subscription.on('open', (response) => {
+ *
+ * });

+ * + *

Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe, + * you'll get this event. The object is the ParseObject which is created. + * + *

+ * subscription.on('create', (object, response) => {
+ *
+ * });

+ * + *

Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe + * is updated (The ParseObject fulfills the ParseQuery before and after changes), + * you'll get this event. The object is the ParseObject which is updated. + * Its content is the latest value of the ParseObject. + * + * Parse-Server 3.1.3+ Required for original object parameter + * + *

+ * subscription.on('update', (object, original, response) => {
+ *
+ * });

+ * + *

Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery + * but its new value fulfills the ParseQuery, you'll get this event. The object is the + * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject. + * + * Parse-Server 3.1.3+ Required for original object parameter + * + *

+ * subscription.on('enter', (object, original, response) => {
+ *
+ * });

+ * + * + *

Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value + * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject + * which leaves the ParseQuery. Its content is the latest value of the ParseObject. + * + *

+ * subscription.on('leave', (object, response) => {
+ *
+ * });

+ * + * + *

Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll + * get this event. The object is the ParseObject which is deleted. + * + *

+ * subscription.on('delete', (object, response) => {
+ *
+ * });

+ * + * + *

Close Event - When the client loses the WebSocket connection to the LiveQuery + * server and we stop receiving events, you'll get this event. + * + *

+ * 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; + subscribed: boolean; + /** + * Close the subscription + * + * @returns {Promise} + */ + unsubscribe(): Promise; +} diff --git a/types/LocalDatastore.d.ts b/types/LocalDatastore.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/LocalDatastore.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/LocalDatastoreController.d.ts b/types/LocalDatastoreController.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/LocalDatastoreController.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/LocalDatastoreController.react-native.d.ts b/types/LocalDatastoreController.react-native.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/LocalDatastoreController.react-native.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/LocalDatastoreUtils.d.ts b/types/LocalDatastoreUtils.d.ts new file mode 100644 index 000000000..3fba166c3 --- /dev/null +++ b/types/LocalDatastoreUtils.d.ts @@ -0,0 +1,8 @@ +/** + * @flow + * @private + */ +export const DEFAULT_PIN: "_default"; +export const PIN_PREFIX: "parsePin_"; +export const OBJECT_PREFIX: "Parse_LDS_"; +export function isLocalDatastoreKey(key: string): boolean; diff --git a/types/ObjectStateMutations.d.ts b/types/ObjectStateMutations.d.ts new file mode 100644 index 000000000..a40ea402f --- /dev/null +++ b/types/ObjectStateMutations.d.ts @@ -0,0 +1,27 @@ +export function defaultState(): State; +export function setServerData(serverData: AttributeMap, attributes: AttributeMap): void; +export function setPendingOp(pendingOps: Array, attr: string, op: Op | null): void; +export function pushPendingState(pendingOps: Array): void; +export function popPendingState(pendingOps: Array): OpsMap; +export function mergeFirstPendingState(pendingOps: Array): void; +export function estimateAttribute(serverData: AttributeMap, pendingOps: Array, className: string, id: string | null, attr: string): mixed; +export function estimateAttributes(serverData: AttributeMap, pendingOps: Array, className: string, id: string | null): AttributeMap; +export function commitServerChanges(serverData: AttributeMap, objectCache: ObjectCache, changes: AttributeMap): void; +type AttributeMap = { + [attr: string]: any; +}; +type OpsMap = { + [attr: string]: Op; +}; +type ObjectCache = { + [attr: string]: string; +}; +type State = { + serverData: AttributeMap; + pendingOps: OpsMap[]; + objectCache: ObjectCache; + tasks: TaskQueue; + existed: boolean; +}; +import { Op } from './ParseOp'; +export {}; diff --git a/types/OfflineQuery.d.ts b/types/OfflineQuery.d.ts new file mode 100644 index 000000000..8c8c81b16 --- /dev/null +++ b/types/OfflineQuery.d.ts @@ -0,0 +1,17 @@ +export type RelativeTimeToDateResult = { + /** + * The conversion status, `error` if conversion failed or + * `success` if conversion succeeded. + */ + status: string; + /** + * The error message if conversion failed, or the relative + * time indication (`past`, `present`, `future`) if conversion succeeded. + */ + info: string; + /** + * The converted date, or `undefined` if conversion + * failed. + */ + result: Date | undefined; +}; diff --git a/types/Parse.d.ts b/types/Parse.d.ts new file mode 100644 index 000000000..db3020c86 --- /dev/null +++ b/types/Parse.d.ts @@ -0,0 +1,103 @@ +import EventuallyQueue from './EventuallyQueue'; +import * as ParseOp from './ParseOp'; +import ACL from './ParseACL'; +import * as Analytics from './Analytics'; +import AnonymousUtils from './AnonymousUtils'; +import * as Cloud from './Cloud'; +import CLP from './ParseCLP'; +import CoreManager from './CoreManager'; +import Config from './ParseConfig'; +import ParseError from './ParseError'; +import FacebookUtils from './FacebookUtils'; +import File from './ParseFile'; +import GeoPoint from './ParseGeoPoint'; +import Polygon from './ParsePolygon'; +import Installation from './ParseInstallation'; +import LocalDatastore from './LocalDatastore'; +import Object from './ParseObject'; +import * as Push from './Push'; +import Query from './ParseQuery'; +import Relation from './ParseRelation'; +import Role from './ParseRole'; +import Schema from './ParseSchema'; +import Session from './ParseSession'; +import Storage from './Storage'; +import User from './ParseUser'; +import LiveQuery from './ParseLiveQuery'; +import LiveQueryClient from './LiveQueryClient'; +/** + * Contains all Parse API classes and functions. + * + * @static + * @global + * @class + * @hideconstructor +*/ +interface ParseType { + ACL: typeof ACL; + Parse?: ParseType; + Analytics: typeof Analytics; + AnonymousUtils: typeof AnonymousUtils; + Cloud: typeof Cloud; + CLP: typeof CLP; + CoreManager: typeof CoreManager; + Config: typeof Config; + Error: typeof ParseError; + EventuallyQueue: typeof EventuallyQueue; + FacebookUtils: typeof FacebookUtils; + File: typeof File; + GeoPoint: typeof GeoPoint; + Hooks?: any; + Polygon: typeof Polygon; + Installation: typeof Installation; + LocalDatastore: typeof LocalDatastore; + Object: typeof Object; + Op: { + Set: typeof ParseOp.SetOp; + Unset: typeof ParseOp.UnsetOp; + Increment: typeof ParseOp.IncrementOp; + Add: typeof ParseOp.AddOp; + Remove: typeof ParseOp.RemoveOp; + AddUnique: typeof ParseOp.AddUniqueOp; + Relation: typeof ParseOp.RelationOp; + }; + Push: typeof Push; + Query: typeof Query; + Relation: typeof Relation; + Role: typeof Role; + Schema: typeof Schema; + Session: typeof Session; + Storage: typeof Storage; + User: typeof User; + LiveQuery: typeof LiveQuery; + LiveQueryClient: typeof LiveQueryClient; + initialize(applicationId: string, javaScriptKey: string): void; + _initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void; + setAsyncStorage(storage: any): void; + setLocalDatastoreController(controller: any): void; + getServerHealth(): Promise; + applicationId: string; + javaScriptKey: string; + masterKey: string; + serverURL: string; + serverAuthToken: string; + serverAuthType: string; + liveQueryServerURL: string; + encryptedUser: boolean; + secret: string; + idempotency: boolean; + allowCustomObjectId: boolean; + IndexedDB?: any; + _request(...args: any[]): void; + _ajax(...args: any[]): void; + _decode(...args: any[]): void; + _encode(...args: any[]): void; + _getInstallationId?(): string; + enableLocalDatastore(polling: boolean, ms: number): void; + isLocalDatastoreEnabled(): boolean; + dumpLocalDatastore(): void; + enableEncryptedUser(): void; + isEncryptedUserEnabled(): void; +} +declare const Parse: ParseType; +export default Parse; diff --git a/types/ParseACL.d.ts b/types/ParseACL.d.ts new file mode 100644 index 000000000..3d29cf5ea --- /dev/null +++ b/types/ParseACL.d.ts @@ -0,0 +1,141 @@ +export default ParseACL; +/** + * Creates a new ACL. + * If no argument is given, the ACL has no permissions for anyone. + * If the argument is a Parse.User, the ACL will have read and write + * permission for only that user. + * If the argument is any other JSON object, that object will be interpretted + * as a serialized ACL created with toJSON(). + * + *

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

+ * + * @alias Parse.ACL + */ +declare class ParseACL { + /** + * @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. + * + * @returns {object} + */ + toJSON(): ByIdMap; + /** + * Returns whether this ACL is equal to another object + * + * @param {ParseACL} other The other object's ACL to compare to + * @returns {boolean} + */ + equals(other: ParseACL): boolean; + _setAccess(accessType: string, userId: ParseUser | ParseRole | string, allowed: boolean): void; + _getAccess(accessType: string, userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the given user is allowed to read this object. + * + * @param userId An instance of Parse.User or its objectId. + * @param {boolean} allowed Whether that user should have read access. + */ + setReadAccess(userId: ParseUser | ParseRole | string, allowed: boolean): void; + /** + * Get whether the given user id is *explicitly* allowed to read this object. + * Even if this returns false, the user may still be able to access it if + * getPublicReadAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getReadAccess(userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the given user id is allowed to write this object. + * + * @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: ParseUser | ParseRole | string, allowed: boolean): void; + /** + * Gets whether the given user id is *explicitly* allowed to write this object. + * Even if this returns false, the user may still be able to write it if + * getPublicWriteAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getWriteAccess(userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the public is allowed to read this object. + * + * @param {boolean} allowed + */ + setPublicReadAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to read this object. + * + * @returns {boolean} + */ + getPublicReadAccess(): boolean; + /** + * Sets whether the public is allowed to write this object. + * + * @param {boolean} allowed + */ + setPublicWriteAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to write this object. + * + * @returns {boolean} + */ + getPublicWriteAccess(): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to read this object. Even if this returns false, the role may + * still be able to write it if a parent role has read access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has read access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleReadAccess(role: ParseRole | string): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to write this object. Even if this returns false, the role may + * still be able to write it if a parent role has write access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has write access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleWriteAccess(role: ParseRole | string): boolean; + /** + * Sets whether users belonging to the given role are allowed + * to read this object. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can read this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Sets whether users belonging to the given role are allowed + * to write this object. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can write this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + 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; +}; diff --git a/types/ParseCLP.d.ts b/types/ParseCLP.d.ts new file mode 100644 index 000000000..14b36e7d3 --- /dev/null +++ b/types/ParseCLP.d.ts @@ -0,0 +1,290 @@ +type PermissionsMap = { + [permission: string]: UsersMap; +}; +export default ParseCLP; +type UsersMap = { + [userId: string]: any; +}; +declare const UsersMap: any; +/** + * Creates a new CLP. + * If no argument is given, the CLP has no permissions for anyone. + * If the argument is a Parse.User or Parse.Role, the CLP will have read and write + * permission for only that user or role. + * If the argument is any other JSON object, that object will be interpretted + * as a serialized CLP created with toJSON(). + * + *

A CLP, or Class Level Permissions can be added to any + * Parse.Schema to restrict access to only a subset of users + * of your application.

+ * + *

+ * For get/count/find/create/update/delete/addField using the following functions: + * + * Entity is type Parse.User or Parse.Role or string + * Role is type Parse.Role or Name of Parse.Role + * + * getGetRequiresAuthentication() + * setGetRequiresAuthentication(allowed: boolean) + * getGetPointerFields() + * setGetPointerFields(pointerFields: string[]) + * getGetAccess(entity: Entity) + * setGetAccess(entity: Entity, allowed: boolean) + * getPublicGetAccess() + * setPublicGetAccess(allowed: boolean) + * getRoleGetAccess(role: Role) + * setRoleGetAccess(role: Role, allowed: boolean) + * getFindRequiresAuthentication() + * setFindRequiresAuthentication(allowed: boolean) + * getFindPointerFields() + * setFindPointerFields(pointerFields: string[]) + * getFindAccess(entity: Entity) + * setFindAccess(entity: Entity, allowed: boolean) + * getPublicFindAccess() + * setPublicFindAccess(allowed: boolean) + * getRoleFindAccess(role: Role) + * setRoleFindAccess(role: Role, allowed: boolean) + * getCountRequiresAuthentication() + * setCountRequiresAuthentication(allowed: boolean) + * getCountPointerFields() + * setCountPointerFields(pointerFields: string[]) + * getCountAccess(entity: Entity) + * setCountAccess(entity: Entity, allowed: boolean) + * getPublicCountAccess() + * setPublicCountAccess(allowed: boolean) + * getRoleCountAccess(role: Role) + * setRoleCountAccess(role: Role, allowed: boolean) + * getCreateRequiresAuthentication() + * setCreateRequiresAuthentication(allowed: boolean) + * getCreatePointerFields() + * setCreatePointerFields(pointerFields: string[]) + * getCreateAccess(entity: Entity) + * setCreateAccess(entity: Entity, allowed: boolean) + * getPublicCreateAccess() + * setPublicCreateAccess(allowed: Boolean) + * getRoleCreateAccess(role: Role) + * setRoleCreateAccess(role: Role, allowed: boolean) + * getUpdateRequiresAuthentication() + * setUpdateRequiresAuthentication(allowed: boolean) + * getUpdatePointerFields() + * setUpdatePointerFields(pointerFields: string[]) + * getUpdateAccess(entity: Entity) + * setUpdateAccess(entity: Entity, allowed: boolean) + * getPublicUpdateAccess() + * setPublicUpdateAccess(allowed: boolean) + * getRoleUpdateAccess(role: Role) + * setRoleUpdateAccess(role: Role, allowed: boolean) + * getDeleteRequiresAuthentication() + * setDeleteRequiresAuthentication(allowed: boolean) + * getDeletePointerFields() + * setDeletePointerFields(pointerFields: string[]) + * getDeleteAccess(entity: Entity) + * setDeleteAccess(entity: Entity, allowed: boolean) + * getPublicDeleteAccess() + * setPublicDeleteAccess(allowed: boolean) + * getRoleDeleteAccess(role: Role) + * setRoleDeleteAccess(role: Role, allowed: boolean) + * getAddFieldRequiresAuthentication() + * setAddFieldRequiresAuthentication(allowed: boolean) + * getAddFieldPointerFields() + * setAddFieldPointerFields(pointerFields: string[]) + * getAddFieldAccess(entity: Entity) + * setAddFieldAccess(entity: Entity, allowed: boolean) + * getPublicAddFieldAccess() + * setPublicAddFieldAccess(allowed: boolean) + * getRoleAddFieldAccess(role: Role) + * setRoleAddFieldAccess(role: Role, allowed: boolean) + *

+ * + * @alias Parse.CLP + */ +declare class ParseCLP { + /** + * @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. + * + * @returns {object} + */ + toJSON(): PermissionsMap; + /** + * Returns whether this CLP is equal to another object + * + * @param other The other object to compare to + * @returns {boolean} + */ + 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; + _setGroupPointerPermission(operation: string, pointerFields: string[]): void; + _getGroupPointerPermissions(operation: string): string[]; + /** + * Sets user pointer fields to allow permission for get/count/find operations. + * + * @param {string[]} pointerFields User pointer fields + */ + setReadUserFields(pointerFields: string[]): void; + /** + * @returns {string[]} User pointer fields + */ + getReadUserFields(): string[]; + /** + * Sets user pointer fields to allow permission for create/delete/update/addField operations + * + * @param {string[]} pointerFields User pointer fields + */ + setWriteUserFields(pointerFields: string[]): void; + /** + * @returns {string[]} User pointer fields + */ + getWriteUserFields(): string[]; + /** + * Sets whether the given user is allowed to retrieve fields from this class. + * + * @param userId An instance of Parse.User or its objectId. + * @param {string[]} fields fields to be protected + */ + setProtectedFields(userId: any, 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[]; + /** + * 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; + /** + * 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 + * getPublicReadAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getReadAccess(userId: any): 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; + /** + * 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 + * getPublicWriteAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getWriteAccess(userId: any): boolean; + /** + * Sets whether the public is allowed to read from this class. + * + * @param {boolean} allowed + */ + setPublicReadAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to read from this class. + * + * @returns {boolean} + */ + getPublicReadAccess(): boolean; + /** + * Sets whether the public is allowed to write to this class. + * + * @param {boolean} allowed + */ + setPublicWriteAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to write to this class. + * + * @returns {boolean} + */ + getPublicWriteAccess(): boolean; + /** + * Sets whether the public is allowed to protect fields in this class. + * + * @param {string[]} fields + */ + setPublicProtectedFields(fields: string[]): void; + /** + * Gets whether the public is allowed to read fields from this class. + * + * @returns {string[]} + */ + getPublicProtectedFields(): string[]; + /** + * Gets whether users belonging to the given role are allowed + * to read from this class. Even if this returns false, the role may + * still be able to write it if a parent role has read access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has read access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleReadAccess(role: ParseRole | string): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to write to this user. Even if this returns false, the role may + * still be able to write it if a parent role has write access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has write access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleWriteAccess(role: ParseRole | string): boolean; + /** + * Sets whether users belonging to the given role are allowed + * to read from this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can read this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Sets whether users belonging to the given role are allowed + * to write to this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can write this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Gets whether users belonging to the given role are allowed + * to count to this user. Even if this returns false, the role may + * still be able to count it if a parent role has count access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {string[]} + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleProtectedFields(role: ParseRole | string): string[]; + /** + * Sets whether users belonging to the given role are allowed + * to set access field in this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {string[]} fields Fields to be protected by Role. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleProtectedFields(role: ParseRole | string, fields: string[]): void; +} +import ParseRole from './ParseRole'; +import ParseUser from './ParseUser'; diff --git a/types/ParseConfig.d.ts b/types/ParseConfig.d.ts new file mode 100644 index 000000000..c51436666 --- /dev/null +++ b/types/ParseConfig.d.ts @@ -0,0 +1,76 @@ +export default ParseConfig; +/** + * Parse.Config is a local representation of configuration data that + * can be set from the Parse dashboard. + * + * @alias Parse.Config + */ +declare class ParseConfig { + /** + * Retrieves the most recently-fetched configuration object, either from + * memory or from local storage if necessary. + * + * @static + * @returns {Parse.Config} The most recently-fetched Parse.Config if it + * exists, else an empty Parse.Config. + */ + static current(): Parse.Config; + /** + * Gets a new configuration object from the server. + * + * @static + * @param {object} options + * Valid options are:
    + *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
+ * @returns {Promise} A promise that is resolved with a newly-created + * configuration object when the get completes. + */ + static get(options?: RequestOptions): Promise; + /** + * Save value keys to the server. + * + * @static + * @param {object} attrs The config parameters and values. + * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed + * in `attrs` should be retrievable only by using the master key. + * For example: `param1: true` makes `param1` only retrievable by using the master key. + * If a parameter is not provided or set to `false`, it can be retrieved without + * using the master key. + * @returns {Promise} A promise that is resolved with a newly-created + * configuration object or with the current with the update. + */ + static save(attrs: { + [key: string]: any; + }, masterKeyOnlyFlags: { + [key: string]: any; + }): Promise; + /** + * Used for testing + * + * @private + */ + private static _clearCache; + attributes: { + [key: string]: any; + }; + _escapedAttributes: { + [key: string]: any; + }; + /** + * Gets the value of an attribute. + * + * @param {string} attr The name of an attribute. + * @returns {*} + */ + get(attr: string): any; + /** + * Gets the HTML-escaped value of an attribute. + * + * @param {string} attr The name of an attribute. + * @returns {string} + */ + escape(attr: string): string; +} +import { RequestOptions } from './RESTController'; diff --git a/types/ParseError.d.ts b/types/ParseError.d.ts new file mode 100644 index 000000000..a276ae251 --- /dev/null +++ b/types/ParseError.d.ts @@ -0,0 +1,77 @@ +export default ParseError; +/** + * Constructs a new Parse.Error object with the given code and message. + * + * @alias Parse.Error + */ +declare 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: 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; +} diff --git a/types/ParseFile.d.ts b/types/ParseFile.d.ts new file mode 100644 index 000000000..78d5becbd --- /dev/null +++ b/types/ParseFile.d.ts @@ -0,0 +1,180 @@ +type FileSource = { + format: "file"; + file: Blob; + type: string; +} | { + format: "base64"; + base64: string; + type: string; +} | { + format: "uri"; + uri: string; + type: string; +}; +export default ParseFile; +/** + * A Parse.File is a local representation of a file that is saved to the Parse + * cloud. + * + * @alias Parse.File + */ +declare class ParseFile { + static fromJSON(obj: any): ParseFile; + static encodeBase64(bytes: Array): string; + /** + * @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 + * an alphanumeric character, and consist of alphanumeric characters, + * periods, spaces, underscores, or dashes. + * @param data {Array} The data for the file, as either: + * 1. an Array of byte value Numbers, or + * 2. an Object like { base64: "..." } with a base64-encoded String. + * 3. an Object like { uri: "..." } with a uri String. + * 4. a File object selected with a file upload control. (3) only works + * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+. + * For example: + *
+     * var fileUploadControl = $("#profilePhotoFileUpload")[0];
+     * if (fileUploadControl.files.length > 0) {
+     *   var file = fileUploadControl.files[0];
+     *   var name = "photo.jpg";
+     *   var parseFile = new Parse.File(name, file);
+     *   parseFile.save().then(function() {
+     *     // The file has been saved to Parse.
+     *   }, function(error) {
+     *     // The file either could not be read, or could not be saved to Parse.
+     *   });
+     * }
+ * @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 + */ + constructor(name: string, data?: FileData, type?: string, metadata?: Object, tags?: Object); + _name: string; + _url: string | null; + _source: FileSource; + _previousSave: Promise | null; + _data: string | null; + _requestTask: any | null; + _metadata: Object | null; + _tags: Object | null; + /** + * 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. + * Data is cleared if saved with File object selected with a file upload control + * + * @returns {Promise} Promise that is resolve with base64 data + */ + getData(): Promise; + /** + * Gets the name of the file. Before save is called, this is the filename + * given by the user. After save is called, that name gets prefixed with a + * unique identifier. + * + * @returns {string} + */ + name(): string; + /** + * Gets the url of the file. It is only available after you save the file or + * after you get the file from a Parse.Object. + * + * @param {object} options An object to specify url options + * @returns {string | undefined} + */ + url(options?: { + forceSecure?: boolean; + }): string | null; + /** + * Gets the metadata of the file. + * + * @returns {object} + */ + metadata(): Object; + /** + * Gets the tags of the file. + * + * @returns {object} + */ + tags(): Object; + /** + * Saves the file to the Parse cloud. + * + * @param {object} options + * Valid options are:
    + *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
  • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
  • progress: In Browser only, callback for upload progress. For example: + *
    +     * let parseFile = new Parse.File(name, file);
    +     * parseFile.save({
    +     *   progress: (progressValue, loaded, total, { type }) => {
    +     *     if (type === "upload" && progressValue !== null) {
    +     *       // Update the UI using progressValue
    +     *     }
    +     *   }
    +     * });
    +     * 
    + *
+ * @returns {Promise | undefined} Promise that is resolved when the save finishes. + */ + save(options?: FullOptions): Promise | null; + /** + * Aborts the request if it has already been sent. + */ + cancel(): void; + /** + * Deletes the file from the Parse cloud. + * In Cloud Code and Node only with Master Key. + * + * @param {object} options + * Valid options are:
    + *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    +     * @returns {Promise} Promise that is resolved when the delete finishes.
    +     */
    +    destroy(options?: FullOptions): Promise;
    +    toJSON(): {
    +        name: string | null;
    +        url: string | null;
    +    };
    +    equals(other: mixed): boolean;
    +    /**
    +     * Sets metadata to be saved with file object. Overwrites existing metadata
    +     *
    +     * @param {object} metadata Key value pairs to be stored with file object
    +     */
    +    setMetadata(metadata: any): void;
    +    /**
    +     * Sets metadata to be saved with file object. Adds to existing metadata.
    +     *
    +     * @param {string} key key to store the metadata
    +     * @param {*} value metadata
    +     */
    +    addMetadata(key: string, value: any): void;
    +    /**
    +     * Sets tags to be saved with file object. Overwrites existing tags
    +     *
    +     * @param {object} tags Key value pairs to be stored with file object
    +     */
    +    setTags(tags: any): void;
    +    /**
    +     * Sets tags to be saved with file object. Adds to existing tags.
    +     *
    +     * @param {string} key key to store tags
    +     * @param {*} value tag
    +     */
    +    addTag(key: string, value: string): void;
    +}
    +import { FullOptions } from './RESTController';
    +type FileData = number[] | Blob | Base64 | Uri;
    +type Base64 = {
    +    base64: string;
    +};
    +type Uri = {
    +    uri: string;
    +};
    diff --git a/types/ParseGeoPoint.d.ts b/types/ParseGeoPoint.d.ts
    new file mode 100644
    index 000000000..4d6c4efd0
    --- /dev/null
    +++ b/types/ParseGeoPoint.d.ts
    @@ -0,0 +1,97 @@
    +export default ParseGeoPoint;
    +/**
    + * @flow
    + */
    +/**
    + * Creates a new GeoPoint with any of the following forms:
    + *
    + *   new GeoPoint(otherGeoPoint)
    + *   new GeoPoint(30, 30)
    + *   new GeoPoint([30, 30])
    + *   new GeoPoint({latitude: 30, longitude: 30})
    + *   new GeoPoint()  // defaults to (0, 0)
    + *   
    + *

    Represents a latitude / longitude point that may be associated + * with a key in a ParseObject or used as a reference point for geo queries. + * This allows proximity-based queries on the key.

    + * + *

    Only one key in a class may contain a GeoPoint.

    + * + *

    Example:

    + *   var point = new Parse.GeoPoint(30.0, -20.0);
    + *   var object = new Parse.Object("PlaceObject");
    + *   object.set("location", point);
    + *   object.save();

    + * + * @alias Parse.GeoPoint + */ +declare class ParseGeoPoint { + static _validate(latitude: number, longitude: number): void; + /** + * Creates a GeoPoint with the user's current location, if available. + * + * @static + * @returns {Parse.GeoPoint} User's current location + */ + static current(): Parse.GeoPoint; + /** + * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point. + * @param {number} arg2 The longitude of the GeoPoint + */ + constructor(arg1: Array | { + latitude: number; + longitude: number; + } | number, arg2?: number); + _latitude: number; + _longitude: number; + set latitude(arg: number); + /** + * North-south portion of the coordinate, in range [-90, 90]. + * Throws an exception if set out of range in a modern browser. + * + * @property {number} latitude + * @returns {number} + */ + get latitude(): number; + set longitude(arg: number); + /** + * East-west portion of the coordinate, in range [-180, 180]. + * Throws if set out of range in a modern browser. + * + * @property {number} longitude + * @returns {number} + */ + get longitude(): number; + /** + * Returns a JSON representation of the GeoPoint, suitable for Parse. + * + * @returns {object} + */ + toJSON(): { + __type: string; + latitude: number; + longitude: number; + }; + equals(other: mixed): boolean; + /** + * Returns the distance from this GeoPoint to another in radians. + * + * @param {Parse.GeoPoint} point the other Parse.GeoPoint. + * @returns {number} + */ + radiansTo(point: ParseGeoPoint): number; + /** + * Returns the distance from this GeoPoint to another in kilometers. + * + * @param {Parse.GeoPoint} point the other Parse.GeoPoint. + * @returns {number} + */ + kilometersTo(point: ParseGeoPoint): number; + /** + * Returns the distance from this GeoPoint to another in miles. + * + * @param {Parse.GeoPoint} point the other Parse.GeoPoint. + * @returns {number} + */ + milesTo(point: ParseGeoPoint): number; +} diff --git a/types/ParseInstallation.d.ts b/types/ParseInstallation.d.ts new file mode 100644 index 000000000..b0c07e2df --- /dev/null +++ b/types/ParseInstallation.d.ts @@ -0,0 +1,5 @@ +export default class Installation extends ParseObject { + constructor(attributes: AttributeMap | null); +} +import ParseObject from './ParseObject'; +import { AttributeMap } from './ObjectStateMutations'; diff --git a/types/ParseLiveQuery.d.ts b/types/ParseLiveQuery.d.ts new file mode 100644 index 000000000..6e98e68c1 --- /dev/null +++ b/types/ParseLiveQuery.d.ts @@ -0,0 +1,29 @@ +export default LiveQuery; +/** + * We expose three events to help you monitor the status of the WebSocket connection: + * + *

    Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event. + * + *

    + * Parse.LiveQuery.on('open', () => {
    + *
    + * });

    + * + *

    Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event. + * + *

    + * Parse.LiveQuery.on('close', () => {
    + *
    + * });

    + * + *

    Error - When some network error or LiveQuery server error happens, you'll get this event. + * + *

    + * Parse.LiveQuery.on('error', (error) => {
    + *
    + * });

    + * + * @class Parse.LiveQuery + * @static + */ +declare const LiveQuery: any; diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts new file mode 100644 index 000000000..e86c0c6c0 --- /dev/null +++ b/types/ParseObject.d.ts @@ -0,0 +1,1006 @@ +type Pointer = { + __type: string; + className: string; + objectId: string; +}; +type SaveOptions = FullOptions & { + cascadeSave?: boolean; + context?: AttributeMap; +}; +export default ParseObject; +/** + * Creates a new model with defined attributes. + * + *

    You won't normally call this method directly. It is recommended that + * you use a subclass of Parse.Object instead, created by calling + * extend.

    + * + *

    However, if you don't want to use a subclass, or aren't sure which + * subclass is appropriate, you can use this form:

    + *     var object = new Parse.Object("ClassName");
    + * 
    + * That is basically equivalent to:
    + *     var MyClass = Parse.Object.extend("ClassName");
    + *     var object = new MyClass();
    + * 

    + * + * @alias Parse.Object + */ +declare class ParseObject { + static _getClassMap(): {}; + static _clearAllState(): void; + /** + * Fetches the given list of Parse.Object. + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAll([object1, object2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • include: The name(s) of the key(s) to include. Can be a string, an array of strings, + * or an array of array of strings. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAll(list: Array, options?: RequestOptions): Parse.Object[]; + /** + * Fetches the given list of Parse.Object. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAllWithInclude(list: Array, keys: String | Array>, options: RequestOptions): Parse.Object[]; + /** + * Fetches the given list of Parse.Object if needed. + * If any error is encountered, stops and calls the error handler. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAllIfNeededWithInclude(list: Array, keys: String | Array>, options: RequestOptions): Parse.Object[]; + /** + * Fetches the given list of Parse.Object if needed. + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllIfNeeded([object1, ...])
    +     *    .then((list) => {
    +     *      // Objects were fetched and updated.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * @static + * @returns {Parse.Object[]} + */ + static fetchAllIfNeeded(list: Array, options: object): Parse.Object[]; + static handleIncludeOptions(options: any): any[]; + /** + * Destroy the given list of models on the server if it was already persisted. + * + *

    Unlike saveAll, if an error occurs while deleting an individual model, + * this method will continue trying to delete the rest of the models if + * possible, except in the case of a fatal error like a connection error. + * + *

    In particular, the Parse.Error object returned in the case of error may + * be one of two types: + * + *

      + *
    • A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an + * array of other Parse.Error objects. Each error object in this array + * has an "object" property that references the object that could not be + * deleted (for instance, because that object could not be found).
    • + *
    • A non-aggregate Parse.Error. This indicates a serious error that + * caused the delete operation to be aborted partway through (for + * instance, a connection failure in the middle of the delete).
    • + *
    + * + *
    +     * Parse.Object.destroyAll([object1, object2, ...])
    +     * .then((list) => {
    +     * // All the objects were deleted.
    +     * }, (error) => {
    +     * // An error occurred while deleting one or more of the objects.
    +     * // If this is an aggregate error, then we can inspect each error
    +     * // object individually to determine the reason why a particular
    +     * // object was not deleted.
    +     * if (error.code === Parse.Error.AGGREGATE_ERROR) {
    +     * for (var i = 0; i < error.errors.length; i++) {
    +     * console.log("Couldn't delete " + error.errors[i].object.id +
    +     * "due to " + error.errors[i].message);
    +     * }
    +     * } else {
    +     * console.log("Delete aborted because of " + error.message);
    +     * }
    +     * });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled when the destroyAll + * completes. + */ + static destroyAll(list: Array, options?: object): Promise; + /** + * Saves the given list of Parse.Object. + * If any error is encountered, stops and calls the error handler. + * + *
    +     * Parse.Object.saveAll([object1, object2, ...])
    +     * .then((list) => {
    +     * // All the objects were saved.
    +     * }, (error) => {
    +     * // An error occurred while saving one of the objects.
    +     * });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * @static + * @returns {Parse.Object[]} + */ + static saveAll(list: Array, options?: RequestOptions): Parse.Object[]; + /** + * Creates a reference to a subclass of Parse.Object with the given id. This + * does not exist on Parse.Object, only on subclasses. + * + *

    A shortcut for:

    +     *  var Foo = Parse.Object.extend("Foo");
    +     *  var pointerToFoo = new Foo();
    +     *  pointerToFoo.id = "myObjectId";
    +     * 
    + * + * @param {string} id The ID of the object to create a reference to. + * @static + * @returns {Parse.Object} A Parse.Object reference. + */ + static createWithoutData(id: string): Parse.Object; + /** + * Creates a new instance of a Parse Object from a JSON representation. + * + * @param {object} json The JSON map of the Object's data + * @param {boolean} override In single instance mode, all old server data + * is overwritten if this is set to true + * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty + * @static + * @returns {Parse.Object} A Parse.Object reference + */ + static fromJSON(json: any, override?: boolean, dirty?: boolean): Parse.Object; + /** + * Registers a subclass of Parse.Object with a specific class name. + * When objects of that class are retrieved from a query, they will be + * instantiated with this subclass. + * This is only necessary when using ES6 subclassing. + * + * @param {string} className The class name of the subclass + * @param {Function} constructor The subclass + */ + static registerSubclass(className: string, constructor: any): void; + /** + * Unegisters a subclass of Parse.Object with a specific class name. + * + * @param {string} className The class name of the subclass + */ + static unregisterSubclass(className: string): void; + /** + * Creates a new subclass of Parse.Object for the given Parse class name. + * + *

    Every extension of a Parse class will inherit from the most recent + * previous extension of that class. When a Parse.Object is automatically + * created by parsing JSON, it will use the most recent extension of that + * class.

    + * + *

    You should call either:

    +     *     var MyClass = Parse.Object.extend("MyClass", {
    +     *         Instance methods,
    +     *         initialize: function(attrs, options) {
    +     *             this.someInstanceProperty = [],
    +     *             Other instance properties
    +     *         }
    +     *     }, {
    +     *         Class properties
    +     *     });
    + * or, for Backbone compatibility:
    +     *     var MyClass = Parse.Object.extend({
    +     *         className: "MyClass",
    +     *         Instance methods,
    +     *         initialize: function(attrs, options) {
    +     *             this.someInstanceProperty = [],
    +     *             Other instance properties
    +     *         }
    +     *     }, {
    +     *         Class properties
    +     *     });

    + * + * @param {string} className The name of the Parse class backing this model. + * @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 + * this method. + * @returns {Parse.Object} A new subclass of Parse.Object. + */ + static extend(className: any, protoProps: any, classProps: any): Parse.Object; + /** + * Enable single instance objects, where any local objects with the same Id + * share the same attributes, and stay synchronized with each other. + * This is disabled by default in server environments, since it can lead to + * security issues. + * + * @static + */ + static enableSingleInstance(): void; + /** + * Disable single instance objects, where any local objects with the same Id + * share the same attributes, and stay synchronized with each other. + * When disabled, you can have two instances of the same object in memory + * without them sharing attributes. + * + * @static + */ + static disableSingleInstance(): void; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, + * recursively, using a default pin name: _default. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await Parse.Object.pinAll([...]);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPin() + * + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the pin completes. + * @static + */ + static pinAll(objects: Array): Promise; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, recursively. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPinWithName(name) + * + * @param {string} name Name of Pin. + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the pin completes. + * @static + */ + static pinAllWithName(name: string, objects: Array): Promise; + /** + * Asynchronously removes the objects and every object they point to in the local datastore, + * recursively, using a default pin name: _default. + * + *
    +     * await Parse.Object.unPinAll([...]);
    +     * 
    + * + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAll(objects: Array): Promise; + /** + * Asynchronously removes the objects and every object they point to in the local datastore, recursively. + * + *
    +     * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
    +     * 
    + * + * @param {string} name Name of Pin. + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllWithName(name: string, objects: Array): Promise; + /** + * Asynchronously removes all objects in the local datastore using a default pin name: _default. + * + *
    +     * await Parse.Object.unPinAllObjects();
    +     * 
    + * + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllObjects(): Promise; + /** + * Asynchronously removes all objects with the specified pin name. + * Deletes the pin name also. + * + *
    +     * await Parse.Object.unPinAllObjectsWithName(name);
    +     * 
    + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllObjectsWithName(name: string): Promise; + /** + * @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. + */ + constructor(className: string | { + [attr: string]: mixed; + className: string; + }, attributes?: { + [attr: string]: mixed; + }, options?: { + ignoreValidation: boolean; + }, ...args: any[]); + _objCount: number; + className: string; + /** + * The ID of this object, unique within its class. + * + * @property {string} id + */ + id: string | null; + _localId: string | null; + get attributes(): AttributeMap; + /** + * The first time this object was saved on the server. + * + * @property {Date} createdAt + * @returns {Date} + */ + get createdAt(): Date; + /** + * The last time this object was updated on the server. + * + * @property {Date} updatedAt + * @returns {Date} + */ + get updatedAt(): Date; + /** + * Returns a local or server Id used uniquely identify this object + * + * @returns {string} + */ + _getId(): string; + /** + * Returns a unique identifier used to pull data from the State Controller. + * + * @returns {Parse.Object|object} + */ + _getStateIdentifier(): ParseObject | { + id: string; + className: string; + }; + _getServerData(): AttributeMap; + _clearServerData(): void; + _getPendingOps(): Array; + /** + * @param {Array} [keysToClear] - if specified, only ops matching + * these fields will be cleared + */ + _clearPendingOps(keysToClear?: Array): void; + _getDirtyObjectAttributes(): AttributeMap; + _toFullJSON(seen?: Array, offline?: boolean): AttributeMap; + _getSaveJSON(): AttributeMap; + _getSaveParams(): SaveParams; + _finishFetch(serverData: AttributeMap): void; + _setExisted(existed: boolean): void; + _migrateId(serverId: string): void; + _handleSaveResponse(response: AttributeMap, status: number): void; + _handleSaveError(): void; + initialize(): void; + /** + * Returns a JSON version of the object suitable for saving to Parse. + * + * @param seen + * @param offline + * @returns {object} + */ + toJSON(seen: Array | void, offline?: boolean): AttributeMap; + /** + * Determines whether this ParseObject is equal to another ParseObject + * + * @param {object} other - An other object ot compare + * @returns {boolean} + */ + equals(other: mixed): boolean; + /** + * Returns true if this object has been modified since its last + * save/refresh. If an attribute is specified, it returns true only if that + * particular attribute has been modified since the last save/refresh. + * + * @param {string} attr An attribute name (optional). + * @returns {boolean} + */ + dirty(attr?: string): boolean; + /** + * Returns an array of keys that have been modified since last save/refresh + * + * @returns {string[]} + */ + dirtyKeys(): Array; + /** + * Returns true if the object has been fetched. + * + * @returns {boolean} + */ + isDataAvailable(): boolean; + /** + * Gets a Pointer referencing this Object. + * + * @returns {Pointer} + */ + toPointer(): Pointer; + /** + * Gets a Pointer referencing this Object. + * + * @returns {Pointer} + */ + toOfflinePointer(): Pointer; + /** + * Gets the value of an attribute. + * + * @param {string} attr The string name of an attribute. + * @returns {*} + */ + get(attr: string): mixed; + /** + * Gets a relation on the given class for the attribute. + * + * @param {string} attr The attribute to get the relation for. + * @returns {Parse.Relation} + */ + relation(attr: string): ParseRelation; + /** + * Gets the HTML-escaped value of an attribute. + * + * @param {string} attr The string name of an attribute. + * @returns {string} + */ + escape(attr: string): string; + /** + * Returns true if the attribute contains a value that is not + * null or undefined. + * + * @param {string} attr The string name of the attribute. + * @returns {boolean} + */ + has(attr: string): boolean; + /** + * Sets a hash of model attributes on the object. + * + *

    You can call it with an object containing keys and values, with one + * key and value, or dot notation. For example:

    +     *   gameTurn.set({
    +     *     player: player1,
    +     *     diceRoll: 2
    +     *   }, {
    +     *     error: function(gameTurnAgain, error) {
    +     *       // The set failed validation.
    +     *     }
    +     *   });
    +     *
    +     *   game.set("currentPlayer", player2, {
    +     *     error: function(gameTurnAgain, error) {
    +     *       // The set failed validation.
    +     *     }
    +     *   });
    +     *
    +     *   game.set("finished", true);

    + * + * game.set("player.score", 10);

    + * + * @param {(string|object)} key The key to set. + * @param {(string|object)} value The value to give it. + * @param {object} options A set of options for the set. + * The only supported option is error. + * @returns {(ParseObject|boolean)} true if the set succeeded. + */ + set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean; + /** + * Remove an attribute from the model. This is a noop if the attribute doesn't + * exist. + * + * @param {string} attr The string name of an attribute. + * @param options + * @returns {(ParseObject | boolean)} + */ + unset(attr: string, options?: { + [opt: string]: mixed; + }): ParseObject | boolean; + /** + * Atomically increments the value of the given attribute the next time the + * object is saved. If no amount is specified, 1 is used by default. + * + * @param attr {String} The key. + * @param amount {Number} The amount to increment by (optional). + * @returns {(ParseObject|boolean)} + */ + increment(attr: string, amount?: number): ParseObject | boolean; + /** + * Atomically decrements the value of the given attribute the next time the + * object is saved. If no amount is specified, 1 is used by default. + * + * @param attr {String} The key. + * @param amount {Number} The amount to decrement by (optional). + * @returns {(ParseObject | boolean)} + */ + decrement(attr: string, amount?: number): ParseObject | boolean; + /** + * Atomically add an object to the end of the array associated with a given + * key. + * + * @param attr {String} The key. + * @param item {} The item to add. + * @returns {(ParseObject | boolean)} + */ + add(attr: string, item: mixed): ParseObject | boolean; + /** + * Atomically add the objects to the end of the array associated with a given + * key. + * + * @param attr {String} The key. + * @param items {Object[]} The items to add. + * @returns {(ParseObject | boolean)} + */ + addAll(attr: string, items: Array): ParseObject | boolean; + /** + * Atomically add an object to the array associated with a given key, only + * if it is not already present in the array. The position of the insert is + * not guaranteed. + * + * @param attr {String} The key. + * @param item {} The object to add. + * @returns {(ParseObject | boolean)} + */ + addUnique(attr: string, item: mixed): ParseObject | boolean; + /** + * Atomically add the objects to the array associated with a given key, only + * if it is not already present in the array. The position of the insert is + * not guaranteed. + * + * @param attr {String} The key. + * @param items {Object[]} The objects to add. + * @returns {(ParseObject | boolean)} + */ + addAllUnique(attr: string, items: Array): ParseObject | boolean; + /** + * Atomically remove all instances of an object from the array associated + * with a given key. + * + * @param attr {String} The key. + * @param item {} The object to remove. + * @returns {(ParseObject | boolean)} + */ + remove(attr: string, item: mixed): ParseObject | boolean; + /** + * Atomically remove all instances of the objects from the array associated + * with a given key. + * + * @param attr {String} The key. + * @param items {Object[]} The object to remove. + * @returns {(ParseObject | boolean)} + */ + removeAll(attr: string, items: Array): ParseObject | boolean; + /** + * Returns an instance of a subclass of Parse.Op describing what kind of + * modification has been performed on this field since the last time it was + * saved. For example, after calling object.increment("x"), calling + * object.op("x") would return an instance of Parse.Op.Increment. + * + * @param attr {String} The key. + * @returns {Parse.Op | undefined} The operation, or undefined if none. + */ + op(attr: string): Op | null; + /** + * Creates a new model with identical attributes to this one. + * + * @returns {Parse.Object} + */ + clone(): any; + /** + * Creates a new instance of this object. Not to be confused with clone() + * + * @returns {Parse.Object} + */ + newInstance(): any; + /** + * Returns true if this object has never been saved to Parse. + * + * @returns {boolean} + */ + isNew(): boolean; + /** + * Returns true if this object was created by the Parse server when the + * object might have already been there (e.g. in the case of a Facebook + * login) + * + * @returns {boolean} + */ + existed(): boolean; + /** + * Returns true if this object exists on the Server + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A boolean promise that is fulfilled if object exists. + */ + exists(options?: RequestOptions): Promise; + /** + * Checks if the model is currently in a valid state. + * + * @returns {boolean} + */ + isValid(): boolean; + /** + * You should not call this function directly unless you subclass + * Parse.Object, in which case you can override this method + * to provide additional validation on set and + * save. Your implementation should return + * + * @param {object} attrs The current data to validate. + * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise. + * @see Parse.Object#set + */ + validate(attrs: AttributeMap): ParseError | boolean; + /** + * Returns the ACL for this object. + * + * @returns {Parse.ACL} An instance of Parse.ACL. + * @see Parse.Object#get + */ + getACL(): ParseACL | null; + /** + * Sets the ACL to be used for this object. + * + * @param {Parse.ACL} acl An instance of Parse.ACL. + * @param {object} options + * @returns {(ParseObject | boolean)} Whether the set passed validation. + * @see Parse.Object#set + */ + setACL(acl: ParseACL, options?: mixed): ParseObject | boolean; + /** + * Clears any (or specific) changes to this object made since the last call to save() + * + * @param {string} [keys] - specify which fields to revert + */ + revert(...keys?: Array): void; + /** + * Clears all attributes on a model + * + * @returns {(ParseObject | boolean)} + */ + clear(): ParseObject | boolean; + /** + * Fetch the model from the server. If the server's representation of the + * model differs from its current attributes, they will be overriden. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • include: The name(s) of the key(s) to include. Can be a string, an array of strings, + * or an array of array of strings. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    + * @returns {Promise} A promise that is fulfilled when the fetch + * completes. + */ + fetch(options: RequestOptions): Promise; + /** + * Fetch the model from the server. If the server's representation of the + * model differs from its current attributes, they will be overriden. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that is fulfilled when the fetch + * completes. + */ + 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. + * + * Use this when you may not have a solid network connection, and don't need to know when the save completes. + * If there is some problem with the object such that it can't be saved, it will be silently discarded. + * + * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. + * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is + * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the + * next time the app is opened. + * + * @param {object} [options] + * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. + * Valid options are: + *
      + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
    • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the save + * completes. + */ + saveEventually(options?: SaveOptions): Promise; + /** + * Set a hash of model attributes, and save the model to the server. + * updatedAt will be updated when the request returns. + * You can either call it as:
    +     * object.save();
    + * or
    +     * object.save(attrs);
    + * or
    +     * object.save(null, options);
    + * or
    +     * object.save(attrs, options);
    + * or
    +     * object.save(key, value);
    + * or
    +     * object.save(key, value, options);
    + * + * Example 1:
    +     * gameTurn.save({
    +     * player: "Jake Cutter",
    +     * diceRoll: 2
    +     * }).then(function(gameTurnAgain) {
    +     * // The save was successful.
    +     * }, function(error) {
    +     * // The save failed.  Error is an instance of Parse.Error.
    +     * });
    + * + * Example 2:
    +     * gameTurn.save("player", "Jake Cutter");
    + * + * @param {string | object | null} [arg1] + * Valid options are:
      + *
    • `Object` - Key/value pairs to update on the object.
    • + *
    • `String` Key - Key of attribute to update (requires arg2 to also be string)
    • + *
    • `null` - Passing null for arg1 allows you to save the object with options passed in arg2.
    • + *
    + * @param {string | object} [arg2] + *
      + *
    • `String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.
    • + *
    • `Object` Options - Valid options are: + *
        + *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
      • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
      • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
      • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
      + *
    • + *
    + * @param {object} [arg3] + * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. + * Valid options are: + *
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
    • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the save + * completes. + */ + save(arg1?: string | { + [attr: string]: mixed; + }, arg2?: SaveOptions | mixed, arg3?: SaveOptions): Promise; + /** + * Deletes this object from the server at some unspecified time in the future, + * even if Parse is currently inaccessible. + * + * Use this when you may not have a solid network connection, + * and don't need to know when the delete completes. If there is some problem with the object + * such that it can't be deleted, the request will be silently discarded. + * + * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted + * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection + * is available. Delete requests will persist even after the app is closed, in which case they will be sent the + * next time the app is opened. + * + * @param {object} [options] + * Valid options are:
      + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the destroy + * completes. + */ + destroyEventually(options?: RequestOptions): Promise; + /** + * Destroy this model on the server if it was already persisted. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the destroy + * completes. + */ + destroy(options: RequestOptions): Promise; + /** + * Asynchronously stores the object and every object it points to in the local datastore, + * recursively, using a default pin name: _default. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await object.pin();
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPin() + * + * @returns {Promise} A promise that is fulfilled when the pin completes. + */ + pin(): Promise; + /** + * Asynchronously removes the object and every object it points to in the local datastore, + * recursively, using a default pin name: _default. + * + *
    +     * await object.unPin();
    +     * 
    + * + * @returns {Promise} A promise that is fulfilled when the unPin completes. + */ + unPin(): Promise; + /** + * Asynchronously returns if the object is pinned + * + *
    +     * const isPinned = await object.isPinned();
    +     * 
    + * + * @returns {Promise} A boolean promise that is fulfilled if object is pinned. + */ + isPinned(): Promise; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, recursively. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await object.pinWithName(name);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPinWithName(name) + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the pin completes. + */ + pinWithName(name: string): Promise; + /** + * Asynchronously removes the object and every object it points to in the local datastore, recursively. + * + *
    +     * await object.unPinWithName(name);
    +     * 
    + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + */ + unPinWithName(name: string): Promise; + /** + * Asynchronously loads data from the local datastore into this object. + * + *
    +     * await object.fetchFromLocalDatastore();
    +     * 
    + * + * You can create an unfetched pointer with Parse.Object.createWithoutData() + * and then call fetchFromLocalDatastore() on it. + * + * @returns {Promise} A promise that is fulfilled when the fetch completes. + */ + fetchFromLocalDatastore(): Promise; +} +import { AttributeMap as AttributeMap_1 } from './ObjectStateMutations'; +import { OpsMap } from './ObjectStateMutations'; +type SaveParams = { + method: string; + path: string; + body: AttributeMap; +}; +import ParseRelation from './ParseRelation'; +import { Op } from './ParseOp'; +import { RequestOptions } from './RESTController'; +import ParseError from './ParseError'; +import ParseACL from './ParseACL'; diff --git a/types/ParseOp.d.ts b/types/ParseOp.d.ts new file mode 100644 index 000000000..544c65a81 --- /dev/null +++ b/types/ParseOp.d.ts @@ -0,0 +1,76 @@ +export function opFromJSON(json: { + [key: string]: any; +}): Op | null; +export class Op { + applyTo(value: mixed): mixed; + mergeWith(previous: Op): Op | null; + toJSON(): mixed; +} +export class SetOp extends Op { + constructor(value: mixed); + _value: mixed; + applyTo(): mixed; + mergeWith(): SetOp; + toJSON(offline?: boolean): any; +} +export class UnsetOp extends Op { + applyTo(): any; + mergeWith(): UnsetOp; + toJSON(): { + __op: string; + }; +} +export class IncrementOp extends Op { + constructor(amount: number); + _amount: number; + applyTo(value: mixed): number; + toJSON(): { + __op: string; + amount: number; + }; +} +export class AddOp extends Op { + constructor(value: mixed | Array); + _value: Array; + applyTo(value: mixed): Array; + toJSON(): { + __op: string; + objects: mixed; + }; +} +export class AddUniqueOp extends Op { + constructor(value: mixed | Array); + _value: Array; + applyTo(value: mixed | Array): Array; + toJSON(): { + __op: string; + objects: mixed; + }; +} +export class RemoveOp extends Op { + constructor(value: mixed | Array); + _value: Array; + applyTo(value: mixed | Array): Array; + toJSON(): { + __op: string; + objects: mixed; + }; +} +export class RelationOp extends Op { + constructor(adds: Array, removes: Array); + _targetClassName: string | null; + relationsToAdd: Array; + relationsToRemove: Array; + _extractId(obj: string | ParseObject): string; + applyTo(value: mixed, object?: { + className: string; + id: string | null; + }, key?: string): ParseRelation | null; + toJSON(): { + __op?: string; + objects?: mixed; + ops?: mixed; + }; +} +import ParseObject from './ParseObject'; +import ParseRelation from './ParseRelation'; diff --git a/types/ParsePolygon.d.ts b/types/ParsePolygon.d.ts new file mode 100644 index 000000000..e838e8744 --- /dev/null +++ b/types/ParsePolygon.d.ts @@ -0,0 +1,67 @@ +export default ParsePolygon; +/** + * Creates a new Polygon with any of the following forms:
    + *
    + *   new Polygon([[0,0],[0,1],[1,1],[1,0]])
    + *   new Polygon([GeoPoint, GeoPoint, GeoPoint])
    + *   
    + * + *

    Represents a coordinates that may be associated + * with a key in a ParseObject or used as a reference point for geo queries. + * This allows proximity-based queries on the key.

    + * + *

    Example:

    + *   var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
    + *   var object = new Parse.Object("PlaceObject");
    + *   object.set("area", polygon);
    + *   object.save();

    + * + * @alias Parse.Polygon + */ +declare class ParsePolygon { + /** + * Validates that the list of coordinates can form a valid polygon + * + * @param {Array} coords the list of coordinates to validate as a polygon + * @throws {TypeError} + * @returns {number[][]} Array of coordinates if validated. + */ + static _validate(coords: Array> | Array): Array>; + /** + * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs + */ + constructor(coordinates: Array> | Array); + _coordinates: Array>; + set coordinates(arg: number[][]); + /** + * Coordinates value for this Polygon. + * Throws an exception if not valid type. + * + * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates + * @returns {number[][]} + */ + get coordinates(): number[][]; + /** + * Returns a JSON representation of the Polygon, suitable for Parse. + * + * @returns {object} + */ + toJSON(): { + __type: string; + coordinates: Array>; + }; + /** + * Checks if two polygons are equal + * + * @param {(Parse.Polygon | object)} other + * @returns {boolean} + */ + equals(other: mixed): boolean; + /** + * + * @param {Parse.GeoPoint} point + * @returns {boolean} Returns if the point is contained in the polygon + */ + containsPoint(point: ParseGeoPoint): boolean; +} +import ParseGeoPoint from './ParseGeoPoint'; diff --git a/types/ParseQuery.d.ts b/types/ParseQuery.d.ts new file mode 100644 index 000000000..3636ab428 --- /dev/null +++ b/types/ParseQuery.d.ts @@ -0,0 +1,924 @@ +type WhereClause = { + [attr: string]: mixed; +}; +type QueryJSON = { + where: WhereClause; + watch?: string; + include?: string; + excludeKeys?: string; + keys?: string; + limit?: number; + skip?: number; + order?: string; + className?: string; + count?: number; + hint?: mixed; + explain?: boolean; + readPreference?: string; + includeReadPreference?: string; + subqueryReadPreference?: string; +}; +export default ParseQuery; +/** + * Creates a new parse Parse.Query for the given Parse.Object subclass. + * + *

    Parse.Query defines a query that is used to fetch Parse.Objects. The + * most common use case is finding all objects that match a query through the + * find method. for example, this sample code fetches all objects + * of class myclass. it calls a different function depending on + * whether the fetch succeeded or not. + * + *

    + * var query = new Parse.Query(myclass);
    + * query.find().then((results) => {
    + *   // results is an array of parse.object.
    + * }).catch((error) =>  {
    + *  // error is an instance of parse.error.
    + * });

    + * + *

    a Parse.Query can also be used to retrieve a single object whose id is + * known, through the get method. for example, this sample code fetches an + * object of class myclass and id myid. it calls a + * different function depending on whether the fetch succeeded or not. + * + *

    + * var query = new Parse.Query(myclass);
    + * query.get(myid).then((object) => {
    + *     // object is an instance of parse.object.
    + * }).catch((error) =>  {
    + *  // error is an instance of parse.error.
    + * });

    + * + *

    a Parse.Query can also be used to count the number of objects that match + * the query without retrieving all of those objects. for example, this + * sample code counts the number of objects of the class myclass + *

    + * var query = new Parse.Query(myclass);
    + * query.count().then((number) => {
    + *     // there are number instances of myclass.
    + * }).catch((error) => {
    + *     // error is an instance of Parse.Error.
    + * });

    + * + * @alias Parse.Query + */ +declare class ParseQuery { + /** + * Static method to restore Parse.Query by json representation + * Internally calling Parse.Query.withJSON + * + * @param {string} className + * @param {QueryJSON} json from Parse.Query.toJSON() method + * @returns {Parse.Query} new created query + */ + static fromJSON(className: string, json: QueryJSON): ParseQuery; + /** + * Constructs a Parse.Query that is the OR of the passed in queries. For + * example: + *
    var compoundQuery = Parse.Query.or(query1, query2, query3);
    + * + * will create a compoundQuery that is an or of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to OR. + * @static + * @returns {Parse.Query} The query that is the OR of the passed in queries. + */ + static or(...queries: Array): ParseQuery; + /** + * Constructs a Parse.Query that is the AND of the passed in queries. For + * example: + *
    var compoundQuery = Parse.Query.and(query1, query2, query3);
    + * + * will create a compoundQuery that is an and of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to AND. + * @static + * @returns {Parse.Query} The query that is the AND of the passed in queries. + */ + static and(...queries: Array): ParseQuery; + /** + * Constructs a Parse.Query that is the NOR of the passed in queries. For + * example: + *
    const compoundQuery = Parse.Query.nor(query1, query2, query3);
    + * + * will create a compoundQuery that is a nor of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to NOR. + * @static + * @returns {Parse.Query} The query that is the NOR of the passed in queries. + */ + static nor(...queries: Array): ParseQuery; + /** + * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string. + */ + constructor(objectClass: string | ParseObject); + /** + * @property {string} className + */ + className: string; + _where: any; + _watch: Array; + _include: Array; + _exclude: Array; + _select: Array; + _limit: number; + _skip: number; + _count: boolean; + _order: Array; + _readPreference: string; + _includeReadPreference: string; + _subqueryReadPreference: string; + _queriesLocalDatastore: boolean; + _localDatastorePinName: any; + _extraOptions: { + [key: string]: mixed; + }; + _hint: mixed; + _explain: boolean; + _xhrRequest: any; + /** + * Adds constraint that at least one of the passed in queries matches. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _orQuery(queries: Array): ParseQuery; + /** + * Adds constraint that all of the passed in queries match. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _andQuery(queries: Array): ParseQuery; + /** + * Adds constraint that none of the passed in queries match. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _norQuery(queries: Array): ParseQuery; + /** + * Helper for condition queries + * + * @param key + * @param condition + * @param value + * @returns {Parse.Query} + */ + _addCondition(key: string, condition: string, value: mixed): ParseQuery; + /** + * Converts string for regular expression at the beginning + * + * @param string + * @returns {string} + */ + _regexStartWith(string: string): string; + _handleOfflineQuery(params: any): Promise; + /** + * Returns a JSON representation of this query. + * + * @returns {object} The JSON representation of the query. + */ + toJSON(): QueryJSON; + /** + * Return a query with conditions from json, can be useful to send query from server side to client + * Not static, all query conditions was set before calling this method will be deleted. + * For example on the server side we have + * var query = new Parse.Query("className"); + * query.equalTo(key: value); + * query.limit(100); + * ... (others queries) + * Create JSON representation of Query Object + * var jsonFromServer = query.fromJSON(); + * + * On client side getting query: + * var query = new Parse.Query("className"); + * query.fromJSON(jsonFromServer); + * + * and continue to query... + * query.skip(100).find().then(...); + * + * @param {QueryJSON} json from Parse.Query.toJSON() method + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withJSON(json: QueryJSON): ParseQuery; + /** + * Constructs a Parse.Object whose id is already known by fetching data from + * the server. Unlike the first method, it never returns undefined. + * + * @param {string} objectId The id of the object to be fetched. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + get(objectId: string, options?: FullOptions): Promise; + /** + * Retrieves a list of ParseObjects that satisfy this query. + * + * @param {object} options Valid options + * are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the results when + * the query completes. + */ + find(options?: FullOptions): Promise>; + /** + * Retrieves a complete list of ParseObjects that satisfy this query. + * Using `eachBatch` under the hood to fetch all the valid objects. + * + * @param {object} options Valid options are:
      + *
    • batchSize: How many objects to yield in each batch (default: 100) + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • 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 results when + * the query completes. + */ + findAll(options?: BatchOptions): Promise>; + /** + * Counts the number of objects that match this query. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • 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 count when + * the query completes. + */ + count(options?: FullOptions): Promise; + /** + * Executes a distinct query and returns unique values + * + * @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. + *
    + * @returns {Promise} A promise that is resolved with the query completes. + */ + distinct(key: string, options?: FullOptions): Promise>; + /** + * 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. + *
    + * @returns {Promise} A promise that is resolved with the query completes. + */ + aggregate(pipeline: mixed, options?: FullOptions): Promise>; + /** + * Retrieves at most one Parse.Object that satisfies this query. + * + * Returns the object if there is one, otherwise undefined. + * + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the object when + * the query completes. + */ + first(options?: FullOptions): Promise; + /** + * Iterates over objects matching a query, calling a callback for each batch. + * If the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are processed + * in an unspecified order. The query may not have any sort order, and may + * not use limit or skip. + * + * @param {Function} callback Callback that will be called with each result + * of the query. + * @param {object} options Valid options are:
      + *
    • batchSize: How many objects to yield in each batch (default: 100) + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + eachBatch(callback: (objs: Array) => Promise, options?: BatchOptions): Promise; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback that will be called with each result + * of the query. + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + each(callback: (obj: ParseObject) => any, options?: BatchOptions): Promise; + /** + * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/) + * + * @param {(string|object)} value String or Object of index that should be used when executing query + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + hint(value: mixed): ParseQuery; + /** + * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/) + * + * @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): ParseQuery; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    • query: The query map was called upon.
    • + *
    + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + map(callback: (currentObject: ParseObject, index: number, query: ParseQuery) => any, options?: BatchOptions): Promise>; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.
    • + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    + * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped. + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + reduce(callback: (accumulator: any, currentObject: ParseObject, index: number) => any, initialValue: any, options?: BatchOptions): Promise>; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    • query: The query filter was called upon.
    • + *
    + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + filter(callback: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean, options?: BatchOptions): Promise>; + /** + * Adds a constraint to the query that requires a particular key's value to + * be equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that the Parse.Object must contain. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + equalTo(key: string | { + [key: string]: any; + }, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be not equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that must not be equalled. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + notEqualTo(key: string | { + [key: string]: any; + }, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be less than the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an upper bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + lessThan(key: string, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be greater than the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an lower bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + greaterThan(key: string, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be less than or equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an upper bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + lessThanOrEqualTo(key: string, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be greater than or equal to the provided value. + * + * @param {string} key The key to check. + * @param {*} value The value that provides an lower bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + greaterThanOrEqualTo(key: string, value: mixed): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be contained in the provided list of values. + * + * @param {string} key The key to check. + * @param {Array<*>} value The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containedIn(key: string, value: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * not be contained in the provided list of values. + * + * @param {string} key The key to check. + * @param {Array<*>} value The values that will not match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + notContainedIn(key: string, value: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be contained by the provided list of values. Get objects where all array elements match. + * + * @param {string} key The key to check. + * @param {Array} values The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containedBy(key: string, values: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * contain each one of the provided list of values. + * + * @param {string} key The key to check. This key's value must be an array. + * @param {Array} values The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containsAll(key: string, values: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * contain each one of the provided list of values starting with given strings. + * + * @param {string} key The key to check. This key's value must be an array. + * @param {Array} values The string values that will match as starting string. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containsAllStartingWith(key: string, values: Array): ParseQuery; + /** + * Adds a constraint for finding objects that contain the given key. + * + * @param {string} key The key that should exist. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + exists(key: string): ParseQuery; + /** + * Adds a constraint for finding objects that do not contain a given key. + * + * @param {string} key The key that should not exist + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotExist(key: string): ParseQuery; + /** + * Adds a regular expression constraint for finding string values that match + * the provided regular expression. + * This may be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {RegExp} regex The regular expression pattern to match. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matches(key: string, regex: RegExp, modifiers: string): ParseQuery; + /** + * Adds a constraint that requires that a key's value matches a Parse.Query + * constraint. + * + * @param {string} key The key that the contains the object to match the + * query. + * @param {Parse.Query} query The query that should match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matchesQuery(key: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value not matches a + * Parse.Query constraint. + * + * @param {string} key The key that the contains the object to match the + * query. + * @param {Parse.Query} query The query that should not match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotMatchQuery(key: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value matches a value in + * an object returned by a different Parse.Query. + * + * @param {string} key The key that contains the value that is being + * matched. + * @param {string} queryKey The key in the objects returned by the query to + * match against. + * @param {Parse.Query} query The query to run. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matchesKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value not match a value in + * an object returned by a different Parse.Query. + * + * @param {string} key The key that contains the value that is being + * excluded. + * @param {string} queryKey The key in the objects returned by the query to + * match against. + * @param {Parse.Query} query The query to run. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotMatchKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint for finding string values that contain a provided + * string. This may be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} substring The substring that the value must contain. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + contains(key: string, substring: string): ParseQuery; + /** + * Adds a constraint for finding string values that contain a provided + * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0 + * + * In order to sort you must use select and ascending ($score is required) + *
    +     *   query.fullText('field', 'term');
    +     *   query.ascending('$score');
    +     *   query.select('$score');
    +     *  
    + * + * To retrieve the weight / rank + *
    +     *   object->get('score');
    +     *  
    + * + * You can define optionals by providing an object as a third parameter + *
    +     *   query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
    +     *  
    + * + * @param {string} key The key that the string to match is stored in. + * @param {string} value The string to search + * @param {object} options (Optional) + * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. + * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search. + * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fullText(key: string, value: string, options: Object | null): ParseQuery; + /** + * Method to sort the full text search by text score + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + sortByTextScore(): Parse.Query; + /** + * Adds a constraint for finding string values that start with a provided + * string. This query will use the backend index, so it will be fast even + * for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} prefix The substring that the value must start with. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + startsWith(key: string, prefix: string, modifiers: string): ParseQuery; + /** + * Adds a constraint for finding string values that end with a provided + * string. This will be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} suffix The substring that the value must end with. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + endsWith(key: string, suffix: string, modifiers: string): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + near(key: string, point: ParseGeoPoint): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in radians) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinRadians(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * Radius of earth used is 3958.8 miles. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in miles) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinMiles(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * Radius of earth used is 6371.0 kilometers. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in kilometers) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinKilometers(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's + * coordinates be contained within a given rectangular geographic bounding + * box. + * + * @param {string} key The key to be constrained. + * @param {Parse.GeoPoint} southwest + * The lower-left inclusive corner of the box. + * @param {Parse.GeoPoint} northeast + * The upper-right inclusive corner of the box. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinGeoBox(key: string, southwest: ParseGeoPoint, northeast: ParseGeoPoint): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's + * coordinates be contained within and on the bounds of a given polygon. + * Supports closed and open (last point is connected to first) paths + * + * Polygon must have at least 3 points + * + * @param {string} key The key to be constrained. + * @param {Array} points Array of Coordinates / GeoPoints + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinPolygon(key: string, points: Array>): ParseQuery; + /** + * Add a constraint to the query that requires a particular key's + * coordinates that contains a ParseGeoPoint + * + * @param {string} key The key to be constrained. + * @param {Parse.GeoPoint} point + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + polygonContains(key: string, point: ParseGeoPoint): ParseQuery; + /** + * Sorts the results in ascending order by the given key. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + ascending(...keys: Array): ParseQuery; + /** + * Sorts the results in ascending order by the given key, + * but can also add secondary sort descriptors without overwriting _order. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + addAscending(...keys: Array): ParseQuery; + /** + * Sorts the results in descending order by the given key. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + descending(...keys: Array): ParseQuery; + /** + * Sorts the results in descending order by the given key, + * but can also add secondary sort descriptors without overwriting _order. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + addDescending(...keys: Array): ParseQuery; + /** + * Sets the number of results to skip before returning any results. + * This is useful for pagination. + * Default is to skip zero results. + * + * @param {number} n the number of results to skip. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + skip(n: number): ParseQuery; + /** + * Sets the limit of the number of results to return. The default limit is 100. + * + * @param {number} n the number of results to limit to. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + limit(n: number): ParseQuery; + /** + * Sets the flag to include with response the total number of objects satisfying this query, + * despite limits/skip. Might be useful for pagination. + * Note that result of this query will be wrapped as an object with + * `results`: holding {ParseObject} array and `count`: integer holding total number + * + * @param {boolean} includeCount false - disable, true - enable. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withCount(includeCount?: boolean): ParseQuery; + /** + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * You can include all nested Parse.Objects by passing in '*'. + * Requires Parse Server 3.0.0+ + *
    query.include('*');
    + * + * @param {...string|Array} keys The name(s) of the key(s) to include. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + include(...keys: Array>): ParseQuery; + /** + * Includes all nested Parse.Objects one level deep. + * + * Requires Parse Server 3.0.0+ + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + includeAll(): ParseQuery; + /** + * Restricts the fields of the returned Parse.Objects to include only the + * provided keys. If this is called multiple times, then all of the keys + * specified in each of the calls will be included. + * + * @param {...string|Array} keys The name(s) of the key(s) to include. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + select(...keys: Array>): ParseQuery; + /** + * Restricts the fields of the returned Parse.Objects to all keys except the + * provided keys. Exclude takes precedence over select and include. + * + * Requires Parse Server 3.6.0+ + * + * @param {...string|Array} keys The name(s) of the key(s) to exclude. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + exclude(...keys: Array>): ParseQuery; + /** + * Restricts live query to trigger only for watched fields. + * + * Requires Parse Server 6.0.0+ + * + * @param {...string|Array} keys The name(s) of the key(s) to watch. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + watch(...keys: Array>): ParseQuery; + /** + * Changes the read preference that the backend will use when performing the query to the database. + * + * @param {string} readPreference The read preference for the main query. + * @param {string} includeReadPreference The read preference for the queries to include pointers. + * @param {string} subqueryReadPreference The read preference for the sub queries. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + readPreference(readPreference: string, includeReadPreference?: string, subqueryReadPreference?: string): ParseQuery; + /** + * Subscribe this query to get liveQuery updates + * + * @param {string} sessionToken (optional) Defaults to the currentUser + * @returns {Promise} Returns the liveQuerySubscription, it's an event emitter + * which can be used to get liveQuery updates. + */ + subscribe(sessionToken?: string): Promise; + /** + * Change the source of this query to the server. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromNetwork(): ParseQuery; + /** + * Changes the source of this query to all pinned objects. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromLocalDatastore(): ParseQuery; + /** + * Changes the source of this query to the default group of pinned objects. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromPin(): ParseQuery; + /** + * Changes the source of this query to a specific group of pinned objects. + * + * @param {string} name The name of query source. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromPinWithName(name?: string): ParseQuery; + /** + * Cancels the current network request (if any is running). + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + cancel(): ParseQuery; + _setRequestTask(options: any): void; +} +import { FullOptions } from './RESTController'; +import ParseObject from './ParseObject'; +type BatchOptions = FullOptions & { + batchSize?: number; +}; +import ParseGeoPoint from './ParseGeoPoint'; +import LiveQuerySubscription from './LiveQuerySubscription'; diff --git a/types/ParseRelation.d.ts b/types/ParseRelation.d.ts new file mode 100644 index 000000000..2815a6e87 --- /dev/null +++ b/types/ParseRelation.d.ts @@ -0,0 +1,56 @@ +export default ParseRelation; +/** + * Creates a new Relation for the given parent object and key. This + * constructor should rarely be used directly, but rather created by + * Parse.Object.relation. + * + *

    + * A class that is used to access all of the children of a many-to-many + * relationship. Each instance of Parse.Relation is associated with a + * particular parent object and key. + *

    + * + * @alias Parse.Relation + */ +declare class ParseRelation { + /** + * @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; + _ensureParentAndKey(parent: ParseObject, key: string): void; + /** + * Adds a Parse.Object or an array of Parse.Objects to the relation. + * + * @param {(Parse.Object|Array)} objects The item or items to add. + * @returns {Parse.Object} The parent of the relation. + */ + add(objects: ParseObject | Array): ParseObject; + /** + * Removes a Parse.Object or an array of Parse.Objects from this relation. + * + * @param {(Parse.Object|Array)} objects The item or items to remove. + */ + remove(objects: ParseObject | Array): void; + /** + * Returns a JSON version of the object suitable for saving to disk. + * + * @returns {object} JSON representation of Relation + */ + toJSON(): { + __type: 'Relation'; + className: string | null; + }; + /** + * Returns a Parse.Query that is limited to objects in this + * relation. + * + * @returns {Parse.Query} Relation Query + */ + query(): ParseQuery; +} +import ParseObject from './ParseObject'; +import ParseQuery from './ParseQuery'; diff --git a/types/ParseRole.d.ts b/types/ParseRole.d.ts new file mode 100644 index 000000000..b77c9c944 --- /dev/null +++ b/types/ParseRole.d.ts @@ -0,0 +1,78 @@ +export default ParseRole; +/** + * Represents a Role on the Parse server. Roles represent groupings of + * Users for the purposes of granting permissions (e.g. specifying an ACL + * for an Object). Roles are specified by their sets of child users and + * child roles, all of which are granted any permissions that the parent + * role has. + * + *

    Roles must have a name (which cannot be changed after creation of the + * role), and must specify an ACL.

    + * + * @alias Parse.Role + * @augments Parse.Object + */ +declare class ParseRole { + /** + * @param {string} name The name of the Role to create. + * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL. + * A Parse.Role is a local representation of a role persisted to the Parse + * cloud. + */ + constructor(name: string, acl: ParseACL); + /** + * Gets the name of the role. You can alternatively call role.get("name") + * + * @returns {string} the name of the role. + */ + getName(): string | null; + /** + * Sets the name for a role. This value must be set before the role has + * been saved to the server, and cannot be set once the role has been + * saved. + * + *

    + * A role's name can only contain alphanumeric characters, _, -, and + * spaces. + *

    + * + *

    This is equivalent to calling role.set("name", name)

    + * + * @param {string} name The name of the role. + * @param {object} options Standard options object with success and error + * callbacks. + * @returns {(ParseObject|boolean)} true if the set succeeded. + */ + setName(name: string, options?: mixed): ParseObject | boolean; + /** + * Gets the Parse.Relation for the Parse.Users that are direct + * children of this role. These users are granted any privileges that this + * role has been granted (e.g. read or write access through ACLs). You can + * add or remove users from the role through this relation. + * + *

    This is equivalent to calling role.relation("users")

    + * + * @returns {Parse.Relation} the relation for the users belonging to this + * role. + */ + getUsers(): ParseRelation; + /** + * Gets the Parse.Relation for the Parse.Roles that are direct + * children of this role. These roles' users are granted any privileges that + * this role has been granted (e.g. read or write access through ACLs). You + * can add or remove child roles from this role through this relation. + * + *

    This is equivalent to calling role.relation("roles")

    + * + * @returns {Parse.Relation} the relation for the roles belonging to this + * role. + */ + getRoles(): ParseRelation; + _validateName(newName: any): void; + validate(attrs: AttributeMap, options?: mixed): ParseError | boolean; +} +import ParseObject from './ParseObject'; +import ParseRelation from './ParseRelation'; +import { AttributeMap } from './ObjectStateMutations'; +import ParseError from './ParseError'; +import ParseACL from './ParseACL'; diff --git a/types/ParseSchema.d.ts b/types/ParseSchema.d.ts new file mode 100644 index 000000000..e71cc362b --- /dev/null +++ b/types/ParseSchema.d.ts @@ -0,0 +1,227 @@ +export default ParseSchema; +/** + * A Parse.Schema object is for handling schema data from Parse. + *

    All the schemas methods require MasterKey. + * + * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+) + * + *

    + * const options = { required: true, defaultValue: 'hello world' };
    + * const schema = new Parse.Schema('MyClass');
    + * schema.addString('field', options);
    + * schema.addIndex('index_name', { 'field': 1 });
    + * schema.save();
    + * 
    + *

    + * + * @alias Parse.Schema + */ +declare class ParseSchema { + /** + * Static method to get all schemas + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + static all(): Promise; + /** + * @param {string} className Parse Class string. + */ + constructor(className: string); + className: string; + _fields: { + [key: string]: mixed; + }; + _indexes: { + [key: string]: mixed; + }; + _clp: { + [key: string]: mixed; + }; + /** + * Get the Schema from Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + get(): Promise; + /** + * Create a new Schema on Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + save(): Promise; + /** + * Update a Schema on Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + update(): Promise; + /** + * Removing a Schema from Parse + * Can only be used on Schema without objects + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + delete(): Promise; + /** + * Removes all objects from a Schema (class) in Parse. + * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + purge(): Promise; + /** + * Assert if ClassName has been filled + * + * @private + */ + private assertClassName; + /** + * Sets Class Level Permissions when creating / updating a Schema. + * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed + * + * @param {object | Parse.CLP} clp Class Level Permissions + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + setCLP(clp: PermissionsMap | ParseCLP): Parse.Schema; + /** + * Adding a Field to Create / Update a Schema + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation) + * @param {object} options + * Valid options are:
      + *
    • required: If field is not set, save operation fails (Requires Parse Server 3.7.0+) + *
    • defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+) + *
    • targetClass: Required if type is Pointer or Parse.Relation + *
    + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addField(name: string, type: string, options?: FieldOptions): Parse.Schema; + /** + * Adding an Index to Create / Update a Schema + * + * @param {string} name Name of the index + * @param {object} index { field: value } + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + * + *
    +     * schema.addIndex('index_name', { 'field': 1 });
    +     * 
    + */ + addIndex(name: string, index: any): Parse.Schema; + /** + * Adding String Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addString(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Number Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addNumber(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Boolean Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addBoolean(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Date Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addDate(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding File Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addFile(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding GeoPoint Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addGeoPoint(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Polygon Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addPolygon(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Array Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addArray(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Object Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addObject(name: string, options: FieldOptions): Parse.Schema; + /** + * Adding Pointer Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} targetClass Name of the target Pointer Class + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addPointer(name: string, targetClass: string, options?: FieldOptions): Parse.Schema; + /** + * Adding Relation Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} targetClass Name of the target Pointer Class + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addRelation(name: string, targetClass: string): Parse.Schema; + /** + * Deleting a Field to Update on a Schema + * + * @param {string} name Name of the field + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + deleteField(name: string): Parse.Schema; + /** + * Deleting an Index to Update on a Schema + * + * @param {string} name Name of the field + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + deleteIndex(name: string): Parse.Schema; +} +import { PermissionsMap } from './ParseCLP'; +import ParseCLP from './ParseCLP'; +type FieldOptions = { + required: boolean; + defaultValue: mixed; +}; diff --git a/types/ParseSession.d.ts b/types/ParseSession.d.ts new file mode 100644 index 000000000..6c3334b8a --- /dev/null +++ b/types/ParseSession.d.ts @@ -0,0 +1,45 @@ +export default ParseSession; +/** + *

    A Parse.Session object is a local representation of a revocable session. + * This class is a subclass of a Parse.Object, and retains the same + * functionality of a Parse.Object.

    + * + * @alias Parse.Session + * @augments Parse.Object + */ +declare class ParseSession { + static readOnlyAttributes(): string[]; + /** + * Retrieves the Session object for the currently logged in session. + * + * @param {object} options useMasterKey + * @static + * @returns {Promise} A promise that is resolved with the Parse.Session + * object after it has been fetched. If there is no current user, the + * promise will be rejected. + */ + static current(options: FullOptions): Promise; + /** + * Determines whether the current session token is revocable. + * This method is useful for migrating Express.js or Node.js web apps to + * use revocable sessions. If you are migrating an app that uses the Parse + * SDK in the browser only, please use Parse.User.enableRevocableSession() + * instead, so that sessions can be automatically upgraded. + * + * @static + * @returns {boolean} + */ + static isCurrentSessionRevocable(): boolean; + /** + * @param {object} attributes The initial set of data to store in the user. + */ + constructor(attributes: AttributeMap | null); + /** + * Returns the session token string. + * + * @returns {string} + */ + getSessionToken(): string; +} +import { FullOptions } from './RESTController'; +import { AttributeMap } from './ObjectStateMutations'; diff --git a/types/ParseUser.d.ts b/types/ParseUser.d.ts new file mode 100644 index 000000000..fe8380c4c --- /dev/null +++ b/types/ParseUser.d.ts @@ -0,0 +1,470 @@ +type AuthData = { + [key: string]: mixed; +}; +export default ParseUser; +/** + *

    A Parse.User object is a local representation of a user persisted to the + * Parse cloud. This class is a subclass of a Parse.Object, and retains the + * same functionality of a Parse.Object, but also extends it with various + * user specific methods, like authentication, signing up, and validation of + * uniqueness.

    + * + * @alias Parse.User + * @augments Parse.Object + */ +declare class ParseUser { + static readOnlyAttributes(): string[]; + /** + * Adds functionality to the existing Parse.User class. + * + * @param {object} protoProps A set of properties to add to the prototype + * @param {object} classProps A set of static properties to add to the class + * @static + * @returns {Parse.User} The newly extended Parse.User class + */ + static extend(protoProps: { + [prop: string]: any; + }, classProps: { + [prop: string]: any; + }): Parse.User; + /** + * Retrieves the currently logged in ParseUser with a valid session, + * either from memory or localStorage, if necessary. + * + * @static + * @returns {Parse.Object} The currently logged in Parse.User. + */ + static current(): ParseUser | null; + /** + * Retrieves the currently logged in ParseUser from asynchronous Storage. + * + * @static + * @returns {Promise} A Promise that is resolved with the currently + * logged in Parse User + */ + static currentAsync(): Promise; + /** + * Signs up a new user with a username (or email) and password. + * This will create a new Parse.User on the server, and also persist the + * session in localStorage so that you can access the user using + * {@link #current}. + * + * @param {string} username The username (or email) to sign up with. + * @param {string} password The password to sign up with. + * @param {object} attrs Extra fields to set on the new user. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the signup completes. + */ + static signUp(username: string, password: string, attrs: AttributeMap, options?: FullOptions): Promise; + /** + * Logs in a user with a username (or email) and password. On success, this + * saves the session to disk, so you can retrieve the currently logged in + * user using current. + * + * @param {string} username The username (or email) to log in with. + * @param {string} password The password to log in with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static logIn(username: string, password: string, options?: FullOptions): Promise; + /** + * Logs in a user with a username (or email) and password, and authData. On success, this + * saves the session to disk, so you can retrieve the currently logged in + * user using current. + * + * @param {string} username The username (or email) to log in with. + * @param {string} password The password to log in with. + * @param {object} authData The authData to log in with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static logInWithAdditionalAuth(username: string, password: string, authData: AuthData, options?: FullOptions): Promise; + /** + * Logs in a user with an objectId. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. + * + * @param {string} userId The objectId for the user. + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static loginAs(userId: string): Promise; + /** + * Logs in a user with a session token. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. + * + * @param {string} sessionToken The sessionToken to log in with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static become(sessionToken: string, options?: RequestOptions): Promise; + /** + * Retrieves a user with a session token. + * + * @param {string} sessionToken The sessionToken to get user with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user is fetched. + */ + static me(sessionToken: string, options?: RequestOptions): Promise; + /** + * Logs in a user with a session token. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. If there is no session token the user will not logged in. + * + * @param {object} userJSON The JSON map of the User's data + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static hydrate(userJSON: AttributeMap): Promise; + /** + * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} + * + * @param provider + * @param options + * @param saveOpts + * @static + * @returns {Promise} + */ + static logInWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * Logs out the currently logged in user session. This will remove the + * session from disk, log out of linked services, and future calls to + * current will return null. + * + * @param {object} options + * @static + * @returns {Promise} A promise that is resolved when the session is + * destroyed on the server. + */ + static logOut(options?: RequestOptions): Promise; + /** + * Requests a password reset email to be sent to the specified email address + * associated with the user account. This email allows the user to securely + * reset their password on the Parse site. + * + * @param {string} email The email address associated with the user that + * forgot their password. + * @param {object} options + * @static + * @returns {Promise} + */ + static requestPasswordReset(email: string, options?: RequestOptions): Promise; + /** + * Request an email verification. + * + * @param {string} email The email address associated with the user that + * needs to verify their email. + * @param {object} options + * @static + * @returns {Promise} + */ + static requestEmailVerification(email: string, options?: RequestOptions): Promise; + /** + * Verify whether a given password is the password of the current user. + * + * @param {string} username A username to be used for identificaiton + * @param {string} password A password to be verified + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with a user + * when the password is correct. + */ + static verifyPassword(username: string, password: string, options?: RequestOptions): Promise; + /** + * Allow someone to define a custom User class without className + * being rewritten to _User. The default behavior is to rewrite + * User to _User for legacy reasons. This allows developers to + * override that behavior. + * + * @param {boolean} isAllowed Whether or not to allow custom User class + * @static + */ + static allowCustomUserClass(isAllowed: boolean): void; + /** + * Allows a legacy application to start using revocable sessions. If the + * current session token is not revocable, a request will be made for a new, + * revocable session. + * It is not necessary to call this method from cloud code unless you are + * handling user signup or login from the server side. In a cloud code call, + * this function will not attempt to upgrade the current token. + * + * @param {object} options + * @static + * @returns {Promise} A promise that is resolved when the process has + * completed. If a replacement session token is requested, the promise + * will be resolved after a new token has been fetched. + */ + static enableRevocableSession(options?: RequestOptions): Promise; + /** + * Enables the use of become or the current user in a server + * environment. These features are disabled by default, since they depend on + * global objects that are not memory-safe for most servers. + * + * @static + */ + static enableUnsafeCurrentUser(): void; + /** + * Disables the use of become or the current user in any environment. + * These features are disabled on servers by default, since they depend on + * global objects that are not memory-safe for most servers. + * + * @static + */ + static disableUnsafeCurrentUser(): void; + /** + * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider + * is automatically created for you. + * + * For advanced authentication, you can register an Auth provider to + * implement custom authentication, deauthentication. + * + * @param provider + * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} + * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module} + * @static + */ + static _registerAuthenticationProvider(provider: any): void; + /** + * @param provider + * @param options + * @param saveOpts + * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith} + * @static + * @returns {Promise} + */ + static _logInWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + static _clearCache(): void; + static _setCurrentUserCache(user: ParseUser): void; + /** + * @param {object} attributes The initial set of data to store in the user. + */ + constructor(attributes: AttributeMap | null); + /** + * Request a revocable session token to replace the older style of token. + * + * @param {object} options + * @returns {Promise} A promise that is resolved when the replacement + * token has been fetched. + */ + _upgradeToRevocableSession(options: RequestOptions): Promise; + /** + * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling + * your users to sign up or log into your application using their existing identities. + * Since 2.9.0 + * + * @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 + *
      + *
    • 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 + *
    + * @param {object} saveOpts useMasterKey / sessionToken + * @returns {Promise} A promise that is fulfilled with the user is linked + */ + linkWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * @param provider + * @param options + * @param saveOpts + * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} + * @returns {Promise} + */ + _linkWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * Synchronizes auth data for a provider (e.g. puts the access token in the + * right place to be used by the Facebook SDK). + * + * @param provider + */ + _synchronizeAuthData(provider: string): void; + /** + * Synchronizes authData for all providers. + */ + _synchronizeAllAuthData(): void; + /** + * Removes null values from authData (which exist temporarily for unlinking) + */ + _cleanupAuthData(): void; + /** + * Unlinks a user from a service. + * + * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} + * @param {object} options MasterKey / SessionToken + * @returns {Promise} A promise that is fulfilled when the unlinking + * finishes. + */ + _unlinkFrom(provider: any, options?: FullOptions): Promise; + /** + * Checks whether a user is linked to a service. + * + * @param {object} provider service to link to + * @returns {boolean} true if link was successful + */ + _isLinked(provider: any): boolean; + /** + * Deauthenticates all providers. + */ + _logOutWithAll(): void; + /** + * Deauthenticates a single provider (e.g. removing access tokens from the + * Facebook SDK). + * + * @param {object} provider service to logout of + */ + _logOutWith(provider: any): void; + /** + * Class instance method used to maintain specific keys when a fetch occurs. + * Used to ensure that the session token is not lost. + * + * @returns {object} sessionToken + */ + _preserveFieldsOnFetch(): AttributeMap; + /** + * Returns true if current would return this user. + * + * @returns {boolean} true if user is cached on disk + */ + isCurrent(): boolean; + /** + * Returns true if current would return this user. + * + * @returns {Promise} true if user is cached on disk + */ + isCurrentAsync(): Promise; + /** + * Returns get("username"). + * + * @returns {string} + */ + getUsername(): string | null; + /** + * Calls set("username", username, options) and returns the result. + * + * @param {string} username + */ + setUsername(username: string): void; + /** + * Calls set("password", password, options) and returns the result. + * + * @param {string} password User's Password + */ + setPassword(password: string): void; + /** + * Returns get("email"). + * + * @returns {string} User's Email + */ + getEmail(): string | null; + /** + * Calls set("email", email) and returns the result. + * + * @param {string} email + * @returns {boolean} + */ + setEmail(email: string): boolean; + /** + * Returns the session token for this user, if the user has been logged in, + * or if it is the result of a query with the master key. Otherwise, returns + * undefined. + * + * @returns {string} the session token, or undefined + */ + getSessionToken(): string | null; + /** + * Checks whether this user is the current user and has been authenticated. + * + * @returns {boolean} whether this user is the current user and is logged in. + */ + authenticated(): boolean; + /** + * Signs up a new user. You should call this instead of save for + * new Parse.Users. This will create a new Parse.User on the server, and + * also persist the session on disk so that you can access the user using + * current. + * + *

    A username and password must be set before calling signUp.

    + * + * @param {object} attrs Extra fields to set on the new user, or null. + * @param {object} options + * @returns {Promise} A promise that is fulfilled when the signup + * finishes. + */ + signUp(attrs: AttributeMap, options?: FullOptions): Promise; + /** + * Logs in a Parse.User. On success, this saves the session to disk, + * so you can retrieve the currently logged in user using + * current. + * + *

    A username and password must be set before calling logIn.

    + * + * @param {object} options + * @returns {Promise} A promise that is fulfilled with the user when + * the login is complete. + */ + logIn(options?: FullOptions): Promise; + /** + * Wrap the default save behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Promise} + */ + save(...args: Array): Promise; + /** + * Wrap the default destroy behavior with functionality that logs out + * the current user when it is destroyed + * + * @param {...any} args + * @returns {Parse.User} + */ + destroy(...args: Array): Promise; + /** + * Wrap the default fetch behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Parse.User} + */ + fetch(...args: Array): Promise; + /** + * Wrap the default fetchWithInclude behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Parse.User} + */ + fetchWithInclude(...args: Array): Promise; + /** + * Verify whether a given password is the password of the current user. + * + * @param {string} password A password to be verified + * @param {object} options + * @returns {Promise} A promise that is fulfilled with a user + * when the password is correct. + */ + verifyPassword(password: string, options?: RequestOptions): Promise; +} +import { RequestOptions } from './RESTController'; +import { FullOptions } from './RESTController'; +import { AttributeMap } from './ObjectStateMutations'; diff --git a/types/Push.d.ts b/types/Push.d.ts new file mode 100644 index 000000000..5b402a633 --- /dev/null +++ b/types/Push.d.ts @@ -0,0 +1,58 @@ +/** + * Contains functions to deal with Push in Parse. + * + * @class Parse.Push + * @static + * @hideconstructor + */ +/** + * Sends a push notification. + * **Available in Cloud Code only.** + * + * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide} + * + * @function send + * @name Parse.Push.send + * @param {object} data - The data of the push notification. Valid fields + * are: + *
      + *
    1. channels - An Array of channels to push to.
    2. + *
    3. push_time - A Date object for when to send the push.
    4. + *
    5. expiration_time - A Date object for when to expire + * the push.
    6. + *
    7. expiration_interval - The seconds from now to expire the push.
    8. + *
    9. where - A Parse.Query over Parse.Installation that is used to match + * a set of installations to push to.
    10. + *
    11. data - The data to send as part of the push.
    12. + *
        + * @param {object} options Valid options + * are:
          + *
        • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
        + * @returns {Promise} A promise that is fulfilled when the push request + * completes. + */ +export function send(data: PushData, options?: FullOptions): Promise; +/** + * Gets push status by Id + * + * @function getPushStatus + * @name Parse.Push.getPushStatus + * @param {string} pushStatusId The Id of Push Status. + * @param {object} options Valid options + * are:
          + *
        • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
        + * @returns {Parse.Object} Status of Push. + */ +export function getPushStatus(pushStatusId: string, options?: FullOptions): Promise; +type PushData = { + where?: WhereClause | ParseQuery; + push_time?: string | Date; + expiration_time?: string | Date; + expiration_interval?: number; +}; +import { FullOptions } from './RESTController'; +export {}; diff --git a/types/RESTController.d.ts b/types/RESTController.d.ts new file mode 100644 index 000000000..8fac87cff --- /dev/null +++ b/types/RESTController.d.ts @@ -0,0 +1,21 @@ +type RequestOptions = { + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + returnStatus?: boolean; + batchSize?: number; + include?: any; + progress?: any; + context?: any; + usePost?: boolean; +}; +type FullOptions = { + success?: any; + error?: any; + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + progress?: any; + usePost?: boolean; +}; +export {}; diff --git a/types/SingleInstanceStateController.d.ts b/types/SingleInstanceStateController.d.ts new file mode 100644 index 000000000..e84481bed --- /dev/null +++ b/types/SingleInstanceStateController.d.ts @@ -0,0 +1,31 @@ +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(source: { + id: string; +}, dest: { + 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/Socket.weapp.d.ts b/types/Socket.weapp.d.ts new file mode 100644 index 000000000..d5194b543 --- /dev/null +++ b/types/Socket.weapp.d.ts @@ -0,0 +1,10 @@ +export = SocketWeapp; +declare class SocketWeapp { + constructor(serverURL: any); + onopen: () => void; + onmessage: () => void; + onclose: () => void; + onerror: () => void; + send(data: any): void; + close(): void; +} diff --git a/types/Storage.d.ts b/types/Storage.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/Storage.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/StorageController.browser.d.ts b/types/StorageController.browser.d.ts new file mode 100644 index 000000000..b3f1f7fe0 --- /dev/null +++ b/types/StorageController.browser.d.ts @@ -0,0 +1,6 @@ +export let async: number; +export function getItem(path: string): string; +export function setItem(path: string, value: string): void; +export function removeItem(path: string): void; +export function getAllKeys(): string[]; +export function clear(): void; diff --git a/types/StorageController.default.d.ts b/types/StorageController.default.d.ts new file mode 100644 index 000000000..b3f1f7fe0 --- /dev/null +++ b/types/StorageController.default.d.ts @@ -0,0 +1,6 @@ +export let async: number; +export function getItem(path: string): string; +export function setItem(path: string, value: string): void; +export function removeItem(path: string): void; +export function getAllKeys(): string[]; +export function clear(): void; diff --git a/types/StorageController.react-native.d.ts b/types/StorageController.react-native.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/StorageController.react-native.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/StorageController.weapp.d.ts b/types/StorageController.weapp.d.ts new file mode 100644 index 000000000..91bafa45b --- /dev/null +++ b/types/StorageController.weapp.d.ts @@ -0,0 +1,6 @@ +export let async: number; +export function getItem(path: string): string; +export function setItem(path: string, value: string): void; +export function removeItem(path: string): void; +export function getAllKeys(): any; +export function clear(): void; diff --git a/types/TaskQueue.d.ts b/types/TaskQueue.d.ts new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/types/TaskQueue.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/UniqueInstanceStateController.d.ts b/types/UniqueInstanceStateController.d.ts new file mode 100644 index 000000000..f3e2ccf60 --- /dev/null +++ b/types/UniqueInstanceStateController.d.ts @@ -0,0 +1,23 @@ +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'; diff --git a/types/Xhr.weapp.d.ts b/types/Xhr.weapp.d.ts new file mode 100644 index 000000000..84263fafa --- /dev/null +++ b/types/Xhr.weapp.d.ts @@ -0,0 +1,28 @@ +export = XhrWeapp; +declare class XhrWeapp { + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + LOADING: number; + DONE: number; + header: {}; + readyState: number; + status: number; + response: string; + responseType: string; + responseText: string; + responseHeader: {}; + method: string; + url: string; + onabort: () => void; + onprogress: () => void; + onerror: () => void; + onreadystatechange: () => void; + requestTask: any; + getAllResponseHeaders(): string; + getResponseHeader(key: any): any; + setRequestHeader(key: any, value: any): void; + open(method: any, url: any): void; + abort(): void; + send(data: any): void; +} diff --git a/types/arrayContainsObject.d.ts b/types/arrayContainsObject.d.ts new file mode 100644 index 000000000..764acda42 --- /dev/null +++ b/types/arrayContainsObject.d.ts @@ -0,0 +1,2 @@ +export default function arrayContainsObject(array: Array, object: ParseObject): boolean; +import ParseObject from './ParseObject'; diff --git a/types/canBeSerialized.d.ts b/types/canBeSerialized.d.ts new file mode 100644 index 000000000..7cc2db046 --- /dev/null +++ b/types/canBeSerialized.d.ts @@ -0,0 +1,2 @@ +export default function canBeSerialized(obj: ParseObject): boolean; +import ParseObject from './ParseObject'; diff --git a/types/decode.d.ts b/types/decode.d.ts new file mode 100644 index 000000000..d811640d5 --- /dev/null +++ b/types/decode.d.ts @@ -0,0 +1 @@ +export default function decode(value: any): any; diff --git a/types/encode.d.ts b/types/encode.d.ts new file mode 100644 index 000000000..510cff8d7 --- /dev/null +++ b/types/encode.d.ts @@ -0,0 +1 @@ +export default function _default(value: mixed, disallowObjects?: boolean, forcePointers?: boolean, seen?: Array, offline?: boolean): any; diff --git a/types/equals.d.ts b/types/equals.d.ts new file mode 100644 index 000000000..fa093c69f --- /dev/null +++ b/types/equals.d.ts @@ -0,0 +1 @@ +export default function equals(a: any, b: any): boolean; diff --git a/types/escape.d.ts b/types/escape.d.ts new file mode 100644 index 000000000..701cce23d --- /dev/null +++ b/types/escape.d.ts @@ -0,0 +1 @@ +export default function escape(str: string): string; diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 000000000..0b96f9ed9 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,2 @@ +import parse from "./Parse"; +export default parse; \ No newline at end of file diff --git a/types/isRevocableSession.d.ts b/types/isRevocableSession.d.ts new file mode 100644 index 000000000..29d483cbb --- /dev/null +++ b/types/isRevocableSession.d.ts @@ -0,0 +1,4 @@ +/** + * @flow + */ +export default function isRevocableSession(token: string): boolean; diff --git a/types/node.d.ts b/types/node.d.ts new file mode 100644 index 000000000..0b96f9ed9 --- /dev/null +++ b/types/node.d.ts @@ -0,0 +1,2 @@ +import parse from "./Parse"; +export default parse; \ No newline at end of file diff --git a/types/parseDate.d.ts b/types/parseDate.d.ts new file mode 100644 index 000000000..4ec986b68 --- /dev/null +++ b/types/parseDate.d.ts @@ -0,0 +1,4 @@ +/** + * @flow + */ +export default function parseDate(iso8601: string): Date | null; diff --git a/types/promiseUtils.d.ts b/types/promiseUtils.d.ts new file mode 100644 index 000000000..ae6efac22 --- /dev/null +++ b/types/promiseUtils.d.ts @@ -0,0 +1,3 @@ +export function resolvingPromise(): Promise; +export function when(promises: any, ...args: any[]): any; +export function continueWhile(test: any, emitter: any): any; diff --git a/types/react-native.d.ts b/types/react-native.d.ts new file mode 100644 index 000000000..0b96f9ed9 --- /dev/null +++ b/types/react-native.d.ts @@ -0,0 +1,2 @@ +import parse from "./Parse"; +export default parse; \ No newline at end of file diff --git a/types/tests.ts b/types/tests.ts new file mode 100644 index 000000000..67a9e9dd9 --- /dev/null +++ b/types/tests.ts @@ -0,0 +1,2170 @@ +import Parse from './Parse'; +// Parse is a global type, but it can also be imported + +class GameScore extends Parse.Object { + constructor(options?: any) { + super('GameScore', options); + } +} + +class Game extends Parse.Object { + constructor(options?: any) { + super('Game', options); + } +} + +function test_config() { + Parse.Config.save({ foo: 'bar' }, { foo: true }); + Parse.Config.get({ useMasterKey: true }); +} + +function test_object() { + const game = new Game(); + game.save(null, { + useMasterKey: true, + sessionToken: 'sometoken', + cascadeSave: false, + }).then(result => result); + + if (!game.isNew()) { + + } + + if (game.toPointer().className !== 'Game') { + + } + + game.fetch({}); + + // Create a new instance of that class. + const gameScore = new GameScore(); + + gameScore.set('score', 1337); + gameScore.set('playerName', 'Sean Plott'); + gameScore.set('cheatMode', false); + + // Setting attrs using object + gameScore.set({ + level: '10', + difficult: 15, + }); + + const score = gameScore.get('score'); + const playerName = gameScore.get('playerName'); + const cheatMode = gameScore.get('cheatMode'); + + gameScore.increment('score'); + gameScore.addUnique('skills', 'flying'); + gameScore.addUnique('skills', 'kungfu'); + gameScore.addAll('skills', ['kungfu']); + gameScore.addAllUnique('skills', ['kungfu']); + gameScore.remove('skills', 'flying'); + gameScore.removeAll('skills', ['kungFu']); + game.set('gameScore', gameScore); + + const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); + + const object = new Parse.Object('TestObject'); + object.equals(gameScore); + object.fetchWithInclude(['key1', 'key2']); +} + +function test_errors() { + try { + throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); + } catch (error) { + if (error.code !== 1) { + + } + } +} + +function test_query() { + const gameScore = new GameScore(); + + const query = new Parse.Query(GameScore); + query.equalTo('playerName', 'Dan Stemkoski'); + query.notEqualTo('playerName', 'Michael Yabuti'); + query.fullText('playerName', 'dan', { language: 'en', caseSensitive: false, diacriticSensitive: true }); + query.greaterThan('playerAge', 18); + query.eachBatch(objs => Promise.resolve(), { batchSize: 10 }); + query.each(score => Promise.resolve()); + query.hint('_id_'); + query.explain(true); + query.limit(10); + query.skip(10); + + // Sorts the results in ascending order by the score field + query.ascending('score'); + + // Sorts the results in descending order by the score field + query.descending('score'); + + // Restricts to wins < 50 + query.lessThan('wins', 50); + + // Restricts to wins <= 50 + query.lessThanOrEqualTo('wins', 50); + + // Restricts to wins > 50 + query.greaterThan('wins', 50); + + // Restricts to wins >= 50 + query.greaterThanOrEqualTo('wins', 50); + + query.containedBy('place', ['1', '2']); + // Finds scores from any of Jonathan, Dario, or Shawn + query.containedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); + + // Finds scores from anyone who is neither Jonathan, Dario, nor Shawn + query.notContainedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); + + // Finds objects that have the score set + query.exists('score'); + + // Finds objects that don't have the score set + query.doesNotExist('score'); + query.matchesKeyInQuery('hometown', 'city', query); + query.doesNotMatchKeyInQuery('hometown', 'city', query); + query.select('score', 'playerName'); + + // Find objects where the array in arrayKey contains 2. + query.equalTo('arrayKey', 2); + + // Find objects where the array in arrayKey contains all of the elements 2, 3, and 4. + query.containsAll('arrayKey', [2, 3, 4]); + query.containsAllStartingWith('arrayKey', ['2', '3', '4']); + + query.startsWith('name', "Big Daddy's"); + query.equalTo('score', gameScore); + query.exists('score'); + query.include('score'); + query.include(['score.team']); + query.includeAll(); + query.sortByTextScore(); + // Find objects that match the aggregation pipeline + query.aggregate({ + group: { + objectId: '$name', + }, + }); + + query.aggregate({ + count: 'total', + }); + + query.aggregate({ + lookup: { + from: 'Collection', + foreignField: 'id', + localField: 'id', + as: 'result', + }, + }); + query.aggregate({ + lookup: { + from: 'Target', + let: { foo: 'bar', baz: 123 }, + pipeline: [], + as: 'result', + }, + }); + + query.aggregate({ + graphLookup: { + from: 'Target', + connectFromField: 'objectId', + connectToField: 'newId', + as: 'result', + }, + }); + + query.aggregate({ + facet: { + foo: [ + { + count: 'total', + }, + ], + bar: [ + { + group: { + objectId: '$name', + }, + }, + ], + }, + }); + + query.aggregate({ + unwind: '$field', + }); + + query.aggregate({ + unwind: { + path: '$field', + includeArrayIndex: 'newIndex', + preserveNullAndEmptyArrays: true, + }, + }); + + // Find objects with distinct key + query.distinct('name'); + + const testQuery = Parse.Query.or(query, query); +} + +function test_query_exclude() { + const gameScore = new GameScore(); + + const query = new Parse.Query(GameScore); + + // Show all keys, except the specified key. + query.exclude('place'); + + const testQuery = Parse.Query.or(query, query); +} + +async function test_query_promise() { + // Test promise with a query + const findQuery = new Parse.Query('Test'); + findQuery + .find() + .then(() => { + // success + }) + .catch(() => { + // error + }); + + const getQuery = new Parse.Query('Test'); + try { + await getQuery.get('objectId'); + } catch (error) { + // noop + } + + await getQuery.map((score, index) => score.increment('score', index)); + await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0); + await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0, { batchSize: 200 }); + await getQuery.filter(scores => scores.get('score') > 0); + await getQuery.filter(scores => scores.get('score') > 0, { batchSize: 10 }); +} + +async function test_live_query() { + const subscription = await new Parse.Query('Test').subscribe(); + subscription.on('close', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('create', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('delete', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('enter', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('leave', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('open', object => { + // $ExpectType ParseObject + object; + }); + subscription.on('update', object => { + // $ExpectType ParseObject + object; + }); +} + +function test_anonymous_utils() { + // $ExpectType boolean + Parse.AnonymousUtils.isLinked(new Parse.User()); + // $ExpectType Promise + Parse.AnonymousUtils.link(new Parse.User(), { useMasterKey: true, sessionToken: '' }); + // $ExpectType Promise + Parse.AnonymousUtils.logIn({ useMasterKey: true, sessionToken: '' }); +} + +function return_a_query(): Parse.Query { + return new Parse.Query(Game); +} + +// function test_each() { +// new Parse.Query(Game).each(game => { +// // $ExpectType Game +// game; +// }); +// } + +// function test_file() { +// const base64 = 'V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE='; +// let file = new Parse.File('myfile.txt', { base64 }); + +// file = new Parse.File('nana', { uri: 'http://example.com/image.jps' }); + +// const bytes = [0xbe, 0xef, 0xca, 0xfe]; +// file = new Parse.File('myfile.txt', bytes); + +// file = new Parse.File('myfile.zzz', new Blob(), 'image/png'); + +// const src = file.url(); +// const secure = file.url({ forceSecure: true }); + +// file.save().then( +// () => { +// // The file has been saved to Parse. +// }, +// error => { +// // The file either could n ot be read, or could not be saved to Parse. +// }, +// ); + +// Parse.Cloud.httpRequest({ url: file.url() }).then((response: Parse.Cloud.HttpResponse) => { +// // result +// }); + +// // TODO: Check + +// file.cancel(); +// file.destroy(); +// } + +// function test_file_tags_and_metadata() { +// const base64 = 'V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE='; +// const file = new Parse.File('myfile.txt', { base64 }); +// file.setTags({ ownerId: 42, status: 'okay' }); +// file.addTag('labes', ['one', 'two', 'three']); +// file.setMetadata({ contentType: 'plain/text', contentLength: 579 }); +// file.addMetadata('author', 'John Doe'); + +// const tags = file.tags(); +// const ownerId = tags['ownerId']; + +// const metadata = file.metadata(); +// const contentType = metadata['contentType']; +// } + +// function test_analytics() { +// const dimensions = { +// // Define ranges to bucket data points into meaningful segments +// priceRange: '1000-1500', +// // Did the user filter the query? +// source: 'craigslist', +// // Do searches happen more often on weekdays or weekends? +// dayType: 'weekday', +// }; +// // Send the dimensions to Parse along with the 'search' event +// Parse.Analytics.track('search', dimensions); + +// const codeString = '404'; +// Parse.Analytics.track('error', { code: codeString }); +// } + +// function test_relation() { +// const game1 = new Game(); +// const game2 = new Game(); + +// new Parse.User() +// .relation('games') +// .query() +// .find() +// .then((g: Game[]) => {}); +// new Parse.User().relation('games').add(game1); +// new Parse.User().relation('games').add([game1, game2]); + +// new Parse.User().relation('games').remove(game1); +// new Parse.User().relation('games').remove([game1, game2]); +// } + +// function test_user() { +// const user = new Parse.User(); +// user.set('username', 'my name'); +// user.set('password', 'my pass'); +// user.set('email', 'email@example.com'); +// user.signUp(null, { useMasterKey: true }); + +// const anotherUser: Parse.User = Parse.User.fromJSON({}); +// anotherUser.set('email', 'email@example.com'); +// } + +// async function test_user_currentAsync() { +// const asyncUser = await Parse.User.currentAsync(); +// if (asyncUser) { +// asyncUser.set('email', 'email@example.com'); +// } else if (asyncUser === null) { +// Parse.User.logIn('email@example.com', 'my pass'); +// } +// } + +// function test_user_acl_roles() { +// const user = new Parse.User(); +// user.set('username', 'my name'); +// user.set('password', 'my pass'); +// user.set('email', 'email@example.com'); + +// // other fields can be set just like with Parse.Object +// user.set('phone', '415-392-0202'); + +// const currentUser = Parse.User.current(); +// if (currentUser) { +// // do stuff with the user +// } else { +// // show the signup or login page +// } + +// Parse.User.become('session-token-here').then( +// user => { +// // The current user is now set to user. +// }, +// error => { +// // The token could not be validated. +// }, +// ); + +// Parse.User.hydrate({}).then( +// user => { +// // The current user is now set to user. +// }, +// error => { +// // The token could not be validated. +// }, +// ); + +// const game = new Game(); +// game.set('gameScore', new GameScore()); +// game.setACL(new Parse.ACL(Parse.User.current())); +// game.save().then((game: Game) => {}); +// game.save(null, { useMasterKey: true }); +// game.save({ score: '10' }, { useMasterKey: true }).then( +// game => { +// // Update game then revert it to the last saved state. +// game.set('score', '20'); +// game.revert('score'); +// game.revert('score', 'ACL'); +// game.revert(); +// }, +// error => { +// // The save failed +// }, +// ); + +// const groupACL = new Parse.ACL(); + +// const userList: Parse.User[] = [Parse.User.current()!]; +// // userList is an array with the users we are sending this message to. +// for (const userListItem of userList) { +// groupACL.setReadAccess(userListItem, true); +// groupACL.setWriteAccess(userListItem, true); +// } + +// groupACL.setPublicReadAccess(true); + +// game.setACL(groupACL); + +// Parse.User.requestPasswordReset('email@example.com').then( +// data => { +// // The current user is now set to user. +// }, +// error => { +// // The token could not be validated. +// }, +// ); + +// Parse.User.requestEmailVerification('email@example.com').then( +// data => { +// // The current user is now set to user. +// }, +// error => { +// // The token could not be validated. +// }, +// ); + +// // By specifying no write privileges for the ACL, we can ensure the role cannot be altered. +// const role = new Parse.Role('Administrator', groupACL); +// role.getUsers().add(userList[0]); +// role.getRoles().add(role); +// role.save(); + +// Parse.User.logOut().then(data => { +// // logged out +// }); +// } + +// function test_facebook_util() { +// Parse.FacebookUtils.init({ +// appId: 'YOUR_APP_ID', // Facebook App ID +// channelUrl: '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File +// cookie: true, // enable cookies to allow Parse to access the session +// xfbml: true, // parse XFBML +// }); + +// Parse.FacebookUtils.logIn(null, { +// success: (user: Parse.User) => { +// if (!user.existed()) { +// alert('User signed up and logged in through Facebook!'); +// } else { +// alert('User logged in through Facebook!'); +// } +// }, +// error: (user: Parse.User, error: any) => { +// alert('User cancelled the Facebook login or did not fully authorize.'); +// }, +// }); + +// const user = Parse.User.current()!; + +// if (!Parse.FacebookUtils.isLinked(user)) { +// Parse.FacebookUtils.link(user, null, { +// success: (user: any) => { +// alert('Woohoo, user logged in with Facebook!'); +// }, +// error: (user: any, error: any) => { +// alert('User cancelled the Facebook login or did not fully authorize.'); +// }, +// }); +// } + +// Parse.FacebookUtils.unlink(user, { +// success: (user: Parse.User) => { +// alert('The user is no longer associated with their Facebook account.'); +// }, +// }); +// } + +// async function test_cloud_functions() { +// Parse.Cloud.run( +// 'hello', +// {}, +// { +// success: (result: any) => { +// // result +// }, +// error: (error: any) => {}, +// }, +// ); + +// // $ExpectType any +// await Parse.Cloud.run('SomeFunction'); + +// // $ExpectType any +// await Parse.Cloud.run('SomeFunction', { something: 'whatever' }); + +// // $ExpectType any +// await Parse.Cloud.run('SomeFunction', null, { useMasterKey: true }); + +// // ExpectType boolean +// await Parse.Cloud.run<() => boolean>('SomeFunction'); + +// // $ExpectType boolean +// await Parse.Cloud.run<() => boolean>('SomeFunction', null); + +// // $ExpectType boolean +// await Parse.Cloud.run<() => boolean>('SomeFunction', null, { useMasterKey: true }); + +// // $ExpectType number +// await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', { paramA: 'hello' }); + +// // @ts-expect-error +// await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction'); + +// // @ts-expect-error +// await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', { paramZ: 'hello' }); + +// // @ts-expect-error +// await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', null, { useMasterKey: true }); + +// // @ts-expect-error +// await Parse.Cloud.run<(params: string) => any>('SomeFunction', 'hello'); + +// Parse.Cloud.afterDelete('MyCustomClass', (request: Parse.Cloud.AfterDeleteRequest) => { +// // result +// }); + +// Parse.Cloud.afterSave('MyCustomClass', (request: Parse.Cloud.AfterSaveRequest) => { +// if (!request.context) { +// throw new Error('Request context should be defined'); +// } +// // result +// }); + +// Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest) => { +// // result +// }); + +// Parse.Cloud.beforeDelete('MyCustomClass', async (request: Parse.Cloud.BeforeDeleteRequest) => { +// // result +// }); + +// interface BeforeSaveObject { +// immutable: boolean; +// } + +// Parse.Cloud.beforeSave('MyCustomClass', async request => { +// if (request.object.isNew()) { +// if (!request.object.has('immutable')) throw new Error('Field immutable is required'); +// } else { +// const original = request.original; +// if (original == null) { +// // When the object is not new, request.original must be defined +// throw new Error('Original must me defined for an existing object'); +// } + +// if (original.get('immutable') !== request.object.get('immutable')) { +// throw new Error('This field cannot be changed'); +// } +// } +// if (!request.context) { +// throw new Error('Request context should be defined'); +// } +// }); + +// Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { +// const query = request.query; // the Parse.Query +// const user = request.user; // the user +// const isMaster = request.master; // if the query is run with masterKey +// const isCount = request.count; // if the query is a count operation (available on parse-server 2.4.0 or up) +// const isGet = request.isGet; // if the query is a get operation + +// // All possible read preferences +// request.readPreference = Parse.Cloud.ReadPreferenceOption.Primary; +// request.readPreference = Parse.Cloud.ReadPreferenceOption.PrimaryPreferred; +// request.readPreference = Parse.Cloud.ReadPreferenceOption.Secondary; +// request.readPreference = Parse.Cloud.ReadPreferenceOption.SecondaryPreferred; +// request.readPreference = Parse.Cloud.ReadPreferenceOption.Nearest; +// }); + +// Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { +// const query = request.query; // the Parse.Query + +// return new Parse.Query('QueryMe!'); +// }); + +// Parse.Cloud.beforeFind('MyCustomClass', async (request: Parse.Cloud.BeforeFindRequest) => { +// const query = request.query; // the Parse.Query + +// return new Parse.Query('QueryMe, IN THE FUTURE!'); +// }); + +// Parse.Cloud.afterFind('MyCustomClass', async (request: Parse.Cloud.AfterFindRequest) => { +// return new Parse.Object('MyCustomClass'); +// }); + +// Parse.Cloud.beforeLogin((request: Parse.Cloud.TriggerRequest) => { +// return Promise.resolve(); +// }); + +// Parse.Cloud.afterLogin((request: Parse.Cloud.TriggerRequest) => { +// return Promise.resolve(); +// }); + +// Parse.Cloud.afterLogout((request: Parse.Cloud.TriggerRequest) => { +// return Promise.resolve(); +// }); + +// Parse.Cloud.beforeSaveFile((request: Parse.Cloud.FileTriggerRequest) => { +// return Promise.resolve(new Parse.File('myFile.txt', { base64: '' })); +// }); + +// Parse.Cloud.beforeSaveFile((request: Parse.Cloud.FileTriggerRequest) => {}); + +// Parse.Cloud.beforeDeleteFile((request: Parse.Cloud.FileTriggerRequest) => {}); + +// Parse.Cloud.afterDeleteFile((request: Parse.Cloud.FileTriggerRequest) => {}); + +// Parse.Cloud.define('AFunc', (request: Parse.Cloud.FunctionRequest) => { +// return 'Some result'; +// }); + +// Parse.Cloud.define( +// 'AFunc', +// (request: Parse.Cloud.FunctionRequest) => { +// return 'Some result'; +// }, +// { +// requireUser: true, +// requireMaster: true, +// validateMasterKey: true, +// skipWithMasterKey: true, +// requireAnyUserRoles: ['a'], +// requireAllUserRoles: ['a'], +// fields: { +// name: { +// type: String, +// constant: true, +// default: true, +// options: [], +// error: 'invalid field.', +// }, +// }, +// requireUserKeys: { +// name: { +// type: String, +// constant: true, +// default: true, +// options: [], +// error: 'invalid field.', +// }, +// }, +// }, +// ); + +// Parse.Cloud.define('AFunc', request => { +// // $ExpectType Params +// request.params; + +// // $ExpectType any +// request.params.anything; +// }); + +// Parse.Cloud.define<() => void>('AFunc', request => { +// // $ExpectType {} +// request.params; +// }); + +// Parse.Cloud.define<(params: { something: string }) => number>('AFunc', request => { +// // $ExpectType { something: string; } +// request.params; + +// // @ts-expect-error +// request.params.somethingElse; + +// return 123; +// }); + +// // @ts-expect-error +// Parse.Cloud.define('AFunc'); + +// // @ts-expect-error +// Parse.Cloud.define<() => string>('AFunc', () => 123); + +// // @ts-expect-error +// Parse.Cloud.define<(params: string) => number>('AFunc', () => 123); + +// Parse.Cloud.job('AJob', (request: Parse.Cloud.JobRequest) => { +// request.message('Message to associate with this job run'); +// }); + +// Parse.Cloud.startJob('AJob', {}).then(v => v); + +// Parse.Cloud.getJobStatus('AJob').then(v => v); + +// Parse.Cloud.getJobsData().then(v => v); +// } + +// class PlaceObject extends Parse.Object {} + +// function test_geo_points() { +// let point = new Parse.GeoPoint(); +// // @ts-expect-error +// point = new Parse.GeoPoint('40.0'); +// // @ts-expect-error +// point = new Parse.GeoPoint(40.0); +// // @ts-expect-error +// point = new Parse.GeoPoint([40.0, -30.0, 20.0]); +// point = new Parse.GeoPoint([40.0, -30.0]); +// point = new Parse.GeoPoint(40.0, -30.0); +// point = new Parse.GeoPoint({ latitude: 40.0, longitude: -30.0 }); + +// const userObject = Parse.User.current>()!; + +// // User's location +// const userGeoPoint = userObject.get('location'); + +// // Create a query for places +// const query = new Parse.Query(Parse.User); +// // Interested in locations near user. +// query.near('location', userGeoPoint); +// // Limit what could be a lot of points. +// query.limit(10); + +// const southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398); +// const northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962); + +// const query2 = new Parse.Query(PlaceObject); +// query2.withinGeoBox('location', southwestOfSF, northeastOfSF); + +// const query3 = new Parse.Query('PlaceObject').find().then((o: Parse.Object[]) => {}); +// } + +// function test_push() { +// Parse.Push.send( +// { +// channels: ['Gia nts', 'Mets'], +// data: { +// alert: 'The Giants won against the Mets 2-3.', +// }, +// }, +// { +// success: () => { +// // Push was successful +// }, +// error: (error: any) => { +// // Handle error +// }, +// }, +// ); + +// const query = new Parse.Query(Parse.Installation); +// query.equalTo('injuryReports', true); + +// Parse.Push.send( +// { +// where: query, // Set our Installation query +// data: { +// alert: 'Willie Hayes injured by own pop fly.', +// }, +// }, +// { +// success() { +// // Push was successful +// }, +// error(error: any) { +// // Handle error +// }, +// }, +// ); +// } + +// function test_batch_operations() { +// const game1 = new Game(); +// const game2 = new Game(); +// const games = [game1, game2]; + +// // Master key +// Parse.Object.saveAll(games, { useMasterKey: true }); +// Parse.Object.destroyAll(games, { useMasterKey: true }); +// Parse.Object.fetchAll(games, { useMasterKey: true }); +// Parse.Object.fetchAllIfNeeded(games, { useMasterKey: true }); + +// // Session token +// Parse.Object.saveAll(games, { sessionToken: '' }); +// Parse.Object.destroyAll(games, { sessionToken: '' }); +// Parse.Object.fetchAll(games, { sessionToken: '' }); +// Parse.Object.fetchAllIfNeeded(games, { sessionToken: '' }); +// } + +// async function test_query_subscribe() { +// // create new query from Game object type +// const query = new Parse.Query(Game); + +// // create subscription to Game object +// // Without a token +// // $ExpectType LiveQuerySubscription +// let subscription = await query.subscribe(); + +// // With a session token +// // $ExpectType LiveQuerySubscription +// subscription = await query.subscribe(new Parse.User().getSessionToken()); + +// // listen for new Game objects created on Parse server +// subscription.on('create', (game: any) => { +// console.log(game); +// }); + +// // unsubscribe +// subscription.unsubscribe(); +// } + +// function test_serverURL() { +// Parse.serverURL = 'http://localhost:1337/parse'; +// } +// function test_polygon() { +// const point = new Parse.GeoPoint(1, 2); +// const polygon1 = new Parse.Polygon([ +// [0, 0], +// [1, 0], +// [1, 1], +// [0, 1], +// ]); +// const polygon2 = new Parse.Polygon([point, point, point]); +// polygon1.equals(polygon2); +// polygon1.containsPoint(point); + +// const query = new Parse.Query('TestObject'); +// query.polygonContains('key', point); +// query.withinPolygon('key', [ +// [0, 0], +// [1, 0], +// [1, 1], +// [0, 1], +// ]); +// } + +// async function test_local_datastore() { +// Parse.enableLocalDatastore(); +// const name = 'test_pin'; +// const obj = new Parse.Object('TestObject'); +// await obj.pin(); +// await obj.unPin(); +// await obj.isPinned(); +// await obj.pinWithName(name); +// await obj.unPinWithName(name); +// await obj.fetchFromLocalDatastore(); + +// await Parse.Object.pinAll([obj]); +// await Parse.Object.unPinAll([obj]); +// await Parse.Object.pinAllWithName(name, [obj]); +// await Parse.Object.unPinAllWithName(name, [obj]); +// await Parse.Object.unPinAllObjects(); +// await Parse.Object.unPinAllObjectsWithName(name); + +// const flag = Parse.isLocalDatastoreEnabled(); +// const LDS = await Parse.dumpLocalDatastore(); + +// const query = new Parse.Query('TestObject'); +// query.fromPin(); +// query.fromPinWithName(name); +// query.fromLocalDatastore(); + +// Parse.setLocalDatastoreController({}); +// } + +// async function test_from_network() { +// const obj = new Parse.Object('TestObject'); +// await obj.save(); + +// const query = new Parse.Query('TestObject'); +// query.fromNetwork(); +// } + +// async function test_cancel_query() { +// const obj = new Parse.Object('TestObject'); +// await obj.save(); + +// const query = new Parse.Query('TestObject'); +// query.fromNetwork().find(); +// query.cancel(); +// } + +// type FieldType = +// | string +// | number +// | boolean +// | Date +// | Parse.File +// | Parse.GeoPoint +// | any[] +// | object +// | Parse.Pointer +// | Parse.Polygon +// | Parse.Relation; +// async function test_schema( +// anyField: FieldType, +// notString: Exclude, +// notNumber: Exclude, +// notboolean: Exclude, +// notDate: Exclude, +// notFile: Exclude, +// notGeopoint: Exclude, +// notArray: Exclude, +// notObject: Exclude, +// notPointer: Exclude, +// notPolygon: Exclude, +// ) { +// // $ExpectType RestSchema[] +// await Parse.Schema.all(); + +// const schema = new Parse.Schema('TestSchema'); + +// schema.addArray('arrayField'); +// schema.addArray('arrayField', { defaultValue: [1, 2, 3, 4] }); +// // @ts-expect-error +// schema.addArray('arrayField', { defaultValue: notArray }); + +// /** +// * @todo Enable type check for default value +// */ +// schema.addField('defaultFieldString'); +// schema.addField('defaultFieldString', 'String', { defaultValue: anyField }); +// schema.addField('defaultFieldString', 'Number'); +// schema.addField('defaultFieldString', 'Relation'); +// // @ts-expect-error +// schema.addField('defaultFieldString', 'String', 'Invalid Options'); + +// schema.addString('field'); +// schema.addString('field', { defaultValue: 'some string', required: true }); +// // @ts-expect-error +// schema.addString('field', { defaultValue: notString }); + +// schema.addNumber('field'); +// schema.addNumber('field', { defaultValue: 0, required: true }); +// // @ts-expect-error +// schema.addNumber('field', { defaultValue: notNumber }); + +// schema.addBoolean('field'); +// schema.addBoolean('field', { defaultValue: true, required: true }); +// // @ts-expect-error +// schema.addBoolean('field', { defaultValue: notboolean }); + +// schema.addDate('field'); +// schema.addDate('field', { defaultValue: new Date(), required: true }); +// // @ts-expect-error +// schema.addDate('field', { defaultValue: notDate }); + +// schema.addFile('field'); +// schema.addFile('field', { defaultValue: new Parse.File('myfile', []), required: true }); +// // @ts-expect-error +// schema.addFile('field', { defaultValue: notFile }); + +// schema.addGeoPoint('field'); +// schema.addGeoPoint('field', { defaultValue: new Parse.GeoPoint(), required: true }); +// // @ts-expect-error +// schema.addGeoPoint('field', { defaultValue: notGeopoint }); + +// schema.addPolygon('field'); +// schema.addPolygon('field', { defaultValue: new Parse.Polygon([]), required: true }); +// // @ts-expect-error +// schema.addPolygon('field', { defaultValue: notPolygon }); + +// schema.addObject('field'); +// schema.addObject('field', { defaultValue: {}, required: true }); +// schema.addObject('field', { defaultValue: { abc: 'def' } }); +// // @ts-expect-error +// schema.addObject('field', { defaultValue: notObject }); + +// schema.addPointer('field', 'SomeClass'); +// // @ts-expect-error +// schema.addPointer('field'); +// /** +// * @todo Infer defaultValue type from targetClass +// */ +// schema.addPointer('field', '_User', { defaultValue: new Parse.User().toPointer(), required: true }); +// // @ts-expect-error +// schema.addPointer('field', { defaultValue: notPointer }); + +// schema.addRelation('field', 'SomeClass'); +// // @ts-expect-error +// schema.addRelation('field'); +// // @ts-expect-error +// schema.addRelation('field', 'SomeClass', 'anything'); + +// schema.addIndex('testIndex', { stringField: 'text' }); +// schema.addIndex('testIndex', { stringField: 1 }); +// schema.addIndex('testIndex', { stringField: -1 }); +// // @ts-expect-error +// schema.addIndex('testIndex', { stringField: true }); + +// schema.deleteField('defaultFieldString'); +// schema.deleteIndex('testIndex'); +// schema.delete().then(results => {}); +// // $ExpectType RestSchema +// await schema.get(); +// schema.purge().then(results => {}); +// schema.save().then(results => {}); +// schema.update().then(results => {}); + +// function testGenericType() { +// interface iTestAttributes { +// arrField: any[]; +// boolField: boolean; +// stringField: string; +// numField: number; +// dateField: Date; +// fileField: Parse.File; +// geoPointField: Parse.GeoPoint; +// polygonField: Parse.Polygon; +// objectField: object; +// relationField: Parse.Relation; +// pointerField: Parse.Pointer | Parse.Object; +// } +// class TestObject extends Parse.Object {} + +// const schema = new Parse.Schema('TestObject'); +// schema.addArray('arrField'); +// schema.addBoolean('boolField'); +// schema.addDate('dateField'); +// schema.addFile('fileField'); +// schema.addGeoPoint('geoPointField'); +// schema.addNumber('numField'); +// schema.addObject('objectField'); +// schema.addPointer('pointerField', 'FooClass'); +// schema.addPolygon('polygonField'); +// schema.addRelation('relationField', 'FooClass'); +// schema.addString('stringField'); + +// // @ts-expect-error +// schema.addArray('wrong'); +// // @ts-expect-error +// schema.addBoolean('wrong'); +// // @ts-expect-error +// schema.addDate('wrong'); +// // @ts-expect-error +// schema.addFile('wrong'); +// // @ts-expect-error +// schema.addGeoPoint('wrong'); +// // @ts-expect-error +// schema.addNumber('wrong'); +// // @ts-expect-error +// schema.addObject('wrong'); +// // @ts-expect-error +// schema.addPointer('wrong', 'FooClass'); +// // @ts-expect-error +// schema.addPolygon('wrong'); +// // @ts-expect-error +// schema.addRelation('wrong', 'FooClass'); +// // @ts-expect-error +// schema.addString('wrong'); +// } +// } + +// function testObject() { +// function testConstructor() { +// // $ExpectType Object +// new Parse.Object(); + +// // $ExpectType Object +// new Parse.Object('TestObject'); + +// // $ExpectType Object<{ example: number; }> +// new Parse.Object('TestObject', { example: 100 }); + +// // $ExpectType Object<{ example: boolean; }> +// new Parse.Object<{ example: boolean }>('TestObject', { example: true }); + +// // $ExpectType Object<{ example: string; }> +// new Parse.Object('TestObject', { example: 'hello' }, { ignoreValidation: true }); + +// // @ts-expect-error +// new Parse.Object<{ example: string }>('TestObject'); + +// // @ts-expect-error +// new Parse.Object<{ example: boolean }>('TestObject', { example: 'hello' }); +// } + +// function testStaticMethods() { +// async function testSaveAll(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType Object[] +// await Parse.Object.saveAll([objUntyped]); + +// // $ExpectType Object<{ example: string; }>[] +// await Parse.Object.saveAll([objTyped]); + +// // $ExpectType [Object, Object<{ example: string; }>] +// await Parse.Object.saveAll<[typeof objUntyped, typeof objTyped]>([objUntyped, objTyped]); + +// // @ts-expect-error +// await Parse.Object.saveAll([123]); +// } +// } + +// function testAttributes(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType any +// objUntyped.attributes.whatever; + +// // $ExpectType string +// objTyped.attributes.example; + +// // @ts-expect-error +// objTyped.attributes.other; +// } + +// function testAdd(objUntyped: Parse.Object, objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>) { +// // $ExpectType false | Object +// objUntyped.add('whatever', 'hello'); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.add('stringList', 'hello'); + +// // @ts-expect-error +// objTyped.add('stringList', 100); + +// // @ts-expect-error +// objTyped.add('thing', true); + +// // @ts-expect-error +// objTyped.add('whatever', 'hello'); +// } + +// function testAddAll(objUntyped: Parse.Object, objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>) { +// // $ExpectType false | Object +// objUntyped.addAll('whatever', ['hello', 100]); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.addAll('stringList', ['hello']); + +// // @ts-expect-error +// objTyped.addAll('stringList', [100]); + +// // @ts-expect-error +// objTyped.addAll('thing', [true]); + +// // @ts-expect-error +// objTyped.addAll('whatever', ['hello']); +// } + +// function testAddAllUnique( +// objUntyped: Parse.Object, +// objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>, +// ) { +// // $ExpectType false | Object +// objUntyped.addAllUnique('whatever', ['hello', 100]); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.addAllUnique('stringList', ['hello']); + +// // @ts-expect-error +// objTyped.addAllUnique('stringList', [100]); + +// // @ts-expect-error +// objTyped.addAllUnique('thing', [true]); + +// // @ts-expect-error +// objTyped.addAllUnique('whatever', ['hello']); +// } + +// function testAddUnique(objUntyped: Parse.Object, objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>) { +// // $ExpectType false | Object +// objUntyped.addUnique('whatever', 'hello'); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.addUnique('stringList', 'hello'); + +// // @ts-expect-error +// objTyped.addUnique('stringList', 100); + +// // @ts-expect-error +// objTyped.addUnique('thing', true); + +// // @ts-expect-error +// objTyped.addUnique('whatever', 'hello'); +// } + +// function testDirty(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType boolean +// objUntyped.dirty(); + +// // $ExpectType boolean +// objUntyped.dirty('whatever'); + +// // $ExpectType boolean +// objTyped.dirty(); + +// // $ExpectType boolean +// objTyped.dirty('example'); + +// // @ts-expect-error +// objTyped.dirty('other'); +// } + +// function testEquals(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType boolean +// objUntyped.equals(objTyped); + +// // $ExpectType boolean +// objTyped.equals(objUntyped); + +// // @ts-expect-error +// objUntyped.equals('blah'); +// } + +// function testEscape(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType string +// objUntyped.escape('whatever'); + +// // $ExpectType string +// objTyped.escape('example'); + +// // @ts-expect-error +// objTyped.escape('other'); +// } + +// function testFetchWithInclude(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType Promise> +// objUntyped.fetchWithInclude('whatever'); + +// // $ExpectType Promise> +// objUntyped.fetchWithInclude(['whatever']); + +// // $ExpectType Promise> +// objUntyped.fetchWithInclude([['whatever']]); + +// // @ts-expect-error +// objUntyped.fetchWithInclude([[['whatever']]]); + +// // $ExpectType Promise> +// objTyped.fetchWithInclude('example'); + +// // $ExpectType Promise> +// objTyped.fetchWithInclude(['example']); + +// // $ExpectType Promise> +// objTyped.fetchWithInclude([['example']]); + +// // @ts-expect-error +// objTyped.fetchWithInclude([[['example']]]); + +// // $ExpectType Promise[]> +// Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'example'); + +// // @ts-expect-error +// Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'notAnAttribute'); + +// // $ExpectType Promise[]> +// Parse.Object.fetchAllWithInclude([objTyped], 'example'); + +// // @ts-expect-error +// Parse.Object.fetchAllWithInclude([objTyped], 'notAnAttribute'); +// } + +// function testGet(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType any +// objUntyped.get('whatever'); + +// // $ExpectType number +// objTyped.get('example'); + +// // @ts-expect-error +// objTyped.get('other'); +// } + +// function testHas(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType boolean +// objUntyped.has('whatever'); + +// // $ExpectType boolean +// objTyped.has('example'); + +// // @ts-expect-error +// objTyped.has('other'); +// } + +// function testIncrement(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType false | Object +// objUntyped.increment('whatever'); + +// // $ExpectType false | Object +// objUntyped.increment('whatever', 10); + +// // $ExpectType false | Object<{ example: number; }> +// objTyped.increment('example'); + +// // $ExpectType false | Object<{ example: number; }> +// objTyped.increment('example', 20); + +// // @ts-expect-error +// objTyped.increment('example', true); + +// // @ts-expect-error +// objTyped.increment('other'); +// } + +// function testDecrement(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType false | Object +// objUntyped.decrement('whatever'); + +// // $ExpectType false | Object +// objUntyped.decrement('whatever', 10); + +// // $ExpectType false | Object<{ example: number; }> +// objTyped.decrement('example'); + +// // $ExpectType false | Object<{ example: number; }> +// objTyped.decrement('example', 20); + +// // @ts-expect-error +// objTyped.decrement('example', true); + +// // @ts-expect-error +// objTyped.decrement('other'); +// } + +// function testNewInstance(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType Object +// objUntyped.newInstance(); + +// // $ExpectType Object<{ example: number; }> +// objTyped.newInstance(); +// } + +// function testOp(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { +// // $ExpectType any +// objUntyped.op('whatever'); + +// // $ExpectType any +// objTyped.op('example'); + +// // @ts-expect-error +// objTyped.op('other'); +// } + +// function testRelation(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number; rel: Parse.Relation }>) { +// // $ExpectType Relation, Object> +// objUntyped.relation('whatever'); + +// // $ExpectType Relation, Object>; }>, Object> +// objTyped.relation('rel'); + +// // @ts-expect-error +// objTyped.relation('example'); + +// // @ts-expect-error +// objTyped.relation('other'); +// } + +// function testRemove(objUntyped: Parse.Object, objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>) { +// // $ExpectType false | Object +// objUntyped.remove('whatever', 'hello'); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.remove('stringList', 'hello'); + +// // @ts-expect-error +// objTyped.remove('stringList', 100); + +// // @ts-expect-error +// objTyped.remove('thing', true); + +// // @ts-expect-error +// objTyped.remove('whatever', 'hello'); +// } + +// function testRemoveAll(objUntyped: Parse.Object, objTyped: Parse.Object<{ stringList: string[]; thing: boolean }>) { +// // $ExpectType false | Object +// objUntyped.removeAll('whatever', ['hello', 100]); + +// // $ExpectType false | Object<{ stringList: string[]; thing: boolean; }> +// objTyped.removeAll('stringList', ['hello']); + +// // @ts-expect-error +// objTyped.removeAll('stringList', [100]); + +// // @ts-expect-error +// objTyped.removeAll('thing', [true]); + +// // @ts-expect-error +// objTyped.removeAll('whatever', ['hello']); +// } + +// function testRevert(objUntyped: Parse.Object, objTyped: Parse.Object<{ thingOne: number; thingTwo: boolean }>) { +// // $ExpectType void +// objUntyped.revert(); + +// // $ExpectType void +// objUntyped.revert('whatever', 'more whatever'); + +// // $ExpectType void +// objTyped.revert(); + +// // $ExpectType void +// objTyped.revert('thingOne', 'thingTwo'); + +// // @ts-expect-error +// objTyped.revert('other'); +// } +// interface ObjectAttributes { +// example: boolean; +// someString: string; +// } +// interface OptionalObjectAttributes { +// example?: boolean | undefined; +// another?: string | undefined; +// } + +// async function testSave( +// objUntyped: Parse.Object, +// objTyped: Parse.Object, +// objTypedOptional: Parse.Object, +// ) { +// // $ExpectType Object +// await objUntyped.save({ whatever: 100 }); + +// // $ExpectType Object +// await objUntyped.save('whatever', 100); + +// // $ExpectType Object +// await objTyped.save({ example: true }); + +// // $ExpectType Object +// await objTyped.save({ example: true, someString: 'hello' }); + +// // @ts-expect-error +// await objTyped.save({ example: 'hello', someString: true }); + +// // $ExpectType Object +// await objTyped.save('example', true); + +// // @ts-expect-error +// await objTyped.save({ example: 'hello' }); + +// // @ts-expect-error +// await objTyped.save({ wrongProp: 5 }); + +// // @ts-expect-error +// await objTyped.save('example', 10); + +// // @ts-expect-error +// await objTyped.save('wrongProp', true); + +// // @ts-expect-error +// await objTyped.save({ example: undefined }); + +// // @ts-expect-error +// await objTyped.save('example', undefined); + +// // $ExpectType Object +// await objTyped.save({}); + +// // $ExpectType Object +// await objTypedOptional.save({ example: undefined }); + +// // $ExpectType Object +// await objTypedOptional.save('example', undefined); + +// // $ExpectType Object +// await objTypedOptional.save({}); + +// // $ExpectType Object +// await objTypedOptional.saveEventually({}); + +// // $ExpectType Object +// await objTypedOptional.destroyEventually({}); +// } + +// function testSet( +// objUntyped: Parse.Object, +// objTyped: Parse.Object, +// objTypedOptional: Parse.Object, +// ) { +// // $ExpectType false | Object +// objUntyped.set('propA', 'some value'); + +// // $ExpectType false | Object +// objUntyped.set({ propA: undefined }); + +// // $ExpectType false | Object +// objTyped.set({ example: false }); + +// // $ExpectType false | Object +// objTyped.set({ example: true, someString: 'abc' }); + +// // @ts-expect-error +// objTyped.set({ example: 123, someString: 'abc' }); + +// // $ExpectType false | Object +// objTyped.set('example', true); + +// // @ts-expect-error +// objTyped.set({ example: 100 }); + +// // @ts-expect-error +// objTyped.set({ other: 'something' }); + +// // @ts-expect-error +// objTyped.set('example', 100); + +// // @ts-expect-error +// objTyped.set('other', 100); + +// // @ts-expect-error +// objTyped.set({ example: undefined }); + +// // $ExpectType false | Object +// objTyped.set({}); + +// // @ts-expect-error +// objTyped.set('example', undefined); + +// // $ExpectType false | Object +// objTypedOptional.set({ example: undefined }); + +// // $ExpectType false | Object +// objTypedOptional.set('example', undefined); + +// // $ExpectType false | Object +// objTypedOptional.set({}); +// } + +// interface AttributesAllTypes { +// someString: string; +// someNumber: number; +// someBoolean: boolean; +// someDate: Date; +// someJSONObject: AttributesAllTypes; +// someJSONArray: AttributesAllTypes[]; +// someRegExp: RegExp; +// someUndefined: undefined; +// someNull: null; +// someParseObjectUntyped: Parse.Object; +// someParseObjectTyped: Parse.Object; +// someParseACL: Parse.ACL; +// someParseGeoPoint: Parse.GeoPoint; +// someParsePolygon: Parse.Polygon; +// someParseRelation: Parse.Relation; +// someParseFile: Parse.File; +// } + +// function testToJSON(objUntyped: Parse.Object, objTyped: Parse.Object) { +// // $ExpectType ToJSON & JSONBaseAttributes +// const JSONUntyped = objUntyped.toJSON(); +// // $ExpectType string +// JSONUntyped.objectId; +// // $ExpectType string +// JSONUntyped.createdAt; +// // $ExpectType string +// JSONUntyped.updatedAt; +// // $ExpectType any +// JSONUntyped.anything; + +// // $ExpectType ToJSON & JSONBaseAttributes +// const JSONTyped = objTyped.toJSON(); +// // $ExpectType string +// JSONTyped.objectId; +// // $ExpectType string +// JSONTyped.createdAt; +// // $ExpectType string +// JSONTyped.updatedAt; +// // $ExpectType string +// JSONTyped.someString; +// // $ExpectType number +// JSONTyped.someNumber; +// // $ExpectType boolean +// JSONTyped.someBoolean; +// // $ExpectType { __type: "Date"; iso: string; } +// JSONTyped.someDate; +// // $ExpectType ToJSON +// JSONTyped.someJSONObject; +// // $ExpectType ToJSON[] +// JSONTyped.someJSONArray; +// // $ExpectType string +// JSONTyped.someRegExp; +// // $ExpectType undefined +// JSONTyped.someUndefined; +// // $ExpectType null +// JSONTyped.someNull; +// // $ExpectType Pointer | (ToJSON & JSONBaseAttributes) +// JSONTyped.someParseObjectUntyped; +// // $ExpectType Pointer | (ToJSON & JSONBaseAttributes) +// JSONTyped.someParseObjectTyped; +// // $ExpectType any +// JSONTyped.someParseACL; +// // $ExpectType any +// JSONTyped.someParseGeoPoint; +// // $ExpectType any +// JSONTyped.someParsePolygon; +// // $ExpectType any +// JSONTyped.someParseRelation; +// // $ExpectType { __type: string; name: string; url: string; } +// JSONTyped.someParseFile; +// } + +// function testUnset(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { +// // $ExpectType false | Object +// objUntyped.unset('whatever'); + +// // $ExpectType false | Object<{ example: string; }> +// objTyped.unset('example'); + +// // @ts-expect-error +// objTyped.unset('other'); +// } + +// function testValidate(obj: Parse.Object<{}>) { +// // Note: The attributes being validated don't necessarily have to match the current object's attributes + +// // $ExpectType false | Error +// obj.validate({ someAttrToValidate: 'hello' }); +// } + +// function testNullableArrays( +// objTyped: Parse.Object<{ stringList?: string[] | null }> +// ) { +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.add('stringList', 'foo'); + +// // @ts-expect-error +// objTyped.add('stringList', 4); + +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.addAll('stringList', ['foo']); + +// // @ts-expect-error +// objTyped.addAll('stringList', [4]); + +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.addAllUnique('stringList', ['foo', 'bar']); + +// // @ts-expect-error +// objTyped.addAllUnique('stringList', [4]); + +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.addUnique('stringList', 'foo'); + +// // @ts-expect-error +// objTyped.addUnique('stringList', 4); + +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.remove('stringList', 'bar'); + +// // @ts-expect-error +// objTyped.remove('stringList', 4); + +// // $ExpectType false | Object<{ stringList?: string[] | null | undefined; }> +// objTyped.removeAll('stringList', ['bar']); + +// // @ts-expect-error +// objTyped.removeAll('stringList', [4]); +// } +// } + +// function testInstallation() { +// function testConstructor() { +// // $ExpectType Installation +// new Parse.Installation(); + +// // $ExpectType Installation<{ example: number; }> +// new Parse.Installation({ example: 100 }); + +// // @ts-expect-error +// new Parse.Installation<{ example: number }>(); + +// // @ts-expect-error +// new Parse.Installation<{ example: number }>({ example: 'hello' }); +// } +// } + +// function testQuery() { +// function testConstructor() { +// // $ExpectType Query> +// new Parse.Query('TestObject'); + +// // $ExpectType Query> +// new Parse.Query(Parse.Role); + +// // $ExpectType Query> +// new Parse.Query(Parse.User); + +// // $ExpectType Query> +// new Parse.Query>('TestObject'); + +// // $ExpectType Query> +// new Parse.Query>(Parse.Role); + +// // $ExpectType Query> +// new Parse.Query>(Parse.User); +// } + +// async function testQueryMethodTypes() { +// class AnotherSubClass extends Parse.Object<{ x: any }> { +// constructor() { +// super('Another', { x: 'example' }); +// } +// } +// class MySubClass extends Parse.Object<{ +// attribute1: string; +// attribute2: number; +// attribute3: AnotherSubClass; +// attribute4: string[]; +// }> {} +// const query = new Parse.Query(MySubClass); + +// // $ExpectType Query +// query.addAscending(['attribute1', 'attribute2', 'updatedAt']); +// // @ts-expect-error +// query.addAscending(['attribute1', 'unexistenProp']); + +// // $ExpectType Query +// query.addDescending(['attribute1', 'attribute2', 'createdAt']); +// // @ts-expect-error +// query.addDescending(['attribute1', 'unexistenProp']); + +// // $ExpectType Query +// query.ascending(['attribute1', 'attribute2', 'objectId']); +// // @ts-expect-error +// query.ascending(['attribute1', 'nonexistentProp']); + +// // $ExpectType Query +// query.containedBy('attribute1', ['a', 'b', 'c']); +// // $ExpectType Query +// query.containedBy('attribute3', ['objectId1', 'objectId2', 'objectId3']); +// // @ts-expect-error +// query.containedBy('attribute2', ['a', 'b', 'c']); +// // @ts-expect-error +// query.containedBy('attribute1', [1, 2, 3]); +// // @ts-expect-error +// query.containedBy('nonexistentProp', ['a', 'b', 'c']); + +// // $ExpectType Query +// query.containedIn('attribute1', ['a', 'b', 'c']); +// // $ExpectType Query +// query.containedIn('attribute3', ['objectId1', 'objectId2', 'objectId3']); +// // @ts-expect-error +// query.containedIn('attribute2', ['a', 'b', 'c']); +// // @ts-expect-error +// query.containedIn('attribute1', [1, 2, 3]); +// // @ts-expect-error +// query.containedIn('nonexistentProp', ['a', 'b', 'c']); + +// // $ExpectType Query +// query.contains('attribute1', 'a substring'); +// // @ts-expect-error +// query.contains('nonexistentProp', 'a substring'); + +// // $ExpectType Query +// query.containsAll('attribute1', ['a', 'b', 'c']); +// // @ts-expect-error +// query.containsAll('nonexistentProp', ['a', 'b', 'c']); + +// // $ExpectType Query +// query.containsAllStartingWith('attribute1', ['a', 'b', 'c']); +// // @ts-expect-error +// query.containsAllStartingWith('nonexistentProp', ['a', 'b', 'c']); + +// // $ExpectType Query +// query.descending(['attribute1', 'attribute2', 'objectId']); +// // @ts-expect-error +// query.descending(['attribute1', 'nonexistentProp']); + +// // $ExpectType Query +// query.doesNotExist('attribute1'); +// // @ts-expect-error +// query.doesNotExist('nonexistentProp'); + +// // $ExpectType Query +// query.doesNotMatchKeyInQuery('attribute1', 'x', new Parse.Query(AnotherSubClass)); +// // @ts-expect-error +// query.doesNotMatchKeyInQuery('unexistenProp', 'x', new Parse.Query(AnotherSubClass)); +// // @ts-expect-error +// query.doesNotMatchKeyInQuery('attribute1', 'unknownKey', new Parse.Query(AnotherSubClass)); +// // $ExpectType Query +// query.doesNotMatchKeyInQuery('objectId', 'x', new Parse.Query(AnotherSubClass)); +// // $ExpectType Query +// query.doesNotMatchKeyInQuery('updatedAt', 'x', new Parse.Query(AnotherSubClass)); + +// // $ExpectType Query +// query.doesNotMatchQuery('attribute1', new Parse.Query('Example')); +// // @ts-expect-error +// query.doesNotMatchQuery('nonexistentProp', new Parse.Query('Example')); + +// // $ExpectType Query +// query.endsWith('attribute1', 'asuffixstring'); +// // @ts-expect-error +// query.endsWith('nonexistentProp', 'asuffixstring'); + +// // $ExpectType Query +// query.equalTo('attribute2', 0); +// // $ExpectType Query +// query.equalTo('attribute3', new AnotherSubClass()); +// // $ExpectType Query +// query.equalTo('attribute3', new AnotherSubClass().toPointer()); +// // @ts-expect-error +// query.equalTo('attribute1', new AnotherSubClass().toPointer()); +// // @ts-expect-error +// query.equalTo('attribute2', 'a string value'); +// // @ts-expect-error +// query.equalTo('nonexistentProp', 'any value'); + +// // $ExpectType Query +// query.equalTo('attribute4', 'a_string_value'); // Can query contents of array +// // Can query array itself if equal too (mongodb $eq matches the array exactly or the contains an element that matches the array exactly) +// // $ExpectType Query +// query.equalTo('attribute4', ['a_string_value']); + +// // $ExpectType Query +// query.notEqualTo('attribute4', 'a_string_value'); +// // $ExpectType Query +// query.notEqualTo('attribute4', ['a_string_value']); + +// // @ts-expect-error +// query.equalTo('attribute4', 5); +// // @ts-expect-error +// query.notEqualTo('attribute4', 5); +// // @ts-expect-error +// query.equalTo('attribute4', [5]); +// // @ts-expect-error +// query.notEqualTo('attribute4', [5]); + +// // $ExpectType Query +// query.exists('attribute1'); +// // @ts-expect-error +// query.exists('nonexistentProp'); + +// // $ExpectType Query +// query.fullText('attribute1', 'full text'); +// // @ts-expect-error +// query.fullText('nonexistentProp', 'full text'); + +// // $ExpectType Query +// query.greaterThan('attribute2', 1000); +// // @ts-expect-error +// query.greaterThan('attribute2', '1000'); +// // @ts-expect-error +// query.greaterThan('nonexistentProp', 1000); + +// // $ExpectType Query +// query.greaterThanOrEqualTo('attribute2', 1000); +// // @ts-expect-error +// query.greaterThanOrEqualTo('attribute2', '1000'); +// // @ts-expect-error +// query.greaterThanOrEqualTo('nonexistentProp', 1000); + +// // $ExpectType Query +// query.include(['attribute1', 'attribute2']); +// // $ExpectType Query +// query.include('attribute3.someProp'); +// // @ts-expect-error +// query.include(['attribute1', 'nonexistentProp']); + +// // $ExpectType Query +// query.lessThan('attribute2', 1000); +// // @ts-expect-error +// query.lessThan('attribute2', '1000'); +// // @ts-expect-error +// query.lessThan('nonexistentProp', 1000); + +// // $ExpectType Query +// query.lessThanOrEqualTo('attribute2', 1000); +// // @ts-expect-error +// query.lessThanOrEqualTo('attribute2', '1000'); +// // @ts-expect-error +// query.lessThanOrEqualTo('nonexistentProp', 1000); + +// // $ExpectType Query +// query.matches('attribute1', /a regex/); +// // @ts-expect-error +// query.matches('nonexistentProp', /a regex/); + +// // $ExpectType Query +// query.matchesKeyInQuery('attribute1', 'x', new Parse.Query(AnotherSubClass)); +// // @ts-expect-error +// query.matchesKeyInQuery('nonexistentProp', 'x', new Parse.Query(AnotherSubClass)); +// // @ts-expect-error +// query.matchesKeyInQuery('attribute1', 'unknownKey', new Parse.Query(AnotherSubClass)); + +// // $ExpectType Query +// query.matchesQuery('attribute1', new Parse.Query('Example')); +// // @ts-expect-error +// query.matchesQuery('nonexistentProp', new Parse.Query('Example')); + +// // $ExpectType Query +// query.near('attribute1', new Parse.GeoPoint()); +// // @ts-expect-error +// query.near('nonexistentProp', new Parse.GeoPoint()); + +// // $ExpectType Query +// query.notContainedIn('attribute2', [1, 2, 3]); +// // @ts-expect-error +// query.notContainedIn('attribute2', ['1', '2', '3']); +// // @ts-expect-error +// query.notContainedIn('nonexistentProp', [1, 2, 3]); + +// // $ExpectType Query +// query.notEqualTo('attribute1', '1'); +// // @ts-expect-error +// query.notEqualTo('attribute1', 1); +// // @ts-expect-error +// query.notEqualTo('nonexistentProp', 1); + +// // $ExpectType Query +// query.polygonContains('attribute1', new Parse.GeoPoint()); +// // @ts-expect-error +// query.polygonContains('nonexistentProp', new Parse.GeoPoint()); + +// // $ExpectType Query +// query.select('attribute1', 'attribute2'); +// // @ts-expect-error +// query.select('attribute1', 'nonexistentProp'); + +// // $ExpectType Query +// query.startsWith('attribute1', 'prefix string'); +// // @ts-expect-error +// query.startsWith('nonexistentProp', 'prefix string'); + +// // $ExpectType Query +// query.withCount(true); + +// // $ExpectType Query +// query.withinGeoBox('attribute1', new Parse.GeoPoint(), new Parse.GeoPoint()); +// // @ts-expect-error +// query.withinGeoBox('nonexistentProp', new Parse.GeoPoint(), new Parse.GeoPoint()); + +// // $ExpectType Query +// query.withinKilometers('attribute1', new Parse.GeoPoint(), 100); +// // @ts-expect-error +// query.withinKilometers('nonexistentProp', new Parse.GeoPoint(), 100); + +// // $ExpectType Query +// query.withinMiles('attribute1', new Parse.GeoPoint(), 100); +// // @ts-expect-error +// query.withinMiles('nonexistentProp', new Parse.GeoPoint(), 100); + +// // $ExpectType Query +// query.withinPolygon('attribute1', [ +// [12.3, 45.6], +// [-78.9, 10.1], +// ]); +// // @ts-expect-error +// query.withinPolygon('nonexistentProp', [ +// [12.3, 45.6], +// [-78.9, 10.1], +// ]); + +// // $ExpectType Query +// query.withinRadians('attribute1', new Parse.GeoPoint(), 100); +// // @ts-expect-error +// query.withinRadians('nonexistentProp', new Parse.GeoPoint(), 100); +// } + +// async function testQueryMethods( +// queryUntyped: Parse.Query, +// queryTyped: Parse.Query>, +// ) { +// // $ExpectType Object +// await queryUntyped.get('objectId'); + +// // $ExpectType Object[] +// await queryUntyped.find(); + +// // $ExpectType string[] +// await queryTyped.distinct('example'); + +// // $ExpectType Object | undefined +// await queryUntyped.first(); + +// // $ExpectType Object<{ example: string; }> +// await queryTyped.get('objectId'); + +// // $ExpectType Object<{ example: string; }>[] +// await queryTyped.find(); + +// // $ExpectType Object<{ example: string; }> | undefined +// await queryTyped.first(); +// } +// } + +// function testRole() { +// function testConstructor(acl: Parse.ACL) { +// // $ExpectType Role> +// new Parse.Role<{ example: string }>('TestRole', acl); +// } + +// function testAttributes(roleUntyped: Parse.Role, roleTyped: Parse.Role<{ example: number }>) { +// // $ExpectType Attributes +// roleUntyped.attributes; + +// // $ExpectType { example: number; } +// roleTyped.attributes; +// } +// } + +// function testSession() { +// function testConstructor() { +// // $ExpectType Session +// new Parse.Session(); + +// // $ExpectType Session<{ example: number; }> +// new Parse.Session({ example: 100 }); + +// // @ts-expect-error +// new Parse.Session<{ example: number }>(); + +// // @ts-expect-error +// new Parse.Session<{ example: number }>({ example: 'hello' }); +// } +// } + +// function testUser() { +// function testConstructor() { +// // $ExpectType User +// new Parse.User(); + +// // $ExpectType User<{ example: number; }> +// new Parse.User({ example: 100 }); + +// // @ts-expect-error +// new Parse.User<{ example: number }>(); + +// // @ts-expect-error +// new Parse.User<{ example: number }>({ example: 'hello' }); +// } +// async function testAuthenticationProvider() { +// const authProvider: Parse.AuthProvider = { +// authenticate: () => {}, +// getAuthType: () => 'customAuthorizationProvider', +// restoreAuthentication: () => false, +// deauthenticate: () => {}, +// }; +// const authData: Parse.AuthData = { +// id: 'some-user-authentication-id', +// access_token: 'some-access-token', +// expiration_date: new Date().toISOString(), +// }; +// Parse.User._registerAuthenticationProvider(authProvider); + +// const user = await Parse.User.logInWith( +// authProvider, +// { authData }, +// { sessionToken: 'some-session-token', useMasterKey: true }, +// ); +// const isLinked = user._isLinked(authProvider); +// const unlinkedUser = await user._unlinkFrom(authProvider); +// const linkedUser = await user.linkWith(authProvider, { authData }); +// } +// } + +// function testEncryptingUser() { +// function testSecretKey() { +// Parse.secret = 'secret!'; +// } + +// function testEnableEncryptedUserKey() { +// Parse.encryptedUser = true; +// } + +// function testEnablingEncryptedUser() { +// Parse.enableEncryptedUser(); +// } + +// function testIsEncryptedUserEnabled() { +// Parse.isEncryptedUserEnabled(); +// } +// } + +// function testEventuallyQueue() { +// function test() { +// const obj = new Parse.Object('TestObject'); +// // $ExpectType Promise +// Parse.EventuallyQueue.clear(); +// // $ExpectType Promise +// Parse.EventuallyQueue.getQueue(); +// // $ExpectType boolean +// Parse.EventuallyQueue.isPolling(); +// // $ExpectType Promise +// Parse.EventuallyQueue.save(obj); +// // $ExpectType Promise +// Parse.EventuallyQueue.save(obj, {}); +// // $ExpectType Promise +// Parse.EventuallyQueue.destroy(obj); +// // $ExpectType Promise +// Parse.EventuallyQueue.destroy(obj, {}); +// // $ExpectType Promise +// Parse.EventuallyQueue.length(); +// // $ExpectType Promise +// Parse.EventuallyQueue.sendQueue(); +// // $ExpectType void +// Parse.EventuallyQueue.stopPoll(); +// // $ExpectType void +// Parse.EventuallyQueue.poll(); +// // $ExpectType void +// Parse.EventuallyQueue.poll(300); +// // @ts-expect-error +// Parse.EventuallyQueue.poll('300'); +// } +// } + +// function LiveQueryEvents() { +// function testLiveQueryEvents() { +// Parse.LiveQuery.on('open', () => { +// }); +// Parse.LiveQuery.on('close', () => { +// }); +// Parse.LiveQuery.on('error', (error: any) => { +// }); +// } +// } diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 000000000..2edb2f209 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + + // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". + // If the library is global (cannot be imported via `import` or `require`), leave this out. + "baseUrl": ".", + "paths": { "parse": ["."] } + }, + "include": [ + "tests.ts" + ] +} diff --git a/types/tslint.json b/types/tslint.json new file mode 100644 index 000000000..776df04be --- /dev/null +++ b/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "@definitelytyped/dtslint/dtslint.json", + "rules": { + "semicolon": false, + "ban-types": false, + "no-unnecessary-generics": false, + "no-redundant-jsdoc": false, + "strict-export-declare-modifiers": false + } +} \ No newline at end of file diff --git a/types/unique.d.ts b/types/unique.d.ts new file mode 100644 index 000000000..1736d2e04 --- /dev/null +++ b/types/unique.d.ts @@ -0,0 +1 @@ +export default function unique(arr: T[]): T[]; diff --git a/types/unsavedChildren.d.ts b/types/unsavedChildren.d.ts new file mode 100644 index 000000000..ec1be90ca --- /dev/null +++ b/types/unsavedChildren.d.ts @@ -0,0 +1,11 @@ +/** + * Return an array of unsaved children, which are either Parse Objects or Files. + * If it encounters any dirty Objects without Ids, it will throw an exception. + * + * @param {Parse.Object} obj + * @param {boolean} allowDeepUnsaved + * @returns {Array} + */ +export default function unsavedChildren(obj: ParseObject, allowDeepUnsaved?: boolean): Array; +import ParseObject from './ParseObject'; +import ParseFile from './ParseFile'; diff --git a/types/uuid.d.ts b/types/uuid.d.ts new file mode 100644 index 000000000..f3a50d131 --- /dev/null +++ b/types/uuid.d.ts @@ -0,0 +1,2 @@ +export = uuid; +declare let uuid: any; From 7f7d4fdbaf7abb769a82b45802bfa7afe1d7ba39 Mon Sep 17 00:00:00 2001 From: dblythy Date: Fri, 28 Jul 2023 13:02:07 +1000 Subject: [PATCH 02/13] Update package-lock.json --- package-lock.json | 72 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index f88935f9f..110e67396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "4.2.0-alpha.4", "license": "Apache-2.0", "dependencies": { - "@babel/runtime-corejs3": "7.22.5", + "@babel/runtime-corejs3": "7.22.6", "idb-keyval": "6.2.1", "react-native-crypto-js": "1.0.0", "uuid": "9.0.0", @@ -20,7 +20,7 @@ "@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.21.0", + "@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", @@ -202,12 +202,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.0.tgz", - "integrity": "sha512-tyzR0OsH88AelgukhL2rbEUCLKBGmy2G9Th/5vpyOt0zf44Be61kvIQXjCwTSX8t+qJ/vMwZfhK6mPdrMLZXRg==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", + "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", "dev": true, "dependencies": { - "@babel/types": "^7.22.0", + "@babel/types": "^7.22.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -1074,12 +1074,12 @@ } }, "node_modules/@babel/plugin-syntax-flow": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.18.6.tgz", - "integrity": "sha512-LUbR+KNTBWCUAqRG9ex5Gnzu2IOkt8jRJbHHXFT9q+L9zm7M/QQbEqXyw1n1pohYvOyWC8CjeyjrSaIwiYjK7A==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.22.5.tgz", + "integrity": "sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -1423,14 +1423,14 @@ } }, "node_modules/@babel/plugin-transform-flow-comments": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-comments/-/plugin-transform-flow-comments-7.21.0.tgz", - "integrity": "sha512-TG7bJMbzlQHV0rUdk1sEWiUMXz4MLJ1uvlAxs52J1lBC9mDSJDtnEmYFywWPg5utvAREM/SR/ty9rwXXuWv+nQ==", + "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.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-flow": "^7.18.6" + "@babel/generator": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-flow": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -2161,9 +2161,9 @@ } }, "node_modules/@babel/runtime-corejs3": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.22.5.tgz", - "integrity": "sha512-TNPDN6aBFaUox2Lu+H/Y1dKKQgr4ucz/FGyCz67RVYLsBpVpUFf1dDngzg+Od8aqbrqwyztkaZjtWCZEUOT8zA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.22.6.tgz", + "integrity": "sha512-M+37LLIRBTEVjktoJjbw4KVhupF0U/3PYUCbBwgAd9k17hoKhRu1n935QiG7Tuxv0LJOMrb2vuKEeYUlv0iyiw==", "dependencies": { "core-js-pure": "^3.30.2", "regenerator-runtime": "^0.13.11" @@ -27936,12 +27936,12 @@ } }, "@babel/generator": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.0.tgz", - "integrity": "sha512-tyzR0OsH88AelgukhL2rbEUCLKBGmy2G9Th/5vpyOt0zf44Be61kvIQXjCwTSX8t+qJ/vMwZfhK6mPdrMLZXRg==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", + "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", "dev": true, "requires": { - "@babel/types": "^7.22.0", + "@babel/types": "^7.22.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -28552,12 +28552,12 @@ } }, "@babel/plugin-syntax-flow": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.18.6.tgz", - "integrity": "sha512-LUbR+KNTBWCUAqRG9ex5Gnzu2IOkt8jRJbHHXFT9q+L9zm7M/QQbEqXyw1n1pohYvOyWC8CjeyjrSaIwiYjK7A==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.22.5.tgz", + "integrity": "sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.22.5" } }, "@babel/plugin-syntax-import-assertions": { @@ -28781,14 +28781,14 @@ } }, "@babel/plugin-transform-flow-comments": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-comments/-/plugin-transform-flow-comments-7.21.0.tgz", - "integrity": "sha512-TG7bJMbzlQHV0rUdk1sEWiUMXz4MLJ1uvlAxs52J1lBC9mDSJDtnEmYFywWPg5utvAREM/SR/ty9rwXXuWv+nQ==", + "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.21.0", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-flow": "^7.18.6" + "@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": { @@ -29283,9 +29283,9 @@ } }, "@babel/runtime-corejs3": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.22.5.tgz", - "integrity": "sha512-TNPDN6aBFaUox2Lu+H/Y1dKKQgr4ucz/FGyCz67RVYLsBpVpUFf1dDngzg+Od8aqbrqwyztkaZjtWCZEUOT8zA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.22.6.tgz", + "integrity": "sha512-M+37LLIRBTEVjktoJjbw4KVhupF0U/3PYUCbBwgAd9k17hoKhRu1n935QiG7Tuxv0LJOMrb2vuKEeYUlv0iyiw==", "requires": { "core-js-pure": "^3.30.2", "regenerator-runtime": "^0.13.11" From 11e1c76ab4b425b5cb2877268424c2761d37b1c0 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Fri, 28 Jul 2023 18:39:42 -0500 Subject: [PATCH 03/13] convert ParseSession to TS --- src/{Parse.ts => Parse.js} | 0 src/{ParseSession.js => ParseSession.ts} | 6 +- tsconfig.json | 6 +- types/ObjectStateMutations.d.ts | 1 + types/ParseGeoPoint.d.ts | 1 + types/ParseObject.d.ts | 1 + types/ParseOp.d.ts | 1 + types/ParseQuery.d.ts | 1 + types/ParseRole.d.ts | 1 + types/ParseSession.d.ts | 30 +- types/ParseUser.d.ts | 1 + types/RESTController.d.ts | 2 +- types/index.d.ts | 2008 +++++++++++++++++++++- types/tests.ts | 565 +++--- 14 files changed, 2316 insertions(+), 308 deletions(-) rename src/{Parse.ts => Parse.js} (100%) rename src/{ParseSession.js => ParseSession.ts} (98%) diff --git a/src/Parse.ts b/src/Parse.js similarity index 100% rename from src/Parse.ts rename to src/Parse.js diff --git a/src/ParseSession.js b/src/ParseSession.ts similarity index 98% rename from src/ParseSession.js rename to src/ParseSession.ts index 131da6509..51b001742 100644 --- a/src/ParseSession.js +++ b/src/ParseSession.ts @@ -1,7 +1,3 @@ -/** - * @flow - */ - import CoreManager from './CoreManager'; import isRevocableSession from './isRevocableSession'; import ParseObject from './ParseObject'; @@ -22,7 +18,7 @@ class ParseSession extends ParseObject { /** * @param {object} attributes The initial set of data to store in the user. */ - constructor(attributes: ?AttributeMap) { + constructor(attributes?: any) { super('_Session'); if (attributes && typeof attributes === 'object') { if (!this.set(attributes || {})) { diff --git a/tsconfig.json b/tsconfig.json index 570b49f91..8ef8fd0f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,9 @@ "emitDeclarationOnly": true, "outDir": "types", "noImplicitAny": false, - "allowJs": true + "allowJs": false }, - "include": ["src/Parse.ts"] + "files": [ + "src/ParseSession.ts" + ] } \ No newline at end of file diff --git a/types/ObjectStateMutations.d.ts b/types/ObjectStateMutations.d.ts index a40ea402f..c82bd0d6c 100644 --- a/types/ObjectStateMutations.d.ts +++ b/types/ObjectStateMutations.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export function defaultState(): State; export function setServerData(serverData: AttributeMap, attributes: AttributeMap): void; export function setPendingOp(pendingOps: Array, attr: string, op: Op | null): void; diff --git a/types/ParseGeoPoint.d.ts b/types/ParseGeoPoint.d.ts index 4d6c4efd0..9dfca7d53 100644 --- a/types/ParseGeoPoint.d.ts +++ b/types/ParseGeoPoint.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default ParseGeoPoint; /** * @flow diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index e86c0c6c0..096cb4d6e 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck type Pointer = { __type: string; className: string; diff --git a/types/ParseOp.d.ts b/types/ParseOp.d.ts index 544c65a81..5faf58b30 100644 --- a/types/ParseOp.d.ts +++ b/types/ParseOp.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export function opFromJSON(json: { [key: string]: any; }): Op | null; diff --git a/types/ParseQuery.d.ts b/types/ParseQuery.d.ts index 3636ab428..5c8f9de0e 100644 --- a/types/ParseQuery.d.ts +++ b/types/ParseQuery.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck type WhereClause = { [attr: string]: mixed; }; diff --git a/types/ParseRole.d.ts b/types/ParseRole.d.ts index b77c9c944..fe82fd571 100644 --- a/types/ParseRole.d.ts +++ b/types/ParseRole.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default ParseRole; /** * Represents a Role on the Parse server. Roles represent groupings of diff --git a/types/ParseSession.d.ts b/types/ParseSession.d.ts index 6c3334b8a..ce17eb974 100644 --- a/types/ParseSession.d.ts +++ b/types/ParseSession.d.ts @@ -1,4 +1,5 @@ -export default ParseSession; +import ParseObject from './ParseObject'; +import type { FullOptions } from './RESTController'; /** *

        A Parse.Session object is a local representation of a revocable session. * This class is a subclass of a Parse.Object, and retains the same @@ -7,7 +8,17 @@ export default ParseSession; * @alias Parse.Session * @augments Parse.Object */ -declare class ParseSession { +declare class ParseSession extends ParseObject { + /** + * @param {object} attributes The initial set of data to store in the user. + */ + constructor(attributes?: any); + /** + * Returns the session token string. + * + * @returns {string} + */ + getSessionToken(): string; static readOnlyAttributes(): string[]; /** * Retrieves the Session object for the currently logged in session. @@ -18,7 +29,7 @@ declare class ParseSession { * object after it has been fetched. If there is no current user, the * promise will be rejected. */ - static current(options: FullOptions): Promise; + static current(options: FullOptions): any; /** * Determines whether the current session token is revocable. * This method is useful for migrating Express.js or Node.js web apps to @@ -30,16 +41,5 @@ declare class ParseSession { * @returns {boolean} */ static isCurrentSessionRevocable(): boolean; - /** - * @param {object} attributes The initial set of data to store in the user. - */ - constructor(attributes: AttributeMap | null); - /** - * Returns the session token string. - * - * @returns {string} - */ - getSessionToken(): string; } -import { FullOptions } from './RESTController'; -import { AttributeMap } from './ObjectStateMutations'; +export default ParseSession; diff --git a/types/ParseUser.d.ts b/types/ParseUser.d.ts index fe8380c4c..5a425bc55 100644 --- a/types/ParseUser.d.ts +++ b/types/ParseUser.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck type AuthData = { [key: string]: mixed; }; diff --git a/types/RESTController.d.ts b/types/RESTController.d.ts index 8fac87cff..540be2e6f 100644 --- a/types/RESTController.d.ts +++ b/types/RESTController.d.ts @@ -18,4 +18,4 @@ type FullOptions = { progress?: any; usePost?: boolean; }; -export {}; +export { RequestOptions, FullOptions }; diff --git a/types/index.d.ts b/types/index.d.ts index 0b96f9ed9..b28624bc2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,2 +1,2006 @@ -import parse from "./Parse"; -export default parse; \ No newline at end of file +import { EventEmitter } from 'events'; + +declare enum ErrorCode { + /** Error code indicating some error other than those enumerated here */ + OTHER_CAUSE = -1, + /** Error code indicating that something has gone wrong with the server. */ + INTERNAL_SERVER_ERROR = 1, + /** Error code indicating the connection to the Parse servers failed. */ + CONNECTION_FAILED = 100, + /** Error code indicating the specified object doesn't exist. */ + 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. + */ + 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. + */ + INVALID_CLASS_NAME = 103, + /** Error code indicating an unspecified object id. */ + 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. + */ + 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. + */ + 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. + */ + INVALID_JSON = 107, + /** + * Error code indicating that the feature you tried to access is only + * available internally for testing purposes. + */ + COMMAND_UNAVAILABLE = 108, + /** You must call Parse.initialize before using the Parse library. */ + NOT_INITIALIZED = 109, + /** Error code indicating that a field was set to an inconsistent type. */ + 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. + */ + INVALID_CHANNEL_NAME = 112, + /** Error code indicating that push is misconfigured. */ + PUSH_MISCONFIGURED = 115, + /** Error code indicating that the object is too large. */ + OBJECT_TOO_LARGE = 116, + /** Error code indicating that the operation isn't allowed for clients. */ + OPERATION_FORBIDDEN = 119, + /** Error code indicating the result was not found in the cache. */ + CACHE_MISS = 120, + /** Error code indicating that an invalid key was used in a nested JSONObject. */ + 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. + */ + INVALID_FILE_NAME = 122, + /** Error code indicating an invalid ACL was provided. */ + 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. + */ + TIMEOUT = 124, + /** Error code indicating that the email address was invalid. */ + INVALID_EMAIL_ADDRESS = 125, + /** Error code indicating a missing content type. */ + MISSING_CONTENT_TYPE = 126, + /** Error code indicating a missing content length. */ + MISSING_CONTENT_LENGTH = 127, + /** Error code indicating an invalid content length. */ + INVALID_CONTENT_LENGTH = 128, + /** Error code indicating a file that was too large. */ + FILE_TOO_LARGE = 129, + /** Error code indicating an error saving a file. */ + FILE_SAVE_ERROR = 130, + /** + * Error code indicating that a unique field was given a value that is + * already taken. + */ + DUPLICATE_VALUE = 137, + /** Error code indicating that a role's name is invalid. */ + INVALID_ROLE_NAME = 139, + /** + * Error code indicating that an application quota was exceeded. + * Upgrade to resolve. + */ + EXCEEDED_QUOTA = 140, + /** Error code indicating that a Cloud Code script failed. */ + SCRIPT_FAILED = 141, + /** Error code indicating that a Cloud Code validation failed. */ + VALIDATION_ERROR = 142, + /** Error code indicating that invalid image data was provided. */ + INVALID_IMAGE_DATA = 150, + /** Error code indicating an unsaved file. */ + UNSAVED_FILE_ERROR = 151, + /** Error code indicating an invalid push time. */ + INVALID_PUSH_TIME_ERROR = 152, + /** Error code indicating an error deleting a file. */ + FILE_DELETE_ERROR = 153, + /** Error code indicating that the application has exceeded its request limit. */ + REQUEST_LIMIT_EXCEEDED = 155, + /** + * Error code indicating that the request was a duplicate and has been discarded due to + * idempotency rules. + */ + DUPLICATE_REQUEST = 159, + /** Error code indicating an invalid event name. */ + INVALID_EVENT_NAME = 160, + /** Error code indicating an error deleting an unnamed file. */ + FILE_DELETE_UNNAMED_ERROR = 161, + /** Error code indicating that the username is missing or empty. */ + USERNAME_MISSING = 200, + /** Error code indicating that the password is missing or empty. */ + PASSWORD_MISSING = 201, + /** Error code indicating that the username has already been taken. */ + USERNAME_TAKEN = 202, + /** Error code indicating that the email has already been taken. */ + EMAIL_TAKEN = 203, + /** Error code indicating that the email is missing, but must be specified. */ + EMAIL_MISSING = 204, + /** Error code indicating that a user with the specified email was not found. */ + EMAIL_NOT_FOUND = 205, + /** + * Error code indicating that a user object without a valid session could + * not be altered. + */ + SESSION_MISSING = 206, + /** Error code indicating that a user can only be created through signup. */ + MUST_CREATE_USER_THROUGH_SIGNUP = 207, + /** + * Error code indicating that an an account being linked is already linked + * to another user. + */ + ACCOUNT_ALREADY_LINKED = 208, + /** Error code indicating that the current session token is invalid. */ + INVALID_SESSION_TOKEN = 209, + /** Error code indicating an error enabling or verifying MFA */ + MFA_ERROR = 210, + /** Error code indicating that a valid MFA token must be provided */ + 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. + */ + LINKED_ID_MISSING = 250, + /** + * Error code indicating that a user with a linked (e.g. Facebook) account + * has an invalid session. + */ + INVALID_LINKED_SESSION = 251, + /** + * Error code indicating that a service being linked (e.g. Facebook or + * Twitter) is unsupported. + */ + UNSUPPORTED_SERVICE = 252, + /** Error code indicating an invalid operation occured on schema */ + 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. + */ + AGGREGATE_ERROR = 600, + /** Error code indicating the client was unable to read an input file. */ + 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. + */ + X_DOMAIN_REQUEST = 602, +} + +declare global { + namespace Parse { + let applicationId: string; + let javaScriptKey: string | undefined; + let liveQueryServerURL: string; + let masterKey: string | undefined; + let serverAuthToken: string | undefined; + let serverAuthType: string | undefined; + let serverURL: string; + let secret: string; + let idempotency: boolean; + let encryptedUser: boolean; + + interface BatchSizeOption { + batchSize?: number | undefined; + } + + interface CascadeSaveOption { + /** If `false`, nested objects will not be saved (default is `true`). */ + cascadeSave?: boolean | undefined; + } + + interface SuccessOption { + success?: Function | undefined; + } + + interface ErrorOption { + error?: Function | undefined; + } + + interface ContextOption { + context?: { [key: string]: any }; + } + + interface FullOptions { + success?: Function | undefined; + error?: Function | undefined; + useMasterKey?: boolean | undefined; + sessionToken?: string | undefined; + installationId?: string | undefined; + progress?: Function | undefined; + /** + * logIn will default to POST instead of GET method since + * version 3.0.0 for security reasons. + * If you need to use GET set this to `false`. + */ + usePost?: boolean; + } + + interface RequestOptions { + useMasterKey?: boolean | undefined; + sessionToken?: string | undefined; + installationId?: string | undefined; + batchSize?: number | undefined; + include?: string | string[] | undefined; + progress?: Function | undefined; + } + + interface SuccessFailureOptions extends SuccessOption, ErrorOption {} + + interface SignUpOptions { + useMasterKey?: boolean | undefined; + installationId?: string | undefined; + } + + interface SessionTokenOption { + sessionToken?: string | undefined; + } + + interface WaitOption { + /** + * Set to true to wait for the server to confirm success + * before triggering an event. + */ + wait?: boolean | undefined; + } + + interface UseMasterKeyOption { + /** + * In Cloud Code and Node only, causes the Master Key to be used for this request. + */ + useMasterKey?: boolean | undefined; + } + + /** + * https://github.com/parse-community/Parse-SDK-JS/pull/1294/files + * feat: Add option to return raw json from queries + */ + interface RawJSONOptions { + /** (3.0.0+) json: Return raw json without converting to Parse.Object */ + json?: boolean; + } + interface ScopeOptions extends SessionTokenOption, UseMasterKeyOption {} + + interface SilentOption { + /** + * Set to true to avoid firing the event. + */ + silent?: boolean | undefined; + } + + interface Pointer { + __type: string; + className: string; + objectId: string; + } + + interface AuthData { + [key: string]: any; + } + + /** + * Interface declaration for Authentication Providers + * https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html + */ + interface AuthProvider { + /** + * Called when _linkWith isn't passed authData. Handle your own authentication here. + */ + authenticate: () => void; + /** + * (Optional) Called when service is unlinked. Handle any cleanup here. + */ + deauthenticate?: (() => void) | undefined; + /** + * Unique identifier for this Auth Provider. + */ + getAuthType: () => string; + /** + * Called when auth data is syncronized. Can be used to determine if authData is still valid + */ + restoreAuthentication: () => boolean; + } + + interface BaseAttributes { + createdAt: Date; + objectId: string; + updatedAt: Date; + } + + interface CommonAttributes { + ACL: ACL; + } + + interface JSONBaseAttributes { + createdAt: string; + objectId: string; + updatedAt: string; + } + + /** + * Creates a new ACL. + * If no argument is given, the ACL has no permissions for anyone. + * If the argument is a Parse.User, the ACL will have read and write + * permission for only that user. + * If the argument is any other JSON object, that object will be interpretted + * as a serialized ACL created with toJSON(). + * @see Parse.Object#setACL + * + *

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

        + */ + class ACL { + permissionsById: any; + + constructor(arg1?: any); + + setPublicReadAccess(allowed: boolean): void; + getPublicReadAccess(): boolean; + + setPublicWriteAccess(allowed: boolean): void; + getPublicWriteAccess(): boolean; + + setReadAccess(userId: User | string, allowed: boolean): void; + getReadAccess(userId: User | string): boolean; + + setWriteAccess(userId: User | string, allowed: boolean): void; + getWriteAccess(userId: User | string): boolean; + + setRoleReadAccess(role: Role | string, allowed: boolean): void; + getRoleReadAccess(role: Role | string): boolean; + + setRoleWriteAccess(role: Role | string, allowed: boolean): void; + getRoleWriteAccess(role: Role | string): boolean; + + toJSON(): any; + } + + /** + * A Parse.File is a local representation of a file that is saved to the Parse + * cloud. + * @param name The file's name. This will be prefixed by a unique + * value once the file has finished saving. The file name must begin with + * an alphanumeric character, and consist of alphanumeric characters, + * periods, spaces, underscores, or dashes. + * @param data The data for the file, as either: + * 1. an Array of byte value Numbers, or + * 2. an Object like { base64: "..." } with a base64-encoded String. + * 3. a File object selected with a file upload control. (3) only works + * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+. + * For example:
        +         * var fileUploadControl = $("#profilePhotoFileUpload")[0];
        +         * if (fileUploadControl.files.length > 0) {
        +         *   var file = fileUploadControl.files[0];
        +         *   var name = "photo.jpg";
        +         *   var parseFile = new Parse.File(name, file);
        +         *   parseFile.save().then(function() {
        +         *     // The file has been saved to Parse.
        +         *   }, function(error) {
        +         *     // The file either could not be read, or could not be saved to Parse.
        +         *   });
        +         * }
        + * @param type Optional Content-Type header to use for the file. If + * this is omitted, the content type will be inferred from the name's + * extension. + */ + class File { + constructor( + name: string, + data: number[] | { base64: string } | { size: number; type: string } | { uri: string }, + type?: string, + ); + /** + * 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. + * Data is cleared if saved with File object selected with a file upload control + * + * @returns Promise that is resolved with base64 data + */ + getData(): Promise; + url(options?: { forceSecure?: boolean | undefined }): string; + metadata(): Record; + tags(): Record; + name(): string; + save(options?: FullOptions): Promise; + cancel(): void; + destroy(options?: FullOptions): Promise; + toJSON(): { __type: string; name: string; url: string }; + equals(other: File): boolean; + setMetadata(metadata: Record): void; + addMetadata(key: string, value: any): void; + setTags(tags: Record): void; + addTag(key: string, value: any): void; + readonly _url: string; + } + + /** + * Creates a new GeoPoint with any of the following forms:
        + *
        +         *   new GeoPoint(otherGeoPoint)
        +         *   new GeoPoint(30, 30)
        +         *   new GeoPoint([30, 30])
        +         *   new GeoPoint({latitude: 30, longitude: 30})
        +         *   new GeoPoint()  // defaults to (0, 0)
        +         *   
        + * + *

        Represents a latitude / longitude point that may be associated + * with a key in a ParseObject or used as a reference point for geo queries. + * This allows proximity-based queries on the key.

        + * + *

        Only one key in a class may contain a GeoPoint.

        + * + *

        Example:

        +         *   var point = new Parse.GeoPoint(30.0, -20.0);
        +         *   var object = new Parse.Object("PlaceObject");
        +         *   object.set("location", point);
        +         *   object.save();

        + */ + class GeoPoint { + latitude: number; + longitude: number; + + constructor(latitude: number, longitude: number); + constructor(coords?: { latitude: number; longitude: number } | [number, number]); + + current(options?: SuccessFailureOptions): GeoPoint; + radiansTo(point: GeoPoint): number; + kilometersTo(point: GeoPoint): number; + milesTo(point: GeoPoint): number; + toJSON(): any; + } + + /** + * A class that is used to access all of the children of a many-to-many relationship. + * Each instance of Parse.Relation is associated with a particular parent object and key. + */ + class Relation { + parent: S; + key: string; + targetClassName: string; + + constructor(parent?: S, key?: string); + + // Adds a Parse.Object or an array of Parse.Objects to the relation. + add(object: T | T[]): void; + + // Returns a Parse.Query that is limited to objects in this relation. + query(): Query; + + // Removes a Parse.Object or an array of Parse.Objects from this relation. + remove(object: T | T[]): void; + + toJSON(): any; + } + + interface Attributes { + [key: string]: any; + } + + /** + * Creates a new model with defined attributes. A client id (cid) is + * automatically generated and assigned for you. + * + *

        You won't normally call this method directly. It is recommended that + * you use a subclass of Parse.Object instead, created by calling + * extend.

        + * + *

        However, if you don't want to use a subclass, or aren't sure which + * subclass is appropriate, you can use this form:

        +         *     var object = new Parse.Object("ClassName");
        +         * 
        + * That is basically equivalent to:
        +         *     var MyClass = Parse.Object.extend("ClassName");
        +         *     var object = new MyClass();
        +         * 

        + * + * @param attributes The initial set of data to store in the object. + * @param options The options for this object instance. + * @see Parse.Object.extend + * + * + * Creates a new model with defined attributes. + */ + interface Object { + id: string; + createdAt: Date; + updatedAt: Date; + attributes: T; + className: string; + + add extends any[] ? K : never }[keyof T]>( + attr: K, + item: NonNullable[number], + ): this | false; + addAll extends any[] ? K : never }[keyof T]>( + attr: K, + items: NonNullable, + ): this | false; + addAllUnique: this['addAll']; + addUnique: this['add']; + clear(options: any): any; + clone(): this; + destroy(options?: Object.DestroyOptions): Promise; + /** EventuallyQueue API; added in version 3.0.0 */ + destroyEventually(options?: Object.DestroyOptions): Promise; + dirty(attr?: Extract): boolean; + dirtyKeys(): string[]; + equals(other: T): boolean; + escape(attr: Extract): string; + existed(): boolean; + exists(options?: RequestOptions): Promise; + fetch(options?: Object.FetchOptions): Promise; + fetchFromLocalDatastore(): Promise; + fetchWithInclude>( + keys: K | Array, + options?: RequestOptions, + ): Promise; + get>(attr: K): T[K]; + getACL(): ACL | undefined; + has(attr: Extract): boolean; + increment(attr: Extract, amount?: number): this | false; + decrement(attr: Extract, amount?: number): this | false; + initialize(): void; + isDataAvailable(): boolean; + isNew(): boolean; + isPinned(): Promise; + isValid(): boolean; + newInstance(): this; + op(attr: Extract): any; + pin(): Promise; + pinWithName(name: string): Promise; + relation = Extract>( + attr: T[K] extends Relation ? K : never, + ): Relation; + remove: this['add']; + removeAll: this['addAll']; + revert(...keys: Array>): void; + // "Pick | T" is a trick to keep IntelliSense working, see: + // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3bdadbf9583c2335197c7e999b9a30880e055f62/types/react/index.d.ts#L482 + save>( + attrs?: Pick | T | null, + options?: Object.SaveOptions, + ): Promise; + save>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: Object.SaveOptions, + ): Promise; + /** EventuallyQueue API; added in version 3.0.0 */ + saveEventually(options?: Object.SaveOptions): Promise; + set>(attrs: Pick | T, options?: Object.SetOptions): this | false; + set>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: Object.SetOptions, + ): this | false; + setACL(acl: ACL, options?: SuccessFailureOptions): this | false; + toJSON(): Object.ToJSON & JSONBaseAttributes; + toPointer(): Pointer; + unPin(): Promise; + unPinWithName(name: string): Promise; + unset(attr: Extract, options?: any): this | false; + validate(attrs: Attributes, options?: SuccessFailureOptions): Error | false; + } + interface ObjectStatic { + createWithoutData(id: string): T; + destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; + extend(className: string | { className: string }, protoProps?: any, classProps?: any): any; + fetchAll(list: T[], options: Object.FetchAllOptions): Promise; + fetchAllIfNeeded(list: T[], options?: Object.FetchAllOptions): Promise; + fetchAllIfNeededWithInclude( + list: T[], + keys: keyof T['attributes'] | Array, + options?: RequestOptions, + ): Promise; + fetchAllWithInclude( + list: T[], + keys: keyof T['attributes'] | Array, + options?: RequestOptions, + ): Promise; + fromJSON(json: any, override?: boolean): T; + pinAll(objects: Object[]): Promise; + pinAllWithName(name: string, objects: Object[]): Promise; + registerSubclass(className: string, clazz: new (options?: any) => T): void; + saveAll(list: T, options?: Object.SaveAllOptions): Promise; + unPinAll(objects: Object[]): Promise; + unPinAllObjects(): Promise; + unPinAllObjectsWithName(name: string): Promise; + unPinAllWithName(name: string, objects: Object[]): Promise; + } + interface ObjectConstructor extends ObjectStatic { + new (className: string, attributes: T, options?: any): Object; + new (className?: string, attributes?: Attributes, options?: any): Object; + } + const Object: ObjectConstructor; + + namespace Object { + interface DestroyOptions extends SuccessFailureOptions, WaitOption, ScopeOptions {} + + interface DestroyAllOptions extends BatchSizeOption, ScopeOptions {} + + interface FetchAllOptions extends SuccessFailureOptions, ScopeOptions {} + + interface FetchOptions extends SuccessFailureOptions, ScopeOptions {} + + interface SaveOptions + extends CascadeSaveOption, + SuccessFailureOptions, + SilentOption, + ScopeOptions, + ContextOption, + WaitOption {} + + interface SaveAllOptions extends BatchSizeOption, ScopeOptions {} + + interface SetOptions extends ErrorOption, SilentOption { + promise?: any; + } + + // From https://github.com/parse-community/Parse-SDK-JS/blob/master/src/encode.js + type Encode = T extends Object + ? ReturnType | Pointer + : T extends ACL | GeoPoint | Polygon | Relation | File + ? ReturnType + : T extends Date + ? { __type: 'Date'; iso: string } + : T extends RegExp + ? string + : T extends Array + ? // This recursion is unsupported in <=3.6 + Array> + : T extends object + ? ToJSON + : T; + + type ToJSON = { + [K in keyof T]: Encode; + }; + } + + class Polygon { + constructor(arg1: GeoPoint[] | number[][]); + containsPoint(point: GeoPoint): boolean; + equals(other: any): boolean; + toJSON(): any; + } + + /** + * Every Parse application installed on a device registered for + * push notifications has an associated Installation object. + */ + interface Installation extends Object { + badge: any; + channels: string[]; + timeZone: any; + deviceType: string; + pushType: string; + installationId: string; + deviceToken: string; + channelUris: string; + appName: string; + appVersion: string; + parseVersion: string; + appIdentifier: string; + } + interface InstallationConstructor extends ObjectStatic { + new (attributes: T): Installation; + new (): Installation; + } + const Installation: InstallationConstructor; + + /** + * Creates a new parse Parse.Query for the given Parse.Object subclass. + * @param objectClass - + * An instance of a subclass of Parse.Object, or a Parse className string. + * + *

        Parse.Query defines a query that is used to fetch Parse.Objects. The + * most common use case is finding all objects that match a query through the + * find method. For example, this sample code fetches all objects + * of class MyClass. It calls a different function depending on + * whether the fetch succeeded or not. + * + *

        +         * var query = new Parse.Query(MyClass);
        +         * query.find({
        +         *   success: function(results) {
        +         *     // results is an array of Parse.Object.
        +         *   },
        +         *
        +         *   error: function(error) {
        +         *     // error is an instance of Parse.Error.
        +         *   }
        +         * });

        + * + *

        A Parse.Query can also be used to retrieve a single object whose id is + * known, through the get method. For example, this sample code fetches an + * object of class MyClass and id myId. It calls a + * different function depending on whether the fetch succeeded or not. + * + *

        +         * var query = new Parse.Query(MyClass);
        +         * query.get(myId, {
        +         *   success: function(object) {
        +         *     // object is an instance of Parse.Object.
        +         *   },
        +         *
        +         *   error: function(object, error) {
        +         *     // error is an instance of Parse.Error.
        +         *   }
        +         * });

        + * + *

        A Parse.Query can also be used to count the number of objects that match + * the query without retrieving all of those objects. For example, this + * sample code counts the number of objects of the class MyClass + *

        +         * var query = new Parse.Query(MyClass);
        +         * query.count({
        +         *   success: function(number) {
        +         *     // There are number instances of MyClass.
        +         *   },
        +         *
        +         *   error: function(error) {
        +         *     // error is an instance of Parse.Error.
        +         *   }
        +         * });

        + */ + class Query { + objectClass: any; + className: string; + + constructor(objectClass: string | (new (...args: any[]) => T | Object)); + + static and(...args: Array>): Query; + static fromJSON(className: string | (new () => U), json: any): Query; + static nor(...args: Array>): Query; + static or(...var_args: Array>): Query; + + addAscending(key: K | K[]): this; + addDescending(key: K | K[]): this; + ascending(key: K | K[]): this; + aggregate(pipeline: Query.AggregationOptions | Query.AggregationOptions[]): Promise; + containedBy( + key: K, + values: Array, + ): this; + containedIn( + key: K, + values: Array, + ): this; + contains(key: K, substring: string): this; + containsAll(key: K, values: any[]): this; + containsAllStartingWith( + key: K, + values: any[], + ): this; + count(options?: Query.CountOptions): Promise; + descending(key: K | K[]): this; + doesNotExist(key: K): this; + doesNotMatchKeyInQuery< + U extends Object, + K extends keyof T['attributes'] | keyof BaseAttributes, + X extends Extract, + >(key: K, queryKey: X, query: Query): this; + doesNotMatchQuery(key: K, query: Query): this; + distinct(key: K): Promise; + eachBatch(callback: (objs: T[]) => PromiseLike | void, options?: Query.BatchOptions): Promise; + each(callback: (obj: T) => PromiseLike | void, options?: Query.BatchOptions): Promise; + hint(value: string | object): this; + explain(explain: boolean): this; + map( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | U, + options?: Query.BatchOptions, + ): Promise; + reduce( + callback: (accumulator: T, currentObject: T, index: number) => PromiseLike | T, + initialValue?: undefined, + options?: Query.BatchOptions, + ): Promise; + reduce( + callback: (accumulator: U, currentObject: T, index: number) => PromiseLike | U, + initialValue: U, + options?: Query.BatchOptions, + ): Promise; + filter( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | boolean, + options?: Query.BatchOptions, + ): Promise; + endsWith(key: K, suffix: string): this; + equalTo( + key: K, + value: + | T['attributes'][K] + | (T['attributes'][K] extends Object + ? Pointer + : T['attributes'][K] extends Array + ? E + : never), + ): this; + exclude(...keys: K[]): this; + exists(key: K): this; + find(options?: Query.FindOptions): Promise; + findAll(options?: Query.BatchOptions): Promise; + first(options?: Query.FirstOptions): Promise; + fromNetwork(): this; + fromLocalDatastore(): this; + fromPin(): this; + fromPinWithName(name: string): this; + cancel(): this; + fullText( + key: K, + value: string, + options?: Query.FullTextOptions, + ): this; + get(objectId: string, options?: Query.GetOptions): Promise; + greaterThan( + key: K, + value: T['attributes'][K], + ): this; + greaterThanOrEqualTo( + key: K, + value: T['attributes'][K], + ): this; + include(...key: K[]): this; + include(key: K[]): this; + includeAll(): Query; + lessThan(key: K, value: T['attributes'][K]): this; + lessThanOrEqualTo( + key: K, + value: T['attributes'][K], + ): this; + limit(n: number): Query; + matches( + key: K, + regex: RegExp, + modifiers?: string, + ): this; + matchesKeyInQuery< + U extends Object, + K extends keyof T['attributes'], + X extends Extract, + >(key: K, queryKey: X, query: Query): this; + matchesQuery(key: K, query: Query): this; + near(key: K, point: GeoPoint): this; + notContainedIn( + key: K, + values: Array, + ): this; + notEqualTo( + key: K, + value: + | T['attributes'][K] + | (T['attributes'][K] extends Object + ? Pointer + : T['attributes'][K] extends Array + ? E + : never), + ): this; + polygonContains(key: K, point: GeoPoint): this; + select(...keys: K[]): this; + select(keys: K[]): this; + skip(n: number): Query; + sortByTextScore(): this; + startsWith(key: K, prefix: string): this; + subscribe(sessionToken?: string): Promise; + toJSON(): any; + withJSON(json: any): this; + withCount(includeCount?: boolean): this; + withinGeoBox( + key: K, + southwest: GeoPoint, + northeast: GeoPoint, + ): this; + withinKilometers( + key: K, + point: GeoPoint, + maxDistance: number, + sorted?: boolean, + ): this; + withinMiles( + key: K, + point: GeoPoint, + maxDistance: number, + sorted?: boolean, + ): this; + withinPolygon(key: K, points: number[][]): this; + withinRadians( + key: K, + point: GeoPoint, + maxDistance: number, + ): this; + } + + namespace Query { + interface EachOptions extends SuccessFailureOptions, ScopeOptions {} + interface CountOptions extends SuccessFailureOptions, ScopeOptions {} + interface FindOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} + interface FirstOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} + interface GetOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} + + // According to http://docs.parseplatform.org/rest/guide/#aggregate-queries + interface AggregationOptions { + group?: (Record & { objectId?: string }) | undefined; + match?: Record | undefined; + project?: Record | undefined; + limit?: number | undefined; + skip?: number | undefined; + // Sort documentation https://docs.mongodb.com/v3.2/reference/operator/aggregation/sort/#pipe._S_sort + sort?: Record | undefined; + // Sample documentation: https://docs.mongodb.com/v3.2/reference/operator/aggregation/sample/ + sample?: { size: number } | undefined; + // Count documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/count/ + count?: string | undefined; + // Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/ + lookup?: + | { + from: string; + localField: string; + foreignField: string; + as: string; + } + | { + from: string; + let?: Record; + pipeline: Record; + as: string; + } + | undefined; + // Graph Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/ + graphLookup?: + | { + from: string; + startWith?: string; + connectFromField: string; + connectToField: string; + as: string; + maxDepth?: number; + depthField?: string; + restrictSearchWithMatch?: Record; + } + | undefined; + // Facet documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/facet/ + facet?: Record>> | undefined; + // Unwind documentation: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/ + unwind?: + | { + path: string; + includeArrayIndex?: string; + preserveNullAndEmptyArrays?: boolean; + } + | string + | undefined; + } + + // According to https://parseplatform.org/Parse-SDK-JS/api/2.1.0/Parse.Query.html#fullText + interface FullTextOptions { + language?: string | undefined; + caseSensitive?: boolean | undefined; + diacriticSensitive?: boolean | undefined; + } + + interface BatchOptions extends FullOptions { + batchSize?: number | undefined; + } + } + + /** + * Represents a LiveQuery Subscription. + * + * @see https://docs.parseplatform.org/js/guide/#live-queries + * @see NodeJS.EventEmitter + * + * Events list + * --- + * `open` - when you call `query.subscribe()`, we send a subscribe request to + * the LiveQuery server, when we get the confirmation from the LiveQuery server, + * this event will be emitted. When the client loses WebSocket connection to the + * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we + * reconnect the LiveQuery server and successfully resubscribe the ParseQuery, + * you'll also get this event. + * + * ``` + * subscription.on('open', () => {}); + * ``` + * --- + * `create` - when a new ParseObject is created and it fulfills the ParseQuery you subscribe, + * you'll get this event. The object is the ParseObject which is created. + * + * ``` + * subscription.on('create', (object: Parse.Object) => {}); + * ``` + * --- + * `update` event - when an existing ParseObject which fulfills the ParseQuery you subscribe + * is updated (The ParseObject fulfills the ParseQuery before and after changes), + * you'll get this event. The object is the ParseObject which is updated. + * Its content is the latest value of the ParseObject. + * + * ``` + * subscription.on('update', (object: Parse.Object) => {}); + * ``` + * --- + * `enter` event - when an existing ParseObject's old value doesn't fulfill the ParseQuery + * but its new value fulfills the ParseQuery, you'll get this event. The object is the + * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject. + * + * ``` + * subscription.on('enter', (object: Parse.Object) => {}); + * ``` + * --- + * `update` event - when an existing ParseObject's old value fulfills the ParseQuery but its new value + * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject + * which leaves the ParseQuery. Its content is the latest value of the ParseObject. + * + * ``` + * subscription.on('leave', (object: Parse.Object) => {}); + * ``` + * --- + * `delete` event - when an existing ParseObject which fulfills the ParseQuery is deleted, you'll + * get this event. The object is the ParseObject which is deleted. + * + * ``` + * subscription.on('delete', (object: Parse.Object) => {}); + * ``` + * --- + * `close` event - when the client loses the WebSocket connection to the LiveQuery + * server and we stop receiving events, you'll get this event. + * + * ``` + * subscription.on('close', () => {}); + * ``` + */ + class LiveQuerySubscription extends EventEmitter { + /** + * Creates an instance of LiveQuerySubscription. + * + * @param id + * @param query + * @param [sessionToken] + */ + constructor(id: string, query: string, sessionToken?: string); + + on( + event: 'open' | 'create' | 'update' | 'enter' | 'leave' | 'delete' | 'close', + listener: (object: Object) => void, + ): this; + + /** + * Closes the subscription. + * + */ + unsubscribe(): void; + } + + /** + * The LiveQuery namespace is basically an EventEmitter + * (source : https://github.com/parse-community/Parse-SDK-JS/blob/8115e959533d1676fe5e5551bc81888b21fc12ef/src/ParseLiveQuery.js) + * https://docs.parseplatform.org/js/guide/#websocket-status + */ + namespace LiveQuery { + function on( + event: 'open' | 'close', + /** When we establish ('open') or lose the WebSocket connection to the LiveQuery server, you’ll get this event */ + listener: () => void, + ): void; + function on( + event: 'error', + /** When some network error or LiveQuery server error happens, you’ll get this event. */ + listener: (error: any) => void, + ): void; + } + + /** + * Represents a Role on the Parse server. Roles represent groupings of + * Users for the purposes of granting permissions (e.g. specifying an ACL + * for an Object). Roles are specified by their sets of child users and + * child roles, all of which are granted any permissions that the parent + * role has. + * + *

        Roles must have a name (which cannot be changed after creation of the + * role), and must specify an ACL.

        + * A Parse.Role is a local representation of a role persisted to the Parse + * cloud. + */ + interface Role extends Object { + getRoles(): Relation; + getUsers(): Relation; + getName(): string; + setName(name: string, options?: SuccessFailureOptions): any; + } + interface RoleConstructor extends ObjectStatic { + new (name: string, acl: ACL): Role>; + new (name: string, acl: ACL): Role; + } + const Role: RoleConstructor; + + class Config { + static get(options?: UseMasterKeyOption): Promise; + static current(): Config; + static save(attr: any, options?: { [attr: string]: boolean }): Promise; + + get(attr: string): any; + escape(attr: string): any; + } + + interface Session extends Object { + getSessionToken(): string; + isCurrentSessionRevocable(): boolean; + } + interface SessionConstructor extends ObjectStatic { + new (attributes: T): Session; + new (): Session; + + current(): Promise; + } + const Session: SessionConstructor; + + /** + * + *

        A Parse.User object is a local representation of a user persisted to the + * Parse cloud. This class is a subclass of a Parse.Object, and retains the + * same functionality of a Parse.Object, but also extends it with various + * user specific methods, like authentication, signing up, and validation of + * uniqueness.

        + */ + interface User extends Object { + signUp(attrs?: any, options?: SignUpOptions): Promise; + logIn(options?: FullOptions): Promise; + authenticated(): boolean; + isCurrent(): boolean; + /** Since version 3.0.0, Returns true if `current` would return this user */ + isCurrentAsync(): Promise; + + getEmail(): string | undefined; + setEmail(email: string, options?: SuccessFailureOptions): boolean; + + getUsername(): string | undefined; + setUsername(username: string, options?: SuccessFailureOptions): boolean; + + setPassword(password: string, options?: SuccessFailureOptions): boolean; + getSessionToken(): string; + + linkWith: ( + provider: string | AuthProvider, + options: { authData?: AuthData | undefined }, + saveOpts?: FullOptions, + ) => Promise; + _isLinked: (provider: string | AuthProvider) => boolean; + _unlinkFrom: (provider: string | AuthProvider, options?: FullOptions) => Promise; + } + interface UserConstructor extends ObjectStatic { + new (attributes: T): User; + new (attributes?: Attributes): User; + + allowCustomUserClass(isAllowed: boolean): void; + become(sessionToken: string, options?: UseMasterKeyOption): Promise; + current(): T | undefined; + currentAsync(): Promise; + signUp(username: string, password: string, attrs: any, options?: SignUpOptions): Promise; + logIn(username: string, password: string, options?: FullOptions): Promise; + logOut(): Promise; + requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; + requestEmailVerification(email: string, options?: UseMasterKeyOption): Promise; + extend(protoProps?: any, classProps?: any): any; + hydrate(userJSON: any): Promise; + enableUnsafeCurrentUser(): void; + disableUnsafeCurrentUser(): void; + logInWith( + provider: string | AuthProvider, + options: { authData?: AuthData | undefined }, + saveOpts?: FullOptions, + ): Promise; + _registerAuthenticationProvider: (provider: AuthProvider) => void; + } + const User: UserConstructor; + + /** + * The raw schema response returned from the `GET /parse/schemas` endpoint. + * This is defined here: https://docs.parseplatform.org/js/guide/#schema. + * Unfortunately, `Schema.all()` and `Schema.prototype.get()` return this rather + * than a `Schema`. It is also the only object which provides introspection on + * the schema - such as `className` and `fields`. + */ + interface RestSchema { + className: string; + fields: { + [key: string]: { + type: string; + targetClass?: string; + required?: boolean; + defaultValue?: string; + }; + }; + classLevelPermissions: Schema.CLP; + indexes?: { + [key: string]: { + [key: string]: any; + }; + }; + } + + /** + * A Parse.Schema object is for handling schema data from Parse. + * All the schemas methods require MasterKey. + * + * @param className Parse Class string + * + * https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html + * + * ``` + * const schema = new Parse.Schema('MyClass'); + * schema.addString('field'); + * schema.addIndex('index_name', { field: 1 }); + * schema.save(); + * ``` + */ + class Schema { + constructor(className: string); + + /** + * Static method to get all schemas + * + * @return A promise that is resolved with the result when + * the query completes. + */ + static all(): Promise; + + addArray(key: Schema.AttrType, options?: Schema.FieldOptions): this; + addBoolean(key: Schema.AttrType, options?: Schema.FieldOptions): this; + addDate(key: Schema.AttrType, options?: Schema.FieldOptions): this; + addField(name: string, type?: T, options?: Schema.FieldOptions): this; + addFile(key: Schema.AttrType, options?: Schema.FieldOptions): this; + addGeoPoint(key: Schema.AttrType, options?: Schema.FieldOptions): this; + + /** + * Adding an Index to Create / Update a Schema + * @param name Name of the field that will be created on Parse + * @param index `{ 'field': value }` where `field` should exist in the schema before using addIndex. + * @return Returns the schema, so you can chain this call. + * @example + * ``` + * schema.addIndex('index_name', {'field': 1}); + * ``` + */ + addIndex(name: string, index: Schema.Index): this; + + addNumber(key: Schema.AttrType, options?: Schema.FieldOptions): this; + + addObject(key: Schema.AttrType, options?: Schema.FieldOptions): this; + + /** + * Adding Pointer Field + * @param name Name of the field that will be created on Parse + * @param targetClass Name of the target Pointer Class + * @return Returns the schema, so you can chain this call. + */ + addPointer( + key: Schema.AttrType, + targetClass: string, + options?: Schema.FieldOptions, + ): this; + + addPolygon(key: Schema.AttrType, options?: Schema.FieldOptions): this; + + /** + * Adding Relation Field + * @param name Name of the field that will be created on Parse + * @param targetClass Name of the target Pointer Class + * @return Returns the schema, so you can chain this call. + */ + addRelation( + key: Schema.AttrType, + targetClass: string, + options?: Schema.FieldOptions, + ): this; + + addString(key: Schema.AttrType, options?: Schema.FieldOptions): this; + + /** + * Removing a Schema from Parse Can only be used on Schema without objects + * @returns A promise that is resolved with the result when the query completes. + */ + // @TODO Fix Promise + delete(): Promise; + + /** + * Deleting a Field to Update on a Schema + * @param name Name of the field + * @return Returns the schema, so you can chain this call. + */ + deleteField(name: string): this; + + /** + * Deleting a Index Field to Update on a Schema + * @param name Name of the index field + * @return Returns the schema, so you can chain this call. + */ + deleteIndex(name: string): this; + + /** + * Get the Schema from Parse + */ + get(): Promise; + + /** + * Removes all objects from a Schema (class) in EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed + */ + // TODO Fix Promise + purge(): Promise; + + /** + * Create a new Schema on Parse + */ + save(): Promise; + + /** + * Sets Class Level Permissions when creating / updating a Schema. + * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed + */ + setCLP(clp: Schema.CLP): this; + + /** + * Update a Schema on Parse + */ + update(): Promise; + } + + namespace Schema { + type TYPE = + | 'String' + | 'Number' + | 'Boolean' + | 'Date' + | 'File' + | 'GeoPoint' + | 'Polygon' + | 'Array' + | 'Object' + | 'Pointer' + | 'Relation'; + type FieldType = + | string + | number + | boolean + | Date + | File + | GeoPoint + | Polygon + | any[] + | object + | Pointer + | Relation; + type AttrType = Extract< + { [K in keyof T['attributes']]: T['attributes'][K] extends V ? K : never }[keyof T['attributes']], + string + >; + + interface FieldOptions< + T extends + | string + | number + | boolean + | Date + | File + | GeoPoint + | Polygon + | any[] + | object + | Pointer + | Relation = any, + > { + required?: boolean | undefined; + defaultValue?: T | undefined; + } + + interface Index { + [fieldName: string]: number | string; + } + + /** + * The id of a `_User` object or a role name prefixed by `'role:'`. + * @example + * '*': false, // public + * requiresAuthentication: false, + * 'role:Admin': true, + * 'idOfASpecificUser': true + */ + interface CLPField { + '*'?: boolean | undefined; + requiresAuthentication?: boolean | undefined; + /** `role:Admin` */ + [userIdOrRoleName: string]: boolean | undefined; + } + + interface CLP { + find?: CLPField | undefined; + get?: CLPField | undefined; + count?: CLPField | undefined; + create?: CLPField | undefined; + update?: CLPField | undefined; + delete?: CLPField | undefined; + addField?: CLPField | undefined; + /** Array of fields that point to a `_User` object's ID or a `Role` object's name */ + readUserFields?: string[] | undefined; + /** Array of fields that point to a `_User` object's ID or a `Role` object's name */ + writeUserFields?: string[] | undefined; + protectedFields?: { + /** '*', user id, or role: followed by a list of fields. */ + [userIdOrRoleName: string]: string[]; + }; + } + } + + namespace Analytics { + function track(name: string, dimensions: any): Promise; + } + + /** + * Provides utility functions for working with Anonymously logged-in users. + */ + namespace AnonymousUtils { + function isLinked(user: User): boolean; + function link(user: User, options?: ScopeOptions): Promise; + function logIn(options?: ScopeOptions): Promise; + } + + /** + * Provides a set of utilities for using Parse with Facebook. + * Provides a set of utilities for using Parse with Facebook. + */ + namespace FacebookUtils { + function init(options?: any): void; + function isLinked(user: User): boolean; + function link(user: User, permissions: any, options?: SuccessFailureOptions): void; + function logIn(permissions: any, options?: FullOptions): void; + function unlink(user: User, options?: SuccessFailureOptions): void; + } + + /** + * Contains functions for calling and declaring + * cloud functions. + *

        + * Some functions are only available from Cloud Code. + *

        + */ + namespace Cloud { + interface CookieOptions { + domain?: string | undefined; + expires?: Date | undefined; + httpOnly?: boolean | undefined; + maxAge?: number | undefined; + path?: string | undefined; + secure?: boolean | undefined; + } + + interface HttpResponse { + buffer?: Buffer | undefined; + cookies?: any; + data?: any; + headers?: any; + status?: number | undefined; + text?: string | undefined; + } + + interface JobRequest { + params: T; + message: (response: any) => void; + } + + interface Params { + [key: string]: any; + } + + interface FunctionRequest { + installationId?: string | undefined; + master?: boolean | undefined; + params: T; + user?: User | undefined; + } + + interface ValidatorField { + type?: any; + constant?: boolean | undefined; + default?: any; + options?: any[] | Function | undefined; + error?: String | undefined; + required?: boolean; + } + interface ValidatorFields { + [field: string]: ValidatorField; + } + interface Validator { + requireUser?: boolean | undefined; + requireMaster?: boolean | undefined; + validateMasterKey?: boolean | undefined; + skipWithMasterKey?: boolean | undefined; + requireAnyUserRoles?: String[] | Function | undefined; + requireAllUserRoles?: String[] | Function | undefined; + fields?: ValidatorFields | String[] | undefined; + requireUserKeys?: ValidatorFields | String[] | undefined; + } + + interface Cookie { + name?: string | undefined; + options?: CookieOptions | undefined; + value?: string | undefined; + } + + interface TriggerRequest { + installationId?: string | undefined; + master?: boolean | undefined; + user?: User | undefined; + ip: string; + headers: any; + triggerName: string; + log: any; + object: T; + original?: T | undefined; + } + + interface AfterSaveRequest extends TriggerRequest { + context: Record; + } + interface AfterDeleteRequest extends TriggerRequest {} // tslint:disable-line no-empty-interface + interface BeforeDeleteRequest extends TriggerRequest {} // tslint:disable-line no-empty-interface + interface BeforeSaveRequest extends TriggerRequest { + context: Record; + } + + interface FileTriggerRequest extends TriggerRequest { + file: File; + fileSize: number; + contentLength: number; + } + + // Read preference describes how MongoDB driver route read operations to the members of a replica set. + enum ReadPreferenceOption { + Primary = 'PRIMARY', + PrimaryPreferred = 'PRIMARY_PREFERRED', + Secondary = 'SECONDARY', + SecondaryPreferred = 'SECONDARY_PREFERRED', + Nearest = 'NEAREST', + } + + interface BeforeFindRequest extends TriggerRequest { + query: Query; + count: boolean; + isGet: boolean; + readPreference?: ReadPreferenceOption | undefined; + } + + interface AfterFindRequest extends TriggerRequest { + objects: T[]; + } + + function afterDelete( + arg1: { new (): T } | string, + func?: (request: AfterDeleteRequest) => Promise | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function afterSave( + arg1: { new (): T } | string, + func?: (request: AfterSaveRequest) => Promise | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function beforeDelete( + arg1: { new (): T } | string, + func?: (request: BeforeDeleteRequest) => Promise | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function beforeSave( + arg1: { new (): T } | string, + func?: (request: BeforeSaveRequest) => Promise | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function beforeFind( + arg1: { new (): T } | string, + func?: (request: BeforeFindRequest) => Promise> | Promise | Query | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function afterFind( + arg1: { new (): T } | string, + func?: (request: AfterFindRequest) => any, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + + function beforeLogin(func?: (request: TriggerRequest) => PromiseLike | void): void; + function afterLogin( + func?: (request: TriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function afterLogout( + func?: (request: TriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + + function beforeSaveFile( + func?: (request: FileTriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function afterSaveFile( + func?: (request: FileTriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function beforeDeleteFile( + func?: (request: FileTriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function afterDeleteFile( + func?: (request: FileTriggerRequest) => PromiseLike | void, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + + function define( + name: string, + func: (request: FunctionRequest) => any, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function define any>( + name: string, + func: (request: FunctionRequest<{}>) => Promise> | ReturnType, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + function define[0]]: Parameters[0][P] }) => any>( + name: string, + func: (request: FunctionRequest[0]>) => Promise> | ReturnType, + validator?: Validator | ((request: FunctionRequest) => any), + ): void; + /** + * Gets data for the current set of cloud jobs. + * @returns A promise that will be resolved with the result of the function. + */ + function getJobsData(): Promise; + /** + * Gets job status by Id + * @param jobStatusId The Id of Job Status. + * @returns Status of Job. + */ + function getJobStatus(jobStatusId: string): Promise; + function httpRequest(options: HTTPOptions): Promise; + function job(name: string, func?: (request: JobRequest) => Promise | void): HttpResponse; + function run(name: string, data?: Params, options?: RunOptions): Promise; + function run any>(name: string, data?: null, options?: RunOptions): Promise>; + function run[0]]: Parameters[0][P] }) => any>( + name: string, + data: Parameters[0], + options?: RunOptions, + ): Promise>; + /** + * Starts a given cloud job, which will process asynchronously. + * @param jobName The function name. + * @param data The parameters to send to the cloud function. + * @returns A promise that will be resolved with the jobStatusId of the job. + */ + function startJob(jobName: string, data: any): Promise; + function useMasterKey(): void; + + interface RunOptions extends SuccessFailureOptions, ScopeOptions {} + + /** + * To use this Cloud Module in Cloud Code, you must require 'buffer' in your JavaScript file. + * + * import Buffer = require("buffer").Buffer; + */ + let HTTPOptions: new () => HTTPOptions; + interface HTTPOptions { + /** + * The body of the request. + * If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. + * You can also set this to a Buffer object to send raw bytes. + * If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. + */ + body?: string | Buffer | object | undefined; + /** + * Defaults to 'false'. + */ + followRedirects?: boolean | undefined; + /** + * The headers for the request. + */ + headers?: + | { + [headerName: string]: string | number | boolean; + } + | undefined; + /** + * The method of the request (i.e GET, POST, etc). + */ + method?: string | undefined; + /** + * The query portion of the url. + */ + params?: any; + /** + * The url to send the request to. + */ + url: string; + + success?: ((response: any) => void) | undefined; + error?: ((response: any) => void) | undefined; + } + } + + namespace EventuallyQueue { + interface QueueObject { + queueId: string; + action: string; + object: Object; + serverOptions: Object.SaveOptions | RequestOptions; + id: string; + className: string; + hash: string; + createdAt: Date; + } + type Queue = QueueObject[]; + /** + * Add object to queue with save operation. + * + * @param object Parse.Object to be saved eventually + * @param serverOptions See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options. + * @returns A promise that is fulfilled if object is added to queue. + * @see Parse.Object#saveEventually + */ + function save(object: Object, serverOptions?: Object.SaveOptions): Promise; + /** + * Add object to queue with save operation. + * + * @param object Parse.Object to be destroyed eventually + * @param serverOptions See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options + * @returns A promise that is fulfilled if object is added to queue. + * @see Parse.Object#destroyEventually + */ + function destroy(object: Object, serverOptions?: RequestOptions): Promise; + // function store(data: any): Promise; + // function load(): Promise; + /** + * Sets the in-memory queue from local storage and returns. + */ + function getQueue(): Promise; + /** + * Removes all objects from queue. + * @returns A promise that is fulfilled when queue is cleared. + */ + function clear(): Promise; + /** + * Return the number of objects in the queue. + */ + function length(): Promise; + /** + * Sends the queue to the server. + * @returns Returns true if queue was sent successfully. + */ + function sendQueue(): Promise; + /** + * Start polling server for network connection. + * Will send queue if connection is established. + * + * @param [ms] Milliseconds to ping the server. Default 2000ms + */ + function poll(ms?: number): void; + /** + * Turns off polling. + */ + function stopPoll(): void; + /** + * Return true if pinging the server. + */ + function isPolling(): boolean; + } + + class Error { + static OTHER_CAUSE: ErrorCode.OTHER_CAUSE; + static INTERNAL_SERVER_ERROR: ErrorCode.INTERNAL_SERVER_ERROR; + static CONNECTION_FAILED: ErrorCode.CONNECTION_FAILED; + static OBJECT_NOT_FOUND: ErrorCode.OBJECT_NOT_FOUND; + static INVALID_QUERY: ErrorCode.INVALID_QUERY; + static INVALID_CLASS_NAME: ErrorCode.INVALID_CLASS_NAME; + static MISSING_OBJECT_ID: ErrorCode.MISSING_OBJECT_ID; + static INVALID_KEY_NAME: ErrorCode.INVALID_KEY_NAME; + static INVALID_POINTER: ErrorCode.INVALID_POINTER; + static INVALID_JSON: ErrorCode.INVALID_JSON; + static COMMAND_UNAVAILABLE: ErrorCode.COMMAND_UNAVAILABLE; + static NOT_INITIALIZED: ErrorCode.NOT_INITIALIZED; + static INCORRECT_TYPE: ErrorCode.INCORRECT_TYPE; + static INVALID_CHANNEL_NAME: ErrorCode.INVALID_CHANNEL_NAME; + static PUSH_MISCONFIGURED: ErrorCode.PUSH_MISCONFIGURED; + static OBJECT_TOO_LARGE: ErrorCode.OBJECT_TOO_LARGE; + static OPERATION_FORBIDDEN: ErrorCode.OPERATION_FORBIDDEN; + static CACHE_MISS: ErrorCode.CACHE_MISS; + static INVALID_NESTED_KEY: ErrorCode.INVALID_NESTED_KEY; + static INVALID_FILE_NAME: ErrorCode.INVALID_FILE_NAME; + static INVALID_ACL: ErrorCode.INVALID_ACL; + static TIMEOUT: ErrorCode.TIMEOUT; + static INVALID_EMAIL_ADDRESS: ErrorCode.INVALID_EMAIL_ADDRESS; + static MISSING_CONTENT_TYPE: ErrorCode.MISSING_CONTENT_TYPE; + static MISSING_CONTENT_LENGTH: ErrorCode.MISSING_CONTENT_LENGTH; + static INVALID_CONTENT_LENGTH: ErrorCode.INVALID_CONTENT_LENGTH; + static FILE_TOO_LARGE: ErrorCode.FILE_TOO_LARGE; + static FILE_SAVE_ERROR: ErrorCode.FILE_SAVE_ERROR; + static DUPLICATE_VALUE: ErrorCode.DUPLICATE_VALUE; + static INVALID_ROLE_NAME: ErrorCode.INVALID_ROLE_NAME; + static EXCEEDED_QUOTA: ErrorCode.EXCEEDED_QUOTA; + static SCRIPT_FAILED: ErrorCode.SCRIPT_FAILED; + static VALIDATION_ERROR: ErrorCode.VALIDATION_ERROR; + static INVALID_IMAGE_DATA: ErrorCode.INVALID_IMAGE_DATA; + static UNSAVED_FILE_ERROR: ErrorCode.UNSAVED_FILE_ERROR; + static INVALID_PUSH_TIME_ERROR: ErrorCode.INVALID_PUSH_TIME_ERROR; + static FILE_DELETE_ERROR: ErrorCode.FILE_DELETE_ERROR; + static REQUEST_LIMIT_EXCEEDED: ErrorCode.REQUEST_LIMIT_EXCEEDED; + static INVALID_EVENT_NAME: ErrorCode.INVALID_EVENT_NAME; + static USERNAME_MISSING: ErrorCode.USERNAME_MISSING; + static PASSWORD_MISSING: ErrorCode.PASSWORD_MISSING; + static USERNAME_TAKEN: ErrorCode.USERNAME_TAKEN; + static EMAIL_TAKEN: ErrorCode.EMAIL_TAKEN; + static EMAIL_MISSING: ErrorCode.EMAIL_MISSING; + static EMAIL_NOT_FOUND: ErrorCode.EMAIL_NOT_FOUND; + static SESSION_MISSING: ErrorCode.SESSION_MISSING; + static MUST_CREATE_USER_THROUGH_SIGNUP: ErrorCode.MUST_CREATE_USER_THROUGH_SIGNUP; + static ACCOUNT_ALREADY_LINKED: ErrorCode.ACCOUNT_ALREADY_LINKED; + static INVALID_SESSION_TOKEN: ErrorCode.INVALID_SESSION_TOKEN; + static LINKED_ID_MISSING: ErrorCode.LINKED_ID_MISSING; + static INVALID_LINKED_SESSION: ErrorCode.INVALID_LINKED_SESSION; + static UNSUPPORTED_SERVICE: ErrorCode.UNSUPPORTED_SERVICE; + static AGGREGATE_ERROR: ErrorCode.AGGREGATE_ERROR; + static FILE_READ_ERROR: ErrorCode.FILE_READ_ERROR; + static X_DOMAIN_REQUEST: ErrorCode.X_DOMAIN_REQUEST; + + code: ErrorCode; + message: string; + + constructor(code: ErrorCode, message: string); + } + + /** + * A Parse.Op is an atomic operation that can be applied to a field in a + * Parse.Object. For example, calling object.set("foo", "bar") + * is an example of a Parse.Op.Set. Calling object.unset("foo") + * is a Parse.Op.Unset. These operations are stored in a Parse.Object and + * sent to the server as part of object.save() operations. + * Instances of Parse.Op should be immutable. + * + * You should not create subclasses of Parse.Op or instantiate Parse.Op + * directly. + */ + namespace Op { + interface BaseOperation { + objects(): any[]; + } + + interface Add extends BaseOperation { + toJSON(): any; + } + + interface AddUnique extends BaseOperation { + toJSON(): any; + } + + interface Increment { + amount: number; + toJSON(): any; + } + + interface Relation { + added(): Object[]; + removed: Object[]; + toJSON(): any; + } + + interface Set { + value(): any; + toJSON(): any; + } + + interface Unset { + toJSON(): any; + } + } + + /** + * Contains functions to deal with Push in Parse + */ + namespace Push { + function send(data: PushData, options?: SendOptions): Promise; + + interface PushData { + channels?: string[] | undefined; + push_time?: Date | undefined; + expiration_time?: Date | undefined; + expiration_interval?: number | undefined; + where?: Query | undefined; + data?: any; + alert?: string | undefined; + badge?: string | undefined; + sound?: string | undefined; + title?: string | undefined; + notification?: any; + content_available?: any; + } + + interface SendOptions extends UseMasterKeyOption { + success?: (() => void) | undefined; + error?: ((error: Error) => void) | undefined; + } + } + + /** + * Call this method first to set up your authentication tokens for Parse. + * You can get your keys from the Data Browser on parse.com. + * @param applicationId Your Parse Application ID. + * @param javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) + * @param masterKey (optional) Your Parse Master Key. (Node.js only!) + */ + function initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void; + + /** + * Use this to set custom headers + * The headers will be sent with every parse request + */ + namespace CoreManager { + function set(key: string, value: any): void; + function get(key: string): void; + } + + /** + * Additionally on React-Native / Expo environments, add AsyncStorage from 'react-native' package + * @param AsyncStorage AsyncStorage from 'react-native' package + */ + function setAsyncStorage(AsyncStorage: any): void; + + /** + * Gets all contents from Local Datastore. + */ + function dumpLocalDatastore(): Promise<{ [key: string]: any }>; + + /** + * Enable pinning in your application. + * This must be called before your application can use pinning. + */ + function enableLocalDatastore(): void; + + /** + * Flag that indicates whether Local Datastore is enabled. + */ + function isLocalDatastoreEnabled(): boolean; + + function setLocalDatastoreController(controller: any): void; + + /** + * Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} + * @param controller a data storage. + */ + function setLocalDatastoreController(controller: any): void; + + /** + * Enable the current user encryption. + * This must be called before login any user. + */ + function enableEncryptedUser(): void; + + /** + * Flag that indicates whether Encrypted User is enabled. + */ + function isEncryptedUserEnabled(): boolean; + } +} + +export = Parse; diff --git a/types/tests.ts b/types/tests.ts index 67a9e9dd9..2c21634ff 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -1,300 +1,315 @@ -import Parse from './Parse'; -// Parse is a global type, but it can also be imported +import ParseSession from './ParseSession'; -class GameScore extends Parse.Object { - constructor(options?: any) { - super('GameScore', options); - } -} +function testSession() { + function testConstructor() { + // $ExpectType ParseSession + new ParseSession(); + + // $ExpectType ParseSession + new ParseSession({ example: 100 }); + + // @ts-expect-error + new ParseSession<{ example: number }>(); -class Game extends Parse.Object { - constructor(options?: any) { - super('Game', options); + // @ts-expect-error + new ParseSession<{ example: number }>({ example: 'hello' }); } } -function test_config() { - Parse.Config.save({ foo: 'bar' }, { foo: true }); - Parse.Config.get({ useMasterKey: true }); -} +// class GameScore extends ParseObject { +// constructor(options?: any) { +// super('GameScore', options); +// } +// } -function test_object() { - const game = new Game(); - game.save(null, { - useMasterKey: true, - sessionToken: 'sometoken', - cascadeSave: false, - }).then(result => result); +// class Game extends ParseObject { +// constructor(options?: any) { +// super('Game', options); +// } +// } - if (!game.isNew()) { +// function test_config() { +// Parse.Config.save({ foo: 'bar' }, { foo: true }); +// Parse.Config.get({ useMasterKey: true }); +// } - } +// function test_object() { +// const game = new Game(); +// game.save(null, { +// useMasterKey: true, +// sessionToken: 'sometoken', +// cascadeSave: false, +// }).then(result => result); - if (game.toPointer().className !== 'Game') { +// if (!game.isNew()) { - } +// } - game.fetch({}); +// if (game.toPointer().className !== 'Game') { - // Create a new instance of that class. - const gameScore = new GameScore(); +// } - gameScore.set('score', 1337); - gameScore.set('playerName', 'Sean Plott'); - gameScore.set('cheatMode', false); +// game.fetch({}); - // Setting attrs using object - gameScore.set({ - level: '10', - difficult: 15, - }); +// // Create a new instance of that class. +// const gameScore = new GameScore(); - const score = gameScore.get('score'); - const playerName = gameScore.get('playerName'); - const cheatMode = gameScore.get('cheatMode'); +// gameScore.set('score', 1337); +// gameScore.set('playerName', 'Sean Plott'); +// gameScore.set('cheatMode', false); - gameScore.increment('score'); - gameScore.addUnique('skills', 'flying'); - gameScore.addUnique('skills', 'kungfu'); - gameScore.addAll('skills', ['kungfu']); - gameScore.addAllUnique('skills', ['kungfu']); - gameScore.remove('skills', 'flying'); - gameScore.removeAll('skills', ['kungFu']); - game.set('gameScore', gameScore); +// // Setting attrs using object +// gameScore.set({ +// level: '10', +// difficult: 15, +// }); - const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); +// const score = gameScore.get('score'); +// const playerName = gameScore.get('playerName'); +// const cheatMode = gameScore.get('cheatMode'); - const object = new Parse.Object('TestObject'); - object.equals(gameScore); - object.fetchWithInclude(['key1', 'key2']); -} +// gameScore.increment('score'); +// gameScore.addUnique('skills', 'flying'); +// gameScore.addUnique('skills', 'kungfu'); +// gameScore.addAll('skills', ['kungfu']); +// gameScore.addAllUnique('skills', ['kungfu']); +// gameScore.remove('skills', 'flying'); +// gameScore.removeAll('skills', ['kungFu']); +// game.set('gameScore', gameScore); -function test_errors() { - try { - throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); - } catch (error) { - if (error.code !== 1) { +// const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); - } - } -} +// const object = new ParseObject('TestObject'); +// object.equals(gameScore); +// object.fetchWithInclude(['key1', 'key2']); +// } -function test_query() { - const gameScore = new GameScore(); - - const query = new Parse.Query(GameScore); - query.equalTo('playerName', 'Dan Stemkoski'); - query.notEqualTo('playerName', 'Michael Yabuti'); - query.fullText('playerName', 'dan', { language: 'en', caseSensitive: false, diacriticSensitive: true }); - query.greaterThan('playerAge', 18); - query.eachBatch(objs => Promise.resolve(), { batchSize: 10 }); - query.each(score => Promise.resolve()); - query.hint('_id_'); - query.explain(true); - query.limit(10); - query.skip(10); - - // Sorts the results in ascending order by the score field - query.ascending('score'); - - // Sorts the results in descending order by the score field - query.descending('score'); - - // Restricts to wins < 50 - query.lessThan('wins', 50); - - // Restricts to wins <= 50 - query.lessThanOrEqualTo('wins', 50); - - // Restricts to wins > 50 - query.greaterThan('wins', 50); - - // Restricts to wins >= 50 - query.greaterThanOrEqualTo('wins', 50); - - query.containedBy('place', ['1', '2']); - // Finds scores from any of Jonathan, Dario, or Shawn - query.containedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); - - // Finds scores from anyone who is neither Jonathan, Dario, nor Shawn - query.notContainedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); - - // Finds objects that have the score set - query.exists('score'); - - // Finds objects that don't have the score set - query.doesNotExist('score'); - query.matchesKeyInQuery('hometown', 'city', query); - query.doesNotMatchKeyInQuery('hometown', 'city', query); - query.select('score', 'playerName'); - - // Find objects where the array in arrayKey contains 2. - query.equalTo('arrayKey', 2); - - // Find objects where the array in arrayKey contains all of the elements 2, 3, and 4. - query.containsAll('arrayKey', [2, 3, 4]); - query.containsAllStartingWith('arrayKey', ['2', '3', '4']); - - query.startsWith('name', "Big Daddy's"); - query.equalTo('score', gameScore); - query.exists('score'); - query.include('score'); - query.include(['score.team']); - query.includeAll(); - query.sortByTextScore(); - // Find objects that match the aggregation pipeline - query.aggregate({ - group: { - objectId: '$name', - }, - }); - - query.aggregate({ - count: 'total', - }); - - query.aggregate({ - lookup: { - from: 'Collection', - foreignField: 'id', - localField: 'id', - as: 'result', - }, - }); - query.aggregate({ - lookup: { - from: 'Target', - let: { foo: 'bar', baz: 123 }, - pipeline: [], - as: 'result', - }, - }); - - query.aggregate({ - graphLookup: { - from: 'Target', - connectFromField: 'objectId', - connectToField: 'newId', - as: 'result', - }, - }); - - query.aggregate({ - facet: { - foo: [ - { - count: 'total', - }, - ], - bar: [ - { - group: { - objectId: '$name', - }, - }, - ], - }, - }); - - query.aggregate({ - unwind: '$field', - }); - - query.aggregate({ - unwind: { - path: '$field', - includeArrayIndex: 'newIndex', - preserveNullAndEmptyArrays: true, - }, - }); - - // Find objects with distinct key - query.distinct('name'); - - const testQuery = Parse.Query.or(query, query); -} +// function test_errors() { +// try { +// throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); +// } catch (error) { +// if (error.code !== 1) { -function test_query_exclude() { - const gameScore = new GameScore(); +// } +// } +// } - const query = new Parse.Query(GameScore); +// function test_query() { +// const gameScore = new GameScore(); + +// const query = new Parse.Query(GameScore); +// query.equalTo('playerName', 'Dan Stemkoski'); +// query.notEqualTo('playerName', 'Michael Yabuti'); +// query.fullText('playerName', 'dan', { language: 'en', caseSensitive: false, diacriticSensitive: true }); +// query.greaterThan('playerAge', 18); +// query.eachBatch(objs => Promise.resolve(), { batchSize: 10 }); +// query.each(score => Promise.resolve()); +// query.hint('_id_'); +// query.explain(true); +// query.limit(10); +// query.skip(10); - // Show all keys, except the specified key. - query.exclude('place'); +// // Sorts the results in ascending order by the score field +// query.ascending('score'); - const testQuery = Parse.Query.or(query, query); -} +// // Sorts the results in descending order by the score field +// query.descending('score'); -async function test_query_promise() { - // Test promise with a query - const findQuery = new Parse.Query('Test'); - findQuery - .find() - .then(() => { - // success - }) - .catch(() => { - // error - }); - - const getQuery = new Parse.Query('Test'); - try { - await getQuery.get('objectId'); - } catch (error) { - // noop - } +// // Restricts to wins < 50 +// query.lessThan('wins', 50); - await getQuery.map((score, index) => score.increment('score', index)); - await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0); - await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0, { batchSize: 200 }); - await getQuery.filter(scores => scores.get('score') > 0); - await getQuery.filter(scores => scores.get('score') > 0, { batchSize: 10 }); -} +// // Restricts to wins <= 50 +// query.lessThanOrEqualTo('wins', 50); -async function test_live_query() { - const subscription = await new Parse.Query('Test').subscribe(); - subscription.on('close', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('create', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('delete', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('enter', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('leave', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('open', object => { - // $ExpectType ParseObject - object; - }); - subscription.on('update', object => { - // $ExpectType ParseObject - object; - }); -} +// // Restricts to wins > 50 +// query.greaterThan('wins', 50); -function test_anonymous_utils() { - // $ExpectType boolean - Parse.AnonymousUtils.isLinked(new Parse.User()); - // $ExpectType Promise - Parse.AnonymousUtils.link(new Parse.User(), { useMasterKey: true, sessionToken: '' }); - // $ExpectType Promise - Parse.AnonymousUtils.logIn({ useMasterKey: true, sessionToken: '' }); -} +// // Restricts to wins >= 50 +// query.greaterThanOrEqualTo('wins', 50); -function return_a_query(): Parse.Query { - return new Parse.Query(Game); -} +// query.containedBy('place', ['1', '2']); +// // Finds scores from any of Jonathan, Dario, or Shawn +// query.containedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); + +// // Finds scores from anyone who is neither Jonathan, Dario, nor Shawn +// query.notContainedIn('playerName', ['Jonathan Walsh', 'Dario Wunsch', 'Shawn Simon']); + +// // Finds objects that have the score set +// query.exists('score'); + +// // Finds objects that don't have the score set +// query.doesNotExist('score'); +// query.matchesKeyInQuery('hometown', 'city', query); +// query.doesNotMatchKeyInQuery('hometown', 'city', query); +// query.select('score', 'playerName'); + +// // Find objects where the array in arrayKey contains 2. +// query.equalTo('arrayKey', 2); + +// // Find objects where the array in arrayKey contains all of the elements 2, 3, and 4. +// query.containsAll('arrayKey', [2, 3, 4]); +// query.containsAllStartingWith('arrayKey', ['2', '3', '4']); + +// query.startsWith('name', "Big Daddy's"); +// query.equalTo('score', gameScore); +// query.exists('score'); +// query.include('score'); +// query.include(['score.team']); +// query.includeAll(); +// query.sortByTextScore(); +// // Find objects that match the aggregation pipeline +// query.aggregate({ +// group: { +// objectId: '$name', +// }, +// }); + +// query.aggregate({ +// count: 'total', +// }); + +// query.aggregate({ +// lookup: { +// from: 'Collection', +// foreignField: 'id', +// localField: 'id', +// as: 'result', +// }, +// }); +// query.aggregate({ +// lookup: { +// from: 'Target', +// let: { foo: 'bar', baz: 123 }, +// pipeline: [], +// as: 'result', +// }, +// }); + +// query.aggregate({ +// graphLookup: { +// from: 'Target', +// connectFromField: 'objectId', +// connectToField: 'newId', +// as: 'result', +// }, +// }); + +// query.aggregate({ +// facet: { +// foo: [ +// { +// count: 'total', +// }, +// ], +// bar: [ +// { +// group: { +// objectId: '$name', +// }, +// }, +// ], +// }, +// }); + +// query.aggregate({ +// unwind: '$field', +// }); + +// query.aggregate({ +// unwind: { +// path: '$field', +// includeArrayIndex: 'newIndex', +// preserveNullAndEmptyArrays: true, +// }, +// }); + +// // Find objects with distinct key +// query.distinct('name'); + +// const testQuery = Parse.Query.or(query, query); +// } + +// function test_query_exclude() { +// const gameScore = new GameScore(); + +// const query = new Parse.Query(GameScore); + +// // Show all keys, except the specified key. +// query.exclude('place'); + +// const testQuery = Parse.Query.or(query, query); +// } + +// async function test_query_promise() { +// // Test promise with a query +// const findQuery = new Parse.Query('Test'); +// findQuery +// .find() +// .then(() => { +// // success +// }) +// .catch(() => { +// // error +// }); + +// const getQuery = new Parse.Query('Test'); +// try { +// await getQuery.get('objectId'); +// } catch (error) { +// // noop +// } + +// await getQuery.map((score, index) => score.increment('score', index)); +// await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0); +// await getQuery.reduce((accum, score, index) => (accum += score.get('score')), 0, { batchSize: 200 }); +// await getQuery.filter(scores => scores.get('score') > 0); +// await getQuery.filter(scores => scores.get('score') > 0, { batchSize: 10 }); +// } + +// async function test_live_query() { +// const subscription = await new Parse.Query('Test').subscribe(); +// subscription.on('close', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('create', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('delete', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('enter', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('leave', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('open', object => { +// // $ExpectType ParseObject +// object; +// }); +// subscription.on('update', object => { +// // $ExpectType ParseObject +// object; +// }); +// } + +// function test_anonymous_utils() { +// // $ExpectType boolean +// Parse.AnonymousUtils.isLinked(new Parse.User()); +// // $ExpectType Promise +// Parse.AnonymousUtils.link(new Parse.User(), { useMasterKey: true, sessionToken: '' }); +// // $ExpectType Promise +// Parse.AnonymousUtils.logIn({ useMasterKey: true, sessionToken: '' }); +// } + +// function return_a_query(): Parse.Query { +// return new Parse.Query(Game); +// } // function test_each() { // new Parse.Query(Game).each(game => { @@ -2053,22 +2068,6 @@ function return_a_query(): Parse.Query { // } // } -// function testSession() { -// function testConstructor() { -// // $ExpectType Session -// new Parse.Session(); - -// // $ExpectType Session<{ example: number; }> -// new Parse.Session({ example: 100 }); - -// // @ts-expect-error -// new Parse.Session<{ example: number }>(); - -// // @ts-expect-error -// new Parse.Session<{ example: number }>({ example: 'hello' }); -// } -// } - // function testUser() { // function testConstructor() { // // $ExpectType User From dd1b43973a54affc464f53b2ff866f69cb618568 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Fri, 28 Jul 2023 18:44:30 -0500 Subject: [PATCH 04/13] convert Parse module to TS --- src/{Parse.js => Parse.ts} | 0 tsconfig.json | 1 + 2 files changed, 1 insertion(+) rename src/{Parse.js => Parse.ts} (100%) diff --git a/src/Parse.js b/src/Parse.ts similarity index 100% rename from src/Parse.js rename to src/Parse.ts diff --git a/tsconfig.json b/tsconfig.json index 8ef8fd0f5..617ff3c4e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "allowJs": false }, "files": [ + "src/Parse.ts", "src/ParseSession.ts" ] } \ No newline at end of file From 455a1b6a092d5902d60137bfd594a4837f3d2105 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Fri, 28 Jul 2023 19:06:25 -0500 Subject: [PATCH 05/13] add no check --- tsconfig.json | 2 +- types/Cloud.d.ts | 1 + types/FacebookUtils.d.ts | 1 + types/LiveQueryClient.d.ts | 1 + types/ParseConfig.d.ts | 1 + types/ParseFile.d.ts | 1 + types/ParseInstallation.d.ts | 1 + types/ParsePolygon.d.ts | 2 ++ types/ParseSchema.d.ts | 1 + types/Push.d.ts | 1 + 10 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 617ff3c4e..051477c29 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,4 +12,4 @@ "src/Parse.ts", "src/ParseSession.ts" ] -} \ No newline at end of file +} diff --git a/types/Cloud.d.ts b/types/Cloud.d.ts index e47654fb3..7af0228fc 100644 --- a/types/Cloud.d.ts +++ b/types/Cloud.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Contains functions for calling and declaring * cloud functions. diff --git a/types/FacebookUtils.d.ts b/types/FacebookUtils.d.ts index 02ba4d614..bef770ab7 100644 --- a/types/FacebookUtils.d.ts +++ b/types/FacebookUtils.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default FacebookUtils; declare namespace FacebookUtils { /** diff --git a/types/LiveQueryClient.d.ts b/types/LiveQueryClient.d.ts index 1b464b7c9..dc42292da 100644 --- a/types/LiveQueryClient.d.ts +++ b/types/LiveQueryClient.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default LiveQueryClient; /** * Creates a new LiveQueryClient. diff --git a/types/ParseConfig.d.ts b/types/ParseConfig.d.ts index c51436666..757f71f83 100644 --- a/types/ParseConfig.d.ts +++ b/types/ParseConfig.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default ParseConfig; /** * Parse.Config is a local representation of configuration data that diff --git a/types/ParseFile.d.ts b/types/ParseFile.d.ts index 78d5becbd..704384901 100644 --- a/types/ParseFile.d.ts +++ b/types/ParseFile.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck type FileSource = { format: "file"; file: Blob; diff --git a/types/ParseInstallation.d.ts b/types/ParseInstallation.d.ts index b0c07e2df..2a512fc6b 100644 --- a/types/ParseInstallation.d.ts +++ b/types/ParseInstallation.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default class Installation extends ParseObject { constructor(attributes: AttributeMap | null); } diff --git a/types/ParsePolygon.d.ts b/types/ParsePolygon.d.ts index e838e8744..d94d63f7f 100644 --- a/types/ParsePolygon.d.ts +++ b/types/ParsePolygon.d.ts @@ -1,3 +1,5 @@ +// @ts-nocheck + export default ParsePolygon; /** * Creates a new Polygon with any of the following forms:
        diff --git a/types/ParseSchema.d.ts b/types/ParseSchema.d.ts index e71cc362b..708070fc9 100644 --- a/types/ParseSchema.d.ts +++ b/types/ParseSchema.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default ParseSchema; /** * A Parse.Schema object is for handling schema data from Parse. diff --git a/types/Push.d.ts b/types/Push.d.ts index 5b402a633..3108e0d24 100644 --- a/types/Push.d.ts +++ b/types/Push.d.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /** * Contains functions to deal with Push in Parse. * From 75cf216db33341f4ae2676413c340e38384a1e80 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Mon, 31 Jul 2023 11:53:24 -0500 Subject: [PATCH 06/13] switch tests to integration --- src/CoreManager.js | 5 +- src/EventuallyQueue.js | 1 + src/LocalDatastore.js | 1 + src/Storage.js | 1 + types/CoreManager.d.ts | 185 ++++++++++++++++++++++++++++++++++++- types/EventuallyQueue.d.ts | 172 +++++++++++++++++++++++++++++++++- types/LocalDatastore.d.ts | 37 +++++++- types/ParseObject.d.ts | 2 +- types/Storage.d.ts | 15 ++- types/tests.ts | 41 ++++---- 10 files changed, 434 insertions(+), 26 deletions(-) diff --git a/src/CoreManager.js b/src/CoreManager.js index a751dd468..73228c6d3 100644 --- a/src/CoreManager.js +++ b/src/CoreManager.js @@ -204,7 +204,7 @@ function requireMethods(name: string, methods: Array, controller: any) { }); } -module.exports = { +const CoreManager = { get: function (key: string): any { if (config.hasOwnProperty(key)) { return config[key]; @@ -468,3 +468,6 @@ module.exports = { return config['HooksController']; }, }; + +module.exports = CoreManager; +export default CoreManager; diff --git a/src/EventuallyQueue.js b/src/EventuallyQueue.js index 8925fda42..03dc82ce8 100644 --- a/src/EventuallyQueue.js +++ b/src/EventuallyQueue.js @@ -373,3 +373,4 @@ const EventuallyQueue = { }; module.exports = EventuallyQueue; +export default EventuallyQueue; diff --git a/src/LocalDatastore.js b/src/LocalDatastore.js index 259e12d44..bf552d09d 100644 --- a/src/LocalDatastore.js +++ b/src/LocalDatastore.js @@ -392,6 +392,7 @@ const LocalDatastore = { }; module.exports = LocalDatastore; +export default LocalDatastore; if (process.env.PARSE_BUILD === 'react-native') { CoreManager.setLocalDatastoreController(require('./LocalDatastoreController.react-native')); diff --git a/src/Storage.js b/src/Storage.js index 232e3000b..67392c249 100644 --- a/src/Storage.js +++ b/src/Storage.js @@ -96,6 +96,7 @@ const Storage = { }; module.exports = Storage; +export default Storage; if (process.env.PARSE_BUILD === 'react-native') { CoreManager.setStorageController(require('./StorageController.react-native')); diff --git a/types/CoreManager.d.ts b/types/CoreManager.d.ts index cb0ff5c3b..c7a350aa4 100644 --- a/types/CoreManager.d.ts +++ b/types/CoreManager.d.ts @@ -1 +1,184 @@ -export {}; +// @ts-nocheck +export default CoreManager; +declare namespace CoreManager { + function get(key: string): any; + function set(key: string, value: any): void; + function setAnalyticsController(controller: AnalyticsController): void; + function getAnalyticsController(): AnalyticsController; + function setCloudController(controller: CloudController): void; + function getCloudController(): CloudController; + function setConfigController(controller: ConfigController): void; + function getConfigController(): ConfigController; + function setCryptoController(controller: CryptoController): void; + function getCryptoController(): CryptoController; + function setFileController(controller: FileController): void; + function getFileController(): FileController; + function setInstallationController(controller: InstallationController): void; + function getInstallationController(): InstallationController; + function setObjectController(controller: ObjectController): void; + function getObjectController(): ObjectController; + function setObjectStateController(controller: ObjectStateController): void; + function getObjectStateController(): ObjectStateController; + function setPushController(controller: PushController): void; + function getPushController(): PushController; + function setQueryController(controller: QueryController): void; + function getQueryController(): QueryController; + function setRESTController(controller: RESTController): void; + function getRESTController(): RESTController; + function setSchemaController(controller: SchemaController): void; + function getSchemaController(): SchemaController; + function setSessionController(controller: SessionController): void; + function getSessionController(): SessionController; + function setStorageController(controller: StorageController): void; + function setLocalDatastoreController(controller: LocalDatastoreController): void; + function getLocalDatastoreController(): LocalDatastoreController; + function setLocalDatastore(store: any): void; + function getLocalDatastore(): mixed; + function getStorageController(): StorageController; + function setAsyncStorage(storage: any): void; + function getAsyncStorage(): mixed; + function setWebSocketController(controller: WebSocketController): void; + function getWebSocketController(): WebSocketController; + function setUserController(controller: UserController): void; + function getUserController(): UserController; + function setLiveQueryController(controller: any): void; + function getLiveQueryController(): any; + function setHooksController(controller: HooksController): void; + function getHooksController(): HooksController; +} +type AnalyticsController = { + track: (name: string, dimensions: { + [key: string]: string; + }) => Promise; +}; +type CloudController = { + run: (name: string, data: mixed, options: RequestOptions) => Promise; + getJobsData: (options: RequestOptions) => Promise; + startJob: (name: string, data: mixed, options: RequestOptions) => Promise; +}; +type ConfigController = { + current: () => Promise; + get: () => Promise; + save: (attrs: { + [key: string]: any; + }) => Promise; +}; +type CryptoController = { + encrypt: (obj: any, secretKey: string) => string; + decrypt: (encryptedText: string, secretKey: any) => string; +}; +type FileController = { + saveFile: (name: string, source: FileSource, options: FullOptions) => Promise; + saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise; + download: (uri: string) => Promise; +}; +type InstallationController = { + currentInstallationId: () => Promise; +}; +type ObjectController = { + fetch: (object: ParseObject | ParseObject[], forceFetch: boolean, options: RequestOptions) => Promise; + save: (object: ParseObject | (ParseFile | ParseObject)[], options: RequestOptions) => Promise; + destroy: (object: ParseObject | ParseObject[], options: RequestOptions) => Promise; +}; +type ObjectStateController = { + getState: (obj: any) => State; + initializeState: (obj: any, initial?: State) => State; + removeState: (obj: any) => State; + getServerData: (obj: any) => AttributeMap; + setServerData: (obj: any, attributes: AttributeMap) => void; + getPendingOps: (obj: any) => OpsMap[]; + setPendingOp: (obj: any, attr: string, op: Op) => void; + pushPendingState: (obj: any) => void; + popPendingState: (obj: any) => OpsMap; + mergeFirstPendingState: (obj: any) => void; + getObjectCache: (obj: any) => ObjectCache; + estimateAttribute: (obj: any, attr: string) => mixed; + estimateAttributes: (obj: any) => AttributeMap; + commitServerChanges: (obj: any, changes: AttributeMap) => void; + enqueueTask: (obj: any, task: () => Promise) => Promise; + clearAllState: () => void; + duplicateState: (source: any, dest: any) => void; +}; +type PushController = { + send: (data: PushData) => Promise; +}; +type QueryController = { + find: (className: string, params: QueryJSON, options: RequestOptions) => Promise; + aggregate: (className: string, params: any, options: RequestOptions) => Promise; +}; +type RESTController = { + request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise; + ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise; +}; +type SchemaController = { + purge: (className: string) => Promise; + get: (className: string, options: RequestOptions) => Promise; + delete: (className: string, options: RequestOptions) => Promise; + create: (className: string, params: any, options: RequestOptions) => Promise; + update: (className: string, params: any, options: RequestOptions) => Promise; + send(className: string, method: string, params: any, options: RequestOptions): Promise; +}; +type SessionController = { + getSession: (token: RequestOptions) => Promise; +}; +type StorageController = { + async: 0; + getItem: (path: string) => string; + setItem: (path: string, value: string) => void; + removeItem: (path: string) => void; + getItemAsync?: (path: string) => Promise; + setItemAsync?: (path: string, value: string) => Promise; + removeItemAsync?: (path: string) => Promise; + clear: () => void; +} | { + async: 1; + getItem?: (path: string) => string; + setItem?: (path: string, value: string) => void; + removeItem?: (path: string) => void; + getItemAsync: (path: string) => Promise; + setItemAsync: (path: string, value: string) => Promise; + removeItemAsync: (path: string) => Promise; + clear: () => void; +}; +type LocalDatastoreController = { + fromPinWithName: (name: string) => any; + pinWithName: (name: string, objects: any) => void; + unPinWithName: (name: string) => void; + getAllContents: () => any; + clear: () => void; +}; +type WebSocketController = { + onopen: () => void; + onmessage: (message: any) => void; + onclose: () => void; + onerror: (error: any) => void; + send: (data: any) => void; + close: () => void; +}; +type UserController = { + setCurrentUser: (user: ParseUser) => Promise; + currentUser: () => ParseUser; + currentUserAsync: () => Promise; + signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise; + logIn: (user: ParseUser, options: RequestOptions) => Promise; + become: (options: RequestOptions) => Promise; + hydrate: (userJSON: AttributeMap) => Promise; + logOut: (options: RequestOptions) => Promise; + me: (options: RequestOptions) => Promise; + requestPasswordReset: (email: string, options: RequestOptions) => Promise; + updateUserOnDisk: (user: ParseUser) => Promise; + upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise; + linkWith: (user: ParseUser, authData: { + [key: string]: mixed; + }) => Promise; + removeUserFromDisk: () => Promise; + verifyPassword: (username: string, password: string, options: RequestOptions) => Promise; + requestEmailVerification: (email: string, options: RequestOptions) => Promise; +}; +type HooksController = { + get: (type: string, functionName?: string, triggerName?: string) => Promise; + create: (hook: mixed) => Promise; + delete: (hook: mixed) => Promise; + update: (hook: mixed) => Promise; + send: (method: string, path: string, body?: mixed) => Promise; +}; diff --git a/types/EventuallyQueue.d.ts b/types/EventuallyQueue.d.ts index cb0ff5c3b..61694cfa0 100644 --- a/types/EventuallyQueue.d.ts +++ b/types/EventuallyQueue.d.ts @@ -1 +1,171 @@ -export {}; +export default EventuallyQueue; +declare namespace EventuallyQueue { + /** + * Add object to queue with save operation. + * + * @function save + * @name Parse.EventuallyQueue.save + * @param {ParseObject} object Parse.Object to be saved eventually + * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options. + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @see Parse.Object#saveEventually + */ + function save(object: ParseObject, serverOptions?: SaveOptions): Promise; + /** + * Add object to queue with save operation. + * + * @function destroy + * @name Parse.EventuallyQueue.destroy + * @param {ParseObject} object Parse.Object to be destroyed eventually + * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @see Parse.Object#destroyEventually + */ + function destroy(object: ParseObject, serverOptions?: RequestOptions): Promise; + /** + * Generate unique identifier to avoid duplicates and maintain previous state. + * + * @param {string} action save / destroy + * @param {object} object Parse.Object to be queued + * @returns {string} + * @static + * @ignore + */ + function generateQueueId(action: string, object: ParseObject): string; + /** + * Build queue object and add to queue. + * + * @param {string} action save / destroy + * @param {object} object Parse.Object to be queued + * @param {object} [serverOptions] + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @ignore + */ + function enqueue(action: string, object: ParseObject, serverOptions?: RequestOptions | SaveOptions): Promise; + function store(data: any): Promise; + function load(): Promise; + /** + * Sets the in-memory queue from local storage and returns. + * + * @function getQueue + * @name Parse.EventuallyQueue.getQueue + * @returns {Promise} + * @static + */ + function getQueue(): Promise; + /** + * Saves the queue to local storage + * + * @param {Queue} queue Queue containing Parse.Object data. + * @returns {Promise} A promise that is fulfilled when queue is stored. + * @static + * @ignore + */ + function setQueue(queue: Queue): Promise; + /** + * Removes Parse.Object data from queue. + * + * @param {string} queueId Unique identifier for Parse.Object data. + * @returns {Promise} A promise that is fulfilled when queue is stored. + * @static + * @ignore + */ + function remove(queueId: string): Promise; + /** + * Removes all objects from queue. + * + * @function clear + * @name Parse.EventuallyQueue.clear + * @returns {Promise} A promise that is fulfilled when queue is cleared. + * @static + */ + function clear(): Promise; + /** + * Return the index of a queueId in the queue. Returns -1 if not found. + * + * @param {Queue} queue Queue containing Parse.Object data. + * @param {string} queueId Unique identifier for Parse.Object data. + * @returns {number} + * @static + * @ignore + */ + function queueItemExists(queue: Queue, queueId: string): number; + /** + * Return the number of objects in the queue. + * + * @function length + * @name Parse.EventuallyQueue.length + * @returns {number} + * @static + */ + function length(): number; + /** + * Sends the queue to the server. + * + * @function sendQueue + * @name Parse.EventuallyQueue.sendQueue + * @returns {Promise} Returns true if queue was sent successfully. + * @static + */ + function sendQueue(): Promise; + /** + * Build queue object and add to queue. + * + * @param {ParseObject} object Parse.Object to be processed + * @param {QueueObject} queueObject Parse.Object data from the queue + * @returns {Promise} A promise that is fulfilled when operation is performed. + * @static + * @ignore + */ + function sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise; + /** + * Start polling server for network connection. + * Will send queue if connection is established. + * + * @function poll + * @name Parse.EventuallyQueue.poll + * @param [ms] Milliseconds to ping the server. Default 2000ms + * @static + */ + function poll(ms?: number): void; + /** + * Turns off polling. + * + * @function stopPoll + * @name Parse.EventuallyQueue.stopPoll + * @static + */ + function stopPoll(): void; + /** + * Return true if pinging the server. + * + * @function isPolling + * @name Parse.EventuallyQueue.isPolling + * @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; +}; diff --git a/types/LocalDatastore.d.ts b/types/LocalDatastore.d.ts index cb0ff5c3b..c8f461765 100644 --- a/types/LocalDatastore.d.ts +++ b/types/LocalDatastore.d.ts @@ -1 +1,36 @@ -export {}; +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; + /** + * Updates Local Datastore from Server + * + *
        +     * await Parse.LocalDatastore.updateFromServer();
        +     * 
        + * + * @function updateFromServer + * @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'; diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index 096cb4d6e..09eb14634 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -4,7 +4,7 @@ type Pointer = { className: string; objectId: string; }; -type SaveOptions = FullOptions & { +export type SaveOptions = FullOptions & { cascadeSave?: boolean; context?: AttributeMap; }; diff --git a/types/Storage.d.ts b/types/Storage.d.ts index cb0ff5c3b..5b82a620a 100644 --- a/types/Storage.d.ts +++ b/types/Storage.d.ts @@ -1 +1,14 @@ -export {}; +export default Storage; +declare namespace Storage { + function async(): boolean; + function getItem(path: string): string; + function getItemAsync(path: string): Promise; + function setItem(path: string, value: string): void; + function setItemAsync(path: string, value: string): Promise; + function removeItem(path: string): void; + function removeItemAsync(path: string): Promise; + function getAllKeys(): string[]; + function getAllKeysAsync(): Promise; + function generatePath(path: string): string; + function _clear(): void; +} diff --git a/types/tests.ts b/types/tests.ts index 2c21634ff..a275584e9 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -1,28 +1,13 @@ -import ParseSession from './ParseSession'; +import Parse from './Parse'; +// Parse is a global type, but it can also be imported -function testSession() { - function testConstructor() { - // $ExpectType ParseSession - new ParseSession(); - - // $ExpectType ParseSession - new ParseSession({ example: 100 }); - - // @ts-expect-error - new ParseSession<{ example: number }>(); - - // @ts-expect-error - new ParseSession<{ example: number }>({ example: 'hello' }); - } -} - -// class GameScore extends ParseObject { +// class GameScore extends Parse.Object { // constructor(options?: any) { // super('GameScore', options); // } // } -// class Game extends ParseObject { +// class Game extends Parse.Object { // constructor(options?: any) { // super('Game', options); // } @@ -79,7 +64,7 @@ function testSession() { // const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); -// const object = new ParseObject('TestObject'); +// const object = new Parse.Object('TestObject'); // object.equals(gameScore); // object.fetchWithInclude(['key1', 'key2']); // } @@ -2068,6 +2053,22 @@ function testSession() { // } // } +function testSession() { + function testConstructor() { + // $ExpectType ParseSession + new Parse.Session(); + + // $ExpectType ParseSession + new Parse.Session({ example: 100 }); + + // @ts-expect-error + new Parse.Session<{ example: number }>(); + + // @ts-expect-error + new Parse.Session<{ example: number }>({ example: 'hello' }); + } +} + // function testUser() { // function testConstructor() { // // $ExpectType User From 4ea5508ff38270a2c36ec3e2c7ddd8ecc096592f Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sat, 5 Aug 2023 12:54:52 -0500 Subject: [PATCH 07/13] support for node and react-native types --- types/index.d.ts | 6 ++++++ types/node.d.ts | 5 +++-- types/react-native.d.ts | 5 +++-- types/tslint.json | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index b28624bc2..e29762502 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,9 @@ +// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b23a36e669fa127d1035e22ca93faab85b98e49f/types/parse/index.d.ts#L11 +// Possibly add @types/node module reference types + +/// +/// + import { EventEmitter } from 'events'; declare enum ErrorCode { diff --git a/types/node.d.ts b/types/node.d.ts index 0b96f9ed9..d4bbf2ccf 100644 --- a/types/node.d.ts +++ b/types/node.d.ts @@ -1,2 +1,3 @@ -import parse from "./Parse"; -export default parse; \ No newline at end of file +import * as parse from "./index"; + +export = parse; diff --git a/types/react-native.d.ts b/types/react-native.d.ts index 0b96f9ed9..d4bbf2ccf 100644 --- a/types/react-native.d.ts +++ b/types/react-native.d.ts @@ -1,2 +1,3 @@ -import parse from "./Parse"; -export default parse; \ No newline at end of file +import * as parse from "./index"; + +export = parse; diff --git a/types/tslint.json b/types/tslint.json index 776df04be..e5fa37117 100644 --- a/types/tslint.json +++ b/types/tslint.json @@ -7,4 +7,4 @@ "no-redundant-jsdoc": false, "strict-export-declare-modifiers": false } -} \ No newline at end of file +} From 9a4b9b49721d26836d2ed53d8f2b7695f7a6bd90 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 6 Aug 2023 10:24:21 -0500 Subject: [PATCH 08/13] Remove DT --- package.json | 3 +- types/index.d.ts | 2010 +--------------------------------------------- 2 files changed, 4 insertions(+), 2009 deletions(-) diff --git a/package.json b/package.json index 9b6ceda07..45c06dd47 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,7 @@ "lib/", "LICENSE", "NOTICE", - "README.md", - "types/index.d.ts" + "README.md" ], "browser": { "react-native": false diff --git a/types/index.d.ts b/types/index.d.ts index e29762502..ee5eb1233 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,2012 +1,8 @@ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b23a36e669fa127d1035e22ca93faab85b98e49f/types/parse/index.d.ts#L11 -// Possibly add @types/node module reference types +// TODO(dplewis): Possibly add @types/node module reference types /// /// -import { EventEmitter } from 'events'; - -declare enum ErrorCode { - /** Error code indicating some error other than those enumerated here */ - OTHER_CAUSE = -1, - /** Error code indicating that something has gone wrong with the server. */ - INTERNAL_SERVER_ERROR = 1, - /** Error code indicating the connection to the Parse servers failed. */ - CONNECTION_FAILED = 100, - /** Error code indicating the specified object doesn't exist. */ - 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. - */ - 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. - */ - INVALID_CLASS_NAME = 103, - /** Error code indicating an unspecified object id. */ - 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. - */ - 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. - */ - 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. - */ - INVALID_JSON = 107, - /** - * Error code indicating that the feature you tried to access is only - * available internally for testing purposes. - */ - COMMAND_UNAVAILABLE = 108, - /** You must call Parse.initialize before using the Parse library. */ - NOT_INITIALIZED = 109, - /** Error code indicating that a field was set to an inconsistent type. */ - 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. - */ - INVALID_CHANNEL_NAME = 112, - /** Error code indicating that push is misconfigured. */ - PUSH_MISCONFIGURED = 115, - /** Error code indicating that the object is too large. */ - OBJECT_TOO_LARGE = 116, - /** Error code indicating that the operation isn't allowed for clients. */ - OPERATION_FORBIDDEN = 119, - /** Error code indicating the result was not found in the cache. */ - CACHE_MISS = 120, - /** Error code indicating that an invalid key was used in a nested JSONObject. */ - 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. - */ - INVALID_FILE_NAME = 122, - /** Error code indicating an invalid ACL was provided. */ - 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. - */ - TIMEOUT = 124, - /** Error code indicating that the email address was invalid. */ - INVALID_EMAIL_ADDRESS = 125, - /** Error code indicating a missing content type. */ - MISSING_CONTENT_TYPE = 126, - /** Error code indicating a missing content length. */ - MISSING_CONTENT_LENGTH = 127, - /** Error code indicating an invalid content length. */ - INVALID_CONTENT_LENGTH = 128, - /** Error code indicating a file that was too large. */ - FILE_TOO_LARGE = 129, - /** Error code indicating an error saving a file. */ - FILE_SAVE_ERROR = 130, - /** - * Error code indicating that a unique field was given a value that is - * already taken. - */ - DUPLICATE_VALUE = 137, - /** Error code indicating that a role's name is invalid. */ - INVALID_ROLE_NAME = 139, - /** - * Error code indicating that an application quota was exceeded. - * Upgrade to resolve. - */ - EXCEEDED_QUOTA = 140, - /** Error code indicating that a Cloud Code script failed. */ - SCRIPT_FAILED = 141, - /** Error code indicating that a Cloud Code validation failed. */ - VALIDATION_ERROR = 142, - /** Error code indicating that invalid image data was provided. */ - INVALID_IMAGE_DATA = 150, - /** Error code indicating an unsaved file. */ - UNSAVED_FILE_ERROR = 151, - /** Error code indicating an invalid push time. */ - INVALID_PUSH_TIME_ERROR = 152, - /** Error code indicating an error deleting a file. */ - FILE_DELETE_ERROR = 153, - /** Error code indicating that the application has exceeded its request limit. */ - REQUEST_LIMIT_EXCEEDED = 155, - /** - * Error code indicating that the request was a duplicate and has been discarded due to - * idempotency rules. - */ - DUPLICATE_REQUEST = 159, - /** Error code indicating an invalid event name. */ - INVALID_EVENT_NAME = 160, - /** Error code indicating an error deleting an unnamed file. */ - FILE_DELETE_UNNAMED_ERROR = 161, - /** Error code indicating that the username is missing or empty. */ - USERNAME_MISSING = 200, - /** Error code indicating that the password is missing or empty. */ - PASSWORD_MISSING = 201, - /** Error code indicating that the username has already been taken. */ - USERNAME_TAKEN = 202, - /** Error code indicating that the email has already been taken. */ - EMAIL_TAKEN = 203, - /** Error code indicating that the email is missing, but must be specified. */ - EMAIL_MISSING = 204, - /** Error code indicating that a user with the specified email was not found. */ - EMAIL_NOT_FOUND = 205, - /** - * Error code indicating that a user object without a valid session could - * not be altered. - */ - SESSION_MISSING = 206, - /** Error code indicating that a user can only be created through signup. */ - MUST_CREATE_USER_THROUGH_SIGNUP = 207, - /** - * Error code indicating that an an account being linked is already linked - * to another user. - */ - ACCOUNT_ALREADY_LINKED = 208, - /** Error code indicating that the current session token is invalid. */ - INVALID_SESSION_TOKEN = 209, - /** Error code indicating an error enabling or verifying MFA */ - MFA_ERROR = 210, - /** Error code indicating that a valid MFA token must be provided */ - 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. - */ - LINKED_ID_MISSING = 250, - /** - * Error code indicating that a user with a linked (e.g. Facebook) account - * has an invalid session. - */ - INVALID_LINKED_SESSION = 251, - /** - * Error code indicating that a service being linked (e.g. Facebook or - * Twitter) is unsupported. - */ - UNSUPPORTED_SERVICE = 252, - /** Error code indicating an invalid operation occured on schema */ - 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. - */ - AGGREGATE_ERROR = 600, - /** Error code indicating the client was unable to read an input file. */ - 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. - */ - X_DOMAIN_REQUEST = 602, -} - -declare global { - namespace Parse { - let applicationId: string; - let javaScriptKey: string | undefined; - let liveQueryServerURL: string; - let masterKey: string | undefined; - let serverAuthToken: string | undefined; - let serverAuthType: string | undefined; - let serverURL: string; - let secret: string; - let idempotency: boolean; - let encryptedUser: boolean; - - interface BatchSizeOption { - batchSize?: number | undefined; - } - - interface CascadeSaveOption { - /** If `false`, nested objects will not be saved (default is `true`). */ - cascadeSave?: boolean | undefined; - } - - interface SuccessOption { - success?: Function | undefined; - } - - interface ErrorOption { - error?: Function | undefined; - } - - interface ContextOption { - context?: { [key: string]: any }; - } - - interface FullOptions { - success?: Function | undefined; - error?: Function | undefined; - useMasterKey?: boolean | undefined; - sessionToken?: string | undefined; - installationId?: string | undefined; - progress?: Function | undefined; - /** - * logIn will default to POST instead of GET method since - * version 3.0.0 for security reasons. - * If you need to use GET set this to `false`. - */ - usePost?: boolean; - } - - interface RequestOptions { - useMasterKey?: boolean | undefined; - sessionToken?: string | undefined; - installationId?: string | undefined; - batchSize?: number | undefined; - include?: string | string[] | undefined; - progress?: Function | undefined; - } - - interface SuccessFailureOptions extends SuccessOption, ErrorOption {} - - interface SignUpOptions { - useMasterKey?: boolean | undefined; - installationId?: string | undefined; - } - - interface SessionTokenOption { - sessionToken?: string | undefined; - } - - interface WaitOption { - /** - * Set to true to wait for the server to confirm success - * before triggering an event. - */ - wait?: boolean | undefined; - } - - interface UseMasterKeyOption { - /** - * In Cloud Code and Node only, causes the Master Key to be used for this request. - */ - useMasterKey?: boolean | undefined; - } - - /** - * https://github.com/parse-community/Parse-SDK-JS/pull/1294/files - * feat: Add option to return raw json from queries - */ - interface RawJSONOptions { - /** (3.0.0+) json: Return raw json without converting to Parse.Object */ - json?: boolean; - } - interface ScopeOptions extends SessionTokenOption, UseMasterKeyOption {} - - interface SilentOption { - /** - * Set to true to avoid firing the event. - */ - silent?: boolean | undefined; - } - - interface Pointer { - __type: string; - className: string; - objectId: string; - } - - interface AuthData { - [key: string]: any; - } - - /** - * Interface declaration for Authentication Providers - * https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html - */ - interface AuthProvider { - /** - * Called when _linkWith isn't passed authData. Handle your own authentication here. - */ - authenticate: () => void; - /** - * (Optional) Called when service is unlinked. Handle any cleanup here. - */ - deauthenticate?: (() => void) | undefined; - /** - * Unique identifier for this Auth Provider. - */ - getAuthType: () => string; - /** - * Called when auth data is syncronized. Can be used to determine if authData is still valid - */ - restoreAuthentication: () => boolean; - } - - interface BaseAttributes { - createdAt: Date; - objectId: string; - updatedAt: Date; - } - - interface CommonAttributes { - ACL: ACL; - } - - interface JSONBaseAttributes { - createdAt: string; - objectId: string; - updatedAt: string; - } - - /** - * Creates a new ACL. - * If no argument is given, the ACL has no permissions for anyone. - * If the argument is a Parse.User, the ACL will have read and write - * permission for only that user. - * If the argument is any other JSON object, that object will be interpretted - * as a serialized ACL created with toJSON(). - * @see Parse.Object#setACL - * - *

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

        - */ - class ACL { - permissionsById: any; - - constructor(arg1?: any); - - setPublicReadAccess(allowed: boolean): void; - getPublicReadAccess(): boolean; - - setPublicWriteAccess(allowed: boolean): void; - getPublicWriteAccess(): boolean; - - setReadAccess(userId: User | string, allowed: boolean): void; - getReadAccess(userId: User | string): boolean; - - setWriteAccess(userId: User | string, allowed: boolean): void; - getWriteAccess(userId: User | string): boolean; - - setRoleReadAccess(role: Role | string, allowed: boolean): void; - getRoleReadAccess(role: Role | string): boolean; - - setRoleWriteAccess(role: Role | string, allowed: boolean): void; - getRoleWriteAccess(role: Role | string): boolean; - - toJSON(): any; - } - - /** - * A Parse.File is a local representation of a file that is saved to the Parse - * cloud. - * @param name The file's name. This will be prefixed by a unique - * value once the file has finished saving. The file name must begin with - * an alphanumeric character, and consist of alphanumeric characters, - * periods, spaces, underscores, or dashes. - * @param data The data for the file, as either: - * 1. an Array of byte value Numbers, or - * 2. an Object like { base64: "..." } with a base64-encoded String. - * 3. a File object selected with a file upload control. (3) only works - * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+. - * For example:
        -         * var fileUploadControl = $("#profilePhotoFileUpload")[0];
        -         * if (fileUploadControl.files.length > 0) {
        -         *   var file = fileUploadControl.files[0];
        -         *   var name = "photo.jpg";
        -         *   var parseFile = new Parse.File(name, file);
        -         *   parseFile.save().then(function() {
        -         *     // The file has been saved to Parse.
        -         *   }, function(error) {
        -         *     // The file either could not be read, or could not be saved to Parse.
        -         *   });
        -         * }
        - * @param type Optional Content-Type header to use for the file. If - * this is omitted, the content type will be inferred from the name's - * extension. - */ - class File { - constructor( - name: string, - data: number[] | { base64: string } | { size: number; type: string } | { uri: string }, - type?: string, - ); - /** - * 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. - * Data is cleared if saved with File object selected with a file upload control - * - * @returns Promise that is resolved with base64 data - */ - getData(): Promise; - url(options?: { forceSecure?: boolean | undefined }): string; - metadata(): Record; - tags(): Record; - name(): string; - save(options?: FullOptions): Promise; - cancel(): void; - destroy(options?: FullOptions): Promise; - toJSON(): { __type: string; name: string; url: string }; - equals(other: File): boolean; - setMetadata(metadata: Record): void; - addMetadata(key: string, value: any): void; - setTags(tags: Record): void; - addTag(key: string, value: any): void; - readonly _url: string; - } - - /** - * Creates a new GeoPoint with any of the following forms:
        - *
        -         *   new GeoPoint(otherGeoPoint)
        -         *   new GeoPoint(30, 30)
        -         *   new GeoPoint([30, 30])
        -         *   new GeoPoint({latitude: 30, longitude: 30})
        -         *   new GeoPoint()  // defaults to (0, 0)
        -         *   
        - * - *

        Represents a latitude / longitude point that may be associated - * with a key in a ParseObject or used as a reference point for geo queries. - * This allows proximity-based queries on the key.

        - * - *

        Only one key in a class may contain a GeoPoint.

        - * - *

        Example:

        -         *   var point = new Parse.GeoPoint(30.0, -20.0);
        -         *   var object = new Parse.Object("PlaceObject");
        -         *   object.set("location", point);
        -         *   object.save();

        - */ - class GeoPoint { - latitude: number; - longitude: number; - - constructor(latitude: number, longitude: number); - constructor(coords?: { latitude: number; longitude: number } | [number, number]); - - current(options?: SuccessFailureOptions): GeoPoint; - radiansTo(point: GeoPoint): number; - kilometersTo(point: GeoPoint): number; - milesTo(point: GeoPoint): number; - toJSON(): any; - } - - /** - * A class that is used to access all of the children of a many-to-many relationship. - * Each instance of Parse.Relation is associated with a particular parent object and key. - */ - class Relation { - parent: S; - key: string; - targetClassName: string; - - constructor(parent?: S, key?: string); - - // Adds a Parse.Object or an array of Parse.Objects to the relation. - add(object: T | T[]): void; - - // Returns a Parse.Query that is limited to objects in this relation. - query(): Query; - - // Removes a Parse.Object or an array of Parse.Objects from this relation. - remove(object: T | T[]): void; - - toJSON(): any; - } - - interface Attributes { - [key: string]: any; - } - - /** - * Creates a new model with defined attributes. A client id (cid) is - * automatically generated and assigned for you. - * - *

        You won't normally call this method directly. It is recommended that - * you use a subclass of Parse.Object instead, created by calling - * extend.

        - * - *

        However, if you don't want to use a subclass, or aren't sure which - * subclass is appropriate, you can use this form:

        -         *     var object = new Parse.Object("ClassName");
        -         * 
        - * That is basically equivalent to:
        -         *     var MyClass = Parse.Object.extend("ClassName");
        -         *     var object = new MyClass();
        -         * 

        - * - * @param attributes The initial set of data to store in the object. - * @param options The options for this object instance. - * @see Parse.Object.extend - * - * - * Creates a new model with defined attributes. - */ - interface Object { - id: string; - createdAt: Date; - updatedAt: Date; - attributes: T; - className: string; - - add extends any[] ? K : never }[keyof T]>( - attr: K, - item: NonNullable[number], - ): this | false; - addAll extends any[] ? K : never }[keyof T]>( - attr: K, - items: NonNullable, - ): this | false; - addAllUnique: this['addAll']; - addUnique: this['add']; - clear(options: any): any; - clone(): this; - destroy(options?: Object.DestroyOptions): Promise; - /** EventuallyQueue API; added in version 3.0.0 */ - destroyEventually(options?: Object.DestroyOptions): Promise; - dirty(attr?: Extract): boolean; - dirtyKeys(): string[]; - equals(other: T): boolean; - escape(attr: Extract): string; - existed(): boolean; - exists(options?: RequestOptions): Promise; - fetch(options?: Object.FetchOptions): Promise; - fetchFromLocalDatastore(): Promise; - fetchWithInclude>( - keys: K | Array, - options?: RequestOptions, - ): Promise; - get>(attr: K): T[K]; - getACL(): ACL | undefined; - has(attr: Extract): boolean; - increment(attr: Extract, amount?: number): this | false; - decrement(attr: Extract, amount?: number): this | false; - initialize(): void; - isDataAvailable(): boolean; - isNew(): boolean; - isPinned(): Promise; - isValid(): boolean; - newInstance(): this; - op(attr: Extract): any; - pin(): Promise; - pinWithName(name: string): Promise; - relation = Extract>( - attr: T[K] extends Relation ? K : never, - ): Relation; - remove: this['add']; - removeAll: this['addAll']; - revert(...keys: Array>): void; - // "Pick | T" is a trick to keep IntelliSense working, see: - // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3bdadbf9583c2335197c7e999b9a30880e055f62/types/react/index.d.ts#L482 - save>( - attrs?: Pick | T | null, - options?: Object.SaveOptions, - ): Promise; - save>( - key: K, - value: T[K] extends undefined ? never : T[K], - options?: Object.SaveOptions, - ): Promise; - /** EventuallyQueue API; added in version 3.0.0 */ - saveEventually(options?: Object.SaveOptions): Promise; - set>(attrs: Pick | T, options?: Object.SetOptions): this | false; - set>( - key: K, - value: T[K] extends undefined ? never : T[K], - options?: Object.SetOptions, - ): this | false; - setACL(acl: ACL, options?: SuccessFailureOptions): this | false; - toJSON(): Object.ToJSON & JSONBaseAttributes; - toPointer(): Pointer; - unPin(): Promise; - unPinWithName(name: string): Promise; - unset(attr: Extract, options?: any): this | false; - validate(attrs: Attributes, options?: SuccessFailureOptions): Error | false; - } - interface ObjectStatic { - createWithoutData(id: string): T; - destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; - extend(className: string | { className: string }, protoProps?: any, classProps?: any): any; - fetchAll(list: T[], options: Object.FetchAllOptions): Promise; - fetchAllIfNeeded(list: T[], options?: Object.FetchAllOptions): Promise; - fetchAllIfNeededWithInclude( - list: T[], - keys: keyof T['attributes'] | Array, - options?: RequestOptions, - ): Promise; - fetchAllWithInclude( - list: T[], - keys: keyof T['attributes'] | Array, - options?: RequestOptions, - ): Promise; - fromJSON(json: any, override?: boolean): T; - pinAll(objects: Object[]): Promise; - pinAllWithName(name: string, objects: Object[]): Promise; - registerSubclass(className: string, clazz: new (options?: any) => T): void; - saveAll(list: T, options?: Object.SaveAllOptions): Promise; - unPinAll(objects: Object[]): Promise; - unPinAllObjects(): Promise; - unPinAllObjectsWithName(name: string): Promise; - unPinAllWithName(name: string, objects: Object[]): Promise; - } - interface ObjectConstructor extends ObjectStatic { - new (className: string, attributes: T, options?: any): Object; - new (className?: string, attributes?: Attributes, options?: any): Object; - } - const Object: ObjectConstructor; - - namespace Object { - interface DestroyOptions extends SuccessFailureOptions, WaitOption, ScopeOptions {} - - interface DestroyAllOptions extends BatchSizeOption, ScopeOptions {} - - interface FetchAllOptions extends SuccessFailureOptions, ScopeOptions {} - - interface FetchOptions extends SuccessFailureOptions, ScopeOptions {} - - interface SaveOptions - extends CascadeSaveOption, - SuccessFailureOptions, - SilentOption, - ScopeOptions, - ContextOption, - WaitOption {} - - interface SaveAllOptions extends BatchSizeOption, ScopeOptions {} - - interface SetOptions extends ErrorOption, SilentOption { - promise?: any; - } - - // From https://github.com/parse-community/Parse-SDK-JS/blob/master/src/encode.js - type Encode = T extends Object - ? ReturnType | Pointer - : T extends ACL | GeoPoint | Polygon | Relation | File - ? ReturnType - : T extends Date - ? { __type: 'Date'; iso: string } - : T extends RegExp - ? string - : T extends Array - ? // This recursion is unsupported in <=3.6 - Array> - : T extends object - ? ToJSON - : T; - - type ToJSON = { - [K in keyof T]: Encode; - }; - } - - class Polygon { - constructor(arg1: GeoPoint[] | number[][]); - containsPoint(point: GeoPoint): boolean; - equals(other: any): boolean; - toJSON(): any; - } - - /** - * Every Parse application installed on a device registered for - * push notifications has an associated Installation object. - */ - interface Installation extends Object { - badge: any; - channels: string[]; - timeZone: any; - deviceType: string; - pushType: string; - installationId: string; - deviceToken: string; - channelUris: string; - appName: string; - appVersion: string; - parseVersion: string; - appIdentifier: string; - } - interface InstallationConstructor extends ObjectStatic { - new (attributes: T): Installation; - new (): Installation; - } - const Installation: InstallationConstructor; - - /** - * Creates a new parse Parse.Query for the given Parse.Object subclass. - * @param objectClass - - * An instance of a subclass of Parse.Object, or a Parse className string. - * - *

        Parse.Query defines a query that is used to fetch Parse.Objects. The - * most common use case is finding all objects that match a query through the - * find method. For example, this sample code fetches all objects - * of class MyClass. It calls a different function depending on - * whether the fetch succeeded or not. - * - *

        -         * var query = new Parse.Query(MyClass);
        -         * query.find({
        -         *   success: function(results) {
        -         *     // results is an array of Parse.Object.
        -         *   },
        -         *
        -         *   error: function(error) {
        -         *     // error is an instance of Parse.Error.
        -         *   }
        -         * });

        - * - *

        A Parse.Query can also be used to retrieve a single object whose id is - * known, through the get method. For example, this sample code fetches an - * object of class MyClass and id myId. It calls a - * different function depending on whether the fetch succeeded or not. - * - *

        -         * var query = new Parse.Query(MyClass);
        -         * query.get(myId, {
        -         *   success: function(object) {
        -         *     // object is an instance of Parse.Object.
        -         *   },
        -         *
        -         *   error: function(object, error) {
        -         *     // error is an instance of Parse.Error.
        -         *   }
        -         * });

        - * - *

        A Parse.Query can also be used to count the number of objects that match - * the query without retrieving all of those objects. For example, this - * sample code counts the number of objects of the class MyClass - *

        -         * var query = new Parse.Query(MyClass);
        -         * query.count({
        -         *   success: function(number) {
        -         *     // There are number instances of MyClass.
        -         *   },
        -         *
        -         *   error: function(error) {
        -         *     // error is an instance of Parse.Error.
        -         *   }
        -         * });

        - */ - class Query { - objectClass: any; - className: string; - - constructor(objectClass: string | (new (...args: any[]) => T | Object)); - - static and(...args: Array>): Query; - static fromJSON(className: string | (new () => U), json: any): Query; - static nor(...args: Array>): Query; - static or(...var_args: Array>): Query; - - addAscending(key: K | K[]): this; - addDescending(key: K | K[]): this; - ascending(key: K | K[]): this; - aggregate(pipeline: Query.AggregationOptions | Query.AggregationOptions[]): Promise; - containedBy( - key: K, - values: Array, - ): this; - containedIn( - key: K, - values: Array, - ): this; - contains(key: K, substring: string): this; - containsAll(key: K, values: any[]): this; - containsAllStartingWith( - key: K, - values: any[], - ): this; - count(options?: Query.CountOptions): Promise; - descending(key: K | K[]): this; - doesNotExist(key: K): this; - doesNotMatchKeyInQuery< - U extends Object, - K extends keyof T['attributes'] | keyof BaseAttributes, - X extends Extract, - >(key: K, queryKey: X, query: Query): this; - doesNotMatchQuery(key: K, query: Query): this; - distinct(key: K): Promise; - eachBatch(callback: (objs: T[]) => PromiseLike | void, options?: Query.BatchOptions): Promise; - each(callback: (obj: T) => PromiseLike | void, options?: Query.BatchOptions): Promise; - hint(value: string | object): this; - explain(explain: boolean): this; - map( - callback: (currentObject: T, index: number, query: Query) => PromiseLike | U, - options?: Query.BatchOptions, - ): Promise; - reduce( - callback: (accumulator: T, currentObject: T, index: number) => PromiseLike | T, - initialValue?: undefined, - options?: Query.BatchOptions, - ): Promise; - reduce( - callback: (accumulator: U, currentObject: T, index: number) => PromiseLike | U, - initialValue: U, - options?: Query.BatchOptions, - ): Promise; - filter( - callback: (currentObject: T, index: number, query: Query) => PromiseLike | boolean, - options?: Query.BatchOptions, - ): Promise; - endsWith(key: K, suffix: string): this; - equalTo( - key: K, - value: - | T['attributes'][K] - | (T['attributes'][K] extends Object - ? Pointer - : T['attributes'][K] extends Array - ? E - : never), - ): this; - exclude(...keys: K[]): this; - exists(key: K): this; - find(options?: Query.FindOptions): Promise; - findAll(options?: Query.BatchOptions): Promise; - first(options?: Query.FirstOptions): Promise; - fromNetwork(): this; - fromLocalDatastore(): this; - fromPin(): this; - fromPinWithName(name: string): this; - cancel(): this; - fullText( - key: K, - value: string, - options?: Query.FullTextOptions, - ): this; - get(objectId: string, options?: Query.GetOptions): Promise; - greaterThan( - key: K, - value: T['attributes'][K], - ): this; - greaterThanOrEqualTo( - key: K, - value: T['attributes'][K], - ): this; - include(...key: K[]): this; - include(key: K[]): this; - includeAll(): Query; - lessThan(key: K, value: T['attributes'][K]): this; - lessThanOrEqualTo( - key: K, - value: T['attributes'][K], - ): this; - limit(n: number): Query; - matches( - key: K, - regex: RegExp, - modifiers?: string, - ): this; - matchesKeyInQuery< - U extends Object, - K extends keyof T['attributes'], - X extends Extract, - >(key: K, queryKey: X, query: Query): this; - matchesQuery(key: K, query: Query): this; - near(key: K, point: GeoPoint): this; - notContainedIn( - key: K, - values: Array, - ): this; - notEqualTo( - key: K, - value: - | T['attributes'][K] - | (T['attributes'][K] extends Object - ? Pointer - : T['attributes'][K] extends Array - ? E - : never), - ): this; - polygonContains(key: K, point: GeoPoint): this; - select(...keys: K[]): this; - select(keys: K[]): this; - skip(n: number): Query; - sortByTextScore(): this; - startsWith(key: K, prefix: string): this; - subscribe(sessionToken?: string): Promise; - toJSON(): any; - withJSON(json: any): this; - withCount(includeCount?: boolean): this; - withinGeoBox( - key: K, - southwest: GeoPoint, - northeast: GeoPoint, - ): this; - withinKilometers( - key: K, - point: GeoPoint, - maxDistance: number, - sorted?: boolean, - ): this; - withinMiles( - key: K, - point: GeoPoint, - maxDistance: number, - sorted?: boolean, - ): this; - withinPolygon(key: K, points: number[][]): this; - withinRadians( - key: K, - point: GeoPoint, - maxDistance: number, - ): this; - } - - namespace Query { - interface EachOptions extends SuccessFailureOptions, ScopeOptions {} - interface CountOptions extends SuccessFailureOptions, ScopeOptions {} - interface FindOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} - interface FirstOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} - interface GetOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {} - - // According to http://docs.parseplatform.org/rest/guide/#aggregate-queries - interface AggregationOptions { - group?: (Record & { objectId?: string }) | undefined; - match?: Record | undefined; - project?: Record | undefined; - limit?: number | undefined; - skip?: number | undefined; - // Sort documentation https://docs.mongodb.com/v3.2/reference/operator/aggregation/sort/#pipe._S_sort - sort?: Record | undefined; - // Sample documentation: https://docs.mongodb.com/v3.2/reference/operator/aggregation/sample/ - sample?: { size: number } | undefined; - // Count documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/count/ - count?: string | undefined; - // Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/ - lookup?: - | { - from: string; - localField: string; - foreignField: string; - as: string; - } - | { - from: string; - let?: Record; - pipeline: Record; - as: string; - } - | undefined; - // Graph Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/ - graphLookup?: - | { - from: string; - startWith?: string; - connectFromField: string; - connectToField: string; - as: string; - maxDepth?: number; - depthField?: string; - restrictSearchWithMatch?: Record; - } - | undefined; - // Facet documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/facet/ - facet?: Record>> | undefined; - // Unwind documentation: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/ - unwind?: - | { - path: string; - includeArrayIndex?: string; - preserveNullAndEmptyArrays?: boolean; - } - | string - | undefined; - } - - // According to https://parseplatform.org/Parse-SDK-JS/api/2.1.0/Parse.Query.html#fullText - interface FullTextOptions { - language?: string | undefined; - caseSensitive?: boolean | undefined; - diacriticSensitive?: boolean | undefined; - } - - interface BatchOptions extends FullOptions { - batchSize?: number | undefined; - } - } - - /** - * Represents a LiveQuery Subscription. - * - * @see https://docs.parseplatform.org/js/guide/#live-queries - * @see NodeJS.EventEmitter - * - * Events list - * --- - * `open` - when you call `query.subscribe()`, we send a subscribe request to - * the LiveQuery server, when we get the confirmation from the LiveQuery server, - * this event will be emitted. When the client loses WebSocket connection to the - * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we - * reconnect the LiveQuery server and successfully resubscribe the ParseQuery, - * you'll also get this event. - * - * ``` - * subscription.on('open', () => {}); - * ``` - * --- - * `create` - when a new ParseObject is created and it fulfills the ParseQuery you subscribe, - * you'll get this event. The object is the ParseObject which is created. - * - * ``` - * subscription.on('create', (object: Parse.Object) => {}); - * ``` - * --- - * `update` event - when an existing ParseObject which fulfills the ParseQuery you subscribe - * is updated (The ParseObject fulfills the ParseQuery before and after changes), - * you'll get this event. The object is the ParseObject which is updated. - * Its content is the latest value of the ParseObject. - * - * ``` - * subscription.on('update', (object: Parse.Object) => {}); - * ``` - * --- - * `enter` event - when an existing ParseObject's old value doesn't fulfill the ParseQuery - * but its new value fulfills the ParseQuery, you'll get this event. The object is the - * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject. - * - * ``` - * subscription.on('enter', (object: Parse.Object) => {}); - * ``` - * --- - * `update` event - when an existing ParseObject's old value fulfills the ParseQuery but its new value - * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject - * which leaves the ParseQuery. Its content is the latest value of the ParseObject. - * - * ``` - * subscription.on('leave', (object: Parse.Object) => {}); - * ``` - * --- - * `delete` event - when an existing ParseObject which fulfills the ParseQuery is deleted, you'll - * get this event. The object is the ParseObject which is deleted. - * - * ``` - * subscription.on('delete', (object: Parse.Object) => {}); - * ``` - * --- - * `close` event - when the client loses the WebSocket connection to the LiveQuery - * server and we stop receiving events, you'll get this event. - * - * ``` - * subscription.on('close', () => {}); - * ``` - */ - class LiveQuerySubscription extends EventEmitter { - /** - * Creates an instance of LiveQuerySubscription. - * - * @param id - * @param query - * @param [sessionToken] - */ - constructor(id: string, query: string, sessionToken?: string); - - on( - event: 'open' | 'create' | 'update' | 'enter' | 'leave' | 'delete' | 'close', - listener: (object: Object) => void, - ): this; - - /** - * Closes the subscription. - * - */ - unsubscribe(): void; - } - - /** - * The LiveQuery namespace is basically an EventEmitter - * (source : https://github.com/parse-community/Parse-SDK-JS/blob/8115e959533d1676fe5e5551bc81888b21fc12ef/src/ParseLiveQuery.js) - * https://docs.parseplatform.org/js/guide/#websocket-status - */ - namespace LiveQuery { - function on( - event: 'open' | 'close', - /** When we establish ('open') or lose the WebSocket connection to the LiveQuery server, you’ll get this event */ - listener: () => void, - ): void; - function on( - event: 'error', - /** When some network error or LiveQuery server error happens, you’ll get this event. */ - listener: (error: any) => void, - ): void; - } - - /** - * Represents a Role on the Parse server. Roles represent groupings of - * Users for the purposes of granting permissions (e.g. specifying an ACL - * for an Object). Roles are specified by their sets of child users and - * child roles, all of which are granted any permissions that the parent - * role has. - * - *

        Roles must have a name (which cannot be changed after creation of the - * role), and must specify an ACL.

        - * A Parse.Role is a local representation of a role persisted to the Parse - * cloud. - */ - interface Role extends Object { - getRoles(): Relation; - getUsers(): Relation; - getName(): string; - setName(name: string, options?: SuccessFailureOptions): any; - } - interface RoleConstructor extends ObjectStatic { - new (name: string, acl: ACL): Role>; - new (name: string, acl: ACL): Role; - } - const Role: RoleConstructor; - - class Config { - static get(options?: UseMasterKeyOption): Promise; - static current(): Config; - static save(attr: any, options?: { [attr: string]: boolean }): Promise; - - get(attr: string): any; - escape(attr: string): any; - } - - interface Session extends Object { - getSessionToken(): string; - isCurrentSessionRevocable(): boolean; - } - interface SessionConstructor extends ObjectStatic { - new (attributes: T): Session; - new (): Session; - - current(): Promise; - } - const Session: SessionConstructor; - - /** - * - *

        A Parse.User object is a local representation of a user persisted to the - * Parse cloud. This class is a subclass of a Parse.Object, and retains the - * same functionality of a Parse.Object, but also extends it with various - * user specific methods, like authentication, signing up, and validation of - * uniqueness.

        - */ - interface User extends Object { - signUp(attrs?: any, options?: SignUpOptions): Promise; - logIn(options?: FullOptions): Promise; - authenticated(): boolean; - isCurrent(): boolean; - /** Since version 3.0.0, Returns true if `current` would return this user */ - isCurrentAsync(): Promise; - - getEmail(): string | undefined; - setEmail(email: string, options?: SuccessFailureOptions): boolean; - - getUsername(): string | undefined; - setUsername(username: string, options?: SuccessFailureOptions): boolean; - - setPassword(password: string, options?: SuccessFailureOptions): boolean; - getSessionToken(): string; - - linkWith: ( - provider: string | AuthProvider, - options: { authData?: AuthData | undefined }, - saveOpts?: FullOptions, - ) => Promise; - _isLinked: (provider: string | AuthProvider) => boolean; - _unlinkFrom: (provider: string | AuthProvider, options?: FullOptions) => Promise; - } - interface UserConstructor extends ObjectStatic { - new (attributes: T): User; - new (attributes?: Attributes): User; - - allowCustomUserClass(isAllowed: boolean): void; - become(sessionToken: string, options?: UseMasterKeyOption): Promise; - current(): T | undefined; - currentAsync(): Promise; - signUp(username: string, password: string, attrs: any, options?: SignUpOptions): Promise; - logIn(username: string, password: string, options?: FullOptions): Promise; - logOut(): Promise; - requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; - requestEmailVerification(email: string, options?: UseMasterKeyOption): Promise; - extend(protoProps?: any, classProps?: any): any; - hydrate(userJSON: any): Promise; - enableUnsafeCurrentUser(): void; - disableUnsafeCurrentUser(): void; - logInWith( - provider: string | AuthProvider, - options: { authData?: AuthData | undefined }, - saveOpts?: FullOptions, - ): Promise; - _registerAuthenticationProvider: (provider: AuthProvider) => void; - } - const User: UserConstructor; - - /** - * The raw schema response returned from the `GET /parse/schemas` endpoint. - * This is defined here: https://docs.parseplatform.org/js/guide/#schema. - * Unfortunately, `Schema.all()` and `Schema.prototype.get()` return this rather - * than a `Schema`. It is also the only object which provides introspection on - * the schema - such as `className` and `fields`. - */ - interface RestSchema { - className: string; - fields: { - [key: string]: { - type: string; - targetClass?: string; - required?: boolean; - defaultValue?: string; - }; - }; - classLevelPermissions: Schema.CLP; - indexes?: { - [key: string]: { - [key: string]: any; - }; - }; - } - - /** - * A Parse.Schema object is for handling schema data from Parse. - * All the schemas methods require MasterKey. - * - * @param className Parse Class string - * - * https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html - * - * ``` - * const schema = new Parse.Schema('MyClass'); - * schema.addString('field'); - * schema.addIndex('index_name', { field: 1 }); - * schema.save(); - * ``` - */ - class Schema { - constructor(className: string); - - /** - * Static method to get all schemas - * - * @return A promise that is resolved with the result when - * the query completes. - */ - static all(): Promise; - - addArray(key: Schema.AttrType, options?: Schema.FieldOptions): this; - addBoolean(key: Schema.AttrType, options?: Schema.FieldOptions): this; - addDate(key: Schema.AttrType, options?: Schema.FieldOptions): this; - addField(name: string, type?: T, options?: Schema.FieldOptions): this; - addFile(key: Schema.AttrType, options?: Schema.FieldOptions): this; - addGeoPoint(key: Schema.AttrType, options?: Schema.FieldOptions): this; - - /** - * Adding an Index to Create / Update a Schema - * @param name Name of the field that will be created on Parse - * @param index `{ 'field': value }` where `field` should exist in the schema before using addIndex. - * @return Returns the schema, so you can chain this call. - * @example - * ``` - * schema.addIndex('index_name', {'field': 1}); - * ``` - */ - addIndex(name: string, index: Schema.Index): this; - - addNumber(key: Schema.AttrType, options?: Schema.FieldOptions): this; - - addObject(key: Schema.AttrType, options?: Schema.FieldOptions): this; - - /** - * Adding Pointer Field - * @param name Name of the field that will be created on Parse - * @param targetClass Name of the target Pointer Class - * @return Returns the schema, so you can chain this call. - */ - addPointer( - key: Schema.AttrType, - targetClass: string, - options?: Schema.FieldOptions, - ): this; - - addPolygon(key: Schema.AttrType, options?: Schema.FieldOptions): this; - - /** - * Adding Relation Field - * @param name Name of the field that will be created on Parse - * @param targetClass Name of the target Pointer Class - * @return Returns the schema, so you can chain this call. - */ - addRelation( - key: Schema.AttrType, - targetClass: string, - options?: Schema.FieldOptions, - ): this; - - addString(key: Schema.AttrType, options?: Schema.FieldOptions): this; - - /** - * Removing a Schema from Parse Can only be used on Schema without objects - * @returns A promise that is resolved with the result when the query completes. - */ - // @TODO Fix Promise - delete(): Promise; - - /** - * Deleting a Field to Update on a Schema - * @param name Name of the field - * @return Returns the schema, so you can chain this call. - */ - deleteField(name: string): this; - - /** - * Deleting a Index Field to Update on a Schema - * @param name Name of the index field - * @return Returns the schema, so you can chain this call. - */ - deleteIndex(name: string): this; - - /** - * Get the Schema from Parse - */ - get(): Promise; - - /** - * Removes all objects from a Schema (class) in EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed - */ - // TODO Fix Promise - purge(): Promise; - - /** - * Create a new Schema on Parse - */ - save(): Promise; - - /** - * Sets Class Level Permissions when creating / updating a Schema. - * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed - */ - setCLP(clp: Schema.CLP): this; - - /** - * Update a Schema on Parse - */ - update(): Promise; - } - - namespace Schema { - type TYPE = - | 'String' - | 'Number' - | 'Boolean' - | 'Date' - | 'File' - | 'GeoPoint' - | 'Polygon' - | 'Array' - | 'Object' - | 'Pointer' - | 'Relation'; - type FieldType = - | string - | number - | boolean - | Date - | File - | GeoPoint - | Polygon - | any[] - | object - | Pointer - | Relation; - type AttrType = Extract< - { [K in keyof T['attributes']]: T['attributes'][K] extends V ? K : never }[keyof T['attributes']], - string - >; - - interface FieldOptions< - T extends - | string - | number - | boolean - | Date - | File - | GeoPoint - | Polygon - | any[] - | object - | Pointer - | Relation = any, - > { - required?: boolean | undefined; - defaultValue?: T | undefined; - } - - interface Index { - [fieldName: string]: number | string; - } - - /** - * The id of a `_User` object or a role name prefixed by `'role:'`. - * @example - * '*': false, // public - * requiresAuthentication: false, - * 'role:Admin': true, - * 'idOfASpecificUser': true - */ - interface CLPField { - '*'?: boolean | undefined; - requiresAuthentication?: boolean | undefined; - /** `role:Admin` */ - [userIdOrRoleName: string]: boolean | undefined; - } - - interface CLP { - find?: CLPField | undefined; - get?: CLPField | undefined; - count?: CLPField | undefined; - create?: CLPField | undefined; - update?: CLPField | undefined; - delete?: CLPField | undefined; - addField?: CLPField | undefined; - /** Array of fields that point to a `_User` object's ID or a `Role` object's name */ - readUserFields?: string[] | undefined; - /** Array of fields that point to a `_User` object's ID or a `Role` object's name */ - writeUserFields?: string[] | undefined; - protectedFields?: { - /** '*', user id, or role: followed by a list of fields. */ - [userIdOrRoleName: string]: string[]; - }; - } - } - - namespace Analytics { - function track(name: string, dimensions: any): Promise; - } - - /** - * Provides utility functions for working with Anonymously logged-in users. - */ - namespace AnonymousUtils { - function isLinked(user: User): boolean; - function link(user: User, options?: ScopeOptions): Promise; - function logIn(options?: ScopeOptions): Promise; - } - - /** - * Provides a set of utilities for using Parse with Facebook. - * Provides a set of utilities for using Parse with Facebook. - */ - namespace FacebookUtils { - function init(options?: any): void; - function isLinked(user: User): boolean; - function link(user: User, permissions: any, options?: SuccessFailureOptions): void; - function logIn(permissions: any, options?: FullOptions): void; - function unlink(user: User, options?: SuccessFailureOptions): void; - } - - /** - * Contains functions for calling and declaring - * cloud functions. - *

        - * Some functions are only available from Cloud Code. - *

        - */ - namespace Cloud { - interface CookieOptions { - domain?: string | undefined; - expires?: Date | undefined; - httpOnly?: boolean | undefined; - maxAge?: number | undefined; - path?: string | undefined; - secure?: boolean | undefined; - } - - interface HttpResponse { - buffer?: Buffer | undefined; - cookies?: any; - data?: any; - headers?: any; - status?: number | undefined; - text?: string | undefined; - } - - interface JobRequest { - params: T; - message: (response: any) => void; - } - - interface Params { - [key: string]: any; - } - - interface FunctionRequest { - installationId?: string | undefined; - master?: boolean | undefined; - params: T; - user?: User | undefined; - } - - interface ValidatorField { - type?: any; - constant?: boolean | undefined; - default?: any; - options?: any[] | Function | undefined; - error?: String | undefined; - required?: boolean; - } - interface ValidatorFields { - [field: string]: ValidatorField; - } - interface Validator { - requireUser?: boolean | undefined; - requireMaster?: boolean | undefined; - validateMasterKey?: boolean | undefined; - skipWithMasterKey?: boolean | undefined; - requireAnyUserRoles?: String[] | Function | undefined; - requireAllUserRoles?: String[] | Function | undefined; - fields?: ValidatorFields | String[] | undefined; - requireUserKeys?: ValidatorFields | String[] | undefined; - } - - interface Cookie { - name?: string | undefined; - options?: CookieOptions | undefined; - value?: string | undefined; - } - - interface TriggerRequest { - installationId?: string | undefined; - master?: boolean | undefined; - user?: User | undefined; - ip: string; - headers: any; - triggerName: string; - log: any; - object: T; - original?: T | undefined; - } - - interface AfterSaveRequest extends TriggerRequest { - context: Record; - } - interface AfterDeleteRequest extends TriggerRequest {} // tslint:disable-line no-empty-interface - interface BeforeDeleteRequest extends TriggerRequest {} // tslint:disable-line no-empty-interface - interface BeforeSaveRequest extends TriggerRequest { - context: Record; - } - - interface FileTriggerRequest extends TriggerRequest { - file: File; - fileSize: number; - contentLength: number; - } - - // Read preference describes how MongoDB driver route read operations to the members of a replica set. - enum ReadPreferenceOption { - Primary = 'PRIMARY', - PrimaryPreferred = 'PRIMARY_PREFERRED', - Secondary = 'SECONDARY', - SecondaryPreferred = 'SECONDARY_PREFERRED', - Nearest = 'NEAREST', - } - - interface BeforeFindRequest extends TriggerRequest { - query: Query; - count: boolean; - isGet: boolean; - readPreference?: ReadPreferenceOption | undefined; - } - - interface AfterFindRequest extends TriggerRequest { - objects: T[]; - } - - function afterDelete( - arg1: { new (): T } | string, - func?: (request: AfterDeleteRequest) => Promise | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function afterSave( - arg1: { new (): T } | string, - func?: (request: AfterSaveRequest) => Promise | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function beforeDelete( - arg1: { new (): T } | string, - func?: (request: BeforeDeleteRequest) => Promise | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function beforeSave( - arg1: { new (): T } | string, - func?: (request: BeforeSaveRequest) => Promise | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function beforeFind( - arg1: { new (): T } | string, - func?: (request: BeforeFindRequest) => Promise> | Promise | Query | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function afterFind( - arg1: { new (): T } | string, - func?: (request: AfterFindRequest) => any, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - - function beforeLogin(func?: (request: TriggerRequest) => PromiseLike | void): void; - function afterLogin( - func?: (request: TriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function afterLogout( - func?: (request: TriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - - function beforeSaveFile( - func?: (request: FileTriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function afterSaveFile( - func?: (request: FileTriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function beforeDeleteFile( - func?: (request: FileTriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function afterDeleteFile( - func?: (request: FileTriggerRequest) => PromiseLike | void, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - - function define( - name: string, - func: (request: FunctionRequest) => any, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function define any>( - name: string, - func: (request: FunctionRequest<{}>) => Promise> | ReturnType, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - function define[0]]: Parameters[0][P] }) => any>( - name: string, - func: (request: FunctionRequest[0]>) => Promise> | ReturnType, - validator?: Validator | ((request: FunctionRequest) => any), - ): void; - /** - * Gets data for the current set of cloud jobs. - * @returns A promise that will be resolved with the result of the function. - */ - function getJobsData(): Promise; - /** - * Gets job status by Id - * @param jobStatusId The Id of Job Status. - * @returns Status of Job. - */ - function getJobStatus(jobStatusId: string): Promise; - function httpRequest(options: HTTPOptions): Promise; - function job(name: string, func?: (request: JobRequest) => Promise | void): HttpResponse; - function run(name: string, data?: Params, options?: RunOptions): Promise; - function run any>(name: string, data?: null, options?: RunOptions): Promise>; - function run[0]]: Parameters[0][P] }) => any>( - name: string, - data: Parameters[0], - options?: RunOptions, - ): Promise>; - /** - * Starts a given cloud job, which will process asynchronously. - * @param jobName The function name. - * @param data The parameters to send to the cloud function. - * @returns A promise that will be resolved with the jobStatusId of the job. - */ - function startJob(jobName: string, data: any): Promise; - function useMasterKey(): void; - - interface RunOptions extends SuccessFailureOptions, ScopeOptions {} - - /** - * To use this Cloud Module in Cloud Code, you must require 'buffer' in your JavaScript file. - * - * import Buffer = require("buffer").Buffer; - */ - let HTTPOptions: new () => HTTPOptions; - interface HTTPOptions { - /** - * The body of the request. - * If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. - * You can also set this to a Buffer object to send raw bytes. - * If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. - */ - body?: string | Buffer | object | undefined; - /** - * Defaults to 'false'. - */ - followRedirects?: boolean | undefined; - /** - * The headers for the request. - */ - headers?: - | { - [headerName: string]: string | number | boolean; - } - | undefined; - /** - * The method of the request (i.e GET, POST, etc). - */ - method?: string | undefined; - /** - * The query portion of the url. - */ - params?: any; - /** - * The url to send the request to. - */ - url: string; - - success?: ((response: any) => void) | undefined; - error?: ((response: any) => void) | undefined; - } - } - - namespace EventuallyQueue { - interface QueueObject { - queueId: string; - action: string; - object: Object; - serverOptions: Object.SaveOptions | RequestOptions; - id: string; - className: string; - hash: string; - createdAt: Date; - } - type Queue = QueueObject[]; - /** - * Add object to queue with save operation. - * - * @param object Parse.Object to be saved eventually - * @param serverOptions See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options. - * @returns A promise that is fulfilled if object is added to queue. - * @see Parse.Object#saveEventually - */ - function save(object: Object, serverOptions?: Object.SaveOptions): Promise; - /** - * Add object to queue with save operation. - * - * @param object Parse.Object to be destroyed eventually - * @param serverOptions See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options - * @returns A promise that is fulfilled if object is added to queue. - * @see Parse.Object#destroyEventually - */ - function destroy(object: Object, serverOptions?: RequestOptions): Promise; - // function store(data: any): Promise; - // function load(): Promise; - /** - * Sets the in-memory queue from local storage and returns. - */ - function getQueue(): Promise; - /** - * Removes all objects from queue. - * @returns A promise that is fulfilled when queue is cleared. - */ - function clear(): Promise; - /** - * Return the number of objects in the queue. - */ - function length(): Promise; - /** - * Sends the queue to the server. - * @returns Returns true if queue was sent successfully. - */ - function sendQueue(): Promise; - /** - * Start polling server for network connection. - * Will send queue if connection is established. - * - * @param [ms] Milliseconds to ping the server. Default 2000ms - */ - function poll(ms?: number): void; - /** - * Turns off polling. - */ - function stopPoll(): void; - /** - * Return true if pinging the server. - */ - function isPolling(): boolean; - } - - class Error { - static OTHER_CAUSE: ErrorCode.OTHER_CAUSE; - static INTERNAL_SERVER_ERROR: ErrorCode.INTERNAL_SERVER_ERROR; - static CONNECTION_FAILED: ErrorCode.CONNECTION_FAILED; - static OBJECT_NOT_FOUND: ErrorCode.OBJECT_NOT_FOUND; - static INVALID_QUERY: ErrorCode.INVALID_QUERY; - static INVALID_CLASS_NAME: ErrorCode.INVALID_CLASS_NAME; - static MISSING_OBJECT_ID: ErrorCode.MISSING_OBJECT_ID; - static INVALID_KEY_NAME: ErrorCode.INVALID_KEY_NAME; - static INVALID_POINTER: ErrorCode.INVALID_POINTER; - static INVALID_JSON: ErrorCode.INVALID_JSON; - static COMMAND_UNAVAILABLE: ErrorCode.COMMAND_UNAVAILABLE; - static NOT_INITIALIZED: ErrorCode.NOT_INITIALIZED; - static INCORRECT_TYPE: ErrorCode.INCORRECT_TYPE; - static INVALID_CHANNEL_NAME: ErrorCode.INVALID_CHANNEL_NAME; - static PUSH_MISCONFIGURED: ErrorCode.PUSH_MISCONFIGURED; - static OBJECT_TOO_LARGE: ErrorCode.OBJECT_TOO_LARGE; - static OPERATION_FORBIDDEN: ErrorCode.OPERATION_FORBIDDEN; - static CACHE_MISS: ErrorCode.CACHE_MISS; - static INVALID_NESTED_KEY: ErrorCode.INVALID_NESTED_KEY; - static INVALID_FILE_NAME: ErrorCode.INVALID_FILE_NAME; - static INVALID_ACL: ErrorCode.INVALID_ACL; - static TIMEOUT: ErrorCode.TIMEOUT; - static INVALID_EMAIL_ADDRESS: ErrorCode.INVALID_EMAIL_ADDRESS; - static MISSING_CONTENT_TYPE: ErrorCode.MISSING_CONTENT_TYPE; - static MISSING_CONTENT_LENGTH: ErrorCode.MISSING_CONTENT_LENGTH; - static INVALID_CONTENT_LENGTH: ErrorCode.INVALID_CONTENT_LENGTH; - static FILE_TOO_LARGE: ErrorCode.FILE_TOO_LARGE; - static FILE_SAVE_ERROR: ErrorCode.FILE_SAVE_ERROR; - static DUPLICATE_VALUE: ErrorCode.DUPLICATE_VALUE; - static INVALID_ROLE_NAME: ErrorCode.INVALID_ROLE_NAME; - static EXCEEDED_QUOTA: ErrorCode.EXCEEDED_QUOTA; - static SCRIPT_FAILED: ErrorCode.SCRIPT_FAILED; - static VALIDATION_ERROR: ErrorCode.VALIDATION_ERROR; - static INVALID_IMAGE_DATA: ErrorCode.INVALID_IMAGE_DATA; - static UNSAVED_FILE_ERROR: ErrorCode.UNSAVED_FILE_ERROR; - static INVALID_PUSH_TIME_ERROR: ErrorCode.INVALID_PUSH_TIME_ERROR; - static FILE_DELETE_ERROR: ErrorCode.FILE_DELETE_ERROR; - static REQUEST_LIMIT_EXCEEDED: ErrorCode.REQUEST_LIMIT_EXCEEDED; - static INVALID_EVENT_NAME: ErrorCode.INVALID_EVENT_NAME; - static USERNAME_MISSING: ErrorCode.USERNAME_MISSING; - static PASSWORD_MISSING: ErrorCode.PASSWORD_MISSING; - static USERNAME_TAKEN: ErrorCode.USERNAME_TAKEN; - static EMAIL_TAKEN: ErrorCode.EMAIL_TAKEN; - static EMAIL_MISSING: ErrorCode.EMAIL_MISSING; - static EMAIL_NOT_FOUND: ErrorCode.EMAIL_NOT_FOUND; - static SESSION_MISSING: ErrorCode.SESSION_MISSING; - static MUST_CREATE_USER_THROUGH_SIGNUP: ErrorCode.MUST_CREATE_USER_THROUGH_SIGNUP; - static ACCOUNT_ALREADY_LINKED: ErrorCode.ACCOUNT_ALREADY_LINKED; - static INVALID_SESSION_TOKEN: ErrorCode.INVALID_SESSION_TOKEN; - static LINKED_ID_MISSING: ErrorCode.LINKED_ID_MISSING; - static INVALID_LINKED_SESSION: ErrorCode.INVALID_LINKED_SESSION; - static UNSUPPORTED_SERVICE: ErrorCode.UNSUPPORTED_SERVICE; - static AGGREGATE_ERROR: ErrorCode.AGGREGATE_ERROR; - static FILE_READ_ERROR: ErrorCode.FILE_READ_ERROR; - static X_DOMAIN_REQUEST: ErrorCode.X_DOMAIN_REQUEST; - - code: ErrorCode; - message: string; - - constructor(code: ErrorCode, message: string); - } - - /** - * A Parse.Op is an atomic operation that can be applied to a field in a - * Parse.Object. For example, calling object.set("foo", "bar") - * is an example of a Parse.Op.Set. Calling object.unset("foo") - * is a Parse.Op.Unset. These operations are stored in a Parse.Object and - * sent to the server as part of object.save() operations. - * Instances of Parse.Op should be immutable. - * - * You should not create subclasses of Parse.Op or instantiate Parse.Op - * directly. - */ - namespace Op { - interface BaseOperation { - objects(): any[]; - } - - interface Add extends BaseOperation { - toJSON(): any; - } - - interface AddUnique extends BaseOperation { - toJSON(): any; - } - - interface Increment { - amount: number; - toJSON(): any; - } - - interface Relation { - added(): Object[]; - removed: Object[]; - toJSON(): any; - } - - interface Set { - value(): any; - toJSON(): any; - } - - interface Unset { - toJSON(): any; - } - } - - /** - * Contains functions to deal with Push in Parse - */ - namespace Push { - function send(data: PushData, options?: SendOptions): Promise; - - interface PushData { - channels?: string[] | undefined; - push_time?: Date | undefined; - expiration_time?: Date | undefined; - expiration_interval?: number | undefined; - where?: Query | undefined; - data?: any; - alert?: string | undefined; - badge?: string | undefined; - sound?: string | undefined; - title?: string | undefined; - notification?: any; - content_available?: any; - } - - interface SendOptions extends UseMasterKeyOption { - success?: (() => void) | undefined; - error?: ((error: Error) => void) | undefined; - } - } - - /** - * Call this method first to set up your authentication tokens for Parse. - * You can get your keys from the Data Browser on parse.com. - * @param applicationId Your Parse Application ID. - * @param javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) - * @param masterKey (optional) Your Parse Master Key. (Node.js only!) - */ - function initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void; - - /** - * Use this to set custom headers - * The headers will be sent with every parse request - */ - namespace CoreManager { - function set(key: string, value: any): void; - function get(key: string): void; - } - - /** - * Additionally on React-Native / Expo environments, add AsyncStorage from 'react-native' package - * @param AsyncStorage AsyncStorage from 'react-native' package - */ - function setAsyncStorage(AsyncStorage: any): void; - - /** - * Gets all contents from Local Datastore. - */ - function dumpLocalDatastore(): Promise<{ [key: string]: any }>; - - /** - * Enable pinning in your application. - * This must be called before your application can use pinning. - */ - function enableLocalDatastore(): void; - - /** - * Flag that indicates whether Local Datastore is enabled. - */ - function isLocalDatastoreEnabled(): boolean; - - function setLocalDatastoreController(controller: any): void; - - /** - * Call this method to set your LocalDatastoreStorage engine - * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} - * @param controller a data storage. - */ - function setLocalDatastoreController(controller: any): void; - - /** - * Enable the current user encryption. - * This must be called before login any user. - */ - function enableEncryptedUser(): void; - - /** - * Flag that indicates whether Encrypted User is enabled. - */ - function isEncryptedUserEnabled(): boolean; - } -} - -export = Parse; +import parse from "./Parse"; +export default parse; From 60ae2a621395e9408b771f9f69f769a2f0c5456b Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 6 Aug 2023 15:57:33 -0500 Subject: [PATCH 09/13] remove comment --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index ee5eb1233..e162045cb 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,5 @@ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b23a36e669fa127d1035e22ca93faab85b98e49f/types/parse/index.d.ts#L11 -// TODO(dplewis): Possibly add @types/node module reference types +// TODO: Possibly add @types/node module reference types /// /// From 41a41b420ab5b464904a80be30ebac058e494f12 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 6 Aug 2023 16:01:45 -0500 Subject: [PATCH 10/13] remove extra comments --- types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index e162045cb..8dd1ccd66 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,4 @@ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b23a36e669fa127d1035e22ca93faab85b98e49f/types/parse/index.d.ts#L11 -// TODO: Possibly add @types/node module reference types /// /// From b59b11109b2b4516aad2636d1871159cba697c98 Mon Sep 17 00:00:00 2001 From: dblythy Date: Thu, 10 Aug 2023 21:03:48 +1000 Subject: [PATCH 11/13] merge add tests Update ParseSession.js Update ci.yml --- .github/workflows/ci.yml | 2 + package.json | 4 +- src/ParseQuery.js | 2 +- src/ParseSession.ts | 2 - tsconfig.json | 3 +- types/ParseObject.d.ts | 8 +-- types/tests.ts | 144 +++++++++++++++++++-------------------- 7 files changed, 83 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dacfb9e48..9f6b2353a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: steps: - uses: actions/checkout@v3 - run: npm ci + # - name: Build types (enable when full typescript support) + # run: npm run build:types - name: Check types run: npm run test:types build: diff --git a/package.json b/package.json index 45c06dd47..5d37949fd 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,13 @@ "lib/", "LICENSE", "NOTICE", - "README.md" + "README.md", + "types/index.d.ts" ], "browser": { "react-native": false }, + "types": "types", "dependencies": { "@babel/runtime-corejs3": "7.22.6", "idb-keyval": "6.2.1", diff --git a/src/ParseQuery.js b/src/ParseQuery.js index f2e18b4d0..ebe56d845 100644 --- a/src/ParseQuery.js +++ b/src/ParseQuery.js @@ -1575,7 +1575,7 @@ class ParseQuery { * @param {string} modifiers The regular expression mode. * @returns {Parse.Query} Returns the query, so you can chain this call. */ - startsWith(key: string, prefix: string, modifiers: string): ParseQuery { + startsWith(key: string, prefix: string, modifiers?: string): ParseQuery { if (typeof prefix !== 'string') { throw new Error('The value being searched for must be a string.'); } diff --git a/src/ParseSession.ts b/src/ParseSession.ts index 51b001742..fa1782d64 100644 --- a/src/ParseSession.ts +++ b/src/ParseSession.ts @@ -2,8 +2,6 @@ import CoreManager from './CoreManager'; import isRevocableSession from './isRevocableSession'; import ParseObject from './ParseObject'; import ParseUser from './ParseUser'; - -import type { AttributeMap } from './ObjectStateMutations'; import type { RequestOptions, FullOptions } from './RESTController'; /** diff --git a/tsconfig.json b/tsconfig.json index 051477c29..73135762d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,6 @@ "allowJs": false }, "files": [ - "src/Parse.ts", - "src/ParseSession.ts" + "src/Parse.ts" ] } diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index 09eb14634..6695dc8e9 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -567,7 +567,7 @@ declare class ParseObject { * The only supported option is error. * @returns {(ParseObject|boolean)} true if the set succeeded. */ - set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean; + set(key: mixed, value?: mixed, options?: mixed): ParseObject | boolean; /** * Remove an attribute from the model. This is a noop if the attribute doesn't * exist. @@ -783,7 +783,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. @@ -873,8 +873,8 @@ declare class ParseObject { * completes. */ save(arg1?: string | { - [attr: string]: mixed; - }, arg2?: SaveOptions | mixed, arg3?: SaveOptions): Promise; + [attr: string]: object; + } | null, arg2?: SaveOptions | object, arg3?: SaveOptions): Promise; /** * Deletes this object from the server at some unspecified time in the future, * even if Parse is currently inaccessible. diff --git a/types/tests.ts b/types/tests.ts index a275584e9..bd5d8bd7c 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -1,83 +1,83 @@ import Parse from './Parse'; // Parse is a global type, but it can also be imported -// class GameScore extends Parse.Object { -// constructor(options?: any) { -// super('GameScore', options); -// } -// } +class GameScore extends Parse.Object { + constructor(options?: any) { + super('GameScore', options); + } +} -// class Game extends Parse.Object { -// constructor(options?: any) { -// super('Game', options); -// } -// } +class Game extends Parse.Object { + constructor(options?: any) { + super('Game', options); + } +} -// function test_config() { -// Parse.Config.save({ foo: 'bar' }, { foo: true }); -// Parse.Config.get({ useMasterKey: true }); -// } +function test_config() { + Parse.Config.save({ foo: 'bar' }, { foo: true }); + Parse.Config.get({ useMasterKey: true }); +} -// function test_object() { -// const game = new Game(); -// game.save(null, { -// useMasterKey: true, -// sessionToken: 'sometoken', -// cascadeSave: false, -// }).then(result => result); +function test_object() { + const game = new Game(); + game.save(null, { + useMasterKey: true, + sessionToken: 'sometoken', + cascadeSave: false, + }).then(result => result); -// if (!game.isNew()) { + if (!game.isNew()) { -// } + } -// if (game.toPointer().className !== 'Game') { + if (game.toPointer().className !== 'Game') { -// } + } -// game.fetch({}); + game.fetch({}); -// // Create a new instance of that class. -// const gameScore = new GameScore(); + // Create a new instance of that class. + const gameScore = new GameScore(); -// gameScore.set('score', 1337); -// gameScore.set('playerName', 'Sean Plott'); -// gameScore.set('cheatMode', false); + gameScore.set('score', 1337); + gameScore.set('playerName', 'Sean Plott'); + gameScore.set('cheatMode', false); -// // Setting attrs using object -// gameScore.set({ -// level: '10', -// difficult: 15, -// }); + // Setting attrs using object + gameScore.set({ + level: '10', + difficult: 15, + }); -// const score = gameScore.get('score'); -// const playerName = gameScore.get('playerName'); -// const cheatMode = gameScore.get('cheatMode'); + const score = gameScore.get('score'); + const playerName = gameScore.get('playerName'); + const cheatMode = gameScore.get('cheatMode'); -// gameScore.increment('score'); -// gameScore.addUnique('skills', 'flying'); -// gameScore.addUnique('skills', 'kungfu'); -// gameScore.addAll('skills', ['kungfu']); -// gameScore.addAllUnique('skills', ['kungfu']); -// gameScore.remove('skills', 'flying'); -// gameScore.removeAll('skills', ['kungFu']); -// game.set('gameScore', gameScore); + gameScore.increment('score'); + gameScore.addUnique('skills', 'flying'); + gameScore.addUnique('skills', 'kungfu'); + gameScore.addAll('skills', ['kungfu']); + gameScore.addAllUnique('skills', ['kungfu']); + gameScore.remove('skills', 'flying'); + gameScore.removeAll('skills', ['kungFu']); + game.set('gameScore', gameScore); -// const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); + const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); -// const object = new Parse.Object('TestObject'); -// object.equals(gameScore); -// object.fetchWithInclude(['key1', 'key2']); -// } + const object = new Parse.Object('TestObject'); + object.equals(gameScore); + object.fetchWithInclude(['key1', 'key2']); +} -// function test_errors() { -// try { -// throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); -// } catch (error) { -// if (error.code !== 1) { +function test_errors() { + try { + throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); + } catch (error) { + if (error.code !== 1) { -// } -// } -// } + } + } +} // function test_query() { // const gameScore = new GameScore(); @@ -2053,21 +2053,21 @@ import Parse from './Parse'; // } // } -function testSession() { - function testConstructor() { - // $ExpectType ParseSession - new Parse.Session(); +// function testSession() { +// function testConstructor() { +// // $ExpectType ParseSession +// new Parse.Session(); - // $ExpectType ParseSession - new Parse.Session({ example: 100 }); +// // $ExpectType ParseSession +// new Parse.Session({ example: 100 }); - // @ts-expect-error - new Parse.Session<{ example: number }>(); +// // @ts-expect-error +// new Parse.Session<{ example: number }>(); - // @ts-expect-error - new Parse.Session<{ example: number }>({ example: 'hello' }); - } -} +// // @ts-expect-error +// new Parse.Session<{ example: number }>({ example: 'hello' }); +// } +// } // function testUser() { // function testConstructor() { From ecc3086e1fa0063b61baffeb2a1c929a4e18a5d8 Mon Sep 17 00:00:00 2001 From: dblythy Date: Thu, 10 Aug 2023 21:19:15 +1000 Subject: [PATCH 12/13] Update tsconfig.json --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 73135762d..051477c29 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "allowJs": false }, "files": [ - "src/Parse.ts" + "src/Parse.ts", + "src/ParseSession.ts" ] } From bd69ab072641dedf75f6b97161daf4cd7d705d82 Mon Sep 17 00:00:00 2001 From: dblythy Date: Fri, 11 Aug 2023 13:52:02 +1000 Subject: [PATCH 13/13] Revert "merge" This reverts commit b59b11109b2b4516aad2636d1871159cba697c98. --- .github/workflows/ci.yml | 2 - package.json | 4 +- src/ParseQuery.js | 2 +- src/ParseSession.ts | 2 + types/ParseObject.d.ts | 8 +-- types/tests.ts | 144 +++++++++++++++++++-------------------- 6 files changed, 80 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f6b2353a..dacfb9e48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,6 @@ jobs: steps: - uses: actions/checkout@v3 - run: npm ci - # - name: Build types (enable when full typescript support) - # run: npm run build:types - name: Check types run: npm run test:types build: diff --git a/package.json b/package.json index 5d37949fd..45c06dd47 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,11 @@ "lib/", "LICENSE", "NOTICE", - "README.md", - "types/index.d.ts" + "README.md" ], "browser": { "react-native": false }, - "types": "types", "dependencies": { "@babel/runtime-corejs3": "7.22.6", "idb-keyval": "6.2.1", diff --git a/src/ParseQuery.js b/src/ParseQuery.js index ebe56d845..f2e18b4d0 100644 --- a/src/ParseQuery.js +++ b/src/ParseQuery.js @@ -1575,7 +1575,7 @@ class ParseQuery { * @param {string} modifiers The regular expression mode. * @returns {Parse.Query} Returns the query, so you can chain this call. */ - startsWith(key: string, prefix: string, modifiers?: string): ParseQuery { + startsWith(key: string, prefix: string, modifiers: string): ParseQuery { if (typeof prefix !== 'string') { throw new Error('The value being searched for must be a string.'); } diff --git a/src/ParseSession.ts b/src/ParseSession.ts index fa1782d64..51b001742 100644 --- a/src/ParseSession.ts +++ b/src/ParseSession.ts @@ -2,6 +2,8 @@ import CoreManager from './CoreManager'; import isRevocableSession from './isRevocableSession'; import ParseObject from './ParseObject'; import ParseUser from './ParseUser'; + +import type { AttributeMap } from './ObjectStateMutations'; import type { RequestOptions, FullOptions } from './RESTController'; /** diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index 6695dc8e9..09eb14634 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -567,7 +567,7 @@ declare class ParseObject { * The only supported option is error. * @returns {(ParseObject|boolean)} true if the set succeeded. */ - set(key: mixed, value?: mixed, options?: mixed): ParseObject | boolean; + set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean; /** * Remove an attribute from the model. This is a noop if the attribute doesn't * exist. @@ -783,7 +783,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. @@ -873,8 +873,8 @@ declare class ParseObject { * completes. */ save(arg1?: string | { - [attr: string]: object; - } | null, arg2?: SaveOptions | object, arg3?: SaveOptions): Promise; + [attr: string]: mixed; + }, arg2?: SaveOptions | mixed, arg3?: SaveOptions): Promise; /** * Deletes this object from the server at some unspecified time in the future, * even if Parse is currently inaccessible. diff --git a/types/tests.ts b/types/tests.ts index bd5d8bd7c..a275584e9 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -1,83 +1,83 @@ import Parse from './Parse'; // Parse is a global type, but it can also be imported -class GameScore extends Parse.Object { - constructor(options?: any) { - super('GameScore', options); - } -} +// class GameScore extends Parse.Object { +// constructor(options?: any) { +// super('GameScore', options); +// } +// } -class Game extends Parse.Object { - constructor(options?: any) { - super('Game', options); - } -} +// class Game extends Parse.Object { +// constructor(options?: any) { +// super('Game', options); +// } +// } -function test_config() { - Parse.Config.save({ foo: 'bar' }, { foo: true }); - Parse.Config.get({ useMasterKey: true }); -} +// function test_config() { +// Parse.Config.save({ foo: 'bar' }, { foo: true }); +// Parse.Config.get({ useMasterKey: true }); +// } -function test_object() { - const game = new Game(); - game.save(null, { - useMasterKey: true, - sessionToken: 'sometoken', - cascadeSave: false, - }).then(result => result); +// function test_object() { +// const game = new Game(); +// game.save(null, { +// useMasterKey: true, +// sessionToken: 'sometoken', +// cascadeSave: false, +// }).then(result => result); - if (!game.isNew()) { +// if (!game.isNew()) { - } +// } - if (game.toPointer().className !== 'Game') { +// if (game.toPointer().className !== 'Game') { - } +// } - game.fetch({}); +// game.fetch({}); - // Create a new instance of that class. - const gameScore = new GameScore(); +// // Create a new instance of that class. +// const gameScore = new GameScore(); - gameScore.set('score', 1337); - gameScore.set('playerName', 'Sean Plott'); - gameScore.set('cheatMode', false); +// gameScore.set('score', 1337); +// gameScore.set('playerName', 'Sean Plott'); +// gameScore.set('cheatMode', false); - // Setting attrs using object - gameScore.set({ - level: '10', - difficult: 15, - }); +// // Setting attrs using object +// gameScore.set({ +// level: '10', +// difficult: 15, +// }); - const score = gameScore.get('score'); - const playerName = gameScore.get('playerName'); - const cheatMode = gameScore.get('cheatMode'); +// const score = gameScore.get('score'); +// const playerName = gameScore.get('playerName'); +// const cheatMode = gameScore.get('cheatMode'); - gameScore.increment('score'); - gameScore.addUnique('skills', 'flying'); - gameScore.addUnique('skills', 'kungfu'); - gameScore.addAll('skills', ['kungfu']); - gameScore.addAllUnique('skills', ['kungfu']); - gameScore.remove('skills', 'flying'); - gameScore.removeAll('skills', ['kungFu']); - game.set('gameScore', gameScore); +// gameScore.increment('score'); +// gameScore.addUnique('skills', 'flying'); +// gameScore.addUnique('skills', 'kungfu'); +// gameScore.addAll('skills', ['kungfu']); +// gameScore.addAllUnique('skills', ['kungfu']); +// gameScore.remove('skills', 'flying'); +// gameScore.removeAll('skills', ['kungFu']); +// game.set('gameScore', gameScore); - const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); +// const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true); - const object = new Parse.Object('TestObject'); - object.equals(gameScore); - object.fetchWithInclude(['key1', 'key2']); -} +// const object = new Parse.Object('TestObject'); +// object.equals(gameScore); +// object.fetchWithInclude(['key1', 'key2']); +// } -function test_errors() { - try { - throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); - } catch (error) { - if (error.code !== 1) { +// function test_errors() { +// try { +// throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds'); +// } catch (error) { +// if (error.code !== 1) { - } - } -} +// } +// } +// } // function test_query() { // const gameScore = new GameScore(); @@ -2053,21 +2053,21 @@ function test_errors() { // } // } -// function testSession() { -// function testConstructor() { -// // $ExpectType ParseSession -// new Parse.Session(); +function testSession() { + function testConstructor() { + // $ExpectType ParseSession + new Parse.Session(); -// // $ExpectType ParseSession -// new Parse.Session({ example: 100 }); + // $ExpectType ParseSession + new Parse.Session({ example: 100 }); -// // @ts-expect-error -// new Parse.Session<{ example: number }>(); + // @ts-expect-error + new Parse.Session<{ example: number }>(); -// // @ts-expect-error -// new Parse.Session<{ example: number }>({ example: 'hello' }); -// } -// } + // @ts-expect-error + new Parse.Session<{ example: number }>({ example: 'hello' }); + } +} // function testUser() { // function testConstructor() {