@object-ui/types 0.3.1 → 0.5.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.
Files changed (97) hide show
  1. package/dist/app.d.ts +10 -0
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/blocks.d.ts +332 -0
  4. package/dist/blocks.d.ts.map +1 -0
  5. package/dist/blocks.js +8 -0
  6. package/dist/crud.d.ts +174 -3
  7. package/dist/crud.d.ts.map +1 -1
  8. package/dist/data-protocol.d.ts +1268 -0
  9. package/dist/data-protocol.d.ts.map +1 -0
  10. package/dist/data-protocol.js +8 -0
  11. package/dist/data.d.ts +6 -1
  12. package/dist/data.d.ts.map +1 -1
  13. package/dist/field-types.d.ts +353 -11
  14. package/dist/field-types.d.ts.map +1 -1
  15. package/dist/index.d.ts +28 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/objectql.d.ts +8 -1
  18. package/dist/objectql.d.ts.map +1 -1
  19. package/dist/plugin-scope.d.ts +194 -0
  20. package/dist/plugin-scope.d.ts.map +1 -0
  21. package/dist/plugin-scope.js +8 -0
  22. package/dist/reports.d.ts +336 -0
  23. package/dist/reports.d.ts.map +1 -0
  24. package/dist/reports.js +8 -0
  25. package/dist/theme.d.ts +289 -0
  26. package/dist/theme.d.ts.map +1 -0
  27. package/dist/theme.js +8 -0
  28. package/dist/ui-action.d.ts +175 -0
  29. package/dist/ui-action.d.ts.map +1 -0
  30. package/dist/ui-action.js +8 -0
  31. package/dist/views.d.ts +417 -0
  32. package/dist/views.d.ts.map +1 -0
  33. package/dist/views.js +8 -0
  34. package/dist/zod/app.zod.d.ts +120 -0
  35. package/dist/zod/app.zod.d.ts.map +1 -0
  36. package/dist/zod/app.zod.js +60 -0
  37. package/dist/zod/blocks.zod.d.ts +834 -0
  38. package/dist/zod/blocks.zod.d.ts.map +1 -0
  39. package/dist/zod/blocks.zod.js +145 -0
  40. package/dist/zod/complex.zod.js +1 -1
  41. package/dist/zod/crud.zod.d.ts +598 -0
  42. package/dist/zod/crud.zod.d.ts.map +1 -0
  43. package/dist/zod/crud.zod.js +230 -0
  44. package/dist/zod/data-display.zod.js +1 -1
  45. package/dist/zod/disclosure.zod.js +1 -1
  46. package/dist/zod/feedback.zod.js +1 -1
  47. package/dist/zod/form.zod.js +1 -1
  48. package/dist/zod/index.zod.d.ts +1829 -18
  49. package/dist/zod/index.zod.d.ts.map +1 -1
  50. package/dist/zod/index.zod.js +96 -19
  51. package/dist/zod/layout.zod.d.ts +2 -2
  52. package/dist/zod/layout.zod.js +1 -1
  53. package/dist/zod/navigation.zod.js +1 -1
  54. package/dist/zod/objectql.zod.d.ts +10 -10
  55. package/dist/zod/objectql.zod.js +1 -1
  56. package/dist/zod/overlay.zod.js +1 -1
  57. package/dist/zod/reports.zod.d.ts +1628 -0
  58. package/dist/zod/reports.zod.d.ts.map +1 -0
  59. package/dist/zod/reports.zod.js +152 -0
  60. package/dist/zod/theme.zod.d.ts +611 -0
  61. package/dist/zod/theme.zod.d.ts.map +1 -0
  62. package/dist/zod/theme.zod.js +130 -0
  63. package/dist/zod/views.zod.d.ts +675 -0
  64. package/dist/zod/views.zod.d.ts.map +1 -0
  65. package/dist/zod/views.zod.js +159 -0
  66. package/package.json +2 -2
  67. package/src/__tests__/namespace-exports.test.ts +80 -0
  68. package/src/__tests__/phase2-schemas.test.ts +639 -0
  69. package/src/app.ts +12 -0
  70. package/src/blocks.ts +405 -0
  71. package/src/crud.ts +177 -3
  72. package/src/data-protocol.ts +1679 -0
  73. package/src/data.ts +3 -1
  74. package/src/field-types.ts +392 -11
  75. package/src/index.ts +214 -0
  76. package/src/objectql.ts +9 -1
  77. package/src/plugin-scope.ts +210 -0
  78. package/src/reports.ts +408 -0
  79. package/src/theme.ts +351 -0
  80. package/src/ui-action.ts +276 -0
  81. package/src/views.ts +429 -0
  82. package/src/zod/app.zod.ts +72 -0
  83. package/src/zod/blocks.zod.ts +170 -0
  84. package/src/zod/complex.zod.ts +1 -1
  85. package/src/zod/crud.zod.ts +259 -0
  86. package/src/zod/data-display.zod.ts +1 -1
  87. package/src/zod/disclosure.zod.ts +1 -1
  88. package/src/zod/feedback.zod.ts +1 -1
  89. package/src/zod/form.zod.ts +1 -1
  90. package/src/zod/index.zod.ts +167 -19
  91. package/src/zod/layout.zod.ts +1 -1
  92. package/src/zod/navigation.zod.ts +1 -1
  93. package/src/zod/objectql.zod.ts +1 -1
  94. package/src/zod/overlay.zod.ts +1 -1
  95. package/src/zod/reports.zod.ts +183 -0
  96. package/src/zod/theme.zod.ts +155 -0
  97. package/src/zod/views.zod.ts +182 -0
@@ -0,0 +1,183 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * @object-ui/types/zod - Report Schema Zod Validators
11
+ *
12
+ * Zod validation schemas for report configuration.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/reports
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
21
+ import { ChartSchema } from './data-display.zod.js';
22
+
23
+ /**
24
+ * Report Export Format Schema
25
+ */
26
+ export const ReportExportFormatSchema = z.enum(['pdf', 'excel', 'csv', 'json', 'html']).describe('Report export format');
27
+
28
+ /**
29
+ * Report Schedule Frequency Schema
30
+ */
31
+ export const ReportScheduleFrequencySchema = z.enum(['once', 'daily', 'weekly', 'monthly', 'quarterly', 'yearly']).describe('Report schedule frequency');
32
+
33
+ /**
34
+ * Report Aggregation Type Schema
35
+ */
36
+ export const ReportAggregationTypeSchema = z.enum(['sum', 'avg', 'min', 'max', 'count', 'distinct']).describe('Report aggregation type');
37
+
38
+ /**
39
+ * Report Field Schema
40
+ */
41
+ export const ReportFieldSchema = z.object({
42
+ name: z.string().describe('Field name/identifier'),
43
+ label: z.string().optional().describe('Display label'),
44
+ type: z.enum(['string', 'number', 'date', 'boolean']).optional().describe('Field type'),
45
+ aggregation: ReportAggregationTypeSchema.optional().describe('Aggregation function'),
46
+ format: z.string().optional().describe('Format string'),
47
+ showInSummary: z.boolean().optional().describe('Show in summary'),
48
+ sortOrder: z.number().optional().describe('Sort order'),
49
+ });
50
+
51
+ /**
52
+ * Report Filter Schema
53
+ */
54
+ export const ReportFilterSchema = z.object({
55
+ field: z.string().describe('Field to filter on'),
56
+ operator: z.enum(['equals', 'not_equals', 'contains', 'greater_than', 'less_than', 'between', 'in', 'not_in']).describe('Filter operator'),
57
+ value: z.any().optional().describe('Filter value'),
58
+ values: z.array(z.any()).optional().describe('Multiple values (for "in" operator)'),
59
+ });
60
+
61
+ /**
62
+ * Report Group By Schema
63
+ */
64
+ export const ReportGroupBySchema = z.object({
65
+ field: z.string().describe('Field to group by'),
66
+ label: z.string().optional().describe('Display label'),
67
+ sort: z.enum(['asc', 'desc']).optional().describe('Sort direction'),
68
+ });
69
+
70
+ /**
71
+ * Report Section Schema
72
+ */
73
+ export const ReportSectionSchema = z.object({
74
+ type: z.enum(['header', 'summary', 'chart', 'table', 'text', 'page-break']).describe('Section type'),
75
+ title: z.string().optional().describe('Section title'),
76
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Section content'),
77
+ chart: ChartSchema.optional().describe('Chart configuration (for type="chart")'),
78
+ columns: z.array(ReportFieldSchema).optional().describe('Columns to display (for type="table")'),
79
+ text: z.string().optional().describe('Text content (for type="text")'),
80
+ visible: z.union([z.boolean(), z.string()]).optional().describe('Visibility condition'),
81
+ });
82
+
83
+ /**
84
+ * Report Schedule Schema
85
+ */
86
+ export const ReportScheduleSchema = z.object({
87
+ enabled: z.boolean().optional().describe('Schedule enabled'),
88
+ frequency: ReportScheduleFrequencySchema.optional().describe('Frequency'),
89
+ dayOfWeek: z.number().optional().describe('Specific day of week (for weekly)'),
90
+ dayOfMonth: z.number().optional().describe('Specific day of month (for monthly)'),
91
+ time: z.string().optional().describe('Time to run (HH:mm format)'),
92
+ timezone: z.string().optional().describe('Timezone'),
93
+ recipients: z.array(z.string()).optional().describe('Email recipients'),
94
+ subject: z.string().optional().describe('Email subject'),
95
+ body: z.string().optional().describe('Email body'),
96
+ formats: z.array(ReportExportFormatSchema).optional().describe('Export formats to attach'),
97
+ });
98
+
99
+ /**
100
+ * Report Export Config Schema
101
+ */
102
+ export const ReportExportConfigSchema = z.object({
103
+ format: ReportExportFormatSchema.describe('Export format'),
104
+ filename: z.string().optional().describe('Filename template'),
105
+ includeHeaders: z.boolean().optional().describe('Include headers'),
106
+ orientation: z.enum(['portrait', 'landscape']).optional().describe('Page orientation (for PDF)'),
107
+ pageSize: z.enum(['A4', 'A3', 'Letter', 'Legal']).optional().describe('Page size (for PDF)'),
108
+ options: z.record(z.string(), z.any()).optional().describe('Custom options'),
109
+ });
110
+
111
+ /**
112
+ * Report Schema
113
+ */
114
+ export const ReportSchema = BaseSchema.extend({
115
+ type: z.literal('report'),
116
+ title: z.string().optional().describe('Report title'),
117
+ description: z.string().optional().describe('Report description'),
118
+ dataSource: z.any().optional().describe('Data source configuration'),
119
+ fields: z.array(ReportFieldSchema).optional().describe('Report fields'),
120
+ filters: z.array(ReportFilterSchema).optional().describe('Report filters'),
121
+ groupBy: z.array(ReportGroupBySchema).optional().describe('Group by configuration'),
122
+ sections: z.array(ReportSectionSchema).optional().describe('Report sections'),
123
+ schedule: ReportScheduleSchema.optional().describe('Schedule configuration'),
124
+ defaultExportFormat: ReportExportFormatSchema.optional().describe('Default export format'),
125
+ exportConfigs: z.record(z.string(), ReportExportConfigSchema).optional().describe('Export configurations'),
126
+ showExportButtons: z.boolean().optional().describe('Show export buttons'),
127
+ showPrintButton: z.boolean().optional().describe('Show print button'),
128
+ showScheduleButton: z.boolean().optional().describe('Show schedule button'),
129
+ refreshInterval: z.number().optional().describe('Auto-refresh interval (in seconds)'),
130
+ loading: z.boolean().optional().describe('Loading state'),
131
+ data: z.array(z.any()).optional().describe('Report data'),
132
+ });
133
+
134
+ /**
135
+ * Report Builder Schema
136
+ */
137
+ export const ReportBuilderSchema = BaseSchema.extend({
138
+ type: z.literal('report-builder'),
139
+ report: ReportSchema.optional().describe('Initial report configuration'),
140
+ dataSources: z.array(z.any()).optional().describe('Available data sources'),
141
+ availableFields: z.array(ReportFieldSchema).optional().describe('Available fields'),
142
+ showPreview: z.boolean().optional().describe('Show preview'),
143
+ onSave: z.string().optional().describe('Save callback'),
144
+ onCancel: z.string().optional().describe('Cancel callback'),
145
+ });
146
+
147
+ /**
148
+ * Report Viewer Schema
149
+ */
150
+ export const ReportViewerSchema = BaseSchema.extend({
151
+ type: z.literal('report-viewer'),
152
+ report: ReportSchema.optional().describe('Report to display'),
153
+ data: z.array(z.any()).optional().describe('Report data'),
154
+ showToolbar: z.boolean().optional().describe('Show toolbar'),
155
+ allowExport: z.boolean().optional().describe('Allow export'),
156
+ allowPrint: z.boolean().optional().describe('Allow print'),
157
+ loading: z.boolean().optional().describe('Loading state'),
158
+ });
159
+
160
+ /**
161
+ * Union of all report schemas
162
+ */
163
+ export const ReportComponentSchema = z.union([
164
+ ReportSchema,
165
+ ReportBuilderSchema,
166
+ ReportViewerSchema,
167
+ ]);
168
+
169
+ /**
170
+ * Export type inference helpers
171
+ */
172
+ export type ReportExportFormatSchemaType = z.infer<typeof ReportExportFormatSchema>;
173
+ export type ReportScheduleFrequencySchemaType = z.infer<typeof ReportScheduleFrequencySchema>;
174
+ export type ReportAggregationTypeSchemaType = z.infer<typeof ReportAggregationTypeSchema>;
175
+ export type ReportFieldSchemaType = z.infer<typeof ReportFieldSchema>;
176
+ export type ReportFilterSchemaType = z.infer<typeof ReportFilterSchema>;
177
+ export type ReportGroupBySchemaType = z.infer<typeof ReportGroupBySchema>;
178
+ export type ReportSectionSchemaType = z.infer<typeof ReportSectionSchema>;
179
+ export type ReportScheduleSchemaType = z.infer<typeof ReportScheduleSchema>;
180
+ export type ReportExportConfigSchemaType = z.infer<typeof ReportExportConfigSchema>;
181
+ export type ReportSchemaType = z.infer<typeof ReportSchema>;
182
+ export type ReportBuilderSchemaType = z.infer<typeof ReportBuilderSchema>;
183
+ export type ReportViewerSchemaType = z.infer<typeof ReportViewerSchema>;
@@ -0,0 +1,155 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * @object-ui/types/zod - Theme Schema Zod Validators
11
+ *
12
+ * Zod validation schemas for theme configuration.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/theme
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema } from './base.zod.js';
21
+
22
+ /**
23
+ * Color Palette Schema
24
+ */
25
+ export const ColorPaletteSchema = z.object({
26
+ primary: z.string().optional().describe('Primary brand color'),
27
+ secondary: z.string().optional().describe('Secondary color'),
28
+ accent: z.string().optional().describe('Accent color'),
29
+ background: z.string().optional().describe('Background color'),
30
+ foreground: z.string().optional().describe('Foreground/text color'),
31
+ muted: z.string().optional().describe('Muted color'),
32
+ mutedForeground: z.string().optional().describe('Muted foreground color'),
33
+ border: z.string().optional().describe('Border color'),
34
+ input: z.string().optional().describe('Input border color'),
35
+ ring: z.string().optional().describe('Ring/focus color'),
36
+ success: z.string().optional().describe('Success color'),
37
+ warning: z.string().optional().describe('Warning color'),
38
+ destructive: z.string().optional().describe('Error/destructive color'),
39
+ info: z.string().optional().describe('Info color'),
40
+ card: z.string().optional().describe('Card background color'),
41
+ cardForeground: z.string().optional().describe('Card foreground color'),
42
+ popover: z.string().optional().describe('Popover background color'),
43
+ popoverForeground: z.string().optional().describe('Popover foreground color'),
44
+ });
45
+
46
+ /**
47
+ * Typography Schema
48
+ */
49
+ export const TypographySchema = z.object({
50
+ fontSans: z.array(z.string()).optional().describe('Font family for sans-serif text'),
51
+ fontSerif: z.array(z.string()).optional().describe('Font family for serif text'),
52
+ fontMono: z.array(z.string()).optional().describe('Font family for monospace text'),
53
+ fontSize: z.number().optional().describe('Base font size (in rem)'),
54
+ lineHeight: z.number().optional().describe('Line height'),
55
+ headingWeight: z.number().optional().describe('Font weight for headings'),
56
+ bodyWeight: z.number().optional().describe('Font weight for body text'),
57
+ });
58
+
59
+ /**
60
+ * Spacing Scale Schema
61
+ */
62
+ export const SpacingScaleSchema = z.object({
63
+ base: z.number().optional().describe('Base spacing unit (in rem)'),
64
+ scale: z.record(z.string(), z.string()).optional().describe('Custom spacing values'),
65
+ });
66
+
67
+ /**
68
+ * Border Radius Schema
69
+ */
70
+ export const BorderRadiusSchema = z.object({
71
+ sm: z.string().optional().describe('Small radius'),
72
+ default: z.string().optional().describe('Default radius'),
73
+ md: z.string().optional().describe('Medium radius'),
74
+ lg: z.string().optional().describe('Large radius'),
75
+ xl: z.string().optional().describe('Extra large radius'),
76
+ });
77
+
78
+ /**
79
+ * Theme Mode Schema
80
+ */
81
+ export const ThemeModeSchema = z.enum(['light', 'dark', 'system']).describe('Theme mode');
82
+
83
+ /**
84
+ * Theme Definition Schema
85
+ */
86
+ export const ThemeDefinitionSchema = z.object({
87
+ name: z.string().describe('Theme name/identifier'),
88
+ label: z.string().optional().describe('Theme display label'),
89
+ light: ColorPaletteSchema.optional().describe('Light mode color palette'),
90
+ dark: ColorPaletteSchema.optional().describe('Dark mode color palette'),
91
+ typography: TypographySchema.optional().describe('Typography configuration'),
92
+ spacing: SpacingScaleSchema.optional().describe('Spacing scale configuration'),
93
+ radius: BorderRadiusSchema.optional().describe('Border radius configuration'),
94
+ cssVariables: z.record(z.string(), z.string()).optional().describe('Custom CSS variables'),
95
+ tailwind: z.record(z.string(), z.any()).optional().describe('Tailwind configuration overrides'),
96
+ });
97
+
98
+ /**
99
+ * Theme Schema
100
+ */
101
+ export const ThemeSchema = BaseSchema.extend({
102
+ type: z.literal('theme'),
103
+ mode: ThemeModeSchema.optional().describe('Current theme mode'),
104
+ themes: z.array(ThemeDefinitionSchema).optional().describe('Available themes'),
105
+ activeTheme: z.string().optional().describe('Active theme name'),
106
+ allowSwitching: z.boolean().optional().describe('Allow user theme switching'),
107
+ persistPreference: z.boolean().optional().describe('Persist theme preference'),
108
+ storageKey: z.string().optional().describe('Storage key for persisting theme'),
109
+ });
110
+
111
+ /**
112
+ * Theme Switcher Schema
113
+ */
114
+ export const ThemeSwitcherSchema = BaseSchema.extend({
115
+ type: z.literal('theme-switcher'),
116
+ variant: z.enum(['dropdown', 'toggle', 'buttons']).optional().describe('Switcher variant'),
117
+ showMode: z.boolean().optional().describe('Show mode selector (light/dark)'),
118
+ showThemes: z.boolean().optional().describe('Show theme selector'),
119
+ lightIcon: z.string().optional().describe('Icon for light mode'),
120
+ darkIcon: z.string().optional().describe('Icon for dark mode'),
121
+ });
122
+
123
+ /**
124
+ * Theme Preview Schema
125
+ */
126
+ export const ThemePreviewSchema = BaseSchema.extend({
127
+ type: z.literal('theme-preview'),
128
+ theme: ThemeDefinitionSchema.optional().describe('Theme to preview'),
129
+ mode: ThemeModeSchema.optional().describe('Preview mode'),
130
+ showColors: z.boolean().optional().describe('Show color palette'),
131
+ showTypography: z.boolean().optional().describe('Show typography samples'),
132
+ showComponents: z.boolean().optional().describe('Show component samples'),
133
+ });
134
+
135
+ /**
136
+ * Union of all theme schemas
137
+ */
138
+ export const ThemeComponentSchema = z.union([
139
+ ThemeSchema,
140
+ ThemeSwitcherSchema,
141
+ ThemePreviewSchema,
142
+ ]);
143
+
144
+ /**
145
+ * Export type inference helpers
146
+ */
147
+ export type ColorPaletteSchemaType = z.infer<typeof ColorPaletteSchema>;
148
+ export type TypographySchemaType = z.infer<typeof TypographySchema>;
149
+ export type SpacingScaleSchemaType = z.infer<typeof SpacingScaleSchema>;
150
+ export type BorderRadiusSchemaType = z.infer<typeof BorderRadiusSchema>;
151
+ export type ThemeModeSchemaType = z.infer<typeof ThemeModeSchema>;
152
+ export type ThemeDefinitionSchemaType = z.infer<typeof ThemeDefinitionSchema>;
153
+ export type ThemeSchemaType = z.infer<typeof ThemeSchema>;
154
+ export type ThemeSwitcherSchemaType = z.infer<typeof ThemeSwitcherSchema>;
155
+ export type ThemePreviewSchemaType = z.infer<typeof ThemePreviewSchema>;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * @object-ui/types/zod - View Component Zod Validators
11
+ *
12
+ * Zod validation schemas for view components.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/views
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
21
+
22
+ /**
23
+ * View Type Schema
24
+ */
25
+ export const ViewTypeSchema = z.enum(['list', 'detail', 'grid', 'kanban', 'calendar', 'timeline', 'map']).describe('View type');
26
+
27
+ /**
28
+ * Detail View Field Schema
29
+ */
30
+ export const DetailViewFieldSchema = z.object({
31
+ name: z.string().describe('Field name/path'),
32
+ label: z.string().optional().describe('Display label'),
33
+ type: z.enum(['text', 'image', 'link', 'badge', 'date', 'datetime', 'json', 'html', 'markdown', 'custom']).optional().describe('Field type for rendering'),
34
+ format: z.string().optional().describe('Format string (e.g., date format)'),
35
+ render: SchemaNodeSchema.optional().describe('Custom renderer'),
36
+ value: z.any().optional().describe('Field value'),
37
+ readonly: z.boolean().optional().describe('Whether field is read-only'),
38
+ visible: z.union([z.boolean(), z.string()]).optional().describe('Field visibility condition'),
39
+ span: z.number().optional().describe('Span across columns (for grid layout)'),
40
+ });
41
+
42
+ /**
43
+ * Detail View Section Schema
44
+ */
45
+ export const DetailViewSectionSchema = z.object({
46
+ title: z.string().optional().describe('Section title'),
47
+ description: z.string().optional().describe('Section description'),
48
+ icon: z.string().optional().describe('Section icon'),
49
+ fields: z.array(DetailViewFieldSchema).describe('Fields in this section'),
50
+ collapsible: z.boolean().optional().describe('Collapsible section'),
51
+ defaultCollapsed: z.boolean().optional().describe('Default collapsed state'),
52
+ columns: z.number().optional().describe('Grid columns for field layout'),
53
+ visible: z.union([z.boolean(), z.string()]).optional().describe('Section visibility condition'),
54
+ });
55
+
56
+ /**
57
+ * Detail View Tab Schema
58
+ */
59
+ export const DetailViewTabSchema = z.object({
60
+ key: z.string().describe('Tab key/identifier'),
61
+ label: z.string().describe('Tab label'),
62
+ icon: z.string().optional().describe('Tab icon'),
63
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Tab content'),
64
+ visible: z.union([z.boolean(), z.string()]).optional().describe('Tab visibility condition'),
65
+ badge: z.union([z.string(), z.number()]).optional().describe('Badge count'),
66
+ });
67
+
68
+ /**
69
+ * Detail View Schema
70
+ */
71
+ export const DetailViewSchema = BaseSchema.extend({
72
+ type: z.literal('detail-view'),
73
+ title: z.string().optional().describe('Detail title'),
74
+ api: z.string().optional().describe('API endpoint to fetch detail data'),
75
+ resourceId: z.union([z.string(), z.number()]).optional().describe('Resource ID to display'),
76
+ objectName: z.string().optional().describe('Object name (for ObjectQL integration)'),
77
+ data: z.any().optional().describe('Data to display (if not fetching from API)'),
78
+ layout: z.enum(['vertical', 'horizontal', 'grid']).optional().describe('Layout mode'),
79
+ columns: z.number().optional().describe('Grid columns (for grid layout)'),
80
+ sections: z.array(DetailViewSectionSchema).optional().describe('Field sections for organized display'),
81
+ fields: z.array(DetailViewFieldSchema).optional().describe('Direct fields (without sections)'),
82
+ actions: z.array(z.any()).optional().describe('Actions available in detail view'),
83
+ tabs: z.array(DetailViewTabSchema).optional().describe('Tabs for additional content'),
84
+ showBack: z.boolean().optional().default(true).describe('Show back button'),
85
+ backUrl: z.string().optional().describe('Back button URL'),
86
+ onBack: z.string().optional().describe('Custom back action'),
87
+ showEdit: z.boolean().optional().describe('Show edit button'),
88
+ editUrl: z.string().optional().describe('Edit button URL'),
89
+ showDelete: z.boolean().optional().describe('Show delete button'),
90
+ deleteConfirmation: z.string().optional().describe('Delete confirmation message'),
91
+ loading: z.boolean().optional().default(true).describe('Whether to show loading state'),
92
+ header: SchemaNodeSchema.optional().describe('Custom header content'),
93
+ footer: SchemaNodeSchema.optional().describe('Custom footer content'),
94
+ related: z.array(z.object({
95
+ title: z.string().describe('Relation title'),
96
+ type: z.enum(['list', 'grid', 'table']).describe('Relation type'),
97
+ api: z.string().optional().describe('API endpoint for related data'),
98
+ data: z.array(z.any()).optional().describe('Static data'),
99
+ columns: z.array(z.any()).optional().describe('Columns for table view'),
100
+ fields: z.array(z.string()).optional().describe('Fields for list view'),
101
+ })).optional().describe('Related records section'),
102
+ });
103
+
104
+ /**
105
+ * View Switcher Schema
106
+ */
107
+ export const ViewSwitcherSchema = BaseSchema.extend({
108
+ type: z.literal('view-switcher'),
109
+ views: z.array(z.object({
110
+ type: ViewTypeSchema.describe('View type'),
111
+ label: z.string().optional().describe('View label'),
112
+ icon: z.string().optional().describe('View icon'),
113
+ schema: SchemaNodeSchema.optional().describe('View schema'),
114
+ })).describe('Available view types'),
115
+ defaultView: ViewTypeSchema.optional().describe('Default/active view'),
116
+ activeView: ViewTypeSchema.optional().describe('Current active view'),
117
+ variant: z.enum(['tabs', 'buttons', 'dropdown']).optional().describe('Switcher variant'),
118
+ position: z.enum(['top', 'bottom', 'left', 'right']).optional().describe('Switcher position'),
119
+ onViewChange: z.string().optional().describe('View change callback'),
120
+ persistPreference: z.boolean().optional().describe('Persist view preference'),
121
+ storageKey: z.string().optional().describe('Storage key for persisting view'),
122
+ });
123
+
124
+ /**
125
+ * Filter UI Schema
126
+ */
127
+ export const FilterUISchema = BaseSchema.extend({
128
+ type: z.literal('filter-ui'),
129
+ filters: z.array(z.object({
130
+ field: z.string().describe('Filter field'),
131
+ label: z.string().optional().describe('Filter label'),
132
+ type: z.enum(['text', 'number', 'select', 'date', 'date-range', 'boolean']).describe('Filter type'),
133
+ operator: z.enum(['equals', 'contains', 'startsWith', 'gt', 'lt', 'between', 'in']).optional().describe('Filter operator'),
134
+ options: z.array(z.object({ label: z.string(), value: z.any() })).optional().describe('Options for select filter'),
135
+ placeholder: z.string().optional().describe('Placeholder'),
136
+ })).describe('Available filters'),
137
+ values: z.record(z.string(), z.any()).optional().describe('Current filter values'),
138
+ onChange: z.string().optional().describe('Filter change callback'),
139
+ showClear: z.boolean().optional().describe('Show clear button'),
140
+ showApply: z.boolean().optional().describe('Show apply button'),
141
+ layout: z.enum(['inline', 'popover', 'drawer']).optional().describe('Filter layout'),
142
+ });
143
+
144
+ /**
145
+ * Sort UI Schema
146
+ */
147
+ export const SortUISchema = BaseSchema.extend({
148
+ type: z.literal('sort-ui'),
149
+ fields: z.array(z.object({
150
+ field: z.string().describe('Field name'),
151
+ label: z.string().optional().describe('Field label'),
152
+ })).describe('Sortable fields'),
153
+ sort: z.array(z.object({
154
+ field: z.string().describe('Field to sort by'),
155
+ direction: z.enum(['asc', 'desc']).describe('Sort direction'),
156
+ })).optional().describe('Current sort configuration'),
157
+ onChange: z.string().optional().describe('Sort change callback'),
158
+ multiple: z.boolean().optional().describe('Allow multiple sort fields'),
159
+ variant: z.enum(['dropdown', 'buttons']).optional().describe('UI variant'),
160
+ });
161
+
162
+ /**
163
+ * Union of all view schemas
164
+ */
165
+ export const ViewComponentSchema = z.union([
166
+ DetailViewSchema,
167
+ ViewSwitcherSchema,
168
+ FilterUISchema,
169
+ SortUISchema,
170
+ ]);
171
+
172
+ /**
173
+ * Export type inference helpers
174
+ */
175
+ export type ViewTypeSchemaType = z.infer<typeof ViewTypeSchema>;
176
+ export type DetailViewFieldSchemaType = z.infer<typeof DetailViewFieldSchema>;
177
+ export type DetailViewSectionSchemaType = z.infer<typeof DetailViewSectionSchema>;
178
+ export type DetailViewTabSchemaType = z.infer<typeof DetailViewTabSchema>;
179
+ export type DetailViewSchemaType = z.infer<typeof DetailViewSchema>;
180
+ export type ViewSwitcherSchemaType = z.infer<typeof ViewSwitcherSchema>;
181
+ export type FilterUISchemaType = z.infer<typeof FilterUISchema>;
182
+ export type SortUISchemaType = z.infer<typeof SortUISchema>;