@seed-ship/mcp-ui-solid 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/GenerativeUIErrorBoundary.cjs +104 -0
- package/dist/components/GenerativeUIErrorBoundary.cjs.map +1 -0
- package/dist/components/GenerativeUIErrorBoundary.d.ts +59 -0
- package/dist/components/GenerativeUIErrorBoundary.d.ts.map +1 -0
- package/dist/components/GenerativeUIErrorBoundary.js +104 -0
- package/dist/components/GenerativeUIErrorBoundary.js.map +1 -0
- package/dist/components/StreamingUIRenderer.cjs +271 -0
- package/dist/components/StreamingUIRenderer.cjs.map +1 -0
- package/dist/components/StreamingUIRenderer.d.ts +32 -0
- package/dist/components/StreamingUIRenderer.d.ts.map +1 -0
- package/dist/components/StreamingUIRenderer.js +271 -0
- package/dist/components/StreamingUIRenderer.js.map +1 -0
- package/dist/components/UIResourceRenderer.cjs +347 -0
- package/dist/components/UIResourceRenderer.cjs.map +1 -0
- package/dist/components/UIResourceRenderer.d.ts +43 -0
- package/dist/components/UIResourceRenderer.d.ts.map +1 -0
- package/dist/components/UIResourceRenderer.js +347 -0
- package/dist/components/UIResourceRenderer.js.map +1 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components.cjs +8 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +6 -4
- package/dist/components.js.map +1 -1
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useStreamingUI.cjs +230 -0
- package/dist/hooks/useStreamingUI.cjs.map +1 -0
- package/dist/hooks/useStreamingUI.d.ts +79 -0
- package/dist/hooks/useStreamingUI.d.ts.map +1 -0
- package/dist/hooks/useStreamingUI.js +230 -0
- package/dist/hooks/useStreamingUI.js.map +1 -0
- package/dist/hooks.cjs +4 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +2 -2
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -293
- package/dist/index.js.map +1 -1
- package/dist/services/component-registry.cjs +295 -0
- package/dist/services/component-registry.cjs.map +1 -0
- package/dist/services/component-registry.d.ts +50 -0
- package/dist/services/component-registry.d.ts.map +1 -0
- package/dist/services/component-registry.js +295 -0
- package/dist/services/component-registry.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/validation.cjs +253 -0
- package/dist/services/validation.cjs.map +1 -0
- package/dist/services/validation.d.ts +48 -0
- package/dist/services/validation.d.ts.map +1 -0
- package/dist/services/validation.js +253 -0
- package/dist/services/validation.js.map +1 -0
- package/dist/types/index.d.ts +250 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/logger.cjs +31 -0
- package/dist/utils/logger.cjs.map +1 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +31 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +2 -2
- package/dist/StreamingUIRenderer-DQ1WoVV6.cjs +0 -5
- package/dist/StreamingUIRenderer-DQ1WoVV6.cjs.map +0 -1
- package/dist/StreamingUIRenderer-oyg_cKKl.js +0 -757
- package/dist/StreamingUIRenderer-oyg_cKKl.js.map +0 -1
- package/dist/useStreamingUI-BL0nh13E.js +0 -187
- package/dist/useStreamingUI-BL0nh13E.js.map +0 -1
- package/dist/useStreamingUI-CXmvpRhz.cjs +0 -3
- package/dist/useStreamingUI-CXmvpRhz.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const UIResourceRenderer = require("./components/UIResourceRenderer.cjs");
|
|
4
|
+
const StreamingUIRenderer = require("./components/StreamingUIRenderer.cjs");
|
|
5
|
+
const GenerativeUIErrorBoundary = require("./components/GenerativeUIErrorBoundary.cjs");
|
|
6
|
+
const useStreamingUI = require("./hooks/useStreamingUI.cjs");
|
|
7
|
+
const validation = require("./services/validation.cjs");
|
|
8
|
+
const componentRegistry = require("./services/component-registry.cjs");
|
|
9
|
+
exports.UIResourceRenderer = UIResourceRenderer.UIResourceRenderer;
|
|
10
|
+
exports.StreamingUIRenderer = StreamingUIRenderer.StreamingUIRenderer;
|
|
11
|
+
exports.GenerativeUIErrorBoundary = GenerativeUIErrorBoundary.GenerativeUIErrorBoundary;
|
|
12
|
+
exports.useStreamingUI = useStreamingUI.useStreamingUI;
|
|
13
|
+
exports.DEFAULT_RESOURCE_LIMITS = validation.DEFAULT_RESOURCE_LIMITS;
|
|
14
|
+
exports.validateComponent = validation.validateComponent;
|
|
15
|
+
exports.validateLayout = validation.validateLayout;
|
|
16
|
+
exports.ComponentRegistry = componentRegistry.ComponentRegistry;
|
|
2
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/services/component-registry.ts"],"sourcesContent":["/**\n * Component Registry Service\n * Phase 0: Static registry with Quickchart and Table definitions\n * Phase 1: Dynamic registry populated from /api/mcp/tools/list\n *\n * Provides component schemas for LLM prompt engineering\n */\n\nimport type { ComponentRegistryEntry, ComponentType } from '../types'\nimport { DEFAULT_RESOURCE_LIMITS } from './validation'\n\n/**\n * Quickchart Component Registry Entry\n * Based on Quickchart API documentation\n */\nexport const QuickchartRegistry: ComponentRegistryEntry = {\n type: 'chart',\n name: 'Quickchart',\n description:\n 'Render charts using Quickchart.io API. Supports bar, line, pie, doughnut, radar, and scatter charts. Best for visualizing numerical data with 2-10 data series and up to 1000 data points.',\n schema: {\n type: 'object',\n properties: {\n type: {\n type: 'string',\n enum: ['bar', 'line', 'pie', 'doughnut', 'radar', 'scatter'],\n description: 'Chart type',\n },\n title: {\n type: 'string',\n description: 'Chart title (optional)',\n },\n data: {\n type: 'object',\n properties: {\n labels: {\n type: 'array',\n items: { type: 'string' },\n description: 'X-axis labels',\n },\n datasets: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n label: { type: 'string' },\n data: {\n type: 'array',\n items: { type: 'number' },\n },\n backgroundColor: {\n oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],\n },\n borderColor: {\n oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],\n },\n borderWidth: { type: 'number' },\n },\n required: ['label', 'data'],\n },\n },\n },\n required: ['labels', 'datasets'],\n },\n options: {\n type: 'object',\n description: 'Chart.js options for customization',\n },\n },\n required: ['type', 'data'],\n },\n examples: [\n {\n query: 'Show me document types distribution',\n component: {\n id: 'example-bar-1',\n type: 'chart',\n position: { colStart: 1, colSpan: 6 },\n params: {\n type: 'bar',\n title: 'Document Types',\n data: {\n labels: ['PDF', 'DOCX', 'TXT', 'XLSX'],\n datasets: [\n {\n label: 'Count',\n data: [245, 189, 123, 98],\n backgroundColor: ['rgba(59, 130, 246, 0.8)'],\n },\n ],\n },\n },\n },\n },\n {\n query: 'Display upload trends over the last week',\n component: {\n id: 'example-line-1',\n type: 'chart',\n position: { colStart: 1, colSpan: 6 },\n params: {\n type: 'line',\n title: 'Upload Trends',\n data: {\n labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],\n datasets: [\n {\n label: 'Uploads',\n data: [42, 38, 51, 47, 63, 29, 15],\n borderColor: 'rgb(59, 130, 246)',\n },\n ],\n },\n options: {\n tension: 0.4,\n },\n },\n },\n },\n ],\n limits: DEFAULT_RESOURCE_LIMITS,\n}\n\n/**\n * Table Component Registry Entry\n */\nexport const TableRegistry: ComponentRegistryEntry = {\n type: 'table',\n name: 'DataTable',\n description:\n 'Render tabular data with sortable columns and pagination. Best for displaying structured records with up to 100 rows. Supports column width customization and cell formatting.',\n schema: {\n type: 'object',\n properties: {\n title: {\n type: 'string',\n description: 'Table title (optional)',\n },\n columns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key: { type: 'string', description: 'Data key for this column' },\n label: { type: 'string', description: 'Column header label' },\n sortable: { type: 'boolean', description: 'Whether column is sortable' },\n width: { type: 'string', description: 'CSS width (e.g., \"30%\")' },\n },\n required: ['key', 'label'],\n },\n minItems: 1,\n },\n rows: {\n type: 'array',\n items: {\n type: 'object',\n description: 'Row data matching column keys',\n },\n maxItems: 100,\n },\n pagination: {\n type: 'object',\n properties: {\n currentPage: { type: 'number' },\n pageSize: { type: 'number' },\n totalRows: { type: 'number' },\n },\n },\n },\n required: ['columns', 'rows'],\n },\n examples: [\n {\n query: 'Show me the most recent documents',\n component: {\n id: 'example-table-1',\n type: 'table',\n position: { colStart: 1, colSpan: 8 },\n params: {\n title: 'Recent Documents',\n columns: [\n { key: 'name', label: 'Name', sortable: true, width: '40%' },\n { key: 'type', label: 'Type', sortable: true, width: '15%' },\n { key: 'size', label: 'Size', width: '15%' },\n { key: 'modified', label: 'Modified', sortable: true, width: '30%' },\n ],\n rows: [\n { name: 'Report.pdf', type: 'PDF', size: '2.4 MB', modified: '2 hours ago' },\n { name: 'Slides.pptx', type: 'PPTX', size: '8.7 MB', modified: '1 day ago' },\n ],\n },\n },\n },\n ],\n limits: DEFAULT_RESOURCE_LIMITS,\n}\n\n/**\n * Metric Card Component Registry Entry\n */\nexport const MetricRegistry: ComponentRegistryEntry = {\n type: 'metric',\n name: 'MetricCard',\n description:\n 'Display a single metric with optional trend indicator. Best for KPIs, statistics, and summary numbers. Supports trend direction (up/down/neutral) and subtitles.',\n schema: {\n type: 'object',\n properties: {\n title: {\n type: 'string',\n description: 'Metric title',\n },\n value: {\n oneOf: [{ type: 'string' }, { type: 'number' }],\n description: 'Metric value',\n },\n unit: {\n type: 'string',\n description: 'Unit of measurement (optional)',\n },\n trend: {\n type: 'object',\n properties: {\n value: { type: 'number', description: 'Percentage change' },\n direction: { type: 'string', enum: ['up', 'down', 'neutral'] },\n },\n },\n subtitle: {\n type: 'string',\n description: 'Additional context (optional)',\n },\n },\n required: ['title', 'value'],\n },\n examples: [\n {\n query: 'Show total document count',\n component: {\n id: 'example-metric-1',\n type: 'metric',\n position: { colStart: 1, colSpan: 3 },\n params: {\n title: 'Total Documents',\n value: '1,247',\n trend: {\n value: 12.5,\n direction: 'up',\n },\n subtitle: '+142 this month',\n },\n },\n },\n ],\n limits: {\n maxDataPoints: 1,\n maxTableRows: 1,\n maxPayloadSize: 5 * 1024, // 5KB\n renderTimeout: 1000, // 1s\n },\n}\n\n/**\n * Text Component Registry Entry\n */\nexport const TextRegistry: ComponentRegistryEntry = {\n type: 'text',\n name: 'TextBlock',\n description:\n 'Render text content with optional markdown support. Best for explanations, summaries, and context. Supports basic HTML formatting.',\n schema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'Text content (HTML allowed, will be sanitized)',\n },\n markdown: {\n type: 'boolean',\n description: 'Whether content is markdown (not yet implemented)',\n },\n className: {\n type: 'string',\n description: 'Custom CSS classes',\n },\n },\n required: ['content'],\n },\n examples: [\n {\n query: 'Explain the document distribution',\n component: {\n id: 'example-text-1',\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: {\n content:\n '<p>Your document library contains <strong>1,247 files</strong> across 5 different formats. PDFs represent the largest category at 35% of total storage.</p>',\n },\n },\n },\n ],\n limits: {\n maxDataPoints: 1,\n maxTableRows: 1,\n maxPayloadSize: 10 * 1024, // 10KB\n renderTimeout: 1000, // 1s\n },\n}\n\n/**\n * Component Registry - All components indexed by type\n */\nexport const ComponentRegistry: Map<ComponentType, ComponentRegistryEntry> = new Map([\n ['chart', QuickchartRegistry],\n ['table', TableRegistry],\n ['metric', MetricRegistry],\n ['text', TextRegistry],\n])\n\n/**\n * Get component registry entry by type\n */\nexport function getComponentEntry(type: ComponentType): ComponentRegistryEntry | undefined {\n return ComponentRegistry.get(type)\n}\n\n/**\n * Get all component types\n */\nexport function getAllComponentTypes(): ComponentType[] {\n return Array.from(ComponentRegistry.keys())\n}\n\n/**\n * Get registry as JSON for LLM context\n */\nexport function getRegistryForLLM(): string {\n const entries = Array.from(ComponentRegistry.values()).map((entry) => ({\n type: entry.type,\n name: entry.name,\n description: entry.description,\n schema: entry.schema,\n examples: entry.examples.map((ex) => ({\n query: ex.query,\n component: ex.component,\n })),\n limits: entry.limits,\n }))\n\n return JSON.stringify(entries, null, 2)\n}\n\n/**\n * Validate component against registry schema\n * (Future: Use Zod for runtime validation)\n */\nexport function validateAgainstRegistry(\n componentType: ComponentType,\n params: any\n): { valid: boolean; errors?: string[] } {\n const entry = getComponentEntry(componentType)\n if (!entry) {\n return { valid: false, errors: [`Unknown component type: ${componentType}`] }\n }\n\n // Basic validation (Phase 1 will add Zod schema validation)\n const required = entry.schema.required || []\n const missing = required.filter((key: string) => !(key in params))\n\n if (missing.length > 0) {\n return {\n valid: false,\n errors: missing.map((key: string) => `Missing required field: ${key}`),\n }\n }\n\n return { valid: true }\n}\n"],"names":["QuickchartRegistry","DEFAULT_RESOURCE_LIMITS","TableRegistry","MetricRegistry","TextRegistry","ComponentRegistry"],"mappings":"iLAeaA,EAA6C,CACxD,KAAM,QACN,KAAM,aACN,YACE,6LACF,OAAQ,CACN,KAAM,SACN,WAAY,CACV,KAAM,CACJ,KAAM,SACN,KAAM,CAAC,MAAO,OAAQ,MAAO,WAAY,QAAS,SAAS,EAC3D,YAAa,YAAA,EAEf,MAAO,CACL,KAAM,SACN,YAAa,wBAAA,EAEf,KAAM,CACJ,KAAM,SACN,WAAY,CACV,OAAQ,CACN,KAAM,QACN,MAAO,CAAE,KAAM,QAAA,EACf,YAAa,eAAA,EAEf,SAAU,CACR,KAAM,QACN,MAAO,CACL,KAAM,SACN,WAAY,CACV,MAAO,CAAE,KAAM,QAAA,EACf,KAAM,CACJ,KAAM,QACN,MAAO,CAAE,KAAM,QAAA,CAAS,EAE1B,gBAAiB,CACf,MAAO,CAAC,CAAE,KAAM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,CAAY,CACvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @seed-ship/mcp-ui-solid
|
|
3
|
+
*
|
|
4
|
+
* SolidJS components and hooks for rendering MCP-generated UI resources
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { UIResourceRenderer, StreamingUIRenderer } from '@seed-ship/mcp-ui-solid'
|
|
9
|
+
* import { useStreamingUI } from '@seed-ship/mcp-ui-solid/hooks'
|
|
10
|
+
* import type { UIComponent, UILayout } from '@seed-ship/mcp-ui-solid/types'
|
|
11
|
+
*
|
|
12
|
+
* // Static rendering
|
|
13
|
+
* function Dashboard() {
|
|
14
|
+
* const layout = { components: [...] }
|
|
15
|
+
* return <UIResourceRenderer content={layout} />
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* // Streaming rendering
|
|
19
|
+
* function StreamingDashboard() {
|
|
20
|
+
* return (
|
|
21
|
+
* <StreamingUIRenderer
|
|
22
|
+
* query="Show me revenue trends"
|
|
23
|
+
* spaceIds={['space-1']}
|
|
24
|
+
* onComplete={(metadata) => console.log('Done!', metadata)}
|
|
25
|
+
* />
|
|
26
|
+
* )
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export { UIResourceRenderer, StreamingUIRenderer, GenerativeUIErrorBoundary } from './components';
|
|
31
|
+
export type { UIResourceRendererProps, StreamingUIRendererProps, GenerativeUIErrorBoundaryProps, } from './components';
|
|
32
|
+
export { useStreamingUI } from './hooks';
|
|
33
|
+
export type { UseStreamingUIOptions, StreamingUIState, StreamProgress, StreamError, CompleteMetadata, } from './hooks';
|
|
34
|
+
export type { UIComponent, UILayout, GridPosition, ComponentType, RendererError, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, } from './types';
|
|
35
|
+
export { validateComponent, validateLayout, DEFAULT_RESOURCE_LIMITS, ComponentRegistry, } from './services';
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAEjG,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAGhB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,296 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
description: "Render charts using Quickchart.io API. Supports bar, line, pie, doughnut, radar, and scatter charts. Best for visualizing numerical data with 2-10 data series and up to 1000 data points.",
|
|
8
|
-
schema: {
|
|
9
|
-
type: "object",
|
|
10
|
-
properties: {
|
|
11
|
-
type: {
|
|
12
|
-
type: "string",
|
|
13
|
-
enum: ["bar", "line", "pie", "doughnut", "radar", "scatter"],
|
|
14
|
-
description: "Chart type"
|
|
15
|
-
},
|
|
16
|
-
title: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "Chart title (optional)"
|
|
19
|
-
},
|
|
20
|
-
data: {
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
labels: {
|
|
24
|
-
type: "array",
|
|
25
|
-
items: { type: "string" },
|
|
26
|
-
description: "X-axis labels"
|
|
27
|
-
},
|
|
28
|
-
datasets: {
|
|
29
|
-
type: "array",
|
|
30
|
-
items: {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
label: { type: "string" },
|
|
34
|
-
data: {
|
|
35
|
-
type: "array",
|
|
36
|
-
items: { type: "number" }
|
|
37
|
-
},
|
|
38
|
-
backgroundColor: {
|
|
39
|
-
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
40
|
-
},
|
|
41
|
-
borderColor: {
|
|
42
|
-
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
43
|
-
},
|
|
44
|
-
borderWidth: { type: "number" }
|
|
45
|
-
},
|
|
46
|
-
required: ["label", "data"]
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
required: ["labels", "datasets"]
|
|
51
|
-
},
|
|
52
|
-
options: {
|
|
53
|
-
type: "object",
|
|
54
|
-
description: "Chart.js options for customization"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
required: ["type", "data"]
|
|
58
|
-
},
|
|
59
|
-
examples: [
|
|
60
|
-
{
|
|
61
|
-
query: "Show me document types distribution",
|
|
62
|
-
component: {
|
|
63
|
-
id: "example-bar-1",
|
|
64
|
-
type: "chart",
|
|
65
|
-
position: { colStart: 1, colSpan: 6 },
|
|
66
|
-
params: {
|
|
67
|
-
type: "bar",
|
|
68
|
-
title: "Document Types",
|
|
69
|
-
data: {
|
|
70
|
-
labels: ["PDF", "DOCX", "TXT", "XLSX"],
|
|
71
|
-
datasets: [
|
|
72
|
-
{
|
|
73
|
-
label: "Count",
|
|
74
|
-
data: [245, 189, 123, 98],
|
|
75
|
-
backgroundColor: ["rgba(59, 130, 246, 0.8)"]
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
query: "Display upload trends over the last week",
|
|
84
|
-
component: {
|
|
85
|
-
id: "example-line-1",
|
|
86
|
-
type: "chart",
|
|
87
|
-
position: { colStart: 1, colSpan: 6 },
|
|
88
|
-
params: {
|
|
89
|
-
type: "line",
|
|
90
|
-
title: "Upload Trends",
|
|
91
|
-
data: {
|
|
92
|
-
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
93
|
-
datasets: [
|
|
94
|
-
{
|
|
95
|
-
label: "Uploads",
|
|
96
|
-
data: [42, 38, 51, 47, 63, 29, 15],
|
|
97
|
-
borderColor: "rgb(59, 130, 246)"
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
options: {
|
|
102
|
-
tension: 0.4
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
limits: e
|
|
109
|
-
}, a = {
|
|
110
|
-
type: "table",
|
|
111
|
-
name: "DataTable",
|
|
112
|
-
description: "Render tabular data with sortable columns and pagination. Best for displaying structured records with up to 100 rows. Supports column width customization and cell formatting.",
|
|
113
|
-
schema: {
|
|
114
|
-
type: "object",
|
|
115
|
-
properties: {
|
|
116
|
-
title: {
|
|
117
|
-
type: "string",
|
|
118
|
-
description: "Table title (optional)"
|
|
119
|
-
},
|
|
120
|
-
columns: {
|
|
121
|
-
type: "array",
|
|
122
|
-
items: {
|
|
123
|
-
type: "object",
|
|
124
|
-
properties: {
|
|
125
|
-
key: { type: "string", description: "Data key for this column" },
|
|
126
|
-
label: { type: "string", description: "Column header label" },
|
|
127
|
-
sortable: { type: "boolean", description: "Whether column is sortable" },
|
|
128
|
-
width: { type: "string", description: 'CSS width (e.g., "30%")' }
|
|
129
|
-
},
|
|
130
|
-
required: ["key", "label"]
|
|
131
|
-
},
|
|
132
|
-
minItems: 1
|
|
133
|
-
},
|
|
134
|
-
rows: {
|
|
135
|
-
type: "array",
|
|
136
|
-
items: {
|
|
137
|
-
type: "object",
|
|
138
|
-
description: "Row data matching column keys"
|
|
139
|
-
},
|
|
140
|
-
maxItems: 100
|
|
141
|
-
},
|
|
142
|
-
pagination: {
|
|
143
|
-
type: "object",
|
|
144
|
-
properties: {
|
|
145
|
-
currentPage: { type: "number" },
|
|
146
|
-
pageSize: { type: "number" },
|
|
147
|
-
totalRows: { type: "number" }
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
required: ["columns", "rows"]
|
|
152
|
-
},
|
|
153
|
-
examples: [
|
|
154
|
-
{
|
|
155
|
-
query: "Show me the most recent documents",
|
|
156
|
-
component: {
|
|
157
|
-
id: "example-table-1",
|
|
158
|
-
type: "table",
|
|
159
|
-
position: { colStart: 1, colSpan: 8 },
|
|
160
|
-
params: {
|
|
161
|
-
title: "Recent Documents",
|
|
162
|
-
columns: [
|
|
163
|
-
{ key: "name", label: "Name", sortable: !0, width: "40%" },
|
|
164
|
-
{ key: "type", label: "Type", sortable: !0, width: "15%" },
|
|
165
|
-
{ key: "size", label: "Size", width: "15%" },
|
|
166
|
-
{ key: "modified", label: "Modified", sortable: !0, width: "30%" }
|
|
167
|
-
],
|
|
168
|
-
rows: [
|
|
169
|
-
{ name: "Report.pdf", type: "PDF", size: "2.4 MB", modified: "2 hours ago" },
|
|
170
|
-
{ name: "Slides.pptx", type: "PPTX", size: "8.7 MB", modified: "1 day ago" }
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
],
|
|
176
|
-
limits: e
|
|
177
|
-
}, r = {
|
|
178
|
-
type: "metric",
|
|
179
|
-
name: "MetricCard",
|
|
180
|
-
description: "Display a single metric with optional trend indicator. Best for KPIs, statistics, and summary numbers. Supports trend direction (up/down/neutral) and subtitles.",
|
|
181
|
-
schema: {
|
|
182
|
-
type: "object",
|
|
183
|
-
properties: {
|
|
184
|
-
title: {
|
|
185
|
-
type: "string",
|
|
186
|
-
description: "Metric title"
|
|
187
|
-
},
|
|
188
|
-
value: {
|
|
189
|
-
oneOf: [{ type: "string" }, { type: "number" }],
|
|
190
|
-
description: "Metric value"
|
|
191
|
-
},
|
|
192
|
-
unit: {
|
|
193
|
-
type: "string",
|
|
194
|
-
description: "Unit of measurement (optional)"
|
|
195
|
-
},
|
|
196
|
-
trend: {
|
|
197
|
-
type: "object",
|
|
198
|
-
properties: {
|
|
199
|
-
value: { type: "number", description: "Percentage change" },
|
|
200
|
-
direction: { type: "string", enum: ["up", "down", "neutral"] }
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
subtitle: {
|
|
204
|
-
type: "string",
|
|
205
|
-
description: "Additional context (optional)"
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
required: ["title", "value"]
|
|
209
|
-
},
|
|
210
|
-
examples: [
|
|
211
|
-
{
|
|
212
|
-
query: "Show total document count",
|
|
213
|
-
component: {
|
|
214
|
-
id: "example-metric-1",
|
|
215
|
-
type: "metric",
|
|
216
|
-
position: { colStart: 1, colSpan: 3 },
|
|
217
|
-
params: {
|
|
218
|
-
title: "Total Documents",
|
|
219
|
-
value: "1,247",
|
|
220
|
-
trend: {
|
|
221
|
-
value: 12.5,
|
|
222
|
-
direction: "up"
|
|
223
|
-
},
|
|
224
|
-
subtitle: "+142 this month"
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
],
|
|
229
|
-
limits: {
|
|
230
|
-
maxDataPoints: 1,
|
|
231
|
-
maxTableRows: 1,
|
|
232
|
-
maxPayloadSize: 5 * 1024,
|
|
233
|
-
// 5KB
|
|
234
|
-
renderTimeout: 1e3
|
|
235
|
-
// 1s
|
|
236
|
-
}
|
|
237
|
-
}, i = {
|
|
238
|
-
type: "text",
|
|
239
|
-
name: "TextBlock",
|
|
240
|
-
description: "Render text content with optional markdown support. Best for explanations, summaries, and context. Supports basic HTML formatting.",
|
|
241
|
-
schema: {
|
|
242
|
-
type: "object",
|
|
243
|
-
properties: {
|
|
244
|
-
content: {
|
|
245
|
-
type: "string",
|
|
246
|
-
description: "Text content (HTML allowed, will be sanitized)"
|
|
247
|
-
},
|
|
248
|
-
markdown: {
|
|
249
|
-
type: "boolean",
|
|
250
|
-
description: "Whether content is markdown (not yet implemented)"
|
|
251
|
-
},
|
|
252
|
-
className: {
|
|
253
|
-
type: "string",
|
|
254
|
-
description: "Custom CSS classes"
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
required: ["content"]
|
|
258
|
-
},
|
|
259
|
-
examples: [
|
|
260
|
-
{
|
|
261
|
-
query: "Explain the document distribution",
|
|
262
|
-
component: {
|
|
263
|
-
id: "example-text-1",
|
|
264
|
-
type: "text",
|
|
265
|
-
position: { colStart: 1, colSpan: 12 },
|
|
266
|
-
params: {
|
|
267
|
-
content: "<p>Your document library contains <strong>1,247 files</strong> across 5 different formats. PDFs represent the largest category at 35% of total storage.</p>"
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
],
|
|
272
|
-
limits: {
|
|
273
|
-
maxDataPoints: 1,
|
|
274
|
-
maxTableRows: 1,
|
|
275
|
-
maxPayloadSize: 10 * 1024,
|
|
276
|
-
// 10KB
|
|
277
|
-
renderTimeout: 1e3
|
|
278
|
-
// 1s
|
|
279
|
-
}
|
|
280
|
-
}, n = /* @__PURE__ */ new Map([
|
|
281
|
-
["chart", t],
|
|
282
|
-
["table", a],
|
|
283
|
-
["metric", r],
|
|
284
|
-
["text", i]
|
|
285
|
-
]);
|
|
1
|
+
import { UIResourceRenderer } from "./components/UIResourceRenderer.js";
|
|
2
|
+
import { StreamingUIRenderer } from "./components/StreamingUIRenderer.js";
|
|
3
|
+
import { GenerativeUIErrorBoundary } from "./components/GenerativeUIErrorBoundary.js";
|
|
4
|
+
import { useStreamingUI } from "./hooks/useStreamingUI.js";
|
|
5
|
+
import { DEFAULT_RESOURCE_LIMITS, validateComponent, validateLayout } from "./services/validation.js";
|
|
6
|
+
import { ComponentRegistry } from "./services/component-registry.js";
|
|
286
7
|
export {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
8
|
+
ComponentRegistry,
|
|
9
|
+
DEFAULT_RESOURCE_LIMITS,
|
|
10
|
+
GenerativeUIErrorBoundary,
|
|
11
|
+
StreamingUIRenderer,
|
|
12
|
+
UIResourceRenderer,
|
|
13
|
+
useStreamingUI,
|
|
14
|
+
validateComponent,
|
|
15
|
+
validateLayout
|
|
295
16
|
};
|
|
296
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/services/component-registry.ts"],"sourcesContent":["/**\n * Component Registry Service\n * Phase 0: Static registry with Quickchart and Table definitions\n * Phase 1: Dynamic registry populated from /api/mcp/tools/list\n *\n * Provides component schemas for LLM prompt engineering\n */\n\nimport type { ComponentRegistryEntry, ComponentType } from '../types'\nimport { DEFAULT_RESOURCE_LIMITS } from './validation'\n\n/**\n * Quickchart Component Registry Entry\n * Based on Quickchart API documentation\n */\nexport const QuickchartRegistry: ComponentRegistryEntry = {\n type: 'chart',\n name: 'Quickchart',\n description:\n 'Render charts using Quickchart.io API. Supports bar, line, pie, doughnut, radar, and scatter charts. Best for visualizing numerical data with 2-10 data series and up to 1000 data points.',\n schema: {\n type: 'object',\n properties: {\n type: {\n type: 'string',\n enum: ['bar', 'line', 'pie', 'doughnut', 'radar', 'scatter'],\n description: 'Chart type',\n },\n title: {\n type: 'string',\n description: 'Chart title (optional)',\n },\n data: {\n type: 'object',\n properties: {\n labels: {\n type: 'array',\n items: { type: 'string' },\n description: 'X-axis labels',\n },\n datasets: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n label: { type: 'string' },\n data: {\n type: 'array',\n items: { type: 'number' },\n },\n backgroundColor: {\n oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],\n },\n borderColor: {\n oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],\n },\n borderWidth: { type: 'number' },\n },\n required: ['label', 'data'],\n },\n },\n },\n required: ['labels', 'datasets'],\n },\n options: {\n type: 'object',\n description: 'Chart.js options for customization',\n },\n },\n required: ['type', 'data'],\n },\n examples: [\n {\n query: 'Show me document types distribution',\n component: {\n id: 'example-bar-1',\n type: 'chart',\n position: { colStart: 1, colSpan: 6 },\n params: {\n type: 'bar',\n title: 'Document Types',\n data: {\n labels: ['PDF', 'DOCX', 'TXT', 'XLSX'],\n datasets: [\n {\n label: 'Count',\n data: [245, 189, 123, 98],\n backgroundColor: ['rgba(59, 130, 246, 0.8)'],\n },\n ],\n },\n },\n },\n },\n {\n query: 'Display upload trends over the last week',\n component: {\n id: 'example-line-1',\n type: 'chart',\n position: { colStart: 1, colSpan: 6 },\n params: {\n type: 'line',\n title: 'Upload Trends',\n data: {\n labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],\n datasets: [\n {\n label: 'Uploads',\n data: [42, 38, 51, 47, 63, 29, 15],\n borderColor: 'rgb(59, 130, 246)',\n },\n ],\n },\n options: {\n tension: 0.4,\n },\n },\n },\n },\n ],\n limits: DEFAULT_RESOURCE_LIMITS,\n}\n\n/**\n * Table Component Registry Entry\n */\nexport const TableRegistry: ComponentRegistryEntry = {\n type: 'table',\n name: 'DataTable',\n description:\n 'Render tabular data with sortable columns and pagination. Best for displaying structured records with up to 100 rows. Supports column width customization and cell formatting.',\n schema: {\n type: 'object',\n properties: {\n title: {\n type: 'string',\n description: 'Table title (optional)',\n },\n columns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key: { type: 'string', description: 'Data key for this column' },\n label: { type: 'string', description: 'Column header label' },\n sortable: { type: 'boolean', description: 'Whether column is sortable' },\n width: { type: 'string', description: 'CSS width (e.g., \"30%\")' },\n },\n required: ['key', 'label'],\n },\n minItems: 1,\n },\n rows: {\n type: 'array',\n items: {\n type: 'object',\n description: 'Row data matching column keys',\n },\n maxItems: 100,\n },\n pagination: {\n type: 'object',\n properties: {\n currentPage: { type: 'number' },\n pageSize: { type: 'number' },\n totalRows: { type: 'number' },\n },\n },\n },\n required: ['columns', 'rows'],\n },\n examples: [\n {\n query: 'Show me the most recent documents',\n component: {\n id: 'example-table-1',\n type: 'table',\n position: { colStart: 1, colSpan: 8 },\n params: {\n title: 'Recent Documents',\n columns: [\n { key: 'name', label: 'Name', sortable: true, width: '40%' },\n { key: 'type', label: 'Type', sortable: true, width: '15%' },\n { key: 'size', label: 'Size', width: '15%' },\n { key: 'modified', label: 'Modified', sortable: true, width: '30%' },\n ],\n rows: [\n { name: 'Report.pdf', type: 'PDF', size: '2.4 MB', modified: '2 hours ago' },\n { name: 'Slides.pptx', type: 'PPTX', size: '8.7 MB', modified: '1 day ago' },\n ],\n },\n },\n },\n ],\n limits: DEFAULT_RESOURCE_LIMITS,\n}\n\n/**\n * Metric Card Component Registry Entry\n */\nexport const MetricRegistry: ComponentRegistryEntry = {\n type: 'metric',\n name: 'MetricCard',\n description:\n 'Display a single metric with optional trend indicator. Best for KPIs, statistics, and summary numbers. Supports trend direction (up/down/neutral) and subtitles.',\n schema: {\n type: 'object',\n properties: {\n title: {\n type: 'string',\n description: 'Metric title',\n },\n value: {\n oneOf: [{ type: 'string' }, { type: 'number' }],\n description: 'Metric value',\n },\n unit: {\n type: 'string',\n description: 'Unit of measurement (optional)',\n },\n trend: {\n type: 'object',\n properties: {\n value: { type: 'number', description: 'Percentage change' },\n direction: { type: 'string', enum: ['up', 'down', 'neutral'] },\n },\n },\n subtitle: {\n type: 'string',\n description: 'Additional context (optional)',\n },\n },\n required: ['title', 'value'],\n },\n examples: [\n {\n query: 'Show total document count',\n component: {\n id: 'example-metric-1',\n type: 'metric',\n position: { colStart: 1, colSpan: 3 },\n params: {\n title: 'Total Documents',\n value: '1,247',\n trend: {\n value: 12.5,\n direction: 'up',\n },\n subtitle: '+142 this month',\n },\n },\n },\n ],\n limits: {\n maxDataPoints: 1,\n maxTableRows: 1,\n maxPayloadSize: 5 * 1024, // 5KB\n renderTimeout: 1000, // 1s\n },\n}\n\n/**\n * Text Component Registry Entry\n */\nexport const TextRegistry: ComponentRegistryEntry = {\n type: 'text',\n name: 'TextBlock',\n description:\n 'Render text content with optional markdown support. Best for explanations, summaries, and context. Supports basic HTML formatting.',\n schema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'Text content (HTML allowed, will be sanitized)',\n },\n markdown: {\n type: 'boolean',\n description: 'Whether content is markdown (not yet implemented)',\n },\n className: {\n type: 'string',\n description: 'Custom CSS classes',\n },\n },\n required: ['content'],\n },\n examples: [\n {\n query: 'Explain the document distribution',\n component: {\n id: 'example-text-1',\n type: 'text',\n position: { colStart: 1, colSpan: 12 },\n params: {\n content:\n '<p>Your document library contains <strong>1,247 files</strong> across 5 different formats. PDFs represent the largest category at 35% of total storage.</p>',\n },\n },\n },\n ],\n limits: {\n maxDataPoints: 1,\n maxTableRows: 1,\n maxPayloadSize: 10 * 1024, // 10KB\n renderTimeout: 1000, // 1s\n },\n}\n\n/**\n * Component Registry - All components indexed by type\n */\nexport const ComponentRegistry: Map<ComponentType, ComponentRegistryEntry> = new Map([\n ['chart', QuickchartRegistry],\n ['table', TableRegistry],\n ['metric', MetricRegistry],\n ['text', TextRegistry],\n])\n\n/**\n * Get component registry entry by type\n */\nexport function getComponentEntry(type: ComponentType): ComponentRegistryEntry | undefined {\n return ComponentRegistry.get(type)\n}\n\n/**\n * Get all component types\n */\nexport function getAllComponentTypes(): ComponentType[] {\n return Array.from(ComponentRegistry.keys())\n}\n\n/**\n * Get registry as JSON for LLM context\n */\nexport function getRegistryForLLM(): string {\n const entries = Array.from(ComponentRegistry.values()).map((entry) => ({\n type: entry.type,\n name: entry.name,\n description: entry.description,\n schema: entry.schema,\n examples: entry.examples.map((ex) => ({\n query: ex.query,\n component: ex.component,\n })),\n limits: entry.limits,\n }))\n\n return JSON.stringify(entries, null, 2)\n}\n\n/**\n * Validate component against registry schema\n * (Future: Use Zod for runtime validation)\n */\nexport function validateAgainstRegistry(\n componentType: ComponentType,\n params: any\n): { valid: boolean; errors?: string[] } {\n const entry = getComponentEntry(componentType)\n if (!entry) {\n return { valid: false, errors: [`Unknown component type: ${componentType}`] }\n }\n\n // Basic validation (Phase 1 will add Zod schema validation)\n const required = entry.schema.required || []\n const missing = required.filter((key: string) => !(key in params))\n\n if (missing.length > 0) {\n return {\n valid: false,\n errors: missing.map((key: string) => `Missing required field: ${key}`),\n }\n }\n\n return { valid: true }\n}\n"],"names":["QuickchartRegistry","DEFAULT_RESOURCE_LIMITS","TableRegistry","MetricRegistry","TextRegistry","ComponentRegistry"],"mappings":";;;AAeO,MAAMA,IAA6C;AAAA,EACxD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aACE;AAAA,EACF,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,MAAM,CAAC,OAAO,QAAQ,OAAO,YAAY,SAAS,SAAS;AAAA,QAC3D,aAAa;AAAA,MAAA;AAAA,MAEf,OAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa;AAAA,MAAA;AAAA,MAEf,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,YAAY;AAAA,UACV,QAAQ;AAAA,YACN,MAAM;AAAA,YACN,OAAO,EAAE,MAAM,SAAA;AAAA,YACf,aAAa;AAAA,UAAA;AAAA,UAEf,UAAU;AAAA,YACR,MAAM;AAAA,YACN,OAAO;AAAA,cACL,MAAM;AAAA,cACN,YAAY;AAAA,gBACV,OAAO,EAAE,MAAM,SAAA;AAAA,gBACf,MAAM;A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