@nahisaho/yata-ui 1.7.0

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/bin/yata-ui.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * YATA UI CLI
4
+ *
5
+ * Start the YATA Knowledge Graph Web UI server.
6
+ *
7
+ * @see REQ-YI-WEB-001
8
+ */
9
+
10
+ import { createYataUIServer } from '../dist/index.js';
11
+
12
+ const args = process.argv.slice(2);
13
+ const portArg = args.find(a => a.startsWith('--port='));
14
+ const port = portArg ? parseInt(portArg.split('=')[1], 10) : 3000;
15
+
16
+ const server = createYataUIServer({ port });
17
+
18
+ // Demo data provider
19
+ server.setDataProvider(async () => ({
20
+ nodes: [
21
+ { id: '1', label: 'UserService', type: 'class', namespace: 'app.services' },
22
+ { id: '2', label: 'UserRepository', type: 'interface', namespace: 'app.repositories' },
23
+ { id: '3', label: 'User', type: 'entity', namespace: 'app.domain' },
24
+ { id: '4', label: 'createUser', type: 'function', namespace: 'app.services' },
25
+ ],
26
+ edges: [
27
+ { id: 'e1', source: '1', target: '2', type: 'uses', label: 'uses' },
28
+ { id: 'e2', source: '1', target: '3', type: 'returns', label: 'returns' },
29
+ { id: 'e3', source: '4', target: '3', type: 'creates', label: 'creates' },
30
+ ],
31
+ }));
32
+
33
+ server.start().then(() => {
34
+ console.log(`🌐 YATA UI running at ${server.getUrl()}`);
35
+ console.log('Press Ctrl+C to stop');
36
+ });
37
+
38
+ process.on('SIGINT', async () => {
39
+ console.log('\nShutting down...');
40
+ await server.stop();
41
+ process.exit(0);
42
+ });
@@ -0,0 +1,203 @@
1
+ /**
2
+ * YATA UI Server
3
+ *
4
+ * Web-based visualization and management interface for YATA knowledge graphs.
5
+ *
6
+ * @packageDocumentation
7
+ * @module @nahisaho/yata-ui
8
+ *
9
+ * @see REQ-YI-WEB-001 - Web-based Visualization
10
+ * @see REQ-YI-WEB-002 - Interactive Graph Editing
11
+ * @see REQ-YI-WEB-003 - Real-time Updates
12
+ * @see DES-YATA-IMPROVEMENTS-001 - Design Document
13
+ */
14
+ import { Express } from 'express';
15
+ /**
16
+ * UI Server configuration
17
+ * @see REQ-YI-WEB-001
18
+ */
19
+ export interface UIServerConfig {
20
+ /** Server port */
21
+ port: number;
22
+ /** Host to bind to */
23
+ host?: string;
24
+ /** Enable CORS */
25
+ cors?: boolean;
26
+ /** Static files directory */
27
+ staticDir?: string;
28
+ /** API base path */
29
+ apiBasePath?: string;
30
+ /** Enable real-time updates via SSE */
31
+ enableRealtime?: boolean;
32
+ }
33
+ /**
34
+ * Graph data for visualization
35
+ */
36
+ export interface GraphData {
37
+ /** Nodes (entities) */
38
+ nodes: GraphNode[];
39
+ /** Edges (relationships) */
40
+ edges: GraphEdge[];
41
+ /** Graph metadata */
42
+ metadata?: Record<string, unknown>;
43
+ }
44
+ /**
45
+ * Graph node
46
+ */
47
+ export interface GraphNode {
48
+ /** Node ID */
49
+ id: string;
50
+ /** Node label */
51
+ label: string;
52
+ /** Node type */
53
+ type: string;
54
+ /** Namespace */
55
+ namespace?: string;
56
+ /** Position (optional) */
57
+ position?: {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ /** Custom data */
62
+ data?: Record<string, unknown>;
63
+ }
64
+ /**
65
+ * Graph edge
66
+ */
67
+ export interface GraphEdge {
68
+ /** Edge ID */
69
+ id: string;
70
+ /** Source node ID */
71
+ source: string;
72
+ /** Target node ID */
73
+ target: string;
74
+ /** Relationship type */
75
+ type: string;
76
+ /** Edge label */
77
+ label?: string;
78
+ /** Edge weight */
79
+ weight?: number;
80
+ /** Custom data */
81
+ data?: Record<string, unknown>;
82
+ }
83
+ /**
84
+ * API response
85
+ */
86
+ export interface ApiResponse<T> {
87
+ /** Success status */
88
+ success: boolean;
89
+ /** Response data */
90
+ data?: T;
91
+ /** Error message */
92
+ error?: string;
93
+ /** Timestamp */
94
+ timestamp: string;
95
+ }
96
+ /**
97
+ * Default configuration
98
+ */
99
+ export declare const DEFAULT_UI_CONFIG: Partial<UIServerConfig>;
100
+ /**
101
+ * YATA Knowledge Graph Web UI Server
102
+ *
103
+ * Provides web-based visualization and management for YATA knowledge graphs.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const server = new YataUIServer({
108
+ * port: 3000,
109
+ * enableRealtime: true,
110
+ * });
111
+ *
112
+ * // Set data provider
113
+ * server.setDataProvider(async () => {
114
+ * return {
115
+ * nodes: [{ id: '1', label: 'Node 1', type: 'entity' }],
116
+ * edges: [],
117
+ * };
118
+ * });
119
+ *
120
+ * await server.start();
121
+ * console.log('UI available at http://localhost:3000');
122
+ * ```
123
+ *
124
+ * @see REQ-YI-WEB-001
125
+ * @see REQ-YI-WEB-002
126
+ * @see REQ-YI-WEB-003
127
+ */
128
+ export declare class YataUIServer {
129
+ private app;
130
+ private server;
131
+ private config;
132
+ private sseClients;
133
+ private dataProvider;
134
+ constructor(config?: Partial<UIServerConfig>);
135
+ /**
136
+ * Set data provider function
137
+ * @param provider - Function that returns graph data
138
+ */
139
+ setDataProvider(provider: () => Promise<GraphData>): void;
140
+ /**
141
+ * Start the server
142
+ * @see REQ-YI-WEB-001
143
+ */
144
+ start(): Promise<void>;
145
+ /**
146
+ * Stop the server
147
+ */
148
+ stop(): Promise<void>;
149
+ /**
150
+ * Get server URL
151
+ */
152
+ getUrl(): string;
153
+ /**
154
+ * Check if server is running
155
+ */
156
+ isRunning(): boolean;
157
+ /**
158
+ * Broadcast update to all SSE clients
159
+ * @see REQ-YI-WEB-003
160
+ */
161
+ broadcastUpdate(event: string, data: unknown): void;
162
+ /**
163
+ * Get Express app instance for testing
164
+ */
165
+ getApp(): Express;
166
+ private setupMiddleware;
167
+ private setupRoutes;
168
+ /**
169
+ * Handle SSE connection
170
+ * @see REQ-YI-WEB-003
171
+ */
172
+ private handleSSEConnection;
173
+ /**
174
+ * Get graph data from provider
175
+ */
176
+ private getGraphData;
177
+ /**
178
+ * Send API response
179
+ */
180
+ private sendResponse;
181
+ /**
182
+ * Send error response
183
+ */
184
+ private sendError;
185
+ /**
186
+ * Convert to Cytoscape.js format
187
+ * @see REQ-YI-WEB-001
188
+ */
189
+ private toCytoscapeFormat;
190
+ /**
191
+ * Count items by type
192
+ */
193
+ private countByType;
194
+ /**
195
+ * Get built-in UI HTML
196
+ */
197
+ private getBuiltInUI;
198
+ }
199
+ /**
200
+ * Factory function to create YataUIServer
201
+ */
202
+ export declare function createYataUIServer(config?: Partial<UIServerConfig>): YataUIServer;
203
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAgB,EAAE,OAAO,EAA6B,MAAM,SAAS,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,4BAA4B;IAC5B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IAC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