autoui-react 0.0.3-alpha
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/README.md +244 -0
- package/dist/index.css +56 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +546 -0
- package/dist/index.d.ts +546 -0
- package/dist/index.js +1466 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1449 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Event types that can be triggered by UI elements
|
|
6
|
+
*/
|
|
7
|
+
declare const uiEventType: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
8
|
+
type UIEventType = z.infer<typeof uiEventType>;
|
|
9
|
+
/**
|
|
10
|
+
* Event payload schema
|
|
11
|
+
*/
|
|
12
|
+
declare const uiEvent: z.ZodObject<{
|
|
13
|
+
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
14
|
+
nodeId: z.ZodString;
|
|
15
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
19
|
+
nodeId: string;
|
|
20
|
+
timestamp?: number | undefined;
|
|
21
|
+
payload?: Record<string, any> | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
24
|
+
nodeId: string;
|
|
25
|
+
timestamp?: number | undefined;
|
|
26
|
+
payload?: Record<string, any> | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
type UIEvent = z.infer<typeof uiEvent>;
|
|
29
|
+
/**
|
|
30
|
+
* Core UI specification node
|
|
31
|
+
* Represents a single element in the UI tree
|
|
32
|
+
*/
|
|
33
|
+
declare const uiSpecNode: z.ZodType<UISpecNode>;
|
|
34
|
+
type UISpecNode = {
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
props?: Record<string, any> | undefined;
|
|
38
|
+
bindings?: Record<string, any> | undefined;
|
|
39
|
+
events?: Record<string, {
|
|
40
|
+
action: string;
|
|
41
|
+
target?: string | undefined;
|
|
42
|
+
payload?: Record<string, any> | undefined;
|
|
43
|
+
}> | undefined;
|
|
44
|
+
children?: UISpecNode[] | undefined;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Application state for the UI engine
|
|
48
|
+
*/
|
|
49
|
+
declare const uiState: z.ZodObject<{
|
|
50
|
+
layout: z.ZodOptional<z.ZodType<UISpecNode, z.ZodTypeDef, UISpecNode>>;
|
|
51
|
+
loading: z.ZodBoolean;
|
|
52
|
+
history: z.ZodArray<z.ZodObject<{
|
|
53
|
+
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
54
|
+
nodeId: z.ZodString;
|
|
55
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
59
|
+
nodeId: string;
|
|
60
|
+
timestamp?: number | undefined;
|
|
61
|
+
payload?: Record<string, any> | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
64
|
+
nodeId: string;
|
|
65
|
+
timestamp?: number | undefined;
|
|
66
|
+
payload?: Record<string, any> | undefined;
|
|
67
|
+
}>, "many">;
|
|
68
|
+
error: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
loading: boolean;
|
|
71
|
+
history: {
|
|
72
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
73
|
+
nodeId: string;
|
|
74
|
+
timestamp?: number | undefined;
|
|
75
|
+
payload?: Record<string, any> | undefined;
|
|
76
|
+
}[];
|
|
77
|
+
layout?: UISpecNode | undefined;
|
|
78
|
+
error?: string | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
loading: boolean;
|
|
81
|
+
history: {
|
|
82
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
83
|
+
nodeId: string;
|
|
84
|
+
timestamp?: number | undefined;
|
|
85
|
+
payload?: Record<string, any> | undefined;
|
|
86
|
+
}[];
|
|
87
|
+
layout?: UISpecNode | undefined;
|
|
88
|
+
error?: string | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
type UIState = z.infer<typeof uiState>;
|
|
91
|
+
/**
|
|
92
|
+
* Input for the AI planner
|
|
93
|
+
*/
|
|
94
|
+
declare const plannerInput: z.ZodObject<{
|
|
95
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
96
|
+
goal: z.ZodString;
|
|
97
|
+
history: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
98
|
+
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
99
|
+
nodeId: z.ZodString;
|
|
100
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
104
|
+
nodeId: string;
|
|
105
|
+
timestamp?: number | undefined;
|
|
106
|
+
payload?: Record<string, any> | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
109
|
+
nodeId: string;
|
|
110
|
+
timestamp?: number | undefined;
|
|
111
|
+
payload?: Record<string, any> | undefined;
|
|
112
|
+
}>, "many">>;
|
|
113
|
+
userContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
schema: Record<string, unknown>;
|
|
116
|
+
goal: string;
|
|
117
|
+
history?: {
|
|
118
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
119
|
+
nodeId: string;
|
|
120
|
+
timestamp?: number | undefined;
|
|
121
|
+
payload?: Record<string, any> | undefined;
|
|
122
|
+
}[] | undefined;
|
|
123
|
+
userContext?: Record<string, unknown> | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
schema: Record<string, unknown>;
|
|
126
|
+
goal: string;
|
|
127
|
+
history?: {
|
|
128
|
+
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
129
|
+
nodeId: string;
|
|
130
|
+
timestamp?: number | undefined;
|
|
131
|
+
payload?: Record<string, any> | undefined;
|
|
132
|
+
}[] | undefined;
|
|
133
|
+
userContext?: Record<string, unknown> | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
type PlannerInput = z.infer<typeof plannerInput>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Interface for the runtime data context
|
|
139
|
+
*/
|
|
140
|
+
interface DataContext {
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Action types supported by the router
|
|
146
|
+
*/
|
|
147
|
+
declare enum ActionType {
|
|
148
|
+
FULL_REFRESH = "FULL_REFRESH",// Generate a completely new UI
|
|
149
|
+
UPDATE_NODE = "UPDATE_NODE",// Update a specific node
|
|
150
|
+
ADD_DROPDOWN = "ADD_DROPDOWN",// Add a dropdown to a specific node
|
|
151
|
+
SHOW_DETAIL = "SHOW_DETAIL",// Show a detail view
|
|
152
|
+
HIDE_DETAIL = "HIDE_DETAIL",// Hide a detail view
|
|
153
|
+
TOGGLE_STATE = "TOGGLE_STATE",// Toggle a boolean state (expanded, selected, etc.)
|
|
154
|
+
UPDATE_FORM = "UPDATE_FORM",// Update a form based on selections
|
|
155
|
+
NAVIGATE = "NAVIGATE"
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Routing configuration for an action
|
|
159
|
+
*/
|
|
160
|
+
interface ActionRouteConfig {
|
|
161
|
+
actionType: ActionType;
|
|
162
|
+
targetNodeId: string;
|
|
163
|
+
promptTemplate: string;
|
|
164
|
+
contextKeys?: string[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Interface for route resolution
|
|
168
|
+
*/
|
|
169
|
+
interface RouteResolution {
|
|
170
|
+
actionType: ActionType;
|
|
171
|
+
targetNodeId: string;
|
|
172
|
+
plannerInput: PlannerInput;
|
|
173
|
+
prompt: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Action router class - handles determining what part of the UI to update
|
|
177
|
+
*/
|
|
178
|
+
declare class ActionRouter {
|
|
179
|
+
private routes;
|
|
180
|
+
/**
|
|
181
|
+
* Register a new action route
|
|
182
|
+
* @param eventType - UI event type to route
|
|
183
|
+
* @param config - Route configuration
|
|
184
|
+
*/
|
|
185
|
+
registerRoute(eventType: string, config: ActionRouteConfig): void;
|
|
186
|
+
/**
|
|
187
|
+
* Find the appropriate route for an event
|
|
188
|
+
* @param event - UI event
|
|
189
|
+
* @param layout - Current UI layout
|
|
190
|
+
* @param dataContext - Current data context
|
|
191
|
+
* @returns Route resolution or null if no match
|
|
192
|
+
*/
|
|
193
|
+
resolveRoute(event: UIEvent, schema: Record<string, unknown>, layout: UISpecNode | undefined, dataContext: DataContext, goal: string, userContext?: Record<string, unknown>): RouteResolution | null;
|
|
194
|
+
/**
|
|
195
|
+
* Process a prompt template with variables
|
|
196
|
+
* @param template - Template string with ${var} placeholders
|
|
197
|
+
* @param values - Values to substitute
|
|
198
|
+
* @returns Processed string
|
|
199
|
+
*/
|
|
200
|
+
private processTemplate;
|
|
201
|
+
}
|
|
202
|
+
declare function createDefaultRouter(): ActionRouter;
|
|
203
|
+
|
|
204
|
+
interface EventHookOptions {
|
|
205
|
+
preventDefault?: boolean;
|
|
206
|
+
stopPropagation?: boolean;
|
|
207
|
+
}
|
|
208
|
+
interface EventHookContext {
|
|
209
|
+
originalEvent: UIEvent;
|
|
210
|
+
preventDefault: () => void;
|
|
211
|
+
stopPropagation: () => void;
|
|
212
|
+
isDefaultPrevented: () => boolean;
|
|
213
|
+
isPropagationStopped: () => boolean;
|
|
214
|
+
}
|
|
215
|
+
type EventHook = (context: EventHookContext) => void | Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Create a hook to intercept specific events
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```tsx
|
|
221
|
+
* const unregister = useEventHook(['CLICK'], (ctx) => {
|
|
222
|
+
* if (ctx.originalEvent.nodeId === 'deleteButton') {
|
|
223
|
+
* // Show confirmation dialog
|
|
224
|
+
* const confirmed = window.confirm('Are you sure?');
|
|
225
|
+
* if (!confirmed) {
|
|
226
|
+
* ctx.preventDefault();
|
|
227
|
+
* }
|
|
228
|
+
* }
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
declare function createEventHook(eventTypes: UIEventType[] | 'all', hook: EventHook, options?: EventHookOptions): EventHook;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* System event types that represent the internal AutoUI lifecycle
|
|
236
|
+
*/
|
|
237
|
+
declare enum SystemEventType {
|
|
238
|
+
PLAN_START = "PLAN_START",// Before AI planning begins
|
|
239
|
+
PLAN_PROMPT_CREATED = "PLAN_PROMPT_CREATED",// After prompt is built
|
|
240
|
+
PLAN_RESPONSE_CHUNK = "PLAN_RESPONSE_CHUNK",// For each AI response chunk
|
|
241
|
+
PLAN_COMPLETE = "PLAN_COMPLETE",// After planning is complete
|
|
242
|
+
PLAN_ERROR = "PLAN_ERROR",// Planning error occurred
|
|
243
|
+
BINDING_RESOLUTION_START = "BINDING_RESOLUTION_START",// Before bindings are resolved
|
|
244
|
+
BINDING_RESOLUTION_COMPLETE = "BINDING_RESOLUTION_COMPLETE",// After bindings are resolved
|
|
245
|
+
DATA_FETCH_START = "DATA_FETCH_START",// Before data is fetched
|
|
246
|
+
DATA_FETCH_COMPLETE = "DATA_FETCH_COMPLETE",// After data is fetched
|
|
247
|
+
RENDER_START = "RENDER_START",// Before layout is rendered
|
|
248
|
+
RENDER_COMPLETE = "RENDER_COMPLETE",// After layout is rendered
|
|
249
|
+
PREFETCH_START = "PREFETCH_START",// Before prefetching begins
|
|
250
|
+
PREFETCH_COMPLETE = "PREFETCH_COMPLETE"
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Base system event interface
|
|
254
|
+
*/
|
|
255
|
+
interface SystemEvent {
|
|
256
|
+
type: SystemEventType;
|
|
257
|
+
timestamp: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Planning events
|
|
261
|
+
*/
|
|
262
|
+
interface PlanStartEvent extends SystemEvent {
|
|
263
|
+
type: SystemEventType.PLAN_START;
|
|
264
|
+
plannerInput: PlannerInput;
|
|
265
|
+
}
|
|
266
|
+
interface PlanPromptCreatedEvent extends SystemEvent {
|
|
267
|
+
type: SystemEventType.PLAN_PROMPT_CREATED;
|
|
268
|
+
prompt: string;
|
|
269
|
+
}
|
|
270
|
+
interface PlanResponseChunkEvent extends SystemEvent {
|
|
271
|
+
type: SystemEventType.PLAN_RESPONSE_CHUNK;
|
|
272
|
+
chunk: string;
|
|
273
|
+
isComplete: boolean;
|
|
274
|
+
}
|
|
275
|
+
interface PlanCompleteEvent extends SystemEvent {
|
|
276
|
+
type: SystemEventType.PLAN_COMPLETE;
|
|
277
|
+
layout: UISpecNode;
|
|
278
|
+
executionTimeMs: number;
|
|
279
|
+
}
|
|
280
|
+
interface PlanErrorEvent extends SystemEvent {
|
|
281
|
+
type: SystemEventType.PLAN_ERROR;
|
|
282
|
+
error: Error;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Binding events
|
|
286
|
+
*/
|
|
287
|
+
interface BindingResolutionStartEvent extends SystemEvent {
|
|
288
|
+
type: SystemEventType.BINDING_RESOLUTION_START;
|
|
289
|
+
layout: UISpecNode;
|
|
290
|
+
}
|
|
291
|
+
interface BindingResolutionCompleteEvent extends SystemEvent {
|
|
292
|
+
type: SystemEventType.BINDING_RESOLUTION_COMPLETE;
|
|
293
|
+
originalLayout: UISpecNode;
|
|
294
|
+
resolvedLayout: UISpecNode;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Data events
|
|
298
|
+
*/
|
|
299
|
+
interface DataFetchStartEvent extends SystemEvent {
|
|
300
|
+
type: SystemEventType.DATA_FETCH_START;
|
|
301
|
+
tableName: string;
|
|
302
|
+
query: unknown;
|
|
303
|
+
}
|
|
304
|
+
interface DataFetchCompleteEvent extends SystemEvent {
|
|
305
|
+
type: SystemEventType.DATA_FETCH_COMPLETE;
|
|
306
|
+
tableName: string;
|
|
307
|
+
results: unknown[];
|
|
308
|
+
executionTimeMs: number;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Rendering events
|
|
312
|
+
*/
|
|
313
|
+
interface RenderStartEvent extends SystemEvent {
|
|
314
|
+
type: SystemEventType.RENDER_START;
|
|
315
|
+
layout: UISpecNode;
|
|
316
|
+
}
|
|
317
|
+
interface RenderCompleteEvent extends SystemEvent {
|
|
318
|
+
type: SystemEventType.RENDER_COMPLETE;
|
|
319
|
+
layout: UISpecNode;
|
|
320
|
+
renderTimeMs: number;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Prefetch events
|
|
324
|
+
*/
|
|
325
|
+
interface PrefetchStartEvent extends SystemEvent {
|
|
326
|
+
type: SystemEventType.PREFETCH_START;
|
|
327
|
+
depth: number;
|
|
328
|
+
}
|
|
329
|
+
interface PrefetchCompleteEvent extends SystemEvent {
|
|
330
|
+
type: SystemEventType.PREFETCH_COMPLETE;
|
|
331
|
+
prefetchedLayouts: Record<string, UISpecNode>;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Union type of all system events
|
|
335
|
+
*/
|
|
336
|
+
type AnySystemEvent = PlanStartEvent | PlanPromptCreatedEvent | PlanResponseChunkEvent | PlanCompleteEvent | PlanErrorEvent | BindingResolutionStartEvent | BindingResolutionCompleteEvent | DataFetchStartEvent | DataFetchCompleteEvent | RenderStartEvent | RenderCompleteEvent | PrefetchStartEvent | PrefetchCompleteEvent;
|
|
337
|
+
/**
|
|
338
|
+
* System event hook type
|
|
339
|
+
*/
|
|
340
|
+
type SystemEventHook<T extends SystemEvent = AnySystemEvent> = (event: T) => void | Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* System event manager
|
|
343
|
+
*/
|
|
344
|
+
declare class SystemEventManager {
|
|
345
|
+
private listeners;
|
|
346
|
+
/**
|
|
347
|
+
* Register a listener for a specific system event type
|
|
348
|
+
*
|
|
349
|
+
* @param eventType - The system event type to listen for
|
|
350
|
+
* @param listener - The listener function
|
|
351
|
+
* @returns Function to unregister the listener
|
|
352
|
+
*/
|
|
353
|
+
on<T extends SystemEventType>(eventType: T, listener: SystemEventHook<Extract<AnySystemEvent, {
|
|
354
|
+
type: T;
|
|
355
|
+
}>>): () => void;
|
|
356
|
+
/**
|
|
357
|
+
* Emit a system event to all registered listeners
|
|
358
|
+
*
|
|
359
|
+
* @param event - The system event to emit
|
|
360
|
+
*/
|
|
361
|
+
emit<T extends AnySystemEvent>(event: T): Promise<void>;
|
|
362
|
+
}
|
|
363
|
+
declare const systemEvents: SystemEventManager;
|
|
364
|
+
/**
|
|
365
|
+
* Helper to create a typed system event
|
|
366
|
+
*
|
|
367
|
+
* @param type - The system event type
|
|
368
|
+
* @param data - Additional event data
|
|
369
|
+
* @returns A system event object
|
|
370
|
+
*/
|
|
371
|
+
declare function createSystemEvent<T extends SystemEventType>(type: T, data: Omit<Extract<AnySystemEvent, {
|
|
372
|
+
type: T;
|
|
373
|
+
}>, 'type' | 'timestamp'>): Extract<AnySystemEvent, {
|
|
374
|
+
type: T;
|
|
375
|
+
}>;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Drizzle schema adapter types
|
|
379
|
+
*/
|
|
380
|
+
interface DrizzleColumn {
|
|
381
|
+
name: string;
|
|
382
|
+
dataType: string;
|
|
383
|
+
notNull?: boolean;
|
|
384
|
+
defaultValue?: unknown;
|
|
385
|
+
primaryKey?: boolean;
|
|
386
|
+
unique?: boolean;
|
|
387
|
+
references?: {
|
|
388
|
+
table: string;
|
|
389
|
+
column: string;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
interface DrizzleTable {
|
|
393
|
+
name: string;
|
|
394
|
+
schema: string;
|
|
395
|
+
columns: Record<string, DrizzleColumn>;
|
|
396
|
+
}
|
|
397
|
+
interface DrizzleSchema {
|
|
398
|
+
[tableName: string]: DrizzleTable;
|
|
399
|
+
}
|
|
400
|
+
interface DrizzleClientConfig {
|
|
401
|
+
connectionString?: string | undefined;
|
|
402
|
+
client?: unknown | undefined;
|
|
403
|
+
queryFn?: ((tableName: string, query: any) => Promise<unknown[]>) | undefined;
|
|
404
|
+
}
|
|
405
|
+
interface DrizzleAdapterOptions$1 {
|
|
406
|
+
schema: DrizzleSchema;
|
|
407
|
+
client?: DrizzleClientConfig | undefined;
|
|
408
|
+
useMockData?: boolean | undefined;
|
|
409
|
+
mockData?: Record<string, unknown[]> | undefined;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Adapter for Drizzle ORM schemas
|
|
413
|
+
* Handles converting Drizzle schema to AutoUI schema format
|
|
414
|
+
* and optionally connects to a database
|
|
415
|
+
*/
|
|
416
|
+
declare class DrizzleAdapter {
|
|
417
|
+
private schema;
|
|
418
|
+
private client;
|
|
419
|
+
private useMockData;
|
|
420
|
+
private mockData;
|
|
421
|
+
constructor(options: DrizzleAdapterOptions$1);
|
|
422
|
+
/**
|
|
423
|
+
* Convert Drizzle schema to AutoUI schema format
|
|
424
|
+
*/
|
|
425
|
+
getSchema(): Record<string, unknown>;
|
|
426
|
+
/**
|
|
427
|
+
* Convert Drizzle columns to AutoUI column format
|
|
428
|
+
*/
|
|
429
|
+
private convertColumns;
|
|
430
|
+
/**
|
|
431
|
+
* Map Drizzle data types to standard types
|
|
432
|
+
*/
|
|
433
|
+
private mapDataType;
|
|
434
|
+
/**
|
|
435
|
+
* Execute a query against the database
|
|
436
|
+
*/
|
|
437
|
+
query(tableName: string, query: any): Promise<unknown[]>;
|
|
438
|
+
/**
|
|
439
|
+
* Initialize the data context with schema information and optional mock data
|
|
440
|
+
*/
|
|
441
|
+
initializeDataContext(): Promise<DataContext>;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Generic schema adapter interface
|
|
446
|
+
*/
|
|
447
|
+
interface SchemaAdapter {
|
|
448
|
+
getSchema(): Record<string, unknown>;
|
|
449
|
+
query(tableName: string, query: any): Promise<unknown[]>;
|
|
450
|
+
initializeDataContext(): Promise<DataContext>;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Schema adapter options union type
|
|
454
|
+
*/
|
|
455
|
+
type SchemaAdapterOptions = {
|
|
456
|
+
type: 'drizzle';
|
|
457
|
+
options: DrizzleAdapterOptions$1;
|
|
458
|
+
} | {
|
|
459
|
+
type: 'custom';
|
|
460
|
+
adapter: SchemaAdapter;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Factory function to create the appropriate schema adapter
|
|
464
|
+
*/
|
|
465
|
+
declare function createSchemaAdapter(options: SchemaAdapterOptions): SchemaAdapter;
|
|
466
|
+
|
|
467
|
+
interface DrizzleAdapterOptions {
|
|
468
|
+
schema: Record<string, unknown>;
|
|
469
|
+
}
|
|
470
|
+
interface AutoUIProps {
|
|
471
|
+
schema: Record<string, unknown> | {
|
|
472
|
+
type: 'drizzle';
|
|
473
|
+
options: DrizzleAdapterOptions;
|
|
474
|
+
} | {
|
|
475
|
+
type: 'custom';
|
|
476
|
+
adapter: SchemaAdapter;
|
|
477
|
+
};
|
|
478
|
+
goal: string;
|
|
479
|
+
componentAdapter?: 'shadcn';
|
|
480
|
+
userContext?: Record<string, unknown>;
|
|
481
|
+
onEvent?: (evt: UIEvent) => void;
|
|
482
|
+
eventHooks?: {
|
|
483
|
+
all?: EventHook[];
|
|
484
|
+
[key: string]: EventHook[] | undefined;
|
|
485
|
+
};
|
|
486
|
+
systemEventHooks?: {
|
|
487
|
+
[key: string]: SystemEventHook[] | undefined;
|
|
488
|
+
};
|
|
489
|
+
enablePartialUpdates?: boolean;
|
|
490
|
+
updatePatterns?: {
|
|
491
|
+
enableDropdowns?: boolean;
|
|
492
|
+
enableDetailViews?: boolean;
|
|
493
|
+
enableExpandCollapse?: boolean;
|
|
494
|
+
enableFormNavigation?: boolean;
|
|
495
|
+
};
|
|
496
|
+
integration?: {
|
|
497
|
+
mode?: 'standalone' | 'component';
|
|
498
|
+
className?: string;
|
|
499
|
+
style?: React.CSSProperties;
|
|
500
|
+
id?: string;
|
|
501
|
+
};
|
|
502
|
+
scope?: {
|
|
503
|
+
type?: 'form' | 'list' | 'detail' | 'dashboard' | 'full-page' | 'card';
|
|
504
|
+
focus?: string;
|
|
505
|
+
};
|
|
506
|
+
debugMode?: boolean;
|
|
507
|
+
mockMode?: boolean;
|
|
508
|
+
databaseConfig?: Record<string, unknown>;
|
|
509
|
+
planningConfig?: {
|
|
510
|
+
prefetchDepth?: number;
|
|
511
|
+
temperature?: number;
|
|
512
|
+
streaming?: boolean;
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* AutoUI - Main component for generating goal-oriented UIs
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```tsx
|
|
520
|
+
* import { AutoUI } from 'autoui-react';
|
|
521
|
+
* import { emailsTable, usersTable } from './schema';
|
|
522
|
+
*
|
|
523
|
+
* function MyApp() {
|
|
524
|
+
* return (
|
|
525
|
+
* <AutoUI
|
|
526
|
+
* schema={{ emails: emailsTable, users: usersTable }}
|
|
527
|
+
* goal="Create an inbox view with email list and detail view"
|
|
528
|
+
* />
|
|
529
|
+
* );
|
|
530
|
+
* }
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
declare const AutoUI: React.FC<AutoUIProps>;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Example function to generate text using the AI SDK
|
|
537
|
+
*
|
|
538
|
+
* Note: You need to set OPENAI_API_KEY environment variable
|
|
539
|
+
* or use another supported provider
|
|
540
|
+
*/
|
|
541
|
+
declare function generateComponent(schema: any): Promise<string>;
|
|
542
|
+
|
|
543
|
+
declare function generateUIDescription(schema: any): Promise<string>;
|
|
544
|
+
declare function generateUIComponent(schema: any): Promise<string>;
|
|
545
|
+
|
|
546
|
+
export { ActionRouteConfig, ActionRouter, ActionType, AnySystemEvent, AutoUI, AutoUIProps, DrizzleAdapter, DrizzleAdapterOptions$1 as DrizzleAdapterOptions, EventHook, EventHookContext, EventHookOptions, PlannerInput, SchemaAdapter, SchemaAdapterOptions, SystemEventHook, SystemEventType, UIEvent, UIEventType, UISpecNode, UIState, createDefaultRouter, createEventHook, createSchemaAdapter, createSystemEvent, generateComponent, generateUIComponent, generateUIDescription, systemEvents, uiEvent, uiEventType, uiSpecNode };
|