From 3ccbb309094c90f76424179ffdc43cf237612896 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 2 Apr 2025 14:17:19 -0500 Subject: [PATCH 1/8] feat: Add initial Typescript definitions --- .github/workflows/ci.yml | 2 + .npmignore | 2 + package-lock.json | 951 ++++++++++++++++++ package.json | 4 + src/{ParseServer.js => ParseServer.ts} | 11 +- src/{index.js => index.ts} | 0 src/logger.ts | 2 +- .../@types/@parse/fs-files-adapter/index.d.ts | 5 + types/ParseServer.d.ts | 60 ++ types/eslint.config.mjs | 30 + types/index.d.ts | 21 + types/logger.d.ts | 1 + types/tests.ts | 44 + types/tsconfig.json | 10 +- 14 files changed, 1137 insertions(+), 6 deletions(-) create mode 100644 .npmignore rename src/{ParseServer.js => ParseServer.ts} (99%) rename src/{index.js => index.ts} (100%) create mode 100644 types/@types/@parse/fs-files-adapter/index.d.ts create mode 100644 types/ParseServer.d.ts create mode 100644 types/eslint.config.mjs create mode 100644 types/tests.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d838cef57a..83686a3f57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,6 +147,8 @@ jobs: - run: npm ci - name: Build types run: npm run build:types + - name: Test Types + run: npm run test:types check-mongo: strategy: matrix: diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..36526782d6 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +types/tests.ts +types/eslint.config.mjs diff --git a/package-lock.json b/package-lock.json index c7d74a1f67..687b06bba4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,7 @@ "cross-env": "7.0.3", "deep-diff": "1.0.2", "eslint": "9.23.0", + "eslint-plugin-expect-type": "0.6.2", "flow-bin": "0.119.1", "form-data": "4.0.2", "globals": "16.0.0", @@ -102,6 +103,7 @@ "prettier": "2.0.5", "semantic-release": "24.2.1", "typescript": "5.8.2", + "typescript-eslint": "8.29.0", "yaml": "2.7.0" }, "engines": { @@ -6404,6 +6406,403 @@ "@types/webidl-conversions": "*" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.29.0.tgz", + "integrity": "sha512-PAIpk/U7NIS6H7TEtN45SPGLQaHNgB7wSjsQV/8+KYokAb2T/gloOA/Bee2yd4/yKVhPKe5LlaUGhAZk5zmSaQ==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/type-utils": "8.29.0", + "@typescript-eslint/utils": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.29.0.tgz", + "integrity": "sha512-8C0+jlNJOwQso2GapCVWWfW/rzaq7Lbme+vGUFKE31djwNncIpgXD7Cd4weEsDdkoZDjH0lwwr3QDQFuyrMg9g==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/typescript-estree": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.29.0.tgz", + "integrity": "sha512-aO1PVsq7Gm+tcghabUpzEnVSFMCU4/nYIgC2GOatJcllvWfnhrgW0ZEbnTxm36QsikmCN1K/6ZgM7fok2I7xNw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/scope-manager/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.29.0.tgz", + "integrity": "sha512-ahaWQ42JAOx+NKEf5++WC/ua17q5l+j1GFrbbpVKzFL/tKVc0aYY8rVSYUpUvt2hUP1YBr7mwXzx+E/DfUWI9Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "8.29.0", + "@typescript-eslint/utils": "8.29.0", + "debug": "^4.3.4", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/@typescript-eslint/types": { "version": "7.18.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz", @@ -6469,6 +6868,133 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@typescript-eslint/utils": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.29.0.tgz", + "integrity": "sha512-gX/A0Mz9Bskm8avSWFcK0gP7cZpbY4AIo6B0hWYFCaIsz750oaiWR4Jr2CI+PQhfW1CpcQr9OlfPS+kMFegjXA==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/typescript-estree": "8.29.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/@typescript-eslint/visitor-keys": { "version": "7.18.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz", @@ -9450,6 +9976,25 @@ } } }, + "node_modules/eslint-plugin-expect-type": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-expect-type/-/eslint-plugin-expect-type-0.6.2.tgz", + "integrity": "sha512-XWgtpplzr6GlpPUFG9ZApnSTv7QJXAPNN6hNmrlleVVCkAK23f/3E2BiCoA3Xtb0rIKfVKh7TLe+D1tcGt8/1w==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^6.10.0 || ^7.0.1 || ^8", + "fs-extra": "^11.1.1", + "get-tsconfig": "^4.8.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@typescript-eslint/parser": ">=6", + "eslint": ">=7", + "typescript": ">=4" + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -10997,6 +11542,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-tsconfig": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.0.tgz", + "integrity": "sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -11336,6 +11893,12 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/graphql": { "version": "16.10.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz", @@ -19142,6 +19705,15 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/responselike": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", @@ -21250,6 +21822,28 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.29.0.tgz", + "integrity": "sha512-ep9rVd9B4kQsZ7ZnWCVxUE/xDLUUUsRzE0poAeNu+4CkFErLfuvPt/qtm2EpnSyfvsR0S6QzDFSrPCFBwf64fg==", + "dev": true, + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.29.0", + "@typescript-eslint/parser": "8.29.0", + "@typescript-eslint/utils": "8.29.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -26556,6 +27150,243 @@ "@types/webidl-conversions": "*" } }, + "@typescript-eslint/eslint-plugin": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.29.0.tgz", + "integrity": "sha512-PAIpk/U7NIS6H7TEtN45SPGLQaHNgB7wSjsQV/8+KYokAb2T/gloOA/Bee2yd4/yKVhPKe5LlaUGhAZk5zmSaQ==", + "dev": true, + "requires": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/type-utils": "8.29.0", + "@typescript-eslint/utils": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.0.1" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true + }, + "@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + } + }, + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true + }, + "ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "requires": {} + } + } + }, + "@typescript-eslint/parser": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.29.0.tgz", + "integrity": "sha512-8C0+jlNJOwQso2GapCVWWfW/rzaq7Lbme+vGUFKE31djwNncIpgXD7Cd4weEsDdkoZDjH0lwwr3QDQFuyrMg9g==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/typescript-estree": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "requires": {} + } + } + }, + "@typescript-eslint/scope-manager": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.29.0.tgz", + "integrity": "sha512-aO1PVsq7Gm+tcghabUpzEnVSFMCU4/nYIgC2GOatJcllvWfnhrgW0ZEbnTxm36QsikmCN1K/6ZgM7fok2I7xNw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true + }, + "@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + } + }, + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true + } + } + }, + "@typescript-eslint/type-utils": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.29.0.tgz", + "integrity": "sha512-ahaWQ42JAOx+NKEf5++WC/ua17q5l+j1GFrbbpVKzFL/tKVc0aYY8rVSYUpUvt2hUP1YBr7mwXzx+E/DfUWI9Q==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "8.29.0", + "@typescript-eslint/utils": "8.29.0", + "debug": "^4.3.4", + "ts-api-utils": "^2.0.1" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "requires": {} + } + } + }, "@typescript-eslint/types": { "version": "7.18.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz", @@ -26598,6 +27429,83 @@ } } }, + "@typescript-eslint/utils": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.29.0.tgz", + "integrity": "sha512-gX/A0Mz9Bskm8avSWFcK0gP7cZpbY4AIo6B0hWYFCaIsz750oaiWR4Jr2CI+PQhfW1CpcQr9OlfPS+kMFegjXA==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.29.0", + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/typescript-estree": "8.29.0" + }, + "dependencies": { + "@typescript-eslint/types": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.29.0.tgz", + "integrity": "sha512-wcJL/+cOXV+RE3gjCyl/V2G877+2faqvlgtso/ZRbTCnZazh0gXhe+7gbAnfubzN2bNsBtZjDvlh7ero8uIbzg==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.29.0.tgz", + "integrity": "sha512-yOfen3jE9ISZR/hHpU/bmNvTtBW1NjRbkSFdZOksL1N+ybPEE7UVGMwqvS6CP022Rp00Sb0tdiIkhSCe6NI8ow==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "@typescript-eslint/visitor-keys": "8.29.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.29.0.tgz", + "integrity": "sha512-Sne/pVz8ryR03NFK21VpN88dZ2FdQXOlq3VIklbrTYEt8yXtRFr9tvUhqvCeKjqYk5FSim37sHbooT6vzBTZcg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.29.0", + "eslint-visitor-keys": "^4.2.0" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "requires": {} + } + } + }, "@typescript-eslint/visitor-keys": { "version": "7.18.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz", @@ -28879,6 +29787,17 @@ } } }, + "eslint-plugin-expect-type": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-expect-type/-/eslint-plugin-expect-type-0.6.2.tgz", + "integrity": "sha512-XWgtpplzr6GlpPUFG9ZApnSTv7QJXAPNN6hNmrlleVVCkAK23f/3E2BiCoA3Xtb0rIKfVKh7TLe+D1tcGt8/1w==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "^6.10.0 || ^7.0.1 || ^8", + "fs-extra": "^11.1.1", + "get-tsconfig": "^4.8.1" + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -29880,6 +30799,15 @@ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", "dev": true }, + "get-tsconfig": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.0.tgz", + "integrity": "sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==", + "dev": true, + "requires": { + "resolve-pkg-maps": "^1.0.0" + } + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -30139,6 +31067,12 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "graphql": { "version": "16.10.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz", @@ -35635,6 +36569,12 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" }, + "resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true + }, "responselike": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", @@ -37132,6 +38072,17 @@ "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", "dev": true }, + "typescript-eslint": { + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.29.0.tgz", + "integrity": "sha512-ep9rVd9B4kQsZ7ZnWCVxUE/xDLUUUsRzE0poAeNu+4CkFErLfuvPt/qtm2EpnSyfvsR0S6QzDFSrPCFBwf64fg==", + "dev": true, + "requires": { + "@typescript-eslint/eslint-plugin": "8.29.0", + "@typescript-eslint/parser": "8.29.0", + "@typescript-eslint/utils": "8.29.0" + } + }, "uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", diff --git a/package.json b/package.json index 0c3275b9c2..6a769a8458 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "cross-env": "7.0.3", "deep-diff": "1.0.2", "eslint": "9.23.0", + "eslint-plugin-expect-type": "0.6.2", "flow-bin": "0.119.1", "form-data": "4.0.2", "globals": "16.0.0", @@ -109,6 +110,7 @@ "prettier": "2.0.5", "semantic-release": "24.2.1", "typescript": "5.8.2", + "typescript-eslint": "8.29.0", "yaml": "2.7.0" }, "scripts": { @@ -122,6 +124,7 @@ "build": "babel src/ -d lib/ --copy-files --extensions '.ts,.js'", "build:types": "tsc", "watch": "babel --watch src/ -d lib/ --copy-files", + "watch:ts": "tsc --watch", "test:mongodb:runnerstart": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=$npm_config_dbversion} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017", "test:mongodb:testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=$npm_config_dbversion} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine", "test:mongodb": "npm run test:mongodb:runnerstart --dbversion=$npm_config_dbversion && npm run test:mongodb:testonly --dbversion=$npm_config_dbversion", @@ -132,6 +135,7 @@ "pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=8.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017", "testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=8.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine", "test": "npm run testonly", + "test:types": "eslint types/tests.ts -c ./types/eslint.config.mjs", "posttest": "cross-env mongodb-runner stop --all", "coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=8.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 nyc jasmine", "start": "node ./bin/parse-server", diff --git a/src/ParseServer.js b/src/ParseServer.ts similarity index 99% rename from src/ParseServer.js rename to src/ParseServer.ts index 7b09a8c335..a160263db2 100644 --- a/src/ParseServer.js +++ b/src/ParseServer.ts @@ -56,6 +56,11 @@ const connections = new Connections(); // ParseServer works like a constructor of an express app. // https://parseplatform.org/parse-server/api/master/ParseServerOptions.html class ParseServer { + _app: any; + config: any; + server: any; + expressApp: any; + liveQueryServer: any; /** * @constructor * @param {ParseServerOptions} options the parse server initialization options @@ -140,7 +145,7 @@ class ParseServer { * Starts Parse Server as an express app; this promise resolves when Parse Server is ready to accept requests. */ - async start() { + async start(): Promise { try { if (this.config.state === 'ok') { return this; @@ -331,7 +336,7 @@ class ParseServer { if (!process.env.TESTING) { //This causes tests to spew some useless warnings, so disable in test /* istanbul ignore next */ - process.on('uncaughtException', err => { + process.on('uncaughtException', (err: any) => { if (err.code === 'EADDRINUSE') { // user-friendly message for this common error process.stderr.write(`Unable to listen on port ${err.port}. The port is already in use.`); @@ -497,7 +502,7 @@ class ParseServer { httpServer, config: LiveQueryServerOptions, options: ParseServerOptions - ) { + ): ParseLiveQueryServer { if (!httpServer || (config && config.port)) { var app = express(); httpServer = require('http').createServer(app); diff --git a/src/index.js b/src/index.ts similarity index 100% rename from src/index.js rename to src/index.ts diff --git a/src/logger.ts b/src/logger.ts index 97604039c5..5ec88c0e47 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -15,7 +15,7 @@ function defaultLogger() { return new LoggerController(adapter, null, options); } -let logger = defaultLogger(); +export let logger = defaultLogger(); export function setLogger(aLogger) { logger = aLogger; diff --git a/types/@types/@parse/fs-files-adapter/index.d.ts b/types/@types/@parse/fs-files-adapter/index.d.ts new file mode 100644 index 0000000000..ffab73832d --- /dev/null +++ b/types/@types/@parse/fs-files-adapter/index.d.ts @@ -0,0 +1,5 @@ +// TODO: Remove when @parse/fs-files-adapter is typed +declare module '@parse/fs-files-adapter' { + const FileSystemAdapter: any; + export default FileSystemAdapter; +} diff --git a/types/ParseServer.d.ts b/types/ParseServer.d.ts new file mode 100644 index 0000000000..651fad3fab --- /dev/null +++ b/types/ParseServer.d.ts @@ -0,0 +1,60 @@ +import { ParseServerOptions, LiveQueryServerOptions } from './Options'; +import { ParseLiveQueryServer } from './LiveQuery/ParseLiveQueryServer'; +declare class ParseServer { + _app: any; + config: any; + server: any; + expressApp: any; + liveQueryServer: any; + /** + * @constructor + * @param {ParseServerOptions} options the parse server initialization options + */ + constructor(options: ParseServerOptions); + /** + * Starts Parse Server as an express app; this promise resolves when Parse Server is ready to accept requests. + */ + start(): Promise; + get app(): any; + /** + * Stops the parse server, cancels any ongoing requests and closes all connections. + * + * Currently, express doesn't shut down immediately after receiving SIGINT/SIGTERM + * if it has client connections that haven't timed out. + * (This is a known issue with node - https://github.com/nodejs/node/issues/2642) + * + * @returns {Promise} a promise that resolves when the server is stopped + */ + handleShutdown(): Promise; + /** + * @static + * Create an express app for the parse server + * @param {Object} options let you specify the maxUploadSize when creating the express app */ + static app(options: any): any; + static promiseRouter({ appId }: { + appId: any; + }): any; + /** + * starts the parse server's express app + * @param {ParseServerOptions} options to use to start the server + * @returns {ParseServer} the parse server instance + */ + startApp(options: ParseServerOptions): Promise; + /** + * Creates a new ParseServer and starts it. + * @param {ParseServerOptions} options used to start the server + * @returns {ParseServer} the parse server instance + */ + static startApp(options: ParseServerOptions): Promise; + /** + * Helper method to create a liveQuery server + * @static + * @param {Server} httpServer an optional http server to pass + * @param {LiveQueryServerOptions} config options for the liveQueryServer + * @param {ParseServerOptions} options options for the ParseServer + * @returns {Promise} the live query server instance + */ + static createLiveQueryServer(httpServer: any, config: LiveQueryServerOptions, options: ParseServerOptions): ParseLiveQueryServer; + static verifyServerUrl(): any; +} +export default ParseServer; diff --git a/types/eslint.config.mjs b/types/eslint.config.mjs new file mode 100644 index 0000000000..f2375e596f --- /dev/null +++ b/types/eslint.config.mjs @@ -0,0 +1,30 @@ +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import expectType from 'eslint-plugin-expect-type/configs/recommended'; + +export default tseslint.config({ + files: ['**/*.js', '**/*.ts'], + extends: [ + expectType, + eslint.configs.recommended, + ...tseslint.configs.recommended, + ...tseslint.configs.recommendedTypeChecked, + ], + plugins: { + '@typescript-eslint': tseslint.plugin, + }, + rules: { + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unsafe-return": "off", + }, + languageOptions: { + parser: tseslint.parser, + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, +}); diff --git a/types/index.d.ts b/types/index.d.ts index e69de29bb2..591044c272 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -0,0 +1,21 @@ +import ParseServer from './ParseServer'; +import FileSystemAdapter from '@parse/fs-files-adapter'; +import InMemoryCacheAdapter from './Adapters/Cache/InMemoryCacheAdapter'; +import NullCacheAdapter from './Adapters/Cache/NullCacheAdapter'; +import RedisCacheAdapter from './Adapters/Cache/RedisCacheAdapter'; +import LRUCacheAdapter from './Adapters/Cache/LRUCache.js'; +import * as TestUtils from './TestUtils'; +import * as SchemaMigrations from './SchemaMigrations/Migrations'; +import AuthAdapter from './Adapters/Auth/AuthAdapter'; +import { PushWorker } from './Push/PushWorker'; +import { ParseServerOptions } from './Options'; +import { ParseGraphQLServer } from './GraphQL/ParseGraphQLServer'; +declare const _ParseServer: { + (options: ParseServerOptions): ParseServer; + createLiveQueryServer: typeof ParseServer.createLiveQueryServer; + startApp: typeof ParseServer.startApp; +}; +declare const S3Adapter: any; +declare const GCSAdapter: any; +export default ParseServer; +export { S3Adapter, GCSAdapter, FileSystemAdapter, InMemoryCacheAdapter, NullCacheAdapter, RedisCacheAdapter, LRUCacheAdapter, TestUtils, PushWorker, ParseGraphQLServer, _ParseServer as ParseServer, SchemaMigrations, AuthAdapter, }; diff --git a/types/logger.d.ts b/types/logger.d.ts index 14b33350d6..f81e70db76 100644 --- a/types/logger.d.ts +++ b/types/logger.d.ts @@ -1,2 +1,3 @@ +export declare let logger: any; export declare function setLogger(aLogger: any): void; export declare function getLogger(): any; diff --git a/types/tests.ts b/types/tests.ts new file mode 100644 index 0000000000..9fc0aa2fcb --- /dev/null +++ b/types/tests.ts @@ -0,0 +1,44 @@ +import ParseServer, { FileSystemAdapter } from 'parse-server'; + +async function server() { + // $ExpectType ParseServer + const parseServer = await ParseServer.startApp({}); + + // $ExpectType void + await parseServer.handleShutdown(); + + // $ExpectType any + parseServer.app; + + // $ExpectType any + ParseServer.app({}); + + // $ExpectType any + ParseServer.promiseRouter({ appId: 'appId' }); + + // $ExpectType ParseLiveQueryServer + await ParseServer.createLiveQueryServer({}, {}, {}); + + // $ExpectType any + ParseServer.verifyServerUrl(); + + // $ExpectError + await ParseServer.startApp(); + + // $ExpectError + ParseServer.promiseRouter(); + + // $ExpectError + ParseServer.createLiveQueryServer(); + + // $ExpectType ParseServer + const parseServer2 = new ParseServer({}); + + // $ExpectType ParseServer + await parseServer2.start(); +} + +function exports() { + // $ExpectType any + FileSystemAdapter; +} diff --git a/types/tsconfig.json b/types/tsconfig.json index 917319a042..0880cb0a81 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -13,6 +13,12 @@ // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". // If the library is global (cannot be imported via `import` or `require`), leave this out. "baseUrl": ".", - "paths": { "parse": ["."] } - } + "paths": { + "parse-server": ["."], + "@parse/fs-files-adapter": ["./@types/@parse/fs-files-adapter"], + } + }, + "include": [ + "tests.ts" + ] } From 468918ef4a5f20276432c2bc031b8b48851f54e5 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 2 Apr 2025 16:01:07 -0500 Subject: [PATCH 2/8] Add ParseLiveQueryServer definitions --- eslint.config.js | 2 +- ...QueryServer.js => ParseLiveQueryServer.ts} | 59 +-- src/Options/{index.js => index.ts} | 374 +++++++++--------- src/ParseServer.ts | 4 +- tsconfig.json | 7 +- types/@types/deepcopy/index.d.ts | 5 + types/LiveQuery/ParseLiveQueryServer.d.ts | 40 ++ types/Options/index.d.ts | 250 ++++++++++++ types/ParseServer.d.ts | 2 +- types/tests.ts | 2 +- 10 files changed, 525 insertions(+), 220 deletions(-) rename src/LiveQuery/{ParseLiveQueryServer.js => ParseLiveQueryServer.ts} (97%) rename src/Options/{index.js => index.ts} (86%) create mode 100644 types/@types/deepcopy/index.d.ts create mode 100644 types/LiveQuery/ParseLiveQueryServer.d.ts create mode 100644 types/Options/index.d.ts diff --git a/eslint.config.js b/eslint.config.js index e7fae3b833..d1cbac6e5e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,7 @@ const babelParser = require("@babel/eslint-parser"); const globals = require("globals"); module.exports = [ { - ignores: ["**/lib/**", "**/coverage/**", "**/out/**"], + ignores: ["**/lib/**", "**/coverage/**", "**/out/**", "**/types/**"], }, js.configs.recommended, { diff --git a/src/LiveQuery/ParseLiveQueryServer.js b/src/LiveQuery/ParseLiveQueryServer.ts similarity index 97% rename from src/LiveQuery/ParseLiveQueryServer.js rename to src/LiveQuery/ParseLiveQueryServer.ts index 5748f7f10f..531de0c786 100644 --- a/src/LiveQuery/ParseLiveQueryServer.js +++ b/src/LiveQuery/ParseLiveQueryServer.ts @@ -3,7 +3,7 @@ import Parse from 'parse/node'; import { Subscription } from './Subscription'; import { Client } from './Client'; import { ParseWebSocketServer } from './ParseWebSocketServer'; -import logger from '../logger'; +import { logger } from '../logger'; import RequestSchema from './RequestSchema'; import { matchesQuery, queryHash } from './QueryTools'; import { ParsePubSub } from './ParsePubSub'; @@ -26,13 +26,17 @@ import { isDeepStrictEqual } from 'util'; import deepcopy from 'deepcopy'; class ParseLiveQueryServer { - clients: Map; + server: any; + config: any; + clients: Map; // className -> (queryHash -> subscription) - subscriptions: Object; - parseWebSocketServer: Object; + subscriptions: Map; + parseWebSocketServer: any; keyPairs: any; // The subscriber we use to get object update from publisher - subscriber: Object; + subscriber: any; + authCache: any; + cacheController: any; constructor(server: any, config: any = {}, parseServerConfig: any = {}) { this.server = server; @@ -168,7 +172,7 @@ class ParseLiveQueryServer { // Message is the JSON object from publisher after inflated. Message.currentParseObject is the ParseObject after changes. // Message.originalParseObject is the original ParseObject. - async _onAfterDelete(message: any): void { + async _onAfterDelete(message: any): Promise { logger.verbose(Parse.applicationId + 'afterDelete is triggered'); let deletedParseObject = message.currentParseObject.toJSON(); @@ -197,7 +201,7 @@ class ParseLiveQueryServer { const acl = message.currentParseObject.getACL(); // Check CLP const op = this._getCLPOperation(subscription.query); - let res = {}; + let res: any = {}; try { await this._matchesCLP( classLevelPermissions, @@ -261,7 +265,7 @@ class ParseLiveQueryServer { // Message is the JSON object from publisher after inflated. Message.currentParseObject is the ParseObject after changes. // Message.originalParseObject is the original ParseObject. - async _onAfterSave(message: any): void { + async _onAfterSave(message: any): Promise { logger.verbose(Parse.applicationId + 'afterSave is triggered'); let originalParseObject = null; @@ -309,7 +313,7 @@ class ParseLiveQueryServer { // Set current ParseObject ACL checking promise, if the object does not match // subscription, we do not need to check ACL let currentACLCheckingPromise; - let res = {}; + let res: any = {}; if (!isCurrentSubscriptionMatched) { currentACLCheckingPromise = Promise.resolve(false); } else { @@ -548,7 +552,7 @@ class ParseLiveQueryServer { } } - getAuthForSessionToken(sessionToken: ?string): Promise<{ auth: ?Auth, userId: ?string }> { + getAuthForSessionToken(sessionToken?: string): Promise<{ auth?: Auth, userId?: string }> { if (!sessionToken) { return Promise.resolve({}); } @@ -565,7 +569,7 @@ class ParseLiveQueryServer { }) .catch(error => { // There was an error with the session token - const result = {}; + const result: any = {}; if (error && error.code === Parse.Error.INVALID_SESSION_TOKEN) { result.error = error; this.authCache.set(sessionToken, Promise.resolve(result), this.config.cacheTimeout); @@ -579,12 +583,12 @@ class ParseLiveQueryServer { } async _matchesCLP( - classLevelPermissions: ?any, - object: any, - client: any, - requestId: number, - op: string - ): any { + classLevelPermissions?: any, + object?: any, + client?: any, + requestId?: number, + op?: string + ): Promise { // try to match on user first, less expensive than with roles const subscriptionInfo = client.getSubscriptionInfo(requestId); const aclGroup = ['*']; @@ -621,12 +625,12 @@ class ParseLiveQueryServer { } async _filterSensitiveData( - classLevelPermissions: ?any, - res: any, - client: any, - requestId: number, - op: string, - query: any + classLevelPermissions?: any, + res?: any, + client?: any, + requestId?: number, + op?: string, + query?: any ) { const subscriptionInfo = client.getSubscriptionInfo(requestId); const aclGroup = ['*']; @@ -718,7 +722,7 @@ class ParseLiveQueryServer { }); } - async getAuthFromClient(client: any, requestId: number, sessionToken: string) { + async getAuthFromClient(client: any, requestId: number, sessionToken?: string) { const getSessionFromClient = () => { const subscriptionInfo = client.getSubscriptionInfo(requestId); if (typeof subscriptionInfo === 'undefined') { @@ -772,7 +776,7 @@ class ParseLiveQueryServer { return false; } - async _handleConnect(parseWebsocket: any, request: any): any { + async _handleConnect(parseWebsocket: any, request: any): Promise { if (!this._validateKeys(request, this.keyPairs)) { Client.pushError(parseWebsocket, 4, 'Key in request is not valid'); logger.error('Key in request is not valid'); @@ -796,6 +800,7 @@ class ParseLiveQueryServer { sessionToken: request.sessionToken, useMasterKey: client.hasMasterKey, installationId: request.installationId, + user: undefined, }; const trigger = getTrigger('@Connect', 'beforeConnect', Parse.applicationId); if (trigger) { @@ -845,7 +850,7 @@ class ParseLiveQueryServer { return isValid; } - async _handleSubscribe(parseWebsocket: any, request: any): any { + async _handleSubscribe(parseWebsocket: any, request: any): Promise { // If we can not find this client, return error to client if (!Object.prototype.hasOwnProperty.call(parseWebsocket, 'clientId')) { Client.pushError( @@ -918,7 +923,7 @@ class ParseLiveQueryServer { } // Add subscriptionInfo to client - const subscriptionInfo = { + const subscriptionInfo: any = { subscription: subscription, }; // Add selected fields, sessionToken and installationId for this subscription if necessary diff --git a/src/Options/index.js b/src/Options/index.ts similarity index 86% rename from src/Options/index.js rename to src/Options/index.ts index b3c04462ca..92e84b0832 100644 --- a/src/Options/index.js +++ b/src/Options/index.ts @@ -15,20 +15,20 @@ export interface SchemaOptions { definitions: any; /* Is true if Parse Server should exit if schema update fail. :DEFAULT: false */ - strict: ?boolean; + strict?: boolean; /* Is true if Parse Server should delete any fields not defined in a schema definition. This should only be used during development. :DEFAULT: false */ - deleteExtraFields: ?boolean; + deleteExtraFields?: boolean; /* Is true if Parse Server should recreate any fields that are different between the current database schema and theschema definition. This should only be used during development. :DEFAULT: false */ - recreateModifiedFields: ?boolean; + recreateModifiedFields?: boolean; /* Is true if Parse Server will reject any attempts to modify the schema while the server is running. :DEFAULT: false */ - lockSchemas: ?boolean; + lockSchemas?: boolean; /* Execute a callback before running schema migrations. */ - beforeMigration: ?() => void | Promise; + beforeMigration?: () => void | Promise; /* Execute a callback after running schema migrations. */ - afterMigration: ?() => void | Promise; + afterMigration?: () => void | Promise; } type Adapter = string | any | T; @@ -48,7 +48,7 @@ export interface ParseServerOptions { /* Your Parse Master Key */ masterKey: (() => void) | string; /* (Optional) The duration in seconds for which the current `masterKey` is being used before it is requested again if `masterKey` is set to a function. If `masterKey` is not set to a function, this option has no effect. Default is `0`, which means the master key is requested by invoking the `masterKey` function every time the master key is used internally by Parse Server. */ - masterKeyTtl: ?number; + masterKeyTtl?: number; /* (Optional) The maintenance key is used for modifying internal and read-only fields of Parse Server.

⚠️ This key is not intended to be used as part of a regular operation of Parse Server. This key is intended to conduct out-of-band changes such as one-time migrations or data correction tasks. Internal fields are not officially documented and may change at any time without publication in release changelogs. We strongly advice not to rely on internal fields as part of your regular operation and to investigate the implications of any planned changes *directly in the source code* of your current version of Parse Server. */ maintenanceKey: string; /* URL to your parse server with http:// or https://. @@ -56,137 +56,137 @@ export interface ParseServerOptions { serverURL: string; /* (Optional) Restricts the use of master key permissions to a list of IP addresses or ranges.

This option accepts a list of single IP addresses, for example `['10.0.0.1', '10.0.0.2']`. You can also use CIDR notation to specify an IP address range, for example `['10.0.1.0/24']`.

Special scenarios:
- Setting an empty array `[]` means that the master key cannot be used even in Parse Server Cloud Code. This value cannot be set via an environment variable as there is no way to pass an empty array to Parse Server via an environment variable.
- Setting `['0.0.0.0/0', '::0']` means to allow any IPv4 and IPv6 address to use the master key and effectively disables the IP filter.

Considerations:
- IPv4 and IPv6 addresses are not compared against each other. Each IP version (IPv4 and IPv6) needs to be considered separately. For example, `['0.0.0.0/0']` allows any IPv4 address and blocks every IPv6 address. Conversely, `['::0']` allows any IPv6 address and blocks every IPv4 address.
- Keep in mind that the IP version in use depends on the network stack of the environment in which Parse Server runs. A local environment may use a different IP version than a remote environment. For example, it's possible that locally the value `['0.0.0.0/0']` allows the request IP because the environment is using IPv4, but when Parse Server is deployed remotely the request IP is blocked because the remote environment is using IPv6.
- When setting the option via an environment variable the notation is a comma-separated string, for example `"0.0.0.0/0,::0"`.
- IPv6 zone indices (`%` suffix) are not supported, for example `fe80::1%eth0`, `fe80::1%1` or `::1%lo`.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server instance on which Parse Server runs, is allowed to use the master key. :DEFAULT: ["127.0.0.1","::1"] */ - masterKeyIps: ?(string[]); + masterKeyIps?: (string[]); /* (Optional) Restricts the use of maintenance key permissions to a list of IP addresses or ranges.

This option accepts a list of single IP addresses, for example `['10.0.0.1', '10.0.0.2']`. You can also use CIDR notation to specify an IP address range, for example `['10.0.1.0/24']`.

Special scenarios:
- Setting an empty array `[]` means that the maintenance key cannot be used even in Parse Server Cloud Code. This value cannot be set via an environment variable as there is no way to pass an empty array to Parse Server via an environment variable.
- Setting `['0.0.0.0/0', '::0']` means to allow any IPv4 and IPv6 address to use the maintenance key and effectively disables the IP filter.

Considerations:
- IPv4 and IPv6 addresses are not compared against each other. Each IP version (IPv4 and IPv6) needs to be considered separately. For example, `['0.0.0.0/0']` allows any IPv4 address and blocks every IPv6 address. Conversely, `['::0']` allows any IPv6 address and blocks every IPv4 address.
- Keep in mind that the IP version in use depends on the network stack of the environment in which Parse Server runs. A local environment may use a different IP version than a remote environment. For example, it's possible that locally the value `['0.0.0.0/0']` allows the request IP because the environment is using IPv4, but when Parse Server is deployed remotely the request IP is blocked because the remote environment is using IPv6.
- When setting the option via an environment variable the notation is a comma-separated string, for example `"0.0.0.0/0,::0"`.
- IPv6 zone indices (`%` suffix) are not supported, for example `fe80::1%eth0`, `fe80::1%1` or `::1%lo`.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server instance on which Parse Server runs, is allowed to use the maintenance key. :DEFAULT: ["127.0.0.1","::1"] */ - maintenanceKeyIps: ?(string[]); + maintenanceKeyIps?: (string[]); /* Sets the app name */ - appName: ?string; + appName?: string; /* Add headers to Access-Control-Allow-Headers */ - allowHeaders: ?(string[]); + allowHeaders?: (string[]); /* Sets origins for Access-Control-Allow-Origin. This can be a string for a single origin or an array of strings for multiple origins. */ - allowOrigin: ?StringOrStringArray; + allowOrigin?: StringOrStringArray; /* Adapter module for the analytics */ - analyticsAdapter: ?Adapter; + analyticsAdapter?: Adapter; /* Adapter module for the files sub-system */ - filesAdapter: ?Adapter; + filesAdapter?: Adapter; /* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */ - push: ?any; + push?: any; /* Configuration for push scheduling, defaults to false. :DEFAULT: false */ - scheduledPush: ?boolean; + scheduledPush?: boolean; /* Adapter module for the logging sub-system */ - loggerAdapter: ?Adapter; + loggerAdapter?: Adapter; /* Log as structured JSON objects :ENV: JSON_LOGS */ - jsonLogs: ?boolean; + jsonLogs?: boolean; /* Folder for the logs (defaults to './logs'); set to null to disable file based logging :ENV: PARSE_SERVER_LOGS_FOLDER :DEFAULT: ./logs */ - logsFolder: ?string; + logsFolder?: string; /* Set the logging to verbose :ENV: VERBOSE */ - verbose: ?boolean; + verbose?: boolean; /* Sets the level for logs */ - logLevel: ?string; + logLevel?: string; /* (Optional) Overrides the log levels used internally by Parse Server to log events. :DEFAULT: {} */ - logLevels: ?LogLevels; + logLevels?: LogLevels; /* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null) */ - maxLogFiles: ?NumberOrString; + maxLogFiles?: NumberOrString; /* Disables console output :ENV: SILENT */ - silent: ?boolean; + silent?: boolean; /* The full URI to your database. Supported databases are mongodb or postgres. :DEFAULT: mongodb://localhost:27017/parse */ databaseURI: string; /* Options to pass to the database client :ENV: PARSE_SERVER_DATABASE_OPTIONS */ - databaseOptions: ?DatabaseOptions; + databaseOptions?: DatabaseOptions; /* Adapter module for the database; any options that are not explicitly described here are passed directly to the database client. */ - databaseAdapter: ?Adapter; + databaseAdapter?: Adapter; /* Optional. If set to `true`, the collation rule of case comparison for queries and indexes is enabled. Enable this option to run Parse Server with MongoDB Atlas Serverless or AWS Amazon DocumentDB. If `false`, the collation rule of case comparison is disabled. Default is `false`. :DEFAULT: false */ - enableCollationCaseComparison: ?boolean; + enableCollationCaseComparison?: boolean; /* Optional. If set to `true`, the `email` property of a user is automatically converted to lowercase before being stored in the database. Consequently, queries must match the case as stored in the database, which would be lowercase in this scenario. If `false`, the `email` property is stored as set, without any case modifications. Default is `false`. :DEFAULT: false */ - convertEmailToLowercase: ?boolean; + convertEmailToLowercase?: boolean; /* Optional. If set to `true`, the `username` property of a user is automatically converted to lowercase before being stored in the database. Consequently, queries must match the case as stored in the database, which would be lowercase in this scenario. If `false`, the `username` property is stored as set, without any case modifications. Default is `false`. :DEFAULT: false */ - convertUsernameToLowercase: ?boolean; + convertUsernameToLowercase?: boolean; /* Full path to your cloud code main.js */ - cloud: ?string; + cloud?: string; /* A collection prefix for the classes :DEFAULT: '' */ - collectionPrefix: ?string; + collectionPrefix?: string; /* Key for iOS, MacOS, tvOS clients */ - clientKey: ?string; + clientKey?: string; /* Key for the Javascript SDK */ - javascriptKey: ?string; + javascriptKey?: string; /* Key for Unity and .Net SDK */ - dotNetKey: ?string; + dotNetKey?: string; /* Key for encrypting your files :ENV: PARSE_SERVER_ENCRYPTION_KEY */ - encryptionKey: ?string; + encryptionKey?: string; /* Key for REST calls :ENV: PARSE_SERVER_REST_API_KEY */ - restAPIKey: ?string; + restAPIKey?: string; /* Read-only key, which has the same capabilities as MasterKey without writes */ - readOnlyMasterKey: ?string; + readOnlyMasterKey?: string; /* Key sent with outgoing webhook calls */ - webhookKey: ?string; + webhookKey?: string; /* Key for your files */ - fileKey: ?string; + fileKey?: string; /* Enable (or disable) the addition of a unique hash to the file names :ENV: PARSE_SERVER_PRESERVE_FILE_NAME :DEFAULT: false */ - preserveFileName: ?boolean; + preserveFileName?: boolean; /* Personally identifiable information fields in the user table the should be removed for non-authorized users. Deprecated @see protectedFields */ - userSensitiveFields: ?(string[]); + userSensitiveFields?: (string[]); /* Protected fields that should be treated with extra security when fetching details. :DEFAULT: {"_User": {"*": ["email"]}} */ - protectedFields: ?ProtectedFields; + protectedFields?: ProtectedFields; /* Enable (or disable) anonymous users, defaults to true :ENV: PARSE_SERVER_ENABLE_ANON_USERS :DEFAULT: true */ - enableAnonymousUsers: ?boolean; + enableAnonymousUsers?: boolean; /* Enable (or disable) client class creation, defaults to false :ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION :DEFAULT: false */ - allowClientClassCreation: ?boolean; + allowClientClassCreation?: boolean; /* Enable (or disable) custom objectId :ENV: PARSE_SERVER_ALLOW_CUSTOM_OBJECT_ID :DEFAULT: false */ - allowCustomObjectId: ?boolean; + allowCustomObjectId?: boolean; /* Configuration for your authentication providers, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication :ENV: PARSE_SERVER_AUTH_PROVIDERS */ - auth: ?{ [string]: AuthAdapter }; + auth?: Record; /* Enable (or disable) insecure auth adapters, defaults to true. Insecure auth adapters are deprecated and it is recommended to disable them. :ENV: PARSE_SERVER_ENABLE_INSECURE_AUTH_ADAPTERS :DEFAULT: true */ - enableInsecureAuthAdapters: ?boolean; + enableInsecureAuthAdapters?: boolean; /* Max file size for uploads, defaults to 20mb :DEFAULT: 20mb */ - maxUploadSize: ?string; + maxUploadSize?: string; /* Set to `true` to require users to verify their email address to complete the sign-up process. Supports a function with a return value of `true` or `false` for conditional verification.

Default is `false`. :DEFAULT: false */ - verifyUserEmails: ?(boolean | void); + verifyUserEmails?: (boolean | void); /* Set to `true` to prevent a user from logging in if the email has not yet been verified and email verification is required.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - preventLoginWithUnverifiedEmail: ?boolean; + preventLoginWithUnverifiedEmail?: boolean; /* If set to `true` it prevents a user from signing up if the email has not yet been verified and email verification is required. In that case the server responds to the sign-up with HTTP status 400 and a Parse Error 205 `EMAIL_NOT_FOUND`. If set to `false` the server responds with HTTP status 200, and client SDKs return an unauthenticated Parse User without session token. In that case subsequent requests fail until the user's email address is verified.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - preventSignupWithUnverifiedEmail: ?boolean; + preventSignupWithUnverifiedEmail?: boolean; /* Set the validity duration of the email verification token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.

For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours). @@ -195,169 +195,169 @@ export interface ParseServerOptions {
Requires option `verifyUserEmails: true`. */ - emailVerifyTokenValidityDuration: ?number; + emailVerifyTokenValidityDuration?: number; /* Set to `true` if a email verification token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - emailVerifyTokenReuseIfValid: ?boolean; + emailVerifyTokenReuseIfValid?: boolean; /* Set to `false` to prevent sending of verification email. Supports a function with a return value of `true` or `false` for conditional email sending.

Default is `true`.
:DEFAULT: true */ - sendUserEmailVerification: ?(boolean | void); + sendUserEmailVerification?: (boolean | void); /* The account lockout policy for failed login attempts. */ - accountLockout: ?AccountLockoutOptions; + accountLockout?: AccountLockoutOptions; /* The password policy for enforcing password related rules. */ - passwordPolicy: ?PasswordPolicyOptions; + passwordPolicy?: PasswordPolicyOptions; /* Adapter module for the cache */ - cacheAdapter: ?Adapter; + cacheAdapter?: Adapter; /* Adapter module for email sending */ - emailAdapter: ?Adapter; + emailAdapter?: Adapter; /* If set to `true`, a `Parse.Object` that is in the payload when calling a Cloud Function will be converted to an instance of `Parse.Object`. If `false`, the object will not be converted and instead be a plain JavaScript object, which contains the raw data of a `Parse.Object` but is not an actual instance of `Parse.Object`. Default is `false`.

ℹ️ The expected behavior would be that the object is converted to an instance of `Parse.Object`, so you would normally set this option to `true`. The default is `false` because this is a temporary option that has been introduced to avoid a breaking change when fixing a bug where JavaScript objects are not converted to actual instances of `Parse.Object`. :DEFAULT: true */ - encodeParseObjectInCloudFunction: ?boolean; + encodeParseObjectInCloudFunction?: boolean; /* Public URL to your parse server with http:// or https://. :ENV: PARSE_PUBLIC_SERVER_URL */ - publicServerURL: ?string; + publicServerURL?: string; /* The options for pages such as password reset and email verification. :DEFAULT: {} */ - pages: ?PagesOptions; + pages?: PagesOptions; /* custom pages for password validation and reset :DEFAULT: {} */ - customPages: ?CustomPagesOptions; + customPages?: CustomPagesOptions; /* parse-server's LiveQuery configuration object */ - liveQuery: ?LiveQueryOptions; + liveQuery?: LiveQueryOptions; /* Session duration, in seconds, defaults to 1 year :DEFAULT: 31536000 */ - sessionLength: ?number; + sessionLength?: number; /* Whether Parse Server should automatically extend a valid session by the sessionLength. In order to reduce the number of session updates in the database, a session will only be extended when a request is received after at least half of the current session's lifetime has passed. :DEFAULT: false */ - extendSessionOnUse: ?boolean; + extendSessionOnUse?: boolean; /* Default value for limit option on queries, defaults to `100`. :DEFAULT: 100 */ - defaultLimit: ?number; + defaultLimit?: number; /* Max value for limit option on queries, defaults to unlimited */ - maxLimit: ?number; + maxLimit?: number; /* Sets whether we should expire the inactive sessions, defaults to true. If false, all new sessions are created with no expiration date. :DEFAULT: true */ - expireInactiveSessions: ?boolean; + expireInactiveSessions?: boolean; /* When a user changes their password, either through the reset password email or while logged in, all sessions are revoked if this is true. Set to false if you don't want to revoke sessions. :DEFAULT: true */ - revokeSessionOnPasswordReset: ?boolean; + revokeSessionOnPasswordReset?: boolean; /* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) :DEFAULT: 5000 */ - cacheTTL: ?number; + cacheTTL?: number; /* Sets the maximum size for the in memory cache, defaults to 10000 :DEFAULT: 10000 */ - cacheMaxSize: ?number; + cacheMaxSize?: number; /* Set to `true` if Parse requests within the same Node.js environment as Parse Server should be routed to Parse Server directly instead of via the HTTP interface. Default is `false`.

If set to `false` then Parse requests within the same Node.js environment as Parse Server are executed as HTTP requests sent to Parse Server via the `serverURL`. For example, a `Parse.Query` in Cloud Code is calling Parse Server via a HTTP request. The server is essentially making a HTTP request to itself, unnecessarily using network resources such as network ports.

⚠️ In environments where multiple Parse Server instances run behind a load balancer and Parse requests within the current Node.js environment should be routed via the load balancer and distributed as HTTP requests among all instances via the `serverURL`, this should be set to `false`. :DEFAULT: true */ - directAccess: ?boolean; + directAccess?: boolean; /* Enables the default express error handler for all errors :DEFAULT: false */ - enableExpressErrorHandler: ?boolean; + enableExpressErrorHandler?: boolean; /* Sets the number of characters in generated object id's, default 10 :DEFAULT: 10 */ - objectIdSize: ?number; + objectIdSize?: number; /* The port to run the ParseServer, defaults to 1337. :ENV: PORT :DEFAULT: 1337 */ - port: ?number; + port?: number; /* The host to serve ParseServer on, defaults to 0.0.0.0 :DEFAULT: 0.0.0.0 */ - host: ?string; + host?: string; /* Mount path for the server, defaults to /parse :DEFAULT: /parse */ - mountPath: ?string; + mountPath?: string; /* Run with cluster, optionally set the number of processes default to os.cpus().length */ - cluster: ?NumberOrBoolean; + cluster?: NumberOrBoolean; /* middleware for express server, can be string or function */ - middleware: ?((() => void) | string); + middleware?: ((() => void) | string); /* The trust proxy settings. It is important to understand the exact setup of the reverse proxy, since this setting will trust values provided in the Parse Server API request. See the express trust proxy settings documentation. Defaults to `false`. :DEFAULT: false */ - trustProxy: ?any; + trustProxy?: any; /* Starts the liveQuery server */ - startLiveQueryServer: ?boolean; + startLiveQueryServer?: boolean; /* Live query server configuration options (will start the liveQuery server) */ - liveQueryServerOptions: ?LiveQueryServerOptions; + liveQueryServerOptions?: LiveQueryServerOptions; /* Options for request idempotency to deduplicate identical requests that may be caused by network issues. Caution, this is an experimental feature that may not be appropriate for production. :ENV: PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_OPTIONS :DEFAULT: false */ - idempotencyOptions: ?IdempotencyOptions; + idempotencyOptions?: IdempotencyOptions; /* Options for file uploads :ENV: PARSE_SERVER_FILE_UPLOAD_OPTIONS :DEFAULT: {} */ - fileUpload: ?FileUploadOptions; + fileUpload?: FileUploadOptions; /* Full path to your GraphQL custom schema.graphql file */ - graphQLSchema: ?string; + graphQLSchema?: string; /* Mounts the GraphQL endpoint :ENV: PARSE_SERVER_MOUNT_GRAPHQL :DEFAULT: false */ - mountGraphQL: ?boolean; + mountGraphQL?: boolean; /* Mount path for the GraphQL endpoint, defaults to /graphql :ENV: PARSE_SERVER_GRAPHQL_PATH :DEFAULT: /graphql */ - graphQLPath: ?string; + graphQLPath?: string; /* Mounts the GraphQL Playground - never use this option in production :ENV: PARSE_SERVER_MOUNT_PLAYGROUND :DEFAULT: false */ - mountPlayground: ?boolean; + mountPlayground?: boolean; /* Mount path for the GraphQL Playground, defaults to /playground :ENV: PARSE_SERVER_PLAYGROUND_PATH :DEFAULT: /playground */ - playgroundPath: ?string; + playgroundPath?: string; /* Defined schema :ENV: PARSE_SERVER_SCHEMA */ - schema: ?SchemaOptions; + schema?: SchemaOptions; /* Callback when server has closed */ - serverCloseComplete: ?() => void; + serverCloseComplete?: () => void; /* The security options to identify and report weak security settings. :DEFAULT: {} */ - security: ?SecurityOptions; + security?: SecurityOptions; /* Set to true if new users should be created without public read and write access. :DEFAULT: true */ - enforcePrivateUsers: ?boolean; + enforcePrivateUsers?: boolean; /* Allow a user to log in even if the 3rd party authentication token that was used to sign in to their account has expired. If this is set to `false`, then the token will be validated every time the user signs in to their account. This refers to the token that is stored in the `_User.authData` field. Defaults to `false`. :DEFAULT: false */ - allowExpiredAuthDataToken: ?boolean; + allowExpiredAuthDataToken?: boolean; /* An array of keys and values that are prohibited in database read and write requests to prevent potential security vulnerabilities. It is possible to specify only a key (`{"key":"..."}`), only a value (`{"value":"..."}`) or a key-value pair (`{"key":"...","value":"..."}`). The specification can use the following types: `boolean`, `numeric` or `string`, where `string` will be interpreted as a regex notation. Request data is deep-scanned for matching definitions to detect also any nested occurrences. Defaults are patterns that are likely to be used in malicious requests. Setting this option will override the default patterns. :DEFAULT: [{"key":"_bsontype","value":"Code"},{"key":"constructor"},{"key":"__proto__"}] */ - requestKeywordDenylist: ?(RequestKeywordDenylist[]); + requestKeywordDenylist?: (RequestKeywordDenylist[]); /* Options to limit repeated requests to Parse Server APIs. This can be used to protect sensitive endpoints such as `/requestPasswordReset` from brute-force attacks or Parse Server as a whole from denial-of-service (DoS) attacks.

ℹ️ Mind the following limitations:
- rate limits applied per IP address; this limits protection against distributed denial-of-service (DDoS) attacks where many requests are coming from various IP addresses
- if multiple Parse Server instances are behind a load balancer or ran in a cluster, each instance will calculate it's own request rates, independent from other instances; this limits the applicability of this feature when using a load balancer and another rate limiting solution that takes requests across all instances into account may be more suitable
- this feature provides basic protection against denial-of-service attacks, but a more sophisticated solution works earlier in the request flow and prevents a malicious requests to even reach a server instance; it's therefore recommended to implement a solution according to architecture and user case. :DEFAULT: [] */ - rateLimit: ?(RateLimitOptions[]); + rateLimit?: (RateLimitOptions[]); } export interface RateLimitOptions { /* The path of the API route to be rate limited. Route paths, in combination with a request method, define the endpoints at which requests can be made. Route paths can be strings, string patterns, or regular expression. See: https://expressjs.com/en/guide/routing.html */ requestPath: string; /* The window of time in milliseconds within which the number of requests set in `requestCount` can be made before the rate limit is applied. */ - requestTimeWindow: ?number; + requestTimeWindow?: number; /* The number of requests that can be made per IP address within the time window set in `requestTimeWindow` before the rate limit is applied. */ - requestCount: ?number; + requestCount?: number; /* The error message that should be returned in the body of the HTTP 429 response when the rate limit is hit. Default is `Too many requests.`. :DEFAULT: Too many requests. */ - errorResponseMessage: ?string; + errorResponseMessage?: string; /* Optional, the HTTP request methods to which the rate limit should be applied, default is all methods. */ - requestMethods: ?(string[]); + requestMethods?: (string[]); /* Optional, if `true` the rate limit will also apply to requests using the `masterKey`, default is `false`. Note that a public Cloud Code function that triggers internal requests using the `masterKey` may circumvent rate limiting and be vulnerable to attacks. :DEFAULT: false */ - includeMasterKey: ?boolean; + includeMasterKey?: boolean; /* Optional, if `true` the rate limit will also apply to requests that are made in by Cloud Code, default is `false`. Note that a public Cloud Code function that triggers internal requests may circumvent rate limiting and be vulnerable to attacks. :DEFAULT: false */ - includeInternalRequests: ?boolean; + includeInternalRequests?: boolean; /* Optional, the URL of the Redis server to store rate limit data. This allows to rate limit requests for multiple servers by calculating the sum of all requests across all servers. This is useful if multiple servers are processing requests behind a load balancer. For example, the limit of 10 requests is reached if each of 2 servers processed 5 requests. */ - redisUrl: ?string; + redisUrl?: string; /* The type of rate limit to apply. The following types are supported:

@@ -368,50 +368,50 @@ export interface RateLimitOptions {

:default: 'ip' */ - zone: ?string; + zone?: string; } export interface SecurityOptions { /* Is true if Parse Server should check for weak security settings. :DEFAULT: false */ - enableCheck: ?boolean; + enableCheck?: boolean; /* Is true if the security check report should be written to logs. This should only be enabled temporarily to not expose weak security settings in logs. :DEFAULT: false */ - enableCheckLog: ?boolean; + enableCheckLog?: boolean; /* The security check groups to run. This allows to add custom security checks or override existing ones. Default are the groups defined in `CheckGroups.js`. */ - checkGroups: ?(CheckGroup[]); + checkGroups?: (CheckGroup[]); } export interface PagesOptions { /* Is true if the pages router should be enabled; this is required for any of the pages options to take effect. :DEFAULT: false */ - enableRouter: ?boolean; + enableRouter?: boolean; /* Is true if pages should be localized; this has no effect on custom page redirects. :DEFAULT: false */ - enableLocalization: ?boolean; + enableLocalization?: boolean; /* The path to the JSON file for localization; the translations will be used to fill template placeholders according to the locale. */ - localizationJsonPath: ?string; + localizationJsonPath?: string; /* The fallback locale for localization if no matching translation is provided for the given locale. This is only relevant when providing translation resources via JSON file. :DEFAULT: en */ - localizationFallbackLocale: ?string; + localizationFallbackLocale?: string; /* The placeholder keys and values which will be filled in pages; this can be a simple object or a callback function. :DEFAULT: {} */ - placeholders: ?Object; + placeholders?: Object; /* Is true if responses should always be redirects and never content, false if the response type should depend on the request type (GET request -> content response; POST request -> redirect response). :DEFAULT: false */ - forceRedirect: ?boolean; + forceRedirect?: boolean; /* The path to the pages directory; this also defines where the static endpoint '/apps' points to. Default is the './public/' directory. :DEFAULT: ./public */ - pagesPath: ?string; + pagesPath?: string; /* The API endpoint for the pages. Default is 'apps'. :DEFAULT: apps */ - pagesEndpoint: ?string; + pagesEndpoint?: string; /* The URLs to the custom pages. :DEFAULT: {} */ - customUrls: ?PagesCustomUrlsOptions; + customUrls?: PagesCustomUrlsOptions; /* The custom routes. :DEFAULT: [] */ - customRoutes: ?(PagesRoute[]); + customRoutes?: (PagesRoute[]); } export interface PagesRoute { @@ -425,201 +425,201 @@ export interface PagesRoute { export interface PagesCustomUrlsOptions { /* The URL to the custom page for password reset. */ - passwordReset: ?string; + passwordReset?: string; /* The URL to the custom page for password reset -> link invalid. */ - passwordResetLinkInvalid: ?string; + passwordResetLinkInvalid?: string; /* The URL to the custom page for password reset -> success. */ - passwordResetSuccess: ?string; + passwordResetSuccess?: string; /* The URL to the custom page for email verification -> success. */ - emailVerificationSuccess: ?string; + emailVerificationSuccess?: string; /* The URL to the custom page for email verification -> link send fail. */ - emailVerificationSendFail: ?string; + emailVerificationSendFail?: string; /* The URL to the custom page for email verification -> resend link -> success. */ - emailVerificationSendSuccess: ?string; + emailVerificationSendSuccess?: string; /* The URL to the custom page for email verification -> link invalid. */ - emailVerificationLinkInvalid: ?string; + emailVerificationLinkInvalid?: string; /* The URL to the custom page for email verification -> link expired. */ - emailVerificationLinkExpired: ?string; + emailVerificationLinkExpired?: string; } export interface CustomPagesOptions { /* invalid link page path */ - invalidLink: ?string; + invalidLink?: string; /* verification link send fail page path */ - linkSendFail: ?string; + linkSendFail?: string; /* choose password page path */ - choosePassword: ?string; + choosePassword?: string; /* verification link send success page path */ - linkSendSuccess: ?string; + linkSendSuccess?: string; /* verify email success page path */ - verifyEmailSuccess: ?string; + verifyEmailSuccess?: string; /* password reset success page path */ - passwordResetSuccess: ?string; + passwordResetSuccess?: string; /* invalid verification link page path */ - invalidVerificationLink: ?string; + invalidVerificationLink?: string; /* expired verification link page path */ - expiredVerificationLink: ?string; + expiredVerificationLink?: string; /* invalid password reset link page path */ - invalidPasswordResetLink: ?string; + invalidPasswordResetLink?: string; /* for masking user-facing pages */ - parseFrameURL: ?string; + parseFrameURL?: string; } export interface LiveQueryOptions { /* parse-server's LiveQuery classNames :ENV: PARSE_SERVER_LIVEQUERY_CLASSNAMES */ - classNames: ?(string[]); + classNames?: (string[]); /* parse-server's LiveQuery redisOptions */ - redisOptions: ?any; + redisOptions?: any; /* parse-server's LiveQuery redisURL */ - redisURL: ?string; + redisURL?: string; /* LiveQuery pubsub adapter */ - pubSubAdapter: ?Adapter; + pubSubAdapter?: Adapter; /* Adapter module for the WebSocketServer */ - wssAdapter: ?Adapter; + wssAdapter?: Adapter; } export interface LiveQueryServerOptions { /* This string should match the appId in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same appId.*/ - appId: ?string; + appId?: string; /* This string should match the masterKey in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same masterKey.*/ - masterKey: ?string; + masterKey?: string; /* This string should match the serverURL in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same serverURL.*/ - serverURL: ?string; + serverURL?: string; /* A JSON object that serves as a whitelist of keys. It is used for validating clients when they try to connect to the LiveQuery server. Check the following Security section and our protocol specification for details.*/ - keyPairs: ?any; + keyPairs?: any; /* Number of milliseconds between ping/pong frames. The WebSocket server sends ping/pong frames to the clients to keep the WebSocket alive. This value defines the interval of the ping/pong frame from the server to clients, defaults to 10 * 1000 ms (10 s).*/ - websocketTimeout: ?number; + websocketTimeout?: number; /* Number in milliseconds. When clients provide the sessionToken to the LiveQuery server, the LiveQuery server will try to fetch its ParseUser's objectId from parse server and store it in the cache. The value defines the duration of the cache. Check the following Security section and our protocol specification for details, defaults to 5 * 1000 ms (5 seconds).*/ - cacheTimeout: ?number; + cacheTimeout?: number; /* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/ - logLevel: ?string; + logLevel?: string; /* The port to run the LiveQuery server, defaults to 1337. :DEFAULT: 1337 */ - port: ?number; + port?: number; /* parse-server's LiveQuery redisOptions */ - redisOptions: ?any; + redisOptions?: any; /* parse-server's LiveQuery redisURL */ - redisURL: ?string; + redisURL?: string; /* LiveQuery pubsub adapter */ - pubSubAdapter: ?Adapter; + pubSubAdapter?: Adapter; /* Adapter module for the WebSocketServer */ - wssAdapter: ?Adapter; + wssAdapter?: Adapter; } export interface IdempotencyOptions { /* An array of paths for which the feature should be enabled. The mount path must not be included, for example instead of `/parse/functions/myFunction` specifiy `functions/myFunction`. The entries are interpreted as regular expression, for example `functions/.*` matches all functions, `jobs/.*` matches all jobs, `classes/.*` matches all classes, `.*` matches all paths. :DEFAULT: [] */ - paths: ?(string[]); + paths?: (string[]); /* The duration in seconds after which a request record is discarded from the database, defaults to 300s. :DEFAULT: 300 */ - ttl: ?number; + ttl?: number; } export interface AccountLockoutOptions { /* Set the duration in minutes that a locked-out account remains locked out before automatically becoming unlocked.

Valid values are greater than `0` and less than `100000`. */ - duration: ?number; + duration?: number; /* Set the number of failed sign-in attempts that will cause a user account to be locked. If the account is locked. The account will unlock after the duration set in the `duration` option has passed and no further login attempts have been made.

Valid values are greater than `0` and less than `1000`. */ - threshold: ?number; + threshold?: number; /* Set to `true` if the account should be unlocked after a successful password reset.

Default is `false`.
Requires options `duration` and `threshold` to be set. :DEFAULT: false */ - unlockOnPasswordReset: ?boolean; + unlockOnPasswordReset?: boolean; } export interface PasswordPolicyOptions { /* Set the regular expression validation pattern a password must match to be accepted.

If used in combination with `validatorCallback`, the password must pass both to be accepted. */ - validatorPattern: ?string; + validatorPattern?: string; /* */ /* Set a callback function to validate a password to be accepted.

If used in combination with `validatorPattern`, the password must pass both to be accepted. */ - validatorCallback: ?() => void; + validatorCallback?: () => void; /* Set the error message to be sent.

Default is `Password does not meet the Password Policy requirements.` */ - validationError: ?string; + validationError?: string; /* Set to `true` to disallow the username as part of the password.

Default is `false`. :DEFAULT: false */ - doNotAllowUsername: ?boolean; + doNotAllowUsername?: boolean; /* Set the number of days after which a password expires. Login attempts fail if the user does not reset the password before expiration. */ - maxPasswordAge: ?number; + maxPasswordAge?: number; /* Set the number of previous password that will not be allowed to be set as new password. If the option is not set or set to `0`, no previous passwords will be considered.

Valid values are >= `0` and <= `20`.
Default is `0`. */ - maxPasswordHistory: ?number; + maxPasswordHistory?: number; /* Set the validity duration of the password reset token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.

For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours).

Default is `undefined`. */ - resetTokenValidityDuration: ?number; + resetTokenValidityDuration?: number; /* Set to `true` if a password reset token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.

Default is `false`. :DEFAULT: false */ - resetTokenReuseIfValid: ?boolean; + resetTokenReuseIfValid?: boolean; /* Set to `true` if a request to reset the password should return a success response even if the provided email address is invalid, or `false` if the request should return an error response if the email address is invalid.

Default is `true`. :DEFAULT: true */ - resetPasswordSuccessOnInvalidEmail: ?boolean; + resetPasswordSuccessOnInvalidEmail?: boolean; } export interface FileUploadOptions { /* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files. :DEFAULT: ["^(?!(h|H)(t|T)(m|M)(l|L)?$)"] */ - fileExtensions: ?(string[]); + fileExtensions?: (string[]); /* Is true if file upload should be allowed for anonymous users. :DEFAULT: false */ - enableForAnonymousUser: ?boolean; + enableForAnonymousUser?: boolean; /* Is true if file upload should be allowed for authenticated users. :DEFAULT: true */ - enableForAuthenticatedUser: ?boolean; + enableForAuthenticatedUser?: boolean; /* Is true if file upload should be allowed for anyone, regardless of user authentication. :DEFAULT: false */ - enableForPublic: ?boolean; + enableForPublic?: boolean; } export interface DatabaseOptions { /* Enables database real-time hooks to update single schema cache. Set to `true` if using multiple Parse Servers instances connected to the same database. Failing to do so will cause a schema change to not propagate to all instances and re-syncing will only happen when the instances restart. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required. :DEFAULT: false */ - enableSchemaHooks: ?boolean; + enableSchemaHooks?: boolean; /* The duration in seconds after which the schema cache expires and will be refetched from the database. Use this option if using multiple Parse Servers instances connected to the same database. A low duration will cause the schema cache to be updated too often, causing unnecessary database reads. A high duration will cause the schema to be updated too rarely, increasing the time required until schema changes propagate to all server instances. This feature can be used as an alternative or in conjunction with the option `enableSchemaHooks`. Default is infinite which means the schema cache never expires. */ - schemaCacheTtl: ?number; + schemaCacheTtl?: number; /* The MongoDB driver option to set whether to retry failed writes. */ - retryWrites: ?boolean; + retryWrites?: boolean; /* The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor. */ - maxTimeMS: ?number; + maxTimeMS?: number; /* The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.*/ - maxStalenessSeconds: ?number; + maxStalenessSeconds?: number; /* The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. */ - minPoolSize: ?number; + minPoolSize?: number; /* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */ - maxPoolSize: ?number; + maxPoolSize?: number; /* The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout. */ - connectTimeoutMS: ?number; + connectTimeoutMS?: number; /* The MongoDB driver option to specify the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ - socketTimeoutMS: ?number; + socketTimeoutMS?: number; /* The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. */ - autoSelectFamily: ?boolean; + autoSelectFamily?: boolean; /* The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. */ - autoSelectFamilyAttemptTimeout: ?number; + autoSelectFamilyAttemptTimeout?: number; } export interface AuthAdapter { @@ -627,28 +627,28 @@ export interface AuthAdapter { :DEFAULT: false :ENV: */ - enabled: ?boolean; + enabled?: boolean; } export interface LogLevels { /* Log level used by the Cloud Code Triggers `afterSave`, `afterDelete`, `afterFind`, `afterLogout`. Default is `info`. :DEFAULT: info */ - triggerAfter: ?string; + triggerAfter?: string; /* Log level used by the Cloud Code Triggers `beforeSave`, `beforeDelete`, `beforeFind`, `beforeLogin` on success. Default is `info`. :DEFAULT: info */ - triggerBeforeSuccess: ?string; + triggerBeforeSuccess?: string; /* Log level used by the Cloud Code Triggers `beforeSave`, `beforeDelete`, `beforeFind`, `beforeLogin` on error. Default is `error`. :DEFAULT: error */ - triggerBeforeError: ?string; + triggerBeforeError?: string; /* Log level used by the Cloud Code Functions on success. Default is `info`. :DEFAULT: info */ - cloudFunctionSuccess: ?string; + cloudFunctionSuccess?: string; /* Log level used by the Cloud Code Functions on error. Default is `error`. :DEFAULT: error */ - cloudFunctionError: ?string; + cloudFunctionError?: string; } diff --git a/src/ParseServer.ts b/src/ParseServer.ts index a160263db2..a881add922 100644 --- a/src/ParseServer.ts +++ b/src/ParseServer.ts @@ -134,7 +134,7 @@ class ParseServer { Config.validateOptions(options); const allControllers = controllers.getControllers(options); - options.state = 'initialized'; + (options as any).state = 'initialized'; this.config = Config.put(Object.assign({}, options, allControllers)); this.config.masterKeyIpsStore = new Map(); this.config.maintenanceKeyIpsStore = new Map(); @@ -502,7 +502,7 @@ class ParseServer { httpServer, config: LiveQueryServerOptions, options: ParseServerOptions - ): ParseLiveQueryServer { + ): Promise { if (!httpServer || (config && config.port)) { var app = express(); httpServer = require('http').createServer(app); diff --git a/tsconfig.json b/tsconfig.json index 0e37d93dce..22836c54d2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,16 @@ { "compilerOptions": { + "module": "commonjs", + "target": "es2015", "declaration": true, "emitDeclarationOnly": true, "outDir": "types", "noImplicitAny": false, "allowJs": false, - "skipLibCheck": true + "skipLibCheck": true, + "paths": { + "deepcopy": ["./types/@types/deepcopy"], + } }, "include": [ "src/*.ts" diff --git a/types/@types/deepcopy/index.d.ts b/types/@types/deepcopy/index.d.ts new file mode 100644 index 0000000000..e5da2a3238 --- /dev/null +++ b/types/@types/deepcopy/index.d.ts @@ -0,0 +1,5 @@ +// TODO: Remove when https://github.com/sasaplus1/deepcopy.js/issues/278 is fixed +declare type Customizer = (value: any, valueType: string) => unknown; +declare type Options = Customizer | { customizer: Customizer }; +declare function deepcopy(value: T, options?: Options): T; +export default deepcopy; diff --git a/types/LiveQuery/ParseLiveQueryServer.d.ts b/types/LiveQuery/ParseLiveQueryServer.d.ts new file mode 100644 index 0000000000..d5966144b5 --- /dev/null +++ b/types/LiveQuery/ParseLiveQueryServer.d.ts @@ -0,0 +1,40 @@ +import { Auth } from '../Auth'; +declare class ParseLiveQueryServer { + server: any; + config: any; + clients: Map; + subscriptions: Map; + parseWebSocketServer: any; + keyPairs: any; + subscriber: any; + authCache: any; + cacheController: any; + constructor(server: any, config?: any, parseServerConfig?: any); + connect(): Promise; + shutdown(): Promise; + _createSubscribers(): void; + _inflateParseObject(message: any): void; + _onAfterDelete(message: any): Promise; + _onAfterSave(message: any): Promise; + _onConnect(parseWebsocket: any): void; + _matchesSubscription(parseObject: any, subscription: any): boolean; + _clearCachedRoles(userId: string): Promise; + getAuthForSessionToken(sessionToken?: string): Promise<{ + auth?: Auth; + userId?: string; + }>; + _matchesCLP(classLevelPermissions?: any, object?: any, client?: any, requestId?: number, op?: string): Promise; + _filterSensitiveData(classLevelPermissions?: any, res?: any, client?: any, requestId?: number, op?: string, query?: any): Promise; + _getCLPOperation(query: any): "get" | "find"; + _verifyACL(acl: any, token: string): Promise; + getAuthFromClient(client: any, requestId: number, sessionToken?: string): Promise; + _checkWatchFields(client: any, requestId: any, message: any): any; + _matchesACL(acl: any, client: any, requestId: number): Promise; + _handleConnect(parseWebsocket: any, request: any): Promise; + _hasMasterKey(request: any, validKeyPairs: any): boolean; + _validateKeys(request: any, validKeyPairs: any): boolean; + _handleSubscribe(parseWebsocket: any, request: any): Promise; + _handleUpdateSubscription(parseWebsocket: any, request: any): any; + _handleUnsubscribe(parseWebsocket: any, request: any, notifyClient?: boolean): any; +} +export { ParseLiveQueryServer }; diff --git a/types/Options/index.d.ts b/types/Options/index.d.ts new file mode 100644 index 0000000000..75f08a6b71 --- /dev/null +++ b/types/Options/index.d.ts @@ -0,0 +1,250 @@ +import { AnalyticsAdapter } from '../Adapters/Analytics/AnalyticsAdapter'; +import { CacheAdapter } from '../Adapters/Cache/CacheAdapter'; +import { MailAdapter } from '../Adapters/Email/MailAdapter'; +import { FilesAdapter } from '../Adapters/Files/FilesAdapter'; +import { LoggerAdapter } from '../Adapters/Logger/LoggerAdapter'; +import { PubSubAdapter } from '../Adapters/PubSub/PubSubAdapter'; +import { StorageAdapter } from '../Adapters/Storage/StorageAdapter'; +import { WSSAdapter } from '../Adapters/WebSocketServer/WSSAdapter'; +import { CheckGroup } from '../Security/CheckGroup'; +export interface SchemaOptions { + definitions: any; + strict?: boolean; + deleteExtraFields?: boolean; + recreateModifiedFields?: boolean; + lockSchemas?: boolean; + beforeMigration?: () => void | Promise; + afterMigration?: () => void | Promise; +} +type Adapter = string | T; +type NumberOrBoolean = number | boolean; +type NumberOrString = number | string; +type ProtectedFields = any; +type StringOrStringArray = string | string[]; +type RequestKeywordDenylist = { + key: string; + value: any; +}; +export interface ParseServerOptions { + appId: string; + masterKey: (() => void) | string; + masterKeyTtl?: number; + maintenanceKey: string; + serverURL: string; + masterKeyIps?: (string[]); + maintenanceKeyIps?: (string[]); + appName?: string; + allowHeaders?: (string[]); + allowOrigin?: StringOrStringArray; + analyticsAdapter?: Adapter; + filesAdapter?: Adapter; + push?: any; + scheduledPush?: boolean; + loggerAdapter?: Adapter; + jsonLogs?: boolean; + logsFolder?: string; + verbose?: boolean; + logLevel?: string; + logLevels?: LogLevels; + maxLogFiles?: NumberOrString; + silent?: boolean; + databaseURI: string; + databaseOptions?: DatabaseOptions; + databaseAdapter?: Adapter; + enableCollationCaseComparison?: boolean; + convertEmailToLowercase?: boolean; + convertUsernameToLowercase?: boolean; + cloud?: string; + collectionPrefix?: string; + clientKey?: string; + javascriptKey?: string; + dotNetKey?: string; + encryptionKey?: string; + restAPIKey?: string; + readOnlyMasterKey?: string; + webhookKey?: string; + fileKey?: string; + preserveFileName?: boolean; + userSensitiveFields?: (string[]); + protectedFields?: ProtectedFields; + enableAnonymousUsers?: boolean; + allowClientClassCreation?: boolean; + allowCustomObjectId?: boolean; + auth?: Record; + enableInsecureAuthAdapters?: boolean; + maxUploadSize?: string; + verifyUserEmails?: (boolean | void); + preventLoginWithUnverifiedEmail?: boolean; + preventSignupWithUnverifiedEmail?: boolean; + emailVerifyTokenValidityDuration?: number; + emailVerifyTokenReuseIfValid?: boolean; + sendUserEmailVerification?: (boolean | void); + accountLockout?: AccountLockoutOptions; + passwordPolicy?: PasswordPolicyOptions; + cacheAdapter?: Adapter; + emailAdapter?: Adapter; + encodeParseObjectInCloudFunction?: boolean; + publicServerURL?: string; + pages?: PagesOptions; + customPages?: CustomPagesOptions; + liveQuery?: LiveQueryOptions; + sessionLength?: number; + extendSessionOnUse?: boolean; + defaultLimit?: number; + maxLimit?: number; + expireInactiveSessions?: boolean; + revokeSessionOnPasswordReset?: boolean; + cacheTTL?: number; + cacheMaxSize?: number; + directAccess?: boolean; + enableExpressErrorHandler?: boolean; + objectIdSize?: number; + port?: number; + host?: string; + mountPath?: string; + cluster?: NumberOrBoolean; + middleware?: ((() => void) | string); + trustProxy?: any; + startLiveQueryServer?: boolean; + liveQueryServerOptions?: LiveQueryServerOptions; + idempotencyOptions?: IdempotencyOptions; + fileUpload?: FileUploadOptions; + graphQLSchema?: string; + mountGraphQL?: boolean; + graphQLPath?: string; + mountPlayground?: boolean; + playgroundPath?: string; + schema?: SchemaOptions; + serverCloseComplete?: () => void; + security?: SecurityOptions; + enforcePrivateUsers?: boolean; + allowExpiredAuthDataToken?: boolean; + requestKeywordDenylist?: (RequestKeywordDenylist[]); + rateLimit?: (RateLimitOptions[]); +} +export interface RateLimitOptions { + requestPath: string; + requestTimeWindow?: number; + requestCount?: number; + errorResponseMessage?: string; + requestMethods?: (string[]); + includeMasterKey?: boolean; + includeInternalRequests?: boolean; + redisUrl?: string; + zone?: string; +} +export interface SecurityOptions { + enableCheck?: boolean; + enableCheckLog?: boolean; + checkGroups?: (CheckGroup[]); +} +export interface PagesOptions { + enableRouter?: boolean; + enableLocalization?: boolean; + localizationJsonPath?: string; + localizationFallbackLocale?: string; + placeholders?: any; + forceRedirect?: boolean; + pagesPath?: string; + pagesEndpoint?: string; + customUrls?: PagesCustomUrlsOptions; + customRoutes?: (PagesRoute[]); +} +export interface PagesRoute { + path: string; + method: string; + handler: () => void; +} +export interface PagesCustomUrlsOptions { + passwordReset?: string; + passwordResetLinkInvalid?: string; + passwordResetSuccess?: string; + emailVerificationSuccess?: string; + emailVerificationSendFail?: string; + emailVerificationSendSuccess?: string; + emailVerificationLinkInvalid?: string; + emailVerificationLinkExpired?: string; +} +export interface CustomPagesOptions { + invalidLink?: string; + linkSendFail?: string; + choosePassword?: string; + linkSendSuccess?: string; + verifyEmailSuccess?: string; + passwordResetSuccess?: string; + invalidVerificationLink?: string; + expiredVerificationLink?: string; + invalidPasswordResetLink?: string; + parseFrameURL?: string; +} +export interface LiveQueryOptions { + classNames?: (string[]); + redisOptions?: any; + redisURL?: string; + pubSubAdapter?: Adapter; + wssAdapter?: Adapter; +} +export interface LiveQueryServerOptions { + appId?: string; + masterKey?: string; + serverURL?: string; + keyPairs?: any; + websocketTimeout?: number; + cacheTimeout?: number; + logLevel?: string; + port?: number; + redisOptions?: any; + redisURL?: string; + pubSubAdapter?: Adapter; + wssAdapter?: Adapter; +} +export interface IdempotencyOptions { + paths?: (string[]); + ttl?: number; +} +export interface AccountLockoutOptions { + duration?: number; + threshold?: number; + unlockOnPasswordReset?: boolean; +} +export interface PasswordPolicyOptions { + validatorPattern?: string; + validatorCallback?: () => void; + validationError?: string; + doNotAllowUsername?: boolean; + maxPasswordAge?: number; + maxPasswordHistory?: number; + resetTokenValidityDuration?: number; + resetTokenReuseIfValid?: boolean; + resetPasswordSuccessOnInvalidEmail?: boolean; +} +export interface FileUploadOptions { + fileExtensions?: (string[]); + enableForAnonymousUser?: boolean; + enableForAuthenticatedUser?: boolean; + enableForPublic?: boolean; +} +export interface DatabaseOptions { + enableSchemaHooks?: boolean; + schemaCacheTtl?: number; + retryWrites?: boolean; + maxTimeMS?: number; + maxStalenessSeconds?: number; + minPoolSize?: number; + maxPoolSize?: number; + connectTimeoutMS?: number; + socketTimeoutMS?: number; + autoSelectFamily?: boolean; + autoSelectFamilyAttemptTimeout?: number; +} +export interface AuthAdapter { + enabled?: boolean; +} +export interface LogLevels { + triggerAfter?: string; + triggerBeforeSuccess?: string; + triggerBeforeError?: string; + cloudFunctionSuccess?: string; + cloudFunctionError?: string; +} +export {}; diff --git a/types/ParseServer.d.ts b/types/ParseServer.d.ts index 651fad3fab..e504e03114 100644 --- a/types/ParseServer.d.ts +++ b/types/ParseServer.d.ts @@ -54,7 +54,7 @@ declare class ParseServer { * @param {ParseServerOptions} options options for the ParseServer * @returns {Promise} the live query server instance */ - static createLiveQueryServer(httpServer: any, config: LiveQueryServerOptions, options: ParseServerOptions): ParseLiveQueryServer; + static createLiveQueryServer(httpServer: any, config: LiveQueryServerOptions, options: ParseServerOptions): Promise; static verifyServerUrl(): any; } export default ParseServer; diff --git a/types/tests.ts b/types/tests.ts index 9fc0aa2fcb..15593963f8 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -29,7 +29,7 @@ async function server() { ParseServer.promiseRouter(); // $ExpectError - ParseServer.createLiveQueryServer(); + await ParseServer.createLiveQueryServer(); // $ExpectType ParseServer const parseServer2 = new ParseServer({}); From 2da57c94ddbdd2aaad0289214efd21476106b3a6 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 2 Apr 2025 17:11:45 -0500 Subject: [PATCH 3/8] fix options --- src/Options/{index.ts => index.js} | 374 ++++++++++++++--------------- types/Options/index.d.ts | 1 + 2 files changed, 188 insertions(+), 187 deletions(-) rename src/Options/{index.ts => index.js} (86%) diff --git a/src/Options/index.ts b/src/Options/index.js similarity index 86% rename from src/Options/index.ts rename to src/Options/index.js index 92e84b0832..b3c04462ca 100644 --- a/src/Options/index.ts +++ b/src/Options/index.js @@ -15,20 +15,20 @@ export interface SchemaOptions { definitions: any; /* Is true if Parse Server should exit if schema update fail. :DEFAULT: false */ - strict?: boolean; + strict: ?boolean; /* Is true if Parse Server should delete any fields not defined in a schema definition. This should only be used during development. :DEFAULT: false */ - deleteExtraFields?: boolean; + deleteExtraFields: ?boolean; /* Is true if Parse Server should recreate any fields that are different between the current database schema and theschema definition. This should only be used during development. :DEFAULT: false */ - recreateModifiedFields?: boolean; + recreateModifiedFields: ?boolean; /* Is true if Parse Server will reject any attempts to modify the schema while the server is running. :DEFAULT: false */ - lockSchemas?: boolean; + lockSchemas: ?boolean; /* Execute a callback before running schema migrations. */ - beforeMigration?: () => void | Promise; + beforeMigration: ?() => void | Promise; /* Execute a callback after running schema migrations. */ - afterMigration?: () => void | Promise; + afterMigration: ?() => void | Promise; } type Adapter = string | any | T; @@ -48,7 +48,7 @@ export interface ParseServerOptions { /* Your Parse Master Key */ masterKey: (() => void) | string; /* (Optional) The duration in seconds for which the current `masterKey` is being used before it is requested again if `masterKey` is set to a function. If `masterKey` is not set to a function, this option has no effect. Default is `0`, which means the master key is requested by invoking the `masterKey` function every time the master key is used internally by Parse Server. */ - masterKeyTtl?: number; + masterKeyTtl: ?number; /* (Optional) The maintenance key is used for modifying internal and read-only fields of Parse Server.

⚠️ This key is not intended to be used as part of a regular operation of Parse Server. This key is intended to conduct out-of-band changes such as one-time migrations or data correction tasks. Internal fields are not officially documented and may change at any time without publication in release changelogs. We strongly advice not to rely on internal fields as part of your regular operation and to investigate the implications of any planned changes *directly in the source code* of your current version of Parse Server. */ maintenanceKey: string; /* URL to your parse server with http:// or https://. @@ -56,137 +56,137 @@ export interface ParseServerOptions { serverURL: string; /* (Optional) Restricts the use of master key permissions to a list of IP addresses or ranges.

This option accepts a list of single IP addresses, for example `['10.0.0.1', '10.0.0.2']`. You can also use CIDR notation to specify an IP address range, for example `['10.0.1.0/24']`.

Special scenarios:
- Setting an empty array `[]` means that the master key cannot be used even in Parse Server Cloud Code. This value cannot be set via an environment variable as there is no way to pass an empty array to Parse Server via an environment variable.
- Setting `['0.0.0.0/0', '::0']` means to allow any IPv4 and IPv6 address to use the master key and effectively disables the IP filter.

Considerations:
- IPv4 and IPv6 addresses are not compared against each other. Each IP version (IPv4 and IPv6) needs to be considered separately. For example, `['0.0.0.0/0']` allows any IPv4 address and blocks every IPv6 address. Conversely, `['::0']` allows any IPv6 address and blocks every IPv4 address.
- Keep in mind that the IP version in use depends on the network stack of the environment in which Parse Server runs. A local environment may use a different IP version than a remote environment. For example, it's possible that locally the value `['0.0.0.0/0']` allows the request IP because the environment is using IPv4, but when Parse Server is deployed remotely the request IP is blocked because the remote environment is using IPv6.
- When setting the option via an environment variable the notation is a comma-separated string, for example `"0.0.0.0/0,::0"`.
- IPv6 zone indices (`%` suffix) are not supported, for example `fe80::1%eth0`, `fe80::1%1` or `::1%lo`.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server instance on which Parse Server runs, is allowed to use the master key. :DEFAULT: ["127.0.0.1","::1"] */ - masterKeyIps?: (string[]); + masterKeyIps: ?(string[]); /* (Optional) Restricts the use of maintenance key permissions to a list of IP addresses or ranges.

This option accepts a list of single IP addresses, for example `['10.0.0.1', '10.0.0.2']`. You can also use CIDR notation to specify an IP address range, for example `['10.0.1.0/24']`.

Special scenarios:
- Setting an empty array `[]` means that the maintenance key cannot be used even in Parse Server Cloud Code. This value cannot be set via an environment variable as there is no way to pass an empty array to Parse Server via an environment variable.
- Setting `['0.0.0.0/0', '::0']` means to allow any IPv4 and IPv6 address to use the maintenance key and effectively disables the IP filter.

Considerations:
- IPv4 and IPv6 addresses are not compared against each other. Each IP version (IPv4 and IPv6) needs to be considered separately. For example, `['0.0.0.0/0']` allows any IPv4 address and blocks every IPv6 address. Conversely, `['::0']` allows any IPv6 address and blocks every IPv4 address.
- Keep in mind that the IP version in use depends on the network stack of the environment in which Parse Server runs. A local environment may use a different IP version than a remote environment. For example, it's possible that locally the value `['0.0.0.0/0']` allows the request IP because the environment is using IPv4, but when Parse Server is deployed remotely the request IP is blocked because the remote environment is using IPv6.
- When setting the option via an environment variable the notation is a comma-separated string, for example `"0.0.0.0/0,::0"`.
- IPv6 zone indices (`%` suffix) are not supported, for example `fe80::1%eth0`, `fe80::1%1` or `::1%lo`.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server instance on which Parse Server runs, is allowed to use the maintenance key. :DEFAULT: ["127.0.0.1","::1"] */ - maintenanceKeyIps?: (string[]); + maintenanceKeyIps: ?(string[]); /* Sets the app name */ - appName?: string; + appName: ?string; /* Add headers to Access-Control-Allow-Headers */ - allowHeaders?: (string[]); + allowHeaders: ?(string[]); /* Sets origins for Access-Control-Allow-Origin. This can be a string for a single origin or an array of strings for multiple origins. */ - allowOrigin?: StringOrStringArray; + allowOrigin: ?StringOrStringArray; /* Adapter module for the analytics */ - analyticsAdapter?: Adapter; + analyticsAdapter: ?Adapter; /* Adapter module for the files sub-system */ - filesAdapter?: Adapter; + filesAdapter: ?Adapter; /* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */ - push?: any; + push: ?any; /* Configuration for push scheduling, defaults to false. :DEFAULT: false */ - scheduledPush?: boolean; + scheduledPush: ?boolean; /* Adapter module for the logging sub-system */ - loggerAdapter?: Adapter; + loggerAdapter: ?Adapter; /* Log as structured JSON objects :ENV: JSON_LOGS */ - jsonLogs?: boolean; + jsonLogs: ?boolean; /* Folder for the logs (defaults to './logs'); set to null to disable file based logging :ENV: PARSE_SERVER_LOGS_FOLDER :DEFAULT: ./logs */ - logsFolder?: string; + logsFolder: ?string; /* Set the logging to verbose :ENV: VERBOSE */ - verbose?: boolean; + verbose: ?boolean; /* Sets the level for logs */ - logLevel?: string; + logLevel: ?string; /* (Optional) Overrides the log levels used internally by Parse Server to log events. :DEFAULT: {} */ - logLevels?: LogLevels; + logLevels: ?LogLevels; /* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null) */ - maxLogFiles?: NumberOrString; + maxLogFiles: ?NumberOrString; /* Disables console output :ENV: SILENT */ - silent?: boolean; + silent: ?boolean; /* The full URI to your database. Supported databases are mongodb or postgres. :DEFAULT: mongodb://localhost:27017/parse */ databaseURI: string; /* Options to pass to the database client :ENV: PARSE_SERVER_DATABASE_OPTIONS */ - databaseOptions?: DatabaseOptions; + databaseOptions: ?DatabaseOptions; /* Adapter module for the database; any options that are not explicitly described here are passed directly to the database client. */ - databaseAdapter?: Adapter; + databaseAdapter: ?Adapter; /* Optional. If set to `true`, the collation rule of case comparison for queries and indexes is enabled. Enable this option to run Parse Server with MongoDB Atlas Serverless or AWS Amazon DocumentDB. If `false`, the collation rule of case comparison is disabled. Default is `false`. :DEFAULT: false */ - enableCollationCaseComparison?: boolean; + enableCollationCaseComparison: ?boolean; /* Optional. If set to `true`, the `email` property of a user is automatically converted to lowercase before being stored in the database. Consequently, queries must match the case as stored in the database, which would be lowercase in this scenario. If `false`, the `email` property is stored as set, without any case modifications. Default is `false`. :DEFAULT: false */ - convertEmailToLowercase?: boolean; + convertEmailToLowercase: ?boolean; /* Optional. If set to `true`, the `username` property of a user is automatically converted to lowercase before being stored in the database. Consequently, queries must match the case as stored in the database, which would be lowercase in this scenario. If `false`, the `username` property is stored as set, without any case modifications. Default is `false`. :DEFAULT: false */ - convertUsernameToLowercase?: boolean; + convertUsernameToLowercase: ?boolean; /* Full path to your cloud code main.js */ - cloud?: string; + cloud: ?string; /* A collection prefix for the classes :DEFAULT: '' */ - collectionPrefix?: string; + collectionPrefix: ?string; /* Key for iOS, MacOS, tvOS clients */ - clientKey?: string; + clientKey: ?string; /* Key for the Javascript SDK */ - javascriptKey?: string; + javascriptKey: ?string; /* Key for Unity and .Net SDK */ - dotNetKey?: string; + dotNetKey: ?string; /* Key for encrypting your files :ENV: PARSE_SERVER_ENCRYPTION_KEY */ - encryptionKey?: string; + encryptionKey: ?string; /* Key for REST calls :ENV: PARSE_SERVER_REST_API_KEY */ - restAPIKey?: string; + restAPIKey: ?string; /* Read-only key, which has the same capabilities as MasterKey without writes */ - readOnlyMasterKey?: string; + readOnlyMasterKey: ?string; /* Key sent with outgoing webhook calls */ - webhookKey?: string; + webhookKey: ?string; /* Key for your files */ - fileKey?: string; + fileKey: ?string; /* Enable (or disable) the addition of a unique hash to the file names :ENV: PARSE_SERVER_PRESERVE_FILE_NAME :DEFAULT: false */ - preserveFileName?: boolean; + preserveFileName: ?boolean; /* Personally identifiable information fields in the user table the should be removed for non-authorized users. Deprecated @see protectedFields */ - userSensitiveFields?: (string[]); + userSensitiveFields: ?(string[]); /* Protected fields that should be treated with extra security when fetching details. :DEFAULT: {"_User": {"*": ["email"]}} */ - protectedFields?: ProtectedFields; + protectedFields: ?ProtectedFields; /* Enable (or disable) anonymous users, defaults to true :ENV: PARSE_SERVER_ENABLE_ANON_USERS :DEFAULT: true */ - enableAnonymousUsers?: boolean; + enableAnonymousUsers: ?boolean; /* Enable (or disable) client class creation, defaults to false :ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION :DEFAULT: false */ - allowClientClassCreation?: boolean; + allowClientClassCreation: ?boolean; /* Enable (or disable) custom objectId :ENV: PARSE_SERVER_ALLOW_CUSTOM_OBJECT_ID :DEFAULT: false */ - allowCustomObjectId?: boolean; + allowCustomObjectId: ?boolean; /* Configuration for your authentication providers, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication :ENV: PARSE_SERVER_AUTH_PROVIDERS */ - auth?: Record; + auth: ?{ [string]: AuthAdapter }; /* Enable (or disable) insecure auth adapters, defaults to true. Insecure auth adapters are deprecated and it is recommended to disable them. :ENV: PARSE_SERVER_ENABLE_INSECURE_AUTH_ADAPTERS :DEFAULT: true */ - enableInsecureAuthAdapters?: boolean; + enableInsecureAuthAdapters: ?boolean; /* Max file size for uploads, defaults to 20mb :DEFAULT: 20mb */ - maxUploadSize?: string; + maxUploadSize: ?string; /* Set to `true` to require users to verify their email address to complete the sign-up process. Supports a function with a return value of `true` or `false` for conditional verification.

Default is `false`. :DEFAULT: false */ - verifyUserEmails?: (boolean | void); + verifyUserEmails: ?(boolean | void); /* Set to `true` to prevent a user from logging in if the email has not yet been verified and email verification is required.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - preventLoginWithUnverifiedEmail?: boolean; + preventLoginWithUnverifiedEmail: ?boolean; /* If set to `true` it prevents a user from signing up if the email has not yet been verified and email verification is required. In that case the server responds to the sign-up with HTTP status 400 and a Parse Error 205 `EMAIL_NOT_FOUND`. If set to `false` the server responds with HTTP status 200, and client SDKs return an unauthenticated Parse User without session token. In that case subsequent requests fail until the user's email address is verified.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - preventSignupWithUnverifiedEmail?: boolean; + preventSignupWithUnverifiedEmail: ?boolean; /* Set the validity duration of the email verification token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.

For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours). @@ -195,169 +195,169 @@ export interface ParseServerOptions {
Requires option `verifyUserEmails: true`. */ - emailVerifyTokenValidityDuration?: number; + emailVerifyTokenValidityDuration: ?number; /* Set to `true` if a email verification token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.

Default is `false`.
Requires option `verifyUserEmails: true`. :DEFAULT: false */ - emailVerifyTokenReuseIfValid?: boolean; + emailVerifyTokenReuseIfValid: ?boolean; /* Set to `false` to prevent sending of verification email. Supports a function with a return value of `true` or `false` for conditional email sending.

Default is `true`.
:DEFAULT: true */ - sendUserEmailVerification?: (boolean | void); + sendUserEmailVerification: ?(boolean | void); /* The account lockout policy for failed login attempts. */ - accountLockout?: AccountLockoutOptions; + accountLockout: ?AccountLockoutOptions; /* The password policy for enforcing password related rules. */ - passwordPolicy?: PasswordPolicyOptions; + passwordPolicy: ?PasswordPolicyOptions; /* Adapter module for the cache */ - cacheAdapter?: Adapter; + cacheAdapter: ?Adapter; /* Adapter module for email sending */ - emailAdapter?: Adapter; + emailAdapter: ?Adapter; /* If set to `true`, a `Parse.Object` that is in the payload when calling a Cloud Function will be converted to an instance of `Parse.Object`. If `false`, the object will not be converted and instead be a plain JavaScript object, which contains the raw data of a `Parse.Object` but is not an actual instance of `Parse.Object`. Default is `false`.

ℹ️ The expected behavior would be that the object is converted to an instance of `Parse.Object`, so you would normally set this option to `true`. The default is `false` because this is a temporary option that has been introduced to avoid a breaking change when fixing a bug where JavaScript objects are not converted to actual instances of `Parse.Object`. :DEFAULT: true */ - encodeParseObjectInCloudFunction?: boolean; + encodeParseObjectInCloudFunction: ?boolean; /* Public URL to your parse server with http:// or https://. :ENV: PARSE_PUBLIC_SERVER_URL */ - publicServerURL?: string; + publicServerURL: ?string; /* The options for pages such as password reset and email verification. :DEFAULT: {} */ - pages?: PagesOptions; + pages: ?PagesOptions; /* custom pages for password validation and reset :DEFAULT: {} */ - customPages?: CustomPagesOptions; + customPages: ?CustomPagesOptions; /* parse-server's LiveQuery configuration object */ - liveQuery?: LiveQueryOptions; + liveQuery: ?LiveQueryOptions; /* Session duration, in seconds, defaults to 1 year :DEFAULT: 31536000 */ - sessionLength?: number; + sessionLength: ?number; /* Whether Parse Server should automatically extend a valid session by the sessionLength. In order to reduce the number of session updates in the database, a session will only be extended when a request is received after at least half of the current session's lifetime has passed. :DEFAULT: false */ - extendSessionOnUse?: boolean; + extendSessionOnUse: ?boolean; /* Default value for limit option on queries, defaults to `100`. :DEFAULT: 100 */ - defaultLimit?: number; + defaultLimit: ?number; /* Max value for limit option on queries, defaults to unlimited */ - maxLimit?: number; + maxLimit: ?number; /* Sets whether we should expire the inactive sessions, defaults to true. If false, all new sessions are created with no expiration date. :DEFAULT: true */ - expireInactiveSessions?: boolean; + expireInactiveSessions: ?boolean; /* When a user changes their password, either through the reset password email or while logged in, all sessions are revoked if this is true. Set to false if you don't want to revoke sessions. :DEFAULT: true */ - revokeSessionOnPasswordReset?: boolean; + revokeSessionOnPasswordReset: ?boolean; /* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) :DEFAULT: 5000 */ - cacheTTL?: number; + cacheTTL: ?number; /* Sets the maximum size for the in memory cache, defaults to 10000 :DEFAULT: 10000 */ - cacheMaxSize?: number; + cacheMaxSize: ?number; /* Set to `true` if Parse requests within the same Node.js environment as Parse Server should be routed to Parse Server directly instead of via the HTTP interface. Default is `false`.

If set to `false` then Parse requests within the same Node.js environment as Parse Server are executed as HTTP requests sent to Parse Server via the `serverURL`. For example, a `Parse.Query` in Cloud Code is calling Parse Server via a HTTP request. The server is essentially making a HTTP request to itself, unnecessarily using network resources such as network ports.

⚠️ In environments where multiple Parse Server instances run behind a load balancer and Parse requests within the current Node.js environment should be routed via the load balancer and distributed as HTTP requests among all instances via the `serverURL`, this should be set to `false`. :DEFAULT: true */ - directAccess?: boolean; + directAccess: ?boolean; /* Enables the default express error handler for all errors :DEFAULT: false */ - enableExpressErrorHandler?: boolean; + enableExpressErrorHandler: ?boolean; /* Sets the number of characters in generated object id's, default 10 :DEFAULT: 10 */ - objectIdSize?: number; + objectIdSize: ?number; /* The port to run the ParseServer, defaults to 1337. :ENV: PORT :DEFAULT: 1337 */ - port?: number; + port: ?number; /* The host to serve ParseServer on, defaults to 0.0.0.0 :DEFAULT: 0.0.0.0 */ - host?: string; + host: ?string; /* Mount path for the server, defaults to /parse :DEFAULT: /parse */ - mountPath?: string; + mountPath: ?string; /* Run with cluster, optionally set the number of processes default to os.cpus().length */ - cluster?: NumberOrBoolean; + cluster: ?NumberOrBoolean; /* middleware for express server, can be string or function */ - middleware?: ((() => void) | string); + middleware: ?((() => void) | string); /* The trust proxy settings. It is important to understand the exact setup of the reverse proxy, since this setting will trust values provided in the Parse Server API request. See the express trust proxy settings documentation. Defaults to `false`. :DEFAULT: false */ - trustProxy?: any; + trustProxy: ?any; /* Starts the liveQuery server */ - startLiveQueryServer?: boolean; + startLiveQueryServer: ?boolean; /* Live query server configuration options (will start the liveQuery server) */ - liveQueryServerOptions?: LiveQueryServerOptions; + liveQueryServerOptions: ?LiveQueryServerOptions; /* Options for request idempotency to deduplicate identical requests that may be caused by network issues. Caution, this is an experimental feature that may not be appropriate for production. :ENV: PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_OPTIONS :DEFAULT: false */ - idempotencyOptions?: IdempotencyOptions; + idempotencyOptions: ?IdempotencyOptions; /* Options for file uploads :ENV: PARSE_SERVER_FILE_UPLOAD_OPTIONS :DEFAULT: {} */ - fileUpload?: FileUploadOptions; + fileUpload: ?FileUploadOptions; /* Full path to your GraphQL custom schema.graphql file */ - graphQLSchema?: string; + graphQLSchema: ?string; /* Mounts the GraphQL endpoint :ENV: PARSE_SERVER_MOUNT_GRAPHQL :DEFAULT: false */ - mountGraphQL?: boolean; + mountGraphQL: ?boolean; /* Mount path for the GraphQL endpoint, defaults to /graphql :ENV: PARSE_SERVER_GRAPHQL_PATH :DEFAULT: /graphql */ - graphQLPath?: string; + graphQLPath: ?string; /* Mounts the GraphQL Playground - never use this option in production :ENV: PARSE_SERVER_MOUNT_PLAYGROUND :DEFAULT: false */ - mountPlayground?: boolean; + mountPlayground: ?boolean; /* Mount path for the GraphQL Playground, defaults to /playground :ENV: PARSE_SERVER_PLAYGROUND_PATH :DEFAULT: /playground */ - playgroundPath?: string; + playgroundPath: ?string; /* Defined schema :ENV: PARSE_SERVER_SCHEMA */ - schema?: SchemaOptions; + schema: ?SchemaOptions; /* Callback when server has closed */ - serverCloseComplete?: () => void; + serverCloseComplete: ?() => void; /* The security options to identify and report weak security settings. :DEFAULT: {} */ - security?: SecurityOptions; + security: ?SecurityOptions; /* Set to true if new users should be created without public read and write access. :DEFAULT: true */ - enforcePrivateUsers?: boolean; + enforcePrivateUsers: ?boolean; /* Allow a user to log in even if the 3rd party authentication token that was used to sign in to their account has expired. If this is set to `false`, then the token will be validated every time the user signs in to their account. This refers to the token that is stored in the `_User.authData` field. Defaults to `false`. :DEFAULT: false */ - allowExpiredAuthDataToken?: boolean; + allowExpiredAuthDataToken: ?boolean; /* An array of keys and values that are prohibited in database read and write requests to prevent potential security vulnerabilities. It is possible to specify only a key (`{"key":"..."}`), only a value (`{"value":"..."}`) or a key-value pair (`{"key":"...","value":"..."}`). The specification can use the following types: `boolean`, `numeric` or `string`, where `string` will be interpreted as a regex notation. Request data is deep-scanned for matching definitions to detect also any nested occurrences. Defaults are patterns that are likely to be used in malicious requests. Setting this option will override the default patterns. :DEFAULT: [{"key":"_bsontype","value":"Code"},{"key":"constructor"},{"key":"__proto__"}] */ - requestKeywordDenylist?: (RequestKeywordDenylist[]); + requestKeywordDenylist: ?(RequestKeywordDenylist[]); /* Options to limit repeated requests to Parse Server APIs. This can be used to protect sensitive endpoints such as `/requestPasswordReset` from brute-force attacks or Parse Server as a whole from denial-of-service (DoS) attacks.

ℹ️ Mind the following limitations:
- rate limits applied per IP address; this limits protection against distributed denial-of-service (DDoS) attacks where many requests are coming from various IP addresses
- if multiple Parse Server instances are behind a load balancer or ran in a cluster, each instance will calculate it's own request rates, independent from other instances; this limits the applicability of this feature when using a load balancer and another rate limiting solution that takes requests across all instances into account may be more suitable
- this feature provides basic protection against denial-of-service attacks, but a more sophisticated solution works earlier in the request flow and prevents a malicious requests to even reach a server instance; it's therefore recommended to implement a solution according to architecture and user case. :DEFAULT: [] */ - rateLimit?: (RateLimitOptions[]); + rateLimit: ?(RateLimitOptions[]); } export interface RateLimitOptions { /* The path of the API route to be rate limited. Route paths, in combination with a request method, define the endpoints at which requests can be made. Route paths can be strings, string patterns, or regular expression. See: https://expressjs.com/en/guide/routing.html */ requestPath: string; /* The window of time in milliseconds within which the number of requests set in `requestCount` can be made before the rate limit is applied. */ - requestTimeWindow?: number; + requestTimeWindow: ?number; /* The number of requests that can be made per IP address within the time window set in `requestTimeWindow` before the rate limit is applied. */ - requestCount?: number; + requestCount: ?number; /* The error message that should be returned in the body of the HTTP 429 response when the rate limit is hit. Default is `Too many requests.`. :DEFAULT: Too many requests. */ - errorResponseMessage?: string; + errorResponseMessage: ?string; /* Optional, the HTTP request methods to which the rate limit should be applied, default is all methods. */ - requestMethods?: (string[]); + requestMethods: ?(string[]); /* Optional, if `true` the rate limit will also apply to requests using the `masterKey`, default is `false`. Note that a public Cloud Code function that triggers internal requests using the `masterKey` may circumvent rate limiting and be vulnerable to attacks. :DEFAULT: false */ - includeMasterKey?: boolean; + includeMasterKey: ?boolean; /* Optional, if `true` the rate limit will also apply to requests that are made in by Cloud Code, default is `false`. Note that a public Cloud Code function that triggers internal requests may circumvent rate limiting and be vulnerable to attacks. :DEFAULT: false */ - includeInternalRequests?: boolean; + includeInternalRequests: ?boolean; /* Optional, the URL of the Redis server to store rate limit data. This allows to rate limit requests for multiple servers by calculating the sum of all requests across all servers. This is useful if multiple servers are processing requests behind a load balancer. For example, the limit of 10 requests is reached if each of 2 servers processed 5 requests. */ - redisUrl?: string; + redisUrl: ?string; /* The type of rate limit to apply. The following types are supported:

@@ -368,50 +368,50 @@ export interface RateLimitOptions {

:default: 'ip' */ - zone?: string; + zone: ?string; } export interface SecurityOptions { /* Is true if Parse Server should check for weak security settings. :DEFAULT: false */ - enableCheck?: boolean; + enableCheck: ?boolean; /* Is true if the security check report should be written to logs. This should only be enabled temporarily to not expose weak security settings in logs. :DEFAULT: false */ - enableCheckLog?: boolean; + enableCheckLog: ?boolean; /* The security check groups to run. This allows to add custom security checks or override existing ones. Default are the groups defined in `CheckGroups.js`. */ - checkGroups?: (CheckGroup[]); + checkGroups: ?(CheckGroup[]); } export interface PagesOptions { /* Is true if the pages router should be enabled; this is required for any of the pages options to take effect. :DEFAULT: false */ - enableRouter?: boolean; + enableRouter: ?boolean; /* Is true if pages should be localized; this has no effect on custom page redirects. :DEFAULT: false */ - enableLocalization?: boolean; + enableLocalization: ?boolean; /* The path to the JSON file for localization; the translations will be used to fill template placeholders according to the locale. */ - localizationJsonPath?: string; + localizationJsonPath: ?string; /* The fallback locale for localization if no matching translation is provided for the given locale. This is only relevant when providing translation resources via JSON file. :DEFAULT: en */ - localizationFallbackLocale?: string; + localizationFallbackLocale: ?string; /* The placeholder keys and values which will be filled in pages; this can be a simple object or a callback function. :DEFAULT: {} */ - placeholders?: Object; + placeholders: ?Object; /* Is true if responses should always be redirects and never content, false if the response type should depend on the request type (GET request -> content response; POST request -> redirect response). :DEFAULT: false */ - forceRedirect?: boolean; + forceRedirect: ?boolean; /* The path to the pages directory; this also defines where the static endpoint '/apps' points to. Default is the './public/' directory. :DEFAULT: ./public */ - pagesPath?: string; + pagesPath: ?string; /* The API endpoint for the pages. Default is 'apps'. :DEFAULT: apps */ - pagesEndpoint?: string; + pagesEndpoint: ?string; /* The URLs to the custom pages. :DEFAULT: {} */ - customUrls?: PagesCustomUrlsOptions; + customUrls: ?PagesCustomUrlsOptions; /* The custom routes. :DEFAULT: [] */ - customRoutes?: (PagesRoute[]); + customRoutes: ?(PagesRoute[]); } export interface PagesRoute { @@ -425,201 +425,201 @@ export interface PagesRoute { export interface PagesCustomUrlsOptions { /* The URL to the custom page for password reset. */ - passwordReset?: string; + passwordReset: ?string; /* The URL to the custom page for password reset -> link invalid. */ - passwordResetLinkInvalid?: string; + passwordResetLinkInvalid: ?string; /* The URL to the custom page for password reset -> success. */ - passwordResetSuccess?: string; + passwordResetSuccess: ?string; /* The URL to the custom page for email verification -> success. */ - emailVerificationSuccess?: string; + emailVerificationSuccess: ?string; /* The URL to the custom page for email verification -> link send fail. */ - emailVerificationSendFail?: string; + emailVerificationSendFail: ?string; /* The URL to the custom page for email verification -> resend link -> success. */ - emailVerificationSendSuccess?: string; + emailVerificationSendSuccess: ?string; /* The URL to the custom page for email verification -> link invalid. */ - emailVerificationLinkInvalid?: string; + emailVerificationLinkInvalid: ?string; /* The URL to the custom page for email verification -> link expired. */ - emailVerificationLinkExpired?: string; + emailVerificationLinkExpired: ?string; } export interface CustomPagesOptions { /* invalid link page path */ - invalidLink?: string; + invalidLink: ?string; /* verification link send fail page path */ - linkSendFail?: string; + linkSendFail: ?string; /* choose password page path */ - choosePassword?: string; + choosePassword: ?string; /* verification link send success page path */ - linkSendSuccess?: string; + linkSendSuccess: ?string; /* verify email success page path */ - verifyEmailSuccess?: string; + verifyEmailSuccess: ?string; /* password reset success page path */ - passwordResetSuccess?: string; + passwordResetSuccess: ?string; /* invalid verification link page path */ - invalidVerificationLink?: string; + invalidVerificationLink: ?string; /* expired verification link page path */ - expiredVerificationLink?: string; + expiredVerificationLink: ?string; /* invalid password reset link page path */ - invalidPasswordResetLink?: string; + invalidPasswordResetLink: ?string; /* for masking user-facing pages */ - parseFrameURL?: string; + parseFrameURL: ?string; } export interface LiveQueryOptions { /* parse-server's LiveQuery classNames :ENV: PARSE_SERVER_LIVEQUERY_CLASSNAMES */ - classNames?: (string[]); + classNames: ?(string[]); /* parse-server's LiveQuery redisOptions */ - redisOptions?: any; + redisOptions: ?any; /* parse-server's LiveQuery redisURL */ - redisURL?: string; + redisURL: ?string; /* LiveQuery pubsub adapter */ - pubSubAdapter?: Adapter; + pubSubAdapter: ?Adapter; /* Adapter module for the WebSocketServer */ - wssAdapter?: Adapter; + wssAdapter: ?Adapter; } export interface LiveQueryServerOptions { /* This string should match the appId in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same appId.*/ - appId?: string; + appId: ?string; /* This string should match the masterKey in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same masterKey.*/ - masterKey?: string; + masterKey: ?string; /* This string should match the serverURL in use by your Parse Server. If you deploy the LiveQuery server alongside Parse Server, the LiveQuery server will try to use the same serverURL.*/ - serverURL?: string; + serverURL: ?string; /* A JSON object that serves as a whitelist of keys. It is used for validating clients when they try to connect to the LiveQuery server. Check the following Security section and our protocol specification for details.*/ - keyPairs?: any; + keyPairs: ?any; /* Number of milliseconds between ping/pong frames. The WebSocket server sends ping/pong frames to the clients to keep the WebSocket alive. This value defines the interval of the ping/pong frame from the server to clients, defaults to 10 * 1000 ms (10 s).*/ - websocketTimeout?: number; + websocketTimeout: ?number; /* Number in milliseconds. When clients provide the sessionToken to the LiveQuery server, the LiveQuery server will try to fetch its ParseUser's objectId from parse server and store it in the cache. The value defines the duration of the cache. Check the following Security section and our protocol specification for details, defaults to 5 * 1000 ms (5 seconds).*/ - cacheTimeout?: number; + cacheTimeout: ?number; /* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/ - logLevel?: string; + logLevel: ?string; /* The port to run the LiveQuery server, defaults to 1337. :DEFAULT: 1337 */ - port?: number; + port: ?number; /* parse-server's LiveQuery redisOptions */ - redisOptions?: any; + redisOptions: ?any; /* parse-server's LiveQuery redisURL */ - redisURL?: string; + redisURL: ?string; /* LiveQuery pubsub adapter */ - pubSubAdapter?: Adapter; + pubSubAdapter: ?Adapter; /* Adapter module for the WebSocketServer */ - wssAdapter?: Adapter; + wssAdapter: ?Adapter; } export interface IdempotencyOptions { /* An array of paths for which the feature should be enabled. The mount path must not be included, for example instead of `/parse/functions/myFunction` specifiy `functions/myFunction`. The entries are interpreted as regular expression, for example `functions/.*` matches all functions, `jobs/.*` matches all jobs, `classes/.*` matches all classes, `.*` matches all paths. :DEFAULT: [] */ - paths?: (string[]); + paths: ?(string[]); /* The duration in seconds after which a request record is discarded from the database, defaults to 300s. :DEFAULT: 300 */ - ttl?: number; + ttl: ?number; } export interface AccountLockoutOptions { /* Set the duration in minutes that a locked-out account remains locked out before automatically becoming unlocked.

Valid values are greater than `0` and less than `100000`. */ - duration?: number; + duration: ?number; /* Set the number of failed sign-in attempts that will cause a user account to be locked. If the account is locked. The account will unlock after the duration set in the `duration` option has passed and no further login attempts have been made.

Valid values are greater than `0` and less than `1000`. */ - threshold?: number; + threshold: ?number; /* Set to `true` if the account should be unlocked after a successful password reset.

Default is `false`.
Requires options `duration` and `threshold` to be set. :DEFAULT: false */ - unlockOnPasswordReset?: boolean; + unlockOnPasswordReset: ?boolean; } export interface PasswordPolicyOptions { /* Set the regular expression validation pattern a password must match to be accepted.

If used in combination with `validatorCallback`, the password must pass both to be accepted. */ - validatorPattern?: string; + validatorPattern: ?string; /* */ /* Set a callback function to validate a password to be accepted.

If used in combination with `validatorPattern`, the password must pass both to be accepted. */ - validatorCallback?: () => void; + validatorCallback: ?() => void; /* Set the error message to be sent.

Default is `Password does not meet the Password Policy requirements.` */ - validationError?: string; + validationError: ?string; /* Set to `true` to disallow the username as part of the password.

Default is `false`. :DEFAULT: false */ - doNotAllowUsername?: boolean; + doNotAllowUsername: ?boolean; /* Set the number of days after which a password expires. Login attempts fail if the user does not reset the password before expiration. */ - maxPasswordAge?: number; + maxPasswordAge: ?number; /* Set the number of previous password that will not be allowed to be set as new password. If the option is not set or set to `0`, no previous passwords will be considered.

Valid values are >= `0` and <= `20`.
Default is `0`. */ - maxPasswordHistory?: number; + maxPasswordHistory: ?number; /* Set the validity duration of the password reset token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.

For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours).

Default is `undefined`. */ - resetTokenValidityDuration?: number; + resetTokenValidityDuration: ?number; /* Set to `true` if a password reset token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.

Default is `false`. :DEFAULT: false */ - resetTokenReuseIfValid?: boolean; + resetTokenReuseIfValid: ?boolean; /* Set to `true` if a request to reset the password should return a success response even if the provided email address is invalid, or `false` if the request should return an error response if the email address is invalid.

Default is `true`. :DEFAULT: true */ - resetPasswordSuccessOnInvalidEmail?: boolean; + resetPasswordSuccessOnInvalidEmail: ?boolean; } export interface FileUploadOptions { /* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files. :DEFAULT: ["^(?!(h|H)(t|T)(m|M)(l|L)?$)"] */ - fileExtensions?: (string[]); + fileExtensions: ?(string[]); /* Is true if file upload should be allowed for anonymous users. :DEFAULT: false */ - enableForAnonymousUser?: boolean; + enableForAnonymousUser: ?boolean; /* Is true if file upload should be allowed for authenticated users. :DEFAULT: true */ - enableForAuthenticatedUser?: boolean; + enableForAuthenticatedUser: ?boolean; /* Is true if file upload should be allowed for anyone, regardless of user authentication. :DEFAULT: false */ - enableForPublic?: boolean; + enableForPublic: ?boolean; } export interface DatabaseOptions { /* Enables database real-time hooks to update single schema cache. Set to `true` if using multiple Parse Servers instances connected to the same database. Failing to do so will cause a schema change to not propagate to all instances and re-syncing will only happen when the instances restart. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required. :DEFAULT: false */ - enableSchemaHooks?: boolean; + enableSchemaHooks: ?boolean; /* The duration in seconds after which the schema cache expires and will be refetched from the database. Use this option if using multiple Parse Servers instances connected to the same database. A low duration will cause the schema cache to be updated too often, causing unnecessary database reads. A high duration will cause the schema to be updated too rarely, increasing the time required until schema changes propagate to all server instances. This feature can be used as an alternative or in conjunction with the option `enableSchemaHooks`. Default is infinite which means the schema cache never expires. */ - schemaCacheTtl?: number; + schemaCacheTtl: ?number; /* The MongoDB driver option to set whether to retry failed writes. */ - retryWrites?: boolean; + retryWrites: ?boolean; /* The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor. */ - maxTimeMS?: number; + maxTimeMS: ?number; /* The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.*/ - maxStalenessSeconds?: number; + maxStalenessSeconds: ?number; /* The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. */ - minPoolSize?: number; + minPoolSize: ?number; /* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */ - maxPoolSize?: number; + maxPoolSize: ?number; /* The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout. */ - connectTimeoutMS?: number; + connectTimeoutMS: ?number; /* The MongoDB driver option to specify the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ - socketTimeoutMS?: number; + socketTimeoutMS: ?number; /* The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. */ - autoSelectFamily?: boolean; + autoSelectFamily: ?boolean; /* The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. */ - autoSelectFamilyAttemptTimeout?: number; + autoSelectFamilyAttemptTimeout: ?number; } export interface AuthAdapter { @@ -627,28 +627,28 @@ export interface AuthAdapter { :DEFAULT: false :ENV: */ - enabled?: boolean; + enabled: ?boolean; } export interface LogLevels { /* Log level used by the Cloud Code Triggers `afterSave`, `afterDelete`, `afterFind`, `afterLogout`. Default is `info`. :DEFAULT: info */ - triggerAfter?: string; + triggerAfter: ?string; /* Log level used by the Cloud Code Triggers `beforeSave`, `beforeDelete`, `beforeFind`, `beforeLogin` on success. Default is `info`. :DEFAULT: info */ - triggerBeforeSuccess?: string; + triggerBeforeSuccess: ?string; /* Log level used by the Cloud Code Triggers `beforeSave`, `beforeDelete`, `beforeFind`, `beforeLogin` on error. Default is `error`. :DEFAULT: error */ - triggerBeforeError?: string; + triggerBeforeError: ?string; /* Log level used by the Cloud Code Functions on success. Default is `info`. :DEFAULT: info */ - cloudFunctionSuccess?: string; + cloudFunctionSuccess: ?string; /* Log level used by the Cloud Code Functions on error. Default is `error`. :DEFAULT: error */ - cloudFunctionError?: string; + cloudFunctionError: ?string; } diff --git a/types/Options/index.d.ts b/types/Options/index.d.ts index 75f08a6b71..ac1c71e886 100644 --- a/types/Options/index.d.ts +++ b/types/Options/index.d.ts @@ -1,3 +1,4 @@ +// This file is manually updated to match src/Options/index.js until typed import { AnalyticsAdapter } from '../Adapters/Analytics/AnalyticsAdapter'; import { CacheAdapter } from '../Adapters/Cache/CacheAdapter'; import { MailAdapter } from '../Adapters/Email/MailAdapter'; From 99cc69ced94907564ed05ea4896823a24cdb8d8e Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 2 Apr 2025 17:18:05 -0500 Subject: [PATCH 4/8] fix logger --- src/LiveQuery/ParseLiveQueryServer.ts | 3 ++- src/ParseServer.ts | 2 +- src/logger.ts | 2 +- types/logger.d.ts | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LiveQuery/ParseLiveQueryServer.ts b/src/LiveQuery/ParseLiveQueryServer.ts index 531de0c786..3e6048c345 100644 --- a/src/LiveQuery/ParseLiveQueryServer.ts +++ b/src/LiveQuery/ParseLiveQueryServer.ts @@ -3,7 +3,8 @@ import Parse from 'parse/node'; import { Subscription } from './Subscription'; import { Client } from './Client'; import { ParseWebSocketServer } from './ParseWebSocketServer'; -import { logger } from '../logger'; +// @ts-ignore +import logger from '../logger'; import RequestSchema from './RequestSchema'; import { matchesQuery, queryHash } from './QueryTools'; import { ParsePubSub } from './ParsePubSub'; diff --git a/src/ParseServer.ts b/src/ParseServer.ts index a881add922..c0df4f3431 100644 --- a/src/ParseServer.ts +++ b/src/ParseServer.ts @@ -116,7 +116,7 @@ class ParseServer { const diff = validateKeyNames(options, optionsBlueprint); if (diff.length > 0) { - const logger = logging.logger; + const logger = (logging as any).logger; logger.error(`Invalid key(s) found in Parse Server configuration: ${diff.join(', ')}`); } diff --git a/src/logger.ts b/src/logger.ts index 5ec88c0e47..97604039c5 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -15,7 +15,7 @@ function defaultLogger() { return new LoggerController(adapter, null, options); } -export let logger = defaultLogger(); +let logger = defaultLogger(); export function setLogger(aLogger) { logger = aLogger; diff --git a/types/logger.d.ts b/types/logger.d.ts index f81e70db76..14b33350d6 100644 --- a/types/logger.d.ts +++ b/types/logger.d.ts @@ -1,3 +1,2 @@ -export declare let logger: any; export declare function setLogger(aLogger: any): void; export declare function getLogger(): any; From adab706afb56d71a5a3576e54c42baa11cd244be Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 2 Apr 2025 17:33:10 -0500 Subject: [PATCH 5/8] Update CONTRIBUTING.md --- CONTRIBUTING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27e7e114a5..db9d79c1bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,6 +21,7 @@ - [Good to Know](#good-to-know) - [Troubleshooting](#troubleshooting) - [Please Do's](#please-dos) + - [TypeScript Tests](#typescript-tests) - [Test against Postgres](#test-against-postgres) - [Postgres with Docker](#postgres-with-docker) - [Breaking Changes](#breaking-changes) @@ -239,6 +240,14 @@ Once you have babel running in watch mode, you can start making changes to parse * Mocks belong in the `spec/support` folder. * Please consider if any changes to the [docs](http://docs.parseplatform.org) are needed or add additional sections in the case of an enhancement or feature. +#### TypeScript Tests + +Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensure types generated for each class is behaving as expected. Types must be generated using `npm run build:types` and should not be manually changed. These types are `.d.ts` files located in [/types](/types). + +When developing type definitions you can use `npm run watch:ts` in order to rebuild your changes automatically upon each save. + +Use `npm run test:types` in order to run types tests against generated `.d.ts` files. + ### Test against Postgres If your pull request introduces a change that may affect the storage or retrieval of objects, you may want to make sure it plays nice with Postgres. From 4ca59b66f33de1348bca9113e463ef892d13a581 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 13 Apr 2025 23:54:10 -0500 Subject: [PATCH 6/8] update contributing guide --- CONTRIBUTING.md | 2 +- package-lock.json | 3 +-- package.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db9d79c1bd..f6c503353e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -242,7 +242,7 @@ Once you have babel running in watch mode, you can start making changes to parse #### TypeScript Tests -Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensure types generated for each class is behaving as expected. Types must be generated using `npm run build:types` and should not be manually changed. These types are `.d.ts` files located in [/types](/types). +Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensure types generated for each class is behaving as expected. Types must be generated using `npm run build:types` and should not be manually changed. These types are `.d.ts` files located in [/types](/types). *Note: Any type changes to `src/Options/index.js` should be manually updated in `types/Options/index.d.ts`.* When developing type definitions you can use `npm run watch:ts` in order to rebuild your changes automatically upon each save. diff --git a/package-lock.json b/package-lock.json index 644ac6fd22..e70336b814 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,7 +82,7 @@ "deep-diff": "1.0.2", "eslint": "9.23.0", "eslint-plugin-expect-type": "0.6.2", - "flow-bin": "0.119.1", + "flow-bin": "0.266.1", "form-data": "4.0.2", "globals": "16.0.0", "graphql-tag": "2.12.6", @@ -10901,7 +10901,6 @@ "resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.266.1.tgz", "integrity": "sha512-c1lg1E8SDcuPSkrOeH0JTcNKMZOzXvqX2DuuXJ0amZec15uyuIi8QlGTO3OzYssMT/kwFdo5vviJqSUI/BNFbw==", "dev": true, - "license": "MIT", "bin": { "flow": "cli.js" }, diff --git a/package.json b/package.json index 3b3abbbf80..319fb881aa 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "deep-diff": "1.0.2", "eslint": "9.23.0", "eslint-plugin-expect-type": "0.6.2", - "flow-bin": "0.119.1", + "flow-bin": "0.266.1", "form-data": "4.0.2", "globals": "16.0.0", "graphql-tag": "2.12.6", From 4aebc4ea31f7f21ff4d6ea6e910393c833b92d81 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Tue, 15 Apr 2025 12:40:40 +0100 Subject: [PATCH 7/8] Update CONTRIBUTING.md Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6c503353e..3f332f6f9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -242,7 +242,10 @@ Once you have babel running in watch mode, you can start making changes to parse #### TypeScript Tests -Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensure types generated for each class is behaving as expected. Types must be generated using `npm run build:types` and should not be manually changed. These types are `.d.ts` files located in [/types](/types). *Note: Any type changes to `src/Options/index.js` should be manually updated in `types/Options/index.d.ts`.* +Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensuring that the type generation for each class is behaving as expected. Types are generated by manually running the script `npm run build:types`. The generated types are `.d.ts` files located in [/types](/types) and must not be manually changed after generation. + +> [!CAUTION] +> An exemption are type changes to `src/Options/index.js` which must be manually updated in `types/Options/index.d.ts`, as these types are not generated via a script. When developing type definitions you can use `npm run watch:ts` in order to rebuild your changes automatically upon each save. From 236b4178bfc3c9419c2aa9e5edd78e8f440f6070 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Tue, 15 Apr 2025 12:40:47 +0100 Subject: [PATCH 8/8] Update CONTRIBUTING.md Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- CONTRIBUTING.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f332f6f9b..01c88df10c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -247,9 +247,7 @@ Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible > [!CAUTION] > An exemption are type changes to `src/Options/index.js` which must be manually updated in `types/Options/index.d.ts`, as these types are not generated via a script. -When developing type definitions you can use `npm run watch:ts` in order to rebuild your changes automatically upon each save. - -Use `npm run test:types` in order to run types tests against generated `.d.ts` files. +When developing type definitions you can run `npm run watch:ts` in order to rebuild your changes automatically upon each save. Use `npm run test:types` in order to run types tests against generated `.d.ts` files. ### Test against Postgres