From d1abebf068ac013903d516cafe9f2cec7d7c597e Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 6 Jul 2025 20:21:58 +0200 Subject: [PATCH] api/inventory: remove 'inventory' from api entirely --- pkgs/clan-app/ui-2d/src/queries/index.ts | 23 +------------------ .../clan-app/ui-2d/src/routes/modules/add.tsx | 21 ++--------------- .../ui-2d/src/routes/modules/details.tsx | 1 - pkgs/clan-cli/clan_lib/inventory/__init__.py | 11 --------- pkgs/clan-cli/clan_lib/machines/delete.py | 4 ++-- pkgs/clan-cli/clan_lib/tests/test_create.py | 2 +- 6 files changed, 6 insertions(+), 56 deletions(-) diff --git a/pkgs/clan-app/ui-2d/src/queries/index.ts b/pkgs/clan-app/ui-2d/src/queries/index.ts index 220d1bd07..29ea86116 100644 --- a/pkgs/clan-app/ui-2d/src/queries/index.ts +++ b/pkgs/clan-app/ui-2d/src/queries/index.ts @@ -33,27 +33,6 @@ export const createModulesQuery = ( }, })); -export const tagsQuery = (uri: string | undefined) => - useQuery(() => ({ - queryKey: [uri, "tags"], - placeholderData: [], - queryFn: async () => { - if (!uri) return []; - - const response = await callApi("get_inventory", { - flake: { identifier: uri }, - }).promise; - if (response.status === "error") { - console.error("Failed to fetch data"); - } else { - const machines = response.data.machines || {}; - const tags = Object.values(machines).flatMap((m) => m.tags || []); - return tags; - } - return []; - }, - })); - export const machinesQuery = (uri: string | undefined) => useQuery(() => ({ queryKey: [uri, "machines"], @@ -61,7 +40,7 @@ export const machinesQuery = (uri: string | undefined) => queryFn: async () => { if (!uri) return []; - const response = await callApi("get_inventory", { + const response = await callApi("list_machines", { flake: { identifier: uri }, }).promise; if (response.status === "error") { diff --git a/pkgs/clan-app/ui-2d/src/routes/modules/add.tsx b/pkgs/clan-app/ui-2d/src/routes/modules/add.tsx index d732312ee..e87133bb3 100644 --- a/pkgs/clan-app/ui-2d/src/routes/modules/add.tsx +++ b/pkgs/clan-app/ui-2d/src/routes/modules/add.tsx @@ -1,5 +1,5 @@ import { BackButton } from "@/src/components/BackButton"; -import { createModulesQuery, machinesQuery, tagsQuery } from "@/src/queries"; +import { createModulesQuery, machinesQuery } from "@/src/queries"; import { useParams } from "@solidjs/router"; import { For, Match, Switch } from "solid-js"; import { ModuleInfo } from "./list"; @@ -34,28 +34,11 @@ interface AddModuleProps { const AddModule = (props: AddModuleProps) => { const { activeClanURI } = useClanContext(); - const tags = tagsQuery(activeClanURI()); const machines = machinesQuery(activeClanURI()); return (
Add to your clan
- - - {(tags) => ( - - {(role) => ( - <> -
{role}s
- - - )} -
- )} -
-
+ Removed
); }; diff --git a/pkgs/clan-app/ui-2d/src/routes/modules/details.tsx b/pkgs/clan-app/ui-2d/src/routes/modules/details.tsx index de8b35f9f..3e40a9f8d 100644 --- a/pkgs/clan-app/ui-2d/src/routes/modules/details.tsx +++ b/pkgs/clan-app/ui-2d/src/routes/modules/details.tsx @@ -62,7 +62,6 @@ const Details = (props: DetailsProps) => { navigate(`/modules/add/${props.id}`); // const uri = activeURI(); // if (!uri) return; - // const res = await callApi("get_inventory", { base_path: uri }); // if (res.status === "error") { // toast.error("Failed to fetch inventory"); // return; diff --git a/pkgs/clan-cli/clan_lib/inventory/__init__.py b/pkgs/clan-cli/clan_lib/inventory/__init__.py index 7409ce8fe..e2fd4eba4 100644 --- a/pkgs/clan-cli/clan_lib/inventory/__init__.py +++ b/pkgs/clan-cli/clan_lib/inventory/__init__.py @@ -10,14 +10,3 @@ Which is an abstraction over the inventory Interacting with 'clan_lib.inventory' is NOT recommended and will be removed """ - -from clan_lib.api import API -from clan_lib.flake import Flake -from clan_lib.persist.inventory_store import InventorySnapshot, InventoryStore - - -@API.register -def get_inventory(flake: Flake) -> InventorySnapshot: - inventory_store = InventoryStore(flake) - inventory = inventory_store.read() - return inventory diff --git a/pkgs/clan-cli/clan_lib/machines/delete.py b/pkgs/clan-cli/clan_lib/machines/delete.py index 68f210cb8..7d642a1d7 100644 --- a/pkgs/clan-cli/clan_lib/machines/delete.py +++ b/pkgs/clan-cli/clan_lib/machines/delete.py @@ -9,7 +9,7 @@ from clan_cli.secrets.secrets import ( list_secrets, ) -from clan_lib import inventory +from clan_lib.persist.inventory_store import InventoryStore from clan_lib.api import API from clan_lib.dirs import specific_machine_dir from clan_lib.machines.machines import Machine @@ -19,7 +19,7 @@ log = logging.getLogger(__name__) @API.register def delete_machine(machine: Machine) -> None: - inventory_store = inventory.InventoryStore(machine.flake) + inventory_store = InventoryStore(machine.flake) try: inventory_store.delete( {f"machines.{machine.name}"}, diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index 4f56a3192..9b5ab7b81 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -22,7 +22,7 @@ from clan_lib.cmd import RunOpts, run from clan_lib.dirs import specific_machine_dir from clan_lib.errors import ClanError from clan_lib.flake import Flake -from clan_lib.inventory import InventoryStore +from clan_lib.persist.inventory_store import InventoryStore from clan_lib.machines.machines import Machine from clan_lib.nix import nix_command from clan_lib.nix_models.clan import (