From 741dfd4468d0ec7b33c3e208160844f74e6fb759 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Wed, 31 Jul 2024 14:40:40 +0800 Subject: [PATCH 1/8] feat: add deriv api manager --- src/client-library/deriv-api-manager.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/client-library/deriv-api-manager.ts diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts new file mode 100644 index 0000000..eea3008 --- /dev/null +++ b/src/client-library/deriv-api-manager.ts @@ -0,0 +1,16 @@ +import { DerivAPIClient, DerivAPIClientOptions } from './deriv-api-client'; + +export class DerivAPIManager { + activeClient: DerivAPIClient; + clientList: Map = new Map(); + + constructor(endpoint: string, options?: DerivAPIClientOptions) { + const client = new DerivAPIClient(endpoint, options); + this.clientList.set(endpoint, client); + this.activeClient = client; + } + + getActiveClient() { + return this.activeClient; + } +} From 43c8b77605e1d94c0fb5b65be1131b4da0b01764 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 1 Aug 2024 11:55:20 +0800 Subject: [PATCH 2/8] feat: initial switch connection funnctionality --- src/client-library/deriv-api-client.ts | 11 ++++---- src/client-library/deriv-api-manager.ts | 35 ++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/client-library/deriv-api-client.ts b/src/client-library/deriv-api-client.ts index 98bc9c8..00593da 100644 --- a/src/client-library/deriv-api-client.ts +++ b/src/client-library/deriv-api-client.ts @@ -8,7 +8,7 @@ import { TSocketSubscribeResponseData, } from '../types/api.types'; -type DerivAPIClientOptions = { +export type DerivAPIClientOptions = { onOpen?: (e: Event) => void; onClose?: (e: CloseEvent) => void; }; @@ -38,19 +38,19 @@ type SubscriptionMap >; -type SendFunctionArgs = { +export type SendFunctionArgs = { name: T; payload?: TSocketRequestPayload; }; -type SubscribeFunctionArgs = { +export type SubscribeFunctionArgs = { name: T; payload?: TSocketRequestPayload; onData: (data: TSocketSubscribeResponseData) => void; onError?: (error: TSocketError['error']) => void; }; -type UnsubscribeHandlerArgs = { +export type UnsubscribeHandlerArgs = { id: number; hash: string; }; @@ -61,6 +61,7 @@ export class DerivAPIClient { subscribeHandler: SubscriptionMap; req_id: number; waitForWebSocketOpen: ReturnType; + waitForWebSocketCall?: ReturnType & { name: TSocketEndpointNames }; keepAliveIntervalId: NodeJS.Timeout | null = null; constructor(endpoint: string, options?: DerivAPIClientOptions) { @@ -202,7 +203,7 @@ export class DerivAPIClient { } } - switchConnection() {} + async waitFor(name: TSocketEndpointNames) {} isSocketClosingOrClosed() { return ![2, 3].includes(this.websocket.readyState); diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts index eea3008..900412e 100644 --- a/src/client-library/deriv-api-manager.ts +++ b/src/client-library/deriv-api-manager.ts @@ -1,6 +1,14 @@ -import { DerivAPIClient, DerivAPIClientOptions } from './deriv-api-client'; +import { TSocketEndpointNames, TSocketSubscribableEndpointNames } from '../types/api.types'; +import { + DerivAPIClient, + DerivAPIClientOptions, + SendFunctionArgs, + SubscribeFunctionArgs, + UnsubscribeHandlerArgs, +} from './deriv-api-client'; export class DerivAPIManager { + options?: DerivAPIClientOptions; activeClient: DerivAPIClient; clientList: Map = new Map(); @@ -8,9 +16,30 @@ export class DerivAPIManager { const client = new DerivAPIClient(endpoint, options); this.clientList.set(endpoint, client); this.activeClient = client; + this.options = options; } - getActiveClient() { - return this.activeClient; + async send(args: SendFunctionArgs) { + return this.activeClient.send(args); + } + + async subscribe(args: SubscribeFunctionArgs) { + return this.activeClient.subscribe(args); + } + + async unsubscribe(args: UnsubscribeHandlerArgs) { + return this.activeClient.unsubscribe(args); + } + + switchConnection(endpoint: string) { + const matchingInstance = this.clientList.get(endpoint); + if (matchingInstance) { + this.activeClient = matchingInstance; + return; + } + const subscribeHandlers = { ...this.activeClient.subscribeHandler }; + const newInstance = new DerivAPIClient(endpoint, this.options); + this.clientList.set(endpoint, newInstance); + this.activeClient = newInstance; } } From cfc4974d3dd53ed9c5b4f565aa1d6d8adc1fcc59 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 1 Aug 2024 11:58:41 +0800 Subject: [PATCH 3/8] chore: update dependencies --- package-lock.json | 702 +++++++++++----------------------------------- package.json | 18 +- 2 files changed, 165 insertions(+), 555 deletions(-) diff --git a/package-lock.json b/package-lock.json index b136a27..4dda131 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,36 +9,36 @@ "version": "0.0.0-development", "license": "ISC", "dependencies": { - "@deriv-com/utils": "^0.0.28", - "@deriv/api-types": "^1.0.985", + "@deriv-com/utils": "^0.0.30", + "@deriv/api-types": "^1.0.1447", "@deriv/deriv-api": "^1.0.15", - "@tanstack/react-query": "^5.48.0" + "@tanstack/react-query": "^5.51.16" }, "devDependencies": { "@semantic-release/changelog": "^6.0.3", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.12", - "@types/node": "^20.14.9", + "@types/node": "^22.0.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@vitejs/plugin-react": "^4.3.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", - "prettier": "3.3.2", + "prettier": "3.3.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "semantic-release": "^23.1.1", + "semantic-release": "^24.0.0", "ts-jest": "^29.2.3", "ts-node": "^10.9.2", - "typescript": "^5.5.2", - "vite": "^5.3.1", + "typescript": "^5.5.4", + "vite": "^5.3.5", "vite-plugin-dts": "^3.9.1", "vite-plugin-mkcert": "^1.17.5", "vite-tsconfig-paths": "^4.3.2" }, "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "^4.18.0" + "@rollup/rollup-linux-x64-gnu": "^4.19.1" } }, "node_modules/@adobe/css-tools": { @@ -615,14 +615,15 @@ } }, "node_modules/@deriv-com/utils": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@deriv-com/utils/-/utils-0.0.28.tgz", - "integrity": "sha512-JJayPckG5ajwZjJ0H3VYe9GXcTpMY7oNOkMRiqwv14dtcsMTsYow9cVs3vfbiL4U59WGQBGMkkbh0EwSjYVrvQ==" + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@deriv-com/utils/-/utils-0.0.30.tgz", + "integrity": "sha512-ZOpIfnQN4N1dM/JHSpQFzz+0jRW5mefy2BpzvFnvMBtp/IVY6+2Uw304cAIBuz56sKnTPP1FTBW7ndRuJDKpMQ==" }, "node_modules/@deriv/api-types": { - "version": "1.0.985", - "resolved": "https://registry.npmjs.org/@deriv/api-types/-/api-types-1.0.985.tgz", - "integrity": "sha512-G9a6P9sgFK73MYKud7TqvvRshXsa2R1gkMtx9L5z1nPvoLbm5zbL2Igiw6LupGoODhrXi5EsEeAZA/2lgY6X9g==" + "version": "1.0.1447", + "resolved": "https://registry.npmjs.org/@deriv/api-types/-/api-types-1.0.1447.tgz", + "integrity": "sha512-5CJ2PBPWWFUvdap8LbEfdUQULGxTWYTjREYWqV27+TTyng05iQyhQCxbB2XZ4WhvKFYHGMM3ux0uUP+l2aC4NQ==", + "license": "Apache-2.0" }, "node_modules/@deriv/deriv-api": { "version": "1.0.15", @@ -634,70 +635,6 @@ "rxjs": "^7.8.1" } }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", - "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/darwin-arm64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", @@ -714,294 +651,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -2253,6 +1902,7 @@ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -2266,6 +1916,7 @@ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -2292,6 +1943,7 @@ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -2305,6 +1957,7 @@ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -2318,6 +1971,7 @@ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -2331,6 +1985,7 @@ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -2344,18 +1999,20 @@ "riscv64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz", - "integrity": "sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w==", + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.19.1.tgz", + "integrity": "sha512-XUXeI9eM8rMP8aGvii/aOOiMvTs7xlCosq9xCjcqI9+5hBxtjDpD+7Abm1ZhVIFE1J2h2VIg0t2DX/gjespC2Q==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "linux" @@ -2369,6 +2026,7 @@ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -2382,6 +2040,7 @@ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -2395,6 +2054,7 @@ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -2408,6 +2068,7 @@ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -2592,14 +2253,16 @@ } }, "node_modules/@semantic-release/commit-analyzer": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-12.0.0.tgz", - "integrity": "sha512-qG+md5gdes+xa8zP7lIo1fWE17zRdO8yMCaxh9lyL65TQleoSv8WHHOqRURfghTytUh+NpkSyBprQ5hrkxOKVQ==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-13.0.0.tgz", + "integrity": "sha512-KtXWczvTAB1ZFZ6B4O+w8HkfYm/OgQb1dUGNFZtDgQ0csggrmkq8sTxhd+lwGF8kMb59/RnG9o4Tn7M/I8dQ9Q==", "dev": true, + "license": "MIT", "dependencies": { - "conventional-changelog-angular": "^7.0.0", - "conventional-commits-filter": "^4.0.0", - "conventional-commits-parser": "^5.0.0", + "conventional-changelog-angular": "^8.0.0", + "conventional-changelog-writer": "^8.0.0", + "conventional-commits-filter": "^5.0.0", + "conventional-commits-parser": "^6.0.0", "debug": "^4.0.0", "import-from-esm": "^1.0.3", "lodash-es": "^4.17.21", @@ -3031,21 +2694,22 @@ "dev": true }, "node_modules/@semantic-release/release-notes-generator": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-13.0.0.tgz", - "integrity": "sha512-LEeZWb340keMYuREMyxrODPXJJ0JOL8D/mCl74B4LdzbxhtXV2LrPN2QBEcGJrlQhoqLO0RhxQb6masHytKw+A==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-14.0.1.tgz", + "integrity": "sha512-K0w+5220TM4HZTthE5dDpIuFrnkN1NfTGPidJFm04ULT1DEZ9WG89VNXN7F0c+6nMEpWgqmPvb7vY7JkB2jyyA==", "dev": true, + "license": "MIT", "dependencies": { - "conventional-changelog-angular": "^7.0.0", - "conventional-changelog-writer": "^7.0.0", - "conventional-commits-filter": "^4.0.0", - "conventional-commits-parser": "^5.0.0", + "conventional-changelog-angular": "^8.0.0", + "conventional-changelog-writer": "^8.0.0", + "conventional-commits-filter": "^5.0.0", + "conventional-commits-parser": "^6.0.0", "debug": "^4.0.0", "get-stream": "^7.0.0", "import-from-esm": "^1.0.3", "into-stream": "^7.0.0", "lodash-es": "^4.17.21", - "read-pkg-up": "^11.0.0" + "read-package-up": "^11.0.0" }, "engines": { "node": ">=20.8.1" @@ -3059,6 +2723,7 @@ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-7.0.1.tgz", "integrity": "sha512-3M8C1EOFN6r8AMUhwUAACIoXZJEOufDU5+0gFFN5uNs6XYOralD2Pqkl7m046va6x77FwposWXbAhPPIOus7mQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=16" }, @@ -3115,20 +2780,22 @@ } }, "node_modules/@tanstack/query-core": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.48.0.tgz", - "integrity": "sha512-lZAfPPeVIqXCswE9SSbG33B6/91XOWt/Iq41bFeWb/mnHwQSIfFRbkS4bfs+WhIk9abRArF9Id2fp0Mgo+hq6Q==", + "version": "5.51.16", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.51.16.tgz", + "integrity": "sha512-zfV+WAtBGm1dUIbL0w/x8qTqVLKU1/Bo1p19J9LF02MmIc4FxzMImMXhFzYJQl5Hx8Wit6RiQ4tB/DvN8y9zaQ==", + "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.48.0.tgz", - "integrity": "sha512-GDExbjYWzvDokyRqMSWXdrPiYpp95Aig0oeMIrxTaruOJJgWiWfUP//OAaowm2RrRkGVsavSZdko/XmIrrV2Nw==", + "version": "5.51.16", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.51.16.tgz", + "integrity": "sha512-NZnpJ30zkwaA2ZPhxJLs/qoMbd0yNAj6yyb3JTADJx9HjSdtvnNzOY1bDa3bU1B9CZTBBb7W9E1PpWlNXdgESg==", + "license": "MIT", "dependencies": { - "@tanstack/query-core": "5.48.0" + "@tanstack/query-core": "5.51.16" }, "funding": { "type": "github", @@ -3550,12 +3217,13 @@ } }, "node_modules/@types/node": { - "version": "20.14.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", - "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "version": "22.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.2.tgz", + "integrity": "sha512-yPL6DyFwY5PiMVEwymNeqUTKsDczQBJ/5T7W/46RwLU/VH+AA8aT5TZkvBviLKLbbm0hlfftEkGrNzfRk/fofQ==", "dev": true, + "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.11.1" } }, "node_modules/@types/normalize-package-data": { @@ -3589,6 +3257,13 @@ "@types/react": "*" } }, + "node_modules/@types/semver": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", + "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -3901,7 +3576,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/arraybuffer.prototype.slice": { "version": "1.0.3", @@ -4572,6 +4248,7 @@ "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", "dev": true, + "license": "MIT", "dependencies": { "array-ify": "^1.0.0", "dot-prop": "^5.1.0" @@ -4600,42 +4277,44 @@ } }, "node_modules/conventional-changelog-angular": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-7.0.0.tgz", - "integrity": "sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-8.0.0.tgz", + "integrity": "sha512-CLf+zr6St0wIxos4bmaKHRXWAcsCXrJU6F4VdNDrGRK3B8LDLKoX3zuMV5GhtbGkVR/LohZ6MT6im43vZLSjmA==", "dev": true, + "license": "ISC", "dependencies": { "compare-func": "^2.0.0" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/conventional-changelog-writer": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-7.0.1.tgz", - "integrity": "sha512-Uo+R9neH3r/foIvQ0MKcsXkX642hdm9odUp7TqgFS7BsalTcjzRlIfWZrZR1gbxOozKucaKt5KAbjW8J8xRSmA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-8.0.0.tgz", + "integrity": "sha512-TQcoYGRatlAnT2qEWDON/XSfnVG38JzA7E0wcGScu7RElQBkg9WWgZd1peCWFcWDh1xfb2CfsrcvOn1bbSzztA==", "dev": true, + "license": "MIT", "dependencies": { - "conventional-commits-filter": "^4.0.0", + "@types/semver": "^7.5.5", + "conventional-commits-filter": "^5.0.0", "handlebars": "^4.7.7", - "json-stringify-safe": "^5.0.1", - "meow": "^12.0.1", - "semver": "^7.5.2", - "split2": "^4.0.0" + "meow": "^13.0.0", + "semver": "^7.5.2" }, "bin": { - "conventional-changelog-writer": "cli.mjs" + "conventional-changelog-writer": "dist/cli/index.js" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/conventional-changelog-writer/node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -4644,30 +4323,29 @@ } }, "node_modules/conventional-commits-filter": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-4.0.0.tgz", - "integrity": "sha512-rnpnibcSOdFcdclpFwWa+pPlZJhXE7l+XK04zxhbWrhgpR96h33QLz8hITTXbcYICxVr3HZFtbtUAQ+4LdBo9A==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-5.0.0.tgz", + "integrity": "sha512-tQMagCOC59EVgNZcC5zl7XqO30Wki9i9J3acbUvkaosCT6JX3EeFwJD7Qqp4MCikRnzS18WXV3BLIQ66ytu6+Q==", "dev": true, + "license": "MIT", "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/conventional-commits-parser": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-5.0.0.tgz", - "integrity": "sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.0.0.tgz", + "integrity": "sha512-TbsINLp48XeMXR8EvGjTnKGsZqBemisPoyWESlpRyR8lif0lcwzqz+NMtYSj1ooF/WYjSuu7wX0CtdeeMEQAmA==", "dev": true, + "license": "MIT", "dependencies": { - "is-text-path": "^2.0.0", - "JSONStream": "^1.3.5", - "meow": "^12.0.1", - "split2": "^4.0.0" + "meow": "^13.0.0" }, "bin": { - "conventional-commits-parser": "cli.mjs" + "conventional-commits-parser": "dist/cli/index.js" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/convert-hrtime": { @@ -5146,6 +4824,7 @@ "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", "dev": true, + "license": "MIT", "dependencies": { "is-obj": "^2.0.0" }, @@ -5728,6 +5407,7 @@ "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", "integrity": "sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==", "dev": true, + "license": "MIT", "dependencies": { "inherits": "^2.0.1", "readable-stream": "^2.0.0" @@ -6050,6 +5730,7 @@ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", "dev": true, + "license": "MIT", "dependencies": { "minimist": "^1.2.5", "neo-async": "^2.6.2", @@ -6298,6 +5979,7 @@ "resolved": "https://registry.npmjs.org/import-from-esm/-/import-from-esm-1.3.4.tgz", "integrity": "sha512-7EyUlPFC0HOlBDpUFGfYstsU7XHxZJKAAMzCT8wZ0hMW7b+hG51LIKTDcsgtz8Pu6YC0HqRVbX+rVUtsGMUKvg==", "dev": true, + "license": "MIT", "dependencies": { "debug": "^4.3.4", "import-meta-resolve": "^4.0.0" @@ -6339,6 +6021,7 @@ "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.1.0.tgz", "integrity": "sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==", "dev": true, + "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" @@ -6416,6 +6099,7 @@ "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-7.0.0.tgz", "integrity": "sha512-2dYz766i9HprMBasCMvHMuazJ7u4WzhJwo5kb3iPSiW/iRYV6uPari3zHoqZlnuaR7V1bEiNMxikhp37rdBXbw==", "dev": true, + "license": "MIT", "dependencies": { "from2": "^2.3.0", "p-is-promise": "^3.0.0" @@ -6611,6 +6295,7 @@ "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -6706,18 +6391,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-text-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-2.0.0.tgz", - "integrity": "sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==", - "dev": true, - "dependencies": { - "text-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-typed-array": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", @@ -8978,12 +8651,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "dev": true - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -9013,31 +8680,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", - "dev": true, - "engines": [ - "node >= 0.2.0" - ] - }, - "node_modules/JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "dependencies": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - }, - "bin": { - "JSONStream": "bin.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -9298,12 +8940,13 @@ } }, "node_modules/meow": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-12.1.1.tgz", - "integrity": "sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==", + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz", + "integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==", "dev": true, + "license": "MIT", "engines": { - "node": ">=16.10" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -9452,6 +9095,7 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -9469,7 +9113,8 @@ "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/nerf-dart": { "version": "1.0.0", @@ -12507,6 +12152,7 @@ "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-3.0.0.tgz", "integrity": "sha512-Wo8VsW4IRQSKVXsJCn7TomUaVtyfjVDn3nUP7kE967BQk0CwFpdbZs0X0uk5sW9mkBa9eNM7hCMaG93WUAwxYQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -12820,9 +12466,9 @@ } }, "node_modules/postcss": { - "version": "8.4.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", - "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "version": "8.4.40", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.40.tgz", + "integrity": "sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==", "dev": true, "funding": [ { @@ -12838,9 +12484,10 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.0", + "picocolors": "^1.0.1", "source-map-js": "^1.2.0" }, "engines": { @@ -12848,10 +12495,11 @@ } }, "node_modules/prettier": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", - "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, + "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" }, @@ -13090,24 +12738,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/read-pkg-up": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-11.0.0.tgz", - "integrity": "sha512-LOVbvF1Q0SZdjClSefZ0Nz5z8u+tIE7mV5NibzmE9VYmDe9CaBbAVtz1veOSZbofrdsilxuDAYnFenukZVp8/Q==", - "deprecated": "Renamed to read-package-up", - "dev": true, - "dependencies": { - "find-up-simple": "^1.0.0", - "read-pkg": "^9.0.0", - "type-fest": "^4.6.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/read-pkg/node_modules/parse-json": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.1.0.tgz", @@ -13307,6 +12937,7 @@ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -13412,16 +13043,17 @@ } }, "node_modules/semantic-release": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/semantic-release/-/semantic-release-23.1.1.tgz", - "integrity": "sha512-qqJDBhbtHsjUEMsojWKGuL5lQFCJuPtiXKEIlFKyTzDDGTAE/oyvznaP8GeOr5PvcqBJ6LQz4JCENWPLeehSpA==", + "version": "24.0.0", + "resolved": "https://registry.npmjs.org/semantic-release/-/semantic-release-24.0.0.tgz", + "integrity": "sha512-v46CRPw+9eI3ZuYGF2oAjqPqsfbnfFTwLBgQsv/lch4goD09ytwOTESMN4QIrx/wPLxUGey60/NMx+ANQtWRsA==", "dev": true, + "license": "MIT", "dependencies": { - "@semantic-release/commit-analyzer": "^12.0.0", + "@semantic-release/commit-analyzer": "^13.0.0-beta.1", "@semantic-release/error": "^4.0.0", "@semantic-release/github": "^10.0.0", "@semantic-release/npm": "^12.0.0", - "@semantic-release/release-notes-generator": "^13.0.0", + "@semantic-release/release-notes-generator": "^14.0.0-beta.1", "aggregate-error": "^5.0.0", "cosmiconfig": "^9.0.0", "debug": "^4.0.0", @@ -13911,15 +13543,6 @@ "integrity": "sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==", "dev": true }, - "node_modules/split2": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", - "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", - "dev": true, - "engines": { - "node": ">= 10.x" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -14263,18 +13886,6 @@ "node": "*" } }, - "node_modules/text-extensions": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-2.4.0.tgz", - "integrity": "sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/thenify": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", @@ -14296,12 +13907,6 @@ "node": ">=0.8" } }, - "node_modules/through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true - }, "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", @@ -14650,10 +14255,11 @@ } }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -14663,10 +14269,11 @@ } }, "node_modules/uglify-js": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.18.0.tgz", - "integrity": "sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==", + "version": "3.19.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.1.tgz", + "integrity": "sha512-y/2wiW+ceTYR2TSSptAhfnEtpLaQ4Ups5zrjB2d3kuVxHj16j/QJwPl5PvuGy9uARb39J0+iKxcRPvtpsx4A4A==", "dev": true, + "license": "BSD-2-Clause", "optional": true, "bin": { "uglifyjs": "bin/uglifyjs" @@ -14691,10 +14298,11 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", + "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", + "dev": true, + "license": "MIT" }, "node_modules/unicode-emoji-modifier-base": { "version": "1.0.0", @@ -14851,13 +14459,14 @@ } }, "node_modules/vite": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", - "integrity": "sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.5.tgz", + "integrity": "sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==", "dev": true, + "license": "MIT", "dependencies": { "esbuild": "^0.21.3", - "postcss": "^8.4.38", + "postcss": "^8.4.39", "rollup": "^4.13.0" }, "bin": { @@ -15147,7 +14756,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/wrap-ansi": { "version": "7.0.0", diff --git a/package.json b/package.json index 9dd7e91..0dc336a 100644 --- a/package.json +++ b/package.json @@ -33,35 +33,35 @@ "homepage": "https://deriv.com", "license": "ISC", "dependencies": { - "@deriv-com/utils": "^0.0.28", - "@deriv/api-types": "^1.0.985", + "@deriv-com/utils": "^0.0.30", + "@deriv/api-types": "^1.0.1447", "@deriv/deriv-api": "^1.0.15", - "@tanstack/react-query": "^5.48.0" + "@tanstack/react-query": "^5.51.16" }, "devDependencies": { "@semantic-release/changelog": "^6.0.3", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.12", - "@types/node": "^20.14.9", + "@types/node": "^22.0.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@vitejs/plugin-react": "^4.3.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", - "prettier": "3.3.2", + "prettier": "3.3.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "semantic-release": "^23.1.1", + "semantic-release": "^24.0.0", "ts-jest": "^29.2.3", "ts-node": "^10.9.2", - "typescript": "^5.5.2", - "vite": "^5.3.1", + "typescript": "^5.5.4", + "vite": "^5.3.5", "vite-plugin-dts": "^3.9.1", "vite-plugin-mkcert": "^1.17.5", "vite-tsconfig-paths": "^4.3.2" }, "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "^4.18.0" + "@rollup/rollup-linux-x64-gnu": "^4.19.1" } } From 80db477c074b05459de68d4a5f644119bb42498e Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 1 Aug 2024 13:09:21 +0800 Subject: [PATCH 4/8] chore: removed verify_email_cellxperts --- package-lock.json | 8 ++++---- package.json | 2 +- src/api/non-authorize/index.tsx | 2 -- .../non-authorize/use-verify-email-cellxpert.tsx | 13 ------------- src/types/api.types.ts | 6 ------ 5 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 src/api/non-authorize/use-verify-email-cellxpert.tsx diff --git a/package-lock.json b/package-lock.json index 4dda131..769f36d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "@deriv-com/utils": "^0.0.30", - "@deriv/api-types": "^1.0.1447", + "@deriv/api-types": "^1.0.1448", "@deriv/deriv-api": "^1.0.15", "@tanstack/react-query": "^5.51.16" }, @@ -620,9 +620,9 @@ "integrity": "sha512-ZOpIfnQN4N1dM/JHSpQFzz+0jRW5mefy2BpzvFnvMBtp/IVY6+2Uw304cAIBuz56sKnTPP1FTBW7ndRuJDKpMQ==" }, "node_modules/@deriv/api-types": { - "version": "1.0.1447", - "resolved": "https://registry.npmjs.org/@deriv/api-types/-/api-types-1.0.1447.tgz", - "integrity": "sha512-5CJ2PBPWWFUvdap8LbEfdUQULGxTWYTjREYWqV27+TTyng05iQyhQCxbB2XZ4WhvKFYHGMM3ux0uUP+l2aC4NQ==", + "version": "1.0.1448", + "resolved": "https://registry.npmjs.org/@deriv/api-types/-/api-types-1.0.1448.tgz", + "integrity": "sha512-NNruSoFQXuhiOHW/GrRwgtkBwaOFUe8s6/yEVULUQIo9Umrs/ZM4VypT0MfarVJOYDJF3snqc8QidATB/bg5GA==", "license": "Apache-2.0" }, "node_modules/@deriv/deriv-api": { diff --git a/package.json b/package.json index 0dc336a..905ee79 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "license": "ISC", "dependencies": { "@deriv-com/utils": "^0.0.30", - "@deriv/api-types": "^1.0.1447", + "@deriv/api-types": "^1.0.1448", "@deriv/deriv-api": "^1.0.15", "@tanstack/react-query": "^5.51.16" }, diff --git a/src/api/non-authorize/index.tsx b/src/api/non-authorize/index.tsx index 23faa4d..f50f931 100644 --- a/src/api/non-authorize/index.tsx +++ b/src/api/non-authorize/index.tsx @@ -17,7 +17,6 @@ import { useTradingDurations } from './use-trading-durations'; import { useTradingPlatformLeverage } from './use-trading-platform-leverage'; import { useTradingPlatformProductListing } from './use-trading-platform-product-listing'; import { useTradingTimes } from './use-trading-times'; -import { useVerifyEmailCellxpert } from './use-verify-email-cellxpert'; import { useWebsiteConfig } from './use-website-config'; import { useWebsiteStatus } from './use-website-status'; export { @@ -40,7 +39,6 @@ export { useTradingPlatformLeverage, useTradingPlatformProductListing, useTradingTimes, - useVerifyEmailCellxpert, useWebsiteConfig, useWebsiteStatus, }; diff --git a/src/api/non-authorize/use-verify-email-cellxpert.tsx b/src/api/non-authorize/use-verify-email-cellxpert.tsx deleted file mode 100644 index 5d427a2..0000000 --- a/src/api/non-authorize/use-verify-email-cellxpert.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { useQuery } from '../../base'; -import { TSocketQueryOptions } from '../../base/use-query'; - -export const useVerifyEmailCellxpert = ({ - ...props -}: Omit, 'name'> = {}) => { - const { data, ...rest } = useQuery({ name: 'verify_email_cellxpert', ...props }); - - return { - data: data?.verify_email_cellxpert, - ...rest, - }; -}; diff --git a/src/types/api.types.ts b/src/types/api.types.ts index de9edee..7fe4514 100644 --- a/src/types/api.types.ts +++ b/src/types/api.types.ts @@ -231,8 +231,6 @@ import type { UpdateContractHistoryResponse, UpdateContractRequest, UpdateContractResponse, - VerifyEmailCellxpertRequest, - VerifyEmailCellxpertResponse, VerifyEmailRequest, VerifyEmailResponse, } from '@deriv/api-types'; @@ -1468,10 +1466,6 @@ type TSocketEndpoints = { request: UnsubscribeEmailRequest; response: UnsubscribeEmailResponse; }; - verify_email_cellxpert: { - request: VerifyEmailCellxpertRequest; - response: VerifyEmailCellxpertResponse; - }; verify_email: { request: VerifyEmailRequest; response: VerifyEmailResponse; From 902b87d21c486833ef63604d6754e02a426cc090 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 1 Aug 2024 13:41:44 +0800 Subject: [PATCH 5/8] fix: add wait mechanism and moving of subs to new connection --- src/client-library/deriv-api-client.ts | 29 +++++++++++++++++++++++-- src/client-library/deriv-api-manager.ts | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/client-library/deriv-api-client.ts b/src/client-library/deriv-api-client.ts index 00593da..a8a7231 100644 --- a/src/client-library/deriv-api-client.ts +++ b/src/client-library/deriv-api-client.ts @@ -26,6 +26,7 @@ type SubscriptionHandler = { name: T; status: 'active' | 'idle' | 'error'; data?: TSocketSubscribeResponseData; + payload: TSocketRequestPayload; counter: number; subscriptions: Map) => void>; onError?: (error: TSocketError['error']) => void; @@ -61,7 +62,10 @@ export class DerivAPIClient { subscribeHandler: SubscriptionMap; req_id: number; waitForWebSocketOpen: ReturnType; - waitForWebSocketCall?: ReturnType & { name: TSocketEndpointNames }; + waitForWebSocketCall?: ReturnType & { + name: TSocketEndpointNames; + type: 'all' | 'subscribe' | 'request'; + }; keepAliveIntervalId: NodeJS.Timeout | null = null; constructor(endpoint: string, options?: DerivAPIClientOptions) { @@ -84,6 +88,12 @@ export class DerivAPIClient { this.websocket.addEventListener('message', async response => { const parsedData = JSON.parse(response.data); + // If name matches for the calls you asynchronously wait, resolve + if (this.waitForWebSocketCall && parsedData.msg_type === this.waitForWebSocketCall?.name) { + const { resolve } = this.waitForWebSocketCall; + resolve({}); + } + if (parsedData.subscription || parsedData.echo_req?.subscribe) { const { req_id, ...payload } = parsedData.echo_req; const subscribeHash = await ObjectUtils.hashObject({ ...payload }); @@ -134,6 +144,9 @@ export class DerivAPIClient { this.requestHandler.set(this.req_id.toString(), newRequestHandler as RequestHandler); await this.waitForWebSocketOpen?.promise; + if (this.waitForWebSocketCall?.type === 'request' || this.waitForWebSocketCall?.type === 'all') { + await this.waitForWebSocketCall.promise; + } this.websocket.send(JSON.stringify(requestPayload)); return promise; @@ -149,12 +162,14 @@ export class DerivAPIClient { const subscriptionHash = await ObjectUtils.hashObject(subscriptionPayload); const matchingSubscription = this.subscribeHandler.get(subscriptionHash); + // If no existing subscription, create a new handler and send the subscribe payload if (!matchingSubscription) { this.req_id = this.req_id + 1; const newSubscriptionHandler: SubscriptionHandler = { name, status: 'idle', + payload: subscriptionPayload as unknown as TSocketRequestPayload, onError: onError, subscriptions: new Map(), subscription_id: '', @@ -168,10 +183,14 @@ export class DerivAPIClient { ); await this.waitForWebSocketOpen?.promise; + if (this.waitForWebSocketCall?.type === 'subscribe' || this.waitForWebSocketCall?.type === 'all') { + await this.waitForWebSocketCall.promise; + } this.websocket.send(JSON.stringify({ ...subscriptionPayload, req_id: this.req_id })); return { id: newSubscriptionHandler.counter, hash: subscriptionHash }; } else { + // If there is already a subscription, simply append the onData callback directly to the subscription list const currentCounter = matchingSubscription.counter + 1; matchingSubscription.subscriptions.set( currentCounter, @@ -203,7 +222,13 @@ export class DerivAPIClient { } } - async waitFor(name: TSocketEndpointNames) {} + async waitFor(name: TSocketEndpointNames, type: 'all' | 'subscribe' | 'request') { + this.waitForWebSocketCall = { ...PromiseUtils.createPromise(), name, type }; + } + + reinitializeSubscriptions(subscribeHandler: SubscriptionMap) { + this.subscribeHandler = subscribeHandler; + } isSocketClosingOrClosed() { return ![2, 3].includes(this.websocket.readyState); diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts index 900412e..a8fb856 100644 --- a/src/client-library/deriv-api-manager.ts +++ b/src/client-library/deriv-api-manager.ts @@ -39,6 +39,7 @@ export class DerivAPIManager { } const subscribeHandlers = { ...this.activeClient.subscribeHandler }; const newInstance = new DerivAPIClient(endpoint, this.options); + newInstance.reinitializeSubscriptions(subscribeHandlers); this.clientList.set(endpoint, newInstance); this.activeClient = newInstance; } From ef1dcf1d97c2b44ceecf70bfe1a3a927070a3d17 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Thu, 1 Aug 2024 15:27:36 +0800 Subject: [PATCH 6/8] feat: add reinit subscription --- src/client-library/deriv-api-client.ts | 5 ++++- src/client-library/deriv-api-manager.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client-library/deriv-api-client.ts b/src/client-library/deriv-api-client.ts index a8a7231..fb6a4de 100644 --- a/src/client-library/deriv-api-client.ts +++ b/src/client-library/deriv-api-client.ts @@ -226,8 +226,11 @@ export class DerivAPIClient { this.waitForWebSocketCall = { ...PromiseUtils.createPromise(), name, type }; } - reinitializeSubscriptions(subscribeHandler: SubscriptionMap) { + async reinitializeSubscriptions(subscribeHandler: SubscriptionMap) { this.subscribeHandler = subscribeHandler; + for (const subs of this.subscribeHandler.values()) { + await this.send({ name: subs.name, payload: subs.payload }); + } } isSocketClosingOrClosed() { diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts index a8fb856..228e2ef 100644 --- a/src/client-library/deriv-api-manager.ts +++ b/src/client-library/deriv-api-manager.ts @@ -31,7 +31,7 @@ export class DerivAPIManager { return this.activeClient.unsubscribe(args); } - switchConnection(endpoint: string) { + async switchConnection(endpoint: string) { const matchingInstance = this.clientList.get(endpoint); if (matchingInstance) { this.activeClient = matchingInstance; @@ -39,7 +39,7 @@ export class DerivAPIManager { } const subscribeHandlers = { ...this.activeClient.subscribeHandler }; const newInstance = new DerivAPIClient(endpoint, this.options); - newInstance.reinitializeSubscriptions(subscribeHandlers); + await newInstance.reinitializeSubscriptions(subscribeHandlers); this.clientList.set(endpoint, newInstance); this.activeClient = newInstance; } From 284ab7bd0a5927bf1a6ac41e95660bc70f059680 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Mon, 5 Aug 2024 11:36:03 +0800 Subject: [PATCH 7/8] feat: add reauthorization on switch --- src/client-library/deriv-api-client.ts | 17 ++++++++++++++++- src/client-library/deriv-api-manager.ts | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/client-library/deriv-api-client.ts b/src/client-library/deriv-api-client.ts index fb6a4de..053a52f 100644 --- a/src/client-library/deriv-api-client.ts +++ b/src/client-library/deriv-api-client.ts @@ -66,6 +66,7 @@ export class DerivAPIClient { name: TSocketEndpointNames; type: 'all' | 'subscribe' | 'request'; }; + authorizePayload: TSocketRequestPayload<'authorize'> | null = null; keepAliveIntervalId: NodeJS.Timeout | null = null; constructor(endpoint: string, options?: DerivAPIClientOptions) { @@ -149,6 +150,13 @@ export class DerivAPIClient { } this.websocket.send(JSON.stringify(requestPayload)); + if (name === 'authorize') { + const { req_id, ...cleanedPayload } = requestPayload as TSocketRequestPayload<'authorize'> & { + req_id: number; + }; + this.authorizePayload = cleanedPayload; + } + return promise; } @@ -226,7 +234,14 @@ export class DerivAPIClient { this.waitForWebSocketCall = { ...PromiseUtils.createPromise(), name, type }; } - async reinitializeSubscriptions(subscribeHandler: SubscriptionMap) { + async reinitializeSubscriptions( + subscribeHandler: SubscriptionMap, + authorizeData?: TSocketRequestPayload<'authorize'> | null + ) { + if (authorizeData) { + this.authorizePayload = authorizeData; + await this.send({ name: 'authorize', ...authorizeData }); + } this.subscribeHandler = subscribeHandler; for (const subs of this.subscribeHandler.values()) { await this.send({ name: subs.name, payload: subs.payload }); diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts index 228e2ef..859f82b 100644 --- a/src/client-library/deriv-api-manager.ts +++ b/src/client-library/deriv-api-manager.ts @@ -39,7 +39,7 @@ export class DerivAPIManager { } const subscribeHandlers = { ...this.activeClient.subscribeHandler }; const newInstance = new DerivAPIClient(endpoint, this.options); - await newInstance.reinitializeSubscriptions(subscribeHandlers); + await newInstance.reinitializeSubscriptions(subscribeHandlers, this.activeClient.authorizePayload); this.clientList.set(endpoint, newInstance); this.activeClient = newInstance; } From 76bdb4583ec1e7baef894af9969752af84f29d97 Mon Sep 17 00:00:00 2001 From: yashim-deriv Date: Mon, 5 Aug 2024 14:52:42 +0800 Subject: [PATCH 8/8] fix: subscription transfer to new connection --- sandbox/sandbox-page.tsx | 8 +++++++- src/base/index.ts | 14 ++++++++++++-- src/client-library/deriv-api-client.ts | 4 ++-- src/client-library/deriv-api-manager.ts | 2 +- src/context/api-context.tsx | 17 +++-------------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/sandbox/sandbox-page.tsx b/sandbox/sandbox-page.tsx index 8c4275c..e34a437 100644 --- a/sandbox/sandbox-page.tsx +++ b/sandbox/sandbox-page.tsx @@ -1,9 +1,10 @@ import React, { useEffect } from 'react'; import { useAccountList } from '../src/api/authorize'; import { URLUtils } from '@deriv-com/utils'; -import { useSubscribe } from '../src/base'; +import { useAPI, useSubscribe } from '../src/base'; export const SandboxPage = () => { + const { derivAPIClient } = useAPI(); const { data } = useAccountList(); const { data: exchangeRateData, subscribe: subscribeExchangeRates } = useSubscribe('exchange_rates'); const { @@ -14,6 +15,10 @@ export const SandboxPage = () => { error: ticksError, } = useSubscribe('ticks'); + const handleSwitchFrench = async () => { + await derivAPIClient.switchConnection('wss://blue.derivws.com/websockets/v3?app_id=36300&l=FR&brand=deriv'); + }; + useEffect(() => { const handleSubscribe = async () => { await subscribeExchangeRates({ base_currency: 'USD', target_currency: 'AED' }); @@ -37,6 +42,7 @@ export const SandboxPage = () => { Subscribe to Different Ticks + ); }; diff --git a/src/base/index.ts b/src/base/index.ts index 591b673..972a867 100644 --- a/src/base/index.ts +++ b/src/base/index.ts @@ -1,4 +1,4 @@ -import { useAppData, useAuthData } from './use-context-hooks'; +import { useAppData, useAuthData, useAPI } from './use-context-hooks'; import { useAuthorizeQuery } from './use-authorize-query'; import { useQuery } from './use-query'; import { useMutation } from './use-mutation'; @@ -6,4 +6,14 @@ import { useSubscribe } from './use-subscribe'; import { useAuthorizedSubscription } from './use-authorized-subscription'; import { useInfiniteQuery } from './use-infinite-query'; -export { useAppData, useAuthData, useAuthorizeQuery, useQuery, useMutation, useSubscribe, useAuthorizedSubscription, useInfiniteQuery }; +export { + useAppData, + useAuthData, + useAPI, + useAuthorizeQuery, + useQuery, + useMutation, + useSubscribe, + useAuthorizedSubscription, + useInfiniteQuery, +}; diff --git a/src/client-library/deriv-api-client.ts b/src/client-library/deriv-api-client.ts index 053a52f..58bc6c7 100644 --- a/src/client-library/deriv-api-client.ts +++ b/src/client-library/deriv-api-client.ts @@ -240,10 +240,10 @@ export class DerivAPIClient { ) { if (authorizeData) { this.authorizePayload = authorizeData; - await this.send({ name: 'authorize', ...authorizeData }); + await this.send({ name: 'authorize', payload: { ...authorizeData } }); } this.subscribeHandler = subscribeHandler; - for (const subs of this.subscribeHandler.values()) { + for (const subs of subscribeHandler.values()) { await this.send({ name: subs.name, payload: subs.payload }); } } diff --git a/src/client-library/deriv-api-manager.ts b/src/client-library/deriv-api-manager.ts index 859f82b..2b614d5 100644 --- a/src/client-library/deriv-api-manager.ts +++ b/src/client-library/deriv-api-manager.ts @@ -37,7 +37,7 @@ export class DerivAPIManager { this.activeClient = matchingInstance; return; } - const subscribeHandlers = { ...this.activeClient.subscribeHandler }; + const subscribeHandlers = this.activeClient.subscribeHandler; const newInstance = new DerivAPIClient(endpoint, this.options); await newInstance.reinitializeSubscriptions(subscribeHandlers, this.activeClient.authorizePayload); this.clientList.set(endpoint, newInstance); diff --git a/src/context/api-context.tsx b/src/context/api-context.tsx index 7455d9e..648a925 100644 --- a/src/context/api-context.tsx +++ b/src/context/api-context.tsx @@ -1,22 +1,11 @@ import { createContext, PropsWithChildren } from 'react'; import { URLUtils } from '@deriv-com/utils'; -import { DerivAPIClient } from '../client-library/deriv-api-client'; +import { DerivAPIManager } from '../client-library/deriv-api-manager'; -export const derivAPIClient = new DerivAPIClient(URLUtils.getWebsocketURL(), { - onOpen: () => { - localStorage.setItem('api.connecting', 'false'); - }, - onClose: () => { - const isConnecting = localStorage.getItem('api.connecting') ?? 'false'; - if (isConnecting === 'false') { - localStorage.setItem('api.connecting', 'true'); - window.location.reload(); - } - }, -}); +export const derivAPIClient = new DerivAPIManager(URLUtils.getWebsocketURL()); type APIData = { - derivAPIClient: DerivAPIClient; + derivAPIClient: DerivAPIManager; }; export const APIDataContext = createContext(null);