@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.
- package/dist/app.d.ts +10 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/blocks.d.ts +332 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +8 -0
- package/dist/crud.d.ts +174 -3
- package/dist/crud.d.ts.map +1 -1
- package/dist/data-protocol.d.ts +1268 -0
- package/dist/data-protocol.d.ts.map +1 -0
- package/dist/data-protocol.js +8 -0
- package/dist/data.d.ts +6 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/field-types.d.ts +353 -11
- package/dist/field-types.d.ts.map +1 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/objectql.d.ts +8 -1
- package/dist/objectql.d.ts.map +1 -1
- package/dist/plugin-scope.d.ts +194 -0
- package/dist/plugin-scope.d.ts.map +1 -0
- package/dist/plugin-scope.js +8 -0
- package/dist/reports.d.ts +336 -0
- package/dist/reports.d.ts.map +1 -0
- package/dist/reports.js +8 -0
- package/dist/theme.d.ts +289 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +8 -0
- package/dist/ui-action.d.ts +175 -0
- package/dist/ui-action.d.ts.map +1 -0
- package/dist/ui-action.js +8 -0
- package/dist/views.d.ts +417 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +8 -0
- package/dist/zod/app.zod.d.ts +120 -0
- package/dist/zod/app.zod.d.ts.map +1 -0
- package/dist/zod/app.zod.js +60 -0
- package/dist/zod/blocks.zod.d.ts +834 -0
- package/dist/zod/blocks.zod.d.ts.map +1 -0
- package/dist/zod/blocks.zod.js +145 -0
- package/dist/zod/complex.zod.js +1 -1
- package/dist/zod/crud.zod.d.ts +598 -0
- package/dist/zod/crud.zod.d.ts.map +1 -0
- package/dist/zod/crud.zod.js +230 -0
- package/dist/zod/data-display.zod.js +1 -1
- package/dist/zod/disclosure.zod.js +1 -1
- package/dist/zod/feedback.zod.js +1 -1
- package/dist/zod/form.zod.js +1 -1
- package/dist/zod/index.zod.d.ts +1829 -18
- package/dist/zod/index.zod.d.ts.map +1 -1
- package/dist/zod/index.zod.js +96 -19
- package/dist/zod/layout.zod.d.ts +2 -2
- package/dist/zod/layout.zod.js +1 -1
- package/dist/zod/navigation.zod.js +1 -1
- package/dist/zod/objectql.zod.d.ts +10 -10
- package/dist/zod/objectql.zod.js +1 -1
- package/dist/zod/overlay.zod.js +1 -1
- package/dist/zod/reports.zod.d.ts +1628 -0
- package/dist/zod/reports.zod.d.ts.map +1 -0
- package/dist/zod/reports.zod.js +152 -0
- package/dist/zod/theme.zod.d.ts +611 -0
- package/dist/zod/theme.zod.d.ts.map +1 -0
- package/dist/zod/theme.zod.js +130 -0
- package/dist/zod/views.zod.d.ts +675 -0
- package/dist/zod/views.zod.d.ts.map +1 -0
- package/dist/zod/views.zod.js +159 -0
- package/package.json +2 -2
- package/src/__tests__/namespace-exports.test.ts +80 -0
- package/src/__tests__/phase2-schemas.test.ts +639 -0
- package/src/app.ts +12 -0
- package/src/blocks.ts +405 -0
- package/src/crud.ts +177 -3
- package/src/data-protocol.ts +1679 -0
- package/src/data.ts +3 -1
- package/src/field-types.ts +392 -11
- package/src/index.ts +214 -0
- package/src/objectql.ts +9 -1
- package/src/plugin-scope.ts +210 -0
- package/src/reports.ts +408 -0
- package/src/theme.ts +351 -0
- package/src/ui-action.ts +276 -0
- package/src/views.ts +429 -0
- package/src/zod/app.zod.ts +72 -0
- package/src/zod/blocks.zod.ts +170 -0
- package/src/zod/complex.zod.ts +1 -1
- package/src/zod/crud.zod.ts +259 -0
- package/src/zod/data-display.zod.ts +1 -1
- package/src/zod/disclosure.zod.ts +1 -1
- package/src/zod/feedback.zod.ts +1 -1
- package/src/zod/form.zod.ts +1 -1
- package/src/zod/index.zod.ts +167 -19
- package/src/zod/layout.zod.ts +1 -1
- package/src/zod/navigation.zod.ts +1 -1
- package/src/zod/objectql.zod.ts +1 -1
- package/src/zod/overlay.zod.ts +1 -1
- package/src/zod/reports.zod.ts +183 -0
- package/src/zod/theme.zod.ts +155 -0
- package/src/zod/views.zod.ts +182 -0
|
@@ -0,0 +1,259 @@
|
|
|
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 - CRUD Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for CRUD operations.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* Enhanced in Phase 2 with ajax, confirm, dialog actions, chaining, and conditional execution.
|
|
16
|
+
*
|
|
17
|
+
* @module zod/crud
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Action Execution Mode Schema
|
|
26
|
+
*/
|
|
27
|
+
export const ActionExecutionModeSchema = z.enum(['sequential', 'parallel']).describe('Action execution mode for chaining');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Action Callback Schema
|
|
31
|
+
*/
|
|
32
|
+
export const ActionCallbackSchema = z.object({
|
|
33
|
+
type: z.enum(['toast', 'message', 'redirect', 'reload', 'custom', 'ajax', 'dialog']).describe('Callback type'),
|
|
34
|
+
message: z.string().optional().describe('Message to display'),
|
|
35
|
+
url: z.string().optional().describe('Redirect URL'),
|
|
36
|
+
api: z.string().optional().describe('API endpoint for ajax callback'),
|
|
37
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().describe('HTTP method for ajax callback'),
|
|
38
|
+
dialog: SchemaNodeSchema.optional().describe('Dialog schema to open'),
|
|
39
|
+
handler: z.string().optional().describe('Custom callback handler expression'),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Action Condition Schema
|
|
44
|
+
*/
|
|
45
|
+
export const ActionConditionSchema: z.ZodType<any> = z.lazy(() => z.object({
|
|
46
|
+
expression: z.string().describe('Condition expression'),
|
|
47
|
+
then: z.union([ActionSchema, z.array(ActionSchema)]).optional().describe('Action to execute if condition is true'),
|
|
48
|
+
else: z.union([ActionSchema, z.array(ActionSchema)]).optional().describe('Action to execute if condition is false'),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Action Schema - Enhanced with Phase 2 features
|
|
53
|
+
*/
|
|
54
|
+
export const ActionSchema: z.ZodType<any> = z.lazy(() => BaseSchema.extend({
|
|
55
|
+
type: z.literal('action'),
|
|
56
|
+
label: z.string().describe('Action label'),
|
|
57
|
+
level: z.enum(['primary', 'secondary', 'success', 'warning', 'danger', 'info', 'default']).optional().default('default').describe('Action type/level'),
|
|
58
|
+
icon: z.string().optional().describe('Icon to display (lucide-react icon name)'),
|
|
59
|
+
variant: z.enum(['default', 'outline', 'ghost', 'link']).optional().describe('Action variant'),
|
|
60
|
+
disabled: z.boolean().optional().describe('Whether action is disabled'),
|
|
61
|
+
actionType: z.enum(['button', 'link', 'dropdown', 'ajax', 'confirm', 'dialog']).optional().describe('Action type'),
|
|
62
|
+
api: z.string().optional().describe('API endpoint to call (for ajax actions)'),
|
|
63
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().default('POST').describe('HTTP method'),
|
|
64
|
+
data: z.any().optional().describe('Request body/data'),
|
|
65
|
+
headers: z.record(z.string(), z.string()).optional().describe('Request headers'),
|
|
66
|
+
confirm: z.object({
|
|
67
|
+
title: z.string().optional().describe('Confirmation title'),
|
|
68
|
+
message: z.string().optional().describe('Confirmation message'),
|
|
69
|
+
confirmText: z.string().optional().describe('Confirm button text'),
|
|
70
|
+
cancelText: z.string().optional().describe('Cancel button text'),
|
|
71
|
+
confirmVariant: z.enum(['default', 'destructive', 'outline', 'secondary', 'ghost']).optional().describe('Confirm button variant'),
|
|
72
|
+
}).optional().describe('Confirmation dialog configuration (for confirm actions)'),
|
|
73
|
+
confirmText: z.string().optional().describe('Legacy confirmation message (deprecated - use confirm object instead)'),
|
|
74
|
+
dialog: z.object({
|
|
75
|
+
title: z.string().optional().describe('Dialog title'),
|
|
76
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog content'),
|
|
77
|
+
size: z.enum(['sm', 'default', 'lg', 'xl', 'full']).optional().describe('Dialog size'),
|
|
78
|
+
actions: z.array(ActionSchema).optional().describe('Dialog actions'),
|
|
79
|
+
}).optional().describe('Dialog configuration (for dialog actions)'),
|
|
80
|
+
successMessage: z.string().optional().describe('Success message after execution'),
|
|
81
|
+
errorMessage: z.string().optional().describe('Error message on failure'),
|
|
82
|
+
onSuccess: ActionCallbackSchema.optional().describe('Success callback'),
|
|
83
|
+
onFailure: ActionCallbackSchema.optional().describe('Failure callback'),
|
|
84
|
+
chain: z.array(ActionSchema).optional().describe('Action chaining - actions to execute after this one'),
|
|
85
|
+
chainMode: ActionExecutionModeSchema.optional().default('sequential').describe('Chain execution mode'),
|
|
86
|
+
condition: ActionConditionSchema.optional().describe('Conditional execution'),
|
|
87
|
+
reload: z.boolean().optional().default(true).describe('Whether to reload data after action'),
|
|
88
|
+
close: z.boolean().optional().default(true).describe('Whether to close dialog/modal after action'),
|
|
89
|
+
onClick: z.any().optional().describe('Custom click handler'),
|
|
90
|
+
redirect: z.string().optional().describe('Redirect URL after success'),
|
|
91
|
+
tracking: z.object({
|
|
92
|
+
enabled: z.boolean().optional().describe('Enable tracking'),
|
|
93
|
+
event: z.string().optional().describe('Event name'),
|
|
94
|
+
metadata: z.record(z.string(), z.any()).optional().describe('Additional metadata'),
|
|
95
|
+
}).optional().describe('Action logging/tracking'),
|
|
96
|
+
timeout: z.number().optional().describe('Timeout in milliseconds'),
|
|
97
|
+
retry: z.object({
|
|
98
|
+
maxAttempts: z.number().optional().describe('Maximum retry attempts'),
|
|
99
|
+
delay: z.number().optional().describe('Delay between retries (in ms)'),
|
|
100
|
+
}).optional().describe('Retry configuration'),
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* CRUD Operation Schema
|
|
105
|
+
*/
|
|
106
|
+
export const CRUDOperationSchema = z.object({
|
|
107
|
+
type: z.enum(['create', 'read', 'update', 'delete', 'export', 'import', 'custom']).describe('Operation type'),
|
|
108
|
+
label: z.string().optional().describe('Operation label'),
|
|
109
|
+
icon: z.string().optional().describe('Operation icon'),
|
|
110
|
+
enabled: z.boolean().optional().default(true).describe('Whether operation is enabled'),
|
|
111
|
+
api: z.string().optional().describe('API endpoint for this operation'),
|
|
112
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().describe('HTTP method'),
|
|
113
|
+
confirmText: z.string().optional().describe('Confirmation message'),
|
|
114
|
+
successMessage: z.string().optional().describe('Success message'),
|
|
115
|
+
visibleOn: z.string().optional().describe('Visibility condition'),
|
|
116
|
+
disabledOn: z.string().optional().describe('Disabled condition'),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* CRUD Filter Schema
|
|
121
|
+
*/
|
|
122
|
+
export const CRUDFilterSchema = z.object({
|
|
123
|
+
name: z.string().describe('Filter name (field name)'),
|
|
124
|
+
label: z.string().optional().describe('Filter label'),
|
|
125
|
+
type: z.enum(['input', 'select', 'date-picker', 'date-range', 'number-range']).optional().describe('Filter type'),
|
|
126
|
+
operator: z.enum(['equals', 'contains', 'startsWith', 'endsWith', 'gt', 'gte', 'lt', 'lte', 'between', 'in']).optional().default('equals').describe('Filter operator'),
|
|
127
|
+
options: z.array(z.object({ label: z.string(), value: z.union([z.string(), z.number()]) })).optional().describe('Options for select filter'),
|
|
128
|
+
placeholder: z.string().optional().describe('Placeholder text'),
|
|
129
|
+
defaultValue: z.any().optional().describe('Default value'),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* CRUD Toolbar Schema
|
|
134
|
+
*/
|
|
135
|
+
export const CRUDToolbarSchema = z.object({
|
|
136
|
+
showCreate: z.boolean().optional().default(true).describe('Show create button'),
|
|
137
|
+
showRefresh: z.boolean().optional().default(true).describe('Show refresh button'),
|
|
138
|
+
showExport: z.boolean().optional().default(false).describe('Show export button'),
|
|
139
|
+
showImport: z.boolean().optional().default(false).describe('Show import button'),
|
|
140
|
+
showFilter: z.boolean().optional().default(true).describe('Show filter toggle'),
|
|
141
|
+
showSearch: z.boolean().optional().default(true).describe('Show search box'),
|
|
142
|
+
actions: z.array(ActionSchema).optional().describe('Custom actions'),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* CRUD Pagination Schema
|
|
147
|
+
*/
|
|
148
|
+
export const CRUDPaginationSchema = z.object({
|
|
149
|
+
enabled: z.boolean().optional().default(true).describe('Whether pagination is enabled'),
|
|
150
|
+
pageSize: z.number().optional().default(10).describe('Default page size'),
|
|
151
|
+
pageSizeOptions: z.array(z.number()).optional().default([10, 20, 50, 100]).describe('Page size options'),
|
|
152
|
+
showTotal: z.boolean().optional().default(true).describe('Show total count'),
|
|
153
|
+
showSizeChanger: z.boolean().optional().default(true).describe('Show page size selector'),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* CRUD Schema
|
|
158
|
+
*/
|
|
159
|
+
export const CRUDSchema = BaseSchema.extend({
|
|
160
|
+
type: z.literal('crud'),
|
|
161
|
+
title: z.string().optional().describe('CRUD title'),
|
|
162
|
+
resource: z.string().optional().describe('Resource name (singular)'),
|
|
163
|
+
api: z.string().optional().describe('API endpoint for list/search'),
|
|
164
|
+
columns: z.array(z.any()).describe('Table columns configuration'),
|
|
165
|
+
fields: z.array(z.any()).optional().describe('Form fields for create/edit'),
|
|
166
|
+
operations: z.record(z.string(), z.union([z.boolean(), CRUDOperationSchema])).optional().describe('Enabled operations'),
|
|
167
|
+
toolbar: CRUDToolbarSchema.optional().describe('Toolbar configuration'),
|
|
168
|
+
filters: z.array(CRUDFilterSchema).optional().describe('Filter configuration'),
|
|
169
|
+
pagination: CRUDPaginationSchema.optional().describe('Pagination configuration'),
|
|
170
|
+
defaultSort: z.string().optional().describe('Default sort field'),
|
|
171
|
+
defaultSortOrder: z.enum(['asc', 'desc']).optional().default('asc').describe('Default sort order'),
|
|
172
|
+
selectable: z.union([z.boolean(), z.enum(['single', 'multiple'])]).optional().describe('Row selection mode'),
|
|
173
|
+
batchActions: z.array(ActionSchema).optional().describe('Batch actions for selected rows'),
|
|
174
|
+
rowActions: z.array(ActionSchema).optional().describe('Row actions (displayed in each row)'),
|
|
175
|
+
emptyState: SchemaNodeSchema.optional().describe('Custom empty state'),
|
|
176
|
+
loading: z.boolean().optional().default(true).describe('Whether to show loading state'),
|
|
177
|
+
loadingComponent: SchemaNodeSchema.optional().describe('Custom loading component'),
|
|
178
|
+
mode: z.enum(['table', 'grid', 'list', 'kanban']).optional().default('table').describe('Table layout mode'),
|
|
179
|
+
gridColumns: z.number().optional().default(3).describe('Grid columns (for grid mode)'),
|
|
180
|
+
cardTemplate: SchemaNodeSchema.optional().describe('Card template (for grid/list mode)'),
|
|
181
|
+
kanbanColumns: z.array(z.object({
|
|
182
|
+
id: z.string(),
|
|
183
|
+
title: z.string(),
|
|
184
|
+
color: z.string().optional(),
|
|
185
|
+
})).optional().describe('Kanban columns (for kanban mode)'),
|
|
186
|
+
kanbanGroupField: z.string().optional().describe('Kanban group field'),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Detail Schema
|
|
191
|
+
*/
|
|
192
|
+
export const DetailSchema = BaseSchema.extend({
|
|
193
|
+
type: z.literal('detail'),
|
|
194
|
+
title: z.string().optional().describe('Detail title'),
|
|
195
|
+
api: z.string().optional().describe('API endpoint to fetch detail data'),
|
|
196
|
+
resourceId: z.union([z.string(), z.number()]).optional().describe('Resource ID to display'),
|
|
197
|
+
groups: z.array(z.object({
|
|
198
|
+
title: z.string().optional(),
|
|
199
|
+
description: z.string().optional(),
|
|
200
|
+
fields: z.array(z.object({
|
|
201
|
+
name: z.string(),
|
|
202
|
+
label: z.string().optional(),
|
|
203
|
+
type: z.enum(['text', 'image', 'link', 'badge', 'date', 'datetime', 'json', 'html', 'custom']).optional(),
|
|
204
|
+
format: z.string().optional(),
|
|
205
|
+
render: SchemaNodeSchema.optional(),
|
|
206
|
+
})),
|
|
207
|
+
})).optional().describe('Field groups for organized display'),
|
|
208
|
+
actions: z.array(ActionSchema).optional().describe('Actions available in detail view'),
|
|
209
|
+
tabs: z.array(z.object({
|
|
210
|
+
key: z.string(),
|
|
211
|
+
label: z.string(),
|
|
212
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]),
|
|
213
|
+
})).optional().describe('Tabs for additional content'),
|
|
214
|
+
showBack: z.boolean().optional().default(true).describe('Show back button'),
|
|
215
|
+
onBack: z.any().optional().describe('Custom back action'),
|
|
216
|
+
loading: z.boolean().optional().default(true).describe('Whether to show loading state'),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* CRUD Dialog Schema
|
|
221
|
+
*/
|
|
222
|
+
export const CRUDDialogSchema = BaseSchema.extend({
|
|
223
|
+
type: z.literal('crud-dialog'),
|
|
224
|
+
title: z.string().optional().describe('Dialog title'),
|
|
225
|
+
description: z.string().optional().describe('Dialog description'),
|
|
226
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog content'),
|
|
227
|
+
size: z.enum(['sm', 'default', 'lg', 'xl', 'full']).optional().default('default').describe('Dialog size'),
|
|
228
|
+
actions: z.array(ActionSchema).optional().describe('Dialog actions/buttons'),
|
|
229
|
+
open: z.boolean().optional().describe('Whether dialog is open'),
|
|
230
|
+
onClose: z.any().optional().describe('Close handler'),
|
|
231
|
+
closeOnOutsideClick: z.boolean().optional().default(true).describe('Whether clicking outside closes dialog'),
|
|
232
|
+
closeOnEscape: z.boolean().optional().default(true).describe('Whether pressing Escape closes dialog'),
|
|
233
|
+
showClose: z.boolean().optional().default(true).describe('Show close button'),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Union of all CRUD schemas
|
|
238
|
+
*/
|
|
239
|
+
export const CRUDComponentSchema = z.union([
|
|
240
|
+
ActionSchema,
|
|
241
|
+
CRUDSchema,
|
|
242
|
+
DetailSchema,
|
|
243
|
+
CRUDDialogSchema,
|
|
244
|
+
]);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Export type inference helpers
|
|
248
|
+
*/
|
|
249
|
+
export type ActionExecutionModeSchemaType = z.infer<typeof ActionExecutionModeSchema>;
|
|
250
|
+
export type ActionCallbackSchemaType = z.infer<typeof ActionCallbackSchema>;
|
|
251
|
+
export type ActionConditionSchemaType = z.infer<typeof ActionConditionSchema>;
|
|
252
|
+
export type ActionSchemaType = z.infer<typeof ActionSchema>;
|
|
253
|
+
export type CRUDOperationSchemaType = z.infer<typeof CRUDOperationSchema>;
|
|
254
|
+
export type CRUDFilterSchemaType = z.infer<typeof CRUDFilterSchema>;
|
|
255
|
+
export type CRUDToolbarSchemaType = z.infer<typeof CRUDToolbarSchema>;
|
|
256
|
+
export type CRUDPaginationSchemaType = z.infer<typeof CRUDPaginationSchema>;
|
|
257
|
+
export type CRUDSchemaType = z.infer<typeof CRUDSchema>;
|
|
258
|
+
export type DetailSchemaType = z.infer<typeof DetailSchema>;
|
|
259
|
+
export type CRUDDialogSchemaType = z.infer<typeof CRUDDialogSchema>;
|
package/src/zod/feedback.zod.ts
CHANGED
package/src/zod/form.zod.ts
CHANGED
package/src/zod/index.zod.ts
CHANGED
|
@@ -34,6 +34,15 @@
|
|
|
34
34
|
* @packageDocumentation
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Application - Global Configuration
|
|
39
|
+
// ============================================================================
|
|
40
|
+
export {
|
|
41
|
+
AppSchema,
|
|
42
|
+
AppActionSchema,
|
|
43
|
+
MenuItemSchema as AppMenuItemSchema,
|
|
44
|
+
} from './app.zod.js';
|
|
45
|
+
|
|
37
46
|
// ============================================================================
|
|
38
47
|
// Base Schema - Foundation
|
|
39
48
|
// ============================================================================
|
|
@@ -46,7 +55,7 @@ export {
|
|
|
46
55
|
HTMLAttributesSchema,
|
|
47
56
|
EventHandlersSchema,
|
|
48
57
|
StylePropsSchema,
|
|
49
|
-
} from './base.zod';
|
|
58
|
+
} from './base.zod.js';
|
|
50
59
|
|
|
51
60
|
// ============================================================================
|
|
52
61
|
// Layout Components - Structure & Organization
|
|
@@ -71,7 +80,7 @@ export {
|
|
|
71
80
|
AspectRatioSchema,
|
|
72
81
|
PageSchema,
|
|
73
82
|
LayoutSchema,
|
|
74
|
-
} from './layout.zod';
|
|
83
|
+
} from './layout.zod.js';
|
|
75
84
|
|
|
76
85
|
// ============================================================================
|
|
77
86
|
// Form Components - User Input & Interaction
|
|
@@ -103,7 +112,7 @@ export {
|
|
|
103
112
|
FormFieldSchema,
|
|
104
113
|
FormSchema,
|
|
105
114
|
FormComponentSchema,
|
|
106
|
-
} from './form.zod';
|
|
115
|
+
} from './form.zod.js';
|
|
107
116
|
|
|
108
117
|
// ============================================================================
|
|
109
118
|
// Data Display Components - Information Presentation
|
|
@@ -129,7 +138,7 @@ export {
|
|
|
129
138
|
KbdSchema,
|
|
130
139
|
HtmlSchema,
|
|
131
140
|
DataDisplaySchema,
|
|
132
|
-
} from './data-display.zod';
|
|
141
|
+
} from './data-display.zod.js';
|
|
133
142
|
|
|
134
143
|
// ============================================================================
|
|
135
144
|
// Feedback Components - Status & Progress Indication
|
|
@@ -144,7 +153,7 @@ export {
|
|
|
144
153
|
EmptySchema,
|
|
145
154
|
SonnerSchema,
|
|
146
155
|
FeedbackSchema,
|
|
147
|
-
} from './feedback.zod';
|
|
156
|
+
} from './feedback.zod.js';
|
|
148
157
|
|
|
149
158
|
// ============================================================================
|
|
150
159
|
// Disclosure Components - Collapsible Content
|
|
@@ -156,7 +165,7 @@ export {
|
|
|
156
165
|
ToggleGroupItemSchema,
|
|
157
166
|
ToggleGroupSchema,
|
|
158
167
|
DisclosureSchema,
|
|
159
|
-
} from './disclosure.zod';
|
|
168
|
+
} from './disclosure.zod.js';
|
|
160
169
|
|
|
161
170
|
// ============================================================================
|
|
162
171
|
// Overlay Components - Modals & Popovers
|
|
@@ -175,7 +184,7 @@ export {
|
|
|
175
184
|
MenubarMenuSchema,
|
|
176
185
|
MenubarSchema,
|
|
177
186
|
OverlaySchema,
|
|
178
|
-
} from './overlay.zod';
|
|
187
|
+
} from './overlay.zod.js';
|
|
179
188
|
|
|
180
189
|
// ============================================================================
|
|
181
190
|
// Navigation Components - Menus & Navigation
|
|
@@ -190,7 +199,7 @@ export {
|
|
|
190
199
|
ButtonGroupButtonSchema,
|
|
191
200
|
ButtonGroupSchema,
|
|
192
201
|
NavigationSchema,
|
|
193
|
-
} from './navigation.zod';
|
|
202
|
+
} from './navigation.zod.js';
|
|
194
203
|
|
|
195
204
|
// ============================================================================
|
|
196
205
|
// Complex Components - Advanced/Composite Components
|
|
@@ -215,7 +224,7 @@ export {
|
|
|
215
224
|
DashboardWidgetSchema,
|
|
216
225
|
DashboardSchema,
|
|
217
226
|
ComplexSchema,
|
|
218
|
-
} from './complex.zod';
|
|
227
|
+
} from './complex.zod.js';
|
|
219
228
|
|
|
220
229
|
// ============================================================================
|
|
221
230
|
// ObjectQL Components - Smart Data Components
|
|
@@ -238,28 +247,110 @@ export {
|
|
|
238
247
|
ObjectChartSchema,
|
|
239
248
|
ListViewSchema,
|
|
240
249
|
ObjectQLComponentSchema,
|
|
241
|
-
} from './objectql.zod';
|
|
250
|
+
} from './objectql.zod.js';
|
|
251
|
+
|
|
252
|
+
// ============================================================================
|
|
253
|
+
// CRUD Components - Create, Read, Update, Delete Operations
|
|
254
|
+
// ============================================================================
|
|
255
|
+
export {
|
|
256
|
+
ActionExecutionModeSchema,
|
|
257
|
+
ActionCallbackSchema,
|
|
258
|
+
ActionConditionSchema,
|
|
259
|
+
ActionSchema,
|
|
260
|
+
CRUDOperationSchema,
|
|
261
|
+
CRUDFilterSchema,
|
|
262
|
+
CRUDToolbarSchema,
|
|
263
|
+
CRUDPaginationSchema,
|
|
264
|
+
CRUDSchema,
|
|
265
|
+
DetailSchema,
|
|
266
|
+
CRUDDialogSchema,
|
|
267
|
+
CRUDComponentSchema,
|
|
268
|
+
} from './crud.zod.js';
|
|
269
|
+
|
|
270
|
+
// ============================================================================
|
|
271
|
+
// Phase 2 Schemas - Theme, Reports, Blocks, and Views
|
|
272
|
+
// ============================================================================
|
|
273
|
+
export {
|
|
274
|
+
ColorPaletteSchema,
|
|
275
|
+
TypographySchema,
|
|
276
|
+
SpacingScaleSchema,
|
|
277
|
+
BorderRadiusSchema,
|
|
278
|
+
ThemeModeSchema,
|
|
279
|
+
ThemeDefinitionSchema,
|
|
280
|
+
ThemeSchema,
|
|
281
|
+
ThemeSwitcherSchema,
|
|
282
|
+
ThemePreviewSchema,
|
|
283
|
+
ThemeComponentSchema,
|
|
284
|
+
} from './theme.zod.js';
|
|
285
|
+
|
|
286
|
+
export {
|
|
287
|
+
ReportExportFormatSchema,
|
|
288
|
+
ReportScheduleFrequencySchema,
|
|
289
|
+
ReportAggregationTypeSchema,
|
|
290
|
+
ReportFieldSchema,
|
|
291
|
+
ReportFilterSchema,
|
|
292
|
+
ReportGroupBySchema,
|
|
293
|
+
ReportSectionSchema,
|
|
294
|
+
ReportScheduleSchema,
|
|
295
|
+
ReportExportConfigSchema,
|
|
296
|
+
ReportSchema,
|
|
297
|
+
ReportBuilderSchema,
|
|
298
|
+
ReportViewerSchema,
|
|
299
|
+
ReportComponentSchema,
|
|
300
|
+
} from './reports.zod.js';
|
|
301
|
+
|
|
302
|
+
export {
|
|
303
|
+
BlockVariableSchema,
|
|
304
|
+
BlockSlotSchema,
|
|
305
|
+
BlockMetadataSchema,
|
|
306
|
+
BlockSchema,
|
|
307
|
+
BlockLibraryItemSchema,
|
|
308
|
+
BlockLibrarySchema,
|
|
309
|
+
BlockEditorSchema,
|
|
310
|
+
BlockInstanceSchema,
|
|
311
|
+
ComponentSchema,
|
|
312
|
+
BlockComponentSchema,
|
|
313
|
+
} from './blocks.zod.js';
|
|
314
|
+
|
|
315
|
+
export {
|
|
316
|
+
ViewTypeSchema,
|
|
317
|
+
DetailViewFieldSchema,
|
|
318
|
+
DetailViewSectionSchema,
|
|
319
|
+
DetailViewTabSchema,
|
|
320
|
+
DetailViewSchema,
|
|
321
|
+
ViewSwitcherSchema,
|
|
322
|
+
FilterUISchema,
|
|
323
|
+
SortUISchema,
|
|
324
|
+
ViewComponentSchema,
|
|
325
|
+
} from './views.zod.js';
|
|
242
326
|
|
|
243
327
|
// ============================================================================
|
|
244
328
|
// Union Types - All Component Schemas
|
|
245
329
|
// ============================================================================
|
|
246
330
|
|
|
247
331
|
import { z } from 'zod';
|
|
248
|
-
import {
|
|
249
|
-
import {
|
|
250
|
-
import {
|
|
251
|
-
import {
|
|
252
|
-
import {
|
|
253
|
-
import {
|
|
254
|
-
import {
|
|
255
|
-
import {
|
|
256
|
-
import {
|
|
332
|
+
import { AppSchema } from './app.zod.js';
|
|
333
|
+
import { LayoutSchema } from './layout.zod.js';
|
|
334
|
+
import { FormComponentSchema } from './form.zod.js';
|
|
335
|
+
import { DataDisplaySchema } from './data-display.zod.js';
|
|
336
|
+
import { FeedbackSchema } from './feedback.zod.js';
|
|
337
|
+
import { DisclosureSchema } from './disclosure.zod.js';
|
|
338
|
+
import { OverlaySchema } from './overlay.zod.js';
|
|
339
|
+
import { NavigationSchema } from './navigation.zod.js';
|
|
340
|
+
import { ComplexSchema } from './complex.zod.js';
|
|
341
|
+
import { ObjectQLComponentSchema } from './objectql.zod.js';
|
|
342
|
+
import { CRUDComponentSchema } from './crud.zod.js';
|
|
343
|
+
import { ThemeComponentSchema } from './theme.zod.js';
|
|
344
|
+
import { ReportComponentSchema } from './reports.zod.js';
|
|
345
|
+
import { BlockComponentSchema } from './blocks.zod.js';
|
|
346
|
+
import { ViewComponentSchema } from './views.zod.js';
|
|
257
347
|
|
|
258
348
|
/**
|
|
259
349
|
* Union of all component schemas.
|
|
260
350
|
* Use this for generic component rendering where the type is determined at runtime.
|
|
261
351
|
*/
|
|
262
352
|
export const AnyComponentSchema = z.union([
|
|
353
|
+
AppSchema,
|
|
263
354
|
LayoutSchema,
|
|
264
355
|
FormComponentSchema,
|
|
265
356
|
DataDisplaySchema,
|
|
@@ -269,8 +360,65 @@ export const AnyComponentSchema = z.union([
|
|
|
269
360
|
NavigationSchema,
|
|
270
361
|
ComplexSchema,
|
|
271
362
|
ObjectQLComponentSchema,
|
|
363
|
+
CRUDComponentSchema,
|
|
364
|
+
ThemeComponentSchema,
|
|
365
|
+
ReportComponentSchema,
|
|
366
|
+
BlockComponentSchema,
|
|
367
|
+
ViewComponentSchema,
|
|
272
368
|
]);
|
|
273
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Validate a schema against the AnyComponentSchema
|
|
372
|
+
*
|
|
373
|
+
* @param schema - The schema to validate
|
|
374
|
+
* @returns The validated and typed schema
|
|
375
|
+
* @throws ZodError if validation fails
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* import { validateSchema } from '@object-ui/types/zod';
|
|
380
|
+
*
|
|
381
|
+
* try {
|
|
382
|
+
* const validSchema = validateSchema({
|
|
383
|
+
* type: 'button',
|
|
384
|
+
* label: 'Click Me',
|
|
385
|
+
* });
|
|
386
|
+
* console.log('Valid schema:', validSchema);
|
|
387
|
+
* } catch (error) {
|
|
388
|
+
* console.error('Validation failed:', error);
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
export function validateSchema(schema: unknown) {
|
|
393
|
+
return AnyComponentSchema.parse(schema);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Safely validate a schema without throwing errors
|
|
398
|
+
*
|
|
399
|
+
* @param schema - The schema to validate
|
|
400
|
+
* @returns Object with success boolean and either data or error
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* import { safeValidateSchema } from '@object-ui/types/zod';
|
|
405
|
+
*
|
|
406
|
+
* const result = safeValidateSchema({
|
|
407
|
+
* type: 'button',
|
|
408
|
+
* label: 'Click Me',
|
|
409
|
+
* });
|
|
410
|
+
*
|
|
411
|
+
* if (result.success) {
|
|
412
|
+
* console.log('Valid schema:', result.data);
|
|
413
|
+
* } else {
|
|
414
|
+
* console.error('Validation errors:', result.error);
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
export function safeValidateSchema(schema: unknown) {
|
|
419
|
+
return AnyComponentSchema.safeParse(schema);
|
|
420
|
+
}
|
|
421
|
+
|
|
274
422
|
/**
|
|
275
423
|
* Version information
|
|
276
424
|
*/
|
package/src/zod/layout.zod.ts
CHANGED
package/src/zod/objectql.zod.ts
CHANGED