MDK Logo

General

General-purpose utility functions

General-purpose helper functions.

Package

@tetherto/mdk-ui-foundation

Utilities

@tetherto/mdk-ui-foundation

Import the public APIs on this page from @tetherto/mdk-ui-foundation.

ALERT_TYPE_POOL_NAME

Constant

{ readonly ip_worker_name: "IP worker name"; readonly wrong_miner_pool: "Wrong miner pool"; readonly wrong_worker_name: "Wrong worker name"; readonly wrong_miner_subaccount: "Wrong miner subaccount";…

ALERT_TYPE_POOL_VALUE

Constant

{ readonly IP_WORKER_NAME: "ip_worker_name"; readonly WRONG_MINER_POOL: "wrong_miner_pool"; readonly WRONG_WORKER_NAME: "wrong_worker_name"; readonly WRONG_MINER_SUBACCOUNT: "wrong_miner_subaccount";…

appendContainerToTag

Function

(deviceId: string) => string

appendIdToTag

Function

(deviceId: string) => string

appendIdToTags

Function

(deviceIdList: string[]) => string[]

AUTH_LEVELS

Constant

{ readonly READ: "r"; readonly WRITE: "w"; }

AUTH_PERMISSIONS

Constant

{ readonly TEMP: "temp"; readonly MINER: "miner"; readonly USERS: "users"; readonly ALERTS: "alerts"; readonly TICKETS: "tickets"; readonly ACTIONS: "actions"; readonly REVENUE: "revenue"; readonly F…

AUTH_TOKEN_QUERY_PARAM

Pure URL helpers shared by the auth flow. Kept framework-agnostic so the react-adapter (and any future framework adapter) can call them without pulling in router-specific APIs.

Constant

"authToken"

CABINET_DEVICES_TYPES_NAME_MAP

Constant

{ readonly "powermeter-abb-b24": "Powermeter ABB B24"; readonly "sensor-temp-seneca": "Sensor Temp Seneca"; readonly "powermeter-abb-m4m20": "Powermeter ABB M4M20"; readonly "powermeter-abb-m1m20": "…

checkPermission

Check if user has the requested permission

Function

(config: AuthConfig | null | undefined, { perm, write, cap }: PermissionCheck) => boolean

COMPLETE_CONTAINER_TYPE

Constant

{ readonly BITMAIN_HYDRO: "container-as-hk3"; readonly BITDEER_M30: "container-bd-d40-m30"; readonly BITDEER_M56: "container-bd-d40-m56"; readonly MICROBT_ALPHA: "container-mbt-alpha"; readonly BITDE…

COMPLETE_MINER_TYPES

Constant

{ readonly ANTMINER_AM_S21: "miner-am-s21"; readonly WHATSMINER_WM_63: "miner-wm-m63"; readonly WHATSMINER_WM_53: "miner-wm-m53s"; readonly AVALON_AV_a1346: "miner-av-a1346"; readonly WHATSMINER_WM_5…

CONTAINER_MODEL

Container tag / type / threshold literals. Data-layer contracts shared across the toolkit — owned by ui-foundation so the React layers stay free of tag strings.

Constant

{ readonly M221: "m221"; readonly GAMMA: "gamma"; readonly BITDEER: "bitdeer"; readonly BITMAIN: "bitmain"; readonly MICROBT: "microbt"; readonly ANTSPACE: "antspace"; readonly BITMAIN_IMM: "bitmain-…

CONTAINER_SETTINGS_MODEL

Constant

{ BITDEER: string; MICROBT: string; HYDRO: string; IMMERSION: string; }

CONTAINER_STATUS

Constant

{ readonly RUNNING: "running"; readonly OFFLINE: "offline"; readonly STOPPED: "stopped"; }

CONTAINER_TAB

Container detail-view tab keys. The per-model availability matrix lives in utils/container-tabs.ts.

Constant

{ readonly PDU: "pdu"; readonly HOME: "home"; readonly ALARM: "alarm"; readonly CHARTS: "charts"; readonly HEATMAP: "heatmap"; readonly CONTROLS: "controls"; readonly SETTINGS: "settings"; readonly P…

CONTAINER_TACTICS_TYPE

Constant

{ readonly COIN: "coin"; readonly DISABLED: "disabled"; readonly ELECTRICITY: "electricity"; }

CONTAINER_TYPE

Constant

{ readonly BITDEER: "bd"; readonly ANTSPACE: "as"; readonly MICROBT: "mbt"; readonly ANTSPACE_HYDRO: "as-hk3"; readonly ANTSPACE_IMMERSION: "as-immersion"; }

CONTAINER_TYPE_NAME_MAP

Constant

{ readonly "container-bd-d40-m30": "Bitdeer M30"; readonly "container-bd-d40-m56": "Bitdeer M56"; readonly "container-bd-d40-s19xp": "Bitdeer S19XP"; readonly "container-as-hk3": "Bitmain Hydro"; rea…

CONTAINERS_MINER_TYPE

Constant

{ readonly M56: "m56"; readonly M30: "m30"; readonly A1346: "a1346"; readonly S19XP: "s19xp"; }

exportSettingsToFile

Function

(data: SettingsExportData) => string

filterUsers

Function

({ users, email, role }: FilterUsersParams) => SettingsUser[]

formatLastActive

Function

(timestamp: string | undefined) => string

formatRoleLabel

Function

(role: string) => string

GATEWAY_REFRESH_INTERVAL_MS

Refresh cadence — 250 s. The Gateway's token TTL defaults to 5 min, so this refreshes comfortably inside the window.

Constant

250000

getRolesFromAuthToken

Extract roles from authentication token

Function

(authToken?: string) => string[]

isAntminer

Function

(type: string | undefined) => boolean

isAvalon

Function

(type: string | undefined) => boolean

isContainer

Function

(type: string | undefined) => boolean

isMiner

Function

(type: string | undefined) => boolean

isWhatsminer

Function

(type: string | undefined) => boolean

LV_CABINET_DEVICES_TAG

Constant

{ readonly POWERMETER: "t-powermeter"; readonly SENSOR_TEMP: "t-sensor-temp"; }

LV_CABINET_DEVICES_TYPE

Constant

{ readonly POWERMETER_ABB_B24: "powermeter-abb-b24"; readonly SENSOR_TEMP_SENECA: "sensor-temp-seneca"; readonly POWERMETER_ABB_M1M20: "powermeter-abb-m1m20"; readonly POWERMETER_ABB_M4M20: "powermet…

MAINTENANCE_CONTAINER

Constant

"maintenance"

MINER_BRAND_NAMES

Constant

{ readonly av: "Avalon"; readonly am: "Antminer"; readonly wm: "Whatsminer"; }

MINER_MODEL

Device / miner / power-meter tag + type literals. These are data-layer contracts shared between the API surface and the UI — owned by ui-foundation so the React layers can stay free of tag strings.

Constant

{ readonly AVALON: "avalon"; readonly ANTMINER: "antminer"; readonly WHATSMINER: "whatsminer"; }

MINER_MODEL_TO_TYPE_MAP

Constant

{ readonly av: "avalon"; readonly am: "antminer"; readonly wm: "whatsminer"; }

MINER_POWER_MODE

Constant

{ readonly SLEEP: "sleep"; readonly LOW: "low"; readonly NORMAL: "normal"; readonly HIGH: "high"; }

MINER_TYPE

Constant

{ readonly AVALON: "av"; readonly ANTMINER: "am"; readonly WHATSMINER: "wm"; }

MINER_TYPE_MESSAGE

Constant

{ readonly "miner-av-a1346": "A1346 miners do not report consumption individually, so Avg. efficiency cannot be calculated"; }

MINER_TYPE_NAME_MAP

Constant

{ readonly "miner-av-a1346": "Avalon A1346"; readonly "miner-am-s21": "Antminer S21"; readonly "miner-wm-m63": "Whatsminer M63"; readonly "miner-wm-m56s": "Whatsminer M56S"; readonly "miner-wm-m53s":…

MinerStatuses

Constant

{ readonly MINING: "mining"; readonly OFFLINE: "offline"; readonly SLEEPING: "sleeping"; readonly ERROR: "error"; readonly NOT_MINING: "not_mining"; readonly MAINTENANCE: "maintenance"; readonly ALER…

NO_MAINTENANCE_CONTAINER

Constant

"no_maintenance"

ONE_DAY_MS

One day in milliseconds.

Constant

number

parseSettingsFile

Function

(file: File) => Promise<SettingsExportData>

PM_ATTRIBUTE_LABEL_MAP

Constant

{ readonly 'I1 a': "Current L1"; readonly 'I2 a': "Current L2"; readonly 'I3 a': "Current L3"; readonly 'V3 n v': "Voltage L3-N"; readonly 'V2 n v': "Voltage L2-N"; readonly 'V1 n v': "Voltage L1-N";…

removeContainerPrefix

Function

(text: string) => string

SITE_OVERVIEW_STATUSES

Constant

{ readonly OFFLINE: "offline"; readonly EMPTY: "empty"; readonly NOT_MINING: "not_mining"; readonly MINING: "mining"; }

SOCKET_STATUSES

Constant

{ readonly ERROR_MINING: "errorMining"; readonly MINER_DISCONNECTED: "disconnected"; readonly CONNECTING: "connecting"; readonly SLEEP: "sleep"; readonly LOW: "low"; readonly NORMAL: "normal"; readon…

THRESHOLD_LEVEL

Constant

{ readonly ALERT: "alert"; readonly ALARM: "alarm"; readonly NORMAL: "normal"; readonly ALARM_LOW: "alarmLow"; readonly ALARM_HIGH: "alarmHigh"; readonly CRITICAL_LOW: "criticalLow"; readonly CRITICA…

THRESHOLD_TYPE

Constant

{ readonly TANK_PRESSURE: "tankPressure"; readonly OIL_TEMPERATURE: "oilTemperature"; readonly WATER_TEMPERATURE: "waterTemperature"; readonly SUPPLY_LIQUID_PRESSURE: "supplyLiquidPressure"; }

USER_ROLE

Constant

{ readonly ADMIN: "admin"; readonly READ_ONLY: "read_only_user"; readonly SITE_MANAGER: "site_manager"; readonly SITE_OPERATOR: "site_operator"; readonly FIELD_OPERATOR: "field_operator"; readonly RE…

validateSettingsJson

Function

(data: unknown) => data is SettingsExportData

WEBAPP_DISPLAY_NAME

Constant

"Application"

WEBAPP_NAME

Neutral application display names used anywhere the toolkit needs to refer to the running product (header labels, chart legends, settings copy). Single source of truth — rebrands change these three values only.

Constant

"Appl."

WEBAPP_SHORT_NAME

Constant

"APP"

On this page