OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Add a widget to a dashboard.
Goal
Allow users to add visualizations.
Context
Dashboard editor.
Source Definition
import {
defineCommand,
defineQuery,
} from '@lssm-tech/lib.contracts-spec/operations';
import {
AddWidgetInputModel,
CreateDashboardInputModel,
DashboardModel,
GetDashboardInputModel,
ListDashboardsInputModel,
ListDashboardsOutputModel,
WidgetModel,
} from './dashboard.schema';
export const AddWidgetContract = defineCommand({
meta: {
key: 'analytics.widget.add',
version: '1.0.0',
stability: 'stable',
owners: ['@example.analytics-dashboard'],
tags: ['analytics', 'widget', 'add'],
description: 'Add a widget to a dashboard.',
goal: 'Allow users to add visualizations.',
context: 'Dashboard editor.',
},
io: { input: AddWidgetInputModel, output: WidgetModel },
policy: { auth: 'user' },
sideEffects: {
emits: [
{
key: 'analytics.widget.added',
version: '1.0.0',
stability: 'stable',
owners: ['@example.analytics-dashboard'],
tags: ['analytics', 'widget', 'added'],
when: 'Widget added',
payload: WidgetModel,
},
],
},
acceptance: {
scenarios: [
{
key: 'add-widget-happy-path',
given: ['Dashboard exists'],
when: ['User adds widget to dashboard'],
then: ['Widget is created', 'WidgetAdded event is emitted'],
},
],
examples: [
{
key: 'add-chart-widget',
input: {
dashboardId: 'dash-123',
type: 'chart',
queryId: 'query-456',
config: { chartType: 'bar' },
},
output: { id: 'widget-789', type: 'chart', dashboardId: 'dash-123' },
},
],
},
});