From d722c92979a6f2eab5eaa73b81591ba23f46aeae Mon Sep 17 00:00:00 2001 From: Bruno Gelatti Date: Tue, 3 Dec 2024 12:20:29 -0300 Subject: [PATCH] Changes to use new SDK --- Justfile | 3 +- package-lock.json | 149 ++++++++++++++---- package.json | 2 +- .../src/back/RealtimeConnection.ts | 3 +- .../tagoio-integration/src/back/Request.ts | 5 +- 5 files changed, 126 insertions(+), 36 deletions(-) diff --git a/Justfile b/Justfile index ea65e115..52dd5389 100644 --- a/Justfile +++ b/Justfile @@ -33,8 +33,9 @@ install: # The process.env is not working on Vite Build # This is a workaround to make it work -file_path := "./node_modules/@tago-io/sdk/out/regions.js" +file_path := "./node_modules/@tago-io/sdk/lib/regions.js" _pre-build: @sed -i'' -e 's/ process\.env\.TAGOIO_API/ window.process.env.TAGOIO_API/g' "{{file_path}}" @sed -i'' -e 's/ process\.env\.TAGOIO_REALTIME/ window.process.env.TAGOIO_REALTIME/g' "{{file_path}}" + @sed -i'' -e 's/ process\.env\.TAGOIO_SSE/ window.process.env.TAGOIO_SSE/g' "{{file_path}}" @echo "SDK patched" diff --git a/package-lock.json b/package-lock.json index a747dbfe..b6acaa96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "plugins/*" ], "dependencies": { - "@tago-io/sdk": "10.4.4", + "@tago-io/sdk": "11.3.6", "async": "3.2.6", "axios": "0.26.0", "body-parser": "2.0.1", @@ -3616,37 +3616,75 @@ } }, "node_modules/@tago-io/sdk": { - "version": "10.4.4", - "resolved": "https://registry.npmjs.org/@tago-io/sdk/-/sdk-10.4.4.tgz", - "integrity": "sha512-5rZxeJCRCCf0wfEVsFjS4OJL31YvRDDJSAA0OgEh1vkGtowO0JuYbASyZV6ZYxU4kczHCC4FfjkeIw5uu8G/hg==", + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/@tago-io/sdk/-/sdk-11.3.6.tgz", + "integrity": "sha512-UqZ2u460al5DQLh4kiA3ro+pldXF+3GT/kslgbJyfnuZnEz+zuqOuA8G3CndyqYfrm6xFH7LReXvj4BkzdgFow==", "license": "Apache-2.0", "dependencies": { - "axios": "0.25.0", + "axios": "1.7.4", "form-data": "4.0.0", - "lodash.chunk": "4.2.0", - "nanoid": "3.2.0", - "papaparse": "5.3.1", - "qs": "6.10.3", - "socket.io-client": "4.4.1" + "nanoid": "3.3.7", + "papaparse": "5.4.1", + "qs": "6.12.0", + "socket.io-client": "4.7.5" }, "engines": { - "node": ">=14.0.0", + "node": ">=16.0.0", "npm": ">=6.0.0" + }, + "optionalDependencies": { + "eventsource": "2.0.2" } }, + "node_modules/@tago-io/sdk/node_modules/@socket.io/component-emitter": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", + "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==", + "license": "MIT" + }, "node_modules/@tago-io/sdk/node_modules/axios": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.25.0.tgz", - "integrity": "sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/@tago-io/sdk/node_modules/engine.io-client": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz", + "integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.14.7" + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.17.1", + "xmlhttprequest-ssl": "~2.0.0" + } + }, + "node_modules/@tago-io/sdk/node_modules/engine.io-parser": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz", + "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" } }, "node_modules/@tago-io/sdk/node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" @@ -3656,12 +3694,12 @@ } }, "node_modules/@tago-io/sdk/node_modules/qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.0.tgz", + "integrity": "sha512-trVZiI6RMOkO476zLGaBIzszOdFPnCCXHPG9kn0yuS1uz6xdVxPfZdB3vUig9pxPFDM9BRAgz/YUIVQ1/vuiUg==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -3670,6 +3708,55 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/@tago-io/sdk/node_modules/socket.io-client": { + "version": "4.7.5", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.5.tgz", + "integrity": "sha512-sJ/tqHOCe7Z50JCBCXrsY3I2k03iOiUe+tj1OmKeD2lXPiGH/RUCdTZFoqVyN7l1MnpIzPrGtLcijffmeouNlQ==", + "license": "MIT", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.2", + "engine.io-client": "~6.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@tago-io/sdk/node_modules/socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "license": "MIT", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@tago-io/sdk/node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/@tago-io/tagocore-plugin-tagoio-integration": { "resolved": "plugins/tagoio-integration", "link": true @@ -8139,12 +8226,6 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "license": "MIT" }, - "node_modules/lodash.chunk": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz", - "integrity": "sha512-ZzydJKfUHJwHa+hF5X66zLFCBrWn5GeF28OHEr4WVWtNDXlQ/IjWKPBiikqKo2ne0+v6JgCgJ0GzJp8k8bHC7w==", - "license": "MIT" - }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -9719,9 +9800,9 @@ } }, "node_modules/papaparse": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.1.tgz", - "integrity": "sha512-Dbt2yjLJrCwH2sRqKFFJaN5XgIASO9YOFeFP8rIBRG2Ain8mqk5r1M6DkfvqEVozVcz3r3HaUGw253hA1nLIcA==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", + "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==", "license": "MIT" }, "node_modules/parent-module": { @@ -10282,6 +10363,12 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/pump": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", diff --git a/package.json b/package.json index 793f6e3d..e4c9c932 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "url": "git+https://github.com/tago-io/tcore.git" }, "dependencies": { - "@tago-io/sdk": "10.4.4", + "@tago-io/sdk": "11.3.6", "async": "3.2.6", "axios": "0.26.0", "body-parser": "2.0.1", diff --git a/plugins/tagoio-integration/src/back/RealtimeConnection.ts b/plugins/tagoio-integration/src/back/RealtimeConnection.ts index 17c77b61..306b301d 100644 --- a/plugins/tagoio-integration/src/back/RealtimeConnection.ts +++ b/plugins/tagoio-integration/src/back/RealtimeConnection.ts @@ -1,5 +1,6 @@ import os from "node:os"; import { URLSearchParams } from "node:url"; +import * as getConnectionURI from "@tago-io/sdk/lib/regions.js"; import { core, helpers, pluginStorage } from "@tago-io/tcore-sdk"; import EventSource from "eventsource"; import removeNullValues from "../../../../packages/sdk/src/Types/Helpers/removeNullValues.ts"; @@ -22,7 +23,7 @@ function startRealtimeCommunication(token: string) { const channel = "commands"; const params = new URLSearchParams({ token, channel }); - const url = `${process.env.TAGOIO_SSE}/events?${params.toString()}`; + const url = `${getConnectionURI.default.default("usa-1").sse}?${params.toString()}`; const connect = () => { events = new EventSource(url); diff --git a/plugins/tagoio-integration/src/back/Request.ts b/plugins/tagoio-integration/src/back/Request.ts index a4efff1c..e2d1d5f1 100644 --- a/plugins/tagoio-integration/src/back/Request.ts +++ b/plugins/tagoio-integration/src/back/Request.ts @@ -1,3 +1,4 @@ +import * as getConnectionURI from "@tago-io/sdk/lib/regions.js"; import axios from "axios"; /** @@ -6,7 +7,7 @@ import axios from "axios"; async function createTCore(token: string, data: any) { try { const response = await axios({ - url: `${process.env.TAGOIO_API}/tcore/instance`, + url: `${getConnectionURI.default.default("usa-1").api}/tcore/instance`, method: "POST", headers: { token }, data, @@ -28,7 +29,7 @@ async function sendDataToTagoio( ) { try { const response = await axios({ - url: `${process.env.TAGOIO_API}/tcore/sse/${connId}`, + url: `${getConnectionURI.default.default("usa-1").api}/tcore/sse/${connId}`, method: "POST", headers: { token }, data: {