From 687d8d1337656d542a12d73951bc452bd62fff5d Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Tue, 10 Dec 2024 13:17:00 +0000 Subject: [PATCH 1/6] fix(): eslint configuration --- .eslintrc.cjs | 34 ++ .eslintrc.js | 36 -- package-lock.json | 1132 +++++++++++++++++++++++++++----------- package.json | 5 + src/util/BaseWSClient.ts | 23 +- tsconfig.linting.json | 17 + 6 files changed, 884 insertions(+), 363 deletions(-) create mode 100644 .eslintrc.cjs delete mode 100644 .eslintrc.js create mode 100644 tsconfig.linting.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..021f68f --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,34 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: 'tsconfig.linting.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + plugins: [ + '@typescript-eslint/eslint-plugin', + 'simple-import-sort', + 'require-extensions', + ], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + 'plugin:require-extensions/recommended', + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: ['.eslintrc.js'], + rules: { + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/ban-types': 'off', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + }, +}; diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index e8c5c55..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = { - env: { - es6: true, - node: true, - }, - extends: ['eslint:recommended'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 9 - }, - - plugins: [], - rules: { - 'array-bracket-spacing': ['error', 'never'], - indent: ['warn', 2], - 'linebreak-style': ['error', 'unix'], - 'lines-between-class-members': ['warn', 'always'], - semi: ['error', 'always'], - 'new-cap': 'off', - 'no-console': 'off', - 'no-debugger': 'off', - 'no-mixed-spaces-and-tabs': 2, - 'no-use-before-define': [2, 'nofunc'], - 'no-unreachable': ['warn'], - 'no-unused-vars': ['warn'], - 'no-extra-parens': ['off'], - 'no-mixed-operators': ['off'], - quotes: [2, 'single', 'avoid-escape'], - 'block-scoped-var': 2, - 'brace-style': [2, '1tbs', { allowSingleLine: true }], - 'computed-property-spacing': [2, 'never'], - 'keyword-spacing': 2, - 'space-unary-ops': 2, - 'max-len': ['warn', { 'code': 140 }] - } -}; diff --git a/package-lock.json b/package-lock.json index b69b319..53c19a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,12 @@ "devDependencies": { "@types/jest": "^29.0.3", "@types/node": "^18.7.23", + "@typescript-eslint/eslint-plugin": "^8.18.0", "eslint": "^8.24.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-require-extensions": "^0.1.3", + "eslint-plugin-simple-import-sort": "^12.1.1", "jest": "^29.1.1", "source-map-loader": "^4.0.0", "ts-jest": "^29.0.2", @@ -700,16 +705,43 @@ "node": ">=10.0.0" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", - "integrity": "sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.15.0", + "espree": "^9.6.0", + "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -723,30 +755,30 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { - "version": "0.10.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.5.tgz", - "integrity": "sha512-XVVDtp+dVvRxMoxSiSfasYaG02VEe1qH5cKgMQJWhol6HwzbcqoCMJi8dAGoYAO57jhUyhI6cWuRiTcRaDaYug==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.4" + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, - "node_modules/@humanwhocodes/gitignore-to-minimatch": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", - "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -761,9 +793,10 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { @@ -1259,6 +1292,18 @@ "node": ">= 8" } }, + "node_modules/@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@polka/url": { "version": "1.0.0-next.21", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz", @@ -1418,6 +1463,233 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.0.tgz", + "integrity": "sha512-NR2yS7qUqCL7AIxdJUQf2MKKNDVNaig/dEB0GBLU7D+ZdHgK1NoH/3wsgO3OnPVipn51tG3MAwaODEGil70WEw==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/type-utils": "8.18.0", + "@typescript-eslint/utils": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + }, + "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.8.0" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.0.tgz", + "integrity": "sha512-hgUZ3kTEpVzKaK3uNibExUYm6SKKOmTU2BOxBSvOYwtJEPdVQ70kZJpPjstlnhCHcuc2WGfSbpKlb/69ttyN5Q==", + "dev": true, + "peer": true, + "dependencies": { + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.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.8.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.0.tgz", + "integrity": "sha512-PNGcHop0jkK2WVYGotk/hxj+UFLhXtGPiGtiaWgVBVP1jhMoMCHlTyJA+hEj4rszoSdLTK3fN4oOatrL0Cp+Xw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.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": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.0.tgz", + "integrity": "sha512-er224jRepVAVLnMF2Q7MZJCq5CsdH2oqjP4dT7K6ij09Kyd+R21r7UVJrF0buMVdZS5QRhDzpvzAxHxabQadow==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "8.18.0", + "@typescript-eslint/utils": "8.18.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.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.8.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.0.tgz", + "integrity": "sha512-FNYxgyTCAnFwTrzpBGq+zrnoTO4x0c1CKYY5MuUTzpScqmY5fmsh2o3+57lqdI3NZucBDCzDgdEbIaNfAjAHQA==", + "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/typescript-estree": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.0.tgz", + "integrity": "sha512-rqQgFRu6yPkauz+ms3nQpohwejS8bvgbPyIDq13cgEDbkXt4LH4OkDMT0/fN1RUtzG8e8AKJyDBoocuQh8qNeg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.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": "^1.3.0" + }, + "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.8.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/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/typescript-estree/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/typescript-estree/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.0.tgz", + "integrity": "sha512-p6GLdY383i7h5b0Qrfbix3Vc3+J2k6QWw6UMUeY5JGfm3C5LbZ4QIZzJNoNOfgyRe0uuYKjvVOsO/jD4SJO+xg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.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.8.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.0.tgz", + "integrity": "sha512-pCh/qEA8Lb1wVIqNvBke8UaRjJ6wrAWkJO5yyIbs8Yx6TNGYyfNjOo61tLv+WwLvoLPp4BQ8B7AHKijl8NGUfw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.18.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/visitor-keys/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/@ungap/structured-clone": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz", + "integrity": "sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==", + "dev": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", @@ -1752,15 +2024,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -2136,9 +2399,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -2213,18 +2476,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -2329,49 +2580,49 @@ } }, "node_modules/eslint": { - "version": "8.24.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.24.0.tgz", - "integrity": "sha512-dWFaPhGhTAiPcCgm3f6LI2MBWbogMnTJzFBbhXVRQDJPkr9pGZvVjlVfXd+vyDcWPA2Ic9L2AXPIQM0+vk/cSQ==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.3.2", - "@humanwhocodes/config-array": "^0.10.5", - "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", "@humanwhocodes/module-importer": "^1.0.1", - "ajv": "^6.10.0", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", - "glob-parent": "^6.0.1", - "globals": "^13.15.0", - "globby": "^11.1.0", - "grapheme-splitter": "^1.0.4", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "js-sdsl": "^4.1.4", + "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -2384,10 +2635,73 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-require-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz", + "integrity": "sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/eslint-plugin-simple-import-sort": { + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.1.tgz", + "integrity": "sha512-6nuzu4xwQtE3332Uz0to+TxDQYRLTKRESSc2hefVT48Zc8JthmN23Gx9lnYhu0FtkRSL1oxny3kJ2aveVhmOVA==", + "dev": true, + "peerDependencies": { + "eslint": ">=5.0.0" + } + }, "node_modules/eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -2395,53 +2709,32 @@ }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/espree": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", - "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2464,9 +2757,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -2568,10 +2861,16 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -2618,9 +2917,9 @@ } }, "node_modules/fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -2830,9 +3129,9 @@ "dev": true }, "node_modules/globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -2844,36 +3143,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "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/gzip-size": { @@ -2940,9 +3219,9 @@ } }, "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "engines": { "node": ">= 4" @@ -3083,6 +3362,15 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3768,12 +4056,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sdsl": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.4.tgz", - "integrity": "sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==", - "dev": true - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4126,9 +4408,9 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "dependencies": { "deep-is": "^0.1.3", @@ -4136,7 +4418,7 @@ "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "word-wrap": "^1.2.5" }, "engines": { "node": ">= 0.8.0" @@ -4244,15 +4526,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/picocolors": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", @@ -4353,6 +4626,34 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", + "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", + "dev": true, + "peer": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-format": { "version": "29.1.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.0.tgz", @@ -4453,18 +4754,6 @@ "node": ">= 0.10" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4876,6 +5165,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "dev": true, + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -5048,6 +5353,18 @@ "node": ">=6" } }, + "node_modules/ts-api-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz", + "integrity": "sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-jest": { "version": "29.0.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.2.tgz", @@ -5140,6 +5457,12 @@ "node": ">=10" } }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -6110,16 +6433,31 @@ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", "dev": true }, + "@eslint-community/eslint-utils": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.4.3" + } + }, + "@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true + }, "@eslint/eslintrc": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.2.tgz", - "integrity": "sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.15.0", + "espree": "^9.6.0", + "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -6127,23 +6465,23 @@ "strip-json-comments": "^3.1.1" } }, + "@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true + }, "@humanwhocodes/config-array": { - "version": "0.10.5", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.5.tgz", - "integrity": "sha512-XVVDtp+dVvRxMoxSiSfasYaG02VEe1qH5cKgMQJWhol6HwzbcqoCMJi8dAGoYAO57jhUyhI6cWuRiTcRaDaYug==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.4" + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" } }, - "@humanwhocodes/gitignore-to-minimatch": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", - "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", - "dev": true - }, "@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -6151,9 +6489,9 @@ "dev": true }, "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "@istanbuljs/load-nyc-config": { @@ -6547,6 +6885,12 @@ "fastq": "^1.6.0" } }, + "@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true + }, "@polka/url": { "version": "1.0.0-next.21", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz", @@ -6706,6 +7050,143 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.0.tgz", + "integrity": "sha512-NR2yS7qUqCL7AIxdJUQf2MKKNDVNaig/dEB0GBLU7D+ZdHgK1NoH/3wsgO3OnPVipn51tG3MAwaODEGil70WEw==", + "dev": true, + "requires": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/type-utils": "8.18.0", + "@typescript-eslint/utils": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + } + }, + "@typescript-eslint/parser": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.0.tgz", + "integrity": "sha512-hgUZ3kTEpVzKaK3uNibExUYm6SKKOmTU2BOxBSvOYwtJEPdVQ70kZJpPjstlnhCHcuc2WGfSbpKlb/69ttyN5Q==", + "dev": true, + "peer": true, + "requires": { + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.0", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.0.tgz", + "integrity": "sha512-PNGcHop0jkK2WVYGotk/hxj+UFLhXtGPiGtiaWgVBVP1jhMoMCHlTyJA+hEj4rszoSdLTK3fN4oOatrL0Cp+Xw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.0.tgz", + "integrity": "sha512-er224jRepVAVLnMF2Q7MZJCq5CsdH2oqjP4dT7K6ij09Kyd+R21r7UVJrF0buMVdZS5QRhDzpvzAxHxabQadow==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "8.18.0", + "@typescript-eslint/utils": "8.18.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + } + }, + "@typescript-eslint/types": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.0.tgz", + "integrity": "sha512-FNYxgyTCAnFwTrzpBGq+zrnoTO4x0c1CKYY5MuUTzpScqmY5fmsh2o3+57lqdI3NZucBDCzDgdEbIaNfAjAHQA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.0.tgz", + "integrity": "sha512-rqQgFRu6yPkauz+ms3nQpohwejS8bvgbPyIDq13cgEDbkXt4LH4OkDMT0/fN1RUtzG8e8AKJyDBoocuQh8qNeg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/visitor-keys": "8.18.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": "^1.3.0" + }, + "dependencies": { + "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" + } + }, + "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" + } + }, + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + } + } + }, + "@typescript-eslint/utils": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.0.tgz", + "integrity": "sha512-p6GLdY383i7h5b0Qrfbix3Vc3+J2k6QWw6UMUeY5JGfm3C5LbZ4QIZzJNoNOfgyRe0uuYKjvVOsO/jD4SJO+xg==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.18.0", + "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.0.tgz", + "integrity": "sha512-pCh/qEA8Lb1wVIqNvBke8UaRjJ6wrAWkJO5yyIbs8Yx6TNGYyfNjOo61tLv+WwLvoLPp4BQ8B7AHKijl8NGUfw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.18.0", + "eslint-visitor-keys": "^4.2.0" + }, + "dependencies": { + "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 + } + } + }, + "@ungap/structured-clone": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz", + "integrity": "sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==", + "dev": true + }, "@webassemblyjs/ast": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", @@ -6986,12 +7467,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -7275,9 +7750,9 @@ } }, "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "requires": { "path-key": "^3.1.0", @@ -7329,15 +7804,6 @@ "integrity": "sha512-7Qe/zd1wxSDL4D/X/FPjOMB+ZMDt71W94KYaq05I2l0oQqgXgs7s4ftYYmV38gBSrPz2vcygxfs1xn0FT+rKNA==", "dev": true }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "requires": { - "path-type": "^4.0.0" - } - }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -7415,94 +7881,107 @@ "dev": true }, "eslint": { - "version": "8.24.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.24.0.tgz", - "integrity": "sha512-dWFaPhGhTAiPcCgm3f6LI2MBWbogMnTJzFBbhXVRQDJPkr9pGZvVjlVfXd+vyDcWPA2Ic9L2AXPIQM0+vk/cSQ==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.3.2", - "@humanwhocodes/config-array": "^0.10.5", - "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", "@humanwhocodes/module-importer": "^1.0.1", - "ajv": "^6.10.0", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", - "glob-parent": "^6.0.1", - "globals": "^13.15.0", - "globby": "^11.1.0", - "grapheme-splitter": "^1.0.4", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "js-sdsl": "^4.1.4", + "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" } }, + "eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "requires": {} + }, + "eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + } + }, + "eslint-plugin-require-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz", + "integrity": "sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==", + "dev": true, + "requires": {} + }, + "eslint-plugin-simple-import-sort": { + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.1.tgz", + "integrity": "sha512-6nuzu4xwQtE3332Uz0to+TxDQYRLTKRESSc2hefVT48Zc8JthmN23Gx9lnYhu0FtkRSL1oxny3kJ2aveVhmOVA==", + "dev": true, + "requires": {} + }, "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "requires": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true }, "espree": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", - "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "requires": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" } }, "esprima": { @@ -7512,9 +7991,9 @@ "dev": true }, "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -7589,10 +8068,16 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -7632,9 +8117,9 @@ "dev": true }, "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "requires": { "reusify": "^1.0.4" @@ -7781,38 +8266,24 @@ "dev": true }, "globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "requires": { "type-fest": "^0.20.2" } }, - "globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "requires": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - } - }, "graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, "gzip-size": { @@ -7861,9 +8332,9 @@ } }, "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true }, "import-fresh": { @@ -7962,6 +8433,12 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -8485,12 +8962,6 @@ } } }, - "js-sdsl": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.4.tgz", - "integrity": "sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==", - "dev": true - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -8762,9 +9233,9 @@ "dev": true }, "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "requires": { "deep-is": "^0.1.3", @@ -8772,7 +9243,7 @@ "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "word-wrap": "^1.2.5" } }, "p-limit": { @@ -8844,12 +9315,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - }, "picocolors": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", @@ -8922,6 +9387,22 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", + "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", + "dev": true, + "peer": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-format": { "version": "29.1.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.0.tgz", @@ -8992,12 +9473,6 @@ "resolve": "^1.9.0" } }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -9288,6 +9763,16 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "dev": true, + "requires": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + } + }, "tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -9407,6 +9892,13 @@ "integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==", "dev": true }, + "ts-api-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz", + "integrity": "sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==", + "dev": true, + "requires": {} + }, "ts-jest": { "version": "29.0.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.2.tgz", @@ -9457,6 +9949,12 @@ } } }, + "tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index f106477..000cd02 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,12 @@ "devDependencies": { "@types/jest": "^29.0.3", "@types/node": "^18.7.23", + "@typescript-eslint/eslint-plugin": "^8.18.0", "eslint": "^8.24.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-require-extensions": "^0.1.3", + "eslint-plugin-simple-import-sort": "^12.1.1", "jest": "^29.1.1", "source-map-loader": "^4.0.0", "ts-jest": "^29.0.2", diff --git a/src/util/BaseWSClient.ts b/src/util/BaseWSClient.ts index 66a30ae..32d79df 100644 --- a/src/util/BaseWSClient.ts +++ b/src/util/BaseWSClient.ts @@ -1,12 +1,16 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ import EventEmitter from 'events'; import WebSocket from 'isomorphic-ws'; -import { WebsocketClientOptions, WSClientConfigurableOptions } from '../types'; -import WsStore from './WsStore'; -import { WsConnectionStateEnum } from './WsStore.types'; -import { DefaultLogger } from './logger'; -import { isWsPong } from './requestUtils'; -import { getWsAuthSignature } from './websocket-util'; +import { + WebsocketClientOptions, + WSClientConfigurableOptions, +} from '../types/index.js'; +import { DefaultLogger } from './logger.js'; +import { isWsPong } from './requestUtils.js'; +import { getWsAuthSignature } from './websocket-util.js'; +import WsStore from './WsStore.js'; +import { WsConnectionStateEnum } from './WsStore.types.js'; interface WSClientEventMap { /** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */ @@ -30,6 +34,7 @@ interface WSClientEventMap { // Type safety for on and emit handlers: https://stackoverflow.com/a/61609010/880837 export interface BaseWebsocketClient< TWSKey extends string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars TWSTopicSubscribeEventArgs extends object, > { on>( @@ -43,8 +48,6 @@ export interface BaseWebsocketClient< ): boolean; } -export interface BaseWSClientImpl {} - const LOGGER_CATEGORY = { category: 'bitget-ws' }; export abstract class BaseWebsocketClient< @@ -382,7 +385,7 @@ export abstract class BaseWebsocketClient< this.logger.silly( `Subscribing to topics in batches of ${maxTopicsPerEvent}`, ); - for (var i = 0; i < topics.length; i += maxTopicsPerEvent) { + for (let i = 0; i < topics.length; i += maxTopicsPerEvent) { const batch = topics.slice(i, i + maxTopicsPerEvent); this.logger.silly(`Subscribing to batch of ${batch.length}`); this.requestSubscribeTopics(wsKey, batch); @@ -417,7 +420,7 @@ export abstract class BaseWebsocketClient< this.logger.silly( `Unsubscribing to topics in batches of ${maxTopicsPerEvent}`, ); - for (var i = 0; i < topics.length; i += maxTopicsPerEvent) { + for (let i = 0; i < topics.length; i += maxTopicsPerEvent) { const batch = topics.slice(i, i + maxTopicsPerEvent); this.logger.silly(`Unsubscribing to batch of ${batch.length}`); this.requestUnsubscribeTopics(wsKey, batch); diff --git a/tsconfig.linting.json b/tsconfig.linting.json new file mode 100644 index 0000000..e925971 --- /dev/null +++ b/tsconfig.linting.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist/cjs", + "target": "esnext", + "rootDir": "../", + "allowJs": true + }, + "include": [ + "src/**/*.*", + "test/**/*.*", + "examples/**/*.*", + ".eslintrc.cjs", + "jest.config.ts" + ] +} From e92c083961eaafd64140431919d56418b54a5045 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Tue, 10 Dec 2024 17:29:47 +0000 Subject: [PATCH 2/6] chore(): run linter fixes --- .eslintrc.cjs | 4 +- src/broker-client.ts | 2 +- src/futures-client.ts | 60 +-- src/index.ts | 10 +- src/rest-client-v2.ts | 190 ++++---- src/spot-client.ts | 38 +- src/types/index.ts | 2 +- src/types/request/index.ts | 22 +- src/types/request/shared.ts | 78 ++-- src/types/request/v1/futuresV1.ts | 2 +- src/types/request/v1/spotV1.ts | 36 +- src/types/request/v2/common.ts | 374 +++++++-------- src/types/request/v2/spot.ts | 702 ++++++++++++++--------------- src/types/response/index.ts | 2 +- src/types/shared.ts | 2 +- src/util/BaseRestClient.ts | 10 +- src/util/BaseWSClient.ts | 12 +- src/util/WsStore.ts | 1 + src/util/browser-support.ts | 1 + src/util/index.ts | 4 +- src/util/logger.ts | 1 + src/util/node-support.ts | 1 + src/util/requestUtils.ts | 2 +- src/util/websocket-util.ts | 1 + src/websocket-client-v2.ts | 10 +- src/websocket-client.ts | 23 +- test/broker/private.read.test.ts | 6 +- test/broker/private.write.test.ts | 8 +- test/futures/private.write.test.ts | 6 +- test/futures/public.test.ts | 8 +- test/spot/private.read.test.ts | 2 +- test/spot/public.test.ts | 5 +- test/ws.private.test.ts | 11 +- test/ws.public.test.ts | 4 +- test/ws.util.ts | 2 + 35 files changed, 817 insertions(+), 825 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 021f68f..71a433c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -8,12 +8,12 @@ module.exports = { plugins: [ '@typescript-eslint/eslint-plugin', 'simple-import-sort', - 'require-extensions', + // 'require-extensions', // only once moved to ESM ], extends: [ 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', - 'plugin:require-extensions/recommended', + // 'plugin:require-extensions/recommended', // only once moved to ESM ], root: true, env: { diff --git a/src/broker-client.ts b/src/broker-client.ts index bad3bdc..83daf10 100644 --- a/src/broker-client.ts +++ b/src/broker-client.ts @@ -1,9 +1,9 @@ import { APIResponse, BrokerProductType, - BrokerSubWithdrawalRequest, BrokerSubAPIKeyModifyRequest, BrokerSubListRequest, + BrokerSubWithdrawalRequest, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; diff --git a/src/futures-client.ts b/src/futures-client.ts index 6041ddf..7d2cfbb 100644 --- a/src/futures-client.ts +++ b/src/futures-client.ts @@ -1,32 +1,32 @@ import { APIResponse, - FuturesProductType, + CancelFuturesPlanTPSL, + FuturesAccount, FuturesAccountBillRequest, FuturesBusinessBillRequest, - NewFuturesOrder, - NewBatchFuturesOrder, + FuturesCandleData, + FuturesHistoricPositions, + FuturesKlineInterval, + FuturesMarginMode, + FuturesMarketTrade, FuturesPagination, - NewFuturesPlanOrder, + FuturesPlanType, + FuturesPosition, + FuturesProductType, + FuturesSymbolRule, + GetHistoricTradesParams, + HistoricPlanOrderTPSLRequest, + ModifyFuturesOrder, ModifyFuturesPlanOrder, ModifyFuturesPlanOrderTPSL, - NewFuturesPlanPositionTPSL, ModifyFuturesPlanStopOrder, - CancelFuturesPlanTPSL, - HistoricPlanOrderTPSLRequest, + NewBatchFuturesOrder, + NewFuturesOrder, + NewFuturesPlanOrder, + NewFuturesPlanPositionTPSL, NewFuturesPlanStopOrder, - FuturesAccount, - FuturesSymbolRule, - FuturesMarginMode, - FuturesPosition, NewFuturesPlanTrailingStopOrder, VIPFeeRate, - GetHistoricTradesParams, - FuturesMarketTrade, - FuturesPlanType, - FuturesKlineInterval, - FuturesHistoricPositions, - ModifyFuturesOrder, - FuturesCandleData, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -105,9 +105,9 @@ export class FuturesClient extends BaseRestClient { symbol: string, granularity: FuturesKlineInterval, startTime: string, - endTime: string, + endTime: string, limit?: string, - kLineType?: 'market' | 'mark' | 'index' + kLineType?: 'market' | 'mark' | 'index', ): Promise> { return this.get('/api/mix/v1/market/candles', { symbol, @@ -569,16 +569,16 @@ export class FuturesClient extends BaseRestClient { return this.postPrivate('/api/mix/v1/plan/cancelPlan', params); } - /** Cancel Symbol Plan Order (TPSL) */ - cancelSymbolPlanOrders( - symbol: string, - planType: FuturesPlanType, - ): Promise> { - return this.postPrivate('/api/mix/v1/plan/cancelSymbolPlan', { - symbol, - planType, - }); - } + /** Cancel Symbol Plan Order (TPSL) */ + cancelSymbolPlanOrders( + symbol: string, + planType: FuturesPlanType, + ): Promise> { + return this.postPrivate('/api/mix/v1/plan/cancelSymbolPlan', { + symbol, + planType, + }); + } /** Cancel All Trigger Order (TPSL) */ cancelAllPlanOrders( diff --git a/src/index.ts b/src/index.ts index 771b2dc..c1c41cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ -export * from './rest-client-v2'; export * from './broker-client'; +export * from './constants/enum'; export * from './futures-client'; +export * from './rest-client-v2'; export * from './spot-client'; +export * from './types'; +export * from './util'; +export * from './util/logger'; export * from './websocket-client'; export * from './websocket-client-v2'; -export * from './util/logger'; -export * from './util'; -export * from './types'; -export * from './constants/enum'; diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 5774191..5b1cef3 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -1,111 +1,111 @@ import { APIResponse, - MarginType, + BorrowLoanRequestV2, + CloseFuturesFollowerPositionsRequestV2, + CopyTradingProductTypeV2, FuturesAccountBillRequestV2, + FuturesBatchCancelOrderRequestV2, + FuturesBatchOrderRequestV2, + FuturesCancelAllOrdersRequestV2, + FuturesCancelOrderRequestV2, + FuturesCancelPlanOrderRequestV2, FuturesCandlesRequestV2, - SpotCandlesRequestV2, - SpotAccountBill, - SpotHistoricCandlesRequestV2, - SpotHistoricTradesRequestV2, - SpotOrderRequestV2, - SpotCancelandSubmitOrderRequestV2, - SpotCancelOrderRequestV2, - SpotBatchOrderRequestV2, - SpotBatchCancelOrderRequestV2, - GetSpotOrderInfoRequestV2, - GetSpotOpenOrdersRequestV2, - GetSpotHistoryOrdersRequestV2, - GetSpotFillsRequestV2, - SpotPlanOrderRequestV2, - SpotModifyPlanOrderRequestV2, - GetSpotCurrentPlanOrdersRequestV2, - GetSpotHistoryPlanOrdersRequestV2, - GetSpotAccountBillsRequestV2, - SpotTransferRequestV2, - SpotAccountTypeV2, - SpotSubAccountTransferRequestV2, - SpotWithdrawalRequestV2, - SpotMainSubTransferRecordRequestV2, - GetSpotTransferRecordRequestV2, - GetSpotSubAccountDepositRecordRequestV2, - GetSpotWithdrawalRecordRequestV2, - GetSpotDepositRecordRequestV2, + FuturesFlashClosePositionsRequestV2, + FuturesGetHistoricalFillsRequestV2, + FuturesGetHistoryOrdersRequestV2, + FuturesGetHistoryPlanOrdersRequestV2, + FuturesGetOpenOrdersRequestV2, + FuturesGetOrderFillsRequestV2, + FuturesGetOrderRequestV2, + FuturesGetPlanOrdersRequestV2, + FuturesHistoricalPositionsRequestV2, + FuturesHistoricTradesRequestV2, + FuturesInterestHistoryRequestV2, FuturesMergeDepthRequestV2, + FuturesModifyOrderRequestV2, + FuturesModifyPlanOrderRequestV2, + FuturesModifyTPSLOrderRequestV2, + FuturesOpenCountRequestV2, + FuturesPlaceOrderRequestV2, + FuturesPlanOrderRequestV2, FuturesProductTypeV2, FuturesRecentTradesRequestV2, - FuturesHistoricTradesRequestV2, - FuturesSingleAccountRequestV2, - FuturesInterestHistoryRequestV2, - FuturesOpenCountRequestV2, + FuturesReversalOrderRequestV2, FuturesSetAutoMarginRequestV2, FuturesSetLeverageRequestV2, - FuturesSetPositionMarginRequestV2, FuturesSetMarginModeRequestV2, - FuturesHistoricalPositionsRequestV2, - FuturesPlaceOrderRequestV2, - FuturesReversalOrderRequestV2, - FuturesBatchOrderRequestV2, - FuturesModifyOrderRequestV2, - FuturesCancelOrderRequestV2, - FuturesBatchCancelOrderRequestV2, - FuturesFlashClosePositionsRequestV2, - FuturesGetOrderRequestV2, - FuturesGetOrderFillsRequestV2, - FuturesGetHistoricalFillsRequestV2, - FuturesGetOpenOrdersRequestV2, - FuturesGetHistoryOrdersRequestV2, - FuturesCancelAllOrdersRequestV2, + FuturesSetPositionMarginRequestV2, + FuturesSingleAccountRequestV2, FuturesTPSLOrderRequestV2, - FuturesPlanOrderRequestV2, - FuturesModifyTPSLOrderRequestV2, - FuturesModifyPlanOrderRequestV2, - FuturesGetPlanOrdersRequestV2, - FuturesCancelPlanOrderRequestV2, - FuturesGetHistoryPlanOrdersRequestV2, - GetBorrowHistoryRequestV2, - GetRepayHistoryRequestV2, - GetInterestHistoryRequestV2, - GetLiquidationHistoryRequestV2, - GetFinancialHistoryRequestV2, - MarginPlaceOrderRequestV2, - MarginBatchOrdersRequestV2, - GetMarginCurrentOrdersRequestV2, - GetHistoryOrdersRequestV2, - GetMarginOrderFillsRequestV2, - GetMarginLiquidationOrdersRequestV2, - GetFuturesTraderCurrentOrdersRequestV2, - GetFuturesTraderHistoryOrdersRequestV2, - ModifyFuturesTraderOrderTPSLRequestV2, - GetFuturesTraderProfitShareDetailRequestV2, - CopyTradingProductTypeV2, FuturesTraderSymbolSettingRequestV2, - GetFuturesTraderFollowersRequestV2, - GetFollowerFuturesCurrentTrackingOrdersRequestV2, - GetFollowerFuturesHistoryTrackingOrdersRequestV2, - UpdateFuturesFollowerTPSLRequestV2, - UpdateFuturesFollowerSettingsRequestV2, - GetFuturesFollowerTradersRequestV2, - CloseFuturesFollowerPositionsRequestV2, - GetSpotTraderHistoryProfitRequestV2, - GetSpotTraderHistoryOrdersRequestV2, - GetSpotTraderCurrentOrdersRequestV2, - GetSpotTraderFollowersRequestV2, - SpotFollowerCopyTradeSettingV2, - GetSpotFollowerHistoryOrdersRequestV2, - GetSpotFollowerOpenOrdersRequestV2, + GetBorrowHistoryRequestV2, GetEarnSavingsAssetsRequestV2, GetEarnSavingsRecordsRequestV2, - RedeemSavingsRequestV2, + GetFinancialHistoryRequestV2, + GetFollowerFuturesCurrentTrackingOrdersRequestV2, + GetFollowerFuturesHistoryTrackingOrdersRequestV2, + GetFuturesFollowerTradersRequestV2, + GetFuturesTraderCurrentOrdersRequestV2, + GetFuturesTraderFollowersRequestV2, + GetFuturesTraderHistoryOrdersRequestV2, + GetFuturesTraderProfitShareDetailRequestV2, + GetHistoryOrdersRequestV2, + GetInterestHistoryRequestV2, + GetLiquidationHistoryRequestV2, + GetLiquidationRecordsRequestV2, + GetLoanEstInterestAndBorrowableRequestV2, + GetLoanHistoryRequestV2, + GetLoanPledgeRateHistoryRequestV2, + GetLoanRepayHistoryRequestV2, + GetMarginCurrentOrdersRequestV2, + GetMarginLiquidationOrdersRequestV2, + GetMarginOrderFillsRequestV2, + GetRepayHistoryRequestV2, GetSharkfinAssetsRequestV2, GetSharkfinRecordsRequestV2, - GetLoanEstInterestAndBorrowableRequestV2, - BorrowLoanRequestV2, - RepayLoanRequestV2, - GetLoanRepayHistoryRequestV2, + GetSpotAccountBillsRequestV2, + GetSpotCurrentPlanOrdersRequestV2, + GetSpotDepositRecordRequestV2, + GetSpotFillsRequestV2, + GetSpotFollowerHistoryOrdersRequestV2, + GetSpotFollowerOpenOrdersRequestV2, + GetSpotHistoryOrdersRequestV2, + GetSpotHistoryPlanOrdersRequestV2, + GetSpotOpenOrdersRequestV2, + GetSpotOrderInfoRequestV2, + GetSpotSubAccountDepositRecordRequestV2, + GetSpotTraderCurrentOrdersRequestV2, + GetSpotTraderFollowersRequestV2, + GetSpotTraderHistoryOrdersRequestV2, + GetSpotTraderHistoryProfitRequestV2, + GetSpotTransferRecordRequestV2, + GetSpotWithdrawalRecordRequestV2, + MarginBatchOrdersRequestV2, + MarginPlaceOrderRequestV2, + MarginType, + ModifyFuturesTraderOrderTPSLRequestV2, ModifyLoanPledgeRateRequestV2, - GetLoanPledgeRateHistoryRequestV2, - GetLoanHistoryRequestV2, - GetLiquidationRecordsRequestV2, + RedeemSavingsRequestV2, + RepayLoanRequestV2, + SpotAccountBill, + SpotAccountTypeV2, + SpotBatchCancelOrderRequestV2, + SpotBatchOrderRequestV2, + SpotCancelandSubmitOrderRequestV2, + SpotCancelOrderRequestV2, + SpotCandlesRequestV2, + SpotFollowerCopyTradeSettingV2, + SpotHistoricCandlesRequestV2, + SpotHistoricTradesRequestV2, + SpotMainSubTransferRecordRequestV2, + SpotModifyPlanOrderRequestV2, + SpotOrderRequestV2, + SpotPlanOrderRequestV2, + SpotSubAccountTransferRequestV2, + SpotTransferRequestV2, + SpotWithdrawalRequestV2, + UpdateFuturesFollowerSettingsRequestV2, + UpdateFuturesFollowerTPSLRequestV2, } from './types'; import { CreateSubAccountApiKeyRequestV2, @@ -122,6 +122,7 @@ import { CreateVirtualSubApiKeyRequestV2, CreateVirtualSubRequestV2, GetAnnouncementsRequestV2, + GetConvertBGBHistoryRequestV2, GetConvertHistoryRequestV2, GetFuturesTransactionsRequestV2, GetMarginTransactionsRequestV2, @@ -131,11 +132,10 @@ import { GetP2PTransactionsRequestV2, GetSpotTransactionsRequestV2, GetTradeRateRequestV2, - ModifyVirtualSubRequestV2, ModifyVirtualSubApiKeyRequestV2, - GetConvertBGBHistoryRequestV2, + ModifyVirtualSubRequestV2, } from './types/request/v2/common'; -import { REST_CLIENT_TYPE_ENUM, assertMarginType } from './util'; +import { assertMarginType, REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; /** @@ -188,7 +188,7 @@ export class RestClientV2 extends BaseRestClient { console.log(result); console.log( - `Your approximate latency to exchange server: + `Your approximate latency to exchange server: One way: ${estimatedOneWayLatency}ms. Round trip: ${roundTripTime}ms. `, diff --git a/src/spot-client.ts b/src/spot-client.ts index 975e976..726e36b 100644 --- a/src/spot-client.ts +++ b/src/spot-client.ts @@ -1,27 +1,27 @@ import { + APIResponse, + BatchCancelSpotOrderV2, + CancelSpotOrderV2, + CancelSpotPlanOrderParams, + CoinBalance, + GetHistoricPlanOrdersParams, + GetHistoricTradesParams, + GetSpotPlanOrdersParams, + ModifySpotPlanOrder, NewBatchSpotOrder, NewSpotOrder, - NewWalletTransfer, - Pagination, - APIResponse, - CoinBalance, - SymbolRules, + NewSpotPlanOrder, NewSpotSubTransfer, NewSpotWithdraw, - CancelSpotOrderV2, - BatchCancelSpotOrderV2, - SpotOrderResult, - NewSpotPlanOrder, - ModifySpotPlanOrder, - CancelSpotPlanOrderParams, - GetSpotPlanOrdersParams, - SpotPlanOrder, - GetHistoricPlanOrdersParams, - SpotMarketTrade, - GetHistoricTradesParams, - VIPFeeRate, - SpotKlineInterval, + NewWalletTransfer, + Pagination, SpotCandleData, + SpotKlineInterval, + SpotMarketTrade, + SpotOrderResult, + SpotPlanOrder, + SymbolRules, + VIPFeeRate, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -112,7 +112,7 @@ export class SpotClient extends BaseRestClient { getCandles( symbol: string, period: SpotKlineInterval, - pagination?: Pagination, + pagination?: Pagination, ): Promise> { return this.get('/api/spot/v1/market/candles', { symbol, diff --git a/src/types/index.ts b/src/types/index.ts index 82b2b91..86329ba 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,4 @@ -export * from './response'; export * from './request'; +export * from './response'; export * from './shared'; export * from './websockets'; diff --git a/src/types/request/index.ts b/src/types/request/index.ts index 4c25afa..1cf44db 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -1,11 +1,11 @@ -export * from './v1/brokerV1'; -export * from './v1/futuresV1'; -export * from './v1/spotV1'; -export * from './v2/futures'; -export * from './v2/spot'; -export * from './v2/broker'; -export * from './v2/margin'; -export * from './v2/copytrading'; -export * from './v2/earn'; -export * from './shared'; -export * from './v2/common'; +export * from './shared'; +export * from './v1/brokerV1'; +export * from './v1/futuresV1'; +export * from './v1/spotV1'; +export * from './v2/broker'; +export * from './v2/common'; +export * from './v2/copytrading'; +export * from './v2/earn'; +export * from './v2/futures'; +export * from './v2/margin'; +export * from './v2/spot'; diff --git a/src/types/request/shared.ts b/src/types/request/shared.ts index 23b4db4..eb03f3b 100644 --- a/src/types/request/shared.ts +++ b/src/types/request/shared.ts @@ -1,39 +1,39 @@ -/** Pagination */ -export interface Pagination { - /** Time after */ - after?: string; - /** Time before */ - before?: string; - /** Elements per page */ - limit?: string; -} - -export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; - -export interface GetHistoricTradesParams { - symbol: string; - limit?: string; - tradeId?: string; - startTime?: string; - endTime?: string; -} - -/** - * The margin type, used directly in building the endpoint URL - */ -export type MarginType = 'crossed' | 'isolated'; - -export type FuturesProductTypeV2 = - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'SUSDT-FUTURES' - | 'SCOIN-FUTURES' - | 'SUSDC-FUTURES'; - -export type FuturesPlanTypeV2 = - | 'profit_plan' - | 'loss_plan' - | 'moving_plan' - | 'pos_profit' - | 'pos_loss'; +/** Pagination */ +export interface Pagination { + /** Time after */ + after?: string; + /** Time before */ + before?: string; + /** Elements per page */ + limit?: string; +} + +export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; + +export interface GetHistoricTradesParams { + symbol: string; + limit?: string; + tradeId?: string; + startTime?: string; + endTime?: string; +} + +/** + * The margin type, used directly in building the endpoint URL + */ +export type MarginType = 'crossed' | 'isolated'; + +export type FuturesProductTypeV2 = + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES' + | 'SUSDT-FUTURES' + | 'SCOIN-FUTURES' + | 'SUSDC-FUTURES'; + +export type FuturesPlanTypeV2 = + | 'profit_plan' + | 'loss_plan' + | 'moving_plan' + | 'pos_profit' + | 'pos_loss'; diff --git a/src/types/request/v1/futuresV1.ts b/src/types/request/v1/futuresV1.ts index 527e967..0dedc9d 100644 --- a/src/types/request/v1/futuresV1.ts +++ b/src/types/request/v1/futuresV1.ts @@ -226,4 +226,4 @@ export interface HistoricPlanOrderTPSLRequest { * @property {Array[5]} Base currency trading volume * @property {Array[6]} Quote currency trading volume */ -export type FuturesCandleData = string[6]; \ No newline at end of file +export type FuturesCandleData = string[6]; diff --git a/src/types/request/v1/spotV1.ts b/src/types/request/v1/spotV1.ts index 0009c4a..f3f4b85 100644 --- a/src/types/request/v1/spotV1.ts +++ b/src/types/request/v1/spotV1.ts @@ -3,23 +3,23 @@ import { OrderTimeInForce } from '../shared'; export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd'; export type SpotKlineInterval = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' | '1Mutc'; export interface NewWalletTransfer { @@ -135,4 +135,4 @@ export interface SpotCandleData { baseVol: string; usdtVol: string; ts: string; -} \ No newline at end of file +} diff --git a/src/types/request/v2/common.ts b/src/types/request/v2/common.ts index 051273b..a8f60ec 100644 --- a/src/types/request/v2/common.ts +++ b/src/types/request/v2/common.ts @@ -1,187 +1,187 @@ -import { FuturesProductTypeV2, MarginType } from '../shared'; - -/** - * - * * Common | Notice - * - */ - -export interface GetAnnouncementsRequestV2 { - annType?: string; - startTime?: string; - endTime?: string; - language: string; -} - -/** - * - * * Common | Public - * - */ - -export interface GetTradeRateRequestV2 { - symbol: string; - businessType: string; -} - -/** - * - * * Common | Tax - * - */ - -export interface GetSpotTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -export interface GetFuturesTransactionsRequestV2 { - productType?: FuturesProductTypeV2; - marginCoin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -export interface GetMarginTransactionsRequestV2 { - marginType?: MarginType; - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -export interface GetP2PTransactionsRequestV2 { - coin?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -/** - * - * * Common | P2P - * - */ - -export interface GetP2PMerchantsRequestV2 { - online?: 'yes' | 'no'; - idLessThan?: string; - limit?: string; -} - -export interface GetMerchantP2POrdersRequestV2 { - startTime: string; - endTime?: string; - idLessThan?: string; - limit?: string; - status?: string; - advNo: string; - side?: string; - coin?: string; - language: string; - fiat?: string; - orderNo?: string; -} - -export interface GetMerchantAdvertisementsRequestV2 { - startTime: string; - endTime?: string; - idLessThan?: string; - limit?: string; - status: string; - advNo?: string; - side: string; - coin: string; - language?: string; - fiat: string; - orderBy?: string; - payMethodId?: string; - sourceType?: string; -} - -/** - * - * * Common | Virtual Subaccount - * - */ - -export interface ModifyVirtualSubRequestV2 { - subAccountUid: string; - permList: string[]; - status: string; -} - -export interface CreateVirtualSubRequestV2 { - subAccountName: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} - -export interface CreateVirtualSubApiKeyRequestV2 { - subAccountUid: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} - -export interface ModifyVirtualSubApiKeyRequestV2 { - subAccountUid: string; - subAccountApiKey: string; - passphrase: string; - label: string; - ipList?: string[]; - permList?: string[]; -} - -/** - * - * * Common | Convert - * - */ - -export interface ConvertQuoteRequestV2 { - fromCoin: string; - fromCoinSize?: string; - toCoin: string; - toCoinSize?: string; -} - -export interface ConvertRequestV2 { - fromCoin: string; - fromCoinSize: string; - cnvtPrice: string; - toCoin: string; - toCoinSize: string; - traceId: string; -} - -export interface GetConvertHistoryRequestV2 { - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} - -/** - * - * * Common | BGB Convert - * - */ - -export interface GetConvertBGBHistoryRequestV2 { - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; -} +import { FuturesProductTypeV2, MarginType } from '../shared'; + +/** + * + * * Common | Notice + * + */ + +export interface GetAnnouncementsRequestV2 { + annType?: string; + startTime?: string; + endTime?: string; + language: string; +} + +/** + * + * * Common | Public + * + */ + +export interface GetTradeRateRequestV2 { + symbol: string; + businessType: string; +} + +/** + * + * * Common | Tax + * + */ + +export interface GetSpotTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetFuturesTransactionsRequestV2 { + productType?: FuturesProductTypeV2; + marginCoin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetMarginTransactionsRequestV2 { + marginType?: MarginType; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetP2PTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | P2P + * + */ + +export interface GetP2PMerchantsRequestV2 { + online?: 'yes' | 'no'; + idLessThan?: string; + limit?: string; +} + +export interface GetMerchantP2POrdersRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status?: string; + advNo: string; + side?: string; + coin?: string; + language: string; + fiat?: string; + orderNo?: string; +} + +export interface GetMerchantAdvertisementsRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status: string; + advNo?: string; + side: string; + coin: string; + language?: string; + fiat: string; + orderBy?: string; + payMethodId?: string; + sourceType?: string; +} + +/** + * + * * Common | Virtual Subaccount + * + */ + +export interface ModifyVirtualSubRequestV2 { + subAccountUid: string; + permList: string[]; + status: string; +} + +export interface CreateVirtualSubRequestV2 { + subAccountName: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface CreateVirtualSubApiKeyRequestV2 { + subAccountUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface ModifyVirtualSubApiKeyRequestV2 { + subAccountUid: string; + subAccountApiKey: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +/** + * + * * Common | Convert + * + */ + +export interface ConvertQuoteRequestV2 { + fromCoin: string; + fromCoinSize?: string; + toCoin: string; + toCoinSize?: string; +} + +export interface ConvertRequestV2 { + fromCoin: string; + fromCoinSize: string; + cnvtPrice: string; + toCoin: string; + toCoinSize: string; + traceId: string; +} + +export interface GetConvertHistoryRequestV2 { + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | BGB Convert + * + */ + +export interface GetConvertBGBHistoryRequestV2 { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} diff --git a/src/types/request/v2/spot.ts b/src/types/request/v2/spot.ts index 84eb86c..aec28e7 100644 --- a/src/types/request/v2/spot.ts +++ b/src/types/request/v2/spot.ts @@ -1,351 +1,351 @@ -type SpotKlineIntervalV2 = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; - -export interface SpotCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - startTime?: string; - endTime?: string; - limit?: string; -} - -export interface SpotHistoricCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - endTime?: string; - limit?: string; -} - -export interface SpotHistoricTradesRequestV2 { - symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; -} - -/** - * - * * Spot | Trade - * - */ - -export type SpotOrderSideV2 = 'buy' | 'sell'; - -export type SpotOrderTypeV2 = 'limit' | 'market'; - -export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; - -export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; - -export type SpotSTPModeV2 = - | 'none' - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; - -export type SpotBatchModeV2 = 'single' | 'multiple'; - -export interface SpotOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - triggerPrice?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} - -export interface SpotCancelandSubmitOrderRequestV2 { - symbol: string; - price: string; - size: string; - orderId?: string; - clientOid?: string; - newClientOid?: string; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} - -export interface SpotCancelOrderRequestV2 { - symbol: string; - tpslType?: SpotTPSLTypeV2; - orderId?: string; - clientOid?: string; -} - -export interface SpotBatchOrderRequestItemV2 { - symbol?: string; - side: SpotOrderSideV2; - orderType: SpotOrderTypeV2; - force: SpotOrderForceV2; - price?: string; - size: string; - clientOid?: string; - stpMode?: SpotSTPModeV2; - presetTakeProfitPrice?: string; - executeTakeProfitPrice?: string; - presetStopLossPrice?: string; - executeStopLossPrice?: string; -} - -export interface SpotBatchOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: SpotBatchOrderRequestItemV2[]; -} - -export interface SpotBatchCancelOrderRequestV2 { - symbol?: string; - batchMode?: SpotBatchModeV2; - orderList: { - symbol?: string; - orderId?: string; - clientOid?: string; - }[]; -} - -export interface GetSpotOrderInfoRequestV2 { - orderId?: string; - clientOid?: string; - requestTime?: string; - receiveWindow?: string; -} - -export interface GetSpotOpenOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; -} - -export interface GetSpotHistoryOrdersRequestV2 { - symbol?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; - orderId?: string; - tpslType?: SpotTPSLTypeV2; - requestTime?: string; - receiveWindow?: string; -} - -export interface GetSpotFillsRequestV2 { - symbol: string; - orderId?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} - -/** - * - * * Spot | Trigger Orders - * - */ - -export type SpotPlanTypeV2 = 'amount' | 'total'; - -export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; - -export interface SpotPlanOrderRequestV2 { - symbol: string; - side: SpotOrderSideV2; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - planType?: SpotPlanTypeV2; - size: string; - triggerType: SpotTriggerTypeV2; - clientOid?: string; - force?: SpotOrderForceV2; - stpMode?: SpotSTPModeV2; -} - -export interface SpotModifyPlanOrderRequestV2 { - orderId?: string; - clientOid?: string; - triggerPrice: string; - orderType: SpotOrderTypeV2; - executePrice?: string; - size: string; -} - -export interface GetSpotCurrentPlanOrdersRequestV2 { - symbol: string; - limit?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; -} - -export interface GetSpotHistoryPlanOrdersRequestV2 { - symbol: string; - startTime: string; - endTime: string; - limit?: string; -} - -/** - * - * * Spot | Account - * - */ - -export type SpotBillGroupTypeV2 = - | 'deposit' - | 'withdraw' - | 'transaction' - | 'transfer' - | 'other'; - -export type SpotBusinessTypeV2 = - | 'deposit' - | 'withdraw' - | 'buy' - | 'sell' - | 'deduction of handling fee' - | 'transfer-in' - | 'transfer-out' - | 'rebate rewards' - | 'airdrop rewards' - | 'USDT contract rewards' - | 'mix contract rewards' - | 'system lock' - | 'user lock'; - -export type SpotAccountTypeV2 = - | 'spot' - | 'p2p' - | 'coin_futures' - | 'usdt_futures' - | 'usdc_futures' - | 'crossed_margin' - | 'isolated_margin'; - -export interface GetSpotAccountBillsRequestV2 { - coin?: string; - groupType?: SpotBillGroupTypeV2; - businessType?: SpotBusinessTypeV2; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; -} - -export interface SpotTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol: string; - clientOid?: string; -} - -export interface SpotSubAccountTransferRequestV2 { - fromType: SpotAccountTypeV2; - toType: SpotAccountTypeV2; - amount: string; - coin: string; - symbol?: string; - clientOid?: string; - fromUserId: string; - toUserId: string; -} - -export interface SpotWithdrawalRequestV2 { - coin: string; - transferType: 'on_chain' | 'internal_transfer'; - address: string; - chain?: string; - innerToType?: 'email' | 'mobile' | 'uid'; - areaCode?: string; - tag?: string; - size: string; - remark?: string; - clientOid?: string; -} - -export interface SpotMainSubTransferRecordRequestV2 { - coin?: string; - role?: 'initiator' | 'receiver'; - subUid?: string; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; -} - -export interface GetSpotTransferRecordRequestV2 { - coin: string; - fromType: SpotAccountTypeV2; - startTime?: string; - endTime?: string; - clientOid?: string; - limit?: string; - idLessThan?: string; -} - -export interface GetSpotSubAccountDepositRecordRequestV2 { - subUid: string; - coin?: string; - startTime?: string; - endTime?: string; - idLessThan?: string; - limit?: string; -} - -export interface GetSpotWithdrawalRecordRequestV2 { - coin?: string; - clientOid?: string; - startTime: string; - endTime: string; - idLessThan?: string; - orderId?: string; - limit?: string; -} - -export interface GetSpotDepositRecordRequestV2 { - coin?: string; - orderId?: string; - startTime: string; - endTime: string; - idLessThan?: string; - limit?: string; -} +type SpotKlineIntervalV2 = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; + +export interface SpotCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface SpotHistoricCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + endTime?: string; + limit?: string; +} + +export interface SpotHistoricTradesRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * * Spot | Trade + * + */ + +export type SpotOrderSideV2 = 'buy' | 'sell'; + +export type SpotOrderTypeV2 = 'limit' | 'market'; + +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; + +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; + +export type SpotSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export type SpotBatchModeV2 = 'single' | 'multiple'; + +export interface SpotOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelandSubmitOrderRequestV2 { + symbol: string; + price: string; + size: string; + orderId?: string; + clientOid?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelOrderRequestV2 { + symbol: string; + tpslType?: SpotTPSLTypeV2; + orderId?: string; + clientOid?: string; +} + +export interface SpotBatchOrderRequestItemV2 { + symbol?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotBatchOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: SpotBatchOrderRequestItemV2[]; +} + +export interface SpotBatchCancelOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; +} + +export interface GetSpotOrderInfoRequestV2 { + orderId?: string; + clientOid?: string; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotOpenOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotHistoryOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotFillsRequestV2 { + symbol: string; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Spot | Trigger Orders + * + */ + +export type SpotPlanTypeV2 = 'amount' | 'total'; + +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; + +export interface SpotPlanOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + planType?: SpotPlanTypeV2; + size: string; + triggerType: SpotTriggerTypeV2; + clientOid?: string; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; +} + +export interface SpotModifyPlanOrderRequestV2 { + orderId?: string; + clientOid?: string; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + size: string; +} + +export interface GetSpotCurrentPlanOrdersRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +export interface GetSpotHistoryPlanOrdersRequestV2 { + symbol: string; + startTime: string; + endTime: string; + limit?: string; +} + +/** + * + * * Spot | Account + * + */ + +export type SpotBillGroupTypeV2 = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; + +export type SpotBusinessTypeV2 = + | 'deposit' + | 'withdraw' + | 'buy' + | 'sell' + | 'deduction of handling fee' + | 'transfer-in' + | 'transfer-out' + | 'rebate rewards' + | 'airdrop rewards' + | 'USDT contract rewards' + | 'mix contract rewards' + | 'system lock' + | 'user lock'; + +export type SpotAccountTypeV2 = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; + +export interface GetSpotAccountBillsRequestV2 { + coin?: string; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface SpotTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol: string; + clientOid?: string; +} + +export interface SpotSubAccountTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; +} + +export interface SpotWithdrawalRequestV2 { + coin: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + chain?: string; + innerToType?: 'email' | 'mobile' | 'uid'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; +} + +export interface SpotMainSubTransferRecordRequestV2 { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotTransferRecordRequestV2 { + coin: string; + fromType: SpotAccountTypeV2; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotSubAccountDepositRecordRequestV2 { + subUid: string; + coin?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; +} + +export interface GetSpotWithdrawalRecordRequestV2 { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; + limit?: string; +} + +export interface GetSpotDepositRecordRequestV2 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + idLessThan?: string; + limit?: string; +} diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 0c86356..e42f90e 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -1,3 +1,3 @@ +export * from './futures'; export * from './shared'; export * from './spot'; -export * from './futures'; diff --git a/src/types/shared.ts b/src/types/shared.ts index b125ec3..6c9e9a9 100644 --- a/src/types/shared.ts +++ b/src/types/shared.ts @@ -27,4 +27,4 @@ export type KlineInterval = | '1Mutc'; export type RestClientType = - typeof REST_CLIENT_TYPE_ENUM[keyof typeof REST_CLIENT_TYPE_ENUM]; + (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM]; diff --git a/src/util/BaseRestClient.ts b/src/util/BaseRestClient.ts index 4e74d74..beba6f9 100644 --- a/src/util/BaseRestClient.ts +++ b/src/util/BaseRestClient.ts @@ -1,15 +1,15 @@ import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios'; -import { RestClientType } from '../types'; +import { RestClientType } from '../types'; import { signMessage } from './node-support'; import { + getRestBaseUrl, RestClientOptions, serializeParams, - getRestBaseUrl, } from './requestUtils'; import { neverGuard } from './websocket-util'; -interface SignedRequest { +interface SignedRequest { originalParams: T; paramsWithSign?: T & { sign: string }; serializedParams: string; @@ -19,7 +19,7 @@ interface SignedRequest { recvWindow: number; } -interface UnsignedRequest { +interface UnsignedRequest { originalParams: T; paramsWithSign: T; } @@ -229,7 +229,7 @@ export default abstract class BaseRestClient { /** * @private sign request and set recv window */ - private async signRequest( + private async signRequest( data: T, endpoint: string, method: Method, diff --git a/src/util/BaseWSClient.ts b/src/util/BaseWSClient.ts index 32d79df..e4f55e5 100644 --- a/src/util/BaseWSClient.ts +++ b/src/util/BaseWSClient.ts @@ -5,12 +5,12 @@ import WebSocket from 'isomorphic-ws'; import { WebsocketClientOptions, WSClientConfigurableOptions, -} from '../types/index.js'; -import { DefaultLogger } from './logger.js'; -import { isWsPong } from './requestUtils.js'; -import { getWsAuthSignature } from './websocket-util.js'; -import WsStore from './WsStore.js'; -import { WsConnectionStateEnum } from './WsStore.types.js'; +} from '../types/index'; +import { DefaultLogger } from './logger'; +import { isWsPong } from './requestUtils'; +import { getWsAuthSignature } from './websocket-util'; +import WsStore from './WsStore'; +import { WsConnectionStateEnum } from './WsStore.types'; interface WSClientEventMap { /** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */ diff --git a/src/util/WsStore.ts b/src/util/WsStore.ts index 19f990d..9a609dc 100644 --- a/src/util/WsStore.ts +++ b/src/util/WsStore.ts @@ -1,4 +1,5 @@ import WebSocket from 'isomorphic-ws'; + import { DefaultLogger } from './logger'; import { WsConnectionStateEnum, WsStoredState } from './WsStore.types'; diff --git a/src/util/browser-support.ts b/src/util/browser-support.ts index 3633549..f4a4fd2 100644 --- a/src/util/browser-support.ts +++ b/src/util/browser-support.ts @@ -40,6 +40,7 @@ export async function signMessage( return _arrayBufferToBase64(signature); } default: { + // eslint-disable-next-line @typescript-eslint/no-unused-vars ((x: never) => {})(method); throw new Error(`Unhandled sign method: ${method}`); } diff --git a/src/util/index.ts b/src/util/index.ts index fd92581..6c491bd 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -1,6 +1,6 @@ export * from './BaseRestClient'; -export * from './requestUtils'; -export * from './WsStore'; export * from './logger'; +export * from './requestUtils'; export * from './type-guards'; export * from './websocket-util'; +export * from './WsStore'; diff --git a/src/util/logger.ts b/src/util/logger.ts index a0b2379..d5a585c 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -1,6 +1,7 @@ export type LogParams = null | any; export const DefaultLogger = { + // eslint-disable-next-line @typescript-eslint/no-unused-vars silly: (...params: LogParams): void => { // console.log(params); }, diff --git a/src/util/node-support.ts b/src/util/node-support.ts index 4afe4b6..7472e15 100644 --- a/src/util/node-support.ts +++ b/src/util/node-support.ts @@ -16,6 +16,7 @@ export async function signMessage( return hmac.digest().toString('base64'); } default: { + // eslint-disable-next-line @typescript-eslint/no-unused-vars ((x: never) => {})(method); throw new Error(`Unhandled sign method: ${method}`); } diff --git a/src/util/requestUtils.ts b/src/util/requestUtils.ts index 6f831f0..90ea006 100644 --- a/src/util/requestUtils.ts +++ b/src/util/requestUtils.ts @@ -34,7 +34,7 @@ export interface RestClientOptions { parseExceptions?: boolean; } -export function serializeParams( +export function serializeParams( params: T, strict_validation = false, encodeValues: boolean = true, diff --git a/src/util/websocket-util.ts b/src/util/websocket-util.ts index 36ffc27..ac9c956 100644 --- a/src/util/websocket-util.ts +++ b/src/util/websocket-util.ts @@ -95,6 +95,7 @@ export function isPrivateChannel( export function getWsKeyForTopic( subscribeEvent: WsTopicSubscribeEventArgs, + // eslint-disable-next-line @typescript-eslint/no-unused-vars isPrivate?: boolean, ): WsKey { const instType = subscribeEvent.instType.toUpperCase() as BitgetInstType; diff --git a/src/websocket-client-v2.ts b/src/websocket-client-v2.ts index c124d28..6d0c6af 100644 --- a/src/websocket-client-v2.ts +++ b/src/websocket-client-v2.ts @@ -12,17 +12,15 @@ import { WsTopicSubscribePrivateInstIdArgsV2, WsTopicV2, } from './types'; - import { - WS_AUTH_ON_CONNECT_KEYS, - WS_KEY_MAP, DefaultLogger, - WS_BASE_URL_MAP, - neverGuard, getMaxTopicsPerSubscribeEvent, isPrivateChannel, + neverGuard, + WS_AUTH_ON_CONNECT_KEYS, + WS_BASE_URL_MAP, + WS_KEY_MAP, } from './util'; - import { BaseWebsocketClient } from './util/BaseWSClient'; const LOGGER_CATEGORY = { category: 'bitget-ws' }; diff --git a/src/websocket-client.ts b/src/websocket-client.ts index cf7ab28..d12b870 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -1,8 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ import { EventEmitter } from 'events'; import WebSocket from 'isomorphic-ws'; -import WsStore from './util/WsStore'; - import { BitgetInstType, WebsocketClientOptions, @@ -11,19 +10,19 @@ import { WsTopic, WsTopicSubscribeEventArgs, } from './types'; - import { - isWsPong, - WS_AUTH_ON_CONNECT_KEYS, - WS_KEY_MAP, DefaultLogger, - WS_BASE_URL_MAP, - getWsKeyForTopic, - neverGuard, getMaxTopicsPerSubscribeEvent, - isPrivateChannel, getWsAuthSignature, + getWsKeyForTopic, + isPrivateChannel, + isWsPong, + neverGuard, + WS_AUTH_ON_CONNECT_KEYS, + WS_BASE_URL_MAP, + WS_KEY_MAP, } from './util'; +import WsStore from './util/WsStore'; import { WsConnectionStateEnum } from './util/WsStore.types'; const LOGGER_CATEGORY = { category: 'bitget-ws' }; @@ -387,7 +386,7 @@ export class WebsocketClient extends EventEmitter { this.logger.silly( `Subscribing to topics in batches of ${maxTopicsPerEvent}`, ); - for (var i = 0; i < topics.length; i += maxTopicsPerEvent) { + for (let i = 0; i < topics.length; i += maxTopicsPerEvent) { const batch = topics.slice(i, i + maxTopicsPerEvent); this.logger.silly(`Subscribing to batch of ${batch.length}`); this.requestSubscribeTopics(wsKey, batch); @@ -422,7 +421,7 @@ export class WebsocketClient extends EventEmitter { this.logger.silly( `Unsubscribing to topics in batches of ${maxTopicsPerEvent}`, ); - for (var i = 0; i < topics.length; i += maxTopicsPerEvent) { + for (let i = 0; i < topics.length; i += maxTopicsPerEvent) { const batch = topics.slice(i, i + maxTopicsPerEvent); this.logger.silly(`Unsubscribing to batch of ${batch.length}`); this.requestUnsubscribeTopics(wsKey, batch); diff --git a/test/broker/private.read.test.ts b/test/broker/private.read.test.ts index cb92c57..f881293 100644 --- a/test/broker/private.read.test.ts +++ b/test/broker/private.read.test.ts @@ -20,9 +20,9 @@ describe('Private Broker REST API GET Endpoints', () => { const coin = 'BTC'; const subUid = '123456'; - const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; - const from = timestampOneHourAgo.toFixed(0); - const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes + // const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; + // const from = timestampOneHourAgo.toFixed(0); + // const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes it('getBrokerInfo()', async () => { try { diff --git a/test/broker/private.write.test.ts b/test/broker/private.write.test.ts index 32d8c3a..8fb7448 100644 --- a/test/broker/private.write.test.ts +++ b/test/broker/private.write.test.ts @@ -18,11 +18,11 @@ describe('Private Broker REST API POST Endpoints', () => { apiPass: API_PASS, }); - const coin = 'BTC'; + // const coin = 'BTC'; const subUid = '123456'; - const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; - const from = timestampOneHourAgo.toFixed(0); - const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes + // const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; + // const from = timestampOneHourAgo.toFixed(0); + // const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes it('createSubAccount()', async () => { try { diff --git a/test/futures/private.write.test.ts b/test/futures/private.write.test.ts index 497f631..7ded747 100644 --- a/test/futures/private.write.test.ts +++ b/test/futures/private.write.test.ts @@ -22,9 +22,9 @@ describe('Private Futures REST API POST Endpoints', () => { const symbol = 'BTCUSDT_UMCBL'; const marginCoin = 'USDT'; - const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; - const from = timestampOneHourAgo.toFixed(0); - const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes + // const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60; + // const from = timestampOneHourAgo.toFixed(0); + // const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes it('setLeverage()', async () => { try { diff --git a/test/futures/public.test.ts b/test/futures/public.test.ts index ba1ea96..1b497e1 100644 --- a/test/futures/public.test.ts +++ b/test/futures/public.test.ts @@ -1,9 +1,5 @@ -import { API_ERROR_CODE, FuturesClient } from '../../src'; -import { - notAuthenticatedError, - successResponseString, - sucessEmptyResponseObject, -} from '../response.util'; +import { FuturesClient } from '../../src'; +import { sucessEmptyResponseObject } from '../response.util'; describe('Public Spot REST API Endpoints', () => { const api = new FuturesClient(); diff --git a/test/spot/private.read.test.ts b/test/spot/private.read.test.ts index 8815caa..761a4a6 100644 --- a/test/spot/private.read.test.ts +++ b/test/spot/private.read.test.ts @@ -1,4 +1,4 @@ -import { API_ERROR_CODE, SpotClient } from '../../src'; +import { SpotClient } from '../../src'; import { sucessEmptyResponseObject } from '../response.util'; describe('Private Spot REST API GET Endpoints', () => { diff --git a/test/spot/public.test.ts b/test/spot/public.test.ts index b802a1e..29eed0c 100644 --- a/test/spot/public.test.ts +++ b/test/spot/public.test.ts @@ -1,6 +1,5 @@ -import { API_ERROR_CODE, SpotClient } from '../../src'; +import { SpotClient } from '../../src'; import { - notAuthenticatedError, successResponseString, sucessEmptyResponseObject, } from '../response.util'; @@ -9,8 +8,6 @@ describe('Public Spot REST API Endpoints', () => { const api = new SpotClient(); const symbol = 'BTCUSDT_SPBL'; - const timestampOneHourAgo = new Date().getTime() / 1000 - 1000 * 60 * 60; - const from = Number(timestampOneHourAgo.toFixed(0)); // it('should throw for unauthenticated private calls', async () => { // expect(() => api.getOpenOrders()).rejects.toMatchObject( diff --git a/test/ws.private.test.ts b/test/ws.private.test.ts index 6c75ecd..c62fd95 100644 --- a/test/ws.private.test.ts +++ b/test/ws.private.test.ts @@ -1,15 +1,10 @@ import { WebsocketClient, - WSClientConfigurableOptions, WS_ERROR_ENUM, WS_KEY_MAP, + WSClientConfigurableOptions, } from '../src'; -import { - getSilentLogger, - listenToSocketEvents, - logAllEvents, - waitForSocketEvent, -} from './ws.util'; +import { getSilentLogger, logAllEvents, waitForSocketEvent } from './ws.util'; describe.skip('Private Spot Websocket Client', () => { const API_KEY = process.env.API_KEY_COM; @@ -50,7 +45,7 @@ describe.skip('Private Spot Websocket Client', () => { try { await Promise.all([wsResponsePromise]); } catch (e) { - // console.error() + console.error(e); } badClient.closeAll(); }); diff --git a/test/ws.public.test.ts b/test/ws.public.test.ts index 0b6539b..63c4c7f 100644 --- a/test/ws.public.test.ts +++ b/test/ws.public.test.ts @@ -1,9 +1,9 @@ import { WebsocketClient, - WSClientConfigurableOptions, WS_KEY_MAP, + WSClientConfigurableOptions, } from '../src'; -import { logAllEvents, getSilentLogger, waitForSocketEvent } from './ws.util'; +import { getSilentLogger, logAllEvents, waitForSocketEvent } from './ws.util'; describe('Public Spot Websocket Client', () => { let wsClient: WebsocketClient; diff --git a/test/ws.util.ts b/test/ws.util.ts index 2e3e449..223880d 100644 --- a/test/ws.util.ts +++ b/test/ws.util.ts @@ -1,5 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { WebsocketClient } from '../src'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function getSilentLogger(logHint?: string) { return { silly: () => {}, From d363c51b2bc7559eb65cab9d029fbc01192e5a75 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 11 Dec 2024 16:40:54 +0000 Subject: [PATCH 3/6] chore(): fix and run linter, bump node version to LTS --- .eslintrc.cjs | 21 +- .gitignore | 3 +- .nvmrc | 2 +- src/rest-client-v2.ts | 461 +++++++++++++++++---------------- src/types/websockets/events.ts | 24 +- src/util/BaseRestClient.ts | 7 + src/util/BaseWSClient.ts | 13 +- src/util/WsStore.ts | 3 + src/util/type-guards.ts | 2 +- src/util/websocket-util.ts | 4 +- src/websocket-client-v2.ts | 5 +- src/websocket-client.ts | 17 +- tsconfig.linting.json | 3 +- webpack/webpack.config.js | 52 ++-- 14 files changed, 330 insertions(+), 287 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 71a433c..f14285a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -20,7 +20,7 @@ module.exports = { node: true, jest: true, }, - ignorePatterns: ['.eslintrc.js'], + ignorePatterns: ['.eslintrc.js', 'webpack.config.js'], rules: { '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/explicit-function-return-type': 'off', @@ -30,5 +30,24 @@ module.exports = { '@typescript-eslint/ban-types': 'off', 'simple-import-sort/imports': 'error', 'simple-import-sort/exports': 'error', + 'array-bracket-spacing': ['error', 'never'], + 'linebreak-style': ['error', 'unix'], + 'lines-between-class-members': ['warn', 'always'], + semi: ['error', 'always'], + 'new-cap': 'off', + 'no-console': 'off', + 'no-debugger': 'off', + 'no-mixed-spaces-and-tabs': 2, + 'no-use-before-define': [2, 'nofunc'], + 'no-unreachable': ['warn'], + // 'no-unused-vars': ['warn'], + 'no-extra-parens': ['off'], + 'no-mixed-operators': ['off'], + quotes: [2, 'single', 'avoid-escape'], + 'block-scoped-var': 2, + 'brace-style': [2, '1tbs', { allowSingleLine: true }], + 'computed-property-spacing': [2, 'never'], + 'keyword-spacing': 2, + 'space-unary-ops': 2, }, }; diff --git a/.gitignore b/.gitignore index adabcaf..aef300a 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ tiagoSpot.ts restClientRegex.ts localtest.sh privaterepotracker -testfile.ts \ No newline at end of file +testfile.ts +dist diff --git a/.nvmrc b/.nvmrc index 95c758c..bb8c76c 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.12.1 \ No newline at end of file +v22.11.0 diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 5b1cef3..2e71d7f 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -237,7 +237,7 @@ export class RestClientV2 extends BaseRestClient { getAnnouncements( params?: GetAnnouncementsRequestV2, ): Promise> { - return this.get(`/api/v2/public/annoucements`, params); + return this.get('/api/v2/public/annoucements', params); } /** @@ -247,11 +247,11 @@ export class RestClientV2 extends BaseRestClient { */ getServerTime(): Promise> { - return this.get(`/api/v2/public/time`); + return this.get('/api/v2/public/time'); } getTradeRate(params: GetTradeRateRequestV2): Promise> { - return this.getPrivate(`/api/v2/common/trade-rate`, params); + return this.getPrivate('/api/v2/common/trade-rate', params); } /** @@ -263,25 +263,25 @@ export class RestClientV2 extends BaseRestClient { getSpotTransactionRecords( params: GetSpotTransactionsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/tax/spot-record`, params); + return this.getPrivate('/api/v2/tax/spot-record', params); } getFuturesTransactionRecords( params: GetFuturesTransactionsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/tax/future-record`, params); + return this.getPrivate('/api/v2/tax/future-record', params); } getMarginTransactionRecords( params: GetMarginTransactionsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/tax/margin-record`, params); + return this.getPrivate('/api/v2/tax/margin-record', params); } getP2PTransactionRecords( params: GetP2PTransactionsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/tax/p2p-record`, params); + return this.getPrivate('/api/v2/tax/p2p-record', params); } /** @@ -293,23 +293,23 @@ export class RestClientV2 extends BaseRestClient { getP2PMerchantList( params?: GetP2PMerchantsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/p2p/merchantList`, params); + return this.getPrivate('/api/v2/p2p/merchantList', params); } getP2PMerchantInfo(): Promise> { - return this.getPrivate(`/api/v2/p2p/merchantInfo`); + return this.getPrivate('/api/v2/p2p/merchantInfo'); } getP2PMerchantOrders( params: GetMerchantP2POrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/p2p/orderList`, params); + return this.getPrivate('/api/v2/p2p/orderList', params); } getP2PMerchantAdvertisementList( params: GetMerchantAdvertisementsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/p2p/advList`, params); + return this.getPrivate('/api/v2/p2p/advList', params); } /** @@ -321,21 +321,21 @@ export class RestClientV2 extends BaseRestClient { getSpotWhaleNetFlowData(params: { symbol: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/market/whale-net-flow`, params); + return this.getPrivate('/api/v2/spot/market/whale-net-flow', params); } getFuturesActiveTakerBuySellVolumeData(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/mix/market/taker-buy-sell`, params); + return this.get('/api/v2/mix/market/taker-buy-sell', params); } getFuturesActiveLongShortPositionData(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/mix/market/position-long-short`, params); + return this.get('/api/v2/mix/market/position-long-short', params); } getFuturesLongShortRatio(params: { @@ -343,7 +343,7 @@ export class RestClientV2 extends BaseRestClient { period?: string; coin?: string; }): Promise> { - return this.get(`/api/v2/mix/market/long-short-ratio`, params); + return this.get('/api/v2/mix/market/long-short-ratio', params); } getMarginLoanGrowthRate(params: { @@ -351,45 +351,45 @@ export class RestClientV2 extends BaseRestClient { period?: string; coin?: string; }): Promise> { - return this.get(`/api/v2/mix/market/loan-growth`, params); + return this.get('/api/v2/mix/market/loan-growth', params); } getIsolatedMarginBorrowingRatio(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/mix/market/isolated-borrow-rate`, params); + return this.get('/api/v2/mix/market/isolated-borrow-rate', params); } getFuturesActiveBuySellVolumeData(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/mix/market/long-short`, params); + return this.get('/api/v2/mix/market/long-short', params); } getSpotFundFlow(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/spot/market/fund-flow`, params); + return this.get('/api/v2/spot/market/fund-flow', params); } getTradeDataSupportSymbols(): Promise> { - return this.get(`/api/v2/spot/market/support-symbols`); + return this.get('/api/v2/spot/market/support-symbols'); } getSpotFundNetFlowData(params: { symbol: string; }): Promise> { - return this.get(`/api/v2/spot/market/fund-net-flow`, params); + return this.get('/api/v2/spot/market/fund-net-flow', params); } getFuturesActiveLongShortAccountData(params: { symbol: string; period?: string; }): Promise> { - return this.get(`/api/v2/mix/market/account-long-short`, params); + return this.get('/api/v2/mix/market/account-long-short', params); } /** @@ -401,13 +401,13 @@ export class RestClientV2 extends BaseRestClient { createVirtualSubaccount(params: { subAccountList: string[]; }): Promise> { - return this.postPrivate(`/api/v2/user/create-virtual-subaccount`, params); + return this.postPrivate('/api/v2/user/create-virtual-subaccount', params); } modifyVirtualSubaccount( params: ModifyVirtualSubRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/user/modify-virtual-subaccount`, params); + return this.postPrivate('/api/v2/user/modify-virtual-subaccount', params); } batchCreateVirtualSubaccountAndAPIKey( @@ -424,7 +424,7 @@ export class RestClientV2 extends BaseRestClient { idLessThan?: string; status?: 'normal' | 'freeze'; }): Promise> { - return this.getPrivate(`/api/v2/user/virtual-subaccount-list`, params); + return this.getPrivate('/api/v2/user/virtual-subaccount-list', params); } createVirtualSubaccountAPIKey( @@ -460,16 +460,16 @@ export class RestClientV2 extends BaseRestClient { * */ getFundingAssets(params?: { coin?: string }): Promise> { - return this.getPrivate(`/api/v2/account/funding-assets`, params); + return this.getPrivate('/api/v2/account/funding-assets', params); } getBotAccount(params?: { accountType?: string }): Promise> { - return this.getPrivate(`/api/v2/account/bot-assets`, params); + return this.getPrivate('/api/v2/account/bot-assets', params); } /** Get assets overview */ getBalances(): Promise> { - return this.getPrivate(`/api/v2/account/all-account-balance`); + return this.getPrivate('/api/v2/account/all-account-balance'); } /** @@ -479,23 +479,23 @@ export class RestClientV2 extends BaseRestClient { */ getConvertCoins(): Promise> { - return this.getPrivate(`/api/v2/convert/currencies`); + return this.getPrivate('/api/v2/convert/currencies'); } getConvertQuotedPrice( params: ConvertQuoteRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/convert/quoted-price`, params); + return this.getPrivate('/api/v2/convert/quoted-price', params); } convert(params: ConvertRequestV2): Promise> { - return this.postPrivate(`/api/v2/convert/trade`, params); + return this.postPrivate('/api/v2/convert/trade', params); } getConvertHistory( params: GetConvertHistoryRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/convert/convert-record`, params); + return this.getPrivate('/api/v2/convert/convert-record', params); } /** @@ -505,17 +505,17 @@ export class RestClientV2 extends BaseRestClient { */ getConvertBGBCoins(): Promise> { - return this.getPrivate(`/api/v2/convert/bgb-convert-coin-list`); + return this.getPrivate('/api/v2/convert/bgb-convert-coin-list'); } convertBGB(params: { coinList: string }): Promise> { - return this.postPrivate(`/api/v2/convert/bgb-convert`, params); + return this.postPrivate('/api/v2/convert/bgb-convert', params); } getConvertBGBHistory( params: GetConvertBGBHistoryRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/convert/bgb-convert-records`, params); + return this.getPrivate('/api/v2/convert/bgb-convert-records', params); } /** @@ -533,19 +533,19 @@ export class RestClientV2 extends BaseRestClient { */ getSpotCoinInfo(params?: { coin?: string }): Promise> { - return this.getPrivate(`/api/v2/spot/public/coins`, params); + return this.getPrivate('/api/v2/spot/public/coins', params); } getSpotSymbolInfo(params?: { symbol?: string }): Promise> { - return this.getPrivate(`/api/v2/spot/public/symbols`, params); + return this.getPrivate('/api/v2/spot/public/symbols', params); } getSpotVIPFeeRate(): Promise> { - return this.getPrivate(`/api/v2/spot/market/vip-fee-rate`); + return this.getPrivate('/api/v2/spot/market/vip-fee-rate'); } getSpotTicker(params?: { symbol?: string }): Promise> { - return this.getPrivate(`/api/v2/spot/market/tickers`, params); + return this.getPrivate('/api/v2/spot/market/tickers', params); } getSpotMergeDepth(params: { @@ -553,7 +553,7 @@ export class RestClientV2 extends BaseRestClient { precision?: string; limit?: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/market/merge-depth`, params); + return this.getPrivate('/api/v2/spot/market/merge-depth', params); } getSpotOrderBookDepth(params: { @@ -561,30 +561,30 @@ export class RestClientV2 extends BaseRestClient { type?: string; limit?: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/market/orderbook`, params); + return this.getPrivate('/api/v2/spot/market/orderbook', params); } getSpotCandles(params: SpotCandlesRequestV2): Promise> { - return this.getPrivate(`/api/v2/spot/market/candles`, params); + return this.getPrivate('/api/v2/spot/market/candles', params); } getSpotHistoricCandles( params: SpotHistoricCandlesRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/market/history-candles`, params); + return this.getPrivate('/api/v2/spot/market/history-candles', params); } getSpotRecentTrades(params: { symbol: string; limit?: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/market/fills`, params); + return this.getPrivate('/api/v2/spot/market/fills', params); } getSpotHistoricTrades( params: SpotHistoricTradesRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/market/fills-history`, params); + return this.getPrivate('/api/v2/spot/market/fills-history', params); } /** @@ -594,62 +594,62 @@ export class RestClientV2 extends BaseRestClient { */ spotSubmitOrder(params: SpotOrderRequestV2): Promise> { - return this.postPrivate(`/api/v2/spot/trade/place-order`, params); + return this.postPrivate('/api/v2/spot/trade/place-order', params); } spotCancelandSubmitOrder( params: SpotCancelandSubmitOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/trade/cancel-replace-order`, params); + return this.postPrivate('/api/v2/spot/trade/cancel-replace-order', params); } spotBatchCancelandSubmitOrder(params: { orderList: SpotCancelandSubmitOrderRequestV2[]; }): Promise> { return this.postPrivate( - `/api/v2/spot/trade/batch-cancel-replace-order`, + '/api/v2/spot/trade/batch-cancel-replace-order', params, ); } spotCancelOrder(params: SpotCancelOrderRequestV2): Promise> { - return this.postPrivate(`/api/v2/spot/trade/cancel-order`, params); + return this.postPrivate('/api/v2/spot/trade/cancel-order', params); } spotBatchSubmitOrders( params: SpotBatchOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/trade/batch-orders`, params); + return this.postPrivate('/api/v2/spot/trade/batch-orders', params); } spotBatchCancelOrders( params: SpotBatchCancelOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/trade/batch-cancel-order`, params); + return this.postPrivate('/api/v2/spot/trade/batch-cancel-order', params); } spotCancelSymbolOrder(params: { symbol: string }): Promise> { - return this.postPrivate(`/api/v2/spot/trade/cancel-symbol-order`, params); + return this.postPrivate('/api/v2/spot/trade/cancel-symbol-order', params); } getSpotOrder(params?: GetSpotOrderInfoRequestV2): Promise> { - return this.getPrivate(`/api/v2/spot/trade/orderInfo`, params); + return this.getPrivate('/api/v2/spot/trade/orderInfo', params); } getSpotOpenOrders( params?: GetSpotOpenOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/trade/unfilled-orders`, params); + return this.getPrivate('/api/v2/spot/trade/unfilled-orders', params); } getSpotHistoricOrders( params?: GetSpotHistoryOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/trade/history-orders`, params); + return this.getPrivate('/api/v2/spot/trade/history-orders', params); } getSpotFills(params: GetSpotFillsRequestV2): Promise> { - return this.getPrivate(`/api/v2/spot/trade/fills`, params); + return this.getPrivate('/api/v2/spot/trade/fills', params); } /** @@ -661,38 +661,38 @@ export class RestClientV2 extends BaseRestClient { spotSubmitPlanOrder( params: SpotPlanOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/trade/place-plan-order`, params); + return this.postPrivate('/api/v2/spot/trade/place-plan-order', params); } spotModifyPlanOrder( params: SpotModifyPlanOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/trade/modify-plan-order`, params); + return this.postPrivate('/api/v2/spot/trade/modify-plan-order', params); } spotCancelPlanOrder(params: { clientOid?: string; orderId?: string; }): Promise> { - return this.postPrivate(`/api/v2/spot/trade/cancel-plan-order`, params); + return this.postPrivate('/api/v2/spot/trade/cancel-plan-order', params); } getSpotCurrentPlanOrders( params: GetSpotCurrentPlanOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/trade/current-plan-order`, params); + return this.getPrivate('/api/v2/spot/trade/current-plan-order', params); } getSpotPlanSubOrder(params: { planOrderId: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/trade/plan-sub-order`, params); + return this.getPrivate('/api/v2/spot/trade/plan-sub-order', params); } getSpotHistoricPlanOrders( params: GetSpotHistoryPlanOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/trade/history-plan-order`, params); + return this.getPrivate('/api/v2/spot/trade/history-plan-order', params); } spotCancelPlanOrders(params?: { @@ -711,18 +711,18 @@ export class RestClientV2 extends BaseRestClient { */ getSpotAccount(): Promise> { - return this.getPrivate(`/api/v2/spot/account/info`); + return this.getPrivate('/api/v2/spot/account/info'); } getSpotAccountAssets(params?: { coin?: string; assetType?: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/account/assets`, params); + return this.getPrivate('/api/v2/spot/account/assets', params); } getSpotSubAccountAssets(): Promise> { - return this.getPrivate(`/api/v2/spot/account/subaccount-assets`); + return this.getPrivate('/api/v2/spot/account/subaccount-assets'); } spotModifyDepositAccount(params: { @@ -730,7 +730,7 @@ export class RestClientV2 extends BaseRestClient { coin: string; }): Promise> { return this.postPrivate( - `/api/v2/spot/wallet/modify-deposit-account`, + '/api/v2/spot/wallet/modify-deposit-account', params, ); } @@ -738,35 +738,35 @@ export class RestClientV2 extends BaseRestClient { getSpotAccountBills( params?: GetSpotAccountBillsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/account/bills`, params); + return this.getPrivate('/api/v2/spot/account/bills', params); } spotTransfer(params: SpotTransferRequestV2): Promise> { - return this.postPrivate(`/api/v2/spot/wallet/transfer`, params); + return this.postPrivate('/api/v2/spot/wallet/transfer', params); } getSpotTransferableCoins(params: { fromType: SpotAccountTypeV2; toType: SpotAccountTypeV2; }): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/transfer-coin-info`, params); + return this.getPrivate('/api/v2/spot/wallet/transfer-coin-info', params); } spotSubTransfer( params: SpotSubAccountTransferRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/spot/wallet/subaccount-transfer`, params); + return this.postPrivate('/api/v2/spot/wallet/subaccount-transfer', params); } spotWithdraw(params: SpotWithdrawalRequestV2): Promise> { - return this.postPrivate(`/api/v2/spot/wallet/withdrawal`, params); + return this.postPrivate('/api/v2/spot/wallet/withdrawal', params); } getSpotMainSubTransferRecord( params: SpotMainSubTransferRecordRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/spot/account/sub-main-trans-record`, + '/api/v2/spot/account/sub-main-trans-record', params, ); } @@ -774,11 +774,11 @@ export class RestClientV2 extends BaseRestClient { getSpotTransferHistory( params: GetSpotTransferRecordRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/account/transferRecords`, params); + return this.getPrivate('/api/v2/spot/account/transferRecords', params); } spotSwitchBGBDeduct(params: { deduct: boolean }): Promise> { - return this.postPrivate(`/api/v2/spot/account/switch-deduct`, params); + return this.postPrivate('/api/v2/spot/account/switch-deduct', params); } getSpotDepositAddress(params: { @@ -786,7 +786,7 @@ export class RestClientV2 extends BaseRestClient { chain?: string; size: string; }): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/deposit-address`, params); + return this.getPrivate('/api/v2/spot/wallet/deposit-address', params); } getSpotSubDepositAddress(params: { @@ -796,23 +796,24 @@ export class RestClientV2 extends BaseRestClient { size: string; }): Promise> { return this.getPrivate( - `/api/v2/spot/wallet/subaccount-deposit-address`, + '/api/v2/spot/wallet/subaccount-deposit-address', params, ); } + getSpotBGBDeductInfo(): Promise> { - return this.getPrivate(`/api/v2/spot/account/deduct-info`); + return this.getPrivate('/api/v2/spot/account/deduct-info'); } spotCancelWithdrawal(params: { orderId: string }): Promise> { - return this.postPrivate(`/api/v2/spot/wallet/cancel-withdrawal`, params); + return this.postPrivate('/api/v2/spot/wallet/cancel-withdrawal', params); } getSubAccountDepositRecords( params: GetSpotSubAccountDepositRecordRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/spot/wallet/subaccount-deposit-records`, + '/api/v2/spot/wallet/subaccount-deposit-records', params, ); } @@ -820,13 +821,13 @@ export class RestClientV2 extends BaseRestClient { getSpotDepositHistory( params: GetSpotDepositRecordRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/deposit-records`, params); + return this.getPrivate('/api/v2/spot/wallet/deposit-records', params); } getSpotWithdrawalHistory( params: GetSpotWithdrawalRecordRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/withdrawal-records`, params); + return this.getPrivate('/api/v2/spot/wallet/withdrawal-records', params); } /** @@ -844,97 +845,97 @@ export class RestClientV2 extends BaseRestClient { */ getFuturesVIPFeeRate(): Promise> { - return this.get(`/api/v2/mix/market/vip-fee-rate`); + return this.get('/api/v2/mix/market/vip-fee-rate'); } getFuturesInterestRateHistory(params: { coin: string; }): Promise> { - return this.get(`/api/v2/mix/market/union-interest-rate-history`, params); + return this.get('/api/v2/mix/market/union-interest-rate-history', params); } getFuturesTicker(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/ticker`, params); + return this.get('/api/v2/mix/market/ticker', params); } getFuturesInterestExchangeRate(): Promise> { - return this.get(`/api/v2/mix/market/exchange-rate`); + return this.get('/api/v2/mix/market/exchange-rate'); } getFuturesDiscountRate(): Promise> { - return this.get(`/api/v2/mix/market/discount-rate`); + return this.get('/api/v2/mix/market/discount-rate'); } getFuturesAllTickers(params: { productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/tickers`, params); + return this.get('/api/v2/mix/market/tickers', params); } getFuturesMergeDepth( params: FuturesMergeDepthRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/merge-depth`, params); + return this.get('/api/v2/mix/market/merge-depth', params); } getFuturesCandles( params: FuturesCandlesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/candles`, params); + return this.get('/api/v2/mix/market/candles', params); } getFuturesHistoricCandles( params: FuturesCandlesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/history-candles`, params); + return this.get('/api/v2/mix/market/history-candles', params); } getFuturesHistoricIndexPriceCandles( params: FuturesCandlesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/history-index-candles`, params); + return this.get('/api/v2/mix/market/history-index-candles', params); } getFuturesHistoricMarkPriceCandles( params: FuturesCandlesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/history-mark-candles`, params); + return this.get('/api/v2/mix/market/history-mark-candles', params); } getFuturesRecentTrades( params: FuturesRecentTradesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/fills`, params); + return this.get('/api/v2/mix/market/fills', params); } getFuturesHistoricTrades( params: FuturesHistoricTradesRequestV2, ): Promise> { - return this.get(`/api/v2/mix/market/fills-history`, params); + return this.get('/api/v2/mix/market/fills-history', params); } getFuturesOpenInterest(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/open-interest`, params); + return this.get('/api/v2/mix/market/open-interest', params); } getFuturesNextFundingTime(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/funding-time`, params); + return this.get('/api/v2/mix/market/funding-time', params); } getFuturesSymbolPrice(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/symbol-price`, params); + return this.get('/api/v2/mix/market/symbol-price', params); } getFuturesHistoricFundingRates(params: { @@ -943,21 +944,21 @@ export class RestClientV2 extends BaseRestClient { pageSize?: string; pageNumber?: string; }): Promise> { - return this.get(`/api/v2/mix/market/history-fund-rate`, params); + return this.get('/api/v2/mix/market/history-fund-rate', params); } getFuturesCurrentFundingRate(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/current-fund-rate`, params); + return this.get('/api/v2/mix/market/current-fund-rate', params); } getFuturesContractConfig(params: { symbol: string; productType: FuturesProductTypeV2; }): Promise> { - return this.get(`/api/v2/mix/market/contracts`, params); + return this.get('/api/v2/mix/market/contracts', params); } /** @@ -969,75 +970,75 @@ export class RestClientV2 extends BaseRestClient { getFuturesAccountAsset( params: FuturesSingleAccountRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/account/account`, params); + return this.getPrivate('/api/v2/mix/account/account', params); } getFuturesAccountAssets(params: { productType: FuturesProductTypeV2; }): Promise> { - return this.getPrivate(`/api/v2/mix/account/accounts`, params); + return this.getPrivate('/api/v2/mix/account/accounts', params); } getFuturesSubAccountAssets(params: { productType: FuturesProductTypeV2; }): Promise> { - return this.getPrivate(`/api/v2/mix/account/sub-account-assets`, params); + return this.getPrivate('/api/v2/mix/account/sub-account-assets', params); } getFuturesInterestHistory( params: FuturesInterestHistoryRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/account/interest-history`, params); + return this.getPrivate('/api/v2/mix/account/interest-history', params); } getFuturesOpenCount( params: FuturesOpenCountRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/account/open-count`, params); + return this.getPrivate('/api/v2/mix/account/open-count', params); } setFuturesLeverage( params: FuturesSetLeverageRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-leverage`, params); + return this.postPrivate('/api/v2/mix/account/set-leverage', params); } setFuturesPositionAutoMargin( params: FuturesSetAutoMarginRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-auto-margin`, params); + return this.postPrivate('/api/v2/mix/account/set-auto-margin', params); } setFuturesPositionMargin( params: FuturesSetPositionMarginRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-margin`, params); + return this.postPrivate('/api/v2/mix/account/set-margin', params); } setFuturesAssetMode(params: { productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; assetMode: 'single' | 'union'; }): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-asset-mode`, params); + return this.postPrivate('/api/v2/mix/account/set-asset-mode', params); } setFuturesMarginMode( params: FuturesSetMarginModeRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-margin-mode`, params); + return this.postPrivate('/api/v2/mix/account/set-margin-mode', params); } setFuturesPositionMode(params: { productType: FuturesProductTypeV2; posMode: 'one_way_mode' | 'hedge_mode'; }): Promise> { - return this.postPrivate(`/api/v2/mix/account/set-position-mode`, params); + return this.postPrivate('/api/v2/mix/account/set-position-mode', params); } getFuturesAccountBills( params: FuturesAccountBillRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/account/bill`, params); + return this.getPrivate('/api/v2/mix/account/bill', params); } /** @@ -1050,7 +1051,7 @@ export class RestClientV2 extends BaseRestClient { productType: FuturesProductTypeV2; symbol: string; }): Promise> { - return this.get(`/api/v2/mix/market/query-position-lever`, params); + return this.get('/api/v2/mix/market/query-position-lever', params); } getFuturesPosition(params: { @@ -1058,20 +1059,20 @@ export class RestClientV2 extends BaseRestClient { symbol: string; marginCoin: string; }): Promise> { - return this.getPrivate(`/api/v2/mix/position/single-position`, params); + return this.getPrivate('/api/v2/mix/position/single-position', params); } getFuturesPositions(params: { productType: FuturesProductTypeV2; marginCoin?: string; }): Promise> { - return this.getPrivate(`/api/v2/mix/position/all-position`, params); + return this.getPrivate('/api/v2/mix/position/all-position', params); } getFuturesHistoricPositions( params?: FuturesHistoricalPositionsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/position/history-position`, params); + return this.getPrivate('/api/v2/mix/position/history-position', params); } /** @@ -1083,77 +1084,77 @@ export class RestClientV2 extends BaseRestClient { futuresSubmitOrder( params: FuturesPlaceOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/place-order`, params); + return this.postPrivate('/api/v2/mix/order/place-order', params); } futuresCancelOrder( params: FuturesCancelOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/cancel-order`, params); + return this.postPrivate('/api/v2/mix/order/cancel-order', params); } futuresSubmitReversal( params: FuturesReversalOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/click-backhand`, params); + return this.postPrivate('/api/v2/mix/order/click-backhand', params); } futuresBatchSubmitOrders( params: FuturesBatchOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/batch-place-order`, params); + return this.postPrivate('/api/v2/mix/order/batch-place-order', params); } futuresModifyOrder( params: FuturesModifyOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/modify-order`, params); + return this.postPrivate('/api/v2/mix/order/modify-order', params); } futuresBatchCancelOrders( params: FuturesBatchCancelOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/batch-cancel-orders`, params); + return this.postPrivate('/api/v2/mix/order/batch-cancel-orders', params); } futuresFlashClosePositions( params: FuturesFlashClosePositionsRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/close-positions`, params); + return this.postPrivate('/api/v2/mix/order/close-positions', params); } getFuturesOrder(params: FuturesGetOrderRequestV2): Promise> { - return this.getPrivate(`/api/v2/mix/order/detail`, params); + return this.getPrivate('/api/v2/mix/order/detail', params); } getFuturesFills( params: FuturesGetOrderFillsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/fills`, params); + return this.getPrivate('/api/v2/mix/order/fills', params); } getFuturesHistoricOrderFills( params: FuturesGetHistoricalFillsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/fill-history`, params); + return this.getPrivate('/api/v2/mix/order/fill-history', params); } getFuturesOpenOrders( params: FuturesGetOpenOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/orders-pending`, params); + return this.getPrivate('/api/v2/mix/order/orders-pending', params); } getFuturesHistoricOrders( params: FuturesGetHistoryOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/orders-history`, params); + return this.getPrivate('/api/v2/mix/order/orders-history', params); } futuresCancelAllOrders( params: FuturesCancelAllOrdersRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/cancel-all-orders`, params); + return this.postPrivate('/api/v2/mix/order/cancel-all-orders', params); } /** @@ -1167,49 +1168,49 @@ export class RestClientV2 extends BaseRestClient { planOrderId: string; productType: FuturesProductTypeV2; }): Promise> { - return this.postPrivate(`/api/v2/mix/order/plan-sub-order`, params); + return this.postPrivate('/api/v2/mix/order/plan-sub-order', params); } futuresSubmitTPSLOrder( params: FuturesTPSLOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/place-tpsl-order`, params); + return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); } futuresSubmitPlanOrder( params: FuturesPlanOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/place-plan-order`, params); + return this.postPrivate('/api/v2/mix/order/place-plan-order', params); } futuresModifyTPSLPOrder( params: FuturesModifyTPSLOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/modify-tpsl-order`, params); + return this.postPrivate('/api/v2/mix/order/modify-tpsl-order', params); } futuresModifyPlanOrder( params: FuturesModifyPlanOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/modify-plan-order`, params); + return this.postPrivate('/api/v2/mix/order/modify-plan-order', params); } futuresCancelPlanOrder( params: FuturesCancelPlanOrderRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/mix/order/cancel-plan-order`, params); + return this.postPrivate('/api/v2/mix/order/cancel-plan-order', params); } getFuturesPlanOrders( params: FuturesGetPlanOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/orders-plan-pending`, params); + return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); } getFuturesHistoricPlanOrders( params: FuturesGetHistoryPlanOrdersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/mix/order/orders-plan-history`, params); + return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); } /** @@ -1231,32 +1232,32 @@ export class RestClientV2 extends BaseRestClient { subaccountEmail: string; }): Promise> { return this.postPrivate( - `/api/v2/broker/account/modify-subaccount-email`, + '/api/v2/broker/account/modify-subaccount-email', params, ); } getBrokerInfo(): Promise> { - return this.getPrivate(`/api/v2/broker/account/info`); + return this.getPrivate('/api/v2/broker/account/info'); } createSubaccount(params: { subaccountName: string; label: string; }): Promise> { - return this.postPrivate(`/api/v2/broker/account/create-subaccount`, params); + return this.postPrivate('/api/v2/broker/account/create-subaccount', params); } getSubaccounts(params?: GetSubAccountsRequestV2): Promise> { - return this.getPrivate(`/api/v2/broker/account/subaccount-list`, params); + return this.getPrivate('/api/v2/broker/account/subaccount-list', params); } modifySubaccount(params: ModifySubRequestV2): Promise> { - return this.postPrivate(`/api/v2/broker/account/modify-subaccount`, params); + return this.postPrivate('/api/v2/broker/account/modify-subaccount', params); } getSubaccountEmail(params: { subUid: string }): Promise> { - return this.getPrivate(`/api/v2/broker/account/subaccount-email`, params); + return this.getPrivate('/api/v2/broker/account/subaccount-email', params); } getSubaccountSpotAssets(params: { @@ -1265,7 +1266,7 @@ export class RestClientV2 extends BaseRestClient { assetType?: 'hold_only' | 'all'; }): Promise> { return this.getPrivate( - `/api/v2/broker/account/subaccount-spot-assets`, + '/api/v2/broker/account/subaccount-spot-assets', params, ); } @@ -1275,7 +1276,7 @@ export class RestClientV2 extends BaseRestClient { productType: FuturesProductTypeV2; }): Promise> { return this.getPrivate( - `/api/v2/broker/account/subaccount-future-assets`, + '/api/v2/broker/account/subaccount-future-assets', params, ); } @@ -1286,7 +1287,7 @@ export class RestClientV2 extends BaseRestClient { chain?: string; }): Promise> { return this.postPrivate( - `/api/v2/broker/account/subaccount-address`, + '/api/v2/broker/account/subaccount-address', params, ); } @@ -1295,7 +1296,7 @@ export class RestClientV2 extends BaseRestClient { params: SubWithdrawalRequestV2, ): Promise> { return this.postPrivate( - `/api/v2/broker/account/subaccount-withdrawal`, + '/api/v2/broker/account/subaccount-withdrawal', params, ); } @@ -1306,7 +1307,7 @@ export class RestClientV2 extends BaseRestClient { toAccountType: string; }): Promise> { return this.postPrivate( - `/api/v2/broker/account/set-subaccount-autotransfer`, + '/api/v2/broker/account/set-subaccount-autotransfer', params, ); } @@ -1314,13 +1315,13 @@ export class RestClientV2 extends BaseRestClient { subaccountDepositRecords( params: SubDepositRecordsRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/broker/subaccount-deposit`, params); + return this.postPrivate('/api/v2/broker/subaccount-deposit', params); } subaccountWithdrawalRecords( params: SubWithdrawalRecordsRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/broker/subaccount-withdrawal`, params); + return this.postPrivate('/api/v2/broker/subaccount-withdrawal', params); } /** @@ -1333,14 +1334,14 @@ export class RestClientV2 extends BaseRestClient { params: CreateSubAccountApiKeyRequestV2, ): Promise> { return this.postPrivate( - `/api/v2/broker/manage/create-subaccount-apikey`, + '/api/v2/broker/manage/create-subaccount-apikey', params, ); } getSubaccountApiKey(params: { subUid: string }): Promise> { return this.getPrivate( - `/api/v2/broker/manage/subaccount-apikey-list`, + '/api/v2/broker/manage/subaccount-apikey-list', params, ); } @@ -1349,7 +1350,7 @@ export class RestClientV2 extends BaseRestClient { params: ModifySubAccountApiKeyRequestV2, ): Promise> { return this.postPrivate( - `/api/v2/broker/manage/modify-subaccount-apikey`, + '/api/v2/broker/manage/modify-subaccount-apikey', params, ); } @@ -1369,7 +1370,7 @@ export class RestClientV2 extends BaseRestClient { */ getMarginCurrencies(): Promise> { - return this.get(`/api/v2/margin/currencies`); + return this.get('/api/v2/margin/currencies'); } /** @@ -1659,7 +1660,7 @@ export class RestClientV2 extends BaseRestClient { params: GetFuturesTraderCurrentOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/order-current-track`, + '/api/v2/copy/mix-trader/order-current-track', params, ); } @@ -1668,7 +1669,7 @@ export class RestClientV2 extends BaseRestClient { params: GetFuturesTraderHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/order-history-track`, + '/api/v2/copy/mix-trader/order-history-track', params, ); } @@ -1677,24 +1678,24 @@ export class RestClientV2 extends BaseRestClient { params: ModifyFuturesTraderOrderTPSLRequestV2, ): Promise> { return this.postPrivate( - `/api/v2/copy/mix-trader/order-modify-tpsl`, + '/api/v2/copy/mix-trader/order-modify-tpsl', params, ); } getFuturesTraderOrder(): Promise> { - return this.getPrivate(`/api/v2/copy/mix-trader/order-total-detail`); + return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); } getFuturesTraderProfitHistory(): Promise> { - return this.getPrivate(`/api/v2/copy/mix-trader/profit-history-summarys`); + return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); } getFuturesTraderProfitShareHistory( params: GetFuturesTraderProfitShareDetailRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/profit-history-details`, + '/api/v2/copy/mix-trader/profit-history-details', params, ); } @@ -1705,7 +1706,7 @@ export class RestClientV2 extends BaseRestClient { productType: CopyTradingProductTypeV2; }): Promise> { return this.postPrivate( - `/api/v2/copy/mix-trader/order-close-positions`, + '/api/v2/copy/mix-trader/order-close-positions', params, ); } @@ -1715,7 +1716,7 @@ export class RestClientV2 extends BaseRestClient { pageSize?: string; pageNo?: string; }): Promise> { - return this.getPrivate(`/api/v2/copy/mix-trader/profit-details`, params); + return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); } getFuturesTraderProfitShareGroup(params?: { @@ -1723,7 +1724,7 @@ export class RestClientV2 extends BaseRestClient { pageNo?: string; }): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/profits-group-coin-date`, + '/api/v2/copy/mix-trader/profits-group-coin-date', params, ); } @@ -1732,7 +1733,7 @@ export class RestClientV2 extends BaseRestClient { productType: CopyTradingProductTypeV2; }): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/config-query-symbols`, + '/api/v2/copy/mix-trader/config-query-symbols', params, ); } @@ -1741,7 +1742,7 @@ export class RestClientV2 extends BaseRestClient { settingList: FuturesTraderSymbolSettingRequestV2[]; }): Promise> { return this.postPrivate( - `/api/v2/copy/mix-trader/config-setting-symbols`, + '/api/v2/copy/mix-trader/config-setting-symbols', params, ); } @@ -1752,7 +1753,7 @@ export class RestClientV2 extends BaseRestClient { showTpsl?: 'YES' | 'NO'; }): Promise> { return this.postPrivate( - `/api/v2/copy/mix-trader/config-settings-base`, + '/api/v2/copy/mix-trader/config-settings-base', params, ); } @@ -1761,7 +1762,7 @@ export class RestClientV2 extends BaseRestClient { params?: GetFuturesTraderFollowersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-trader/config-query-followers`, + '/api/v2/copy/mix-trader/config-query-followers', params, ); } @@ -1770,7 +1771,7 @@ export class RestClientV2 extends BaseRestClient { followerUid: string; }): Promise> { return this.postPrivate( - `/api/v2/copy/mix-trader/config-remove-follower`, + '/api/v2/copy/mix-trader/config-remove-follower', params, ); } @@ -1787,7 +1788,7 @@ export class RestClientV2 extends BaseRestClient { params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-follower/query-current-orders`, + '/api/v2/copy/mix-follower/query-current-orders', params, ); } @@ -1796,7 +1797,7 @@ export class RestClientV2 extends BaseRestClient { params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/mix-follower/query-history-orders`, + '/api/v2/copy/mix-follower/query-history-orders', params, ); } @@ -1804,26 +1805,26 @@ export class RestClientV2 extends BaseRestClient { updateFuturesFollowerTPSL( params: UpdateFuturesFollowerTPSLRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/copy/mix-follower/setting-tpsl`, params); + return this.postPrivate('/api/v2/copy/mix-follower/setting-tpsl', params); } updateFuturesFollowerSettings( params: UpdateFuturesFollowerSettingsRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/copy/mix-follower/settings`, params); + return this.postPrivate('/api/v2/copy/mix-follower/settings', params); } getFuturesFollowerSettings(params: { traderId: string; }): Promise> { - return this.getPrivate(`/api/v2/copy/mix-follower/query-settings`, params); + return this.getPrivate('/api/v2/copy/mix-follower/query-settings', params); } closeFuturesFollowerPositions( params: CloseFuturesFollowerPositionsRequestV2, ): Promise> { return this.postPrivate( - `/api/v2/copy/mix-follower/close-positions`, + '/api/v2/copy/mix-follower/close-positions', params, ); } @@ -1831,7 +1832,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerTraders( params: GetFuturesFollowerTradersRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/copy/mix-follower/query-traders`, params); + return this.getPrivate('/api/v2/copy/mix-follower/query-traders', params); } getFuturesFollowerFollowLimit(params: { @@ -1839,7 +1840,7 @@ export class RestClientV2 extends BaseRestClient { productType: CopyTradingProductTypeV2; }): Promise> { return this.getPrivate( - `/api/v2/copy/mix-follower/query-quantity-limit`, + '/api/v2/copy/mix-follower/query-quantity-limit', params, ); } @@ -1847,7 +1848,7 @@ export class RestClientV2 extends BaseRestClient { unfollowFuturesTrader(params: { traderId: string; }): Promise> { - return this.postPrivate(`/api/v2/copy/mix-follower/cancel-trader`, params); + return this.postPrivate('/api/v2/copy/mix-follower/cancel-trader', params); } /** @@ -1859,19 +1860,19 @@ export class RestClientV2 extends BaseRestClient { */ getBrokerTraders(params: object): Promise> { - return this.getPrivate(`/api/v2/copy/mix-broker/query-traders`, params); + return this.getPrivate('/api/v2/copy/mix-broker/query-traders', params); } getBrokerTradersHistoricalOrders(params: object): Promise> { return this.getPrivate( - `/api/v2/copy/mix-broker/query-history-traces`, + '/api/v2/copy/mix-broker/query-history-traces', params, ); } getBrokerTradersPendingOrders(params: object): Promise> { return this.getPrivate( - `/api/v2/copy/mix-broker/query-current-traces`, + '/api/v2/copy/mix-broker/query-current-traces', params, ); } @@ -1885,14 +1886,14 @@ export class RestClientV2 extends BaseRestClient { */ getSpotTraderProfit(): Promise> { - return this.getPrivate(`/api/v2/copy/spot-trader/profit-summarys`); + return this.getPrivate('/api/v2/copy/spot-trader/profit-summarys'); } getSpotTraderHistoryProfit( params: GetSpotTraderHistoryProfitRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-trader/profit-history-details`, + '/api/v2/copy/spot-trader/profit-history-details', params, ); } @@ -1902,11 +1903,11 @@ export class RestClientV2 extends BaseRestClient { pageNo?: string; pageSize?: string; }): Promise> { - return this.getPrivate(`/api/v2/copy/spot-trader/profit-details`, params); + return this.getPrivate('/api/v2/copy/spot-trader/profit-details', params); } getSpotTraderOrder(): Promise> { - return this.getPrivate(`/api/v2/copy/spot-trader/order-total-detail`); + return this.getPrivate('/api/v2/copy/spot-trader/order-total-detail'); } modifySpotTraderOrderTPSL(params: { @@ -1915,7 +1916,7 @@ export class RestClientV2 extends BaseRestClient { stopLossPrice?: string; }): Promise> { return this.postPrivate( - `/api/v2/copy/spot-trader/order-modify-tpsl`, + '/api/v2/copy/spot-trader/order-modify-tpsl', params, ); } @@ -1924,7 +1925,7 @@ export class RestClientV2 extends BaseRestClient { params: GetSpotTraderHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-trader/order-history-track`, + '/api/v2/copy/spot-trader/order-history-track', params, ); } @@ -1933,7 +1934,7 @@ export class RestClientV2 extends BaseRestClient { params: GetSpotTraderCurrentOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-trader/order-current-track`, + '/api/v2/copy/spot-trader/order-current-track', params, ); } @@ -1943,7 +1944,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; }): Promise> { return this.postPrivate( - `/api/v2/copy/spot-trader/order-close-tracking`, + '/api/v2/copy/spot-trader/order-close-tracking', params, ); } @@ -1953,7 +1954,7 @@ export class RestClientV2 extends BaseRestClient { settingType: 'add' | 'delete'; }): Promise> { return this.postPrivate( - `/api/v2/copy/spot-trader/config-setting-symbols`, + '/api/v2/copy/spot-trader/config-setting-symbols', params, ); } @@ -1962,20 +1963,20 @@ export class RestClientV2 extends BaseRestClient { followerUid: string; }): Promise> { return this.postPrivate( - `/api/v2/copy/spot-trader/config-remove-follower`, + '/api/v2/copy/spot-trader/config-remove-follower', params, ); } getSpotTraderConfiguration(): Promise> { - return this.getPrivate(`/api/v2/copy/spot-trader/config-query-settings`); + return this.getPrivate('/api/v2/copy/spot-trader/config-query-settings'); } getSpotTraderFollowers( params: GetSpotTraderFollowersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-trader/config-query-followers`, + '/api/v2/copy/spot-trader/config-query-followers', params, ); } @@ -1991,7 +1992,7 @@ export class RestClientV2 extends BaseRestClient { cancelSpotFollowerOrder(params: { trackingNoList: string[]; }): Promise> { - return this.postPrivate(`/api/v2/copy/spot-follower/stop-order`, params); + return this.postPrivate('/api/v2/copy/spot-follower/stop-order', params); } updateSpotFollowerSettings(params: { @@ -2000,7 +2001,7 @@ export class RestClientV2 extends BaseRestClient { mode?: 'basic' | 'advanced'; settings: SpotFollowerCopyTradeSettingV2[]; }): Promise> { - return this.postPrivate(`/api/v2/copy/spot-follower/settings`, params); + return this.postPrivate('/api/v2/copy/spot-follower/settings', params); } updateSpotFollowerTPSL(params: { @@ -2008,7 +2009,7 @@ export class RestClientV2 extends BaseRestClient { stopSurplusPrice?: string; stopLossPrice?: string; }): Promise> { - return this.postPrivate(`/api/v2/copy/spot-follower/setting-tpsl`, params); + return this.postPrivate('/api/v2/copy/spot-follower/setting-tpsl', params); } getSpotFollowerTraders(params?: { @@ -2017,14 +2018,14 @@ export class RestClientV2 extends BaseRestClient { startTime?: string; endTime?: string; }): Promise> { - return this.getPrivate(`/api/v2/copy/spot-follower/query-traders`, params); + return this.getPrivate('/api/v2/copy/spot-follower/query-traders', params); } getSpotFollowerCurrentTraderSymbols(params: { traderId: string; }): Promise> { return this.getPrivate( - `/api/v2/copy/spot-follower/query-trader-symbols`, + '/api/v2/copy/spot-follower/query-trader-symbols', params, ); } @@ -2032,14 +2033,14 @@ export class RestClientV2 extends BaseRestClient { getSpotFollowerSettings(params: { traderId: string; }): Promise> { - return this.getPrivate(`/api/v2/copy/spot-follower/query-settings`, params); + return this.getPrivate('/api/v2/copy/spot-follower/query-settings', params); } getSpotFollowerHistoryOrders( params: GetSpotFollowerHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-follower/query-history-orders`, + '/api/v2/copy/spot-follower/query-history-orders', params, ); } @@ -2048,7 +2049,7 @@ export class RestClientV2 extends BaseRestClient { params: GetSpotFollowerOpenOrdersRequestV2, ): Promise> { return this.getPrivate( - `/api/v2/copy/spot-follower/query-current-orders`, + '/api/v2/copy/spot-follower/query-current-orders', params, ); } @@ -2058,13 +2059,13 @@ export class RestClientV2 extends BaseRestClient { symbol: string; }): Promise> { return this.postPrivate( - `/api/v2/copy/spot-follower/order-close-tracking`, + '/api/v2/copy/spot-follower/order-close-tracking', params, ); } unfollowSpotTrader(params: { traderId: string }): Promise> { - return this.postPrivate(`/api/v2/copy/spot-follower/cancel-trader`, params); + return this.postPrivate('/api/v2/copy/spot-follower/cancel-trader', params); } /** @@ -2079,30 +2080,30 @@ export class RestClientV2 extends BaseRestClient { coin?: string; filter?: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/savings/product`, params); + return this.getPrivate('/api/v2/earn/savings/product', params); } getEarnSavingsAccount(): Promise> { - return this.getPrivate(`/api/v2/earn/savings/account`); + return this.getPrivate('/api/v2/earn/savings/account'); } getEarnSavingsAssets( params: GetEarnSavingsAssetsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/savings/assets`, params); + return this.getPrivate('/api/v2/earn/savings/assets', params); } getEarnSavingsRecords( params: GetEarnSavingsRecordsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/savings/records`, params); + return this.getPrivate('/api/v2/earn/savings/records', params); } getEarnSavingsSubscription(params: { productId: string; periodType: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/savings/subscribe-info`, params); + return this.getPrivate('/api/v2/earn/savings/subscribe-info', params); } earnSubscribeSavings(params: { @@ -2110,25 +2111,25 @@ export class RestClientV2 extends BaseRestClient { periodType: string; amount: string; }): Promise> { - return this.postPrivate(`/api/v2/earn/savings/subscribe`, params); + return this.postPrivate('/api/v2/earn/savings/subscribe', params); } getEarnSavingsSubscriptionResult(params: { productId: string; periodType: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/savings/subscribe-result`, params); + return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); } earnRedeemSavings(params: RedeemSavingsRequestV2): Promise> { - return this.postPrivate(`/api/v2/earn/savings/redeem`, params); + return this.postPrivate('/api/v2/earn/savings/redeem', params); } getEarnSavingsRedemptionResult(params: { orderId: string; periodType: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/savings/redeem-result`, params); + return this.getPrivate('/api/v2/earn/savings/redeem-result', params); } /** @@ -2140,7 +2141,7 @@ export class RestClientV2 extends BaseRestClient { */ getEarnAccount(params?: { coin?: string }): Promise> { - return this.getPrivate(`/api/v2/earn/account/assets`, params); + return this.getPrivate('/api/v2/earn/account/assets', params); } /** @@ -2156,42 +2157,42 @@ export class RestClientV2 extends BaseRestClient { limit?: string; idLessThan?: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/product`, params); + return this.getPrivate('/api/v2/earn/sharkfin/product', params); } getSharkfinAccount(): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/account`); + return this.getPrivate('/api/v2/earn/sharkfin/account'); } getSharkfinAssets( params: GetSharkfinAssetsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/assets`, params); + return this.getPrivate('/api/v2/earn/sharkfin/assets', params); } getSharkfinRecords( params: GetSharkfinRecordsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/records`, params); + return this.getPrivate('/api/v2/earn/sharkfin/records', params); } getSharkfinSubscription(params: { productId: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/subscribe-info`, params); + return this.getPrivate('/api/v2/earn/sharkfin/subscribe-info', params); } subscribeSharkfin(params: { productId: string; amount: string; }): Promise> { - return this.postPrivate(`/api/v2/earn/sharkfin/subscribe`, params); + return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); } getSharkfinSubscriptionResult(params: { orderId: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/sharkfin/subscribe-result`, params); + return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); } /** @@ -2203,17 +2204,17 @@ export class RestClientV2 extends BaseRestClient { */ getLoanCurrencies(params?: { coin?: string }): Promise> { - return this.get(`/api/v2/earn/loan/public/coinInfos`, params); + return this.get('/api/v2/earn/loan/public/coinInfos', params); } getLoanEstInterestAndBorrowable( params: GetLoanEstInterestAndBorrowableRequestV2, ): Promise> { - return this.get(`/api/v2/earn/loan/public/hour-interest`, params); + return this.get('/api/v2/earn/loan/public/hour-interest', params); } borrowLoan(params: BorrowLoanRequestV2): Promise> { - return this.postPrivate(`/api/v2/earn/loan/borrow`, params); + return this.postPrivate('/api/v2/earn/loan/borrow', params); } getOngoingLoanOrders(params?: { @@ -2221,42 +2222,42 @@ export class RestClientV2 extends BaseRestClient { loanCoin?: string; pledgeCoin?: string; }): Promise> { - return this.getPrivate(`/api/v2/earn/loan/ongoing-orders`, params); + return this.getPrivate('/api/v2/earn/loan/ongoing-orders', params); } repayLoan(params: RepayLoanRequestV2): Promise> { - return this.postPrivate(`/api/v2/earn/loan/repay`, params); + return this.postPrivate('/api/v2/earn/loan/repay', params); } getRepayHistory( params: GetLoanRepayHistoryRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/loan/repay-history`, params); + return this.getPrivate('/api/v2/earn/loan/repay-history', params); } updateLoanPledgeRate( params: ModifyLoanPledgeRateRequestV2, ): Promise> { - return this.postPrivate(`/api/v2/earn/loan/revise-pledge`, params); + return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); } getLoanPledgeRateHistory( params: GetLoanPledgeRateHistoryRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/loan/revise-history`, params); + return this.getPrivate('/api/v2/earn/loan/revise-history', params); } getLoanHistory(params: GetLoanHistoryRequestV2): Promise> { - return this.getPrivate(`/api/v2/earn/loan/borrow-history`, params); + return this.getPrivate('/api/v2/earn/loan/borrow-history', params); } getLoanDebts(): Promise> { - return this.getPrivate(`/api/v2/earn/loan/debts`); + return this.getPrivate('/api/v2/earn/loan/debts'); } getLoanLiquidationRecords( params: GetLiquidationRecordsRequestV2, ): Promise> { - return this.getPrivate(`/api/v2/earn/loan/reduces`, params); + return this.getPrivate('/api/v2/earn/loan/reduces', params); } } diff --git a/src/types/websockets/events.ts b/src/types/websockets/events.ts index 8082e64..1b1107e 100644 --- a/src/types/websockets/events.ts +++ b/src/types/websockets/events.ts @@ -28,15 +28,6 @@ export interface WsSnapshotPositionsEvent extends WsBaseEvent<'snapshot'> { }; } -export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { - arg: { - instType: 'umcbl'; - channel: 'account'; - instId: string; - }; - data: WsAccountSnapshotDataUMCBL[]; -} - export interface WsAccountSnapshotDataUMCBL { marginCoin: string; locked: string; @@ -47,13 +38,13 @@ export interface WsAccountSnapshotDataUMCBL { usdtEquity: string; } -export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { +export interface WsAccountSnapshotUMCBL extends WsBaseEvent<'snapshot'> { arg: { instType: 'umcbl'; - channel: 'positions'; + channel: 'account'; instId: string; }; - data: WsPositionSnapshotDataUMCBL[]; + data: WsAccountSnapshotDataUMCBL[]; } export interface WsPositionSnapshotDataUMCBL { @@ -80,3 +71,12 @@ export interface WsPositionSnapshotDataUMCBL { uTime: string; markPrice: string; } + +export interface WSPositionSnapshotUMCBL extends WsBaseEvent<'snapshot'> { + arg: { + instType: 'umcbl'; + channel: 'positions'; + instId: string; + }; + data: WsPositionSnapshotDataUMCBL[]; +} diff --git a/src/util/BaseRestClient.ts b/src/util/BaseRestClient.ts index beba6f9..dcf4057 100644 --- a/src/util/BaseRestClient.ts +++ b/src/util/BaseRestClient.ts @@ -70,10 +70,15 @@ if (ENABLE_HTTP_TRACE) { export default abstract class BaseRestClient { private options: RestClientOptions; + private baseUrl: string; + private globalRequestOptions: AxiosRequestConfig; + private apiKey: string | undefined; + private apiSecret: string | undefined; + private apiPass: string | undefined; /** Defines the client type (affecting how requests & signatures behave) */ @@ -292,6 +297,7 @@ export default abstract class BaseRestClient { params?: TParams, isPublicApi?: true, ): Promise>; + private async prepareSignParams( method: Method, endpoint: string, @@ -299,6 +305,7 @@ export default abstract class BaseRestClient { params?: TParams, isPublicApi?: false | undefined, ): Promise>; + private async prepareSignParams( method: Method, endpoint: string, diff --git a/src/util/BaseWSClient.ts b/src/util/BaseWSClient.ts index e4f55e5..be6c277 100644 --- a/src/util/BaseWSClient.ts +++ b/src/util/BaseWSClient.ts @@ -57,6 +57,7 @@ export abstract class BaseWebsocketClient< private wsStore: WsStore; protected logger: typeof DefaultLogger; + protected options: WebsocketClientOptions; constructor( @@ -87,7 +88,9 @@ export abstract class BaseWebsocketClient< ): boolean; protected abstract shouldAuthOnConnect(wsKey: TWSKey): boolean; + protected abstract getWsUrl(wsKey: TWSKey): string; + protected abstract getMaxTopicsPerSubscribeEvent( wsKey: TWSKey, ): number | null; @@ -280,7 +283,7 @@ export abstract class BaseWebsocketClient< recvWindow, ); - this.logger.info(`Sending auth request...`, { + this.logger.info('Sending auth request...', { ...LOGGER_CATEGORY, wsKey, }); @@ -441,7 +444,7 @@ export abstract class BaseWebsocketClient< public tryWsSend(wsKey: TWSKey, wsMessage: string) { try { - this.logger.silly(`Sending upstream ws message: `, { + this.logger.silly('Sending upstream ws message: ', { ...LOGGER_CATEGORY, wsMessage, wsKey, @@ -459,7 +462,7 @@ export abstract class BaseWebsocketClient< } ws.send(wsMessage); } catch (e) { - this.logger.error(`Failed to send WS message`, { + this.logger.error('Failed to send WS message', { ...LOGGER_CATEGORY, wsMessage, wsKey, @@ -552,7 +555,7 @@ export abstract class BaseWebsocketClient< if (typeof msg === 'object') { if (typeof msg['code'] === 'number') { if (msg.event === 'login' && msg.code === 0) { - this.logger.info(`Successfully authenticated WS client`, { + this.logger.info('Successfully authenticated WS client', { ...LOGGER_CATEGORY, wsKey, }); @@ -565,7 +568,7 @@ export abstract class BaseWebsocketClient< if (msg['event']) { if (msg.event === 'error') { - this.logger.error(`WS Error received`, { + this.logger.error('WS Error received', { ...LOGGER_CATEGORY, wsKey, message: msg || 'no message', diff --git a/src/util/WsStore.ts b/src/util/WsStore.ts index 9a609dc..c37cb03 100644 --- a/src/util/WsStore.ts +++ b/src/util/WsStore.ts @@ -18,6 +18,7 @@ export default class WsStore< > { private wsState: Record> = {}; + private logger: typeof DefaultLogger; constructor(logger: typeof DefaultLogger) { @@ -29,10 +30,12 @@ export default class WsStore< key: WsKey, createIfMissing?: true, ): WsStoredState; + get( key: WsKey, createIfMissing?: false, ): WsStoredState | undefined; + get( key: WsKey, createIfMissing?: boolean, diff --git a/src/util/type-guards.ts b/src/util/type-guards.ts index fbf9967..897f5d0 100644 --- a/src/util/type-guards.ts +++ b/src/util/type-guards.ts @@ -78,7 +78,7 @@ export function isWsFuturesPositionsSnapshotEvent( */ export function assertMarginType(marginType: string): marginType is MarginType { if (marginType !== 'isolated' && marginType !== 'crossed') { - throw new Error(`MarginType should be one of: crossed | isolated`); + throw new Error('MarginType should be one of: crossed | isolated'); } return true; } diff --git a/src/util/websocket-util.ts b/src/util/websocket-util.ts index ac9c956..13a1305 100644 --- a/src/util/websocket-util.ts +++ b/src/util/websocket-util.ts @@ -138,7 +138,7 @@ export function getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null { return 15; } default: { - throw neverGuard(wsKey, `getWsKeyForTopic(): Unhandled wsKey`); + throw neverGuard(wsKey, 'getWsKeyForTopic(): Unhandled wsKey'); } } } @@ -162,7 +162,7 @@ export async function getWsAuthSignature( }> { if (!apiKey || !apiSecret || !apiPass) { throw new Error( - `Cannot auth - missing api key, secret or passcode in config`, + 'Cannot auth - missing api key, secret or passcode in config', ); } const signatureExpiresAt = ((Date.now() + recvWindow) / 1000).toFixed(0); diff --git a/src/websocket-client-v2.ts b/src/websocket-client-v2.ts index 6d0c6af..1c0e795 100644 --- a/src/websocket-client-v2.ts +++ b/src/websocket-client-v2.ts @@ -36,6 +36,7 @@ export class WebsocketClientV2 extends BaseWebsocketClient< WsTopicSubscribeEventArgsV2 > { protected logger: typeof DefaultLogger; + protected options: WebsocketClientOptions; protected getWsKeyForTopic( @@ -68,7 +69,7 @@ export class WebsocketClientV2 extends BaseWebsocketClient< case WS_KEY_MAP.spotv1: case WS_KEY_MAP.mixv1: { throw new Error( - `Use the WebsocketClient instead of WebsocketClientV2 for V1 websockets`, + 'Use the WebsocketClient instead of WebsocketClientV2 for V1 websockets', ); } case WS_KEY_MAP.v2Private: { @@ -82,7 +83,7 @@ export class WebsocketClientV2 extends BaseWebsocketClient< ...LOGGER_CATEGORY, wsKey, }); - throw neverGuard(wsKey, `getWsUrl(): Unhandled wsKey`); + throw neverGuard(wsKey, 'getWsUrl(): Unhandled wsKey'); } } } diff --git a/src/websocket-client.ts b/src/websocket-client.ts index d12b870..86182ec 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -73,7 +73,9 @@ export declare interface WebsocketClient { */ export class WebsocketClient extends EventEmitter { private logger: typeof DefaultLogger; + private options: WebsocketClientOptions; + private wsStore: WsStore; constructor( @@ -144,6 +146,7 @@ export class WebsocketClient extends EventEmitter { } }); } + /** * Unsubscribe from topics & remove them from memory. They won't be re-subscribed to if the connection reconnects. * @param wsTopics topic or list of topics @@ -281,7 +284,7 @@ export class WebsocketClient extends EventEmitter { recvWindow, ); - this.logger.info(`Sending auth request...`, { + this.logger.info('Sending auth request...', { ...LOGGER_CATEGORY, wsKey, }); @@ -442,7 +445,7 @@ export class WebsocketClient extends EventEmitter { public tryWsSend(wsKey: WsKey, wsMessage: string) { try { - this.logger.silly(`Sending upstream ws message: `, { + this.logger.silly('Sending upstream ws message: ', { ...LOGGER_CATEGORY, wsMessage, wsKey, @@ -460,7 +463,7 @@ export class WebsocketClient extends EventEmitter { } ws.send(wsMessage); } catch (e) { - this.logger.error(`Failed to send WS message`, { + this.logger.error('Failed to send WS message', { ...LOGGER_CATEGORY, wsMessage, wsKey, @@ -553,7 +556,7 @@ export class WebsocketClient extends EventEmitter { if (typeof msg === 'object') { if (typeof msg['code'] === 'number') { if (msg.event === 'login' && msg.code === 0) { - this.logger.info(`Successfully authenticated WS client`, { + this.logger.info('Successfully authenticated WS client', { ...LOGGER_CATEGORY, wsKey, }); @@ -566,7 +569,7 @@ export class WebsocketClient extends EventEmitter { if (msg['event']) { if (msg.event === 'error') { - this.logger.error(`WS Error received`, { + this.logger.error('WS Error received', { ...LOGGER_CATEGORY, wsKey, message: msg || 'no message', @@ -648,14 +651,14 @@ export class WebsocketClient extends EventEmitter { } case WS_KEY_MAP.v2Private: case WS_KEY_MAP.v2Public: { - throw new Error(`Use the WebsocketClientV2 for V2 websockets`); + throw new Error('Use the WebsocketClientV2 for V2 websockets'); } default: { this.logger.error('getWsUrl(): Unhandled wsKey: ', { ...LOGGER_CATEGORY, wsKey, }); - throw neverGuard(wsKey, `getWsUrl(): Unhandled wsKey`); + throw neverGuard(wsKey, 'getWsUrl(): Unhandled wsKey'); } } } diff --git a/tsconfig.linting.json b/tsconfig.linting.json index e925971..ee6bda0 100644 --- a/tsconfig.linting.json +++ b/tsconfig.linting.json @@ -12,6 +12,7 @@ "test/**/*.*", "examples/**/*.*", ".eslintrc.cjs", - "jest.config.ts" + "jest.config.ts", + "webpack/webpack.config.ts" ] } diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index 4fdc116..9386e58 100644 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -1,6 +1,6 @@ -const webpack = require('webpack'); const path = require('path'); -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; +const BundleAnalyzerPlugin = + require('webpack-bundle-analyzer').BundleAnalyzerPlugin; function generateConfig(name) { var config = { @@ -10,27 +10,29 @@ function generateConfig(name) { filename: name + '.js', sourceMapFilename: name + '.map', library: name, - libraryTarget: 'umd' + libraryTarget: 'umd', }, - devtool: "source-map", + devtool: 'source-map', mode: 'production', resolve: { // Add '.ts' and '.tsx' as resolvable extensions. - extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"], + extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'], alias: { - [path.resolve(__dirname, "../lib/util/node-support.js")]: - path.resolve(__dirname, "../lib/util/browser-support.js"), - } + [path.resolve(__dirname, '../lib/util/node-support.js')]: path.resolve( + __dirname, + '../lib/util/browser-support.js', + ), + }, }, module: { rules: [ // All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'. - { test: /\.tsx?$/, loader: "ts-loader" }, + { test: /\.tsx?$/, loader: 'ts-loader' }, // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. - { test: /\.js$/, loader: "source-map-loader" }, + { test: /\.js$/, loader: 'source-map-loader' }, { test: /\.m?js$/, @@ -38,28 +40,30 @@ function generateConfig(name) { use: { loader: 'babel-loader', options: { - presets: [['@babel/preset-env', { - 'targets': { - 'node': 'current' - } - }]] - } - } - } - ] - } + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current', + }, + }, + ], + ], + }, + }, + }, + ], + }, }; config.plugins = [ - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) - }), new BundleAnalyzerPlugin({ defaultSizes: 'stat', analyzerMode: 'static', reportFilename: '../doc/bundleReport.html', openAnalyzer: false, - }) + }), ]; return config; From ebf7f69a81aa946672fa20eb24ae8cefa8b9f8a9 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 11 Dec 2024 16:53:14 +0000 Subject: [PATCH 4/6] chore(): update e2e test action, with deliberate lint fail --- .github/workflows/e2etests.yml | 31 +++++++++++++++++-------------- package.json | 1 + src/types/request/v1/spotV1.ts | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/e2etests.yml b/.github/workflows/e2etests.yml index 9c5f555..09a3def 100644 --- a/.github/workflows/e2etests.yml +++ b/.github/workflows/e2etests.yml @@ -1,13 +1,9 @@ -name: "Build & Test" +name: "Build, Lint & Test" -on: [push] - -# on: -# # pull_request: -# # branches: -# # - "master" -# push: -# branches: +on: + push: + pull_request: + workflow_dispatch: jobs: build: @@ -15,20 +11,27 @@ jobs: runs-on: ubuntu-latest steps: - - name: "Checkout source code" - uses: actions/checkout@v3 + - name: 'Checkout source code' + uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 16 + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org/' cache: 'npm' - name: Install run: npm ci --ignore-scripts - - name: Build + - name: Clean + run: npm run clean + + - name: Check Build run: npm run build + - name: Check Lint + run: npm run lint + - name: Test run: npm run test env: diff --git a/package.json b/package.json index d5d362e..63b84ca 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build:clean": "npm run clean && npm run build", "build:watch": "npm run clean && tsc --watch", "pack": "webpack --config webpack/webpack.config.js", + "lint": "eslint src", "prepublish": "npm run build:clean", "betapublish": "npm publish --tag beta" }, diff --git a/src/types/request/v1/spotV1.ts b/src/types/request/v1/spotV1.ts index f3f4b85..fbecdcc 100644 --- a/src/types/request/v1/spotV1.ts +++ b/src/types/request/v1/spotV1.ts @@ -20,7 +20,7 @@ export type SpotKlineInterval = | '1Dutc' | '3Dutc' | '1Wutc' - | '1Mutc'; + | "1Mutc"; export interface NewWalletTransfer { fromType: WalletType; From 0299bf41d2f42dc99b0613c49401833f8e9f3961 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 11 Dec 2024 16:54:15 +0000 Subject: [PATCH 5/6] chore(): undo linter test --- src/types/request/v1/spotV1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/request/v1/spotV1.ts b/src/types/request/v1/spotV1.ts index fbecdcc..f3f4b85 100644 --- a/src/types/request/v1/spotV1.ts +++ b/src/types/request/v1/spotV1.ts @@ -20,7 +20,7 @@ export type SpotKlineInterval = | '1Dutc' | '3Dutc' | '1Wutc' - | "1Mutc"; + | '1Mutc'; export interface NewWalletTransfer { fromType: WalletType; From d96ce802282e62e2d7f9f3195c839d19f4b6a561 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 11 Dec 2024 16:55:37 +0000 Subject: [PATCH 6/6] feat(v2.2.0): bump build version to node LTS, fix linter, address linter conflicts, update gh action for linter check --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5c86bb6..78f8fcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "2.1.0", + "version": "2.2.0", "license": "MIT", "dependencies": { "axios": "^1.6.1", diff --git a/package.json b/package.json index 63b84ca..6d51b4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "2.1.0", + "version": "2.2.0", "description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts",