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