autoui-react 0.0.4-alpha → 0.1.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/README.md +6 -52
- package/dist/index.css +0 -10
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +70 -103
- package/dist/index.d.ts +70 -103
- package/dist/index.js +418 -1155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +412 -1141
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -44
package/dist/index.d.ts
CHANGED
|
@@ -12,77 +12,80 @@ type UIEventType = z.infer<typeof uiEventType>;
|
|
|
12
12
|
declare const uiEvent: z.ZodObject<{
|
|
13
13
|
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
14
14
|
nodeId: z.ZodString;
|
|
15
|
-
timestamp: z.
|
|
16
|
-
payload: z.
|
|
15
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
18
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
19
19
|
nodeId: string;
|
|
20
|
-
timestamp
|
|
21
|
-
payload
|
|
20
|
+
timestamp?: number | undefined;
|
|
21
|
+
payload?: Record<string, any> | undefined;
|
|
22
22
|
}, {
|
|
23
23
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
24
24
|
nodeId: string;
|
|
25
|
-
timestamp
|
|
26
|
-
payload
|
|
25
|
+
timestamp?: number | undefined;
|
|
26
|
+
payload?: Record<string, any> | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
type UIEvent = z.infer<typeof uiEvent>;
|
|
29
|
-
|
|
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 = {
|
|
30
35
|
id: string;
|
|
31
|
-
|
|
32
|
-
props
|
|
33
|
-
bindings
|
|
34
|
-
events
|
|
36
|
+
type: string;
|
|
37
|
+
props?: Record<string, any> | undefined;
|
|
38
|
+
bindings?: Record<string, any> | undefined;
|
|
39
|
+
events?: Record<string, {
|
|
35
40
|
action: string;
|
|
36
|
-
target
|
|
37
|
-
payload
|
|
38
|
-
}> |
|
|
39
|
-
children
|
|
40
|
-
}
|
|
41
|
-
declare const uiSpecNode: z.ZodType<UISpecNodeInterface>;
|
|
42
|
-
type UISpecNode = z.infer<typeof uiSpecNode>;
|
|
41
|
+
target?: string | undefined;
|
|
42
|
+
payload?: Record<string, any> | undefined;
|
|
43
|
+
}> | undefined;
|
|
44
|
+
children?: UISpecNode[] | undefined;
|
|
45
|
+
};
|
|
43
46
|
/**
|
|
44
47
|
* Application state for the UI engine
|
|
45
48
|
*/
|
|
46
49
|
declare const uiState: z.ZodObject<{
|
|
47
|
-
layout: z.
|
|
50
|
+
layout: z.ZodOptional<z.ZodType<UISpecNode, z.ZodTypeDef, UISpecNode>>;
|
|
48
51
|
loading: z.ZodBoolean;
|
|
49
52
|
history: z.ZodArray<z.ZodObject<{
|
|
50
53
|
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
51
54
|
nodeId: z.ZodString;
|
|
52
|
-
timestamp: z.
|
|
53
|
-
payload: z.
|
|
55
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
54
57
|
}, "strip", z.ZodTypeAny, {
|
|
55
58
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
56
59
|
nodeId: string;
|
|
57
|
-
timestamp
|
|
58
|
-
payload
|
|
60
|
+
timestamp?: number | undefined;
|
|
61
|
+
payload?: Record<string, any> | undefined;
|
|
59
62
|
}, {
|
|
60
63
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
61
64
|
nodeId: string;
|
|
62
|
-
timestamp
|
|
63
|
-
payload
|
|
65
|
+
timestamp?: number | undefined;
|
|
66
|
+
payload?: Record<string, any> | undefined;
|
|
64
67
|
}>, "many">;
|
|
65
|
-
error: z.
|
|
68
|
+
error: z.ZodOptional<z.ZodString>;
|
|
66
69
|
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
layout: UISpecNodeInterface | null;
|
|
68
70
|
loading: boolean;
|
|
69
71
|
history: {
|
|
70
72
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
71
73
|
nodeId: string;
|
|
72
|
-
timestamp
|
|
73
|
-
payload
|
|
74
|
+
timestamp?: number | undefined;
|
|
75
|
+
payload?: Record<string, any> | undefined;
|
|
74
76
|
}[];
|
|
75
|
-
|
|
77
|
+
layout?: UISpecNode | undefined;
|
|
78
|
+
error?: string | undefined;
|
|
76
79
|
}, {
|
|
77
|
-
layout: UISpecNodeInterface | null;
|
|
78
80
|
loading: boolean;
|
|
79
81
|
history: {
|
|
80
82
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
81
83
|
nodeId: string;
|
|
82
|
-
timestamp
|
|
83
|
-
payload
|
|
84
|
+
timestamp?: number | undefined;
|
|
85
|
+
payload?: Record<string, any> | undefined;
|
|
84
86
|
}[];
|
|
85
|
-
|
|
87
|
+
layout?: UISpecNode | undefined;
|
|
88
|
+
error?: string | undefined;
|
|
86
89
|
}>;
|
|
87
90
|
type UIState = z.infer<typeof uiState>;
|
|
88
91
|
/**
|
|
@@ -91,43 +94,43 @@ type UIState = z.infer<typeof uiState>;
|
|
|
91
94
|
declare const plannerInput: z.ZodObject<{
|
|
92
95
|
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
93
96
|
goal: z.ZodString;
|
|
94
|
-
history: z.
|
|
97
|
+
history: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
95
98
|
type: z.ZodEnum<["CLICK", "CHANGE", "SUBMIT", "MOUSEOVER", "MOUSEOUT", "FOCUS", "BLUR"]>;
|
|
96
99
|
nodeId: z.ZodString;
|
|
97
|
-
timestamp: z.
|
|
98
|
-
payload: z.
|
|
100
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
99
102
|
}, "strip", z.ZodTypeAny, {
|
|
100
103
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
101
104
|
nodeId: string;
|
|
102
|
-
timestamp
|
|
103
|
-
payload
|
|
105
|
+
timestamp?: number | undefined;
|
|
106
|
+
payload?: Record<string, any> | undefined;
|
|
104
107
|
}, {
|
|
105
108
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
106
109
|
nodeId: string;
|
|
107
|
-
timestamp
|
|
108
|
-
payload
|
|
110
|
+
timestamp?: number | undefined;
|
|
111
|
+
payload?: Record<string, any> | undefined;
|
|
109
112
|
}>, "many">>;
|
|
110
|
-
userContext: z.ZodOptional<z.
|
|
113
|
+
userContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
111
114
|
}, "strip", z.ZodTypeAny, {
|
|
112
|
-
history: {
|
|
113
|
-
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
114
|
-
nodeId: string;
|
|
115
|
-
timestamp: number | null;
|
|
116
|
-
payload: Record<string, unknown> | null;
|
|
117
|
-
}[] | null;
|
|
118
115
|
schema: Record<string, unknown>;
|
|
119
116
|
goal: string;
|
|
120
|
-
|
|
121
|
-
}, {
|
|
122
|
-
history: {
|
|
117
|
+
history?: {
|
|
123
118
|
type: "CLICK" | "CHANGE" | "SUBMIT" | "MOUSEOVER" | "MOUSEOUT" | "FOCUS" | "BLUR";
|
|
124
119
|
nodeId: string;
|
|
125
|
-
timestamp
|
|
126
|
-
payload
|
|
127
|
-
}[] |
|
|
120
|
+
timestamp?: number | undefined;
|
|
121
|
+
payload?: Record<string, any> | undefined;
|
|
122
|
+
}[] | undefined;
|
|
123
|
+
userContext?: Record<string, unknown> | undefined;
|
|
124
|
+
}, {
|
|
128
125
|
schema: Record<string, unknown>;
|
|
129
126
|
goal: string;
|
|
130
|
-
|
|
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;
|
|
131
134
|
}>;
|
|
132
135
|
type PlannerInput = z.infer<typeof plannerInput>;
|
|
133
136
|
|
|
@@ -187,7 +190,7 @@ declare class ActionRouter {
|
|
|
187
190
|
* @param dataContext - Current data context
|
|
188
191
|
* @returns Route resolution or null if no match
|
|
189
192
|
*/
|
|
190
|
-
resolveRoute(event: UIEvent, schema: Record<string, unknown>, layout: UISpecNode |
|
|
193
|
+
resolveRoute(event: UIEvent, schema: Record<string, unknown>, layout: UISpecNode | undefined, dataContext: DataContext, goal: string, userContext?: Record<string, unknown>): RouteResolution | null;
|
|
191
194
|
/**
|
|
192
195
|
* Process a prompt template with variables
|
|
193
196
|
* @param template - Template string with ${var} placeholders
|
|
@@ -226,7 +229,7 @@ type EventHook = (context: EventHookContext) => void | Promise<void>;
|
|
|
226
229
|
* });
|
|
227
230
|
* ```
|
|
228
231
|
*/
|
|
229
|
-
declare function createEventHook(eventTypes: UIEventType[] |
|
|
232
|
+
declare function createEventHook(eventTypes: UIEventType[] | 'all', hook: EventHook, options?: EventHookOptions): EventHook;
|
|
230
233
|
|
|
231
234
|
/**
|
|
232
235
|
* System event types that represent the internal AutoUI lifecycle
|
|
@@ -367,7 +370,7 @@ declare const systemEvents: SystemEventManager;
|
|
|
367
370
|
*/
|
|
368
371
|
declare function createSystemEvent<T extends SystemEventType>(type: T, data: Omit<Extract<AnySystemEvent, {
|
|
369
372
|
type: T;
|
|
370
|
-
}>,
|
|
373
|
+
}>, 'type' | 'timestamp'>): Extract<AnySystemEvent, {
|
|
371
374
|
type: T;
|
|
372
375
|
}>;
|
|
373
376
|
|
|
@@ -450,10 +453,10 @@ interface SchemaAdapter {
|
|
|
450
453
|
* Schema adapter options union type
|
|
451
454
|
*/
|
|
452
455
|
type SchemaAdapterOptions = {
|
|
453
|
-
type:
|
|
456
|
+
type: 'drizzle';
|
|
454
457
|
options: DrizzleAdapterOptions$1;
|
|
455
458
|
} | {
|
|
456
|
-
type:
|
|
459
|
+
type: 'custom';
|
|
457
460
|
adapter: SchemaAdapter;
|
|
458
461
|
};
|
|
459
462
|
/**
|
|
@@ -466,14 +469,14 @@ interface DrizzleAdapterOptions {
|
|
|
466
469
|
}
|
|
467
470
|
interface AutoUIProps {
|
|
468
471
|
schema: Record<string, unknown> | {
|
|
469
|
-
type:
|
|
472
|
+
type: 'drizzle';
|
|
470
473
|
options: DrizzleAdapterOptions;
|
|
471
474
|
} | {
|
|
472
|
-
type:
|
|
475
|
+
type: 'custom';
|
|
473
476
|
adapter: SchemaAdapter;
|
|
474
477
|
};
|
|
475
478
|
goal: string;
|
|
476
|
-
componentAdapter?:
|
|
479
|
+
componentAdapter?: 'shadcn';
|
|
477
480
|
userContext?: Record<string, unknown>;
|
|
478
481
|
onEvent?: (evt: UIEvent) => void;
|
|
479
482
|
eventHooks?: {
|
|
@@ -491,13 +494,13 @@ interface AutoUIProps {
|
|
|
491
494
|
enableFormNavigation?: boolean;
|
|
492
495
|
};
|
|
493
496
|
integration?: {
|
|
494
|
-
mode?:
|
|
497
|
+
mode?: 'standalone' | 'component';
|
|
495
498
|
className?: string;
|
|
496
499
|
style?: React.CSSProperties;
|
|
497
500
|
id?: string;
|
|
498
501
|
};
|
|
499
502
|
scope?: {
|
|
500
|
-
type?:
|
|
503
|
+
type?: 'form' | 'list' | 'detail' | 'dashboard' | 'full-page' | 'card';
|
|
501
504
|
focus?: string;
|
|
502
505
|
};
|
|
503
506
|
debugMode?: boolean;
|
|
@@ -514,7 +517,7 @@ interface AutoUIProps {
|
|
|
514
517
|
*
|
|
515
518
|
* @example
|
|
516
519
|
* ```tsx
|
|
517
|
-
* import { AutoUI } from 'autoui
|
|
520
|
+
* import { AutoUI } from '@autoui/react';
|
|
518
521
|
* import { emailsTable, usersTable } from './schema';
|
|
519
522
|
*
|
|
520
523
|
* function MyApp() {
|
|
@@ -529,40 +532,4 @@ interface AutoUIProps {
|
|
|
529
532
|
*/
|
|
530
533
|
declare const AutoUI: React.FC<AutoUIProps>;
|
|
531
534
|
|
|
532
|
-
|
|
533
|
-
* AI Utilities for AutoUI React
|
|
534
|
-
* Provides AI-powered UI generation functionality
|
|
535
|
-
*/
|
|
536
|
-
/**
|
|
537
|
-
* Generates a component using AI
|
|
538
|
-
*/
|
|
539
|
-
declare const generateComponent: (prompt: string) => Promise<string>;
|
|
540
|
-
/**
|
|
541
|
-
* Generates a UI description using AI
|
|
542
|
-
*/
|
|
543
|
-
declare const generateUIDescription: (prompt: string) => Promise<string>;
|
|
544
|
-
/**
|
|
545
|
-
* Generates a UI component using AI
|
|
546
|
-
*/
|
|
547
|
-
declare const generateUIComponent: (prompt: string) => Promise<string>;
|
|
548
|
-
|
|
549
|
-
interface UsePlannerOptions {
|
|
550
|
-
goal: string;
|
|
551
|
-
schema: Record<string, unknown>;
|
|
552
|
-
userContext?: Record<string, unknown>;
|
|
553
|
-
router?: ActionRouter;
|
|
554
|
-
modelProvider?: unknown;
|
|
555
|
-
}
|
|
556
|
-
interface UsePlannerResult {
|
|
557
|
-
layout: UISpecNode | undefined;
|
|
558
|
-
loading: boolean;
|
|
559
|
-
error: Error | null;
|
|
560
|
-
handleEvent: (event: UIEvent) => Promise<void>;
|
|
561
|
-
generateInitialLayout: () => Promise<void>;
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* React hook for utilizing the AI planner functionality
|
|
565
|
-
*/
|
|
566
|
-
declare function usePlanner(options: UsePlannerOptions): UsePlannerResult;
|
|
567
|
-
|
|
568
|
-
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, usePlanner };
|
|
535
|
+
export { type ActionRouteConfig, ActionRouter, ActionType, type AnySystemEvent, AutoUI, type AutoUIProps, DrizzleAdapter, type DrizzleAdapterOptions$1 as DrizzleAdapterOptions, type EventHook, type EventHookContext, type EventHookOptions, type PlannerInput, type SchemaAdapter, type SchemaAdapterOptions, type SystemEventHook, SystemEventType, type UIEvent, type UIEventType, type UISpecNode, type UIState, createDefaultRouter, createEventHook, createSchemaAdapter, createSystemEvent, systemEvents, uiEvent, uiEventType, uiSpecNode };
|