MDK Logo
UI Kitui-core

Query helpers

TanStack Query helpers exported by @tetherto/mdk-ui-core.

HelperCategorySignatureDescription
actionsQueryquery(client: QueryClient, params: ActionsParams = {}, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "actions", …`GET /auth/actions` — pending/voting actions list (the review-tray source). Array params serialize comma-separated.
appendCommaQueryquery(url: string, params: Record<string, unknown>) => stringAppend query params to a URL, serializing array values comma-separated (e.g. `{ ids: ['a', 'b'] }` → `?ids=a,b`). Mirrors the `qs` `arrayFormat: 'comma'` convention MiningOS expects, without the extra dependency. `undefined` / `null` and e…
authQueryquery(client: QueryClient, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["auth"]; queryFn: () => Promise<unknown>; }TanStack Query factory for the `/auth` session lookup. Pass into `useQuery(authQuery(client))` to fetch the current session.
authTokenMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "token"]; mutationFn: (body?: …TanStack Mutation factory for `POST /auth/token`. Used by `useTokenPolling` to refresh the session token every 250 s.
cancelActionsMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "actions", "cancel"]; mutationFn: ({ type, ids }: …`DELETE /auth/actions/:type/cancel?ids=<comma>` — cancel pending actions.
containerPoolStatsQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "pools", "stats", "containers"]; queryFn: () => Promise<…`GET /auth/pools/stats/containers` — per-container override counts.
createBearerFetcherquery(options: { /** Override the token source — defaults to `authStore.getState().token`. */ getToken?: () => string | null /** Override `fetch` — pass a stub in tests. */ fetchImpl?: typeof fetch } = {}…Build a `Fetcher` that injects `Authorization: Bearer <token>` from the supplied token getter (defaults to `authStore`). Non-2xx responses throw an `MdkFetchError` carrying the HTTP status and parsed body.
createMdkQueryClientquery(options: CreateMdkQueryClientOptions = {}) => QueryClientBuild a TanStack `QueryClient` configured with the resolved API base URL. The base URL is exposed via `client.getDefaultOptions().queries.meta` so callers can read it without importing the `resolveApiBaseUrl` helper.
deviceQueryquery(client: QueryClient, id: string, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["devices", string]; queryFn: () => Promise<unknown>; }TanStack Query factory for a single device by id (`/devices/:id`).
devicesQueryquery(client: QueryClient, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["devices"]; queryFn: () => Promise<unknown>; }TanStack Query factory for the full `/devices` inventory listing.
extDataQueryquery(client: QueryClient, params: ExtDataParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "ext-data", …TanStack Query factory for `GET /auth/ext-data`. Generic in the response row type so adapters can pin the result to a typed envelope (see `minerpoolStatsQuery` for the canonical narrowing). `query` is a JSON-stringified provider-specific s…
getApiBaseUrlquery(client: QueryClient) => stringRead the configured base URL back from a `QueryClient` produced by `createMdkQueryClient`. Falls back to the default if metadata is absent.
historyLogQueryquery(client: QueryClient, params: HistoryLogParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "history-log", …TanStack Query factory for `GET /auth/history-log`. `logType` is required (`'alerts' | 'info'`).
listThingsQueryquery(client: QueryClient, params: ListThingsParams = {}, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "list-things", …TanStack Query factory for `GET /auth/list-things`. `query` and `fields` are Mongo-style selectors passed as already-stringified JSON.
liveActionsQueryquery(client: QueryClient, queries: ActionTypeQuery[] = [ { type: 'voting', opts: { reverse: true, limit: LIVE_ACTIONS_LIMIT } }, { type: 'ready', opts: { reverse: true, limit: LIVE_ACTIONS_LIMIT } }, { t…`GET /auth/actions?queries=…` — polls all action types in a single request using the multi-type query format. Returns the typed response map `{ voting, ready, executing, done }`.
mdkFetchqueryFetcherModule-level singleton bearer fetcher reading from the global `authStore`. Used as the default by the mining query factories (`tailLogQuery`, etc.).
minerpoolStatsQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "ext-data", ExtD…Convenience wrapper around `extDataQuery` pinned to `type=minerpool` and `query={"key":"stats"}`. Returns the canonical `MinerpoolExtDataEntry[][]` envelope so the pool counts hook can `_head(_head(...))` without casts.
minersQueryquery(client: QueryClient, params: MinersParams = {}, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "miners", …`GET /auth/miners` — miners with their assigned `poolConfig` (Miner Explorer rows). `filter` / `fields` / `sort` are JSON-stringified selectors. Returns the paginated {@link MinersResponse} envelope.
poolBalanceHistoryQueryquery(client: QueryClient, pool: string, params: PoolBalanceHistoryParams = {}, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "pools", string, "balance-history", …`GET /auth/pools/:pool/balance-history` — per-pool revenue/hashrate history for the chart view.
poolConfigForDeviceQueryquery(client: QueryClient, minerId: string, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "pools", "config", string]; queryFn: () => Promise<…`GET /auth/pools/config/:minerId` — pool config + override count for a single device/miner.
poolConfigsQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "configs", "pool"]; queryFn: () => Promise<…`GET /auth/configs/pool` — raw pool configurations. The shape the devkit `usePoolConfigs` transform consumes.
poolsQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "pools"]; queryFn: () => Promise<…`GET /auth/pools` — aggregated pools (hashrate / workers / balance / revenue). Feeds the Dashboard pool panel.
resolveApiBaseUrlquery(override?: string) => stringResolves the App Node API base URL using the priority order described in HLD §2.4 / §5:
siteStatusLiveQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "site", "status", "live"]; queryFn: () => Promise<…`GET /auth/site/status/live?overwriteCache=true` — composite live site-status snapshot (hashrate / power / efficiency / miner, alert & pool counts). Polled on a short interval by `useSiteStatusLive`; `overwriteCache` bypasses the server-si…
submitActionMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "actions", "submit"]; mutationFn: (payload: …`POST /auth/actions/voting` — submit a single staged action. The backend exposes a fixed `voting` path, so the client-only `type` field is stripped from the body; the remaining fields (`query`, `action`, `params`, `rackType`, …) form the r…
submitBatchActionMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "actions", "submit", "batch"]; mutationFn: (payload: …`POST /auth/actions/voting/batch` — submit a batch of staged actions in one request. Expects the {@link SubmitBatchActionsPayload} body (`{ batchActionsPayload, batchActionUID, suffix? }`).
tailLogQueryquery(client: QueryClient, params: TailLogParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "tail-log", …TanStack Query factory for `GET /auth/tail-log`. Returns the raw nested response shape (`Array<Array<TailLogEntry>>`) — callers unwrap with `_head(response)` (or a typed `select` projection).
telemetryQueryquery(client: QueryClient, deviceId: string, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["telemetry", string]; queryFn: () => Promise<unknown>; }TanStack Query factory for live telemetry of a device (`/telemetry/:deviceId`).
userInfoQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "userinfo"]; queryFn: () => Promise<…`GET /auth/userinfo` — current authenticated user's profile. Used to resolve the caller's email for partitioning live actions into "mine vs others".
voteActionMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "actions", "vote"]; mutationFn: ({ id, approve }: …`PUT /auth/actions/voting/:id/vote` — approve or reject a pending action.