MDK Logo

Constants

Shared constants exported by @mdk/core and @mdk/foundation

This page documents constants exported by the MDK packages. Constants live in two distinct domains:

  • @mdk/core ships UI primitives: colors, units, currency symbols, chart defaults
  • @mdk/foundation ships mining-domain values: permissions, roles, header preferences, error codes

@mdk/core constants

Prerequisites

Import

@mdk/core
import {
  COLOR,
  UNITS,
  CURRENCY,
  CHART_COLORS,
  TABLE_COLORS,
  HASHRATE_LABEL_DIVISOR,
} from '@mdk/core'

Color constants

COLOR

@mdk/core

Comprehensive color palette with 80+ named colors.

import { COLOR } from '@mdk/core'

COLOR.GREEN        // '#72F59E'
COLOR.RED          // '#EF4444'
COLOR.COLD_ORANGE  // '#F7931A'
Base colors
ConstantValueDescription
WHITE#FFFFFFPure white
BLACK#17130FStandard black
DARK_BACK#1A1815Dark background
EBONY#0f0f0fChart background
TRANSPARENTtransparentTransparent
Status colors
ConstantValueDescription
GREEN#72F59ESuccess/online
RED#EF4444Error/danger
YELLOW#FFC107Warning
BRIGHT_YELLOW#EAB308Bright warning
LIGHT_BLUE#22AFFFInfo
SLEEP_BLUE#3B82F6Sleep/standby
Brand colors
ConstantValueDescription
COLD_ORANGE#F7931ABitcoin orange
ORANGE#FF6A00Primary orange
EMERALD#009393Teal accent
INDIGO#5B5FFBPurple accent

TABLE_COLORS

@mdk/core

Colors for table styling.

import { TABLE_COLORS } from '@mdk/core'

TABLE_COLORS.HEADER_BG
TABLE_COLORS.ROW_HOVER

HEATMAP

@mdk/core

HEATMAP color scale for temperature and intensity displays.

import { HEATMAP } from '@mdk/core'

CHART_COLORS

@mdk/core

Default chart color palette.

import { CHART_COLORS } from '@mdk/core'

PIE_CHART_COLORS

@mdk/core

Color palette for pie and doughnut charts.

import { PIE_CHART_COLORS } from '@mdk/core'

CATEGORICAL_COLORS

@mdk/core

25-color categorical palette for multi-series charts.

import { CATEGORICAL_COLORS } from '@mdk/core'

CATEGORICAL_COLORS[0]  // First color
CATEGORICAL_COLORS[24] // Last color

TEMPERATURE_COLORS

@mdk/core

Color scale for temperature displays.

import { TEMPERATURE_COLORS } from '@mdk/core'

SOCKET_BORDER_COLOR

@mdk/core

Colors for socket status indicators.

import { SOCKET_BORDER_COLOR } from '@mdk/core'

Unit constants

UNITS

@mdk/core

Physical and measurement units.

import { UNITS } from '@mdk/core'

UNITS.POWER_W         // 'W'
UNITS.POWER_KW        // 'kW'
UNITS.ENERGY_MWH      // 'MWh'
UNITS.TEMPERATURE_C   // '°C'
UNITS.HASHRATE_TH_S   // 'TH/s'
ConstantValueDescription
POWER_WWWatts
POWER_KWkWKilowatts
ENERGY_WHWhWatt-hours
ENERGY_KWHkWhKilowatt-hours
ENERGY_MWMWMegawatts
ENERGY_MWHMWhMegawatt-hours
ENERGY_GWHGWhGigawatt-hours
TEMPERATURE_C°CCelsius
VOLTAGE_VVVolts
AMPEREAAmperes
PERCENT%Percentage
PRESSURE_BARbarPressure (bar)
HASHRATE_MH_SMH/sMegahash/second
HASHRATE_TH_STH/sTerahash/second
HASHRATE_PH_SPH/sPetahash/second
HASHRATE_EH_SEH/sExahash/second
FREQUENCY_MHZMHzMegahertz
FREQUENCY_HERTZHzHertz
HUMIDITY_PERCENT%RHRelative humidity
EFFICIENCY_W_PER_THW/THWatts per terahash
FLOW_M3Hm3/hFlow rate
SATSSatsSatoshis
VBYTEvByteVirtual bytes

CURRENCY

@mdk/core

Currency symbols and labels.

import { CURRENCY } from '@mdk/core'

CURRENCY.BTC       // '₿'
CURRENCY.USD       // '$'
CURRENCY.EUR       // '€'
CURRENCY.SATS      // 'Sats'
CURRENCY.BTC_LABEL // 'BTC'
CURRENCY.USD_LABEL // 'USD'

MAX_UNIT_VALUE

@mdk/core

Maximum values for certain units.

import { MAX_UNIT_VALUE } from '@mdk/core'

MAX_UNIT_VALUE.HUMIDITY_PERCENT     // 100
MAX_UNIT_VALUE.TEMPERATURE_PERCENT  // 100

HASHRATE_LABEL_DIVISOR

@mdk/core

Divisors for converting hashrate units.

import { HASHRATE_LABEL_DIVISOR } from '@mdk/core'

HASHRATE_LABEL_DIVISOR['TH/s']  // 1e6
HASHRATE_LABEL_DIVISOR['PH/s']  // 1e9
HASHRATE_LABEL_DIVISOR['EH/s']  // 1e12

Chart constants

defaultChartColors

@mdk/core

Default color array for chart datasets.

import { defaultChartColors } from '@mdk/core'

defaultChartOptions

@mdk/core

Default Chart.js options.

import { defaultChartOptions } from '@mdk/core'

CHART_LEGEND_OPACITY

@mdk/core

Opacity values for chart legends.

import { CHART_LEGEND_OPACITY } from '@mdk/core'

CHART_PERFORMANCE

@mdk/core

Performance threshold constants for charts.

import { CHART_PERFORMANCE } from '@mdk/core'

getChartAnimationConfig

@mdk/core

Get animation configuration based on data count.

import { getChartAnimationConfig } from '@mdk/core'

const animConfig = getChartAnimationConfig(dataPointCount)

getDataDecimationConfig

@mdk/core

Get data decimation configuration for large datasets.

import { getDataDecimationConfig } from '@mdk/core'

const decimationConfig = getDataDecimationConfig(dataPointCount)

Type exports

The constants module also exports TypeScript types:

import type {
  UnitKey,
  UnitValue,
  CurrencyKey,
  CurrencyValue,
} from '@mdk/core'

@mdk/foundation constants

Prerequisites

Import

@mdk/foundation
import {
  POSITION_CHANGE_DIALOG_FLOWS,
  HEADER_ITEMS,
  DEFAULT_HEADER_PREFERENCES,
  AUTH_PERMISSIONS,
  AUTH_LEVELS,
  USER_ROLE,
  USER_ROLES,
  PERM_LEVEL_LABELS,
  getRoleBadgeColors,
} from '@mdk/foundation'

Dialog flows

POSITION_CHANGE_DIALOG_FLOWS

@mdk/foundation

Flow keys consumed by PositionChangeDialog and its sibling dialogs to route between step-specific surfaces.

import { POSITION_CHANGE_DIALOG_FLOWS } from '@mdk/foundation'

POSITION_CHANGE_DIALOG_FLOWS.MAINTENANCE       // 'maintenance'
POSITION_CHANGE_DIALOG_FLOWS.REPLACE_MINER     // 'replaceMiner'
ConstantValueDescription
CONFIRM_REMOVEremoveRender the remove-miner confirmation surface
CHANGE_INFOchangeInfoEdit info for an existing miner
MAINTENANCEmaintenanceMove a miner to (or back from) the maintenance container
REPLACE_MINERreplaceMinerReplace the miner currently occupying a socket
CONFIRM_CHANGE_POSITIONconfirmChangeConfirm a position change between sockets
CONTAINER_SELECTIONcontainerSelectionPick a destination container and socket

PositionChangeDialogFlowKey type

@mdk/foundation
import type { PositionChangeDialogFlowKey } from '@mdk/foundation'

type PositionChangeDialogFlowKey = keyof typeof POSITION_CHANGE_DIALOG_FLOWS

PositionChangeDialogFlowValue type

@mdk/foundation
import type { PositionChangeDialogFlowValue } from '@mdk/foundation'

type PositionChangeDialogFlowValue =
  (typeof POSITION_CHANGE_DIALOG_FLOWS)[PositionChangeDialogFlowKey]

Header controls

HEADER_ITEMS

@mdk/foundation

Array of header metric options for the HeaderControlsSettings component.

import { HEADER_ITEMS } from '@mdk/foundation'
KeyLabel
poolMinersPool Miners
mosMinersMOS Miners
poolHashratePool Hashrate
mosHashrateMOS Hashrate
consumptionConsumption
efficiencyEfficiency

DEFAULT_HEADER_PREFERENCES

@mdk/foundation

Default visibility state for all header items (all true).

import { DEFAULT_HEADER_PREFERENCES } from '@mdk/foundation'

DEFAULT_HEADER_PREFERENCES.poolMiners    // true
DEFAULT_HEADER_PREFERENCES.consumption   // true

HeaderPreferences type

@mdk/foundation
import type { HeaderPreferences } from '@mdk/foundation'

type HeaderPreferences = {
  poolMiners: boolean
  mosMiners: boolean
  poolHashrate: boolean
  mosHashrate: boolean
  consumption: boolean
  efficiency: boolean
}

Permissions

AUTH_PERMISSIONS

@mdk/foundation

Permission resource identifiers.

import { AUTH_PERMISSIONS } from '@mdk/foundation'

AUTH_PERMISSIONS.USERS      // 'users'
AUTH_PERMISSIONS.SETTINGS   // 'settings'
AUTH_PERMISSIONS.MINER      // 'miner'
ConstantValueDescription
USERSusersUser management
SETTINGSsettingsApplication settings
MINERminerMiner operations
ALERTSalertsAlert management
ACTIONSactionsAction execution
EXPLORERexplorerDevice explorer
INVENTORYinventoryInventory management
CONTAINERcontainerContainer management
PRODUCTIONproductionProduction data
REPORTINGreportingReports

AUTH_LEVELS

@mdk/foundation

Permission access levels.

import { AUTH_LEVELS } from '@mdk/foundation'

AUTH_LEVELS.READ   // 'r'
AUTH_LEVELS.WRITE  // 'w'

USER_ROLE

@mdk/foundation

User role identifiers.

import { USER_ROLE } from '@mdk/foundation'

USER_ROLE.ADMIN           // 'admin'
USER_ROLE.SITE_MANAGER    // 'site_manager'
USER_ROLE.READ_ONLY       // 'read_only_user'
ConstantValue
ADMINadmin
SITE_MANAGERsite_manager
SITE_OPERATORsite_operator
FIELD_OPERATORfield_operator
REPAIR_TECHNICIANrepair_technician
REPORTING_TOOL_MANAGERreporting_tool_manager
READ_ONLYread_only_user

Settings

USER_ROLES

@mdk/foundation

Array of role options for select dropdowns.

import { USER_ROLES } from '@mdk/foundation'

// [{ label: 'Admin', value: 'admin' }, ...]

PERM_LEVEL_LABELS

@mdk/foundation

Human-readable labels for permission levels.

import { PERM_LEVEL_LABELS } from '@mdk/foundation'

PERM_LEVEL_LABELS.rw    // 'Read & Write'
PERM_LEVEL_LABELS.r     // 'Read Only'
PERM_LEVEL_LABELS.none  // 'No Access'

SETTINGS_ERROR_CODES

@mdk/foundation

Error code to message mapping.

import { SETTINGS_ERROR_CODES } from '@mdk/foundation'

SETTINGS_ERROR_CODES.ERR_USER_EXISTS  // 'User already exists'
SETTINGS_ERROR_CODES.DEFAULT          // 'An error occurred'

Role styling

getRoleBadgeColors

@mdk/foundation

Get badge colors for a role.

import { getRoleBadgeColors } from '@mdk/foundation'

const { color, bgColor } = getRoleBadgeColors('admin')
// { color: '#e8833a', bgColor: 'rgba(232, 131, 58, 0.1)' }
RoleColorBackground
admin#e8833aOrange tint
site_manager#52c41aGreen tint
site_operator#faad14Yellow tint
read_only_user#8c8c8cGray tint

On this page