brick.ts

@brickkit/cli/dashboard

defineDashboard, the UI kit and the data hooks for a dashboard extension.

llms.txt

@brickkit/cli/dashboard exports 63 names: 45 functions, 13 interfaces, 2 types, 3 variables.

import { appFetch, Badge, badgeVariants } from "@brickkit/cli/dashboard";

Functions

FunctionDescription
appFetchCall the app through the dashboard's /app proxy, from the dashboard's own origin.
Badge
Button
Card
CardAction
CardContent
CardDescription
CardFooter
CardHeader
CardTitle
Checkbox
cn
createAppClientThe app's typed client, calling it through the dashboard's /app proxy: createAppClient<AppContract>(\{ contract \}), with both from the contract brick dev …
defineDashboardDeclare the dashboard extension; the module's default export.
Empty
Input
Kbd
KbdGroup
Metric
PageHeader
PanelEfferd's card: a square, 1px-bordered surface with a plus mark on each corner, built on the shadcn Card with its radius and ring removed.
Popover
PopoverContent
PopoverTrigger
Separator
SparkBarsMiniature stacked-block bar chart, with the newest column emphasized.
Table
TableBody
TableCaption
TableCell
TableFooter
TableHead
TableHeader
TableRow
Toggle
ToggleGroup
ToggleGroupItem
Tooltip
TooltipContent
TooltipProvider
TooltipTrigger
useAppFetchRead path from the app (JSON, or text for anything else) when the component mounts and whenever path changes.
useAppQueryRun query when the component mounts and whenever deps change, as useEffect would: useAppQuery((signal) => api.orders.order.list(\{\}, \{ signal \}), []).
useArchitectureThe app's services, actions and routes as last started; null before it starts.
useRequestsThe requests the dashboard holds live, newest first.

appFetch

function appFetch(path: string, init?: RequestInit): Promise<Response>

Call the app through the dashboard's /app proxy, from the dashboard's own origin. path is the app's: appFetch("/api/admin/queues").

Parameters

NameTypeDescription
pathstring
init?RequestInit

Returns Promise<Response>

Source: packages/cli/dashboard/extension.tsx:166

Badge

function Badge(
  { className, variant = "default", render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>,
): ReactElement<unknown, string | JSXElementConstructor<any>>

Parameters

NameTypeDescription
{ className, variant = "default", render, ...props }useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>

Returns ReactElement<unknown, string \| JSXElementConstructor<any>>

Source: packages/cli/dashboard/components/ui/badge.tsx:29

Button

function Button(
  { className, variant = "default", size = "default", ...props }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>,
): JSX.Element

Parameters

NameTypeDescription
{ className, variant = "default", size = "default", ...props }ButtonPrimitive.Props & VariantProps<typeof buttonVariants>

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/button.tsx:42

Card

function Card(
  { className, size = "default", ...props }: React.ComponentProps<"div"> & { size?: "default" | "sm" },
): React.JSX.Element

Parameters

NameTypeDescription
{ className, size = "default", ...props }React.ComponentProps<"div"> & { size?: "default" | "sm" }

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:4

CardAction

function CardAction(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:58

CardContent

function CardContent(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:71

CardDescription

function CardDescription(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:48

CardFooter

function CardFooter(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:81

CardHeader

function CardHeader(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:22

CardTitle

function CardTitle(
  { className, ...props }: React.ComponentProps<"div">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/card.tsx:35

Checkbox

function Checkbox(
  { className, ...props }: CheckboxPrimitive.Root.Props,
): JSX.Element

Parameters

NameTypeDescription
{ className, ...props }CheckboxPrimitive.Root.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/checkbox.tsx:5

cn

function cn(...inputs: ClassValue[]): string

Parameters

NameTypeDescription
inputs?ClassValue[]

Returns string

Source: packages/cli/dashboard/lib/utils.ts:4

createAppClient

function createAppClient<TApp extends Record<string, any>>(
  options: Omit<BrickClientOptions, "baseUrl"> & { contract?: TApp } = {},
): BrickClient<TApp>

The app's typed client, calling it through the dashboard's /app proxy: createAppClient<AppContract>({ contract }), with both from the contract brick dev generates. CRUD and other plugin routes need the contract value. Headers, the prefix and timeouts are as for createBrickClient.

Parameters

NameTypeDescription
options?Omit<BrickClientOptions, "baseUrl"> & { contract?: TApp } default {}

Returns BrickClient<TApp>

Source: packages/cli/dashboard/extension.tsx:184

defineDashboard

function defineDashboard<T extends DashboardExtension>(extension: T): T

Declare the dashboard extension; the module's default export.

Parameters

NameTypeDescription
extensionT

Returns T

Source: packages/cli/dashboard/extension-registry.ts:95

Empty

function Empty({ title, hint }: { title: string; hint?: string }): JSX.Element

Parameters

NameTypeDescription
{ title, hint }{ title: string; hint?: string }

Returns JSX.Element

Source: packages/cli/dashboard/components/page-header.tsx:25

Input

function Input(
  { className, type, ...props }: React.ComponentProps<"input">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, type, ...props }React.ComponentProps<"input">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/input.tsx:5

Kbd

function Kbd({ className, ...props }: React.ComponentProps<"kbd">): JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"kbd">

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/kbd.tsx:3

KbdGroup

function KbdGroup(
  { className, ...props }: React.ComponentProps<"div">,
): JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"div">

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/kbd.tsx:16

Metric

function Metric(
  { icon, label, value, note, spark }: { icon?: ReactNode; label: string; value: ReactNode; /** A line under the value. */ note?: string; /** Recent values for t…,
): JSX.Element

Parameters

NameTypeDescription
{ icon, label, value, note, spark, }{ icon?: ReactNode; label: string; value: ReactNode; /** A line under the value. */ note?: string; /** Recent values for the miniature chart; omit for none. */ spark?: number[]; }

Returns JSX.Element

Source: packages/cli/dashboard/components/metric.tsx:32

function PageHeader(
  { title, description, actions }: { title: string; description?: string; actions?: ReactNode; },
): JSX.Element

Parameters

NameTypeDescription
{ title, description, actions, }{ title: string; description?: string; actions?: ReactNode; }

Returns JSX.Element

Source: packages/cli/dashboard/components/page-header.tsx:3

Panel

function Panel(
  { className, children, title, ...props }: Omit<ComponentProps<"div">, "title"> & { title?: ReactNode },
): JSX.Element

Efferd's card: a square, 1px-bordered surface with a plus mark on each corner, built on the shadcn Card with its radius and ring removed. A title is a heading row across the top.

Parameters

NameTypeDescription
{ className, children, title, ...props }Omit<ComponentProps<"div">, "title"> & { title?: ReactNode }

Returns JSX.Element

Source: packages/cli/dashboard/components/panel.tsx:18

Popover

function Popover({ ...props }: PopoverPrimitive.Root.Props): JSX.Element

Parameters

NameTypeDescription
{ ...props }PopoverPrimitive.Root.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/popover.tsx:6

PopoverContent

function PopoverContent(
  { className, align = "start", alignOffset = 0, side = "bottom", sideOffset = 6, ...props }: PopoverPrimitive.Popup.Props & Pick<PopoverPrimitive.Positioner.Pro…,
): JSX.Element

Parameters

NameTypeDescription
{ className, align = "start", alignOffset = 0, side = "bottom", sideOffset = 6, ...props }PopoverPrimitive.Popup.Props & Pick<PopoverPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/popover.tsx:14

PopoverTrigger

function PopoverTrigger(
  { ...props }: PopoverPrimitive.Trigger.Props,
): JSX.Element

Parameters

NameTypeDescription
{ ...props }PopoverPrimitive.Trigger.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/popover.tsx:10

Separator

function Separator(
  { className, orientation = "horizontal", ...props }: SeparatorPrimitive.Props,
): JSX.Element

Parameters

NameTypeDescription
{ className, orientation = "horizontal", ...props }SeparatorPrimitive.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/separator.tsx:6

SparkBars

function SparkBars({ values }: { values: number[] }): JSX.Element

Miniature stacked-block bar chart, with the newest column emphasized.

Parameters

NameTypeDescription
{ values }{ values: number[] }

Returns JSX.Element

Source: packages/cli/dashboard/components/metric.tsx:6

Table

function Table(
  { className, ...props }: React.ComponentProps<"table">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"table">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:6

TableBody

function TableBody(
  { className, ...props }: React.ComponentProps<"tbody">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"tbody">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:31

TableCaption

function TableCaption(
  { className, ...props }: React.ComponentProps<"caption">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"caption">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:93

TableCell

function TableCell(
  { className, ...props }: React.ComponentProps<"td">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"td">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:80

TableFooter

function TableFooter(
  { className, ...props }: React.ComponentProps<"tfoot">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"tfoot">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:41

TableHead

function TableHead(
  { className, ...props }: React.ComponentProps<"th">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"th">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:67

TableHeader

function TableHeader(
  { className, ...props }: React.ComponentProps<"thead">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"thead">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:21

TableRow

function TableRow(
  { className, ...props }: React.ComponentProps<"tr">,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, ...props }React.ComponentProps<"tr">

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/table.tsx:54

Toggle

function Toggle(
  { className, variant = "default", size = "default", ...props }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>,
): JSX.Element

Parameters

NameTypeDescription
{ className, variant = "default", size = "default", ...props }TogglePrimitive.Props & VariantProps<typeof toggleVariants>

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/toggle.tsx:29

ToggleGroup

function ToggleGroup(
  { className, variant, size, spacing = 2, orientation = "horizontal", children, ...props }: ToggleGroupPrimitive.Props & VariantProps<typeof toggleVariants> & {…,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, variant, size, spacing = 2, orientation = "horizontal", children, ...props }ToggleGroupPrimitive.Props & VariantProps<typeof toggleVariants> & { spacing?: number; orientation?: "horizontal" | "vertical"; }

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/toggle-group.tsx:23

ToggleGroupItem

function ToggleGroupItem(
  { className, children, variant = "default", size = "default", ...props }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>,
): React.JSX.Element

Parameters

NameTypeDescription
{ className, children, variant = "default", size = "default", ...props }TogglePrimitive.Props & VariantProps<typeof toggleVariants>

Returns React.JSX.Element

Source: packages/cli/dashboard/components/ui/toggle-group.tsx:59

Tooltip

function Tooltip({ ...props }: TooltipPrimitive.Root.Props): JSX.Element

Parameters

NameTypeDescription
{ ...props }TooltipPrimitive.Root.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/tooltip.tsx:19

TooltipContent

function TooltipContent(
  { className, side = "top", sideOffset = 4, align = "center", alignOffset = 0, children, ...props }: TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positi…,
): JSX.Element

Parameters

NameTypeDescription
{ className, side = "top", sideOffset = 4, align = "center", alignOffset = 0, children, ...props }TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/tooltip.tsx:27

TooltipProvider

function TooltipProvider(
  { delay = 0, ...props }: TooltipPrimitive.Provider.Props,
): JSX.Element

Parameters

NameTypeDescription
{ delay = 0, ...props }TooltipPrimitive.Provider.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/tooltip.tsx:6

TooltipTrigger

function TooltipTrigger(
  { ...props }: TooltipPrimitive.Trigger.Props,
): JSX.Element

Parameters

NameTypeDescription
{ ...props }TooltipPrimitive.Trigger.Props

Returns JSX.Element

Source: packages/cli/dashboard/components/ui/tooltip.tsx:23

useAppFetch

function useAppFetch<T = unknown>(
  path: string | null,
  init?: RequestInit,
): AppFetchResult<T>

Read path from the app (JSON, or text for anything else) when the component mounts and whenever path changes. A null path waits.

Parameters

NameTypeDescription
pathstring | null
init?RequestInit

Returns AppFetchResult<T>

Source: packages/cli/dashboard/extension.tsx:242

useAppQuery

function useAppQuery<T>(
  query: ((signal: AbortSignal) => Promise<T>) | null,
  deps: readonly unknown[],
): AppFetchResult<T>

Run query when the component mounts and whenever deps change, as useEffect would: useAppQuery((signal) => api.orders.order.list({}, { signal }), []). A null query waits. The signal aborts when deps change or on unmount.

Parameters

NameTypeDescription
query((signal: AbortSignal) => Promise<T>) | null
depsreadonly unknown[]

Returns AppFetchResult<T>

Source: packages/cli/dashboard/extension.tsx:198

useArchitecture

function useArchitecture(): ArchitectureSchema | null

The app's services, actions and routes as last started; null before it starts.

Returns ArchitectureSchema \| null

Source: packages/cli/dashboard/extension.tsx:158

useRequests

function useRequests(): TraceSummary[]

The requests the dashboard holds live, newest first.

Returns TraceSummary[]

Source: packages/cli/dashboard/extension.tsx:153

Interfaces

AppFetchResult

interface AppFetchResult<T>

Properties

NameTypeDescription
dataT | undefined
errorError | undefined
loadingboolean
refetch() => voidFetch again.

Source: packages/cli/dashboard/extension.tsx:170

DashboardExtension

interface DashboardExtension

Properties

NameTypeDescription
root?ComponentType<{ children: ReactNode }>Wraps the whole dashboard: providers, analytics, feature flags.
slots?DashboardSlots
pages?ExtensionPage[]
sidebar?SidebarLink[]

Source: packages/cli/dashboard/extension-registry.ts:86

DashboardSlots

interface DashboardSlots

The fixed places an extension can fill.

Properties

NameTypeDescription
"topbar.start"?ComponentType<SlotContext>
"topbar.end"?ComponentType<SlotContext>
"sidebar.header"?ComponentType<SidebarSlotContext>
"sidebar.footer"?ComponentType<SidebarSlotContext>
"overview.top"?ComponentType<SlotContext>
"request.drawer.tabs"?DrawerTab[]

Source: packages/cli/dashboard/extension-registry.ts:41

DrawerTab

interface DrawerTab

A tab of the request drawer, beside its own Details.

Properties

NameTypeDescription
idstring
labelstring
componentComponentType<DrawerTabContext>

Source: packages/cli/dashboard/extension-registry.ts:34

DrawerTabContext

interface DrawerTabContext extends SlotContext

Properties

NameTypeDescription
requestTraceSummary | undefinedThe request the drawer shows; undefined while its spans load.

Source: packages/cli/dashboard/extension-registry.ts:28

PageProps

interface PageProps extends SlotContext

Properties

NameTypeDescription
pathstring[]The address after the page's own: #/x/queues/a/b gives ["a", "b"].

Source: packages/cli/dashboard/extension-registry.ts:52

Placement

interface Placement

Where a page or link sits in the sidebar.

Properties

NameTypeDescription
after?stringAfter this page: a built-in one ("overview") or another extension page's id.
section?stringUnder this heading, below the built-in pages. after wins when both are set.
production?booleanShow it in the production dashboard of brick start too.

Source: packages/cli/dashboard/extension-registry.ts:58

Route

interface Route

Properties

NameTypeDescription
viewView
traceId?string
pathstring[]Segments after the view, for views with pages of their own (APIs, Docs). For x, after the page's id.
anchor?stringThe #heading after a docs page's path.
page?stringThe extension page's id, for x.

Source: packages/cli/dashboard/state.ts:209

interface SidebarLink extends Placement

A sidebar link. One to another site opens in a new tab.

Properties

NameTypeDescription
labelstring
icon?ReactNode
hrefstring

Source: packages/cli/dashboard/extension-registry.ts:80

SidebarSlotContext

interface SidebarSlotContext extends SlotContext

Properties

NameTypeDescription
expandedbooleanWhether the sidebar shows labels, or only its icon rail.

Source: packages/cli/dashboard/extension-registry.ts:23

SlotContext

interface SlotContext

What every slot, page and drawer tab receives.

Properties

NameTypeDescription
routeRouteWhere the dashboard is: #/x/queues/42 is { view: "x", page: "queues", path: ["42"] }.
theme"light" | "dark"The theme in effect, after following the system setting.
productionbooleanThe read-only dashboard of brick start, not brick dev.
selectedRequestId?stringThe request open in the Requests view, when one is.

Source: packages/cli/dashboard/extension-registry.ts:12

TraceSpan

interface TraceSpan

Properties

NameTypeDescription
spanIdstring
parentSpanId?string
namestring
startMsnumber
endMs?number
statusSpanOutcome
statusMessage?string
attributesAttributes
eventsSpanEventRecord[]

Source: packages/cli/src/dev-telemetry-store.ts:15

TraceSummary

interface TraceSummary

Properties

NameTypeDescription
traceIdstring
namestring
method?string
route?string
path?stringThe request's actual path, which differs from a wildcard route template.
httpStatus?number
generationnumber
startMsnumber
endMs?number
durationMs?number
statusSpanOutcome
truncatedboolean
service?stringThe service and action that handled the request, when it ran one.
action?string
message?stringWhy it failed, when it did.
legacyRoute?booleanThe request used a v0.10 path that brick({ legacyRoutes: true }) still serves.
spansTraceSpan[]

Source: packages/cli/src/dev-telemetry-store.ts:27

Types

ExtensionPage

type ExtensionPage =
  | (PageBase & { component: ComponentType<PageProps>; url?: undefined })
  /** A page shown in a frame. It cannot fill slots or follow the theme. */
  | (PageBase & { url: string; component?: undefined });

Source: packages/cli/dashboard/extension-registry.ts:74

SlotName

type SlotName = keyof DashboardSlots;

Source: packages/cli/dashboard/extension-registry.ts:50

Variables

badgeVariants

const badgeVariants: (props?: ({ variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined; } & ClassProp) | undefined) => string

Source: packages/cli/dashboard/components/ui/badge.tsx:6

buttonVariants

const buttonVariants: (props?: ({ variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined; size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined; } &…

Source: packages/cli/dashboard/components/ui/button.tsx:5

toggleVariants

const toggleVariants: (props?: ({ variant?: "default" | "outline" | null | undefined; size?: "default" | "sm" | "lg" | null | undefined; } & ClassProp) | undefined) => string

Source: packages/cli/dashboard/components/ui/toggle.tsx:7