
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@jcoreio/clarity-plugin-api
Advanced tools
@jcoreio/clarity-plugin-apiThis package provides a mock environment for developing plugins for Clarity. Many of the exports from this package are nonfunctional stubs; Clarity injects a runtime implementation of this package with the same API as provided here.
@jcoreio/clarity-plugin-apiDashboardWidgetPropsimport { DashboardWidgetProps } from '@jcoreio/clarity-plugin-api/client'
The props Clarity passes to a dashboard widget component provided by a plugin.
ClientPluginContributionsimport { ClientPluginContributions } from '@jcoreio/clarity-plugin-api/client'
Components and behaviors contributed to the client side of Clarity by a plugin. You should make sure the default export from your client entrypoint satisfies this type.
See ClientPluginContributions.ts
useTagState(tag: string): { loading: boolean, error?: Error, data?: TagState }import { useTagState } from '@jcoreio/clarity-plugin-api/client'
React hook that subscribes to the realtime value, metadata, and alarm state of a tag.
import * as React from 'react'
import {
useTagState,
DashboardWidgetProps,
} from '@jcoreio/clarity-plugin-api/client'
export function MyWidget({
config,
}: DashboardWidgetProps<{ tag: string } | undefined>) {
const { loading, error, data } = useTagState(config?.tag)
if (loading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
const t = data?.t
const v = data?.v
const metadata = data?.metadata
const notification = data?.notification
const name = metadata?.fullName?.join('/') || tag
return <div>
Most recent data for {name}:
<p>Time: {t != null ? new Date(t).toLocaleString()}</p>
<p>Value: {v}</p>
<p>Notification: {notification?.severity}</p>
</div>
}
TagStateimport { TagState } from '@jcoreio/clarity-plugin-api/client'
See TagState.ts
useDrop(spec, deps?)import { useDrop } from '@jcoreio/clarity-plugin-api/client'
React hook for connecting a drop target to Clarity
See types in dnd.ts
spec: FactoryOrInstance<ClarityDropTargetHookSpec>The drop target specification (object or function, function preferred)
deps?: unknown[]The memoization deps array to use when evaluating spec changes
[ClarityCollectedProps, ConnectDropTarget]See types in dnd.ts
import * as React from 'react'
import {
useTagState,
DashboardWidgetProps,
} from '@jcoreio/clarity-plugin-api/client'
export function MyWidget({
config,
setConfig,
}: DashboardWidgetProps<{ tag?: string } | undefined>) {
const [{ isOver, canDrop, tag, MetadataItem }, connectDropTarget] = useDrop(
{
canDrop: ({ tag, MetadataItem }) => tag != null,
drop: ({ tag, MetadataItem }): undefined => {
if (tag != null) setConfig({ tag })
},
},
[setConfig]
)
return (
<div ref={connectDropTarget}>
{tag != null ?
<p>Drop to set tag to {tag}</p>
: <p>Tag: {config?.tag}</p>}
</div>
)
}
useCurrentPluginRoute(): PluginRouteInfoimport { useCurrentPluginRoute } from '@jcoreio/clarity-plugin-api/client'
Returns information about the plugin route associated with the current location.pathname.
Throws if location.pathname is not a plugin route or subroute
See useCurrentPluginRoute.ts for properties of
the PluginRouteInfo return type.
useOrganizationId(options): number | undefinedimport { useOrganizationId } from '@jcoreio/clarity-plugin-api/client'
Returns the id of the current organization the user is viewing from the URL path.
Returns undefined if the user isn't in an organization route and options?.optional
is truthy
Throws if the user isn't in an organization route and options?.optional is falsy
useSeverityPulseStyles(options)import { useSeverityPulseStyles } from '@jcoreio/clarity-plugin-api/client'
Creates CSS classes to apply a color pulse animation for a warning, alarm, or critical condition to the given CSS property.
options.propertyThe camel-cased CSS property to animate (e.g. backgroundColor)
options.variantWhich set of colors to use:
An object with info, warning, alarm, and critical properties, which are
CSS class names. The info class doesn't apply an animation, but is provided for convenience
since info is one of the severity enum constants.
You can use these in a component provided by your plugin in the sidebarSections property of your
`ClientPluginContributions.
SidebarItemimport { SidebarItem } from '@jcoreio/clarity-plugin-api/client'
The React component for a single item in the sidebar.
See SidebarItem.tsx for properties.
SidebarItemTextimport { SidebarItemText } from '@jcoreio/clarity-plugin-api/client'
The React component for text inside a <SidebarItem>
See SidebarItemText.tsx for properties.
SidebarItemIconimport { SidebarItemIcon } from '@jcoreio/clarity-plugin-api/client'
The React component for an icon inside a <SidebarItem>
See SidebarItemIcon.tsx for properties.
SidebarItemSecondaryActionimport { SidebarItemSecondaryAction } from '@jcoreio/clarity-plugin-api/client'
The React component for a secondary action (icon button, loading spinner, etc) inside a
<SidebarItem> on the right hand side.
See SidebarItemSecondaryAction.tsx for properties.
SidebarSectionimport { SidebarSection } from '@jcoreio/clarity-plugin-api/client'
The React component for a sidebar section, which comprises a header item
(rendered via <SidebarSectionHeader>) and a collapsible list of
children, which may be <SidebarItem>s or other elements.
See SidebarSection.tsx for properties.
SidebarSectionHeaderimport { SidebarSectionHeader } from '@jcoreio/clarity-plugin-api/client'
The React component for the header of a <SidebarSection>, renders a
<SidebarItem>.
See SidebarSectionHeader.tsx for properties.
WebappPluginContributionsimport { WebappPluginContributions } from '@jcoreio/clarity-plugin-api/server'
Components and behaviors contributed to the server side webapp task of Clarity by a plugin, like API methods.
See WebappPluginContributions.ts for properties.
MigratePluginContributionsimport { MigratePluginContributions } from '@jcoreio/clarity-plugin-api/server'
Behaviors contributed to the server side migrate task of Clarity by a plugin, like database migrations.
See MigratePluginContributions.ts for properties.
getAPIContext(request: Request): APIContextimport { getAPIContext } from '@jcoreio/clarity-plugin-api/server'
APIContextimport type { APIContext } from '@jcoreio/clarity-plugin-api/server'
The context of a Clarity API request
Use getAPIContext to get the APIContext from an express Request
See APIContext.ts for more info.
appContext: AppContextThe Clarity AppContext
actorId: number | null | undefinedThe id of the Clarity user who is performing the request, if any
actorIp: string | null | undefinedThe IP address of the user who is performing the request, if available
AppContextimport type { AppContext } from '@jcoreio/clarity-plugin-api/server'
The Clarity application context types exposed to plugins.
In an API method handler, you can get the AppContext via getAPIContext(request).appContext
See AppContext.ts for more info.
postgresPoolThe postgres pool of connections to the app database.
This may not be a true {@link Pool pg.Pool} instance, instead it may
be an adapter that provides the Pool.connect, Pool.query,
and PoolClient.release() with the same signatures in pg.
Provides URL route parsers and formatters for plugins. The specific URL formats are determined by Clarity, so you should use these helpers instead of hardcoding any base paths in your plugin.
PluginRouteStub<Params extends {}>The interface for parsing/formatting URL routes
parse(pathname: string): ParamsParses the given URL pathname and returns the parsed Params for this route.
Throws if pathname doesn't match this route
format(params: Params): stringCreates a URL pathname for the given params.
partialFormat(params: Partial<Params>): stringCreates a URL pathname pattern for the given params. If a value for a parameter like
plugin is omitted, that part of the pattern will be left as :plugin instead of being
replaced by the parameter value.
apiBasePath: PluginRouteStub<{ plugin: string }>import { apiBasePath } from '@jcoreio/clarity-plugin-api/client'
// or
import { apiBasePath } from '@jcoreio/clarity-plugin-api/server'
The base path for plugins' API routes
uiBasePath: PluginRouteStub<{ plugin: string }>import { uiBasePath } from '@jcoreio/clarity-plugin-api/client'
// or
import { uiBasePath } from '@jcoreio/clarity-plugin-api/server'
The base path for plugins' UI routes that aren't under the base path for an organization
organizationUIBasePath: PluginRouteStub<{ plugin: string }>import { organizationUIBasePath } from '@jcoreio/clarity-plugin-api/client'
// or
import { organizationUIBasePath } from '@jcoreio/clarity-plugin-api/server'
The base path for plugins' UI routes under the base path for an organization
FAQs
Clarity Plugin API mocks for developing plugins
We found that @jcoreio/clarity-plugin-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.