MDK Logo
ReferenceUI Kitui-foundation

Query helpers

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

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.
addThingCommentMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "thing", "comment", "add"]; mutationFn: (body: …TanStack Mutation factory for `POST /auth/thing/comment` — add a device comment. Requires the `comments:write` permission; the backend stamps the author from the session token.
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: ({ signal }?: …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: ({ signal }?: …`GET /auth/pools/stats/containers` — per-container override counts.
containerSettingsQueryquery(client: QueryClient, options: { model?: string; overwriteCache?: boolean } = {}, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "global", "data", …Convenience wrapper around `globalDataQuery` pinned to `type=containerSettings` — per-model container thresholds/parameters. Verified live: the response is a flat `ContainerSettingsEntry[]`, not the per-Kernel envelope.
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.
createGetQueryFnquery(fetcher: Fetcher, url: string) => ({ signal }?: QueryFnContext) => Promise<T>Build a signal-aware GET `queryFn` for an already-resolved `url`. This is the single place the `AbortSignal` is threaded into the fetcher: TanStack cancels a query (firing the signal) when its last observer unmounts on navigation, or when…
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.
deleteThingCommentMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "thing", "comment", "delete"]; mutationFn: (body: …TanStack Mutation factory for `DELETE /auth/thing/comment` — remove an existing device comment (`body.id` identifies it; the schema still requires the full body on delete).
deviceQueryquery(client: QueryClient, id: string, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["devices", string]; queryFn: ({ signal }?: …TanStack Query factory for a single device by id (`/devices/:id`).
devicesQueryquery(client: QueryClient, fetcher: Fetcher = defaultFetcher) => { queryKey: readonly ["devices"]; queryFn: ({ signal }?: …TanStack Query factory for the full `/devices` inventory listing.
editThingCommentMutationquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { mutationKey: readonly ["auth", "thing", "comment", "edit"]; mutationFn: (body: …TanStack Mutation factory for `PUT /auth/thing/comment` — edit an existing device comment (`body.id` identifies it).
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…
featureConfigQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "featureConfig"]; queryFn: ({ signal }?: …TanStack Query factory for `GET /auth/featureConfig` — deployment feature flags, including the multi-site mode switch. Note the camelCase path: there is no `/auth/feature-config` route (a kebab-case request falls through to the SPA fallbac…
getApiBaseUrlquery(client: QueryClient) => stringRead the configured base URL back from a `QueryClient` produced by `createMdkQueryClient`. Falls back to the default if metadata is absent.
globalConfigQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "global-config"]; queryFn: ({ signal }?: …TanStack Query factory for `GET /auth/global-config` — the global system config document. Shape is deployment-specific (not yet captured live), so callers narrow via the generic.
globalDataQueryquery(client: QueryClient, params: GlobalDataParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "global", "data", …TanStack Query factory for `GET /auth/global/data`. Generic in the row type — see `containerSettingsQuery` for the canonical narrowing.
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'`).
listRacksQueryquery(client: QueryClient, params: ListRacksParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "list-racks", …TanStack Query factory for `GET /auth/list-racks`. `type` (worker type, e.g. `miner` / `container`) is required — the backend 400s with `ERR_TYPE_INVALID` without it. Response is the per-Kernel nested envelope.
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", …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.
pduLayoutQueryquery(client: QueryClient, params: PduLayoutParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "pdu-layout", …TanStack Query factory for `GET /auth/pdu-layout` — the static PDU socket grid for a container type. The backend sources it from the container worker's `pduGridLayout` config keyed by the exact type string, and 400s with `ERR_PDU_LAYOUT_NO…
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: ({ signal }?: …`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: ({ signal }?: …`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: ({ signal }?: …`GET /auth/pools` — aggregated pools (hashrate / workers / balance / revenue). Feeds the Dashboard pool panel.
resolveApiBaseUrlquery(override?: string) => stringResolves the Gateway API base URL using the priority order described in HLD §2.4 / §5:
siteQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "site"]; queryFn: ({ signal }?: …TanStack Query factory for `GET /auth/site` — the configured site label.
siteStatusLiveQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "site", "status", "live"]; queryFn: ({ signal }?: …`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? }`).
tailLogMultiQueryquery(client: QueryClient, params: TailLogMultiParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "tail-log", "multi", …TanStack Query factory for `GET /auth/tail-log/multi` — the batched variant of tail-log (`keys` is a comma-separated list of `stat-*` keys). Returns the same per-worker nested envelope as `tailLogQuery`, one series per requested key.
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: ({ signal }?: …TanStack Query factory for live telemetry of a device (`/telemetry/:deviceId`).
thingConfigQueryquery(client: QueryClient, params: ThingConfigParams, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "thing-config", …TanStack Query factory for `GET /auth/thing-config` — a thing type's config document (Settings tab). Both params are required by the backend schema. Response shape is worker-specific, so callers narrow via the generic.
userInfoQueryquery(client: QueryClient, fetcher: Fetcher = mdkFetch) => { queryKey: readonly ["auth", "userinfo"]; queryFn: ({ signal }?: …`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.