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.

analytics.widget.add

Add a widget to a dashboard.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.analytics-dashboard
  • Tags: analytics, widget, add
  • File: packages/examples/analytics-dashboard/src/dashboard/dashboard.operation.ts
  • field.key.label
    analytics.widget.add
    field.version.label
    1.0.0
    field.type.label
    operation (command)
    field.title.label
    analytics.widget.add
    field.description.label

    Add a widget to a dashboard.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.analytics-dashboard
  • Tags: analytics, widget, add
  • File: packages/examples/analytics-dashboard/src/dashboard/dashboard.operation.ts
  • field.tags.label
    analytics,widget,add
    field.owners.label
    @example.analytics-dashboard
    field.stability.label
    stable

    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' },
    			},
    		],
    	},
    });