diff --git a/biome.jsonc b/biome.jsonc index 1c4c3468..cc0b3914 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { "enabled": false, "clientKind": "git", @@ -7,12 +7,7 @@ }, "files": { "ignoreUnknown": false, - "ignore": [ - "build", - "build-tsc", - "standalone-plugins", - "standalone" - ] + "ignore": ["build", "build-tsc", "standalone-plugins", "standalone"] }, "formatter": { "enabled": true, diff --git a/package.json b/package.json index 5c5d1cd2..65085116 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,8 @@ "node": ">=20.0.0" }, "type": "module", - "workspaces": [ - "packages/*", - "plugins/*" - ], - "keywords": [ - "platform", - "iot", - "tagoio", - "tcore" - ], + "workspaces": ["packages/*", "plugins/*"], + "keywords": ["platform", "iot", "tagoio", "tcore"], "bugs": { "url": "https://github.com/tago-io/tcore/issues" }, diff --git a/packages/console/biome.jsonc b/packages/console/biome.jsonc index bf4046db..d60ef52d 100644 --- a/packages/console/biome.jsonc +++ b/packages/console/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { "enabled": false, "clientKind": "git", diff --git a/packages/console/src/Components/Navbar/Navbar.tsx b/packages/console/src/Components/Navbar/Navbar.tsx index 85955948..09630379 100644 --- a/packages/console/src/Components/Navbar/Navbar.tsx +++ b/packages/console/src/Components/Navbar/Navbar.tsx @@ -18,9 +18,6 @@ import { EIcon } from "../Icon/Icon.types"; import Link from "../Link/Link.tsx"; import * as Style from "./Navbar.style"; -/** - * Props. - */ interface INavbarProps { /** * This function will be called when the user presses the sidebar button. It should @@ -41,15 +38,10 @@ interface INavbarProps { * This is the main navigation bar located at the top of the page. */ function Navbar(props: INavbarProps) { - // const theme = useTheme(); - // const updateTheme = useContext(ThemeUpdateContext); const { logoWidth, onSidebarToggle } = props; const navigate = useNavigate(); const theme = useTheme(); - /** - * Removes the account, token, and goes back to the /console/login route. - */ const signOut = useCallback(() => { store.account = undefined; store.token = ""; @@ -57,9 +49,6 @@ function Navbar(props: INavbarProps) { navigate("/console/login"); }, [navigate]); - /** - * Renders the navbar buttons for a specific plugin. - */ const renderNavbarButtons = ( plugin: IPluginListItem, buttons: IPluginButtonModuleSetupOption[], @@ -121,12 +110,6 @@ function Navbar(props: INavbarProps) { {store.plugins.map((x) => renderNavbarButtons(x, x.buttons.navbar))} - - - - diff --git a/packages/console/src/Components/Sidebar/Sidebar.tsx b/packages/console/src/Components/Sidebar/Sidebar.tsx index 9b4678e9..6eb51c6e 100644 --- a/packages/console/src/Components/Sidebar/Sidebar.tsx +++ b/packages/console/src/Components/Sidebar/Sidebar.tsx @@ -47,12 +47,12 @@ function Sidebar(props: ISidebarProps) { }, }, { - color: theme.bucket, - icon: EIcon.bucket, - text: "Buckets", + text: "Store", + icon: EIcon.store, + color: theme.settings, action: { type: "open-url", - url: "/console/buckets/", + url: "/console/pluginstore", }, }, { @@ -74,12 +74,12 @@ function Sidebar(props: ISidebarProps) { }, }, { - text: "Store", - icon: EIcon.store, + text: "Logs", + icon: EIcon.scroll, color: theme.settings, action: { type: "open-url", - url: "/console/pluginstore", + url: "/logs", }, }, { diff --git a/packages/sdk/src/Types/DeviceData/DeviceData.types.ts b/packages/sdk/src/Types/DeviceData/DeviceData.types.ts index 2a90fe48..cc364d7a 100644 --- a/packages/sdk/src/Types/DeviceData/DeviceData.types.ts +++ b/packages/sdk/src/Types/DeviceData/DeviceData.types.ts @@ -24,11 +24,11 @@ function handleDates( timezone: string, type: "start" | "end", ): Date { - let date: any = new Date(rawDate); + let date: Date | "never" | undefined = new Date(rawDate); - if (!isDate(rawDate)) { + if (!isDate(date)) { try { - date = parseRelativeDate(rawDate, type === "start" ? "minus" : "plus"); + date = parseRelativeDate(date, type === "start" ? "minus" : "plus"); } catch (ex) { throw new Error(`Invalid ${type} date`); } diff --git a/plugins/tagoio-integration/package.json b/plugins/tagoio-integration/package.json index f833cd73..a618d055 100644 --- a/plugins/tagoio-integration/package.json +++ b/plugins/tagoio-integration/package.json @@ -24,7 +24,11 @@ "watch": "vite", "build": "vite build", "build-watch": "vite build --watch", - "test": "vitest" + "test": "vitest", + "check-types": "tsc --noEmit", + "lint": "biome check .", + "format": "biome format . --write", + "lint-fix": "biome check . --write" }, "dependencies": { "path-browserify": "1.0.1", diff --git a/plugins/tagoio-integration/src/front/App.tsx b/plugins/tagoio-integration/src/front/App.tsx index 0f3a64d0..304decfe 100644 --- a/plugins/tagoio-integration/src/front/App.tsx +++ b/plugins/tagoio-integration/src/front/App.tsx @@ -17,7 +17,7 @@ function App() { /** * Fetches the tcore instance and sets it locally. */ - const fetchTCore = async () => { + const fetchTCore = useCallback(async () => { const location = window.location; axios .get(`${location.protocol}//${location.hostname}:${port}/tcore`) @@ -28,7 +28,7 @@ function App() { .catch(() => { setLoading(false); }); - }; + }, [port]); /** * Signs out. @@ -40,7 +40,7 @@ function App() { ); setTCore(null); setLoading(false); - }, []); + }, [port]); /** * Tries to fetch tcore once we load the app. @@ -49,7 +49,7 @@ function App() { if (port) { fetchTCore(); } - }, [port]); + }, [port, fetchTCore]); /** * TODO: diff --git a/plugins/tagoio-integration/src/front/Details/Details.tsx b/plugins/tagoio-integration/src/front/Details/Details.tsx index ecb8a4ef..92380cbf 100644 --- a/plugins/tagoio-integration/src/front/Details/Details.tsx +++ b/plugins/tagoio-integration/src/front/Details/Details.tsx @@ -53,7 +53,7 @@ function Details(props: IDetailsProps) { `${location.protocol}//${location.hostname}:${port}/tcore`, { active }, ); - }, [active]); + }, [active, port]); /** * Called when the active changes. diff --git a/plugins/tagoio-integration/tsconfig.json b/plugins/tagoio-integration/tsconfig.json new file mode 100644 index 00000000..66a79e94 --- /dev/null +++ b/plugins/tagoio-integration/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "outDir": "./build-tsc", + "rootDir": "./src", + "baseUrl": ".", + "jsx": "react-jsx", + "noImplicitAny": true, + "declaration": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler" + }, + "include": ["types/index.d.ts", "src/**/*", "vite-env.d.ts"], + "exclude": ["src/**/*.test.tsx", "src/**/__mocks__/*", "node_modules"] +} diff --git a/plugins/tagoio-integration/types/index.d.ts b/plugins/tagoio-integration/types/index.d.ts new file mode 100644 index 00000000..c20ba98a --- /dev/null +++ b/plugins/tagoio-integration/types/index.d.ts @@ -0,0 +1,25 @@ +/** + * PNG imports will return a string containing the path to the image. + */ +declare module "*.png" { + const content: string; + export default content; +} + +/** + * GIF imports will return a string containing the path to the image. + */ +declare module "*.gif" { + const content: string; + export default content; +} + +/** + * SVG imports will return the actual `` tag in a React component via SVGR. + */ +declare module "*.svg" { + import type React from "react"; + const SVG: React.VFC>; + + export default SVG; +} diff --git a/plugins/tagoio-integration/vite-env.d.ts b/plugins/tagoio-integration/vite-env.d.ts new file mode 100644 index 00000000..d8161248 --- /dev/null +++ b/plugins/tagoio-integration/vite-env.d.ts @@ -0,0 +1 @@ +///