diff --git a/.eslintrc.json b/.eslintrc.json index 217781908..5c1928108 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,8 +9,8 @@ "es6": true }, "parser": "babel-eslint", - "globals": { - "wx": true + "globals": { + "wx": true }, "plugins": [ "flowtype", @@ -50,7 +50,8 @@ { "definedTags": [ "flow", - "flow-weak" + "flow-weak", + "template" ] } ], @@ -61,7 +62,14 @@ "AuthProvider", "AsyncStorage", "LocalDatastoreController", - "Parse" + "Parse", + "ReturnType", + "Params", + "this", + "Attributes", + "R", + "T", + "K" ] } ] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee7a46ecb..2dc365abd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: build: runs-on: ubuntu-18.04 timeout-minutes: 30 - env: + env: MONGODB_VERSION: 3.6.9 steps: - uses: actions/checkout@v2 @@ -38,6 +38,8 @@ jobs: - run: npm install -g mongodb-runner - run: mongodb-runner start - run: npm run lint + - run: npm run types + - run: npm run test:types - run: npm test -- --maxWorkers=4 - run: npm run integration env: diff --git a/integration/test/clear.js b/integration/test/clear.js index 2ae35ef2a..f829093df 100644 --- a/integration/test/clear.js +++ b/integration/test/clear.js @@ -5,7 +5,7 @@ const Parse = require('../../node'); * Calls /clear route in integration/test/server.js * * @param {boolean} fast set to true if it's ok to just drop objects and not indexes. - * @returns {Promise} A promise that is resolved when database is deleted. + * @returns {Promise} A promise that is resolved when database is deleted. */ module.exports = function (fast = true) { return Parse._ajax('GET', `http://localhost:1337/clear/${fast}`, ''); diff --git a/jsdoc-conf.json b/jsdoc-conf.json index 1386c9069..0ccf11e82 100644 --- a/jsdoc-conf.json +++ b/jsdoc-conf.json @@ -1,5 +1,5 @@ { - "plugins": ["node_modules/jsdoc-babel", "plugins/markdown"], + "plugins": ["node_modules/jsdoc-babel", "plugins/markdown", "jsdoc-plugin-intersection"], "babel": { "plugins": ["@babel/plugin-transform-flow-comments"] }, diff --git a/jsdoc-ts-conf.json b/jsdoc-ts-conf.json new file mode 100644 index 000000000..3c6dc1865 --- /dev/null +++ b/jsdoc-ts-conf.json @@ -0,0 +1,24 @@ +{ + "plugins": ["node_modules/jsdoc-babel", "plugins/markdown", "./node_modules/tsd-jsdoc/dist/plugin", "./types/plugin.js"], + "babel": { + "plugins": ["@babel/plugin-transform-flow-strip-types"] + }, + "source": { + "include": ["./README.md"], + "excludePattern": "(^|\\/|\\\\)_" + }, + "templates": { + "default": { + "outputSourceFiles": false, + "showInheritedInNav": false, + "useLongnameInNav": true + }, + "cleverLinks": true, + "monospaceLinks": false + }, + "opts": { + "template": "./node_modules/tsd-jsdoc/dist", + "recurse": true, + "destination": "types" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 50f0a303e..759f8c37b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@apollo/client": { - "version": "3.4.16", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.4.16.tgz", - "integrity": "sha512-iF4zEYwvebkri0BZQyv8zfavPfVEafsK0wkOofa6eC2yZu50J18uTutKtC174rjHZ2eyxZ8tV7NvAPKRT+OtZw==", + "version": "3.5.8", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.5.8.tgz", + "integrity": "sha512-MAm05+I1ullr64VLpZwon/ISnkMuNLf6vDqgo9wiMhHYBGT4yOAbAIseRdjCHZwfSx/7AUuBgaTNOssZPIr6FQ==", "dev": true, "requires": { "@graphql-typed-document-node/core": "^3.0.0", @@ -19,9 +19,9 @@ "optimism": "^0.16.1", "prop-types": "^15.7.2", "symbol-observable": "^4.0.0", - "ts-invariant": "^0.9.0", + "ts-invariant": "^0.9.4", "tslib": "^2.3.0", - "zen-observable-ts": "~1.1.0" + "zen-observable-ts": "^1.2.0" }, "dependencies": { "@wry/equality": { @@ -34,9 +34,9 @@ } }, "ts-invariant": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.9.3.tgz", - "integrity": "sha512-HinBlTbFslQI0OHP07JLsSXPibSegec6r9ai5xxq/qHYCsIQbzpymLpDhAUsnXcSrDEcd0L62L8vsOEdzM0qlA==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.9.4.tgz", + "integrity": "sha512-63jtX/ZSwnUNi/WhXjnK8kz4cHHpYS60AnmA6ixz17l7E12a5puCWFlNpkne5Rl0J8TBPVHpGjsj4fxs8ObVLQ==", "dev": true, "requires": { "tslib": "^2.1.0" @@ -49,12 +49,11 @@ "dev": true }, "zen-observable-ts": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.1.0.tgz", - "integrity": "sha512-1h4zlLSqI2cRLPJUHJFL8bCWHhkpuXkF+dbGkRaWjgDIG26DmzyshUMrdV/rL3UnR+mhaX4fRq8LPouq0MYYIA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.2.3.tgz", + "integrity": "sha512-hc/TGiPkAWpByykMwDcem3SdUgA4We+0Qb36bItSuJC9xD0XVBZoFHYoadAomDSNf64CG8Ydj0Qb8Od8BUWz5g==", "dev": true, "requires": { - "@types/zen-observable": "0.8.3", "zen-observable": "0.8.15" } } @@ -1306,6 +1305,12 @@ "minimist": "^1.2.0" } }, + "@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true + }, "@dabh/diagnostics": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", @@ -1317,6 +1322,73 @@ "kuler": "^2.0.0" } }, + "@definitelytyped/header-parser": { + "version": "0.0.111", + "resolved": "https://registry.npmjs.org/@definitelytyped/header-parser/-/header-parser-0.0.111.tgz", + "integrity": "sha512-5NqrHDnoH7fG4wTOlWF9xtgiq8hqYdWe/5Sr7bJmbIXf8KY+XfYtC5gHuOMPStU2tSHzn+6Q+cyrfBkIaFGM2Q==", + "dev": true, + "requires": { + "@definitelytyped/typescript-versions": "^0.0.111", + "@types/parsimmon": "^1.10.1", + "parsimmon": "^1.13.0" + } + }, + "@definitelytyped/typescript-versions": { + "version": "0.0.111", + "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.111.tgz", + "integrity": "sha512-kq3ExoHSySxe2nlHy/iXpecyypD8ZGj4Iz7b1zssUfONRrLxQsgs/F91DHLJFGXFjHUltmJgy02HabuQ/irvHw==", + "dev": true + }, + "@definitelytyped/utils": { + "version": "0.0.111", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.111.tgz", + "integrity": "sha512-zt9SP5K1FDhISNaXAJdlVVW8Z3YfHV90fP4ieywWcpG1Q1yVfKGBqN5kRgmzh7v1qukrSfOpPYgX3GWMf/E/dA==", + "dev": true, + "requires": { + "@definitelytyped/typescript-versions": "^0.0.111", + "@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": "^2.2.2", + "tar-stream": "^2.1.4" + }, + "dependencies": { + "@types/node": { + "version": "14.18.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", + "integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==", + "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": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "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 + } + } + }, "@graphql-tools/batch-delegate": { "version": "6.2.6", "resolved": "https://registry.npmjs.org/@graphql-tools/batch-delegate/-/batch-delegate-6.2.6.tgz", @@ -1336,6 +1408,35 @@ } } }, + "@graphql-tools/batch-execute": { + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/@graphql-tools/batch-execute/-/batch-execute-8.3.3.tgz", + "integrity": "sha512-22q/uCMUf+z3EWoM3ZM6DopDBGkni2TsfUb/mJIysunh5u8btAuXeju++De7RFwwUw+awdJXfunFQJG+OoH5Dg==", + "dev": true, + "requires": { + "@graphql-tools/utils": "8.6.3", + "dataloader": "2.0.0", + "tslib": "~2.3.0", + "value-or-promise": "1.0.11" + }, + "dependencies": { + "@graphql-tools/utils": { + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.3.tgz", + "integrity": "sha512-CNyP7Uu7dlVMQ32IpHWOxz4yic9BYXXVkDhG0UdTKSszvzHdgMilemE9MpUrGzzBPsTe3aYTtNGyPUkyh9yTXA==", + "dev": true, + "requires": { + "tslib": "~2.3.0" + } + }, + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true + } + } + }, "@graphql-tools/delegate": { "version": "6.2.4", "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-6.2.4.tgz", @@ -1359,43 +1460,69 @@ } }, "@graphql-tools/links": { - "version": "6.2.5", - "resolved": "https://registry.npmjs.org/@graphql-tools/links/-/links-6.2.5.tgz", - "integrity": "sha512-XeGDioW7F+HK6HHD/zCeF0HRC9s12NfOXAKv1HC0J7D50F4qqMvhdS/OkjzLoBqsgh/Gm8icRc36B5s0rOA9ig==", + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@graphql-tools/links/-/links-8.2.2.tgz", + "integrity": "sha512-lWyRvG4KqVj/3dpuQzZN34TXs9+5ETaT1MxhPHe6LIF/DdNQk4Q4Y7VeET/fZ8ZhbzgweMy0AA+ZkrS2HxBcgw==", "dev": true, "requires": { - "@graphql-tools/utils": "^7.0.0", - "apollo-link": "1.2.14", - "apollo-upload-client": "14.1.2", - "cross-fetch": "3.0.6", - "form-data": "3.0.0", - "is-promise": "4.0.0", - "tslib": "~2.0.1" + "@graphql-tools/delegate": "^8.5.1", + "@graphql-tools/utils": "^8.6.2", + "apollo-upload-client": "17.0.0", + "form-data": "^4.0.0", + "node-fetch": "^2.6.5", + "tslib": "~2.3.0" }, "dependencies": { + "@graphql-tools/delegate": { + "version": "8.5.4", + "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-8.5.4.tgz", + "integrity": "sha512-+3BCgSPCp/HoeOBjhz6X7RY7HMCNBanz/wkxo0/e4rk8TqJ3sjZCH470SHvsxCsBIlMwx4FYwkmxePgX/V+0Cg==", + "dev": true, + "requires": { + "@graphql-tools/batch-execute": "8.3.3", + "@graphql-tools/schema": "8.3.3", + "@graphql-tools/utils": "8.6.3", + "dataloader": "2.0.0", + "graphql-executor": "0.0.19", + "tslib": "~2.3.0", + "value-or-promise": "1.0.11" + } + }, + "@graphql-tools/merge": { + "version": "8.2.4", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-8.2.4.tgz", + "integrity": "sha512-hiNRTsS948F+BB4Q7CZXLaGFOIHQzmimVq3EEI/+PQZsPb7kYDzg0Ow0GyV4conDdEiooLqHf7I1dWzTYwvs0A==", + "dev": true, + "requires": { + "@graphql-tools/utils": "8.6.3", + "tslib": "~2.3.0" + } + }, + "@graphql-tools/schema": { + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-8.3.3.tgz", + "integrity": "sha512-OrRLU9/7UmkDemeyNUy62uH+FofgV3bpVVZJprc9bhe3gZsY7kQNIdY7H1unINlepjLvGOgk7u7iLo2+EhjyWw==", + "dev": true, + "requires": { + "@graphql-tools/merge": "8.2.4", + "@graphql-tools/utils": "8.6.3", + "tslib": "~2.3.0", + "value-or-promise": "1.0.11" + } + }, "@graphql-tools/utils": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-7.10.0.tgz", - "integrity": "sha512-d334r6bo9mxdSqZW6zWboEnnOOFRrAPVQJ7LkU8/6grglrbcu6WhwCLzHb90E94JI3TD3ricC3YGbUqIi9Xg0w==", + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.3.tgz", + "integrity": "sha512-CNyP7Uu7dlVMQ32IpHWOxz4yic9BYXXVkDhG0UdTKSszvzHdgMilemE9MpUrGzzBPsTe3aYTtNGyPUkyh9yTXA==", "dev": true, "requires": { - "@ardatan/aggregate-error": "0.0.6", - "camel-case": "4.1.2", - "tslib": "~2.2.0" - }, - "dependencies": { - "tslib": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", - "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==", - "dev": true - } + "tslib": "~2.3.0" } }, "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dev": true, "requires": { "asynckit": "^0.4.0", @@ -1404,9 +1531,9 @@ } }, "tslib": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", - "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", "dev": true } } @@ -1447,11 +1574,33 @@ "integrity": "sha512-OJD4Q1Xa3sffRiHzy0sskZz9ZWeqaujINfoim4CTk5Y9es1LS+WnKi25wVhmL2SGzzmKuAv7oDn+dpQAlM+Gfw==", "dev": true, "requires": { + "@graphql-tools/merge": "^8.2.0", "@graphql-tools/utils": "^8.4.0", "tslib": "~2.3.0", "value-or-promise": "1.0.11" }, "dependencies": { + "@graphql-tools/merge": { + "version": "8.2.4", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-8.2.4.tgz", + "integrity": "sha512-hiNRTsS948F+BB4Q7CZXLaGFOIHQzmimVq3EEI/+PQZsPb7kYDzg0Ow0GyV4conDdEiooLqHf7I1dWzTYwvs0A==", + "dev": true, + "requires": { + "@graphql-tools/utils": "8.6.3", + "tslib": "~2.3.0" + }, + "dependencies": { + "@graphql-tools/utils": { + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.3.tgz", + "integrity": "sha512-CNyP7Uu7dlVMQ32IpHWOxz4yic9BYXXVkDhG0UdTKSszvzHdgMilemE9MpUrGzzBPsTe3aYTtNGyPUkyh9yTXA==", + "dev": true, + "requires": { + "tslib": "~2.3.0" + } + } + } + }, "@graphql-tools/utils": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.5.0.tgz", @@ -1580,9 +1729,9 @@ } }, "@graphql-typed-document-node/core": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.1.0.tgz", - "integrity": "sha512-wYn6r8zVZyQJ6rQaALBEln5B1pzxb9shV5Ef97kTvn6yVGrqyXVnDqnU24MXnFubR+rZjBY9NWuxX3FB2sTsjg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.1.1.tgz", + "integrity": "sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg==", "dev": true }, "@jest/console": { @@ -2055,10 +2204,10 @@ "@octokit/openapi-types": "^11.2.0" } }, - "@parse/fs-files-adapter": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.0.tgz", - "integrity": "sha512-kr7Ti2eYOm14p05S86yriJdMtawL6qln3Dn5eekrwY14ih4jrjH/E+QlEpBUSBzN64fluFxciFOyjdbwDGWsGw==", + "@panva/asn1.js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@panva/asn1.js/-/asn1.js-1.0.0.tgz", + "integrity": "sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw==", "dev": true }, "@parse/minami": { @@ -2067,18 +2216,6 @@ "integrity": "sha512-Rw+p0WdOOypFPVJsmhyiI+Q056ZxdP2iAtObnU1DZrsvKZTf5x0B/0SjIt0hUgWp+COjqi/p17VdBU9IAD/NJg==", "dev": true }, - "@parse/node-apn": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@parse/node-apn/-/node-apn-4.1.1.tgz", - "integrity": "sha512-stWlQE95w5T0vkVYscoq/S3eXPQ1qzdQbKKQ8GAdw4CSNxRWLWgOH50byUR30thnQ93RshLCH5ROkvXMqzzLtw==", - "dev": true, - "requires": { - "debug": "4.3.2", - "jsonwebtoken": "8.5.1", - "node-forge": "0.10.0", - "verror": "1.10.0" - } - }, "@parse/node-gcm": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@parse/node-gcm/-/node-gcm-1.0.2.tgz", @@ -2145,74 +2282,6 @@ } } }, - "@parse/push-adapter": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@parse/push-adapter/-/push-adapter-3.4.1.tgz", - "integrity": "sha512-iev69kbwhXbez5nfEwB2GkCWBLUmRlImQTmHPpLnHBJfATYKyXf/H41WQhBPuwwScZBVp9ABsIsjjKy8iKg3fw==", - "dev": true, - "requires": { - "@parse/node-apn": "4.1.1", - "@parse/node-gcm": "1.0.2", - "npmlog": "4.1.2", - "parse": "3.3.0" - }, - "dependencies": { - "@babel/runtime": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", - "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "@babel/runtime-corejs3": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.14.6.tgz", - "integrity": "sha512-Xl8SPYtdjcMoCsIM4teyVRg7jIcgl8F2kRtoCcXuHzXswt9UxZCS6BzRo8fcnCuP6u2XtPgvyonmEPF57Kxo9Q==", - "dev": true, - "requires": { - "core-js-pure": "^3.14.0", - "regenerator-runtime": "^0.13.4" - } - }, - "crypto-js": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz", - "integrity": "sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==", - "dev": true, - "optional": true - }, - "idb-keyval": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-5.0.6.tgz", - "integrity": "sha512-6lJuVbwyo82mKSH6Wq2eHkt9LcbwHAelMIcMe0tP4p20Pod7tTxq9zf0ge2n/YDfMOpDryerfmmYyuQiaFaKOg==", - "dev": true - }, - "parse": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/parse/-/parse-3.3.0.tgz", - "integrity": "sha512-SQkTDupU7JQBJpYFIpO8TlQjUtjboUdkXaak57pjoC1ZVbhaiNyLsdYbrlM0B+sNYhlvcMh7zwZW48u10+zm0A==", - "dev": true, - "requires": { - "@babel/runtime": "7.14.6", - "@babel/runtime-corejs3": "7.14.6", - "crypto-js": "4.0.0", - "idb-keyval": "5.0.6", - "react-native-crypto-js": "1.0.0", - "uuid": "3.4.0", - "ws": "7.5.0", - "xmlhttprequest": "1.8.0" - } - }, - "ws": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", - "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==", - "dev": true - } - } - }, "@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -2277,6 +2346,63 @@ "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=", "dev": true }, + "@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" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", + "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 + } + } + }, "@semantic-release/changelog": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-5.0.1.tgz", @@ -3072,6 +3198,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/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", @@ -3106,6 +3238,22 @@ "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", "dev": true }, + "@types/webidl-conversions": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz", + "integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q==", + "dev": true + }, + "@types/whatwg-url": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz", + "integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/webidl-conversions": "*" + } + }, "@types/ws": { "version": "7.4.7", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", @@ -3130,12 +3278,6 @@ "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", "dev": true }, - "@types/zen-observable": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.3.tgz", - "integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==", - "dev": true - }, "@wry/context": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.6.1.tgz", @@ -3599,14 +3741,12 @@ } }, "apollo-upload-client": { - "version": "14.1.2", - "resolved": "https://registry.npmjs.org/apollo-upload-client/-/apollo-upload-client-14.1.2.tgz", - "integrity": "sha512-ozaW+4tnVz1rpfwiQwG3RCdCcZ93RV/37ZQbRnObcQ9mjb+zur58sGDPVg9Ef3fiujLmiE/Fe9kdgvIMA3VOjA==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/apollo-upload-client/-/apollo-upload-client-17.0.0.tgz", + "integrity": "sha512-pue33bWVbdlXAGFPkgz53TTmxVMrKeQr0mdRcftNY+PoHIdbGZD0hoaXHvO6OePJAkFz7OiCFUf98p1G/9+Ykw==", "dev": true, "requires": { - "@apollo/client": "^3.1.5", - "@babel/runtime": "^7.11.2", - "extract-files": "^9.0.0" + "extract-files": "^11.0.0" } }, "apollo-utilities": { @@ -3891,12 +4031,6 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, - "async": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.1.tgz", - "integrity": "sha512-XdD5lRO/87udXCMC9meWdYiR+Nq6ZjUfXidViUZGu2F1MO4T3XwZ1et0hb2++BgLfhyJwy44BGB/yx80ABx8hg==", - "dev": true - }, "async-done": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz", @@ -3969,13 +4103,63 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, - "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "follow-redirects": "^1.14.0" + "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": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "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": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "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": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } } }, "babel-eslint": { @@ -4225,14 +4409,13 @@ "file-uri-to-path": "1.0.0" } }, - "bl": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz", - "integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==", + "block-stream": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "dev": true, "requires": { - "readable-stream": "^2.3.5", - "safe-buffer": "^5.1.1" + "inherits": "~2.0.0" } }, "bluebird": { @@ -4540,12 +4723,6 @@ "node-int64": "^0.4.0" } }, - "bson": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", - "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==", - "dev": true - }, "buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", @@ -4608,12 +4785,24 @@ } } }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "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": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=", + "dev": true + }, "busboy": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", @@ -4668,24 +4857,6 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, - "camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dev": true, - "requires": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - }, - "dependencies": { - "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", - "dev": true - } - } - }, "camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", @@ -4768,6 +4939,15 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "charm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/charm/-/charm-1.0.2.tgz", + "integrity": "sha1-it02cVOm2aWBMxBSxAkJkdqZXjU=", + "dev": true, + "requires": { + "inherits": "^2.0.1" + } + }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", @@ -5178,6 +5358,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": "6.2.1", "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", @@ -5585,23 +5771,6 @@ } } }, - "cross-fetch": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.6.tgz", - "integrity": "sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==", - "dev": true, - "requires": { - "node-fetch": "2.6.1" - }, - "dependencies": { - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true - } - } - }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -6180,6 +6349,12 @@ "streamsearch": "0.1.2" } }, + "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": "24.9.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", @@ -6271,6 +6446,391 @@ } } }, + "dts-critic": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/dts-critic/-/dts-critic-3.3.11.tgz", + "integrity": "sha512-HMO2f9AO7ge44YO8OK18f+cxm/IaE1CFuyNFbfJRCEbyazWj5X5wWDF6W4CGdo5Ax0ILYVfJ7L/rOwuUN1fzWw==", + "dev": true, + "requires": { + "@definitelytyped/header-parser": "^0.0.111", + "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" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "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 + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.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" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "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" + } + } + } + }, + "dtslint": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-4.2.1.tgz", + "integrity": "sha512-57mWY9osUEfS6k62ATS9RSgug1dZcuN4O31hO76u+iEexa6VUEbKoPGaA2mNtc0FQDcdTl0zEUtti79UQKSQyQ==", + "dev": true, + "requires": { + "@definitelytyped/header-parser": "^0.0.111", + "@definitelytyped/typescript-versions": "^0.0.111", + "@definitelytyped/utils": "^0.0.111", + "dts-critic": "^3.3.11", + "fs-extra": "^6.0.1", + "json-stable-stringify": "^1.0.1", + "strip-json-comments": "^2.0.1", + "tslint": "5.14.0", + "tsutils": "^2.29.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" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "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 + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "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" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "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.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "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" + } + } + } + }, "duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", @@ -7238,9 +7798,9 @@ } }, "extract-files": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/extract-files/-/extract-files-9.0.0.tgz", - "integrity": "sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/extract-files/-/extract-files-11.0.0.tgz", + "integrity": "sha512-FuoE1qtbJ4bBVvv94CC7s0oTnKUGvQs+Rjf1L2SJFfS+HTVVjhPFtehPdQ0JiGPqVNfSSZvL5yzHHQq2Z4WNhQ==", "dev": true }, "extsprintf": { @@ -7385,15 +7945,6 @@ "flat-cache": "^2.0.1" } }, - "file-stream-rotator": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.5.7.tgz", - "integrity": "sha512-VYb3HZ/GiAGUCrfeakO8Mp54YGswNUHvL7P09WQcXAJNSj3iQ5QraYSp3cIn1MUyw6uzfgN/EFOarCNa4JvUHQ==", - "dev": true, - "requires": { - "moment": "^2.11.2" - } - }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -7553,12 +8104,6 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "dev": true }, - "follow-redirects": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.2.tgz", - "integrity": "sha512-yLR6WaE2lbF0x4K2qE2p9PEXKLDjUjnR/xmjS3wHAYxtlsI9MLLBJUZirAHKzUZDGLxje7w/cXR49WOUo4rbsA==", - "dev": true - }, "for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -7643,6 +8188,12 @@ "integrity": "sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA==", "dev": true }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, "fs-extra": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", @@ -7682,6 +8233,18 @@ "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" + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -8036,9 +8599,15 @@ "dev": true }, "graphql": { - "version": "15.6.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.6.0.tgz", - "integrity": "sha512-WJR872Zlc9hckiEPhXgyUftXH48jp2EjO5tgBBOyNMRJZ9fviL2mJBD6CAysk6N5S0r9BTs09Qk39nnJBkvOXQ==", + "version": "15.7.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.7.1.tgz", + "integrity": "sha512-x34S6gC0/peBZnlK60zCJox/d45A7p6At9oN9EPA3qhoIAlR4LNZmXRLkICBckwwTMJzVdA8cx3QIQZMOl606A==", + "dev": true + }, + "graphql-executor": { + "version": "0.0.19", + "resolved": "https://registry.npmjs.org/graphql-executor/-/graphql-executor-0.0.19.tgz", + "integrity": "sha512-AFOcsk/yMtl9jcO/f/0Our7unWxJ5m3FS5HjWfsXRHCyjjaubXpSHiOZO/hSYv6brayIrupDoVAzCuJpBc3elg==", "dev": true }, "graphql-extensions": { @@ -8058,12 +8627,6 @@ "integrity": "sha512-9TSAwcVA3KWw7JWYep5NCk2aw3wl1ayLtbMpmG7l26vh1FZ+gZexNPP+XJfUFyJa71UU0zcKSgtgpsrsA3Xv9Q==", "dev": true }, - "graphql-relay": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/graphql-relay/-/graphql-relay-0.9.0.tgz", - "integrity": "sha512-yNJLCqcjz0XpzpmmckRJCSK8a2ZLwTurwrQ09UyGftONh52PbrGpK1UO4yspvj0c7pC+jkN4ZUqVXG3LRrWkXQ==", - "dev": true - }, "graphql-subscriptions": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-1.2.1.tgz", @@ -8517,6 +9080,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": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "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": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, "has-bigints": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", @@ -9117,6 +9697,12 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", "dev": true }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "dev": true + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -10334,6 +10920,15 @@ } } }, + "jose": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/jose/-/jose-2.0.5.tgz", + "integrity": "sha512-BAiDNeDKTMgk4tvD0BbxJ8xHEHBZgpeRZ1zGPPsitSyMgjoMWiLGYAE7H7NpP5h0lPppQajQs871E8NHUrzVPA==", + "dev": true, + "requires": { + "@panva/asn1.js": "^1.0.0" + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10405,6 +11000,12 @@ "lodash": "^4.17.10" } }, + "jsdoc-plugin-intersection": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/jsdoc-plugin-intersection/-/jsdoc-plugin-intersection-1.0.4.tgz", + "integrity": "sha512-5OGv+aWpp0pYRMnhaUeqijesIi/xD2z8IIwIlK+JsQ0sXzMjiWT2YgNSvxcd476pRdh70Xmby/l7GD3NkWcKcQ==", + "dev": true + }, "jsdoc-regex": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/jsdoc-regex/-/jsdoc-regex-1.0.1.tgz", @@ -10629,36 +11230,6 @@ "safe-buffer": "^5.0.1" } }, - "jwks-rsa": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-1.12.3.tgz", - "integrity": "sha512-cFipFDeYYaO9FhhYJcZWX/IyZgc0+g316rcHnDpT2dNRNIE/lMOmWKKqp09TkJoYlNFzrEVODsR4GgXJMgWhnA==", - "dev": true, - "requires": { - "@types/express-jwt": "0.0.42", - "axios": "^0.21.1", - "debug": "^4.1.0", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "^5.0.0", - "jsonwebtoken": "^8.5.1", - "limiter": "^1.1.5", - "lru-memoizer": "^2.1.2", - "ms": "^2.1.2", - "proxy-from-env": "^1.1.0" - }, - "dependencies": { - "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "dev": true, - "requires": { - "agent-base": "6", - "debug": "4" - } - } - } - }, "jws": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", @@ -11350,19 +11921,6 @@ } } }, - "logform": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.3.0.tgz", - "integrity": "sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ==", - "dev": true, - "requires": { - "colors": "^1.2.1", - "fecha": "^4.2.0", - "ms": "^2.1.1", - "safe-stable-stringify": "^1.1.0", - "triple-beam": "^1.3.0" - } - }, "loglevel": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz", @@ -12062,6 +12620,15 @@ "kind-of": "^6.0.3" } }, + "minipass": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", + "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -12144,18 +12711,47 @@ "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", "dev": true }, - "mongodb": { - "version": "3.6.11", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.11.tgz", - "integrity": "sha512-4Y4lTFHDHZZdgMaHmojtNAlqkvddX2QQBEN0K//GzxhGwlI9tZ9R0vhbjr1Decw+TF7qK0ZLjQT292XgHRRQgw==", + "mongodb-connection-string-url": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz", + "integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==", "dev": true, "requires": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.0.3", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" + "@types/whatwg-url": "^8.2.1", + "whatwg-url": "^11.0.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dev": true, + "requires": { + "punycode": "^2.1.1" + } + }, + "webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true + }, + "whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dev": true, + "requires": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + } + } } }, "ms": { @@ -14441,6 +15037,37 @@ } } }, + "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": { + "hosted-git-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -14687,15 +15314,6 @@ "@wry/trie": "^0.3.0" } }, - "optional-require": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.1.8.tgz", - "integrity": "sha512-jq83qaUb0wNg9Krv1c5OQ+58EK+vHde6aBPzLvPPqJm89UQWsvSuFy9X/OSNJnFeSOKo7btE0n8Nl2+nE+z5nA==", - "dev": true, - "requires": { - "require-at": "^1.0.6" - } - }, "optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", @@ -14858,52 +15476,19 @@ } }, "parse": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/parse/-/parse-3.3.1.tgz", - "integrity": "sha512-jrb8tpeanh49lIXuQYbaJoMzywX9YiBtM17aCvYGfaHYJipSTHABA774t8IZap+F8Pb4GgZ0fM4ObfiuO4395A==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/parse/-/parse-3.4.1.tgz", + "integrity": "sha512-XTMaHfcOwAOiWLraNtPbCzR8o94ZWjOfaZDMM2jZ1ZDB5twtK1B82lPa+N197efZhcQ+QFbW/eDJsBybD48aSQ==", "dev": true, "requires": { - "@babel/runtime": "7.14.8", - "@babel/runtime-corejs3": "7.14.6", + "@babel/runtime": "7.15.4", + "@babel/runtime-corejs3": "7.14.7", "crypto-js": "4.1.1", - "idb-keyval": "5.0.6", + "idb-keyval": "6.0.3", "react-native-crypto-js": "1.0.0", "uuid": "3.4.0", - "ws": "7.5.0", + "ws": "7.5.1", "xmlhttprequest": "1.8.0" - }, - "dependencies": { - "@babel/runtime": { - "version": "7.14.8", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.8.tgz", - "integrity": "sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "@babel/runtime-corejs3": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.14.6.tgz", - "integrity": "sha512-Xl8SPYtdjcMoCsIM4teyVRg7jIcgl8F2kRtoCcXuHzXswt9UxZCS6BzRo8fcnCuP6u2XtPgvyonmEPF57Kxo9Q==", - "dev": true, - "requires": { - "core-js-pure": "^3.14.0", - "regenerator-runtime": "^0.13.4" - } - }, - "idb-keyval": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-5.0.6.tgz", - "integrity": "sha512-6lJuVbwyo82mKSH6Wq2eHkt9LcbwHAelMIcMe0tP4p20Pod7tTxq9zf0ge2n/YDfMOpDryerfmmYyuQiaFaKOg==", - "dev": true - }, - "ws": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", - "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==", - "dev": true - } } }, "parse-asn1": { @@ -14986,36 +15571,37 @@ "from": "github:parse-community/parse-server#alpha", "dev": true, "requires": { + "@apollo/client": "3.5.8", "@apollographql/graphql-playground-html": "1.6.29", - "@graphql-tools/links": "8.2.1", + "@graphql-tools/links": "8.2.2", "@graphql-tools/stitch": "6.2.4", "@graphql-tools/utils": "6.2.4", "@node-rs/bcrypt": "1.1.0", "@parse/fs-files-adapter": "1.2.1", - "@parse/push-adapter": "3.4.1", + "@parse/push-adapter": "4.1.0", "apollo-server-express": "2.25.2", "bcryptjs": "2.4.3", - "body-parser": "1.19.0", + "body-parser": "1.19.1", "commander": "5.1.0", "cors": "2.8.5", "deepcopy": "2.1.0", - "express": "4.17.1", - "follow-redirects": "1.14.5", - "graphql": "15.7.0", + "express": "4.17.2", + "follow-redirects": "1.14.8", + "graphql": "15.7.1", "graphql-list-fields": "2.0.2", "graphql-relay": "0.7.0", "graphql-tag": "2.12.6", "graphql-upload": "11.0.0", "intersect": "1.0.1", "jsonwebtoken": "8.5.1", - "jwks-rsa": "1.12.3", + "jwks-rsa": "2.0.5", "ldapjs": "2.3.1", "lodash": "4.17.21", - "lru-cache": "5.1.1", + "lru-cache": "6.0.0", "mime": "3.0.0", - "mongodb": "3.6.11", + "mongodb": "4.3.1", "mustache": "4.2.0", - "parse": "3.4.0", + "parse": "3.4.1", "pg-monitor": "1.4.1", "pg-promise": "10.11.1", "pluralize": "8.0.0", @@ -15024,30 +15610,407 @@ "subscriptions-transport-ws": "0.11.0", "tv4": "1.3.0", "uuid": "8.3.2", - "winston": "3.3.3", - "winston-daily-rotate-file": "4.5.5", + "winston": "3.5.1", + "winston-daily-rotate-file": "4.6.0", "ws": "8.2.3" }, "dependencies": { + "@parse/fs-files-adapter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.1.tgz", + "integrity": "sha512-jUbmlvql9+5Mz8Q6KSk1jH823MVerhOYK1svayYpF03v75OtDn3p+mAoFvPS5UpRln1kT6BlBnLfw4Hv08SD5Q==", + "dev": true + }, + "@parse/node-apn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@parse/node-apn/-/node-apn-5.1.0.tgz", + "integrity": "sha512-WT3iVwr1Y/Jf4nq4RGNwBdLwm3gTodsb+g3IY98MPSJ7LCNf+R81Nj/nQO5r/twJfN1v5B8cAgfvPGs2rPelvg==", + "dev": true, + "requires": { + "debug": "4.3.2", + "jsonwebtoken": "8.5.1", + "node-forge": "0.10.0", + "verror": "1.10.0" + } + }, + "@parse/push-adapter": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@parse/push-adapter/-/push-adapter-4.1.0.tgz", + "integrity": "sha512-8SOU4zgIr3+wn6Hbge4X/zAYAcJR7puJ3aY2ri+8fqMARgBria4JkIeAyKaTG/mUMHw6Qy5DpYYRe0LjImjZNw==", + "dev": true, + "requires": { + "@parse/node-apn": "5.1.0", + "@parse/node-gcm": "1.0.2", + "npmlog": "4.1.2", + "parse": "3.3.0" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", + "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/runtime-corejs3": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.14.6.tgz", + "integrity": "sha512-Xl8SPYtdjcMoCsIM4teyVRg7jIcgl8F2kRtoCcXuHzXswt9UxZCS6BzRo8fcnCuP6u2XtPgvyonmEPF57Kxo9Q==", + "dev": true, + "requires": { + "core-js-pure": "^3.14.0", + "regenerator-runtime": "^0.13.4" + } + }, + "crypto-js": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz", + "integrity": "sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==", + "dev": true, + "optional": true + }, + "parse": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/parse/-/parse-3.3.0.tgz", + "integrity": "sha512-SQkTDupU7JQBJpYFIpO8TlQjUtjboUdkXaak57pjoC1ZVbhaiNyLsdYbrlM0B+sNYhlvcMh7zwZW48u10+zm0A==", + "dev": true, + "requires": { + "@babel/runtime": "7.14.6", + "@babel/runtime-corejs3": "7.14.6", + "crypto-js": "4.0.0", + "idb-keyval": "5.0.6", + "react-native-crypto-js": "1.0.0", + "uuid": "3.4.0", + "ws": "7.5.0", + "xmlhttprequest": "1.8.0" + } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "ws": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", + "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==", + "dev": true + } + } + }, + "async": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "dev": true + }, + "body-parser": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", + "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", + "dev": true, + "requires": { + "bytes": "3.1.1", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.9.6", + "raw-body": "2.4.2", + "type-is": "~1.6.18" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "bson": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.1.tgz", + "integrity": "sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==", + "dev": true, + "requires": { + "buffer": "^5.6.0" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "bytes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", + "dev": true + }, "commander": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "dev": true }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "requires": { + "safe-buffer": "5.2.1" + } + }, + "cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true + }, + "denque": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz", + "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==", + "dev": true + }, + "express": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz", + "integrity": "sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg==", + "dev": true, + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.4.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.9.6", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.17.2", + "serve-static": "1.14.2", + "setprototypeof": "1.2.0", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "file-stream-rotator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.6.1.tgz", + "integrity": "sha512-u+dBid4PvZw17PmDeRcNOtCP9CCK/9lRN2w+r1xIS7yOL9JFrIBKTvrYsxT4P0pGtThYTn++QS5ChHaUov3+zQ==", + "dev": true, + "requires": { + "moment": "^2.29.1" + } + }, + "follow-redirects": { + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", + "dev": true + }, + "graphql-relay": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/graphql-relay/-/graphql-relay-0.7.0.tgz", + "integrity": "sha512-P8eS3IbZRhbfbcfud1Q6VPrIru4hchkb15MuOij+WQo9r0chD5NBIxiVjuRE2iG2EMHxIOrZb8LnMe82+YdITA==", + "dev": true + }, + "graphql-tag": { + "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", + "dev": true, + "requires": { + "tslib": "^2.1.0" + } + }, + "http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + } + }, + "idb-keyval": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-5.0.6.tgz", + "integrity": "sha512-6lJuVbwyo82mKSH6Wq2eHkt9LcbwHAelMIcMe0tP4p20Pod7tTxq9zf0ge2n/YDfMOpDryerfmmYyuQiaFaKOg==", + "dev": true + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "jwks-rsa": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-2.0.5.tgz", + "integrity": "sha512-fliHfsiBRzEU0nXzSvwnh0hynzGB0WihF+CinKbSRlaqRxbqqKf2xbBPgwc8mzf18/WgwlG8e5eTpfSTBcU4DQ==", + "dev": true, + "requires": { + "@types/express-jwt": "0.0.42", + "debug": "^4.3.2", + "jose": "^2.0.5", + "limiter": "^1.1.5", + "lru-memoizer": "^2.1.4" + } + }, + "logform": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.4.0.tgz", + "integrity": "sha512-CPSJw4ftjf517EhXZGGvTHHkYobo7ZCc0kvwUoOYcjfR2UVrI66RHj8MCrfAdEitdmFqbu2BYdYs8FHHZSb6iw==", + "dev": true, + "requires": { + "@colors/colors": "1.5.0", + "fecha": "^4.2.0", + "ms": "^2.1.1", + "safe-stable-stringify": "^2.3.1", + "triple-beam": "^1.3.0" + }, + "dependencies": { + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + } + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "dev": true + }, + "mongodb": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.3.1.tgz", + "integrity": "sha512-sNa8APSIk+r4x31ZwctKjuPSaeKuvUeNb/fu/3B6dRM02HpEgig7hTHM8A/PJQTlxuC/KFWlDlQjhsk/S43tBg==", + "dev": true, + "requires": { + "bson": "^4.6.1", + "denque": "^2.0.1", + "mongodb-connection-string-url": "^2.4.1", + "saslprep": "^1.0.3", + "socks": "^2.6.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "pg-promise": { + "version": "10.11.1", + "resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-10.11.1.tgz", + "integrity": "sha512-HAv32WSKf2m2RqHerW5RmANn/mcXIwWXbg/gOfGQcoS0SE+8iBi3Jj4JmoR4PNzSEozo/y/npy4e6F16psOItw==", "dev": true, "requires": { - "yallist": "^3.0.2" + "assert-options": "0.7.0", + "pg": "8.7.1", + "pg-minify": "1.6.2", + "spex": "3.2.0" } }, - "mime": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", - "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", + "qs": { + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", + "dev": true + }, + "raw-body": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", + "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", + "dev": true, + "requires": { + "bytes": "3.1.1", + "http-errors": "1.8.1", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "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 + }, + "safe-stable-stringify": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", + "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==", "dev": true }, "semver": { @@ -15076,22 +16039,166 @@ } } }, + "send": { + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "1.8.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + } + } + }, + "serve-static": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", + "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", + "dev": true, + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.2" + } + }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "subscriptions-transport-ws": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/subscriptions-transport-ws/-/subscriptions-transport-ws-0.11.0.tgz", + "integrity": "sha512-8D4C6DIH5tGiAIpp5I0wD/xRlNiZAPGHygzCe7VzyzUoxHtawzjNAY9SUTXU05/EY2NMY9/9GF0ycizkXr1CWQ==", + "dev": true, + "requires": { + "backo2": "^1.0.2", + "eventemitter3": "^3.1.0", + "iterall": "^1.2.1", + "symbol-observable": "^1.0.4", + "ws": "^5.2.0 || ^6.0.0 || ^7.0.0" + }, + "dependencies": { + "ws": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", + "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "dev": true + } + } + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true + }, + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true + }, "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "dev": true }, - "ws": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.2.tgz", - "integrity": "sha512-Q6B6H2oc8QY3llc3cB8kVmQ6pnJWVQbP7Q5algTcIxx7YEpc0oU4NBVHlztA7Ekzfhw2r0rPducMUiCGWKQRzw==", - "dev": true + "winston": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.5.1.tgz", + "integrity": "sha512-tbRtVy+vsSSCLcZq/8nXZaOie/S2tPXPFt4be/Q3vI/WtYwm7rrwidxVw2GRa38FIXcJ1kUM6MOZ9Jmnk3F3UA==", + "dev": true, + "requires": { + "@dabh/diagnostics": "^2.0.2", + "async": "^3.2.3", + "is-stream": "^2.0.0", + "logform": "^2.3.2", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", + "safe-stable-stringify": "^2.3.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.4.2" + } }, - "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "winston-daily-rotate-file": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/winston-daily-rotate-file/-/winston-daily-rotate-file-4.6.0.tgz", + "integrity": "sha512-mvpFb1LYmTvh/vz0dIS/aDCwEm0cvDa8D/tE4xWwdUYolD250wf+n0y1PZ2xr7fbvTLF/PQYqXtFIFrmog03Ow==", + "dev": true, + "requires": { + "file-stream-rotator": "^0.6.1", + "object-hash": "^2.0.1", + "triple-beam": "^1.3.0", + "winston-transport": "^4.4.0" + } + }, + "winston-transport": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz", + "integrity": "sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q==", + "dev": true, + "requires": { + "logform": "^2.3.2", + "readable-stream": "^3.6.0", + "triple-beam": "^1.3.0" + } + }, + "ws": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", + "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", "dev": true } } @@ -15108,6 +16215,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 + }, "pascal-case": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", @@ -15271,18 +16384,6 @@ "integrity": "sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ==", "dev": true }, - "pg-promise": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-10.11.0.tgz", - "integrity": "sha512-UntgHZNv+gpGJKhh+tzGSGHLkniKWV+ZQ8/SNdtvElsg9Aa7ZJ4Fgyl6pl2x0ZtJ7uFNy+OIq3Z+Ei6iplqTDQ==", - "dev": true, - "requires": { - "assert-options": "0.7.0", - "pg": "8.7.1", - "pg-minify": "1.6.2", - "spex": "3.2.0" - } - }, "pg-protocol": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", @@ -15598,14 +16699,14 @@ } }, "prop-types": { - "version": "15.7.2", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", - "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "dev": true, "requires": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", - "react-is": "^16.8.1" + "react-is": "^16.13.1" } }, "proxy-addr": { @@ -15618,12 +16719,6 @@ "ipaddr.js": "1.9.1" } }, - "proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "dev": true - }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -16181,12 +17276,6 @@ "tough-cookie": "^2.3.3" } }, - "require-at": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/require-at/-/require-at-1.0.6.tgz", - "integrity": "sha512-7i1auJbMUrXEAZCOQ0VNJgmcT2VOKPRl2YGJwgpHpC9CE91Mv4/4UYIUm4chGJaI381ZDq1JUicFii64Hapd8g==", - "dev": true - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -16363,12 +17452,6 @@ "ret": "~0.1.10" } }, - "safe-stable-stringify": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz", - "integrity": "sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw==", - "dev": true - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -17082,6 +18165,18 @@ } } }, + "slide": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", + "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", + "dev": true + }, + "smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -17204,6 +18299,16 @@ } } }, + "socks": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", + "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "dev": true, + "requires": { + "ip": "^1.1.5", + "smart-buffer": "^4.2.0" + } + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -17370,6 +18475,15 @@ "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" + } + }, "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -17738,27 +18852,6 @@ "minimist": "^1.1.0" } }, - "subscriptions-transport-ws": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/subscriptions-transport-ws/-/subscriptions-transport-ws-0.10.0.tgz", - "integrity": "sha512-k28LhLn3abJ1mowFW+LP4QGggE0e3hrk55zXbMHyAeZkCUYtC0owepiwqMD3zX8DglQVaxnhE760pESrNSEzpg==", - "dev": true, - "requires": { - "backo2": "^1.0.2", - "eventemitter3": "^3.1.0", - "iterall": "^1.2.1", - "symbol-observable": "^1.0.4", - "ws": "^5.2.0 || ^6.0.0 || ^7.0.0" - }, - "dependencies": { - "symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", - "dev": true - } - } - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -17869,6 +18962,64 @@ "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", "dev": true }, + "tar": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", + "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "dev": true, + "requires": { + "block-stream": "*", + "fstream": "^1.0.12", + "inherits": "2" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dev": true, + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "teeny-request": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-6.0.1.tgz", @@ -18141,12 +19292,59 @@ "tslib": "^1.9.3" } }, + "tsd-jsdoc": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tsd-jsdoc/-/tsd-jsdoc-2.5.0.tgz", + "integrity": "sha512-80fcJLAiUeerg4xPftp+iEEKWUjJjHk9AvcHwJqA8Zw0R4oASdu3kT/plE/Zj19QUTz8KupyOX25zStlNJjS9g==", + "dev": true, + "requires": { + "typescript": "^3.2.1" + } + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "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 + } + } + }, + "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" + } + }, "tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -18217,6 +19415,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true + }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", @@ -18558,6 +19762,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": "sha1-X6kS2B630MdK/BQN5zF/DKffQ34=", + "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", @@ -18835,64 +20048,6 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, - "winston": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.3.3.tgz", - "integrity": "sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw==", - "dev": true, - "requires": { - "@dabh/diagnostics": "^2.0.2", - "async": "^3.1.0", - "is-stream": "^2.0.0", - "logform": "^2.2.0", - "one-time": "^1.0.0", - "readable-stream": "^3.4.0", - "stack-trace": "0.0.x", - "triple-beam": "^1.3.0", - "winston-transport": "^4.4.0" - }, - "dependencies": { - "is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, - "winston-daily-rotate-file": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/winston-daily-rotate-file/-/winston-daily-rotate-file-4.5.5.tgz", - "integrity": "sha512-ds0WahIjiDhKCiMXmY799pDBW+58ByqIBtUcsqr4oDoXrAI3Zn+hbgFdUxzMfqA93OG0mPLYVMiotqTgE/WeWQ==", - "dev": true, - "requires": { - "file-stream-rotator": "^0.5.7", - "object-hash": "^2.0.1", - "triple-beam": "^1.3.0", - "winston-transport": "^4.4.0" - } - }, - "winston-transport": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.4.0.tgz", - "integrity": "sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw==", - "dev": true, - "requires": { - "readable-stream": "^2.3.7", - "triple-beam": "^1.2.0" - } - }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", diff --git a/package.json b/package.json index b826bd739..52408c8f8 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,10 @@ "lib/", "LICENSE", "PATENTS", - "README.md" + "README.md", + "types/index.d.ts" ], + "types": "types/index.d.ts", "browser": { "react-native": false }, @@ -61,6 +63,7 @@ "codecov": "3.7.1", "core-js": "3.6.5", "cross-env": "7.0.2", + "dtslint": "^4.1.3", "eslint": "6.8.0", "eslint-plugin-flowtype": "5.1.2", "eslint-plugin-jsdoc": "30.7.3", @@ -79,12 +82,14 @@ "jest": "24.9.0", "jsdoc": "3.6.3", "jsdoc-babel": "0.5.0", + "jsdoc-plugin-intersection": "^1.0.4", "lint-staged": "10.5.3", "metro-react-native-babel-preset": "0.59.0", "parse-server": "github:parse-community/parse-server#alpha", "prettier": "2.2.1", "regenerator-runtime": "0.13.5", "semantic-release": "17.4.6", + "tsd-jsdoc": "2.5.0", "vinyl-source-stream": "2.0.0" }, "optionalDependencies": { @@ -102,6 +107,8 @@ "watch:react-native": "cross-env PARSE_BUILD=react-native npm run watch", "integration": "cross-env TESTING=1 jasmine --config=jasmine.json", "docs": "jsdoc -c ./jsdoc-conf.json ./src", + "types": "./types/types.sh", + "test:types": "dtslint types", "prepare": "npm run build", "release_docs": "./release_docs.sh", "gulp": "gulp", diff --git a/src/Analytics.js b/src/Analytics.js index 348528077..2fa2869b3 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -48,7 +48,7 @@ import CoreManager from './CoreManager'; * 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 + * @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/src/AnonymousUtils.js b/src/AnonymousUtils.js index f9de0f0ff..62c59b504 100644 --- a/src/AnonymousUtils.js +++ b/src/AnonymousUtils.js @@ -66,7 +66,7 @@ const AnonymousUtils = { * @function logIn * @name Parse.AnonymousUtils.logIn * @param {object} options MasterKey / SessionToken. - * @returns {Promise} Logged in user + * @returns {Promise} Logged in user * @static */ logIn(options?: RequestOptions): Promise { @@ -81,7 +81,7 @@ const AnonymousUtils = { * @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 + * @returns {Promise} Linked with User * @static */ link(user: ParseUser, options?: RequestOptions): Promise { diff --git a/src/Cloud.js b/src/Cloud.js index 59797e9fd..bf291b165 100644 --- a/src/Cloud.js +++ b/src/Cloud.js @@ -35,14 +35,14 @@ import type { RequestOptions } from './RESTController'; * @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 + * @param {object} [data] The parameters to send to the cloud function. + * @param {RequestOptions} [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 { options = options || {}; - if (typeof name !== 'string' || name.length === 0) { throw new TypeError('Cloud function name must be a string.'); } @@ -66,7 +66,7 @@ export function run(name: string, data: mixed, options: RequestOptions): Promise * * @function getJobsData * @name Parse.Cloud.getJobsData - * @returns {Promise} A promise that will be resolved with the result + * @returns {Promise} A promise that will be resolved with the result * of the function. */ export function getJobsData(): Promise { @@ -83,7 +83,7 @@ export function getJobsData(): Promise { * @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 + * @returns {Promise} A promise that will be resolved with the jobStatusId * of the job. */ export function startJob(name: string, data: mixed): Promise { @@ -102,7 +102,7 @@ export function startJob(name: string, data: mixed): Promise { * @function getJobStatus * @name Parse.Cloud.getJobStatus * @param {string} jobStatusId The Id of Job Status. - * @returns {Parse.Object} Status of Job. + * @returns {Promise} Status of Job. */ export function getJobStatus(jobStatusId: string): Promise { const query = new ParseQuery('_JobStatus'); diff --git a/src/CloudCode.js b/src/CloudCode.js index f25bfa239..217b408c4 100644 --- a/src/CloudCode.js +++ b/src/CloudCode.js @@ -6,7 +6,9 @@ * @function define * @name Parse.Cloud.define * @param {string} name The name of the Cloud Function - * @param {Function} data The Cloud Function to register. This function should take one parameter {@link Parse.Cloud.FunctionRequest} + * @param {Parse.Cloud.FunctionRequestFunc} func The Cloud Function to register + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.FunctionRequestFunc} [validator] An optional function to help validating cloud code. + * @returns {void} */ /** @@ -27,8 +29,9 @@ * * @function afterDelete * @name Parse.Cloud.afterDelete - * @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass. - * @param {Function} func The function to run after a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run after a delete. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.TriggerRequestFunc} [validator] An optional function to help validating cloud code. */ /** @@ -51,8 +54,59 @@ * * @function afterSave * @name Parse.Cloud.afterSave - * @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. - * @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run after a save. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.TriggerRequestFunc} [validator] An optional function to help validating cloud code. + */ + +/** + * Registers a before find function. + * + * **Available in Cloud Code only.** + * + * If you want to use beforeFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.beforeFind('MyCustomClass', async (request) => { + * // code here + * }, (request) => { + * // validation code here + * }); + * + * Parse.Cloud.beforeFind(Parse.User, async (request) => { + * // code here + * }, { ...validationObject }); + *``` + * + * @function beforeFind + * @name Parse.Cloud.beforeFind + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the before find function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.BeforeFindRequestFunc} func The function to run before a find. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.BeforeFindRequestFunc} [validator] An optional function to help validating cloud code. + */ + +/** + * Registers an after find function. + * + * **Available in Cloud Code only.** + * + * If you want to use afterFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. + * ``` + * Parse.Cloud.afterFind('MyCustomClass', async (request) => { + * // code here + * }, (request) => { + * // validation code here + * }); + * + * Parse.Cloud.afterFind(Parse.User, async (request) => { + * // code here + * }, { ...validationObject }); + *``` + * + * @function afterFind + * @name Parse.Cloud.afterFind + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the after find function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.AfterFindRequestFunc} func The function to run before a find. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.AfterFindRequestFunc} [validator] An optional function to help validating cloud code. */ /** @@ -73,8 +127,72 @@ * * @function beforeDelete * @name Parse.Cloud.beforeDelete - * @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass. - * @param {Function} func The function to run before a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run before a delete. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.TriggerRequestFunc} [validator] An optional function to help validating cloud code. + */ + +/** + * + * Registers the before login function. + * + * **Available in Cloud Code only.** + * + * This function provides further control + * in validating a login attempt. Specifically, + * it is triggered after a user enters + * correct credentials (or other valid authData), + * but prior to a session being generated. + * + * ``` + * Parse.Cloud.beforeLogin((request) => { + * // code here + * }) + * + * ``` + * + * @function beforeLogin + * @name Parse.Cloud.beforeLogin + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run before a login. + */ + +/** + * + * Registers the after login function. + * + * **Available in Cloud Code only.** + * + * This function is triggered after a user logs in successfully, + * and after a _Session object has been created. + * + * ``` + * Parse.Cloud.afterLogin((request) => { + * // code here + * }); + * ``` + * + * @function afterLogin + * @name Parse.Cloud.afterLogin + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run after a login. + */ + +/** + * + * Registers the after logout function. + * + * **Available in Cloud Code only.** + * + * This function is triggered after a user logs out. + * + * ``` + * Parse.Cloud.afterLogout((request) => { + * // code here + * }); + * ``` + * + * @function afterLogout + * @name Parse.Cloud.afterLogout + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run after a logout. */ /** @@ -97,8 +215,9 @@ * * @function beforeSave * @name Parse.Cloud.beforeSave - * @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. - * @param {Function} func The function to run before a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run before a save. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.TriggerRequestFunc} [validator] An optional function to help validating cloud code. */ /** @@ -141,7 +260,8 @@ * * @function beforeSaveFile * @name Parse.Cloud.beforeSaveFile - * @param {Function} func The function to run before a file saves. This function should take one parameter, a {@link Parse.Cloud.FileTriggerRequest}. + * @param {Parse.Cloud.FileTriggerRequestFunc} func The function to run before saving a file. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.FileTriggerRequestFunc} [validator] An optional function to help validating cloud code. */ /** @@ -161,15 +281,63 @@ * await fileObject.save({ sessionToken: user.getSessionToken() }); * }); * - * @method afterSaveFile + * @function afterSaveFile * @name Parse.Cloud.afterSaveFile - * @param {Function} func The function to run after a file saves. This function should take one parameter, a {@link Parse.Cloud.FileTriggerRequest}. + * @param {Parse.Cloud.FileTriggerRequestFunc} func The function to run after saving a file. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.FileTriggerRequestFunc} [validator] An optional function to help validating cloud code. + */ + +/** + * Registers a before delete file function. + * + * **Available in Cloud Code only.** + * + * ``` + * Parse.Cloud.beforeDeleteFile(async (request) => { + * // code here + * }, (request) => { + * // validation code here + * }); + * + * Parse.Cloud.beforeDeleteFile(async (request) => { + * // code here + * }, { ...validationObject }); + *``` + * + * @function beforeDeleteFile + * @name Parse.Cloud.beforeDeleteFile + * @param {Parse.Cloud.FileTriggerRequestFunc} func The function to run before deleting a file. + * @param {(Parse.Cloud.ValidatorObject|Parse.Cloud.FileTriggerRequestFunc)} [validator] An optional function to help validating cloud code. + */ + +/** + * Registers an after delete file function. + * + * **Available in Cloud Code only.** + * + * ``` + * Parse.Cloud.afterDeleteFile(async (request) => { + * // code here + * }, (request) => { + * // validation code here + * }); + * + * Parse.Cloud.afterDeleteFile(async (request) => { + * // code here + * }, { ...validationObject }); + *``` + * + * @function afterDeleteFile + * @name Parse.Cloud.afterDeleteFile + * @param {Parse.Cloud.FileTriggerRequestFunc} func The function to after before deleting a file. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.FileTriggerRequestFunc} [validator] An optional function to help validating cloud code. */ /** * @function beforeConnect * @name Parse.Cloud.beforeConnect - * @param {Function} func The function to before connection is made. This function can be async and should take just one parameter, {@link Parse.Cloud.ConnectTriggerRequest}. + * @param {Parse.Cloud.ConnectTriggerRequestFunc} func The function to before connection is made. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.ConnectTriggerRequestFunc} [validator] An optional function to help validating cloud code. */ /** * @@ -188,11 +356,25 @@ */ /** - * @function beforeSubscribe - * @name Parse.Cloud.beforeSubscribe - * @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the before subscription function for. This can instead be a String that is the className of the subclass. - * @param {Function} func The function to run before a subscription. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}. + * Sends an email through the Parse Server mail adapter. + * + * **Available in Cloud Code only.** + * **Requires a mail adapter to be configured for Parse Server.** + * + * ``` + * Parse.Cloud.sendEmail({ + * from: 'Example ', + * to: 'contact@example.com', + * subject: 'Test email', + * text: 'This email is a test.' + * }); + *``` + * + * @function sendEmail + * @name Parse.Cloud.sendEmail + * @param {object} data The object of the mail data to send. */ + /** * * Registers a before subscribe function. @@ -208,6 +390,54 @@ * query.select("name","year") * }); * ``` + * + * @function beforeSubscribe + * @name Parse.Cloud.beforeSubscribe + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the before subscription function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.TriggerRequestFunc} func The function to run before a subscription. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.TriggerRequestFunc} [validator] An optional function to help validating cloud code. + * + */ + +/** + * Registers an after live query server event function. + * + * **Available in Cloud Code only.** + * + * ``` + * Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => { + * // code here + * }, (request) => { + * // validation code here + * }); + * + * Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => { + * // code here + * }, { ...validationObject }); + *``` + * + * @function afterLiveQueryEvent + * @name Parse.Cloud.afterLiveQueryEvent + * @param {(string | Parse.Object)} ParseClass The Parse.Object subclass to register the after live query event function for. This can instead be a String that is the className of the subclass. + * @param {Parse.Cloud.LiveQueryEventTriggerFunc} func The function to run after a live query event. + * @param {Parse.Cloud.ValidatorObject|Parse.Cloud.LiveQueryEventTriggerFunc} [validator] An optional function to help validating cloud code. + */ + +/** + * Registers an on live query server event function. + * + * **Available in Cloud Code only.** + * + * ``` + * Parse.Cloud.onLiveQueryEvent((event) => { + * // code here + * }); + * + *``` + * + * @function onLiveQueryEvent + * @name Parse.Cloud.onLiveQueryEvent + * @param {Parse.Cloud.LiveQueryEventTriggerFunc} func The function to run on a live query event. */ /** @@ -244,21 +474,34 @@ * @function job * @name Parse.Cloud.job * @param {string} name The name of the Background Job - * @param {Function} func The Background Job to register. This function should take two parameters a {@link Parse.Cloud.JobRequest} and a {@link Parse.Cloud.JobStatus} + * @param {Parse.Cloud.JobRequestFunc} func The Background Job to register. * */ +/** + * @callback Parse.Cloud.TriggerRequestFunc + * @param {Parse.Cloud.TriggerRequest} request The request object + * @returns {any} + */ + /** * @typedef Parse.Cloud.TriggerRequest - * @property {string} installationId If set, the installationId triggering the request. + * @property {string} [installationId] If set, the installationId triggering the request. * @property {boolean} master If true, means the master key was used. - * @property {Parse.User} user If set, the user that made the request. + * @property {Parse.User} [user] If set, the user that made the request. * @property {Parse.Object} object The object triggering the hook. * @property {string} ip The IP address of the client making the request. * @property {object} headers The original HTTP headers for the request. * @property {string} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) * @property {object} log The current logger inside Parse Server. - * @property {Parse.Object} original If set, the object, as currently stored. + * @property {Parse.Object} [original] If set, the object, as currently stored. + * @property {object.} context If set, the context of the request + */ + +/** + * @callback Parse.Cloud.FileTriggerRequestFunc + * @param {Parse.Cloud.FileTriggerRequest} request The request object + * @returns {any} */ /** @@ -266,13 +509,21 @@ * @property {string} installationId If set, the installationId triggering the request. * @property {boolean} master If true, means the master key was used. * @property {Parse.User} user If set, the user that made the request. - * @property {Parse.File} file The file triggering the hook. + * @property {Parse.File} file The file that triggered the hook. + * @property {number} fileSize The size of the file in bytes. + * @property {number} contentLength The value from Content-Length header * @property {string} ip The IP address of the client making the request. * @property {object} headers The original HTTP headers for the request. - * @property {string} triggerName The name of the trigger (`beforeSaveFile`, `afterSaveFile`, ...) + * @property {string} triggerName The name of the trigger (`beforeSaveFile`, `afterSaveFile`) * @property {object} log The current logger inside Parse Server. */ +/** + * @callback Parse.Cloud.ConnectTriggerRequestFunc + * @param {Parse.Cloud.ConnectTriggerRequest} request The request object + * @returns {any} + */ + /** * @typedef Parse.Cloud.ConnectTriggerRequest * @property {string} installationId If set, the installationId triggering the request. @@ -283,35 +534,138 @@ * @property {string} sessionToken If set, the session of the user that made the request. */ +/** + * @callback Parse.Cloud.LiveQueryEventTriggerFunc + * @param {Parse.Cloud.LiveQueryEventTrigger} request The request object + * @returns {any} + */ + +/** + * @typedef Parse.Cloud.LiveQueryEventTrigger + * @property {string} [installationId] If set, the installationId triggering the request. + * @property {boolean} useMasterKey If true, means the master key was used. + * @property {Parse.User} [user] If set, the user that made the request. + * @property {string} [sessionToken] If set, the session of the user that made the request. + * @property {string} event The live query event that triggered the request. + * @property {Parse.Object} object The object triggering the hook. + * @property {Parse.Object} [original] If set, the object, as currently stored. + * @property {number} clients The number of clients connected. + * @property {number} subscriptions The number of subscriptions connected. + * @property {boolean} sendEvent If the LiveQuery event should be sent to the client. Set to false to prevent LiveQuery from pushing to the client. + */ + +/** + * @callback Parse.Cloud.BeforeFindRequestFunc + * @param {Parse.Cloud.BeforeFindRequest} request The request object + * @returns {any} + */ + +/** + * @typedef Parse.Cloud.BeforeFindRequest + * @property {string} [installationId] If set, the installationId triggering the request. + * @property {boolean} master If true, means the master key was used. + * @property {Parse.User} [user] If set, the user that made the request. + * @property {Parse.Query} query The query triggering the hook. + * @property {string} ip The IP address of the client making the request. + * @property {object} headers The original HTTP headers for the request. + * @property {string} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) + * @property {object} log The current logger inside Parse Server. + * @property {boolean} isGet whether the query a `get` or a `find` + * @property {boolean} count whether the query a `get` or a `find` + * @property {Parse.Cloud.ReadPreferenceOption} readPreference read preferences of the query + */ + +/** + * @enum + * @name Parse.Cloud.ReadPreferenceOption + * @property {'PRIMARY'} Primary Primary read preference option + * @property {'PRIMARY_PREFERRED'} PrimaryPreferred Prefer primary + * @property {'SECONDARY'} Secondary Secondary read preference option + * @property {'SECONDARY_PREFERRED'} SecondaryPreferred Prefer secondary + * @property {'NEAREST'} Nearest Nearest read preference option + */ + +/** + * @callback Parse.Cloud.AfterFindRequestFunc + * @param {Parse.Cloud.AfterFindRequest} request The request object + * @returns {any} + */ + +/** + * @typedef Parse.Cloud.AfterFindRequest + * @property {string} [installationId] If set, the installationId triggering the request. + * @property {boolean} master If true, means the master key was used. + * @property {Parse.User} [user] If set, the user that made the request. + * @property {Parse.Query} query The query triggering the hook. + * @property {Array} results The results the query yielded. + * @property {string} ip The IP address of the client making the request. + * @property {object} headers The original HTTP headers for the request. + * @property {string} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...) + * @property {object} log The current logger inside Parse Server. + */ + +/** + * @callback Parse.Cloud.FunctionRequestFunc + * @param {Parse.Cloud.FunctionRequest} request The request object + * @returns {void} + */ + /** * @typedef Parse.Cloud.FunctionRequest - * @property {string} installationId If set, the installationId triggering the request. + * @property {string} [installationId] If set, the installationId triggering the request. * @property {boolean} master If true, means the master key was used. - * @property {Parse.User} user If set, the user that made the request. - * @property {object} params The params passed to the cloud function. + * @property {Parse.User} [user] If set, the user that made the request. + * @property {object.} params The params passed to the cloud function. + * @property {object} log The current logger inside Parse Server. */ /** - * @typedef Parse.Cloud.JobRequest - * @property {object} params The params passed to the background job. + * @callback Parse.Cloud.JobRequestFunc + * @param {Parse.Cloud.JobRequest} request The request object */ /** - * @typedef Parse.Cloud.JobStatus + * @typedef Parse.Cloud.JobRequest + * @property {object.} params The params passed to the background job. * @property {Function} error If error is called, will end the job unsuccessfully with an optional completion message to be stored in the job status. * @property {Function} message If message is called with a string argument, will update the current message to be stored in the job status. * @property {Function} success If success is called, will end the job successfullly with the optional completion message to be stored in the job status. */ +/** + * @callback Parse.Cloud.JobRequestMessage + * @param {string} message The request object + */ + +/** + * @typedef Parse.Cloud.ValidatorObject + * @property {boolean} requireUser whether the cloud trigger requires a user. + * @property {boolean} requireMaster whether the cloud trigger requires a master key. + * @property {boolean} validateMasterKey whether the validator should run if masterKey is provided. Defaults to false. + * @property {boolean} skipWithMasterKey whether the cloud code function should be ignored using a masterKey. + * @property {Array | Function}requireAnyUserRoles If set, request.user has to be part of at least one roles name to make the request. If set to a function, function must return role names. + * @property {Array | Function}requireAllUserRoles If set, request.user has to be part all roles name to make the request. If set to a function, function must return role names. + * @property {object. | Array} requireUserKeys If set, keys required on request.user to make the request. + * @property {object. | Array} fields if an array of strings, validator will look for keys in request.params, and throw if not provided. If Object, fields to validate. If the trigger is a cloud function, `request.params` will be validated, otherwise `request.object`. + */ + +/** + * @typedef Parse.Cloud.ValidatorObjectFieldOptions + * @property {any} type expected type of data for field. + * @property {boolean} constant whether the field can be modified on the object. + * @property {any} default default value if field is `null`, or initial value `constant` is `true`. + * @property {Array | Function | any} options array of options that the field can be, function to validate field, or single value. Throw an error if value is invalid. + * @property {string} error custom error message if field is invalid. + */ + /** * @typedef Parse.Cloud.HTTPOptions - * @property {string | object} body The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. - * @property {Function} error The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object. - * @property {boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false. - * @property {object} headers The headers for the request. - * @property {string} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified. - * @property {string | object} params The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott. - * @property {Function} success The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object. + * @property {string | object} [body] The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. + * @property {Function} [error] The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object. + * @property {boolean} [followRedirects] Whether to follow redirects caused by HTTP 3xx responses. Defaults to false. + * @property {object} [headers] The headers for the request. + * @property {string} [method] The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified. + * @property {string | object} [params] The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott. * @property {string} url The url to send the request to. */ diff --git a/src/CoreManager.js b/src/CoreManager.js index 188970e5c..2754cab07 100644 --- a/src/CoreManager.js +++ b/src/CoreManager.js @@ -20,14 +20,49 @@ import type { AuthData } from './ParseUser'; import type { PushData } from './Push'; import type { RequestOptions, FullOptions } from './RESTController'; +/** + * @typedef AnalyticsController + * @property {AnalyticsControllerTrackCallback} track + */ + +/** + * @callback AnalyticsControllerTrackCallback + * @param {string} name + * @param {object.} [dimensions] + * @returns {Promise} + */ + type AnalyticsController = { track: (name: string, dimensions: { [key: string]: string }) => Promise, }; + +/** + * @typedef CloudController + * @property {CloudControllerRunStart} run + * @property {CloudControllerGetJobsData} getJobsData + * @property {CloudControllerRunStart} startJob + */ + +/** + * @callback CloudControllerRunStart + * @param {string} name + * @param {any} [data] + * @param {RequestOptions} [options] + * @returns {Promise} + */ + +/** + * @callback CloudControllerGetJobsData + * @param {RequestOptions} [options] + * @returns {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, diff --git a/src/EventuallyQueue.js b/src/EventuallyQueue.js index 8925fda42..eba851665 100644 --- a/src/EventuallyQueue.js +++ b/src/EventuallyQueue.js @@ -43,9 +43,9 @@ const EventuallyQueue = { * * @function save * @name Parse.EventuallyQueue.save - * @param {ParseObject} object Parse.Object to be saved eventually + * @param {Parse.Object} 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. + * @returns {Promise} A promise that is fulfilled if object is added to queue. * @static * @see Parse.Object#saveEventually */ @@ -58,9 +58,9 @@ const EventuallyQueue = { * * @function destroy * @name Parse.EventuallyQueue.destroy - * @param {ParseObject} object Parse.Object to be destroyed eventually + * @param {Parse.Object} 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. + * @returns {Promise} A promise that is fulfilled if object is added to queue. * @static * @see Parse.Object#destroyEventually */ @@ -90,7 +90,7 @@ const EventuallyQueue = { * @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. + * @returns {Promise} A promise that is fulfilled if object is added to queue. * @static * @ignore */ @@ -154,7 +154,7 @@ const EventuallyQueue = { * 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. + * @returns {Promise} A promise that is fulfilled when queue is stored. * @static * @ignore */ @@ -167,7 +167,7 @@ const EventuallyQueue = { * 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. + * @returns {Promise} A promise that is fulfilled when queue is stored. * @static * @ignore */ @@ -185,7 +185,7 @@ const EventuallyQueue = { * * @function clear * @name Parse.EventuallyQueue.clear - * @returns {Promise} A promise that is fulfilled when queue is cleared. + * @returns {Promise} A promise that is fulfilled when queue is cleared. * @static */ clear(): Promise { @@ -252,9 +252,9 @@ const EventuallyQueue = { /** * Build queue object and add to queue. * - * @param {ParseObject} object Parse.Object to be processed + * @param {Parse.Object} 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. + * @returns {Promise} A promise that is fulfilled when operation is performed. * @static * @ignore */ diff --git a/src/FacebookUtils.js b/src/FacebookUtils.js index b8ec0fe27..9e02fe5b1 100644 --- a/src/FacebookUtils.js +++ b/src/FacebookUtils.js @@ -165,7 +165,7 @@ const FacebookUtils = { * 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} + * @returns {Promise} */ logIn(permissions, options) { if (!permissions || typeof permissions === 'string') { @@ -203,7 +203,7 @@ const FacebookUtils = { * 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} + * @returns {Promise} */ link(user, permissions, options) { if (!permissions || typeof permissions === 'string') { @@ -226,7 +226,7 @@ const FacebookUtils = { * current user. * @param {object} options Standard options object with success and error * callbacks. - * @returns {Promise} + * @returns {Promise} */ unlink: function (user, options) { if (!initialized) { diff --git a/src/LiveQuerySubscription.js b/src/LiveQuerySubscription.js index 0c5cf1b3d..b5e00c6df 100644 --- a/src/LiveQuerySubscription.js +++ b/src/LiveQuerySubscription.js @@ -95,10 +95,10 @@ import { resolvingPromise } from './promiseUtils'; * * });

* - * @alias Parse.LiveQuerySubscription */ class Subscription extends EventEmitter { - /* + /** + * @alias Parse.LiveQuerySubscription * @param {string} id - subscription id * @param {string} query - query to subscribe to * @param {string} sessionToken - optional session token @@ -119,7 +119,7 @@ class Subscription extends EventEmitter { /** * Close the subscription * - * @returns {Promise} + * @returns {Promise} */ unsubscribe(): Promise { return CoreManager.getLiveQueryController() @@ -129,6 +129,22 @@ class Subscription extends EventEmitter { this.emit('close'); }); } + /** + * LiveQuery event Callback + * + * @callback LiveQueryEventCallback + * @param {Parse.Object} object LiveQuery event object + * @param {Parse.Object} [original] LiveQuery event original object + */ + + /** + * @param {string} event + * @param {LiveQueryEventCallback} callback + */ + + on(event, callback) { + super.on(event, callback); + } } export default Subscription; diff --git a/src/Parse.js b/src/Parse.js index 7554b3c80..8d3891757 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -82,7 +82,7 @@ const Parse = { /** * Returns information regarding the current server's health * - * @returns {Promise} + * @returns {Promise} * @static */ getServerHealth() { @@ -167,7 +167,7 @@ const Parse = { }, /** - * @member {string} Parse.encryptedUser + * @member {boolean} Parse.encryptedUser * @static */ set encryptedUser(value) { @@ -199,6 +199,16 @@ const Parse = { return CoreManager.get('IDEMPOTENCY'); }, + /** + * @typedef Parse.AuthData + * @type {any} + */ + + /** + * @typedef Parse.AuthProvider + * @type {any} + */ + /** * @member {boolean} Parse.allowCustomObjectId * @static @@ -227,6 +237,19 @@ Parse.Polygon = require('./ParsePolygon').default; Parse.Installation = require('./ParseInstallation').default; Parse.LocalDatastore = require('./LocalDatastore'); Parse.Object = require('./ParseObject').default; +/** + * @static + * @typedef Parse.Op + * @property {any} Set + * @property {any} Unset + * @property {any} Increment + * @property {any} Add + * @property {any} Remove + * @property {any} AddUnique + * @property {any} Relation + * + */ + Parse.Op = { Set: ParseOp.SetOp, Unset: ParseOp.UnsetOp, diff --git a/src/ParseACL.js b/src/ParseACL.js index 2b6225573..7b20add6e 100644 --- a/src/ParseACL.js +++ b/src/ParseACL.js @@ -29,13 +29,13 @@ const PUBLIC_KEY = '*'; * Parse.Object to restrict access to only a subset of users * of your application.

* - * @alias Parse.ACL */ class ParseACL { permissionsById: ByIdMap; /** - * @param {(Parse.User | object)} arg1 The user to initialize the ACL for + * @alias Parse.ACL + * @param {(Parse.User | object)} [arg1] The user to initialize the ACL for */ constructor(arg1: ParseUser | ByIdMap) { this.permissionsById = {}; @@ -80,7 +80,7 @@ class ParseACL { /** * Returns whether this ACL is equal to another object * - * @param {ParseACL} other The other object's ACL to compare to + * @param {Parse.ACL} other The other object's ACL to compare to * @returns {boolean} */ equals(other: ParseACL): boolean { diff --git a/src/ParseCLP.js b/src/ParseCLP.js index 179132829..92226b050 100644 --- a/src/ParseCLP.js +++ b/src/ParseCLP.js @@ -120,12 +120,12 @@ VALID_PERMISSIONS_EXTENDED.set('protectedFields', {}); * setRoleAddFieldAccess(role: Role, allowed: boolean) *

* - * @alias Parse.CLP */ class ParseCLP { permissionsMap: PermissionsMap; /** + * @alias Parse.CLP * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for */ constructor(userId: ParseUser | ParseRole | PermissionsMap) { diff --git a/src/ParseConfig.js b/src/ParseConfig.js index de77a8097..fe9a95b70 100644 --- a/src/ParseConfig.js +++ b/src/ParseConfig.js @@ -22,13 +22,14 @@ import type { RequestOptions } from './RESTController'; * Parse.Config is a local representation of configuration data that * can be set from the Parse dashboard. * - * @alias Parse.Config */ class ParseConfig { attributes: { [key: string]: any }; _escapedAttributes: { [key: string]: any }; - + /** + * @alias Parse.Config + */ constructor() { this.attributes = {}; this._escapedAttributes = {}; @@ -86,7 +87,7 @@ class ParseConfig { *
  • 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 + * @returns {Promise} A promise that is resolved with a newly-created * configuration object when the get completes. */ static get(options: RequestOptions = {}) { @@ -104,7 +105,7 @@ class ParseConfig { * 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 + * @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 }) { diff --git a/src/ParseError.js b/src/ParseError.js index e8d11ad84..1a2d4752a 100644 --- a/src/ParseError.js +++ b/src/ParseError.js @@ -10,12 +10,13 @@ /** * Constructs a new Parse.Error object with the given code and message. * - * @alias Parse.Error */ class ParseError extends Error { /** + * @alias Parse.Error * @param {number} code An error code constant from Parse.Error. * @param {string} message A detailed description of the error. + * */ constructor(code, message) { super(message); @@ -34,32 +35,33 @@ class ParseError extends Error { /** * Error code indicating some error other than those enumerated here. * - * @property {number} OTHER_CAUSE - * @static + * @name ParseError.OTHER_CAUSE + * @type {number} + * */ ParseError.OTHER_CAUSE = -1; /** * Error code indicating that something has gone wrong with the server. * - * @property {number} INTERNAL_SERVER_ERROR - * @static + * @name ParseError.INTERNAL_SERVER_ERROR + * @type {number} */ ParseError.INTERNAL_SERVER_ERROR = 1; /** * Error code indicating the connection to the Parse servers failed. * - * @property {number} CONNECTION_FAILED - * @static + * @name ParseError.CONNECTION_FAILED + * @type {number} */ ParseError.CONNECTION_FAILED = 100; /** * Error code indicating the specified object doesn't exist. * - * @property {number} OBJECT_NOT_FOUND - * @static + * @name ParseError.OBJECT_NOT_FOUND + * @type {number} */ ParseError.OBJECT_NOT_FOUND = 101; @@ -67,8 +69,8 @@ ParseError.OBJECT_NOT_FOUND = 101; * Error code indicating you tried to query with a datatype that doesn't * support it, like exact matching an array or object. * - * @property {number} INVALID_QUERY - * @static + * @name ParseError.INVALID_QUERY + * @type {number} */ ParseError.INVALID_QUERY = 102; @@ -77,16 +79,16 @@ ParseError.INVALID_QUERY = 102; * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the * only valid characters. * - * @property {number} INVALID_CLASS_NAME - * @static + * @name ParseError.INVALID_CLASS_NAME + * @type {number} */ ParseError.INVALID_CLASS_NAME = 103; /** * Error code indicating an unspecified object id. * - * @property {number} MISSING_OBJECT_ID - * @static + * @name ParseError.MISSING_OBJECT_ID + * @type {number} */ ParseError.MISSING_OBJECT_ID = 104; @@ -94,8 +96,8 @@ ParseError.MISSING_OBJECT_ID = 104; * Error code indicating an invalid key name. Keys are case-sensitive. They * must start with a letter, and a-zA-Z0-9_ are the only valid characters. * - * @property {number} INVALID_KEY_NAME - * @static + * @name ParseError.INVALID_KEY_NAME + * @type {number} */ ParseError.INVALID_KEY_NAME = 105; @@ -103,8 +105,8 @@ ParseError.INVALID_KEY_NAME = 105; * Error code indicating a malformed pointer. You should not see this unless * you have been mucking about changing internal Parse code. * - * @property {number} INVALID_POINTER - * @static + * @name ParseError.INVALID_POINTER + * @type {number} */ ParseError.INVALID_POINTER = 106; @@ -113,8 +115,8 @@ ParseError.INVALID_POINTER = 106; * either indicates you have done something unusual with modifying how * things encode to JSON, or the network is failing badly. * - * @property {number} INVALID_JSON - * @static + * @name ParseError.INVALID_JSON + * @type {number} */ ParseError.INVALID_JSON = 107; @@ -122,24 +124,24 @@ ParseError.INVALID_JSON = 107; * Error code indicating that the feature you tried to access is only * available internally for testing purposes. * - * @property {number} COMMAND_UNAVAILABLE - * @static + * @name ParseError.COMMAND_UNAVAILABLE + * @type {number} */ ParseError.COMMAND_UNAVAILABLE = 108; /** * You must call Parse.initialize before using the Parse library. * - * @property {number} NOT_INITIALIZED - * @static + * @name ParseError.NOT_INITIALIZED + * @type {number} */ ParseError.NOT_INITIALIZED = 109; /** * Error code indicating that a field was set to an inconsistent type. * - * @property {number} INCORRECT_TYPE - * @static + * @name ParseError.INCORRECT_TYPE + * @type {number} */ ParseError.INCORRECT_TYPE = 111; @@ -148,40 +150,40 @@ ParseError.INCORRECT_TYPE = 111; * an empty string (the broadcast channel) or contains only a-zA-Z0-9_ * characters and starts with a letter. * - * @property {number} INVALID_CHANNEL_NAME - * @static + * @name ParseError.INVALID_CHANNEL_NAME + * @type {number} */ ParseError.INVALID_CHANNEL_NAME = 112; /** * Error code indicating that push is misconfigured. * - * @property {number} PUSH_MISCONFIGURED - * @static + * @name ParseError.PUSH_MISCONFIGURED + * @type {number} */ ParseError.PUSH_MISCONFIGURED = 115; /** * Error code indicating that the object is too large. * - * @property {number} OBJECT_TOO_LARGE - * @static + * @name ParseError.OBJECT_TOO_LARGE + * @type {number} */ ParseError.OBJECT_TOO_LARGE = 116; /** * Error code indicating that the operation isn't allowed for clients. * - * @property {number} OPERATION_FORBIDDEN - * @static + * @name ParseError.OPERATION_FORBIDDEN + * @type {number} */ ParseError.OPERATION_FORBIDDEN = 119; /** * Error code indicating the result was not found in the cache. * - * @property {number} CACHE_MISS - * @static + * @name ParseError.CACHE_MISS + * @type {number} */ ParseError.CACHE_MISS = 120; @@ -189,8 +191,8 @@ ParseError.CACHE_MISS = 120; * Error code indicating that an invalid key was used in a nested * JSONObject. * - * @property {number} INVALID_NESTED_KEY - * @static + * @name ParseError.INVALID_NESTED_KEY + * @type {number} */ ParseError.INVALID_NESTED_KEY = 121; @@ -199,16 +201,16 @@ ParseError.INVALID_NESTED_KEY = 121; * A valid file name contains only a-zA-Z0-9_. characters and is between 1 * and 128 characters. * - * @property {number} INVALID_FILE_NAME - * @static + * @name ParseError.INVALID_FILE_NAME + * @type {number} */ ParseError.INVALID_FILE_NAME = 122; /** * Error code indicating an invalid ACL was provided. * - * @property {number} INVALID_ACL - * @static + * @name ParseError.INVALID_ACL + * @type {number} */ ParseError.INVALID_ACL = 123; @@ -216,56 +218,56 @@ ParseError.INVALID_ACL = 123; * Error code indicating that the request timed out on the server. Typically * this indicates that the request is too expensive to run. * - * @property {number} TIMEOUT - * @static + * @name ParseError.TIMEOUT + * @type {number} */ ParseError.TIMEOUT = 124; /** * Error code indicating that the email address was invalid. * - * @property {number} INVALID_EMAIL_ADDRESS - * @static + * @name ParseError.INVALID_EMAIL_ADDRESS + * @type {number} */ ParseError.INVALID_EMAIL_ADDRESS = 125; /** * Error code indicating a missing content type. * - * @property {number} MISSING_CONTENT_TYPE - * @static + * @name ParseError.MISSING_CONTENT_TYPE + * @type {number} */ ParseError.MISSING_CONTENT_TYPE = 126; /** * Error code indicating a missing content length. * - * @property {number} MISSING_CONTENT_LENGTH - * @static + * @name ParseError.MISSING_CONTENT_LENGTH + * @type {number} */ ParseError.MISSING_CONTENT_LENGTH = 127; /** * Error code indicating an invalid content length. * - * @property {number} INVALID_CONTENT_LENGTH - * @static + * @name ParseError.INVALID_CONTENT_LENGTH + * @type {number} */ ParseError.INVALID_CONTENT_LENGTH = 128; /** * Error code indicating a file that was too large. * - * @property {number} FILE_TOO_LARGE - * @static + * @name ParseError.FILE_TOO_LARGE + * @type {number} */ ParseError.FILE_TOO_LARGE = 129; /** * Error code indicating an error saving a file. * - * @property {number} FILE_SAVE_ERROR - * @static + * @name ParseError.FILE_SAVE_ERROR + * @type {number} */ ParseError.FILE_SAVE_ERROR = 130; @@ -273,16 +275,16 @@ ParseError.FILE_SAVE_ERROR = 130; * Error code indicating that a unique field was given a value that is * already taken. * - * @property {number} DUPLICATE_VALUE - * @static + * @name ParseError.DUPLICATE_VALUE + * @type {number} */ ParseError.DUPLICATE_VALUE = 137; /** * Error code indicating that a role's name is invalid. * - * @property {number} INVALID_ROLE_NAME - * @static + * @name ParseError.INVALID_ROLE_NAME + * @type {number} */ ParseError.INVALID_ROLE_NAME = 139; @@ -290,64 +292,64 @@ ParseError.INVALID_ROLE_NAME = 139; * Error code indicating that an application quota was exceeded. Upgrade to * resolve. * - * @property {number} EXCEEDED_QUOTA - * @static + * @name ParseError.EXCEEDED_QUOTA + * @type {number} */ ParseError.EXCEEDED_QUOTA = 140; /** * Error code indicating that a Cloud Code script failed. * - * @property {number} SCRIPT_FAILED - * @static + * @name ParseError.SCRIPT_FAILED + * @type {number} */ ParseError.SCRIPT_FAILED = 141; /** * Error code indicating that a Cloud Code validation failed. * - * @property {number} VALIDATION_ERROR - * @static + * @name ParseError.VALIDATION_ERROR + * @type {number} */ ParseError.VALIDATION_ERROR = 142; /** * Error code indicating that invalid image data was provided. * - * @property {number} INVALID_IMAGE_DATA - * @static + * @name ParseError.INVALID_IMAGE_DATA + * @type {number} */ ParseError.INVALID_IMAGE_DATA = 143; /** * Error code indicating an unsaved file. * - * @property {number} UNSAVED_FILE_ERROR - * @static + * @name ParseError.UNSAVED_FILE_ERROR + * @type {number} */ ParseError.UNSAVED_FILE_ERROR = 151; /** * Error code indicating an invalid push time. * - * @property {number} INVALID_PUSH_TIME_ERROR - * @static + * @name ParseError.INVALID_PUSH_TIME_ERROR + * @type {number} */ ParseError.INVALID_PUSH_TIME_ERROR = 152; /** * Error code indicating an error deleting a file. * - * @property {number} FILE_DELETE_ERROR - * @static + * @name ParseError.FILE_DELETE_ERROR + * @type {number} */ ParseError.FILE_DELETE_ERROR = 153; /** * Error code indicating an error deleting an unnamed file. * - * @property {number} FILE_DELETE_UNNAMED_ERROR - * @static + * @name ParseError.FILE_DELETE_UNNAMED_ERROR + * @type {number} */ ParseError.FILE_DELETE_UNNAMED_ERROR = 161; @@ -355,8 +357,8 @@ ParseError.FILE_DELETE_UNNAMED_ERROR = 161; * Error code indicating that the application has exceeded its request * limit. * - * @property {number} REQUEST_LIMIT_EXCEEDED - * @static + * @name ParseError.REQUEST_LIMIT_EXCEEDED + * @type {number} */ ParseError.REQUEST_LIMIT_EXCEEDED = 155; @@ -364,72 +366,72 @@ ParseError.REQUEST_LIMIT_EXCEEDED = 155; * Error code indicating that the request was a duplicate and has been discarded due to * idempotency rules. * - * @property {number} DUPLICATE_REQUEST - * @static + * @name ParseError.DUPLICATE_REQUEST + * @type {number} */ ParseError.DUPLICATE_REQUEST = 159; /** * Error code indicating an invalid event name. * - * @property {number} INVALID_EVENT_NAME - * @static + * @name ParseError.INVALID_EVENT_NAME + * @type {number} */ ParseError.INVALID_EVENT_NAME = 160; /** * Error code indicating that a field had an invalid value. * - * @property {number} INVALID_VALUE - * @static + * @name ParseError.INVALID_VALUE + * @type {number} */ ParseError.INVALID_VALUE = 162; /** * Error code indicating that the username is missing or empty. * - * @property {number} USERNAME_MISSING - * @static + * @name ParseError.USERNAME_MISSING + * @type {number} */ ParseError.USERNAME_MISSING = 200; /** * Error code indicating that the password is missing or empty. * - * @property {number} PASSWORD_MISSING - * @static + * @name ParseError.PASSWORD_MISSING + * @type {number} */ ParseError.PASSWORD_MISSING = 201; /** * Error code indicating that the username has already been taken. * - * @property {number} USERNAME_TAKEN - * @static + * @name ParseError.USERNAME_TAKEN + * @type {number} */ ParseError.USERNAME_TAKEN = 202; /** * Error code indicating that the email has already been taken. * - * @property {number} EMAIL_TAKEN - * @static + * @name ParseError.EMAIL_TAKEN + * @type {number} */ ParseError.EMAIL_TAKEN = 203; /** * Error code indicating that the email is missing, but must be specified. * - * @property {number} EMAIL_MISSING - * @static + * @name ParseError.EMAIL_MISSING + * @type {number} */ ParseError.EMAIL_MISSING = 204; /** * Error code indicating that a user with the specified email was not found. * - * @property {number} EMAIL_NOT_FOUND - * @static + * @name ParseError.EMAIL_NOT_FOUND + * @type {number} */ ParseError.EMAIL_NOT_FOUND = 205; @@ -437,16 +439,16 @@ ParseError.EMAIL_NOT_FOUND = 205; * Error code indicating that a user object without a valid session could * not be altered. * - * @property {number} SESSION_MISSING - * @static + * @name ParseError.SESSION_MISSING + * @type {number} */ ParseError.SESSION_MISSING = 206; /** * Error code indicating that a user can only be created through signup. * - * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP - * @static + * @name ParseError.MUST_CREATE_USER_THROUGH_SIGNUP + * @type {number} */ ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207; @@ -454,32 +456,32 @@ ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207; * Error code indicating that an an account being linked is already linked * to another user. * - * @property {number} ACCOUNT_ALREADY_LINKED - * @static + * @name ParseError.ACCOUNT_ALREADY_LINKED + * @type {number} */ ParseError.ACCOUNT_ALREADY_LINKED = 208; /** * Error code indicating that the current session token is invalid. * - * @property {number} INVALID_SESSION_TOKEN - * @static + * @name ParseError.INVALID_SESSION_TOKEN + * @type {number} */ ParseError.INVALID_SESSION_TOKEN = 209; /** * Error code indicating an error enabling or verifying MFA * - * @property {number} MFA_ERROR - * @static + * @name ParseError.MFA_ERROR + * @type {number} */ ParseError.MFA_ERROR = 210; /** * Error code indicating that a valid MFA token must be provided * - * @property {number} MFA_TOKEN_REQUIRED - * @static + * @name ParseError.MFA_TOKEN_REQUIRED + * @type {number} */ ParseError.MFA_TOKEN_REQUIRED = 211; @@ -487,8 +489,8 @@ ParseError.MFA_TOKEN_REQUIRED = 211; * Error code indicating that a user cannot be linked to an account because * that account's id could not be found. * - * @property {number} LINKED_ID_MISSING - * @static + * @name ParseError.LINKED_ID_MISSING + * @type {number} */ ParseError.LINKED_ID_MISSING = 250; @@ -496,8 +498,8 @@ ParseError.LINKED_ID_MISSING = 250; * Error code indicating that a user with a linked (e.g. Facebook) account * has an invalid session. * - * @property {number} INVALID_LINKED_SESSION - * @static + * @name ParseError.INVALID_LINKED_SESSION + * @type {number} */ ParseError.INVALID_LINKED_SESSION = 251; @@ -505,16 +507,16 @@ ParseError.INVALID_LINKED_SESSION = 251; * Error code indicating that a service being linked (e.g. Facebook or * Twitter) is unsupported. * - * @property {number} UNSUPPORTED_SERVICE - * @static + * @name ParseError.UNSUPPORTED_SERVICE + * @type {number} */ ParseError.UNSUPPORTED_SERVICE = 252; /** * Error code indicating an invalid operation occured on schema * - * @property {number} INVALID_SCHEMA_OPERATION - * @static + * @name ParseError.INVALID_SCHEMA_OPERATION + * @type {number} */ ParseError.INVALID_SCHEMA_OPERATION = 255; @@ -523,16 +525,16 @@ ParseError.INVALID_SCHEMA_OPERATION = 255; * have an "errors" property, which is an array of error objects with more * detail about each error that occurred. * - * @property {number} AGGREGATE_ERROR - * @static + * @name ParseError.AGGREGATE_ERROR + * @type {number} */ ParseError.AGGREGATE_ERROR = 600; /** * Error code indicating the client was unable to read an input file. * - * @property {number} FILE_READ_ERROR - * @static + * @name ParseError.FILE_READ_ERROR + * @type {number} */ ParseError.FILE_READ_ERROR = 601; @@ -542,8 +544,8 @@ ParseError.FILE_READ_ERROR = 601; * Internet Explorer, which strips the body from HTTP responses that have * a non-2XX status code. * - * @property {number} X_DOMAIN_REQUEST - * @static + * @name ParseError.X_DOMAIN_REQUEST + * @type {number} */ ParseError.X_DOMAIN_REQUEST = 602; diff --git a/src/ParseFile.js b/src/ParseFile.js index 9470b4813..01e0cbe0e 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -67,7 +67,6 @@ function b64Digit(number: number): string { * A Parse.File is a local representation of a file that is saved to the Parse * cloud. * - * @alias Parse.File */ class ParseFile { _name: string; @@ -80,11 +79,11 @@ class ParseFile { _tags: ?Object; /** - * @param name {String} The file's name. This will be prefixed by a unique + * @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: + * @param {Array | Blob | object} 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. an Object like { uri: "..." } with a uri String. @@ -103,11 +102,12 @@ class ParseFile { * // 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 + * @param {string} [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. - * @param metadata {Object} Optional key value pairs to be stored with file object - * @param tags {Object} Optional key value pairs to be stored with file object + * @param {object} [metadata] Optional key value pairs to be stored with file object + * @param {object} [tags] Optional key value pairs to be stored with file object + * @alias Parse.File */ constructor(name: string, data?: FileData, type?: string, metadata?: Object, tags?: Object) { const specifiedType = type || ''; @@ -168,7 +168,7 @@ class ParseFile { * 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 + * @returns {Promise} Promise that is resolve with base64 data */ async getData(): Promise { if (this._data) { @@ -201,7 +201,8 @@ class ParseFile { * 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 + * @param {object} [options] An object to specify url options + * @param {boolean} [options.forceSecure] Force secure * @returns {string} */ url(options?: { forceSecure?: boolean }): ?string { @@ -237,7 +238,7 @@ class ParseFile { /** * Saves the file to the Parse cloud. * - * @param {object} options + * @param {FullOptions} [options] * * Valid options are:
      *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -255,7 +256,7 @@ class ParseFile { * }); * *
    - * @returns {Promise} Promise that is resolved when the save finishes. + * @returns {Promise} Promise that is resolved when the save finishes. */ save(options?: FullOptions) { options = options || {}; @@ -323,12 +324,12 @@ class ParseFile { * Deletes the file from the Parse cloud. * In Cloud Code and Node only with Master Key. * - * @param {object} options + * @param {FullOptions} [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.
      +   * @returns {Promise} Promise that is resolved when the delete finishes.
          */
         destroy(options?: FullOptions = {}) {
           if (!this._name) {
      @@ -346,6 +347,12 @@ class ParseFile {
           });
         }
       
      +  /**
      +   * Returns a JSON representation of this file.
      +   *
      +   * @returns {object} The JSON representation of the file.
      +   */
      +
         toJSON(): { name: ?string, url: ?string } {
           return {
             __type: 'File',
      diff --git a/src/ParseGeoPoint.js b/src/ParseGeoPoint.js
      index 001dca8a1..e31a79c62 100644
      --- a/src/ParseGeoPoint.js
      +++ b/src/ParseGeoPoint.js
      @@ -32,14 +32,14 @@
        *
        * @alias Parse.GeoPoint
        */
      -/* global navigator */
       class ParseGeoPoint {
         _latitude: number;
         _longitude: number;
       
         /**
      -   * @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
      +   * @alias 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,
      @@ -194,6 +194,7 @@ class ParseGeoPoint {
          * @returns {Parse.GeoPoint} User's current location
          */
         static current() {
      +    /* global navigator */
           return navigator.geolocation.getCurrentPosition(location => {
             return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
           });
      diff --git a/src/ParseInstallation.js b/src/ParseInstallation.js
      index 882214706..d3836926f 100644
      --- a/src/ParseInstallation.js
      +++ b/src/ParseInstallation.js
      @@ -14,6 +14,10 @@ import ParseObject from './ParseObject';
       import type { AttributeMap } from './ObjectStateMutations';
       
       export default class Installation extends ParseObject {
      +  /**
      +   * @alias Parse.Installation
      +   * @param {object} [attributes] The initial set of data to store in the installation.
      +   */
         constructor(attributes: ?AttributeMap) {
           super('_Installation');
           if (attributes && typeof attributes === 'object') {
      diff --git a/src/ParseLiveQuery.js b/src/ParseLiveQuery.js
      index d50dcff06..7e083f10b 100644
      --- a/src/ParseLiveQuery.js
      +++ b/src/ParseLiveQuery.js
      @@ -49,6 +49,11 @@ const LiveQuery = new EventEmitter();
       /**
        * After open is called, the LiveQuery will try to send a connect request
        * to the LiveQuery server.
      + *
      + * @function open
      + * @name Parse.LiveQuery.open
      + * @param {Function} func function to run on open
      + * @static
        */
       LiveQuery.open = async () => {
         const liveQueryClient = await getLiveQueryClient();
      @@ -61,6 +66,11 @@ LiveQuery.open = async () => {
        * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
        * If you call query.subscribe() after this, we'll create a new WebSocket
        * connection to the LiveQuery server.
      + *
      + * @function close
      + * @name Parse.LiveQuery.close
      + * @param {Function} func function to run on close
      + * @static
        */
       LiveQuery.close = async () => {
         const liveQueryClient = await getLiveQueryClient();
      diff --git a/src/ParseObject.js b/src/ParseObject.js
      index 87738d56f..2a0692ed0 100644
      --- a/src/ParseObject.js
      +++ b/src/ParseObject.js
      @@ -45,6 +45,27 @@ import type { RequestOptions, FullOptions } from './RESTController';
       
       const uuidv4 = require('./uuid');
       
      +/**
      + * @typedef Parse.Pointer
      + * @property {string} __type
      + * @property {string} className
      + * @property {string} objectId
      + */
      +
      +/**
      + * Typedef for SaveParams
      + *
      + * @typedef SaveParams
      + * @property {boolean} [cascadeSave] cascadeSave
      + * @property {Attributes} [content] context
      + */
      +
      +/**
      + *
      + * @typedef {FullOptions | SaveParams} SaveOptions
      + *
      + */
      +
       export type Pointer = {
         __type: string,
         className: string,
      @@ -87,6 +108,11 @@ function getServerUrlPath() {
         return url.substr(url.indexOf('/'));
       }
       
      +/**
      + * @typedef Attributes
      + * @type {object.}
      + */
      +
       /**
        * Creates a new model with defined attributes.
        *
      @@ -105,12 +131,16 @@ function getServerUrlPath() {
        *
        * @alias Parse.Object
        */
      +
       class ParseObject {
         /**
      -   * @param {string} className The class name for the object
      -   * @param {object} attributes The initial set of data to store in the object.
      -   * @param {object} options The options for this object instance.
      +   * @alias Parse.Object
      +   * @param {string} [className] The class name for the object
      +   * @param {object} [attributes]  The initial set of data to store in the object.
      +   * @param {object} [options] The options for this object instance.
      +   * @param {boolean} [options.ignoreValidation] Ignore validation
          */
      +
         constructor(
           className: ?string | { className: string, [attr: string]: mixed },
           attributes?: { [attr: string]: mixed },
      @@ -157,6 +187,12 @@ class ParseObject {
       
         /** Prototype getters / setters **/
       
      +  /**
      +   * Object attributes
      +   *
      +   * @type {object}
      +   */
      +
         get attributes(): AttributeMap {
           const stateController = CoreManager.getObjectStateController();
           return Object.freeze(stateController.estimateAttributes(this._getStateIdentifier()));
      @@ -165,9 +201,9 @@ class ParseObject {
         /**
          * The first time this object was saved on the server.
          *
      -   * @property {Date} createdAt
      -   * @returns {Date}
      +   * @type {Date}
          */
      +
         get createdAt(): ?Date {
           return this._getServerData().createdAt;
         }
      @@ -175,8 +211,7 @@ class ParseObject {
         /**
          * The last time this object was updated on the server.
          *
      -   * @property {Date} updatedAt
      -   * @returns {Date}
      +   * @type {Date}
          */
         get updatedAt(): ?Date {
           return this._getServerData().updatedAt;
      @@ -462,8 +497,8 @@ class ParseObject {
         /**
          * Returns a JSON version of the object suitable for saving to Parse.
          *
      -   * @param seen
      -   * @param offline
      +   * @param [seen]
      +   * @param [offline]
          * @returns {object}
          */
         toJSON(seen: Array | void, offline?: boolean): AttributeMap {
      @@ -512,7 +547,7 @@ class ParseObject {
          * 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).
      +   * @param {string} [attr] An attribute name (optional).
          * @returns {boolean}
          */
         dirty(attr?: string): boolean {
      @@ -691,10 +726,10 @@ class ParseObject {
          *   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. + * @param {(string|object)} [value] The value to give it. Optional if `key` is an object. + * @param {object} [options] A set of options for the set. * The only supported option is error. - * @returns {(ParseObject|boolean)} true if the set succeeded. + * @returns {(Parse.Object|boolean)} true if the set succeeded. */ set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean { let changes = {}; @@ -791,8 +826,8 @@ class ParseObject { * exist. * * @param {string} attr The string name of an attribute. - * @param options - * @returns {(ParseObject | boolean)} + * @param {object} [options] + * @returns {(Parse.Object | boolean)} */ unset(attr: string, options?: { [opt: string]: mixed }): ParseObject | boolean { options = options || {}; @@ -804,9 +839,9 @@ class ParseObject { * 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)} + * @param {string} attr The key. + * @param {number} [amount] The amount to increment by (optional). + * @returns {(Parse.Object|boolean)} */ increment(attr: string, amount?: number): ParseObject | boolean { if (typeof amount === 'undefined') { @@ -823,8 +858,8 @@ class ParseObject { * 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)} + * @param [amount] {Number} The amount to decrement by (optional). + * @returns {(Parse.Object | boolean)} */ decrement(attr: string, amount?: number): ParseObject | boolean { if (typeof amount === 'undefined') { @@ -842,7 +877,7 @@ class ParseObject { * * @param attr {String} The key. * @param item {} The item to add. - * @returns {(ParseObject | boolean)} + * @returns {(Parse.Object | boolean)} */ add(attr: string, item: mixed): ParseObject | boolean { return this.set(attr, new AddOp([item])); @@ -853,8 +888,8 @@ class ParseObject { * key. * * @param attr {String} The key. - * @param items {Object[]} The items to add. - * @returns {(ParseObject | boolean)} + * @param items {Array} The items to add. + * @returns {(Parse.Object | boolean)} */ addAll(attr: string, items: Array): ParseObject | boolean { return this.set(attr, new AddOp(items)); @@ -867,7 +902,7 @@ class ParseObject { * * @param attr {String} The key. * @param item {} The object to add. - * @returns {(ParseObject | boolean)} + * @returns {(Parse.Object | boolean)} */ addUnique(attr: string, item: mixed): ParseObject | boolean { return this.set(attr, new AddUniqueOp([item])); @@ -879,8 +914,8 @@ class ParseObject { * not guaranteed. * * @param attr {String} The key. - * @param items {Object[]} The objects to add. - * @returns {(ParseObject | boolean)} + * @param items {Array} The objects to add. + * @returns {(Parse.Object | boolean)} */ addAllUnique(attr: string, items: Array): ParseObject | boolean { return this.set(attr, new AddUniqueOp(items)); @@ -892,7 +927,7 @@ class ParseObject { * * @param attr {String} The key. * @param item {} The object to remove. - * @returns {(ParseObject | boolean)} + * @returns {(Parse.Object | boolean)} */ remove(attr: string, item: mixed): ParseObject | boolean { return this.set(attr, new RemoveOp([item])); @@ -903,8 +938,8 @@ class ParseObject { * with a given key. * * @param attr {String} The key. - * @param items {Object[]} The object to remove. - * @returns {(ParseObject | boolean)} + * @param items {Array} The object to remove. + * @returns {(Parse.Object | boolean)} */ removeAll(attr: string, items: Array): ParseObject | boolean { return this.set(attr, new RemoveOp(items)); @@ -1079,8 +1114,8 @@ class ParseObject { * 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. + * @param {object} [options] + * @returns {(Parse.Object | boolean)} Whether the set passed validation. * @see Parse.Object#set */ setACL(acl: ParseACL, options?: mixed): ParseObject | boolean { @@ -1090,7 +1125,7 @@ class ParseObject { /** * Clears any (or specific) changes to this object made since the last call to save() * - * @param {string} [keys] - specify which fields to revert + * @param {string} keys - specify which fields to revert */ revert(...keys: Array): void { let keysToRevert; @@ -1110,7 +1145,7 @@ class ParseObject { /** * Clears all attributes on a model * - * @returns {(ParseObject | boolean)} + * @returns {(Parse.Object | boolean)} */ clear(): ParseObject | boolean { const attributes = this.attributes; @@ -1131,7 +1166,7 @@ class ParseObject { * 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 + * @param {RequestOptions} [options] * Valid options are:
        *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -1141,7 +1176,7 @@ class ParseObject { * 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 + * @returns {Promise} A promise that is fulfilled when the fetch * completes. */ fetch(options: RequestOptions): Promise { @@ -1182,14 +1217,14 @@ class ParseObject { * 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 + * @param {RequestOptions} [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 + * @returns {Promise} A promise that is fulfilled when the fetch * completes. */ fetchWithInclude(keys: String | Array>, options: RequestOptions): Promise { @@ -1210,7 +1245,7 @@ class ParseObject { * 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] + * @param {SaveOptions} [options] * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. * Valid options are: *
        @@ -1219,7 +1254,7 @@ class ParseObject { *
      • 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 + * @returns {Promise} A promise that is fulfilled when the save * completes. */ async saveEventually(options: SaveOptions): Promise { @@ -1269,7 +1304,7 @@ class ParseObject { *
    • `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] + * @param {string | SaveOptions} [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: @@ -1283,7 +1318,7 @@ class ParseObject { *
    *
  • * - * @param {object} [arg3] + * @param {SaveOptions} [arg3] * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. * Valid options are: *
      @@ -1294,7 +1329,7 @@ class ParseObject { *
    • 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 + * @returns {Promise} A promise that is fulfilled when the save * completes. */ save( @@ -1357,13 +1392,13 @@ class ParseObject { * 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] + * @param {RequestOptions} [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 + * @returns {Promise} A promise that is fulfilled when the destroy * completes. */ async destroyEventually(options: RequestOptions): Promise { @@ -1389,7 +1424,7 @@ class ParseObject { * 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 + * @returns {Promise} A promise that is fulfilled when the destroy * completes. */ destroy(options: RequestOptions): Promise { @@ -1424,7 +1459,7 @@ class ParseObject { * To retrieve object: * query.fromLocalDatastore() or query.fromPin() * - * @returns {Promise} A promise that is fulfilled when the pin completes. + * @returns {Promise} A promise that is fulfilled when the pin completes. */ pin(): Promise { return ParseObject.pinAllWithName(DEFAULT_PIN, [this]); @@ -1438,7 +1473,7 @@ class ParseObject { * await object.unPin(); * * - * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @returns {Promise} A promise that is fulfilled when the unPin completes. */ unPin(): Promise { return ParseObject.unPinAllWithName(DEFAULT_PIN, [this]); @@ -1477,7 +1512,7 @@ class ParseObject { * query.fromLocalDatastore() or query.fromPinWithName(name) * * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the pin completes. + * @returns {Promise} A promise that is fulfilled when the pin completes. */ pinWithName(name: string): Promise { return ParseObject.pinAllWithName(name, [this]); @@ -1491,7 +1526,7 @@ class ParseObject { * * * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @returns {Promise} A promise that is fulfilled when the unPin completes. */ unPinWithName(name: string): Promise { return ParseObject.unPinAllWithName(name, [this]); @@ -1507,7 +1542,7 @@ class ParseObject { * 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. + * @returns {Promise} A promise that is fulfilled when the fetch completes. */ async fetchFromLocalDatastore(): Promise { const localDatastore = CoreManager.getLocalDatastore(); @@ -1581,23 +1616,17 @@ class ParseObject { * 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.
    -   *    });
    +   * 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. - *
    + * @param {RequestOptions} [options] * @static * @returns {Parse.Object[]} */ @@ -1621,23 +1650,17 @@ class ParseObject { * 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.
    -   *    });
    +   * 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. - *
    + * @param {RequestOptions} [options] * @static * @returns {Parse.Object[]} */ @@ -1744,7 +1767,7 @@ class ParseObject { * @param {Array} list A list of Parse.Object. * @param {object} options * @static - * @returns {Promise} A promise that is fulfilled when the destroyAll + * @returns {Promise} A promise that is fulfilled when the destroyAll * completes. */ static destroyAll(list: Array, options = {}) { @@ -1778,10 +1801,11 @@ class ParseObject { * * * @param {Array} list A list of Parse.Object. - * @param {object} options + * @param {RequestOptions} [options] * @static * @returns {Parse.Object[]} */ + static saveAll(list: Array, options: RequestOptions = {}) { const saveOptions = {}; if (options.hasOwnProperty('useMasterKey')) { @@ -1823,9 +1847,9 @@ class ParseObject { * 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 + * @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 + * @param {boolean} [dirty] Whether the Parse.Object should set JSON keys to dirty * @static * @returns {Parse.Object} A Parse.Object reference */ @@ -2067,7 +2091,7 @@ class ParseObject { * query.fromLocalDatastore() or query.fromPin() * * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the pin completes. + * @returns {Promise} A promise that is fulfilled when the pin completes. * @static */ static pinAll(objects: Array): Promise { @@ -2093,7 +2117,7 @@ class ParseObject { * * @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. + * @returns {Promise} A promise that is fulfilled when the pin completes. * @static */ static pinAllWithName(name: string, objects: Array): Promise { @@ -2113,7 +2137,7 @@ class ParseObject { * * * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @returns {Promise} A promise that is fulfilled when the unPin completes. * @static */ static unPinAll(objects: Array): Promise { @@ -2133,7 +2157,7 @@ class ParseObject { * * @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. + * @returns {Promise} A promise that is fulfilled when the unPin completes. * @static */ static unPinAllWithName(name: string, objects: Array): Promise { @@ -2151,7 +2175,7 @@ class ParseObject { * await Parse.Object.unPinAllObjects(); * * - * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @returns {Promise} A promise that is fulfilled when the unPin completes. * @static */ static unPinAllObjects(): Promise { @@ -2171,7 +2195,7 @@ class ParseObject { * * * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @returns {Promise} A promise that is fulfilled when the unPin completes. * @static */ static unPinAllObjectsWithName(name: string): Promise { diff --git a/src/ParsePolygon.js b/src/ParsePolygon.js index b817be8a8..162b72ecd 100644 --- a/src/ParsePolygon.js +++ b/src/ParsePolygon.js @@ -28,13 +28,13 @@ import ParseGeoPoint from './ParseGeoPoint'; * object.set("area", polygon); * object.save();

    * - * @alias Parse.Polygon */ class ParsePolygon { _coordinates: Array>; /** * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs + * @alias Parse.Polygon */ constructor(coordinates: Array> | Array) { this._coordinates = ParsePolygon._validate(coordinates); diff --git a/src/ParseQuery.js b/src/ParseQuery.js index fe5c6f0ea..3669d0ec4 100644 --- a/src/ParseQuery.js +++ b/src/ParseQuery.js @@ -44,6 +44,26 @@ export type QueryJSON = { subqueryReadPreference?: string, }; +/** + * Typedef for QueryOptions + * + * @typedef QueryOptions + * @property {boolean} [useMasterKey] If true, sign up with masterKey + * @property {string} [sessionToken] sessionToken + * @property {any} [context] context + * @property {boolean} [json] json + */ + +/** + * Typedef for BatchOptions + * + * @typedef BatchOptions + * @property {boolean} [useMasterKey] If true, sign up with masterKey + * @property {string} [sessionToken] sessionToken + * @property {any} [context] context + * @property {number} [batchSize] batchSize + */ + /** * Converts a string into a regex that matches it. * Surrounding with \Q .. \E does this, we just need to escape any \E's in @@ -223,7 +243,6 @@ function handleOfflineSort(a, b, sorts) { * // error is an instance of Parse.Error. * });

    * - * @alias Parse.Query */ class ParseQuery { /** @@ -249,8 +268,10 @@ class ParseQuery { _xhrRequest: any; /** + * @alias Parse.Query * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string. */ + constructor(objectClass: string | ParseObject) { if (typeof objectClass === 'string') { if (objectClass === 'User' && CoreManager.get('PERFORM_USER_REWRITE')) { @@ -359,6 +380,25 @@ class ParseQuery { _regexStartWith(string: string): string { return '^' + quote(string); } + /** + * @typedef QueryJSON + * @property {Attributes} where + * @property {string} [include] + * @property {string} [excludeKeys] + * @property {string} [keys] + * @property {number} [limit] + * @property {number} [skip] + * @property {string} [order] + * @property {string} [className] + * @property {number} [count] + * @property {any} [hint] + * @property {boolean} [explain] + * @property {string} [readPreference] + * @property {string} [includeReadPreference] + * + * @property {string} [subqueryReadPreference] + * + */ async _handleOfflineQuery(params: any) { OfflineQuery.validateQuery(this); @@ -594,7 +634,7 @@ class ParseQuery { * the server. Unlike the first method, it never returns undefined. * * @param {string} objectId The id of the object to be fetched. - * @param {object} options + * @param {QueryOptions} [options] * Valid options are:
      *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -604,7 +644,7 @@ class ParseQuery { *
    • json: Return raw json without converting to Parse.Object *
    * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ get(objectId: string, options?: FullOptions): Promise { @@ -637,7 +677,7 @@ class ParseQuery { /** * Retrieves a list of ParseObjects that satisfy this query. * - * @param {object} options Valid options + * @param {QueryOptions} [options] Valid options * are:
      *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -647,7 +687,7 @@ class ParseQuery { *
    • json: Return raw json without converting to Parse.Object *
    * - * @returns {Promise} A promise that is resolved with the results when + * @returns {Promise>} A promise that is resolved with the results when * the query completes. */ find(options?: FullOptions): Promise> { @@ -712,14 +752,8 @@ class ParseQuery { * 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 + * @param {BatchOptions} [options] + * @returns {Promise>} A promise that is resolved with the results when * the query completes. */ async findAll(options?: BatchOptions): Promise> { @@ -734,6 +768,8 @@ class ParseQuery { * Counts the number of objects that match this query. * * @param {object} options + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] * Valid options are:
      *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to * be used for this request. @@ -741,7 +777,7 @@ class ParseQuery { * behalf of a specific user. *
    * - * @returns {Promise} A promise that is resolved with the count when + * @returns {Promise} A promise that is resolved with the count when * the query completes. */ count(options?: FullOptions): Promise { @@ -772,12 +808,9 @@ class ParseQuery { * * @param {string} key A field to find distinct values * @param {object} options - * Valid options are:
      - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    + * @param {string} [options.sessionToken] * - * @returns {Promise} A promise that is resolved with the query completes. + * @returns {Promise>} A promise that is resolved with the query completes. */ distinct(key: string, options?: FullOptions): Promise> { options = options || {}; @@ -801,16 +834,36 @@ class ParseQuery { }); } + /** + * Typedef for Aggregation Options + * + * @typedef AggregationPipeline + * @property {Attributes | GroupParams} [group] + * @property {Attributes} [match] + * @property {Attributes} [project] + * @property {number} [limit] + * @property {number} [skip] + * @property {object.} [sort] + * @property {object} [sample] + * @property {number} [sample.size] + */ + + /** + * Typedef for Aggregate Group + * + * @typedef GroupParams + * @property {string} [objectId] + */ + /** * Executes an aggregate query and returns aggregate results * - * @param {(Array|object)} pipeline Array or Object of stages to process query - * @param {object} options Valid options are:
      - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    + * @param {AggregationPipeline} pipeline Array or Object of stages to process query + * @param {object} options + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] * - * @returns {Promise} A promise that is resolved with the query completes. + * @returns {Promise>} A promise that is resolved with the query completes. */ aggregate(pipeline: mixed, options?: FullOptions): Promise> { options = options || {}; @@ -851,7 +904,7 @@ class ParseQuery { * * Returns the object if there is one, otherwise undefined. * - * @param {object} options Valid options are:
      + * @param {QueryOptions} [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 @@ -860,7 +913,7 @@ class ParseQuery { *
      • json: Return raw json without converting to Parse.Object *
      * - * @returns {Promise} A promise that is resolved with the object when + * @returns {Promise} A promise that is resolved with the object when * the query completes. */ first(options?: FullOptions): Promise { @@ -927,15 +980,8 @@ class ParseQuery { * * @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 + * @param {BatchOptions} [options] + * @returns {Promise} A promise that will be fulfilled once the * iteration has completed. */ eachBatch( @@ -1025,13 +1071,8 @@ class ParseQuery { * * @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. - *
      - * @returns {Promise} A promise that will be fulfilled once the + * @param {BatchOptions} [options] + * @returns {Promise} A promise that will be fulfilled once the * iteration has completed. */ each(callback: (obj: ParseObject) => any, options?: BatchOptions): Promise { @@ -1088,13 +1129,13 @@ class ParseQuery { *
    • query: The query map was called upon.
    • *
    * - * @param {object} options Valid options are:
      + * @param {BatchOptions} [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 + * @returns {Promise>} A promise that will be fulfilled once the * iteration has completed. */ async map( @@ -1126,13 +1167,8 @@ class ParseQuery { *
    • 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 + * @param {BatchOptions} [options] + * @returns {Promise>} A promise that will be fulfilled once the * iteration has completed. */ async reduce( @@ -1177,13 +1213,8 @@ class ParseQuery { *
  • 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 + * @param {BatchOptions} [options] batch options + * @returns {Promise>} A promise that will be fulfilled once the * iteration has completed. */ async filter( @@ -1386,7 +1417,7 @@ class ParseQuery { * * @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. + * @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 { @@ -1491,6 +1522,15 @@ class ParseQuery { return this._addCondition(key, '$regex', quote(substring)); } + /** + * Typedef for Full Text Options + * + * @typedef FullTextOptions + * @property {string} language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. + * @property {boolean} caseSensitive A boolean flag to enable or disable case sensitive search. + * @property {boolean} diacriticSensitive A boolean flag to enable or disable diacritic sensitive search. + */ + /** * 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 @@ -1514,10 +1554,7 @@ class ParseQuery { * * @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. + * @param {FullTextOptions} [options] The full text options * @returns {Parse.Query} Returns the query, so you can chain this call. */ fullText(key: string, value: string, options: ?Object): ParseQuery { @@ -1573,7 +1610,7 @@ class ParseQuery { * * @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. + * @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 { @@ -1622,7 +1659,7 @@ class ParseQuery { * @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 + * @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. @@ -1651,7 +1688,7 @@ class ParseQuery { * @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 + * @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. @@ -1668,7 +1705,7 @@ class ParseQuery { * @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 + * @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. @@ -1845,7 +1882,7 @@ class 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 + * `results`: holding {Parse.Object} 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. @@ -1865,9 +1902,12 @@ class ParseQuery { * 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. + * @returns {this} Returns the query, so you can chain this call. + * */ + include(...keys: Array>): ParseQuery { keys.forEach(key => { if (Array.isArray(key)) { @@ -1954,7 +1994,7 @@ class ParseQuery { /** * Subscribe this query to get liveQuery updates * - * @param {string} sessionToken (optional) Defaults to the currentUser + * @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. */ diff --git a/src/ParseRelation.js b/src/ParseRelation.js index e467c92c2..04482b434 100644 --- a/src/ParseRelation.js +++ b/src/ParseRelation.js @@ -24,7 +24,6 @@ import ParseQuery from './ParseQuery'; * particular parent object and key. *

    * - * @alias Parse.Relation */ class ParseRelation { parent: ?ParseObject; @@ -32,6 +31,7 @@ class ParseRelation { targetClassName: ?string; /** + * @alias Parse.Relation * @param {Parse.Object} parent The parent of this relation. * @param {string} key The key for this relation on the parent. */ diff --git a/src/ParseRole.js b/src/ParseRole.js index 07d4c8fa2..8a4125c7e 100644 --- a/src/ParseRole.js +++ b/src/ParseRole.js @@ -26,16 +26,17 @@ import type ParseRelation from './ParseRelation'; *

    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 */ class ParseRole extends ParseObject { /** + * @augments Parse.Object + * @alias Parse.Role * @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) { super('_Role'); if (typeof name === 'string' && acl instanceof ParseACL) { @@ -72,7 +73,7 @@ class ParseRole extends ParseObject { * @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. + * @returns {(Parse.Object|boolean)} true if the set succeeded. */ setName(name: string, options?: mixed): ParseObject | boolean { return this.set('name', name, options); diff --git a/src/ParseSchema.js b/src/ParseSchema.js index 49c717f0d..2ba60ecfc 100644 --- a/src/ParseSchema.js +++ b/src/ParseSchema.js @@ -34,6 +34,14 @@ type FieldOptions = { defaultValue: mixed, }; +/** + * Typedef for FieldOptions + * + * @typedef FieldOptions + * @property {boolean} [required] Whether the field is required + * @property {any} [defaultValue] Default value for the field + */ + /** * A Parse.Schema object is for handling schema data from Parse. *

    All the schemas methods require MasterKey. @@ -49,7 +57,6 @@ type FieldOptions = { * *

    * - * @alias Parse.Schema */ class ParseSchema { className: string; @@ -58,6 +65,7 @@ class ParseSchema { _clp: { [key: string]: mixed }; /** + * @alias Parse.Schema * @param {string} className Parse Class string. */ constructor(className: string) { @@ -76,7 +84,7 @@ class ParseSchema { /** * Static method to get all schemas * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ static all() { @@ -92,7 +100,7 @@ class ParseSchema { /** * Get the Schema from Parse * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ get() { @@ -110,7 +118,7 @@ class ParseSchema { /** * Create a new Schema on Parse * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ save() { @@ -130,7 +138,7 @@ class ParseSchema { /** * Update a Schema on Parse * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ update() { @@ -154,7 +162,7 @@ class ParseSchema { * Removing a Schema from Parse * Can only be used on Schema without objects * - * @returns {Promise} A promise that is resolved with the result when + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ delete() { @@ -168,7 +176,7 @@ class ParseSchema { * 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 + * @returns {Promise} A promise that is resolved with the result when * the query completes. */ purge() { @@ -209,8 +217,8 @@ class ParseSchema { * 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 + * @param {string} [type] Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation) + * @param {FieldOptions} [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+) @@ -273,7 +281,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -284,7 +292,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -295,7 +303,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -306,7 +314,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -323,7 +331,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -334,7 +342,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -345,7 +353,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -356,7 +364,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -367,7 +375,7 @@ class ParseSchema { * 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} + * @param {FieldOptions} [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) { @@ -379,7 +387,7 @@ class ParseSchema { * * @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} + * @param {FieldOptions} [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 = {}) { diff --git a/src/ParseSession.js b/src/ParseSession.js index 1b1d8d108..dc25509f8 100644 --- a/src/ParseSession.js +++ b/src/ParseSession.js @@ -22,12 +22,12 @@ import type { RequestOptions, FullOptions } from './RESTController'; * This class is a subclass of a Parse.Object, and retains the same * functionality of a Parse.Object.

      * - * @alias Parse.Session - * @augments Parse.Object */ class ParseSession extends ParseObject { /** - * @param {object} attributes The initial set of data to store in the user. + * @augments Parse.Object + * @alias Parse.Session + * @param {object} [attributes] The initial set of data to store in the user. */ constructor(attributes: ?AttributeMap) { super('_Session'); @@ -60,7 +60,7 @@ class ParseSession extends ParseObject { * * @param {object} options useMasterKey * @static - * @returns {Promise} A promise that is resolved with the Parse.Session + * @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. */ diff --git a/src/ParseUser.js b/src/ParseUser.js index d0303dac3..a80689927 100644 --- a/src/ParseUser.js +++ b/src/ParseUser.js @@ -34,13 +34,19 @@ const authProviders = {}; * 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 */ + class ParseUser extends ParseObject { /** - * @param {object} attributes The initial set of data to store in the user. + *

      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.

      + * + * @augments Parse.Object + * @alias Parse.User + * @param {object} [attributes] The initial set of data to store in the user. */ constructor(attributes: ?AttributeMap) { super('_User'); @@ -55,7 +61,7 @@ class ParseUser extends ParseObject { * 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 + * @returns {Promise} A promise that is resolved when the replacement * token has been fetched. */ _upgradeToRevocableSession(options: RequestOptions): Promise { @@ -82,9 +88,10 @@ class ParseUser extends ParseObject { *
    • 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 + * @param {object} [saveOpts] useMasterKey / sessionToken + * @returns {Promise} A promise that is fulfilled with the user is linked */ + linkWith( provider: any, options: { authData?: AuthData }, @@ -148,7 +155,7 @@ class ParseUser extends ParseObject { * @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} + * @returns {Promise} */ _linkWith( provider: any, @@ -222,8 +229,8 @@ class ParseUser extends ParseObject { * 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 + * @param {FullOptions} [options] MasterKey / SessionToken + * @returns {Promise} A promise that is fulfilled when the unlinking * finishes. */ _unlinkFrom(provider: any, options?: FullOptions): Promise { @@ -411,10 +418,13 @@ class ParseUser extends ParseObject { *

    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 + * @param {object} [options] + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] + * @returns {Promise} A promise that is fulfilled when the signup * finishes. */ + signUp(attrs: AttributeMap, options?: FullOptions): Promise { options = options || {}; @@ -437,10 +447,11 @@ class ParseUser extends ParseObject { * *

    A username and password must be set before calling logIn.

    * - * @param {object} options - * @returns {Promise} A promise that is fulfilled with the user when + * @param {FullOptions} [options] + * @returns {Promise} A promise that is fulfilled with the user when * the login is complete. */ + logIn(options?: FullOptions): Promise { options = options || {}; @@ -464,7 +475,7 @@ class ParseUser extends ParseObject { * storage if this is current user. * * @param {...any} args - * @returns {Promise} + * @returns {Promise} */ async save(...args: Array): Promise { await super.save.apply(this, args); @@ -480,7 +491,7 @@ class ParseUser extends ParseObject { * the current user when it is destroyed * * @param {...any} args - * @returns {Parse.User} + * @returns {Promise} */ async destroy(...args: Array): Promise { await super.destroy.apply(this, args); @@ -496,7 +507,7 @@ class ParseUser extends ParseObject { * storage if this is current user. * * @param {...any} args - * @returns {Parse.User} + * @returns {Promise} */ async fetch(...args: Array): Promise { await super.fetch.apply(this, args); @@ -512,7 +523,7 @@ class ParseUser extends ParseObject { * storage if this is current user. * * @param {...any} args - * @returns {Parse.User} + * @returns {Promise} */ async fetchWithInclude(...args: Array): Promise { await super.fetchWithInclude.apply(this, args); @@ -528,7 +539,7 @@ class ParseUser extends ParseObject { * * @param {string} password A password to be verified * @param {object} options - * @returns {Promise} A promise that is fulfilled with a user + * @returns {Promise} A promise that is fulfilled with a user * when the password is correct. */ verifyPassword(password: string, options?: RequestOptions): Promise { @@ -584,7 +595,7 @@ class ParseUser extends ParseObject { * either from memory or localStorage, if necessary. * * @static - * @returns {Parse.Object} The currently logged in Parse.User. + * @returns {Parse.User} The currently logged in Parse.User. */ static current(): ?ParseUser { if (!canUseCurrentUser) { @@ -598,7 +609,7 @@ class ParseUser extends ParseObject { * Retrieves the currently logged in ParseUser from asynchronous Storage. * * @static - * @returns {Promise} A Promise that is resolved with the currently + * @returns {Promise} A Promise that is resolved with the currently * logged in Parse User */ static currentAsync(): Promise { @@ -620,7 +631,7 @@ class ParseUser extends ParseObject { * @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 + * @returns {Promise} A promise that is fulfilled with the user when * the signup completes. */ static signUp(username: string, password: string, attrs: AttributeMap, options?: FullOptions) { @@ -638,9 +649,9 @@ class ParseUser extends ParseObject { * * @param {string} username The username (or email) to log in with. * @param {string} password The password to log in with. - * @param {object} options + * @param {FullOptions} [options] * @static - * @returns {Promise} A promise that is fulfilled with the user when + * @returns {Promise} A promise that is fulfilled with the user when * the login completes. */ static logIn(username: string, password: string, options?: FullOptions) { @@ -660,9 +671,9 @@ class ParseUser extends ParseObject { * current. * * @param {string} sessionToken The sessionToken to log in with. - * @param {object} options + * @param {RequestOptions} [options] * @static - * @returns {Promise} A promise that is fulfilled with the user when + * @returns {Promise} A promise that is fulfilled with the user when * the login completes. */ static become(sessionToken: string, options?: RequestOptions) { @@ -689,7 +700,7 @@ class ParseUser extends ParseObject { * @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. + * @returns {Promise} A promise that is fulfilled with the user is fetched. */ static me(sessionToken: string, options?: RequestOptions = {}) { const controller = CoreManager.getUserController(); @@ -710,7 +721,7 @@ class ParseUser extends ParseObject { * * @param {object} userJSON The JSON map of the User's data * @static - * @returns {Promise} A promise that is fulfilled with the user when + * @returns {Promise} A promise that is fulfilled with the user when * the login completes. */ static hydrate(userJSON: AttributeMap) { @@ -726,7 +737,7 @@ class ParseUser extends ParseObject { * @param options * @param saveOpts * @static - * @returns {Promise} + * @returns {Promise} */ static logInWith( provider: any, @@ -742,9 +753,9 @@ class ParseUser extends ParseObject { * session from disk, log out of linked services, and future calls to * current will return null. * - * @param {object} options + * @param {RequestOptions} [options] * @static - * @returns {Promise} A promise that is resolved when the session is + * @returns {Promise} A promise that is resolved when the session is * destroyed on the server. */ static logOut(options: RequestOptions = {}) { @@ -759,9 +770,9 @@ class ParseUser extends ParseObject { * * @param {string} email The email address associated with the user that * forgot their password. - * @param {object} options + * @param {RequestOptions} [options] * @static - * @returns {Promise} + * @returns {Promise} */ static requestPasswordReset(email: string, options?: RequestOptions) { options = options || {}; @@ -780,9 +791,9 @@ class ParseUser extends ParseObject { * * @param {string} email The email address associated with the user that * forgot their password. - * @param {object} options + * @param {RequestOptions} [options] * @static - * @returns {Promise} + * @returns {Promise} */ static requestEmailVerification(email: string, options?: RequestOptions) { options = options || {}; @@ -803,7 +814,7 @@ class ParseUser extends ParseObject { * @param {string} password A password to be verified * @param {object} options * @static - * @returns {Promise} A promise that is fulfilled with a user + * @returns {Promise} A promise that is fulfilled with a user * when the password is correct. */ static verifyPassword(username: string, password: string, options?: RequestOptions) { @@ -849,7 +860,7 @@ class ParseUser extends ParseObject { * * @param {object} options * @static - * @returns {Promise} A promise that is resolved when the process has + * @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. */ @@ -915,7 +926,7 @@ class ParseUser extends ParseObject { * @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} + * @returns {Promise} */ static _logInWith(provider: any, options: { authData?: AuthData }, saveOpts?: FullOptions) { const user = new this(); diff --git a/src/Push.js b/src/Push.js index 4ef1006c8..444b23023 100644 --- a/src/Push.js +++ b/src/Push.js @@ -55,7 +55,7 @@ export type PushData = { *
  • 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 + * @returns {Promise} A promise that is fulfilled when the push request * completes. */ export function send(data: PushData, options?: FullOptions = {}): Promise { diff --git a/src/RESTController.js b/src/RESTController.js index 4e0653239..40cce39f9 100644 --- a/src/RESTController.js +++ b/src/RESTController.js @@ -15,6 +15,31 @@ import CoreManager from './CoreManager'; import ParseError from './ParseError'; import { resolvingPromise } from './promiseUtils'; +/** + * Typedef for RequestOptions + * + * @typedef RequestOptions + * @property {boolean} [useMasterKey] If true, sign up with masterKey + * @property {string} [sessionToken] sessionToken + * @property {string} [installationId] InstallationId of user + * @property {boolean} [returnStatus] return status + * @property {number} [batchSize] batch size + * @property {any} [include] include + * @property {any} [context] context + * @property {boolean} [usePost] whether request should use POST + */ + +/** + * Typedef for FullOptions + * + * @typedef FullOptions + * @property {boolean} [useMasterKey] If true, sign up with masterKey + * @property {string} [sessionToken] sessionToken + * @property {string} [installationId] InstallationId of user + * @property {void} [progress] progress + * @property {boolean} [usePost] whether request should use POST + */ + export type RequestOptions = { useMasterKey?: boolean, sessionToken?: string, @@ -28,8 +53,6 @@ export type RequestOptions = { }; export type FullOptions = { - success?: any, - error?: any, useMasterKey?: boolean, sessionToken?: string, installationId?: string, diff --git a/types/generics.ts b/types/generics.ts new file mode 100644 index 000000000..7e1127e14 --- /dev/null +++ b/types/generics.ts @@ -0,0 +1,271 @@ +class Object { + attributes: T; + add( + attr: K, + item: T[K][number] + ): this | false; + addAll( + attr: K, + items: T[K] + ): this | false; + dirty(attr?: Extract): boolean; + equals(other: T): boolean; + escape(attr: Extract): string; + fetchWithInclude>( + keys: K | Array, + options?: RequestOptions + ): Promise; + get>(attr: K): T[K]; + has(attr: Extract): boolean; + increment(attr: Extract, amount?: number): this | false; + decrement(attr: Extract, amount?: number): this | false; + op(attr: Extract): any; + relation = Extract>( + attr: T[K] extends Relation ? K : never + ): Relation; + revert(...keys: Array>): void; + save>( + attrs?: Pick | T | null, + options?: SaveOptions + ): Promise; + save>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: SaveOptions + ): Promise; + set>(attrs: Pick | T, options?: any): this | false; + set>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: any + ): this | false; + toJSON(): ToJSON & JSONBaseAttributes; + unset(attr: Extract, options?: any): this | false; +} +class User extends Object {} + +class Relation { + parent: S; + 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; +} + +class Query { + 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: AggregationPipeline | AggregationPipeline[]): 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; + 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?: BatchOptions + ): Promise; + each(callback: (obj: T) => PromiseLike | void, options?: BatchOptions): Promise; + map( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | U, + options?: BatchOptions + ): Promise; + reduce( + callback: (accumulator: T, currentObject: T, index: number) => PromiseLike | T, + initialValue?: undefined, + options?: BatchOptions + ): Promise; + reduce( + callback: (accumulator: U, currentObject: T, index: number) => PromiseLike | U, + initialValue: U, + options?: BatchOptions + ): Promise; + filter( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | boolean, + options?: 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?: QueryOptions): Promise; + findAll(options?: BatchOptions): Promise; + first(options?: QueryOptions): Promise; + fromNetwork(): this; + fromLocalDatastore(): this; + fromPin(): this; + fromPinWithName(name: string): this; + cancel(): this; + fullText( + key: K, + value: string, + options?: FullTextOptions + ): this; + get(objectId: string, options?: QueryOptions): 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; + 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; +} +class Cloud { + static run any>( + name: string, + data?: null, + options?: RequestOptions + ): Promise>; + static run[0]]: Parameters[0][P] }) => any>( + name: string, + data: Parameters[0], + options?: RequestOptions + ): Promise>; + static afterDelete( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any), + ): void; + static afterSave( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any), +): void; +static beforeDelete( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any), +): void; +static beforeSave( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any), +): void; +static beforeFind( + arg1: { new (): T } | string, + func?: (request: BeforeFindRequest) => Promise> | Promise | Query | void, + validator?: Parse.Cloud.ValidatorObject | ((request: BeforeFindRequest) => any), +): void; +static afterFind( + arg1: { new (): T } | string, + func?: (request: AfterFindRequest) => any, + validator?: Parse.Cloud.ValidatorObject | ((request: AfterFindRequest) => any), +): void; +} diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 000000000..cc1b76750 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,4879 @@ +declare namespace Parse { + /** + *

    Parse.Analytics provides an interface to Parse's logging and analytics + * backend.

    + */ + class Analytics { + /** + *

    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.

    + * @param name -

    The name of the custom event to report to Parse as + * having happened.

    + * @param dimensions -

    The dictionary of information by which to + * segment this event.

    + * @returns

    A promise that is resolved when the round-trip + * to the server completes.

    + */ + static track(name: string, dimensions: any): Promise; + } + /** + *

    Provides utility functions for working with Anonymously logged-in users.
    + * Anonymous users have some unique characteristics:

    + *
      + *
    • Anonymous users don't need a user name or password.
    • + *
        + *
      • Once logged out, an anonymous user cannot be recovered.
      • + *
      + *
    • signUp converts an anonymous user to a standard user with the given username and password.
    • + *
        + *
      • Data associated with the anonymous user is retained.
      • + *
      + *
    • logIn switches users without converting the anonymous user.
    • + *
        + *
      • Data associated with the anonymous user will be lost.
      • + *
      + *
    • Service logIn (e.g. Facebook, Twitter) will attempt to convert + * the anonymous user into a standard user by linking it to the service.
    • + *
        + *
      • If a user already exists that is linked to the service, it will instead switch to the existing user.
      • + *
      + *
    • Service linking (e.g. Facebook, Twitter) will convert the anonymous user + * into a standard user by linking it to the service.
    • + *
    + */ + class AnonymousUtils { + /** + *

    Gets whether the user has their account linked to anonymous user.

    + * @param user -

    User to check for. + * The user must be logged in on this device.

    + * @returns

    true if the user has their account + * linked to an anonymous user.

    + */ + static isLinked(user: Parse.User): boolean; + /** + *

    Logs in a user Anonymously.

    + * @param options -

    MasterKey / SessionToken.

    + * @returns

    Logged in user

    + */ + static logIn(options: any): Promise; + /** + *

    Links Anonymous User to an existing PFUser.

    + * @param user -

    User to link. This must be the current user.

    + * @param options -

    MasterKey / SessionToken.

    + * @returns

    Linked with User

    + */ + static link(user: Parse.User, options: any): Promise; + /** + *

    Returns true if Authentication Provider has been registered for use.

    + */ + static isRegistered(): boolean; + } + /** + *

    Contains functions for calling and declaring + * cloud functions.

    + *

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

    + */ + class Cloud { + static run any>( + name: string, + data?: null, + options?: RequestOptions + ): Promise>; + static run[0]]: Parameters[0][P] }) => any>( + name: string, + data: Parameters[0], + options?: RequestOptions + ): Promise>; + static afterDelete( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any) + ): void; + static afterSave( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any) + ): void; + static beforeDelete( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any) + ): void; + static beforeSave( + arg1: { new (): T } | string, + func?: (request: GenericTriggerRequest) => Promise | void, + validator?: Parse.Cloud.ValidatorObject | ((request: GenericTriggerRequest) => any) + ): void; + static beforeFind( + arg1: { new (): T } | string, + func?: (request: BeforeFindRequest) => Promise> | Promise | Query | void, + validator?: Parse.Cloud.ValidatorObject | ((request: BeforeFindRequest) => any) + ): void; + static afterFind( + arg1: { new (): T } | string, + func?: (request: AfterFindRequest) => any, + validator?: Parse.Cloud.ValidatorObject | ((request: AfterFindRequest) => any) + ): void; + + /** + *

    Makes a call to a cloud function.

    + * @param name -

    The function name.

    + * @param [data] -

    The parameters to send to the cloud function.

    + * @returns

    A promise that will be resolved with the result + * of the function.

    + */ + static run(name: string, data?: any, options?: RequestOptions): Promise; + /** + *

    Gets data for the current set of cloud jobs.

    + * @returns

    A promise that will be resolved with the result + * of the function.

    + */ + static getJobsData(): Promise; + /** + *

    Starts a given cloud job, which will process asynchronously.

    + * @param name -

    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.

    + */ + static startJob(name: string, data: any): Promise; + /** + *

    Gets job status by Id

    + * @param jobStatusId -

    The Id of Job Status.

    + * @returns

    Status of Job.

    + */ + static getJobStatus(jobStatusId: string): Promise; + /** + *

    Defines a Cloud Function.

    + *

    Available in Cloud Code only.

    + * @param name -

    The name of the Cloud Function

    + * @param func -

    The Cloud Function to register

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static define( + name: string, + func: Parse.Cloud.FunctionRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.FunctionRequestFunc + ): void; + /** + *

    Registers an after delete function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use afterDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.afterDelete('MyCustomClass', (request) => {
    +     *   // code here
    +     * })
    +     *
    +     * Parse.Cloud.afterDelete(Parse.User, (request) => {
    +     *   // code here
    +     * })
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run after a delete.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterDelete( + ParseClass: string | Parse.Object, + func: Parse.Cloud.TriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.TriggerRequestFunc + ): void; + /** + *

    Registers an after save function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.afterSave('MyCustomClass', function(request) {
    +     *   // code here
    +     * })
    +     *
    +     * Parse.Cloud.afterSave(Parse.User, function(request) {
    +     *   // code here
    +     * })
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run after a save.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterSave( + ParseClass: string | Parse.Object, + func: Parse.Cloud.TriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.TriggerRequestFunc + ): void; + /** + *

    Registers a before find function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use beforeFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.beforeFind('MyCustomClass', async (request) => {
    +     *   // code here
    +     * }, (request) => {
    +     *   // validation code here
    +     * });
    +     *
    +     * Parse.Cloud.beforeFind(Parse.User, async (request) => {
    +     *   // code here
    +     * }, { ...validationObject });
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the before find function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run before a find.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeFind( + ParseClass: string | Parse.Object, + func: Parse.Cloud.BeforeFindRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.BeforeFindRequestFunc + ): void; + /** + *

    Registers an after find function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use afterFind for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.afterFind('MyCustomClass', async (request) => {
    +     *   // code here
    +     * }, (request) => {
    +     *   // validation code here
    +     * });
    +     *
    +     * Parse.Cloud.afterFind(Parse.User, async (request) => {
    +     *   // code here
    +     * }, { ...validationObject });
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the after find function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run before a find.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterFind( + ParseClass: string | Parse.Object, + func: Parse.Cloud.AfterFindRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.AfterFindRequestFunc + ): void; + /** + *

    Registers an before delete function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.beforeDelete('MyCustomClass', (request) => {
    +     *   // code here
    +     * })
    +     *
    +     * Parse.Cloud.beforeDelete(Parse.User, (request) => {
    +     *   // code here
    +     * })
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run before a delete.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeDelete( + ParseClass: string | Parse.Object, + func: Parse.Cloud.TriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.TriggerRequestFunc + ): void; + /** + *

    Registers the before login function.

    + *

    Available in Cloud Code only.

    + *

    This function provides further control + * in validating a login attempt. Specifically, + * it is triggered after a user enters + * correct credentials (or other valid authData), + * but prior to a session being generated.

    + *
    Parse.Cloud.beforeLogin((request) => {
    +     *   // code here
    +     * })
    +     *
    +     * 
    + * @param func -

    The function to run before a login.

    + */ + static beforeLogin(func: Parse.Cloud.TriggerRequestFunc): void; + /** + *

    Registers the after login function.

    + *

    Available in Cloud Code only.

    + *

    This function is triggered after a user logs in successfully, + * and after a _Session object has been created.

    + *
    Parse.Cloud.afterLogin((request) => {
    +     *   // code here
    +     * });
    +     * 
    + * @param func -

    The function to run after a login.

    + */ + static afterLogin(func: Parse.Cloud.TriggerRequestFunc): void; + /** + *

    Registers the after logout function.

    + *

    Available in Cloud Code only.

    + *

    This function is triggered after a user logs out.

    + *
    Parse.Cloud.afterLogout((request) => {
    +     *   // code here
    +     * });
    +     * 
    + * @param func -

    The function to run after a logout.

    + */ + static afterLogout(func: Parse.Cloud.TriggerRequestFunc): void; + /** + *

    Registers an before save function.

    + *

    Available in Cloud Code only.

    + *

    If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

    + *
    Parse.Cloud.beforeSave('MyCustomClass', (request) => {
    +     *   // code here
    +     * })
    +     *
    +     * Parse.Cloud.beforeSave(Parse.User, (request) => {
    +     *   // code here
    +     * })
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run before a save.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeSave( + ParseClass: string | Parse.Object, + func: Parse.Cloud.TriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.TriggerRequestFunc + ): void; + /** + *

    Registers an before save file function. A new Parse.File can be returned to override the file that gets saved. + * If you want to replace the rquesting Parse.File with a Parse.File that is already saved, simply return the already saved Parse.File. + * You can also add metadata to the file that will be stored via whatever file storage solution you're using.

    + *

    Available in Cloud Code only.

    + *

    Example: Adding metadata and tags

    + *
    Parse.Cloud.beforeSaveFile(({ file, user }) => {
    +     *   file.addMetadata('foo', 'bar');
    +     *   file.addTag('createdBy', user.id);
    +     * });
    +     *
    +     * 
    + *

    Example: replacing file with an already saved file

    + *
    Parse.Cloud.beforeSaveFile(({ file, user }) => {
    +     *   return user.get('avatar');
    +     * });
    +     *
    +     * 
    + *

    Example: replacing file with a different file

    + *
    Parse.Cloud.beforeSaveFile(({ file, user }) => {
    +     *   const metadata = { foo: 'bar' };
    +     *   const tags = { createdBy: user.id };
    +     *   const newFile = new Parse.File(file.name(), <some other file data>, 'text/plain', metadata, tags);
    +     *   return newFile;
    +     * });
    +     *
    +     * 
    + * @param func -

    The function to run before saving a file.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeSaveFile( + func: Parse.Cloud.FileTriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.FileTriggerRequestFunc + ): void; + /** + *

    Registers an after save file function.

    + *

    Available in Cloud Code only.

    + *

    Example: creating a new object that references this file in a separate collection

    + *
    Parse.Cloud.afterSaveFile(async ({ file, user }) => {
    +     *   const fileObject = new Parse.Object('FileObject');
    +     *   fileObject.set('metadata', file.metadata());
    +     *   fileObject.set('tags', file.tags());
    +     *   fileObject.set('name', file.name());
    +     *   fileObject.set('createdBy', user);
    +     *   await fileObject.save({ sessionToken: user.getSessionToken() });
    +     * });
    + * @param func -

    The function to run after saving a file.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterSaveFile( + func: Parse.Cloud.FileTriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.FileTriggerRequestFunc + ): void; + /** + *

    Registers a before delete file function.

    + *

    Available in Cloud Code only.

    + *
    Parse.Cloud.beforeDeleteFile(async (request) => {
    +     *   // code here
    +     * }, (request) => {
    +     *   // validation code here
    +     * });
    +     *
    +     * Parse.Cloud.beforeDeleteFile(async (request) => {
    +     *   // code here
    +     * }, { ...validationObject });
    +     * 
    + * @param func -

    The function to run before deleting a file.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeDeleteFile( + func: Parse.Cloud.FileTriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.FileTriggerRequestFunc + ): void; + /** + *

    Registers an after delete file function.

    + *

    Available in Cloud Code only.

    + *
    Parse.Cloud.afterDeleteFile(async (request) => {
    +     *   // code here
    +     * }, (request) => {
    +     *   // validation code here
    +     * });
    +     *
    +     * Parse.Cloud.afterDeleteFile(async (request) => {
    +     *   // code here
    +     * }, { ...validationObject });
    +     * 
    + * @param func -

    The function to after before deleting a file.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterDeleteFile( + func: Parse.Cloud.FileTriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.FileTriggerRequestFunc + ): void; + /** + * @param func -

    The function to before connection is made.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeConnect( + func: Parse.Cloud.ConnectTriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.ConnectTriggerRequestFunc + ): void; + /** + *

    Sends an email through the Parse Server mail adapter.

    + *

    Available in Cloud Code only. + * Requires a mail adapter to be configured for Parse Server.

    + *
    Parse.Cloud.sendEmail({
    +     *   from: 'Example <test@example.com>',
    +     *   to: 'contact@example.com',
    +     *   subject: 'Test email',
    +     *   text: 'This email is a test.'
    +     * });
    +     * 
    + * @param data -

    The object of the mail data to send.

    + */ + static sendEmail(data: any): void; + /** + *

    Registers a before subscribe function.

    + *

    Available in Cloud Code only. + * Example: restrict subscriptions to MyObject to Admin accounts only.

    + *
     Parse.Cloud.beforeSubscribe('MyObject', (request) => {
    +     *   if (!request.user.get('Admin')) {
    +     *       throw new Parse.Error(101, 'You are not authorized to subscribe to MyObject.');
    +     *   }
    +     *   let query = request.query; // the Parse.Query
    +     *   query.select("name","year")
    +     * });
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the before subscription function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run before a subscription.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static beforeSubscribe( + ParseClass: string | Parse.Object, + func: Parse.Cloud.TriggerRequestFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.TriggerRequestFunc + ): void; + /** + *

    Registers an after live query server event function.

    + *

    Available in Cloud Code only.

    + *
    Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => {
    +     *   // code here
    +     * }, (request) => {
    +     *   // validation code here
    +     * });
    +     *
    +     * Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => {
    +     *   // code here
    +     * }, { ...validationObject });
    +     * 
    + * @param ParseClass -

    The Parse.Object subclass to register the after live query event function for. This can instead be a String that is the className of the subclass.

    + * @param func -

    The function to run after a live query event.

    + * @param [validator] -

    An optional function to help validating cloud code.

    + */ + static afterLiveQueryEvent( + ParseClass: string | Parse.Object, + func: Parse.Cloud.LiveQueryEventTriggerFunc, + validator?: Parse.Cloud.ValidatorObject | Parse.Cloud.LiveQueryEventTriggerFunc + ): void; + /** + *

    Registers an on live query server event function.

    + *

    Available in Cloud Code only.

    + *
    Parse.Cloud.onLiveQueryEvent((event) => {
    +     *   // code here
    +     * });
    +     *
    +     * 
    + * @param func -

    The function to run on a live query event.

    + */ + static onLiveQueryEvent(func: Parse.Cloud.LiveQueryEventTriggerFunc): void; + /** + *

    Makes an HTTP Request.

    + *

    Available in Cloud Code only.

    + *

    By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the {@link Parse.Cloud.HTTPOptions} object to change this behavior.

    + *

    Sample request:

    + *
    Parse.Cloud.httpRequest({
    +     *   url: 'http://www.example.com/'
    +     * }).then(function(httpResponse) {
    +     *   // success
    +     *   console.log(httpResponse.text);
    +     * },function(httpResponse) {
    +     *   // error
    +     *   console.error('Request failed with response code ' + httpResponse.status);
    +     * });
    +     * 
    + * @param options -

    The Parse.Cloud.HTTPOptions object that makes the request.

    + * @returns

    A promise that will be resolved with a {@link Parse.Cloud.HTTPResponse} object when the request completes.

    + */ + static httpRequest(options: Parse.Cloud.HTTPOptions): Promise; + /** + *

    Defines a Background Job.

    + *

    Available in Cloud Code only.

    + * @param name -

    The name of the Background Job

    + * @param func -

    The Background Job to register.

    + */ + static job(name: string, func: Parse.Cloud.JobRequestFunc): void; + } + namespace Cloud { + /** + * @param request -

    The request object

    + */ + type TriggerRequestFunc = (request: Parse.Cloud.TriggerRequest) => any; + /** + * @property [installationId] -

    If set, the installationId triggering the request.

    + * @property master -

    If true, means the master key was used.

    + * @property [user] -

    If set, the user that made the request.

    + * @property object -

    The object triggering the hook.

    + * @property ip -

    The IP address of the client making the request.

    + * @property headers -

    The original HTTP headers for the request.

    + * @property triggerName -

    The name of the trigger (beforeSave, afterSave, ...)

    + * @property log -

    The current logger inside Parse Server.

    + * @property [original] -

    If set, the object, as currently stored.

    + * @property context -

    If set, the context of the request

    + */ + type TriggerRequest = { + installationId?: string; + master: boolean; + user?: Parse.User; + object: Parse.Object; + ip: string; + headers: any; + triggerName: string; + log: any; + original?: Parse.Object; + context: { + [key: string]: object; + }; + }; + /** + * @param request -

    The request object

    + */ + type FileTriggerRequestFunc = (request: Parse.Cloud.FileTriggerRequest) => any; + /** + * @property installationId -

    If set, the installationId triggering the request.

    + * @property master -

    If true, means the master key was used.

    + * @property user -

    If set, the user that made the request.

    + * @property file -

    The file that triggered the hook.

    + * @property fileSize -

    The size of the file in bytes.

    + * @property contentLength -

    The value from Content-Length header

    + * @property ip -

    The IP address of the client making the request.

    + * @property headers -

    The original HTTP headers for the request.

    + * @property triggerName -

    The name of the trigger (beforeSaveFile, afterSaveFile)

    + * @property log -

    The current logger inside Parse Server.

    + */ + type FileTriggerRequest = { + installationId: string; + master: boolean; + user: Parse.User; + file: Parse.File; + fileSize: number; + contentLength: number; + ip: string; + headers: any; + triggerName: string; + log: any; + }; + /** + * @param request -

    The request object

    + */ + type ConnectTriggerRequestFunc = (request: Parse.Cloud.ConnectTriggerRequest) => any; + /** + * @property installationId -

    If set, the installationId triggering the request.

    + * @property useMasterKey -

    If true, means the master key was used.

    + * @property user -

    If set, the user that made the request.

    + * @property clients -

    The number of clients connected.

    + * @property subscriptions -

    The number of subscriptions connected.

    + * @property sessionToken -

    If set, the session of the user that made the request.

    + */ + type ConnectTriggerRequest = { + installationId: string; + useMasterKey: boolean; + user: Parse.User; + clients: number; + subscriptions: number; + sessionToken: string; + }; + /** + * @param request -

    The request object

    + */ + type LiveQueryEventTriggerFunc = (request: Parse.Cloud.LiveQueryEventTrigger) => any; + /** + * @property [installationId] -

    If set, the installationId triggering the request.

    + * @property useMasterKey -

    If true, means the master key was used.

    + * @property [user] -

    If set, the user that made the request.

    + * @property [sessionToken] -

    If set, the session of the user that made the request.

    + * @property event -

    The live query event that triggered the request.

    + * @property object -

    The object triggering the hook.

    + * @property [original] -

    If set, the object, as currently stored.

    + * @property clients -

    The number of clients connected.

    + * @property subscriptions -

    The number of subscriptions connected.

    + * @property sendEvent -

    If the LiveQuery event should be sent to the client. Set to false to prevent LiveQuery from pushing to the client.

    + */ + type LiveQueryEventTrigger = { + installationId?: string; + useMasterKey: boolean; + user?: Parse.User; + sessionToken?: string; + event: string; + object: Parse.Object; + original?: Parse.Object; + clients: number; + subscriptions: number; + sendEvent: boolean; + }; + /** + * @param request -

    The request object

    + */ + type BeforeFindRequestFunc = (request: Parse.Cloud.BeforeFindRequest) => any; + /** + * @property [installationId] -

    If set, the installationId triggering the request.

    + * @property master -

    If true, means the master key was used.

    + * @property [user] -

    If set, the user that made the request.

    + * @property query -

    The query triggering the hook.

    + * @property ip -

    The IP address of the client making the request.

    + * @property headers -

    The original HTTP headers for the request.

    + * @property triggerName -

    The name of the trigger (beforeSave, afterSave, ...)

    + * @property log -

    The current logger inside Parse Server.

    + * @property isGet -

    whether the query a get or a find

    + * @property count -

    whether the query a get or a find

    + * @property readPreference -

    read preferences of the query

    + */ + type BeforeFindRequest = { + installationId?: string; + master: boolean; + user?: Parse.User; + query: Parse.Query; + ip: string; + headers: any; + triggerName: string; + log: any; + isGet: boolean; + count: boolean; + readPreference: Parse.Cloud.ReadPreferenceOption; + }; + enum ReadPreferenceOption { + Primary, + PrimaryPreferred, + Secondary, + SecondaryPreferred, + Nearest, + } + /** + * @param request -

    The request object

    + */ + type AfterFindRequestFunc = (request: Parse.Cloud.AfterFindRequest) => any; + /** + * @property [installationId] -

    If set, the installationId triggering the request.

    + * @property master -

    If true, means the master key was used.

    + * @property [user] -

    If set, the user that made the request.

    + * @property query -

    The query triggering the hook.

    + * @property results -

    The results the query yielded.

    + * @property ip -

    The IP address of the client making the request.

    + * @property headers -

    The original HTTP headers for the request.

    + * @property triggerName -

    The name of the trigger (beforeSave, afterSave, ...)

    + * @property log -

    The current logger inside Parse Server.

    + */ + type AfterFindRequest = { + installationId?: string; + master: boolean; + user?: Parse.User; + query: Parse.Query; + results: Parse.Object[]; + ip: string; + headers: any; + triggerName: string; + log: any; + }; + /** + * @param request -

    The request object

    + */ + type FunctionRequestFunc = (request: Parse.Cloud.FunctionRequest) => void; + /** + * @property [installationId] -

    If set, the installationId triggering the request.

    + * @property master -

    If true, means the master key was used.

    + * @property [user] -

    If set, the user that made the request.

    + * @property params -

    The params passed to the cloud function.

    + * @property log -

    The current logger inside Parse Server.

    + */ + type FunctionRequest = { + installationId?: string; + master: boolean; + user?: Parse.User; + params: { + [key: string]: object; + }; + log: any; + }; + /** + * @param request -

    The request object

    + */ + type JobRequestFunc = (request: Parse.Cloud.JobRequest) => void; + /** + * @property params -

    The params passed to the background job.

    + * @property error -

    If error is called, will end the job unsuccessfully with an optional completion message to be stored in the job status.

    + * @property message -

    If message is called with a string argument, will update the current message to be stored in the job status.

    + * @property success -

    If success is called, will end the job successfullly with the optional completion message to be stored in the job status.

    + */ + type JobRequest = { + params: { + [key: string]: object; + }; + error: (...params: any[]) => any; + message: (...params: any[]) => any; + success: (...params: any[]) => any; + }; + /** + * @param message -

    The request object

    + */ + type JobRequestMessage = (message: string) => void; + /** + * @property requireUser -

    whether the cloud trigger requires a user.

    + * @property requireMaster -

    whether the cloud trigger requires a master key.

    + * @property validateMasterKey -

    whether the validator should run if masterKey is provided. Defaults to false.

    + * @property skipWithMasterKey -

    whether the cloud code function should be ignored using a masterKey.

    + * @property requireAnyUserRoles -

    If set, request.user has to be part of at least one roles name to make the request. If set to a function, function must return role names.

    + * @property requireAllUserRoles -

    If set, request.user has to be part all roles name to make the request. If set to a function, function must return role names.

    + * @property requireUserKeys -

    If set, keys required on request.user to make the request.

    + * @property fields -

    if an array of strings, validator will look for keys in request.params, and throw if not provided. If Object, fields to validate. If the trigger is a cloud function, request.params will be validated, otherwise request.object.

    + */ + type ValidatorObject = { + requireUser: boolean; + requireMaster: boolean; + validateMasterKey: boolean; + skipWithMasterKey: boolean; + requireAnyUserRoles: string[] | ((...params: any[]) => any); + requireAllUserRoles: string[] | ((...params: any[]) => any); + requireUserKeys: + | { + [key: string]: Parse.Cloud.ValidatorObjectFieldOptions; + } + | string[]; + fields: + | { + [key: string]: Parse.Cloud.ValidatorObjectFieldOptions; + } + | string[]; + }; + /** + * @property type -

    expected type of data for field.

    + * @property constant -

    whether the field can be modified on the object.

    + * @property default -

    default value if field is null, or initial value constant is true.

    + * @property options -

    array of options that the field can be, function to validate field, or single value. Throw an error if value is invalid.

    + * @property error -

    custom error message if field is invalid.

    + */ + type ValidatorObjectFieldOptions = { + type: any; + constant: boolean; + default: any; + options: any[] | ((...params: any[]) => any) | any; + error: string; + }; + /** + * @property [body] -

    The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent.

    + * @property [error] -

    The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object.

    + * @property [followRedirects] -

    Whether to follow redirects caused by HTTP 3xx responses. Defaults to false.

    + * @property [headers] -

    The headers for the request.

    + * @property [method] -

    The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified.

    + * @property [params] -

    The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott.

    + * @property url -

    The url to send the request to.

    + */ + type HTTPOptions = { + body?: string | any; + error?: (...params: any[]) => any; + followRedirects?: boolean; + headers?: any; + method?: string; + params?: string | any; + url: string; + }; + /** + * @property buffer -

    The raw byte representation of the response body. Use this to receive binary data. See Buffer for more details.

    + * @property cookies -

    The cookies sent by the server. The keys in this object are the names of the cookies. The values are Parse.Cloud.Cookie objects.

    + * @property data -

    The parsed response body as a JavaScript object. This is only available when the response Content-Type is application/x-www-form-urlencoded or application/json.

    + * @property headers -

    The headers sent by the server. The keys in this object are the names of the headers. We do not support multiple response headers with the same name. In the common case of Set-Cookie headers, please use the cookies field instead.

    + * @property status -

    The status code.

    + * @property text -

    The raw text representation of the response body.

    + */ + type HTTPResponse = { + buffer: Buffer; + cookies: any; + data: any; + headers: any; + status: number; + text: string; + }; + } + /** + *

    Provides utility functions to queue objects that will be + * saved to the server at a later date.

    + */ + class EventuallyQueue { + /** + *

    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.

    + */ + static save(object: Parse.Object, serverOptions?: any): 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.

    + */ + static destroy(object: Parse.Object, serverOptions?: any): Promise; + /** + *

    Sets the in-memory queue from local storage and returns.

    + */ + static getQueue(): Promise; + /** + *

    Removes all objects from queue.

    + * @returns

    A promise that is fulfilled when queue is cleared.

    + */ + static clear(): Promise; + /** + *

    Return the number of objects in the queue.

    + */ + static length(): number; + /** + *

    Sends the queue to the server.

    + * @returns

    Returns true if queue was sent successfully.

    + */ + static sendQueue(): Promise; + /** + *

    Start polling server for network connection. + * Will send queue if connection is established.

    + * @param [ms] -

    Milliseconds to ping the server. Default 2000ms

    + */ + static poll(ms?: any): void; + /** + *

    Turns off polling.

    + */ + static stopPoll(): void; + /** + *

    Return true if pinging the server.

    + */ + static isPolling(): boolean; + } + /** + *

    Provides a set of utilities for using Parse with Facebook.

    + */ + class 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.

    + * @param 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.

    + */ + static init(options: any): void; + /** + *

    Gets whether the user has their account linked to Facebook.

    + * @param user -

    User to check for a facebook link. + * The user must be logged in on this device.

    + * @returns

    true if the user has their account + * linked to Facebook.

    + */ + static 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);

    + * @param 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 options -

    MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string

    + */ + static logIn(permissions: string | 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);

    + * @param user -

    User to link to Facebook. This must be the + * current user.

    + * @param 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 options -

    MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string

    + */ + static link(user: Parse.User, permissions: string | any, options: any): Promise; + /** + *

    Unlinks the Parse.User from a Facebook account.

    + * @param user -

    User to unlink from Facebook. This must be the + * current user.

    + * @param options -

    Standard options object with success and error + * callbacks.

    + */ + static unlink(user: Parse.User, options: any): Promise; + } + /** + *

    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) => {
    +   *
    +   * });
    + * @param options.applicationId -

    applicationId of your Parse app

    + * @param options.serverURL -

    the URL of your LiveQuery server

    + * @param options.javascriptKey -

    (optional)

    + * @param options.masterKey -

    (optional) Your Parse Master Key. (Node.js only!)

    + * @param options.sessionToken -

    (optional)

    + * @param options.installationId -

    (optional)

    + */ + class LiveQueryClient { + constructor(options: { + applicationId: string; + serverURL: string; + javascriptKey: string; + masterKey: string; + sessionToken: string; + installationId: string; + }); + /** + *

    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 query -

    the ParseQuery you want to subscribe to

    + * @param sessionToken -

    (optional)

    + * @returns

    subscription

    + */ + subscribe(query: any, sessionToken: string): LiveQuerySubscription; + /** + *

    After calling unsubscribe you'll stop receiving events from the subscription object.

    + * @param subscription -

    subscription you would like to unsubscribe from.

    + */ + unsubscribe(subscription: any): void; + /** + *

    After open is called, the LiveQueryClient will try to send a connect request + * to the LiveQuery server.

    + */ + open(): void; + /** + *

    This method will close the WebSocket connection to this LiveQueryClient, + * cancel the auto reconnect and unsubscribe all subscriptions based on it.

    + */ + close(): void; + } + /** + *

    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', () => {
    +   *
    +   * });

    + * @param id -

    subscription id

    + * @param query -

    query to subscribe to

    + * @param sessionToken -

    optional session token

    + */ + class LiveQuerySubscription { + constructor(id: string, query: string, sessionToken: string); + /** + *

    Close the subscription

    + */ + unsubscribe(): Promise; + on(event: string, callback: LiveQueryEventCallback): void; + } + /** + *

    Provides a local datastore which can be used to store and retrieve Parse.Object.
    + * To enable this functionality, call Parse.enableLocalDatastore().

    + *

    Pin object to add to local datastore

    + *
    await object.pin();
    + *
    await object.pinWithName('pinName');
    + *

    Query pinned objects

    + *
    query.fromLocalDatastore();
    + *
    query.fromPin();
    + *
    query.fromPinWithName();
    + *
    const localObjects = await query.find();
    + */ + class LocalDatastore { + /** + *

    Updates Local Datastore from Server

    + *
    +     * await Parse.LocalDatastore.updateFromServer();
    +     * 
    + */ + static updateFromServer(): void; + } + type AuthData = any; + type AuthProvider = any; + type Op = { + Set: any; + Unset: any; + Increment: any; + Add: any; + Remove: any; + AddUnique: any; + Relation: any; + }; + /** + *

    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.

    + * @param [arg1] -

    The user to initialize the ACL for

    + */ + class ACL { + constructor(arg1?: Parse.User | any); + /** + *

    Returns a JSON-encoded version of the ACL.

    + */ + toJSON(): any; + /** + *

    Returns whether this ACL is equal to another object

    + * @param other -

    The other object's ACL to compare to

    + */ + equals(other: Parse.ACL): boolean; + /** + *

    Sets whether the given user is allowed to read this object.

    + * @param userId -

    An instance of Parse.User or its objectId.

    + * @param 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 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.

    + */ + getReadAccess(userId: any): 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 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 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.

    + */ + getWriteAccess(userId: any): boolean; + /** + *

    Sets whether the public is allowed to read this object.

    + */ + setPublicReadAccess(allowed: boolean): void; + /** + *

    Gets whether the public is allowed to read this object.

    + */ + getPublicReadAccess(): boolean; + /** + *

    Sets whether the public is allowed to write this object.

    + */ + setPublicWriteAccess(allowed: boolean): void; + /** + *

    Gets whether the public is allowed to write this object.

    + */ + 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

    true if the role has read access. false otherwise.

    + */ + getRoleReadAccess(role: any): 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

    true if the role has write access. false otherwise.

    + */ + getRoleWriteAccess(role: any): 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 allowed -

    Whether the given role can read this object.

    + */ + setRoleReadAccess(role: any, 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 allowed -

    Whether the given role can write this object.

    + */ + setRoleWriteAccess(role: any, allowed: boolean): void; + } + /** + *

    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)

    + *

    + * @param userId -

    The user to initialize the CLP for

    + */ + class CLP { + constructor(userId: Parse.User | Parse.Role | any); + /** + *

    Returns a JSON-encoded version of the CLP.

    + */ + toJSON(): any; + /** + *

    Returns whether this CLP is equal to another object

    + * @param other -

    The other object to compare to

    + */ + equals(other: any): boolean; + /** + *

    Sets user pointer fields to allow permission for get/count/find operations.

    + * @param pointerFields -

    User pointer fields

    + */ + setReadUserFields(pointerFields: string[]): void; + /** + * @returns

    User pointer fields

    + */ + getReadUserFields(): string[]; + /** + *

    Sets user pointer fields to allow permission for create/delete/update/addField operations

    + * @param pointerFields -

    User pointer fields

    + */ + setWriteUserFields(pointerFields: string[]): void; + /** + * @returns

    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 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.

    + */ + 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 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.

    + */ + 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 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.

    + */ + getWriteAccess(userId: any): boolean; + /** + *

    Sets whether the public is allowed to read from this class.

    + */ + setPublicReadAccess(allowed: boolean): void; + /** + *

    Gets whether the public is allowed to read from this class.

    + */ + getPublicReadAccess(): boolean; + /** + *

    Sets whether the public is allowed to write to this class.

    + */ + setPublicWriteAccess(allowed: boolean): void; + /** + *

    Gets whether the public is allowed to write to this class.

    + */ + getPublicWriteAccess(): boolean; + /** + *

    Sets whether the public is allowed to protect fields in this class.

    + */ + setPublicProtectedFields(fields: string[]): void; + /** + *

    Gets whether the public is allowed to read fields from this class.

    + */ + 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

    true if the role has read access. false otherwise.

    + */ + getRoleReadAccess(role: any): 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

    true if the role has write access. false otherwise.

    + */ + getRoleWriteAccess(role: any): 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 allowed -

    Whether the given role can read this object.

    + */ + setRoleReadAccess(role: any, 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 allowed -

    Whether the given role can write this object.

    + */ + setRoleWriteAccess(role: any, 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.

    + */ + getRoleProtectedFields(role: any): 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 fields -

    Fields to be protected by Role.

    + */ + setRoleProtectedFields(role: any, fields: string[]): void; + } + /** + *

    Parse.Config is a local representation of configuration data that + * can be set from the Parse dashboard.

    + */ + class Config { + /** + *

    Gets the value of an attribute.

    + * @param attr -

    The name of an attribute.

    + */ + get(attr: string): any; + /** + *

    Gets the HTML-escaped value of an attribute.

    + * @param attr -

    The name of an attribute.

    + */ + escape(attr: string): string; + /** + *

    Retrieves the most recently-fetched configuration object, either from + * memory or from local storage if necessary.

    + * @returns

    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.

    + * @param options -

    Valid options are:

      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    + * @returns

    A promise that is resolved with a newly-created + * configuration object when the get completes.

    + */ + static get(options: any): Promise; + /** + *

    Save value keys to the server.

    + * @param attrs -

    The config parameters and values.

    + * @param 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

    A promise that is resolved with a newly-created + * configuration object or with the current with the update.

    + */ + static save(attrs: any, masterKeyOnlyFlags: any): Promise; + /** + *

    Used for testing

    + */ + private static _clearCache(): void; + } + /** + *

    Constructs a new Parse.Error object with the given code and message.

    + * @param code -

    An error code constant from Parse.Error.

    + * @param message -

    A detailed description of the error.

    + */ + class Error { + constructor(code: number, message: string); + /** + *

    Error code indicating some error other than those enumerated here.

    + */ + static OTHER_CAUSE: number; + /** + *

    Error code indicating that something has gone wrong with the server.

    + */ + static INTERNAL_SERVER_ERROR: number; + /** + *

    Error code indicating the connection to the Parse servers failed.

    + */ + static CONNECTION_FAILED: number; + /** + *

    Error code indicating the specified object doesn't exist.

    + */ + static OBJECT_NOT_FOUND: number; + /** + *

    Error code indicating you tried to query with a datatype that doesn't + * support it, like exact matching an array or object.

    + */ + static INVALID_QUERY: number; + /** + *

    Error code indicating a missing or invalid classname. Classnames are + * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the + * only valid characters.

    + */ + static INVALID_CLASS_NAME: number; + /** + *

    Error code indicating an unspecified object id.

    + */ + static MISSING_OBJECT_ID: number; + /** + *

    Error code indicating an invalid key name. Keys are case-sensitive. They + * must start with a letter, and a-zA-Z0-9_ are the only valid characters.

    + */ + static INVALID_KEY_NAME: number; + /** + *

    Error code indicating a malformed pointer. You should not see this unless + * you have been mucking about changing internal Parse code.

    + */ + static INVALID_POINTER: number; + /** + *

    Error code indicating that badly formed JSON was received upstream. This + * either indicates you have done something unusual with modifying how + * things encode to JSON, or the network is failing badly.

    + */ + static INVALID_JSON: number; + /** + *

    Error code indicating that the feature you tried to access is only + * available internally for testing purposes.

    + */ + static COMMAND_UNAVAILABLE: number; + /** + *

    You must call Parse.initialize before using the Parse library.

    + */ + static NOT_INITIALIZED: number; + /** + *

    Error code indicating that a field was set to an inconsistent type.

    + */ + static INCORRECT_TYPE: number; + /** + *

    Error code indicating an invalid channel name. A channel name is either + * an empty string (the broadcast channel) or contains only a-zA-Z0-9_ + * characters and starts with a letter.

    + */ + static INVALID_CHANNEL_NAME: number; + /** + *

    Error code indicating that push is misconfigured.

    + */ + static PUSH_MISCONFIGURED: number; + /** + *

    Error code indicating that the object is too large.

    + */ + static OBJECT_TOO_LARGE: number; + /** + *

    Error code indicating that the operation isn't allowed for clients.

    + */ + static OPERATION_FORBIDDEN: number; + /** + *

    Error code indicating the result was not found in the cache.

    + */ + static CACHE_MISS: number; + /** + *

    Error code indicating that an invalid key was used in a nested + * JSONObject.

    + */ + static INVALID_NESTED_KEY: number; + /** + *

    Error code indicating that an invalid filename was used for ParseFile. + * A valid file name contains only a-zA-Z0-9_. characters and is between 1 + * and 128 characters.

    + */ + static INVALID_FILE_NAME: number; + /** + *

    Error code indicating an invalid ACL was provided.

    + */ + static INVALID_ACL: number; + /** + *

    Error code indicating that the request timed out on the server. Typically + * this indicates that the request is too expensive to run.

    + */ + static TIMEOUT: number; + /** + *

    Error code indicating that the email address was invalid.

    + */ + static INVALID_EMAIL_ADDRESS: number; + /** + *

    Error code indicating a missing content type.

    + */ + static MISSING_CONTENT_TYPE: number; + /** + *

    Error code indicating a missing content length.

    + */ + static MISSING_CONTENT_LENGTH: number; + /** + *

    Error code indicating an invalid content length.

    + */ + static INVALID_CONTENT_LENGTH: number; + /** + *

    Error code indicating a file that was too large.

    + */ + static FILE_TOO_LARGE: number; + /** + *

    Error code indicating an error saving a file.

    + */ + static FILE_SAVE_ERROR: number; + /** + *

    Error code indicating that a unique field was given a value that is + * already taken.

    + */ + static DUPLICATE_VALUE: number; + /** + *

    Error code indicating that a role's name is invalid.

    + */ + static INVALID_ROLE_NAME: number; + /** + *

    Error code indicating that an application quota was exceeded. Upgrade to + * resolve.

    + */ + static EXCEEDED_QUOTA: number; + /** + *

    Error code indicating that a Cloud Code script failed.

    + */ + static SCRIPT_FAILED: number; + /** + *

    Error code indicating that a Cloud Code validation failed.

    + */ + static VALIDATION_ERROR: number; + /** + *

    Error code indicating that invalid image data was provided.

    + */ + static INVALID_IMAGE_DATA: number; + /** + *

    Error code indicating an unsaved file.

    + */ + static UNSAVED_FILE_ERROR: number; + /** + *

    Error code indicating an invalid push time.

    + */ + static INVALID_PUSH_TIME_ERROR: number; + /** + *

    Error code indicating an error deleting a file.

    + */ + static FILE_DELETE_ERROR: number; + /** + *

    Error code indicating an error deleting an unnamed file.

    + */ + static FILE_DELETE_UNNAMED_ERROR: number; + /** + *

    Error code indicating that the application has exceeded its request + * limit.

    + */ + static REQUEST_LIMIT_EXCEEDED: number; + /** + *

    Error code indicating that the request was a duplicate and has been discarded due to + * idempotency rules.

    + */ + static DUPLICATE_REQUEST: number; + /** + *

    Error code indicating an invalid event name.

    + */ + static INVALID_EVENT_NAME: number; + /** + *

    Error code indicating that a field had an invalid value.

    + */ + static INVALID_VALUE: number; + /** + *

    Error code indicating that the username is missing or empty.

    + */ + static USERNAME_MISSING: number; + /** + *

    Error code indicating that the password is missing or empty.

    + */ + static PASSWORD_MISSING: number; + /** + *

    Error code indicating that the username has already been taken.

    + */ + static USERNAME_TAKEN: number; + /** + *

    Error code indicating that the email has already been taken.

    + */ + static EMAIL_TAKEN: number; + /** + *

    Error code indicating that the email is missing, but must be specified.

    + */ + static EMAIL_MISSING: number; + /** + *

    Error code indicating that a user with the specified email was not found.

    + */ + static EMAIL_NOT_FOUND: number; + /** + *

    Error code indicating that a user object without a valid session could + * not be altered.

    + */ + static SESSION_MISSING: number; + /** + *

    Error code indicating that a user can only be created through signup.

    + */ + static MUST_CREATE_USER_THROUGH_SIGNUP: number; + /** + *

    Error code indicating that an an account being linked is already linked + * to another user.

    + */ + static ACCOUNT_ALREADY_LINKED: number; + /** + *

    Error code indicating that the current session token is invalid.

    + */ + static INVALID_SESSION_TOKEN: number; + /** + *

    Error code indicating an error enabling or verifying MFA

    + */ + static MFA_ERROR: number; + /** + *

    Error code indicating that a valid MFA token must be provided

    + */ + static MFA_TOKEN_REQUIRED: number; + /** + *

    Error code indicating that a user cannot be linked to an account because + * that account's id could not be found.

    + */ + static LINKED_ID_MISSING: number; + /** + *

    Error code indicating that a user with a linked (e.g. Facebook) account + * has an invalid session.

    + */ + static INVALID_LINKED_SESSION: number; + /** + *

    Error code indicating that a service being linked (e.g. Facebook or + * Twitter) is unsupported.

    + */ + static UNSUPPORTED_SERVICE: number; + /** + *

    Error code indicating an invalid operation occured on schema

    + */ + static INVALID_SCHEMA_OPERATION: number; + /** + *

    Error code indicating that there were multiple errors. Aggregate errors + * have an "errors" property, which is an array of error objects with more + * detail about each error that occurred.

    + */ + static AGGREGATE_ERROR: number; + /** + *

    Error code indicating the client was unable to read an input file.

    + */ + static FILE_READ_ERROR: number; + /** + *

    Error code indicating a real error code is unavailable because + * we had to use an XDomainRequest object to allow CORS requests in + * Internet Explorer, which strips the body from HTTP responses that have + * a non-2XX status code.

    + */ + static X_DOMAIN_REQUEST: number; + } + /** + *

    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. 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] -

    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] -

    Optional key value pairs to be stored with file object

    + * @param [tags] -

    Optional key value pairs to be stored with file object

    + */ + class File { + constructor(name: string, data: any[] | Blob | any, type?: string, metadata?: any, tags?: any); + /** + *

    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 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.

    + */ + 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 [options] -

    An object to specify url options

    + * @param [options.forceSecure] -

    Force secure

    + */ + url(options?: { forceSecure?: boolean }): string; + /** + *

    Gets the metadata of the file.

    + */ + metadata(): any; + /** + *

    Gets the tags of the file.

    + */ + tags(): any; + /** + *

    Saves the file to the Parse cloud.

    + * @param [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 that is resolved when the save finishes.

    + */ + save(options?: FullOptions): Promise; + /** + *

    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 [options] -
      + *
    • Valid options are:
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
      • + *
      + *
      +     * @returns 

      Promise that is resolved when the delete finishes.

      + */ + destroy(options?: FullOptions): Promise; + /** + *

      Returns a JSON representation of this file.

      + * @returns

      The JSON representation of the file.

      + */ + toJSON(): any; + /** + *

      Sets metadata to be saved with file object. Overwrites existing metadata

      + * @param 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 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 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 key -

      key to store tags

      + * @param value -

      tag

      + */ + addTag(key: string, value: any): void; + } + /** + *

      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();

      + * @param [arg1] -

      Either a list of coordinate pairs, an object with latitude, longitude, or the latitude or the point.

      + * @param [arg2] -

      The longitude of the GeoPoint

      + */ + class GeoPoint { + constructor(arg1?: number[] | any | number, arg2?: number); + /** + *

      North-south portion of the coordinate, in range [-90, 90]. + * Throws an exception if set out of range in a modern browser.

      + */ + latitude: { + latitude: number; + }; + /** + *

      East-west portion of the coordinate, in range [-180, 180]. + * Throws if set out of range in a modern browser.

      + */ + longitude: { + longitude: number; + }; + /** + *

      Returns a JSON representation of the GeoPoint, suitable for Parse.

      + */ + toJSON(): any; + /** + *

      Returns the distance from this GeoPoint to another in radians.

      + * @param point -

      the other Parse.GeoPoint.

      + */ + radiansTo(point: Parse.GeoPoint): number; + /** + *

      Returns the distance from this GeoPoint to another in kilometers.

      + * @param point -

      the other Parse.GeoPoint.

      + */ + kilometersTo(point: Parse.GeoPoint): number; + /** + *

      Returns the distance from this GeoPoint to another in miles.

      + * @param point -

      the other Parse.GeoPoint.

      + */ + milesTo(point: Parse.GeoPoint): number; + /** + *

      Creates a GeoPoint with the user's current location, if available.

      + * @returns

      User's current location

      + */ + static current(): Parse.GeoPoint; + } + /** + * @param [attributes] -

      The initial set of data to store in the installation.

      + */ + class Installation { + constructor(attributes?: any); + } + /** + *

      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 LiveQuery { + /** + *

      After open is called, the LiveQuery will try to send a connect request + * to the LiveQuery server.

      + * @param func -

      function to run on open

      + */ + static open(func: (...params: any[]) => any): void; + /** + *

      When you're done using LiveQuery, you can call Parse.LiveQuery.close(). + * This function will close the WebSocket connection to the LiveQuery server, + * cancel the auto reconnect, and unsubscribe all subscriptions based on it. + * If you call query.subscribe() after this, we'll create a new WebSocket + * connection to the LiveQuery server.

      + * @param func -

      function to run on close

      + */ + static close(func: (...params: any[]) => any): void; + } + type Pointer = { + __type: string; + className: string; + objectId: string; + }; + /** + *

      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();
      +   * 

      + * @param [className] -

      The class name for the object

      + * @param [attributes] -

      The initial set of data to store in the object.

      + * @param [options] -

      The options for this object instance.

      + * @param [options.ignoreValidation] -

      Ignore validation

      + */ + class Object { + attributes: T; + add( + attr: K, + item: T[K][number] + ): this | false; + addAll( + attr: K, + items: T[K] + ): this | false; + dirty(attr?: Extract): boolean; + equals(other: T): boolean; + escape(attr: Extract): string; + fetchWithInclude>( + keys: K | Array, + options?: RequestOptions + ): Promise; + get>(attr: K): T[K]; + has(attr: Extract): boolean; + increment(attr: Extract, amount?: number): this | false; + decrement(attr: Extract, amount?: number): this | false; + op(attr: Extract): any; + relation = Extract>( + attr: T[K] extends Relation ? K : never + ): Relation; + revert(...keys: Array>): void; + save>( + attrs?: Pick | T | null, + options?: SaveOptions + ): Promise; + save>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: SaveOptions + ): Promise; + set>(attrs: Pick | T, options?: any): this | false; + set>( + key: K, + value: T[K] extends undefined ? never : T[K], + options?: any + ): this | false; + toJSON(): ToJSON & JSONBaseAttributes; + unset(attr: Extract, options?: any): this | false; + + constructor( + className?: string, + attributes?: any, + options?: { + ignoreValidation?: boolean; + } + ); + /** + *

      Object attributes

      + */ + attributes: any; + /** + *

      The first time this object was saved on the server.

      + */ + createdAt: Date; + /** + *

      The last time this object was updated on the server.

      + */ + updatedAt: Date; + /** + *

      Returns a local or server Id used uniquely identify this object

      + */ + _getId(): string; + /** + *

      Returns a unique identifier used to pull data from the State Controller.

      + */ + _getStateIdentifier(): Parse.Object | any; + /** + * @param [keysToClear] -

      if specified, only ops matching + * these fields will be cleared

      + */ + _clearPendingOps(keysToClear?: string[]): void; + /** + *

      Public methods

      + */ + initialize(): void; + /** + *

      Returns a JSON version of the object suitable for saving to Parse.

      + */ + toJSON(seen?: any, offline?: any): any; + /** + *

      Determines whether this ParseObject is equal to another ParseObject

      + * @param other -

      An other object ot compare

      + */ + equals(other: any): 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 [attr] -

      An attribute name (optional).

      + */ + dirty(attr?: string): boolean; + /** + *

      Returns an array of keys that have been modified since last save/refresh

      + */ + dirtyKeys(): string[]; + /** + *

      Returns true if the object has been fetched.

      + */ + isDataAvailable(): boolean; + /** + *

      Gets a Pointer referencing this Object.

      + */ + toPointer(): Pointer; + /** + *

      Gets a Pointer referencing this Object.

      + */ + toOfflinePointer(): Pointer; + /** + *

      Gets the value of an attribute.

      + * @param attr -

      The string name of an attribute.

      + */ + get(attr: string): any; + /** + *

      Gets a relation on the given class for the attribute.

      + * @param attr -

      The attribute to get the relation for.

      + */ + relation(attr: string): Parse.Relation; + /** + *

      Gets the HTML-escaped value of an attribute.

      + * @param attr -

      The string name of an attribute.

      + */ + escape(attr: string): string; + /** + *

      Returns true if the attribute contains a value that is not + * null or undefined.

      + * @param attr -

      The string name of the attribute.

      + */ + 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 key -

      The key to set.

      + * @param [value] -

      The value to give it. Optional if key is an object.

      + * @param [options] -

      A set of options for the set. + * The only supported option is error.

      + * @returns

      true if the set succeeded.

      + */ + set(key: string | any, value?: string | any, options?: any): Parse.Object | boolean; + /** + *

      Remove an attribute from the model. This is a noop if the attribute doesn't + * exist.

      + * @param attr -

      The string name of an attribute.

      + */ + unset(attr: string, options?: any): Parse.Object | 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 -

      The key.

      + * @param [amount] -

      The amount to increment by (optional).

      + */ + increment(attr: string, amount?: number): Parse.Object | 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 -

      The key.

      + * @param [amount] -

      The amount to decrement by (optional).

      + */ + decrement(attr: string, amount?: number): Parse.Object | boolean; + /** + *

      Atomically add an object to the end of the array associated with a given + * key.

      + * @param attr -

      The key.

      + * @param item -

      The item to add.

      + */ + add(attr: string, item: any): Parse.Object | boolean; + /** + *

      Atomically add the objects to the end of the array associated with a given + * key.

      + * @param attr -

      The key.

      + * @param items -

      The items to add.

      + */ + addAll(attr: string, items: any[]): Parse.Object | 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 -

      The key.

      + * @param item -

      The object to add.

      + */ + addUnique(attr: string, item: any): Parse.Object | 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 -

      The key.

      + * @param items -

      The objects to add.

      + */ + addAllUnique(attr: string, items: any[]): Parse.Object | boolean; + /** + *

      Atomically remove all instances of an object from the array associated + * with a given key.

      + * @param attr -

      The key.

      + * @param item -

      The object to remove.

      + */ + remove(attr: string, item: any): Parse.Object | boolean; + /** + *

      Atomically remove all instances of the objects from the array associated + * with a given key.

      + * @param attr -

      The key.

      + * @param items -

      The object to remove.

      + */ + removeAll(attr: string, items: any[]): Parse.Object | 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 -

      The key.

      + * @returns

      The operation, or undefined if none.

      + */ + op(attr: string): Parse.Op; + /** + *

      Creates a new model with identical attributes to this one.

      + */ + clone(): Parse.Object; + /** + *

      Creates a new instance of this object. Not to be confused with clone()

      + */ + newInstance(): Parse.Object; + /** + *

      Returns true if this object has never been saved to Parse.

      + */ + 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)

      + */ + existed(): boolean; + /** + *

      Returns true if this object exists on the Server

      + * @param 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

      A boolean promise that is fulfilled if object exists.

      + */ + exists(options: any): Promise; + /** + *

      Checks if the model is currently in a valid state.

      + */ + 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 attrs -

      The current data to validate.

      + * @returns

      False if the data is valid. An error object otherwise.

      + */ + validate(attrs: any): Parse.Error | boolean; + /** + *

      Returns the ACL for this object.

      + * @returns

      An instance of Parse.ACL.

      + */ + getACL(): Parse.ACL; + /** + *

      Sets the ACL to be used for this object.

      + * @param acl -

      An instance of Parse.ACL.

      + * @returns

      Whether the set passed validation.

      + */ + setACL(acl: Parse.ACL, options?: any): Parse.Object | boolean; + /** + *

      Clears any (or specific) changes to this object made since the last call to save()

      + * @param keys -

      specify which fields to revert

      + */ + revert(...keys: string[]): void; + /** + *

      Clears all attributes on a model

      + */ + clear(): Parse.Object | 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 [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

      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 keys -

      The name(s) of the key(s) to include.

      + * @param [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

      A promise that is fulfilled when the fetch + * completes.

      + */ + fetchWithInclude(keys: string | (string | string[])[], 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 [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

      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 [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 [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 [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

      A promise that is fulfilled when the save + * completes.

      + */ + save( + arg1?: string | any | null, + arg2?: string | SaveOptions, + 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 [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

      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 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

      A promise that is fulfilled when the destroy + * completes.

      + */ + destroy(options: any): 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

      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

      A promise that is fulfilled when the unPin completes.

      + */ + unPin(): Promise; + /** + *

      Asynchronously returns if the object is pinned

      + *
      +     * const isPinned = await object.isPinned();
      +     * 
      + * @returns

      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 name -

      Name of Pin.

      + * @returns

      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 name -

      Name of Pin.

      + * @returns

      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

      A promise that is fulfilled when the fetch completes.

      + */ + fetchFromLocalDatastore(): Promise; + /** + *

      Static methods

      + */ + 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 list -

      A list of Parse.Object.

      + * @param 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 fetchAll(list: any[], options: any): 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 list -

      A list of Parse.Object.

      + * @param keys -

      The name(s) of the key(s) to include.

      + */ + static fetchAllWithInclude( + list: any[], + keys: string | (string | string[])[], + 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 list -

      A list of Parse.Object.

      + * @param keys -

      The name(s) of the key(s) to include.

      + */ + static fetchAllIfNeededWithInclude( + list: any[], + keys: string | (string | string[])[], + 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 list -

      A list of Parse.Object.

      + */ + static fetchAllIfNeeded(list: any[], options: any): Parse.Object[]; + /** + *

      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 list -

      A list of Parse.Object.

      + * @returns

      A promise that is fulfilled when the destroyAll + * completes.

      + */ + static destroyAll(list: any[], options: any): 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 list -

      A list of Parse.Object.

      + */ + static saveAll(list: any[], 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 id -

      The ID of the object to create a reference to.

      + * @returns

      A Parse.Object reference.

      + */ + static createWithoutData(id: string): Parse.Object; + /** + *

      Creates a new instance of a Parse Object from a JSON representation.

      + * @param json -

      The JSON map of the Object's data

      + * @param [override] -

      In single instance mode, all old server data + * is overwritten if this is set to true

      + * @param [dirty] -

      Whether the Parse.Object should set JSON keys to dirty

      + * @returns

      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 className -

      The class name of the subclass

      + * @param constructor -

      The subclass

      + */ + static registerSubclass(className: string, constructor: (...params: any[]) => any): void; + /** + *

      Unegisters a subclass of Parse.Object with a specific class name.

      + * @param 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 className -

      The name of the Parse class backing this model.

      + * @param protoProps -

      Instance properties to add to instances of the + * class returned from this method.

      + * @param classProps -

      Class properties to add the class returned from + * this method.

      + * @returns

      A new subclass of Parse.Object.

      + */ + static extend(className: string, 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 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 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 objects -

      A list of Parse.Object.

      + * @returns

      A promise that is fulfilled when the pin completes.

      + */ + static pinAll(objects: any[]): 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 name -

      Name of Pin.

      + * @param objects -

      A list of Parse.Object.

      + * @returns

      A promise that is fulfilled when the pin completes.

      + */ + static pinAllWithName(name: string, objects: any[]): 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 objects -

      A list of Parse.Object.

      + * @returns

      A promise that is fulfilled when the unPin completes.

      + */ + static unPinAll(objects: any[]): Promise; + /** + *

      Asynchronously removes the objects and every object they point to in the local datastore, recursively.

      + *
      +     * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
      +     * 
      + * @param name -

      Name of Pin.

      + * @param objects -

      A list of Parse.Object.

      + * @returns

      A promise that is fulfilled when the unPin completes.

      + */ + static unPinAllWithName(name: string, objects: any[]): Promise; + /** + *

      Asynchronously removes all objects in the local datastore using a default pin name: _default.

      + *
      +     * await Parse.Object.unPinAllObjects();
      +     * 
      + * @returns

      A promise that is fulfilled when the unPin completes.

      + */ + static unPinAllObjects(): Promise; + /** + *

      Asynchronously removes all objects with the specified pin name. + * Deletes the pin name also.

      + *
      +     * await Parse.Object.unPinAllObjectsWithName(name);
      +     * 
      + * @param name -

      Name of Pin.

      + * @returns

      A promise that is fulfilled when the unPin completes.

      + */ + static unPinAllObjectsWithName(name: string): Promise; + } + /** + *

      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();

      + * @param coordinates -

      An Array of coordinate pairs

      + */ + class Polygon { + constructor(coordinates: number[][] | Parse.GeoPoint[]); + /** + *

      Coordinates value for this Polygon. + * Throws an exception if not valid type.

      + * @property coordinates -

      list of coordinates

      + */ + coordinates: { + coordinates: number[][] | Parse.GeoPoint[]; + }; + /** + *

      Returns a JSON representation of the Polygon, suitable for Parse.

      + */ + toJSON(): any; + /** + *

      Checks if two polygons are equal

      + */ + equals(other: Parse.Polygon | any): boolean; + /** + * @returns

      Returns if the point is contained in the polygon

      + */ + containsPoint(point: Parse.GeoPoint): boolean; + /** + *

      Validates that the list of coordinates can form a valid polygon

      + * @param coords -

      the list of coordinates to validate as a polygon

      + * @returns

      Array of coordinates if validated.

      + */ + static _validate(coords: any[]): number[][]; + } + /** + *

      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.
      +   * });

      + * @param objectClass -

      An instance of a subclass of Parse.Object, or a Parse className string.

      + */ + class Query { + 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: AggregationPipeline | AggregationPipeline[]): 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; + 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?: BatchOptions + ): Promise; + each(callback: (obj: T) => PromiseLike | void, options?: BatchOptions): Promise; + map( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | U, + options?: BatchOptions + ): Promise; + reduce( + callback: (accumulator: T, currentObject: T, index: number) => PromiseLike | T, + initialValue?: undefined, + options?: BatchOptions + ): Promise; + reduce( + callback: (accumulator: U, currentObject: T, index: number) => PromiseLike | U, + initialValue: U, + options?: BatchOptions + ): Promise; + filter( + callback: (currentObject: T, index: number, query: Query) => PromiseLike | boolean, + options?: 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?: QueryOptions): Promise; + findAll(options?: BatchOptions): Promise; + first(options?: QueryOptions): Promise; + fromNetwork(): this; + fromLocalDatastore(): this; + fromPin(): this; + fromPinWithName(name: string): this; + cancel(): this; + fullText( + key: K, + value: string, + options?: FullTextOptions + ): this; + get(objectId: string, options?: QueryOptions): 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; + 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; + + constructor(objectClass: string | Parse.Object); + /** + *

      Adds constraint that at least one of the passed in queries matches.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + _orQuery(queries: any[]): Parse.Query; + /** + *

      Adds constraint that all of the passed in queries match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + _andQuery(queries: any[]): Parse.Query; + /** + *

      Adds constraint that none of the passed in queries match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + _norQuery(queries: any[]): Parse.Query; + /** + *

      Helper for condition queries

      + */ + _addCondition(key: any, condition: any, value: any): Parse.Query; + /** + *

      Converts string for regular expression at the beginning

      + */ + _regexStartWith(string: any): string; + /** + *

      Returns a JSON representation of this query.

      + * @returns

      The JSON representation of the query.

      + */ + toJSON(): any; + /** + *

      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 json -

      from Parse.Query.toJSON() method

      + * @returns

      Returns the query, so you can chain this call.

      + */ + withJSON(json: QueryJSON): Parse.Query; + /** + *

      Static method to restore Parse.Query by json representation + * Internally calling Parse.Query.withJSON

      + * @param json -

      from Parse.Query.toJSON() method

      + * @returns

      new created query

      + */ + static fromJSON(className: string, json: QueryJSON): Parse.Query; + /** + *

      Constructs a Parse.Object whose id is already known by fetching data from + * the server. Unlike the first method, it never returns undefined.

      + * @param objectId -

      The id of the object to be fetched.

      + * @param [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

      A promise that is resolved with the result when + * the query completes.

      + */ + get(objectId: string, options?: QueryOptions): Promise; + /** + *

      Retrieves a list of ParseObjects that satisfy this query.

      + * @param [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

      A promise that is resolved with the results when + * the query completes.

      + */ + find(options?: QueryOptions): Promise; + /** + *

      Retrieves a complete list of ParseObjects that satisfy this query. + * Using eachBatch under the hood to fetch all the valid objects.

      + * @returns

      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 [options.sessionToken] -

      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

      A promise that is resolved with the count when + * the query completes.

      + */ + count(options: { useMasterKey?: boolean; sessionToken?: string }): Promise; + /** + *

      Executes a distinct query and returns unique values

      + * @param key -

      A field to find distinct values

      + * @returns

      A promise that is resolved with the query completes.

      + */ + distinct( + key: string, + options: { + sessionToken?: string; + } + ): Promise; + /** + *

      Executes an aggregate query and returns aggregate results

      + * @param pipeline -

      Array or Object of stages to process query

      + * @returns

      A promise that is resolved with the query completes.

      + */ + aggregate( + pipeline: AggregationPipeline, + options: { + useMasterKey?: boolean; + sessionToken?: string; + } + ): Promise; + /** + *

      Retrieves at most one Parse.Object that satisfies this query.

      + *

      Returns the object if there is one, otherwise undefined.

      + * @param [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

      A promise that is resolved with the object when + * the query completes.

      + */ + first(options?: QueryOptions): 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 callback -

      Callback that will be called with each result + * of the query.

      + * @returns

      A promise that will be fulfilled once the + * iteration has completed.

      + */ + eachBatch(callback: (...params: any[]) => 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 callback -

      Callback that will be called with each result + * of the query.

      + * @returns

      A promise that will be fulfilled once the + * iteration has completed.

      + */ + each(callback: (...params: any[]) => any, options?: BatchOptions): Promise; + /** + *

      Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)

      + * @param value -

      String or Object of index that should be used when executing query

      + * @returns

      Returns the query, so you can chain this call.

      + */ + hint(value: string | any): Parse.Query; + /** + *

      Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)

      + * @param explain -

      Used to toggle the information on the query plan.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + explain(explain?: boolean): Parse.Query; + /** + *

      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 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 [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

      A promise that will be fulfilled once the + * iteration has completed.

      + */ + map(callback: (...params: any[]) => 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 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.

      + * @returns

      A promise that will be fulfilled once the + * iteration has completed.

      + */ + reduce( + callback: (...params: any[]) => 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 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 [options] -

      batch options

      + * @returns

      A promise that will be fulfilled once the + * iteration has completed.

      + */ + filter(callback: (...params: any[]) => any, options?: BatchOptions): Promise; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be equal to the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that the Parse.Object must contain.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + equalTo(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be not equal to the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that must not be equalled.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + notEqualTo(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be less than the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that provides an upper bound.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + lessThan(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be greater than the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that provides an lower bound.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + greaterThan(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be less than or equal to the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that provides an upper bound.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + lessThanOrEqualTo(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be greater than or equal to the provided value.

      + * @param key -

      The key to check.

      + * @param value -

      The value that provides an lower bound.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + greaterThanOrEqualTo(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * be contained in the provided list of values.

      + * @param key -

      The key to check.

      + * @param value -

      The values that will match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + containedIn(key: string, value: any): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * not be contained in the provided list of values.

      + * @param key -

      The key to check.

      + * @param value -

      The values that will not match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + notContainedIn(key: string, value: any): Parse.Query; + /** + *

      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 key -

      The key to check.

      + * @param values -

      The values that will match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + containedBy(key: string, values: any[]): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's value to + * contain each one of the provided list of values.

      + * @param key -

      The key to check. This key's value must be an array.

      + * @param values -

      The values that will match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + containsAll(key: string, values: any[]): Parse.Query; + /** + *

      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 key -

      The key to check. This key's value must be an array.

      + * @param values -

      The string values that will match as starting string.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + containsAllStartingWith(key: string, values: string[]): Parse.Query; + /** + *

      Adds a constraint for finding objects that contain the given key.

      + * @param key -

      The key that should exist.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + exists(key: string): Parse.Query; + /** + *

      Adds a constraint for finding objects that do not contain a given key.

      + * @param key -

      The key that should not exist

      + * @returns

      Returns the query, so you can chain this call.

      + */ + doesNotExist(key: string): Parse.Query; + /** + *

      Adds a regular expression constraint for finding string values that match + * the provided regular expression. + * This may be slow for large datasets.

      + * @param key -

      The key that the string to match is stored in.

      + * @param regex -

      The regular expression pattern to match.

      + * @param [modifiers] -

      The regular expression mode.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + matches(key: string, regex: RegExp, modifiers?: string): Parse.Query; + /** + *

      Adds a constraint that requires that a key's value matches a Parse.Query + * constraint.

      + * @param key -

      The key that the contains the object to match the + * query.

      + * @param query -

      The query that should match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + matchesQuery(key: string, query: Parse.Query): Parse.Query; + /** + *

      Adds a constraint that requires that a key's value not matches a + * Parse.Query constraint.

      + * @param key -

      The key that the contains the object to match the + * query.

      + * @param query -

      The query that should not match.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + doesNotMatchQuery(key: string, query: Parse.Query): Parse.Query; + /** + *

      Adds a constraint that requires that a key's value matches a value in + * an object returned by a different Parse.Query.

      + * @param key -

      The key that contains the value that is being + * matched.

      + * @param queryKey -

      The key in the objects returned by the query to + * match against.

      + * @param query -

      The query to run.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + matchesKeyInQuery(key: string, queryKey: string, query: Parse.Query): Parse.Query; + /** + *

      Adds a constraint that requires that a key's value not match a value in + * an object returned by a different Parse.Query.

      + * @param key -

      The key that contains the value that is being + * excluded.

      + * @param queryKey -

      The key in the objects returned by the query to + * match against.

      + * @param query -

      The query to run.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + doesNotMatchKeyInQuery(key: string, queryKey: string, query: Parse.Query): Parse.Query; + /** + *

      Adds a constraint for finding string values that contain a provided + * string. This may be slow for large datasets.

      + * @param key -

      The key that the string to match is stored in.

      + * @param substring -

      The substring that the value must contain.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + contains(key: string, substring: string): Parse.Query; + /** + *

      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 key -

      The key that the string to match is stored in.

      + * @param value -

      The string to search

      + * @param [options] -

      The full text options

      + * @returns

      Returns the query, so you can chain this call.

      + */ + fullText(key: string, value: string, options?: FullTextOptions): Parse.Query; + /** + *

      Method to sort the full text search by text score

      + * @returns

      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 key -

      The key that the string to match is stored in.

      + * @param prefix -

      The substring that the value must start with.

      + * @param [modifiers] -

      The regular expression mode.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + startsWith(key: string, prefix: string, modifiers?: string): Parse.Query; + /** + *

      Adds a constraint for finding string values that end with a provided + * string. This will be slow for large datasets.

      + * @param key -

      The key that the string to match is stored in.

      + * @param suffix -

      The substring that the value must end with.

      + * @param modifiers -

      The regular expression mode.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + endsWith(key: string, suffix: string, modifiers: string): Parse.Query; + /** + *

      Adds a proximity based constraint for finding objects with key point + * values near the point given.

      + * @param key -

      The key that the Parse.GeoPoint is stored in.

      + * @param point -

      The reference Parse.GeoPoint that is used.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + near(key: string, point: Parse.GeoPoint): Parse.Query; + /** + *

      Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given.

      + * @param key -

      The key that the Parse.GeoPoint is stored in.

      + * @param point -

      The reference Parse.GeoPoint that is used.

      + * @param maxDistance -

      Maximum distance (in radians) of results to return.

      + * @param [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

      Returns the query, so you can chain this call.

      + */ + withinRadians( + key: string, + point: Parse.GeoPoint, + maxDistance: number, + sorted?: boolean + ): Parse.Query; + /** + *

      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 key -

      The key that the Parse.GeoPoint is stored in.

      + * @param point -

      The reference Parse.GeoPoint that is used.

      + * @param maxDistance -

      Maximum distance (in miles) of results to return.

      + * @param [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

      Returns the query, so you can chain this call.

      + */ + withinMiles( + key: string, + point: Parse.GeoPoint, + maxDistance: number, + sorted?: boolean + ): Parse.Query; + /** + *

      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 key -

      The key that the Parse.GeoPoint is stored in.

      + * @param point -

      The reference Parse.GeoPoint that is used.

      + * @param maxDistance -

      Maximum distance (in kilometers) of results to return.

      + * @param [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

      Returns the query, so you can chain this call.

      + */ + withinKilometers( + key: string, + point: Parse.GeoPoint, + maxDistance: number, + sorted?: boolean + ): Parse.Query; + /** + *

      Adds a constraint to the query that requires a particular key's + * coordinates be contained within a given rectangular geographic bounding + * box.

      + * @param key -

      The key to be constrained.

      + * @param southwest -

      The lower-left inclusive corner of the box.

      + * @param northeast -

      The upper-right inclusive corner of the box.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + withinGeoBox(key: string, southwest: Parse.GeoPoint, northeast: Parse.GeoPoint): Parse.Query; + /** + *

      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 key -

      The key to be constrained.

      + * @param points -

      Array of Coordinates / GeoPoints

      + * @returns

      Returns the query, so you can chain this call.

      + */ + withinPolygon(key: string, points: any[]): Parse.Query; + /** + *

      Add a constraint to the query that requires a particular key's + * coordinates that contains a ParseGeoPoint

      + * @param key -

      The key to be constrained.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + polygonContains(key: string, point: Parse.GeoPoint): Parse.Query; + /** + *

      Sorts the results in ascending order by the given key.

      + * @param keys -

      The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + ascending(...keys: (string | string[])[]): Parse.Query; + /** + *

      Sorts the results in ascending order by the given key, + * but can also add secondary sort descriptors without overwriting _order.

      + * @param keys -

      The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + addAscending(...keys: (string | string[])[]): Parse.Query; + /** + *

      Sorts the results in descending order by the given key.

      + * @param keys -

      The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + descending(...keys: (string | string[])[]): Parse.Query; + /** + *

      Sorts the results in descending order by the given key, + * but can also add secondary sort descriptors without overwriting _order.

      + * @param keys -

      The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + addDescending(...keys: (string | string[])[]): Parse.Query; + /** + *

      Sets the number of results to skip before returning any results. + * This is useful for pagination. + * Default is to skip zero results.

      + * @param n -

      the number of results to skip.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + skip(n: number): Parse.Query; + /** + *

      Sets the limit of the number of results to return. The default limit is 100.

      + * @param n -

      the number of results to limit to.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + limit(n: number): Parse.Query; + /** + *

      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 {Parse.Object} array and count: integer holding total number

      + * @param includeCount -

      false - disable, true - enable.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + withCount(includeCount?: boolean): Parse.Query; + /** + *

      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 keys -

      The name(s) of the key(s) to include.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + include(...keys: (string | string[])[]): this; + /** + *

      Includes all nested Parse.Objects one level deep.

      + *

      Requires Parse Server 3.0.0+

      + * @returns

      Returns the query, so you can chain this call.

      + */ + includeAll(): Parse.Query; + /** + *

      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 keys -

      The name(s) of the key(s) to include.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + select(...keys: (string | string[])[]): Parse.Query; + /** + *

      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 keys -

      The name(s) of the key(s) to exclude.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + exclude(...keys: (string | string[])[]): Parse.Query; + /** + *

      Changes the read preference that the backend will use when performing the query to the database.

      + * @param readPreference -

      The read preference for the main query.

      + * @param includeReadPreference -

      The read preference for the queries to include pointers.

      + * @param subqueryReadPreference -

      The read preference for the sub queries.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + readPreference( + readPreference: string, + includeReadPreference: string, + subqueryReadPreference: string + ): Parse.Query; + /** + *

      Subscribe this query to get liveQuery updates

      + * @param [sessionToken] -

      (optional) Defaults to the currentUser

      + * @returns

      Returns the liveQuerySubscription, it's an event emitter + * which can be used to get liveQuery updates.

      + */ + subscribe(sessionToken?: string): Promise; + /** + *

      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 queries -

      The list of queries to OR.

      + * @returns

      The query that is the OR of the passed in queries.

      + */ + static or(...queries: Parse.Query[]): Parse.Query; + /** + *

      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 queries -

      The list of queries to AND.

      + * @returns

      The query that is the AND of the passed in queries.

      + */ + static and(...queries: Parse.Query[]): Parse.Query; + /** + *

      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 queries -

      The list of queries to NOR.

      + * @returns

      The query that is the NOR of the passed in queries.

      + */ + static nor(...queries: Parse.Query[]): Parse.Query; + /** + *

      Change the source of this query to the server.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + fromNetwork(): Parse.Query; + /** + *

      Changes the source of this query to all pinned objects.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + fromLocalDatastore(): Parse.Query; + /** + *

      Changes the source of this query to the default group of pinned objects.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + fromPin(): Parse.Query; + /** + *

      Changes the source of this query to a specific group of pinned objects.

      + * @param name -

      The name of query source.

      + * @returns

      Returns the query, so you can chain this call.

      + */ + fromPinWithName(name: string): Parse.Query; + /** + *

      Cancels the current network request (if any is running).

      + * @returns

      Returns the query, so you can chain this call.

      + */ + cancel(): Parse.Query; + } + /** + *

      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. + *

      + * @param parent -

      The parent of this relation.

      + * @param key -

      The key for this relation on the parent.

      + */ + class Relation { + parent: S; + 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; + + constructor(parent: Parse.Object, key: string); + /** + *

      Adds a Parse.Object or an array of Parse.Objects to the relation.

      + * @param objects -

      The item or items to add.

      + * @returns

      The parent of the relation.

      + */ + add(objects: Parse.Object | any[]): Parse.Object; + /** + *

      Removes a Parse.Object or an array of Parse.Objects from this relation.

      + * @param objects -

      The item or items to remove.

      + */ + remove(objects: Parse.Object | any[]): void; + /** + *

      Returns a JSON version of the object suitable for saving to disk.

      + * @returns

      JSON representation of Relation

      + */ + toJSON(): any; + /** + *

      Returns a Parse.Query that is limited to objects in this + * relation.

      + * @returns

      Relation Query

      + */ + query(): Parse.Query; + } + /** + *

      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.

      + * @param name -

      The name of the Role to create.

      + * @param 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.

      + */ + class Role extends Parse.Object { + constructor(name: string, acl: Parse.ACL); + /** + *

      Gets the name of the role. You can alternatively call role.get("name")

      + * @returns

      the name of the role.

      + */ + getName(): string; + /** + *

      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 name -

      The name of the role.

      + * @param options -

      Standard options object with success and error + * callbacks.

      + * @returns

      true if the set succeeded.

      + */ + setName(name: string, options: any): Parse.Object | 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

      the relation for the users belonging to this + * role.

      + */ + getUsers(): Parse.Relation; + /** + *

      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

      the relation for the roles belonging to this + * role.

      + */ + getRoles(): Parse.Relation; + /** + *

      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 attrs -

      The current data to validate.

      + * @returns

      False if the data is valid. An error object otherwise.

      + */ + validate(attrs: any): Parse.Error | boolean; + } + /** + *

      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();
      +   * 
      + *

      + * @param className -

      Parse Class string.

      + */ + class Schema { + constructor(className: string); + /** + *

      Static method to get all schemas

      + * @returns

      A promise that is resolved with the result when + * the query completes.

      + */ + static all(): Promise; + /** + *

      Get the Schema from Parse

      + * @returns

      A promise that is resolved with the result when + * the query completes.

      + */ + get(): Promise; + /** + *

      Create a new Schema on Parse

      + * @returns

      A promise that is resolved with the result when + * the query completes.

      + */ + save(): Promise; + /** + *

      Update a Schema on Parse

      + * @returns

      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

      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

      A promise that is resolved with the result when + * the query completes.

      + */ + purge(): Promise; + /** + *

      Assert if ClassName has been filled

      + */ + private assertClassName(): void; + /** + *

      Sets Class Level Permissions when creating / updating a Schema. + * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed

      + * @param clp -

      Class Level Permissions

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + setCLP(clp: any | Parse.CLP): Parse.Schema; + /** + *

      Adding a Field to Create / Update a Schema

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [type] -

      Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)

      + * @param [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

      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 name -

      Name of the index

      + * @param index -

      { field: value }

      + * @returns

      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 name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addString(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Number Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addNumber(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Boolean Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addBoolean(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Date Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addDate(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding File Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addFile(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding GeoPoint Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addGeoPoint(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Polygon Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addPolygon(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Array Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addArray(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Object Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addObject(name: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Pointer Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param targetClass -

      Name of the target Pointer Class

      + * @param [options] -

      See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + addPointer(name: string, targetClass: string, options?: FieldOptions): Parse.Schema; + /** + *

      Adding Relation Field

      + * @param name -

      Name of the field that will be created on Parse

      + * @param targetClass -

      Name of the target Pointer Class

      + * @returns

      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 name -

      Name of the field

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + deleteField(name: string): Parse.Schema; + /** + *

      Deleting an Index to Update on a Schema

      + * @param name -

      Name of the field

      + * @returns

      Returns the schema, so you can chain this call.

      + */ + deleteIndex(name: string): Parse.Schema; + } + /** + *

      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.

      + * @param [attributes] -

      The initial set of data to store in the user.

      + */ + class Session extends Parse.Object { + constructor(attributes?: any); + /** + *

      Returns the session token string.

      + */ + getSessionToken(): string; + /** + *

      Retrieves the Session object for the currently logged in session.

      + * @param options -

      useMasterKey

      + * @returns

      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: any): 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 isCurrentSessionRevocable(): boolean; + } + /** + *

      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.

      + * @param [attributes] -

      The initial set of data to store in the user.

      + */ + class User extends Parse.Object { + constructor(attributes?: any); + /** + *

      Request a revocable session token to replace the older style of token.

      + * @returns

      A promise that is resolved when the replacement + * token has been fetched.

      + */ + _upgradeToRevocableSession(options: any): 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

      + * @param provider -

      Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}

      + * @param 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 [saveOpts] -

      useMasterKey / sessionToken

      + * @returns

      A promise that is fulfilled with the user is linked

      + */ + linkWith(provider: string | AuthProvider, options: any, saveOpts?: any): Promise; + _linkWith(provider: any, options: any, saveOpts: any): Promise; + /** + *

      Synchronizes auth data for a provider (e.g. puts the access token in the + * right place to be used by the Facebook SDK).

      + */ + _synchronizeAuthData(provider: any): 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 provider -

      Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}

      + * @param [options] -

      MasterKey / SessionToken

      + * @returns

      A promise that is fulfilled when the unlinking + * finishes.

      + */ + _unlinkFrom(provider: string | AuthProvider, options?: FullOptions): Promise; + /** + *

      Checks whether a user is linked to a service.

      + * @param provider -

      service to link to

      + * @returns

      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 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

      sessionToken

      + */ + _preserveFieldsOnFetch(): any; + /** + *

      Returns true if current would return this user.

      + * @returns

      true if user is cached on disk

      + */ + isCurrent(): boolean; + /** + *

      Returns true if current would return this user.

      + * @returns

      true if user is cached on disk

      + */ + isCurrentAsync(): Promise; + /** + *

      Returns get("username").

      + */ + getUsername(): string; + /** + *

      Calls set("username", username, options) and returns the result.

      + */ + setUsername(username: string): void; + /** + *

      Calls set("password", password, options) and returns the result.

      + * @param password -

      User's Password

      + */ + setPassword(password: string): void; + /** + *

      Returns get("email").

      + * @returns

      User's Email

      + */ + getEmail(): string; + /** + *

      Calls set("email", email) and returns the result.

      + */ + 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

      the session token, or undefined

      + */ + getSessionToken(): string; + /** + *

      Checks whether this user is the current user and has been authenticated.

      + * @returns

      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 attrs -

      Extra fields to set on the new user, or null.

      + * @returns

      A promise that is fulfilled when the signup + * finishes.

      + */ + signUp( + attrs: any, + options?: { + useMasterKey?: boolean; + sessionToken?: string; + } + ): 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.

      + * @returns

      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.

      + */ + save(...args: any[]): Promise; + /** + *

      Wrap the default destroy behavior with functionality that logs out + * the current user when it is destroyed

      + */ + destroy(...args: any[]): Promise; + /** + *

      Wrap the default fetch behavior with functionality to save to local + * storage if this is current user.

      + */ + fetch(...args: any[]): Promise; + /** + *

      Wrap the default fetchWithInclude behavior with functionality to save to local + * storage if this is current user.

      + */ + fetchWithInclude(...args: any[]): Promise; + /** + *

      Verify whether a given password is the password of the current user.

      + * @param password -

      A password to be verified

      + * @returns

      A promise that is fulfilled with a user + * when the password is correct.

      + */ + verifyPassword(password: string, options: any): Promise; + /** + *

      Adds functionality to the existing Parse.User class.

      + * @param protoProps -

      A set of properties to add to the prototype

      + * @param classProps -

      A set of static properties to add to the class

      + * @returns

      The newly extended Parse.User class

      + */ + static extend(protoProps: any, classProps: any): Parse.User; + /** + *

      Retrieves the currently logged in ParseUser with a valid session, + * either from memory or localStorage, if necessary.

      + * @returns

      The currently logged in Parse.User.

      + */ + static current(): Parse.User; + /** + *

      Retrieves the currently logged in ParseUser from asynchronous Storage.

      + * @returns

      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 username -

      The username (or email) to sign up with.

      + * @param password -

      The password to sign up with.

      + * @param attrs -

      Extra fields to set on the new user.

      + * @returns

      A promise that is fulfilled with the user when + * the signup completes.

      + */ + static signUp( + username: string, + password: string, + attrs: any, + options: any + ): 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 username -

      The username (or email) to log in with.

      + * @param password -

      The password to log in with.

      + * @returns

      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 session token. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current.

      + * @param sessionToken -

      The sessionToken to log in with.

      + * @returns

      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 sessionToken -

      The sessionToken to get user with.

      + * @returns

      A promise that is fulfilled with the user is fetched.

      + */ + static me(sessionToken: string, options: any): 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 userJSON -

      The JSON map of the User's data

      + * @returns

      A promise that is fulfilled with the user when + * the login completes.

      + */ + static hydrate(userJSON: any): Promise; + /** + *

      Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}

      + */ + static logInWith(provider: any, options: any, saveOpts: any): 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.

      + * @returns

      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 email -

      The email address associated with the user that + * forgot their password.

      + */ + static requestPasswordReset(email: string, options?: RequestOptions): Promise; + /** + *

      Request an email verification.

      + * @param email -

      The email address associated with the user that + * forgot their password.

      + */ + static requestEmailVerification(email: string, options?: RequestOptions): Promise; + /** + *

      Verify whether a given password is the password of the current user.

      + * @param username -

      A username to be used for identificaiton

      + * @param password -

      A password to be verified

      + * @returns

      A promise that is fulfilled with a user + * when the password is correct.

      + */ + static verifyPassword(username: string, password: string, options: any): 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 isAllowed -

      Whether or not to allow custom User class

      + */ + 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.

      + * @returns

      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: any): 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 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 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.

      + */ + static _registerAuthenticationProvider(provider: any): void; + static _logInWith(provider: any, options: any, saveOpts: any): Promise; + } + /** + *

      Contains functions to deal with Push in Parse.

      + */ + class Push { + /** + *

      Sends a push notification. + * Available in Cloud Code only.

      + *

      See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}

      + * @param 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 options -

          Valid options + * are:

            + *
          • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
          + * @returns

          A promise that is fulfilled when the push request + * completes.

          + */ + static send(data: any, options: any): Promise; + /** + *

          Gets push status by Id

          + * @param pushStatusId -

          The Id of Push Status.

          + * @param options -

          Valid options + * are:

            + *
          • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
          + * @returns

          Status of Push.

          + */ + static getPushStatus(pushStatusId: string, options: any): Parse.Object; + } +} + +declare type AnalyticsController = { + track: AnalyticsControllerTrackCallback; +}; + +declare type AnalyticsControllerTrackCallback = ( + name: string, + dimensions?: { + [key: string]: string; + } +) => Promise; + +declare type CloudController = { + run: CloudControllerRunStart; + getJobsData: CloudControllerGetJobsData; + startJob: CloudControllerRunStart; +}; + +declare type CloudControllerRunStart = ( + name: string, + data?: any, + options?: RequestOptions +) => Promise; + +declare type CloudControllerGetJobsData = (options?: RequestOptions) => Promise; + +/** + *

          LiveQuery event Callback

          + * @param object -

          LiveQuery event object

          + * @param [original] -

          LiveQuery event original object

          + */ +declare type LiveQueryEventCallback = (object: Parse.Object, original?: Parse.Object) => void; + +/** + *

          Copyright (c) 2015-present, Parse, LLC. + * All rights reserved.

          + *

          This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory.

          + */ +declare const DEFAULT_PIN = '_default'; + +/** + *

          contains -- Determines if an object is contained in a list with special handling for Parse pointers.

          + */ +declare function contains(haystack: any, needle: any): boolean; + +/** + *

          matchesQuery -- Determines if an object would be returned by a Parse Query + * It's a lightweight, where-clause only implementation of a full query engine. + * Since we find queries that match objects, rather than objects that match + * queries, we can avoid building a full-blown query tool.

          + */ +declare function matchesQuery(className: any, object: any, objects: any, query: any): boolean; + +/** + * @property status -

          The conversion status, error if conversion failed or + * success if conversion succeeded.

          + * @property info -

          The error message if conversion failed, or the relative + * time indication (past, present, future) if conversion succeeded.

          + * @property result -

          The converted date, or undefined if conversion + * failed.

          + */ +declare type RelativeTimeToDateResult = { + status: string; + info: string; + result: Date | undefined; +}; + +/** + *

          Converts human readable relative date string, for example, 'in 10 days' to a date + * relative to now.

          + * @param text -

          The text to convert.

          + * @param [now = new Date()] -

          The date from which add or subtract. Default is now.

          + */ +declare function relativeTimeToDate(text: string, now?: Date): RelativeTimeToDateResult; + +/** + *

          Determines whether an object matches a single key's constraints

          + */ +declare function matchesKeyConstraints( + className: any, + object: any, + objects: any, + key: any, + constraints: any +): boolean; + +/** + *

          Contains all Parse API classes and functions.

          + */ +declare class Parse { + constructor(); + /** + *

          Call this method first to set up your authentication tokens for Parse.

          + * @param applicationId -

          Your Parse Application ID.

          + * @param [javaScriptKey] -

          Your Parse JavaScript Key (Not needed for parse-server)

          + * @param [masterKey] -

          Your Parse Master Key. (Node.js only!)

          + */ + static initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void; + /** + *

          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 storage -

          a react native async storage.

          + */ + static setAsyncStorage(storage: AsyncStorage): void; + /** + *

          Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}

          + * @param controller -

          a data storage.

          + */ + static setLocalDatastoreController(controller: LocalDatastoreController): void; + /** + *

          Returns information regarding the current server's health

          + */ + static getServerHealth(): Promise; + static applicationId: string; + static javaScriptKey: string; + static masterKey: string; + static serverURL: string; + static serverAuthToken: string; + static serverAuthType: string; + static liveQueryServerURL: string; + static encryptedUser: boolean; + static secret: string; + static idempotency: boolean; + static allowCustomObjectId: boolean; + /** + *

          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?: any, ms?: any): void; + /** + *

          Flag that indicates whether Local Datastore is enabled.

          + */ + static isLocalDatastoreEnabled(): boolean; + /** + *

          Gets all contents from Local Datastore

          + *
          +   * await Parse.dumpLocalDatastore();
          +   * 
          + */ + static dumpLocalDatastore(): any; + /** + *

          Enable the current user encryption. + * This must be called before login any user.

          + */ + static enableEncryptedUser(): void; + /** + *

          Flag that indicates whether Encrypted User is enabled.

          + */ + static isEncryptedUserEnabled(): boolean; +} + +/** + *

          Typedef for SaveParams

          + * @property [cascadeSave] -

          cascadeSave

          + * @property [content] -

          context

          + */ +declare type SaveParams = { + cascadeSave?: boolean; + content?: Attributes; +}; + +declare type SaveOptions = FullOptions | SaveParams; + +declare type Attributes = { + [key: string]: any; +}; + +/** + *

          Typedef for QueryOptions

          + * @property [useMasterKey] -

          If true, sign up with masterKey

          + * @property [sessionToken] -

          sessionToken

          + * @property [context] -

          context

          + * @property [json] -

          json

          + */ +declare type QueryOptions = { + useMasterKey?: boolean; + sessionToken?: string; + context?: any; + json?: boolean; +}; + +/** + *

          Typedef for BatchOptions

          + * @property [useMasterKey] -

          If true, sign up with masterKey

          + * @property [sessionToken] -

          sessionToken

          + * @property [context] -

          context

          + * @property [batchSize] -

          batchSize

          + */ +declare type BatchOptions = { + useMasterKey?: boolean; + sessionToken?: string; + context?: any; + batchSize?: number; +}; + +/** + *

          Converts a string into a regex that matches it. + * Surrounding with \Q .. \E does this, we just need to escape any \E's in + * the text separately.

          + */ +declare function quote(s: any): string; + +/** + *

          Extracts the class name from queries. If not all queries have the same + * class name an error will be thrown.

          + */ +declare function _getClassNameFromQueries(queries: any): string; + +declare type QueryJSON = { + where: Attributes; + include?: string; + excludeKeys?: string; + keys?: string; + limit?: number; + skip?: number; + order?: string; + className?: string; + count?: number; + hint?: any; + explain?: boolean; + readPreference?: string; + includeReadPreference?: string; + subqueryReadPreference?: string; +}; + +/** + *

          Typedef for Aggregation Options

          + */ +declare type AggregationPipeline = { + group?: Attributes | GroupParams; + match?: Attributes; + project?: Attributes; + limit?: number; + skip?: number; + sort?: { + [key: string]: 1 | -1; + }; + sample?: { + size?: number; + }; +}; + +/** + *

          Typedef for Aggregate Group

          + */ +declare type GroupParams = { + objectId?: string; +}; + +/** + *

          Typedef for Full Text Options

          + * @property language -

          The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.

          + * @property caseSensitive -

          A boolean flag to enable or disable case sensitive search.

          + * @property diacriticSensitive -

          A boolean flag to enable or disable diacritic sensitive search.

          + */ +declare type FullTextOptions = { + language: string; + caseSensitive: boolean; + diacriticSensitive: boolean; +}; + +/** + *

          Typedef for FieldOptions

          + * @property [required] -

          Whether the field is required

          + * @property [defaultValue] -

          Default value for the field

          + */ +declare type FieldOptions = { + required?: boolean; + defaultValue?: any; +}; + +/** + *

          Typedef for RequestOptions

          + * @property [useMasterKey] -

          If true, sign up with masterKey

          + * @property [sessionToken] -

          sessionToken

          + * @property [installationId] -

          InstallationId of user

          + * @property [returnStatus] -

          return status

          + * @property [batchSize] -

          batch size

          + * @property [include] -

          include

          + * @property [context] -

          context

          + * @property [usePost] -

          whether request should use POST

          + */ +declare type RequestOptions = { + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + returnStatus?: boolean; + batchSize?: number; + include?: any; + context?: any; + usePost?: boolean; +}; + +/** + *

          Typedef for FullOptions

          + * @property [useMasterKey] -

          If true, sign up with masterKey

          + * @property [sessionToken] -

          sessionToken

          + * @property [installationId] -

          InstallationId of user

          + * @property [progress] -

          progress

          + * @property [usePost] -

          whether request should use POST

          + */ +declare type FullOptions = { + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + progress?: void; + usePost?: boolean; +}; + +/** + *

          Copyright (c) 2015-present, Parse, LLC. + * All rights reserved.

          + *

          This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory.

          + */ +declare const StorageController: any; + +/** + *

          Interface declaration for Authentication Providers

          + */ +declare interface AuthProvider { + /** + *

          Called when _linkWith isn't passed authData. + * Handle your own authentication here.

          + * @param options -

          options.success(provider, authData) or options.error(provider, error) on completion

          + */ + authenticate(options: any): void; + /** + *

          (Optional) Called when service is unlinked. + * Handle any cleanup here.

          + */ + deauthenticate(): void; + /** + *

          Unique identifier for this Auth Provider.

          + * @returns

          identifier

          + */ + getAuthType(): string; + /** + *

          Called when auth data is syncronized. + * Can be used to determine if authData is still valid

          + * @param authData -

          Data used when register provider

          + * @returns

          Indicate if service should continue to be linked

          + */ + restoreAuthentication(authData: any): boolean; +} + +interface BaseAttributes { + createdAt: Date; + objectId: string; + updatedAt: Date; +} + +interface CommonAttributes { + ACL: Parse.ACL; +} + +interface JSONBaseAttributes { + createdAt: string; + objectId: string; + updatedAt: string; +} + +type Encode = T extends Parse.Object + ? ReturnType | Parse.Pointer + : T extends Parse.ACL | Parse.GeoPoint | Parse.Polygon | Parse.Relation | Parse.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; +}; + +interface GenericTriggerRequest { + installationId?: string; + master: boolean; + user?: Parse.User; + object: T; + ip: string; + headers: any; + triggerName: string; + log: any; + original?: T; + context: { + [key: string]: object; + }; +} + +interface BeforeFindRequest + extends GenericTriggerRequest { + query: Parse.Query; +} +interface AfterFindRequest extends GenericTriggerRequest { + objects: T[]; +} diff --git a/types/interfaces.ts b/types/interfaces.ts new file mode 100644 index 000000000..bc312e061 --- /dev/null +++ b/types/interfaces.ts @@ -0,0 +1,56 @@ +interface BaseAttributes { + createdAt: Date; + objectId: string; + updatedAt: Date; +} + +interface CommonAttributes { + ACL: Parse.ACL; +} + +interface JSONBaseAttributes { + createdAt: string; + objectId: string; + updatedAt: string; +} + +type Encode = T extends Parse.Object +? ReturnType | Parse.Pointer +: T extends Parse.ACL | Parse.GeoPoint | Parse.Polygon | Parse.Relation | Parse.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; +}; + +interface GenericTriggerRequest { + installationId?: string; + master: boolean; + user?: Parse.User; + object: T; + ip: string; + headers: any; + triggerName: string; + log: any; + original?: T; + context: { + [key: string]: object; + }; +} + +interface BeforeFindRequest extends GenericTriggerRequest { + query: Parse.Query; +} +interface AfterFindRequest extends GenericTriggerRequest { + objects: T[]; +} diff --git a/types/plugin.js b/types/plugin.js new file mode 100644 index 000000000..485ccf767 --- /dev/null +++ b/types/plugin.js @@ -0,0 +1,9 @@ +exports.handlers = { + newDoclet({doclet}) { + if (doclet.comment.includes("'-1'")) { + doclet.comment = doclet.comment.split("'-1'").join('-1'); + const stringify = JSON.stringify(doclet.properties).split("'-1'").join('-1'); + doclet.properties = JSON.parse(stringify); + } + } +} \ No newline at end of file diff --git a/types/tests.ts b/types/tests.ts new file mode 100644 index 000000000..3803a9bdf --- /dev/null +++ b/types/tests.ts @@ -0,0 +1,2014 @@ +// 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<{ gameScore: GameScore; score: string }> { + 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 GameScore(); + game.save(null, { + useMasterKey: true, + sessionToken: "sometoken", + cascadeSave: false, + }).then(result => result); + + if (!game.isNew()) { + console.error("Game should be new"); + } + + if (game.toPointer().className !== "Game") { + console.log("Class name should be '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.OTHER_CAUSE, "sdfds"); + } catch (error) { + if (error.code !== 1) { + console.error("Error code did not match expected number."); + } + } +} + +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", + }, + }); + + // 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 Object + object; + }); + subscription.on("create", object => { + // $ExpectType Object + object; + }); + subscription.on("delete", object => { + // $ExpectType Object + object; + }); + subscription.on("enter", object => { + // $ExpectType Object + object; + }); + subscription.on("leave", object => { + // $ExpectType Object + object; + }); + subscription.on("open", object => { + // $ExpectType Object + object; + }); + subscription.on("update", object => { + // $ExpectType Object + object; + }); + subscription.on("update", (object, original) => { + // $ExpectType Object | undefined + original; + }); +} + +function return_a_generic_query(): Parse.Query { + return new Parse.Query(Game) +} + +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(GameScore); +} + +function test_each() { + new Parse.Query(GameScore).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. + }, + () => { + // 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 GameScore(); + const game2 = new GameScore(); + + new Parse.User() + .relation("games") + .query() + .find() + .then((g: GameScore[]) => {}); + 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 }); +} + +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. + // $ExpectType Parse.User + user + }, + () => { + // The token could not be validated. + }, + ); + + Parse.User.hydrate({}).then( + user => { + // The current user is now set to user. + }, + () => { + // The token could not be validated. + }, + ); + + const game = new GameScore(); + game.set("gameScore", new GameScore()); + game.setACL(new Parse.ACL(Parse.User.current())); + game.save().then((game: GameScore) => {}); + 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. + }, + () => { + // The token could not be validated. + }, + ); + + Parse.User.requestEmailVerification("email@example.com").then( + data => { + // The current user is now set to user. + }, + () => { + // 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", + {}, + ); + + // $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" }); + + // $ExpectError + await Parse.Cloud.run<(params: { paramA: string }) => number>("SomeFunction"); + + // $ExpectError + await Parse.Cloud.run<(params: { paramA: string }) => number>("SomeFunction", { paramZ: "hello" }); + + // $ExpectError + await Parse.Cloud.run<(params: { paramA: string }) => number>("SomeFunction", null, { useMasterKey: true }); + + // $ExpectError + await Parse.Cloud.run<(params: string) => any>("SomeFunction", "hello"); + + Parse.Cloud.afterDelete("MyCustomClass", (request: Parse.Cloud.TriggerRequest) => { + // result + }); + + Parse.Cloud.afterSave("MyCustomClass", (request: Parse.Cloud.TriggerRequest) => { + if (!request.context) { + throw new Error("Request context should be defined"); + } + // result + }); + + Parse.Cloud.beforeDelete("MyCustomClass", (request: Parse.Cloud.TriggerRequest) => { + // result + }); + + Parse.Cloud.beforeDelete("MyCustomClass", async (request: Parse.Cloud.TriggerRequest) => { + // result + }); + + const CUSTOM_ERROR_INVALID_CONDITION = 1001; + const CUSTOM_ERROR_IMMUTABLE_FIELD = 1002; + + 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 Parse.Error( + CUSTOM_ERROR_INVALID_CONDITION, + "Original must me defined for an existing object", + ); + } + + if (original.get("immutable") !== request.object.get("immutable")) { + throw new Parse.Error(CUSTOM_ERROR_IMMUTABLE_FIELD, "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.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", async (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; + + // $ExpectError + request.params.somethingElse; + + return 123; + }); + + // $ExpectError + Parse.Cloud.define("AFunc"); + + // $ExpectError + 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(); + // $ExpectError + point = new Parse.GeoPoint("40.0"); + // $ExpectError + point = new Parse.GeoPoint(40.0); + // $ExpectError + 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 GameScore(); + const game2 = new GameScore(); + 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(GameScore); + + // create subscription to Game object + const subscription = await query.subscribe(); + + // 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, +) { + Parse.Schema.all(); + + const schema = new Parse.Schema("TestSchema"); + + schema.addArray("arrayField"); + schema.addArray("arrayField", { defaultValue: [1, 2, 3, 4] }); + // $ExpectError + schema.addArray("arrayField", { defaultValue: notArray }); + + /** + * @todo Enable type check for defaul value + */ + schema.addField("defaultFieldString"); + schema.addField("defaultFieldString", "String", { defaultValue: anyField }); + schema.addField("defaultFieldString", "Number"); + schema.addField("defaultFieldString", "Relation"); + // $ExpectError + schema.addField("defaultFieldString", "String", "Invalid Options"); + + schema.addString("field"); + schema.addString("field", { defaultValue: "some string", required: true }); + // $ExpectError + schema.addString("field", { defaultValue: notString }); + + schema.addNumber("field"); + schema.addNumber("field", { defaultValue: 0, required: true }); + // $ExpectError + schema.addNumber("field", { defaultValue: notNumber }); + + schema.addBoolean("field"); + schema.addBoolean("field", { defaultValue: true, required: true }); + // $ExpectError + schema.addBoolean("field", { defaultValue: notboolean }); + + schema.addDate("field"); + schema.addDate("field", { defaultValue: new Date(), required: true }); + // $ExpectError + schema.addDate("field", { defaultValue: notDate }); + + schema.addFile("field"); + schema.addFile("field", { defaultValue: new Parse.File("myfile", []), required: true }); + // $ExpectError + schema.addFile("field", { defaultValue: notFile }); + + schema.addGeoPoint("field"); + schema.addGeoPoint("field", { defaultValue: new Parse.GeoPoint(), required: true }); + // $ExpectError + schema.addGeoPoint("field", { defaultValue: notGeopoint }); + + schema.addPolygon("field"); + schema.addPolygon("field", { defaultValue: new Parse.Polygon([]), required: true }); + // $ExpectError + schema.addPolygon("field", { defaultValue: notPolygon }); + + schema.addObject("field"); + schema.addObject("field", { defaultValue: {}, required: true }); + schema.addObject("field", { defaultValue: { abc: "def" } }); + // $ExpectError + schema.addObject("field", { defaultValue: notObject }); + + schema.addPointer("field", "SomeClass"); + // $ExpectError + schema.addPointer("field"); + /** + * @todo Infer defaultValue type from targetClass + */ + schema.addPointer("field", "_User", { defaultValue: new Parse.User().toPointer(), required: true }); + // $ExpectError + schema.addPointer("field", { defaultValue: notPointer }); + + schema.addRelation("field", "SomeClass"); + // $ExpectError + schema.addRelation("field"); + // $ExpectError + schema.addRelation("field", "SomeClass", "anything"); + + schema.addIndex("testIndex", { stringField: "Number" }); + // $ExpectError + schema.addIndex("testIndex", { stringField: 1 }); + + schema.deleteField("defaultFieldString"); + schema.deleteIndex("testIndex"); + schema.delete().then(results => {}); + schema.get().then(results => {}); + 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"); + + // $ExpectError + schema.addArray("wrong"); + // $ExpectError + schema.addBoolean("wrong"); + // $ExpectError + schema.addDate("wrong"); + // $ExpectError + schema.addFile("wrong"); + // $ExpectError + schema.addGeoPoint("wrong"); + // $ExpectError + schema.addNumber("wrong"); + // $ExpectError + schema.addObject("wrong"); + // $ExpectError + schema.addPointer("wrong", "FooClass"); + // $ExpectError + schema.addPolygon("wrong"); + // $ExpectError + schema.addRelation("wrong", "FooClass"); + // $ExpectError + 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 }); + + // $ExpectError + new Parse.Object<{ example: string }>("TestObject"); + + // $ExpectError + 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]); + + // $ExpectError + 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; + + // $ExpectError + 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"); + + // $ExpectError + objTyped.add("stringList", 100); + + // $ExpectError + objTyped.add("thing", true); + + // $ExpectError + 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"]); + + // $ExpectError + objTyped.addAll("stringList", [100]); + + // $ExpectError + objTyped.addAll("thing", [true]); + + // $ExpectError + 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"]); + + // $ExpectError + objTyped.addAllUnique("stringList", [100]); + + // $ExpectError + objTyped.addAllUnique("thing", [true]); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.addUnique("stringList", 100); + + // $ExpectError + objTyped.addUnique("thing", true); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.dirty("other"); + } + + function testEquals(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { + // $ExpectType boolean + objUntyped.equals(objTyped); + + // $ExpectType boolean + objTyped.equals(objUntyped); + + // $ExpectError + objUntyped.equals("blah"); + } + + function testEscape(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: string }>) { + // $ExpectType string + objUntyped.escape("whatever"); + + // $ExpectType string + objTyped.escape("example"); + + // $ExpectError + 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"]]); + + // $ExpectError + objUntyped.fetchWithInclude([[["whatever"]]]); + + // $ExpectType Promise> + objTyped.fetchWithInclude("example"); + + // $ExpectType Promise> + objTyped.fetchWithInclude(["example"]); + + // $ExpectType Promise> + objTyped.fetchWithInclude([["example"]]); + + // $ExpectError + objTyped.fetchWithInclude([[["example"]]]); + + // $ExpectType Promise[]> + Parse.Object.fetchAllIfNeededWithInclude([objTyped], "example"); + + // $ExpectError + Parse.Object.fetchAllIfNeededWithInclude([objTyped], "notAnAttribute"); + + // $ExpectType Promise[]> + Parse.Object.fetchAllWithInclude([objTyped], "example"); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.get("other"); + } + + function testHas(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) { + // $ExpectType boolean + objUntyped.has("whatever"); + + // $ExpectType boolean + objTyped.has("example"); + + // $ExpectError + 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); + + // $ExpectError + objTyped.increment("example", true); + + // $ExpectError + 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); + + // $ExpectError + objTyped.decrement("example", true); + + // $ExpectError + 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"); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.relation("example"); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.remove("stringList", 100); + + // $ExpectError + objTyped.remove("thing", true); + + // $ExpectError + 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"]); + + // $ExpectError + objTyped.removeAll("stringList", [100]); + + // $ExpectError + objTyped.removeAll("thing", [true]); + + // $ExpectError + 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"); + + // $ExpectError + objTyped.revert("other"); + } + interface ObjectAttributes { + example: boolean; + someString: string; + } + interface OptionalObjectAttributes { + example?: boolean; + another?: string; + } + + 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" }); + + // $ExpectError + await objTyped.save({ example: "hello", someString: true }); + + // $ExpectType Object + await objTyped.save("example", true); + + // $ExpectError + await objTyped.save({ example: "hello" }); + + // $ExpectError + await objTyped.save({ wrongProp: 5 }); + + // $ExpectError + await objTyped.save("example", 10); + + // $ExpectError + await objTyped.save("wrongProp", true); + + // $ExpectError + await objTyped.save({ example: undefined }); + + // $ExpectError + 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({}); + } + + 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" }); + + // $ExpectError + objTyped.set({ example: 123, someString: "abc" }); + + // $ExpectType false | Object + objTyped.set("example", true); + + // $ExpectError + objTyped.set({ example: 100 }); + + // $ExpectError + objTyped.set({ other: "something" }); + + // $ExpectError + objTyped.set("example", 100); + + // $ExpectError + objTyped.set("other", 100); + + // $ExpectError + objTyped.set({ example: undefined }); + + // $ExpectType false | Object + objTyped.set({}); + + // $ExpectError + objTyped.set("example", undefined); + + // $ExpectType false | Object + objTypedOptional.set({ example: undefined }); + + // $ExpectError 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 any[] + 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"); + + // $ExpectError + 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 testInstallation() { + function testConstructor() { + // $ExpectType Installation + new Parse.Installation(); + + // $ExpectType Installation<{ example: number; }> + new Parse.Installation({ example: 100 }); + + // $ExpectError + new Parse.Installation<{ example: number }>(); + + // $ExpectError + 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"]); + // $ExpectError + query.addAscending(["attribute1", "unexistenProp"]); + + // $ExpectType Query + query.addDescending(["attribute1", "attribute2", "createdAt"]); + // $ExpectError + query.addDescending(["attribute1", "unexistenProp"]); + + // $ExpectType Query + query.ascending(["attribute1", "attribute2", "objectId"]); + // $ExpectError + query.ascending(["attribute1", "nonexistentProp"]); + + // $ExpectType Query + query.containedBy("attribute1", ["a", "b", "c"]); + // $ExpectType Query + query.containedBy("attribute3", ["objectId1", "objectId2", "objectId3"]); + // $ExpectError + query.containedBy("attribute2", ["a", "b", "c"]); + // $ExpectError + query.containedBy("attribute1", [1, 2, 3]); + // $ExpectError + query.containedBy("nonexistentProp", ["a", "b", "c"]); + + // $ExpectType Query + query.containedIn("attribute1", ["a", "b", "c"]); + // $ExpectType Query + query.containedIn("attribute3", ["objectId1", "objectId2", "objectId3"]); + // $ExpectError + query.containedIn("attribute2", ["a", "b", "c"]); + // $ExpectError + query.containedIn("attribute1", [1, 2, 3]); + // $ExpectError + query.containedIn("nonexistentProp", ["a", "b", "c"]); + + // $ExpectType Query + query.contains("attribute1", "a substring"); + // $ExpectError + query.contains("nonexistentProp", "a substring"); + + // $ExpectType Query + query.containsAll("attribute1", ["a", "b", "c"]); + // $ExpectError + query.containsAll("nonexistentProp", ["a", "b", "c"]); + + // $ExpectType Query + query.containsAllStartingWith("attribute1", ["a", "b", "c"]); + // $ExpectError + query.containsAllStartingWith("nonexistentProp", ["a", "b", "c"]); + + // $ExpectType Query + query.descending(["attribute1", "attribute2", "objectId"]); + // $ExpectError + query.descending(["attribute1", "nonexistentProp"]); + + // $ExpectType Query + query.doesNotExist("attribute1"); + // $ExpectError + query.doesNotExist("nonexistentProp"); + + // $ExpectType Query + query.doesNotMatchKeyInQuery("attribute1", "x", new Parse.Query(AnotherSubClass)); + // $ExpectError + query.doesNotMatchKeyInQuery("unexistenProp", "x", new Parse.Query(AnotherSubClass)); + // $ExpectError + 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")); + // $ExpectError + query.doesNotMatchQuery("nonexistentProp", new Parse.Query("Example")); + + // $ExpectType Query + query.endsWith("attribute1", "asuffixstring", "regex"); + + // $ExpectType Query + query.equalTo("attribute2", 0); + // $ExpectType Query + query.equalTo("attribute3", new AnotherSubClass()); + // $ExpectType Query + query.equalTo("attribute3", new AnotherSubClass().toPointer()); + // $ExpectError + query.equalTo("attribute1", new AnotherSubClass().toPointer()); + // $ExpectError + query.equalTo("attribute2", "a string value"); + // $ExpectError + 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"]); + + // $ExpectError + query.equalTo("attribute4", 5); + // $ExpectError + query.notEqualTo("attribute4", 5); + // $ExpectError + query.equalTo("attribute4", [5]); + // $ExpectError + query.notEqualTo("attribute4", [5]); + + // $ExpectType Query + query.exists("attribute1"); + // $ExpectError + query.exists("nonexistentProp"); + + // $ExpectType Query + query.fullText("attribute1", "full text"); + // $ExpectError + query.fullText("nonexistentProp", "full text"); + + // $ExpectType Query + query.greaterThan("attribute2", 1000); + // $ExpectError + query.greaterThan("attribute2", "1000"); + // $ExpectError + query.greaterThan("nonexistentProp", 1000); + + // $ExpectType Query + query.greaterThanOrEqualTo("attribute2", 1000); + // $ExpectError + query.greaterThanOrEqualTo("attribute2", "1000"); + // $ExpectError + query.greaterThanOrEqualTo("nonexistentProp", 1000); + + // $ExpectType Query + query.include(["attribute1", "attribute2"]); + // $ExpectType Query + query.include("attribute3.someProp"); + // $ExpectError + query.include(["attribute1", "nonexistentProp"]); + + // $ExpectType Query + query.lessThan("attribute2", 1000); + // $ExpectError + query.lessThan("attribute2", "1000"); + // $ExpectError + query.lessThan("nonexistentProp", 1000); + + // $ExpectType Query + query.lessThanOrEqualTo("attribute2", 1000); + // $ExpectError + query.lessThanOrEqualTo("attribute2", "1000"); + // $ExpectError + query.lessThanOrEqualTo("nonexistentProp", 1000); + + // $ExpectType Query + query.matches("attribute1", /a regex/); + // $ExpectError + query.matches("nonexistentProp", /a regex/); + + // $ExpectType Query + query.matchesKeyInQuery("attribute1", "x", new Parse.Query(AnotherSubClass)); + // $ExpectError + query.matchesKeyInQuery("nonexistentProp", "x", new Parse.Query(AnotherSubClass)); + // $ExpectError + query.matchesKeyInQuery("attribute1", "unknownKey", new Parse.Query(AnotherSubClass)); + + // $ExpectType Query + query.matchesQuery("attribute1", new Parse.Query("Example")); + // $ExpectError + query.matchesQuery("nonexistentProp", new Parse.Query("Example")); + + // $ExpectType Query + query.near("attribute1", new Parse.GeoPoint()); + // $ExpectError + query.near("nonexistentProp", new Parse.GeoPoint()); + + // $ExpectType Query + query.notContainedIn("attribute2", [1, 2, 3]); + // $ExpectError + query.notContainedIn("attribute2", ["1", "2", "3"]); + // $ExpectError + query.notContainedIn("nonexistentProp", [1, 2, 3]); + + // $ExpectType Query + query.notEqualTo("attribute1", "1"); + // $ExpectError + query.notEqualTo("attribute1", 1); + // $ExpectError + query.notEqualTo("nonexistentProp", 1); + + // $ExpectType Query + query.polygonContains("attribute1", new Parse.GeoPoint()); + // $ExpectError + query.polygonContains("nonexistentProp", new Parse.GeoPoint()); + + // $ExpectType Query + query.select("attribute1", "attribute2"); + // $ExpectError + query.select("attribute1", "nonexistentProp"); + + // $ExpectType Query + query.startsWith("attribute1", "prefix string"); + // $ExpectError + query.startsWith("nonexistentProp", "prefix string"); + + // $ExpectType Query + query.withCount(true); + + // $ExpectType Query + query.withinGeoBox("attribute1", new Parse.GeoPoint(), new Parse.GeoPoint()); + // $ExpectError + query.withinGeoBox("nonexistentProp", new Parse.GeoPoint(), new Parse.GeoPoint()); + + // $ExpectType Query + query.withinKilometers("attribute1", new Parse.GeoPoint(), 100); + // $ExpectError + query.withinKilometers("nonexistentProp", new Parse.GeoPoint(), 100); + + // $ExpectType Query + query.withinMiles("attribute1", new Parse.GeoPoint(), 100); + // $ExpectError + query.withinMiles("nonexistentProp", new Parse.GeoPoint(), 100); + + // $ExpectType Query + query.withinPolygon("attribute1", [ + [12.3, 45.6], + [-78.9, 10.1], + ]); + // $ExpectError + query.withinPolygon("nonexistentProp", [ + [12.3, 45.6], + [-78.9, 10.1], + ]); + + // $ExpectType Query + query.withinRadians("attribute1", new Parse.GeoPoint(), 100); + // $ExpectError + 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 }); + + // $ExpectError + new Parse.Session<{ example: number }>(); + + // $ExpectError + 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 }); + + // $ExpectError + new Parse.User<{ example: number }>(); + + // $ExpectError + new Parse.User<{ example: number }>({ }); + + // $ExpectError + 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(); + } +} diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 000000000..b929e6b82 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tests.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/types/tslint.json b/types/tslint.json new file mode 100644 index 000000000..f0e511597 --- /dev/null +++ b/types/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "ban-types": false, + "no-unnecessary-generics": false, + "no-redundant-jsdoc": false + } +} \ No newline at end of file diff --git a/types/types.js b/types/types.js new file mode 100644 index 000000000..accdefbc2 --- /dev/null +++ b/types/types.js @@ -0,0 +1,10 @@ +const fs = require('fs'); +let declarations = fs.readFileSync('index.d.ts').toString(); +const generics = fs.readFileSync('generics.ts').toString(); +const classes = generics.split('class '); +for (let classGrop of classes) { + const name = classGrop.split('<')[0].split(' ')[0]; + classGrop = classGrop.substring(0, classGrop.lastIndexOf("}")); + declarations = declarations.replace(`class ${name} {`, `class ${classGrop}`); +} +fs.writeFileSync('index.d.ts', declarations); diff --git a/types/types.sh b/types/types.sh new file mode 100755 index 000000000..a22d9c5ef --- /dev/null +++ b/types/types.sh @@ -0,0 +1,7 @@ +#!/bin/sh -e +jsdoc -a all -c ./jsdoc-ts-conf.json ./src -p +cd types +mv types.d.ts index.d.ts +cat interfaces.ts >> index.d.ts +node ./types.js +prettier --write 'index.d.ts' \ No newline at end of file