@object-ui/types 0.3.0 → 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/README.md +19 -11
- package/dist/api-types.d.ts +7 -0
- package/dist/api-types.d.ts.map +1 -1
- package/dist/api-types.js +4 -6
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -3
- package/dist/base.d.ts +7 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +4 -6
- package/dist/blocks.d.ts +332 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +8 -0
- package/dist/complex.d.ts +68 -1
- package/dist/complex.d.ts.map +1 -1
- package/dist/complex.js +4 -5
- package/dist/crud.d.ts +181 -3
- package/dist/crud.d.ts.map +1 -1
- package/dist/crud.js +4 -6
- package/dist/data-display.d.ts +54 -2
- package/dist/data-display.d.ts.map +1 -1
- package/dist/data-display.js +4 -5
- 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 +22 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +4 -6
- package/dist/disclosure.d.ts +70 -1
- package/dist/disclosure.d.ts.map +1 -1
- package/dist/disclosure.js +4 -5
- package/dist/feedback.d.ts +68 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +4 -5
- package/dist/field-types.d.ts +728 -0
- package/dist/field-types.d.ts.map +1 -0
- package/dist/field-types.js +8 -0
- package/dist/form.d.ts +123 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +4 -5
- package/dist/index.d.ts +48 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -37
- package/dist/layout.d.ts +66 -16
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +4 -6
- package/dist/navigation.d.ts +102 -2
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +4 -5
- package/dist/objectql.d.ts +491 -54
- package/dist/objectql.d.ts.map +1 -1
- package/dist/objectql.js +4 -6
- package/dist/overlay.d.ts +31 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +4 -5
- 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/registry.d.ts +7 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -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/base.zod.d.ts +202 -0
- package/dist/zod/base.zod.d.ts.map +1 -0
- package/dist/zod/base.zod.js +198 -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.d.ts +742 -0
- package/dist/zod/complex.zod.d.ts.map +1 -0
- package/dist/zod/complex.zod.js +233 -0
- 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.d.ts +996 -0
- package/dist/zod/data-display.zod.d.ts.map +1 -0
- package/dist/zod/data-display.zod.js +266 -0
- package/dist/zod/disclosure.zod.d.ts +267 -0
- package/dist/zod/disclosure.zod.d.ts.map +1 -0
- package/dist/zod/disclosure.zod.js +84 -0
- package/dist/zod/feedback.zod.d.ts +538 -0
- package/dist/zod/feedback.zod.d.ts.map +1 -0
- package/dist/zod/feedback.zod.js +127 -0
- package/dist/zod/form.zod.d.ts +1308 -0
- package/dist/zod/form.zod.d.ts.map +1 -0
- package/dist/zod/form.zod.js +406 -0
- package/dist/zod/index.zod.d.ts +4985 -0
- package/dist/zod/index.zod.d.ts.map +1 -0
- package/dist/zod/index.zod.js +183 -0
- package/dist/zod/layout.zod.d.ts +1048 -0
- package/dist/zod/layout.zod.d.ts.map +1 -0
- package/dist/zod/layout.zod.js +241 -0
- package/dist/zod/navigation.zod.d.ts +486 -0
- package/dist/zod/navigation.zod.d.ts.map +1 -0
- package/dist/zod/navigation.zod.js +142 -0
- package/dist/zod/objectql.zod.d.ts +1261 -0
- package/dist/zod/objectql.zod.d.ts.map +1 -0
- package/dist/zod/objectql.zod.js +248 -0
- package/dist/zod/overlay.zod.d.ts +691 -0
- package/dist/zod/overlay.zod.d.ts.map +1 -0
- package/dist/zod/overlay.zod.js +179 -0
- 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 +9 -1
- package/src/__tests__/namespace-exports.test.ts +80 -0
- package/src/__tests__/phase2-schemas.test.ts +639 -0
- package/src/api-types.ts +8 -0
- package/src/app.ts +20 -0
- package/src/base.ts +8 -0
- package/src/blocks.ts +405 -0
- package/src/complex.ts +69 -1
- package/src/crud.ts +185 -3
- package/src/data-display.ts +60 -2
- package/src/data-protocol.ts +1679 -0
- package/src/data.ts +21 -1
- package/src/disclosure.ts +74 -1
- package/src/feedback.ts +76 -2
- package/src/field-types.ts +846 -0
- package/src/form.ts +131 -1
- package/src/index.ts +305 -8
- package/src/layout.ts +70 -15
- package/src/navigation.ts +109 -2
- package/src/objectql.ts +563 -59
- package/src/overlay.ts +35 -1
- package/src/plugin-scope.ts +210 -0
- package/src/registry.ts +8 -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/README.md +329 -0
- package/src/zod/app.zod.ts +72 -0
- package/src/zod/base.zod.ts +229 -0
- package/src/zod/blocks.zod.ts +170 -0
- package/src/zod/complex.zod.ts +258 -0
- package/src/zod/crud.zod.ts +259 -0
- package/src/zod/data-display.zod.ts +290 -0
- package/src/zod/disclosure.zod.ts +92 -0
- package/src/zod/feedback.zod.ts +138 -0
- package/src/zod/form.zod.ts +434 -0
- package/src/zod/index.zod.ts +425 -0
- package/src/zod/layout.zod.ts +262 -0
- package/src/zod/navigation.zod.ts +159 -0
- package/src/zod/objectql.zod.ts +268 -0
- package/src/zod/overlay.zod.ts +196 -0
- 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,170 @@
|
|
|
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 - Block Schema Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for reusable component blocks.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/blocks
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Block Variable Schema
|
|
24
|
+
*/
|
|
25
|
+
export const BlockVariableSchema = z.object({
|
|
26
|
+
name: z.string().describe('Variable name'),
|
|
27
|
+
label: z.string().optional().describe('Display label'),
|
|
28
|
+
type: z.enum(['string', 'number', 'boolean', 'object', 'array', 'component']).optional().describe('Variable type'),
|
|
29
|
+
defaultValue: z.any().optional().describe('Default value'),
|
|
30
|
+
description: z.string().optional().describe('Description/help text'),
|
|
31
|
+
required: z.boolean().optional().describe('Whether this variable is required'),
|
|
32
|
+
validation: z.any().optional().describe('Validation rules'),
|
|
33
|
+
enum: z.array(z.any()).optional().describe('Enum options (for string/number types)'),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Block Slot Schema
|
|
38
|
+
*/
|
|
39
|
+
export const BlockSlotSchema = z.object({
|
|
40
|
+
name: z.string().describe('Slot name'),
|
|
41
|
+
label: z.string().optional().describe('Display label'),
|
|
42
|
+
description: z.string().optional().describe('Description'),
|
|
43
|
+
defaultContent: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Default content'),
|
|
44
|
+
allowedTypes: z.array(z.string()).optional().describe('Allowed component types'),
|
|
45
|
+
maxChildren: z.number().optional().describe('Maximum number of children'),
|
|
46
|
+
required: z.boolean().optional().describe('Whether this slot is required'),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Block Metadata Schema
|
|
51
|
+
*/
|
|
52
|
+
export const BlockMetadataSchema = z.object({
|
|
53
|
+
name: z.string().describe('Block name/identifier'),
|
|
54
|
+
label: z.string().optional().describe('Display label'),
|
|
55
|
+
description: z.string().optional().describe('Block description'),
|
|
56
|
+
category: z.string().optional().describe('Block category'),
|
|
57
|
+
icon: z.string().optional().describe('Block icon'),
|
|
58
|
+
tags: z.array(z.string()).optional().describe('Block tags for search'),
|
|
59
|
+
author: z.string().optional().describe('Author/creator'),
|
|
60
|
+
version: z.string().optional().describe('Version'),
|
|
61
|
+
license: z.string().optional().describe('License'),
|
|
62
|
+
repository: z.string().optional().describe('Repository URL'),
|
|
63
|
+
preview: z.string().optional().describe('Preview image URL'),
|
|
64
|
+
premium: z.boolean().optional().describe('Is this a premium/paid block'),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Block Schema
|
|
69
|
+
*/
|
|
70
|
+
export const BlockSchema = BaseSchema.extend({
|
|
71
|
+
type: z.literal('block'),
|
|
72
|
+
meta: BlockMetadataSchema.optional().describe('Block metadata'),
|
|
73
|
+
variables: z.array(BlockVariableSchema).optional().describe('Block variables/props'),
|
|
74
|
+
slots: z.array(BlockSlotSchema).optional().describe('Block slots for content injection'),
|
|
75
|
+
template: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Block template (component tree)'),
|
|
76
|
+
values: z.record(z.string(), z.any()).optional().describe('Variable values (when using a block)'),
|
|
77
|
+
slotContent: z.record(z.string(), z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)])).optional().describe('Slot content (when using a block)'),
|
|
78
|
+
blockRef: z.string().optional().describe('Block reference (for reusing saved blocks)'),
|
|
79
|
+
editable: z.boolean().optional().describe('Enable edit mode'),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Block Library Item Schema
|
|
84
|
+
*/
|
|
85
|
+
export const BlockLibraryItemSchema = z.object({
|
|
86
|
+
id: z.string().describe('Unique identifier'),
|
|
87
|
+
meta: BlockMetadataSchema.describe('Block metadata'),
|
|
88
|
+
schema: BlockSchema.describe('Block schema'),
|
|
89
|
+
installs: z.number().optional().describe('Installation count'),
|
|
90
|
+
rating: z.number().optional().describe('Rating (1-5)'),
|
|
91
|
+
ratingCount: z.number().optional().describe('Number of ratings'),
|
|
92
|
+
updatedAt: z.string().optional().describe('Last updated timestamp'),
|
|
93
|
+
createdAt: z.string().optional().describe('Created timestamp'),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Block Library Schema
|
|
98
|
+
*/
|
|
99
|
+
export const BlockLibrarySchema = BaseSchema.extend({
|
|
100
|
+
type: z.literal('block-library'),
|
|
101
|
+
apiEndpoint: z.string().optional().describe('Library API endpoint'),
|
|
102
|
+
category: z.string().optional().describe('Filter by category'),
|
|
103
|
+
searchQuery: z.string().optional().describe('Search query'),
|
|
104
|
+
tags: z.array(z.string()).optional().describe('Filter by tags'),
|
|
105
|
+
showPremium: z.boolean().optional().describe('Show premium blocks'),
|
|
106
|
+
blocks: z.array(BlockLibraryItemSchema).optional().describe('Blocks to display'),
|
|
107
|
+
loading: z.boolean().optional().describe('Loading state'),
|
|
108
|
+
onInstall: z.string().optional().describe('Install callback'),
|
|
109
|
+
onPreview: z.string().optional().describe('Preview callback'),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Block Editor Schema
|
|
114
|
+
*/
|
|
115
|
+
export const BlockEditorSchema = BaseSchema.extend({
|
|
116
|
+
type: z.literal('block-editor'),
|
|
117
|
+
block: BlockSchema.optional().describe('Block being edited'),
|
|
118
|
+
showVariables: z.boolean().optional().describe('Show variable editor'),
|
|
119
|
+
showSlots: z.boolean().optional().describe('Show slot editor'),
|
|
120
|
+
showTemplate: z.boolean().optional().describe('Show template editor'),
|
|
121
|
+
showPreview: z.boolean().optional().describe('Show preview'),
|
|
122
|
+
onSave: z.string().optional().describe('Save callback'),
|
|
123
|
+
onCancel: z.string().optional().describe('Cancel callback'),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Block Instance Schema
|
|
128
|
+
*/
|
|
129
|
+
export const BlockInstanceSchema = BaseSchema.extend({
|
|
130
|
+
type: z.literal('block-instance'),
|
|
131
|
+
blockId: z.string().describe('Block reference ID'),
|
|
132
|
+
blockName: z.string().optional().describe('Block name (for local blocks)'),
|
|
133
|
+
values: z.record(z.string(), z.any()).optional().describe('Variable values'),
|
|
134
|
+
slotContent: z.record(z.string(), z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)])).optional().describe('Slot content'),
|
|
135
|
+
overrideStyles: z.boolean().optional().describe('Override styles'),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Component Schema
|
|
140
|
+
*/
|
|
141
|
+
export const ComponentSchema = BaseSchema.extend({
|
|
142
|
+
type: z.literal('component'),
|
|
143
|
+
componentName: z.string().optional().describe('Component name/identifier'),
|
|
144
|
+
props: z.record(z.string(), z.any()).optional().describe('Component props'),
|
|
145
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Component children'),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Union of all block schemas
|
|
150
|
+
*/
|
|
151
|
+
export const BlockComponentSchema = z.union([
|
|
152
|
+
BlockSchema,
|
|
153
|
+
BlockLibrarySchema,
|
|
154
|
+
BlockEditorSchema,
|
|
155
|
+
BlockInstanceSchema,
|
|
156
|
+
ComponentSchema,
|
|
157
|
+
]);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Export type inference helpers
|
|
161
|
+
*/
|
|
162
|
+
export type BlockVariableSchemaType = z.infer<typeof BlockVariableSchema>;
|
|
163
|
+
export type BlockSlotSchemaType = z.infer<typeof BlockSlotSchema>;
|
|
164
|
+
export type BlockMetadataSchemaType = z.infer<typeof BlockMetadataSchema>;
|
|
165
|
+
export type BlockSchemaType = z.infer<typeof BlockSchema>;
|
|
166
|
+
export type BlockLibraryItemSchemaType = z.infer<typeof BlockLibraryItemSchema>;
|
|
167
|
+
export type BlockLibrarySchemaType = z.infer<typeof BlockLibrarySchema>;
|
|
168
|
+
export type BlockEditorSchemaType = z.infer<typeof BlockEditorSchema>;
|
|
169
|
+
export type BlockInstanceSchemaType = z.infer<typeof BlockInstanceSchema>;
|
|
170
|
+
export type ComponentSchemaType = z.infer<typeof ComponentSchema>;
|
|
@@ -0,0 +1,258 @@
|
|
|
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 - Complex Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for advanced/composite components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/complex
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Kanban Card Schema
|
|
24
|
+
*/
|
|
25
|
+
export const KanbanCardSchema = z.object({
|
|
26
|
+
id: z.string().describe('Card ID'),
|
|
27
|
+
title: z.string().describe('Card title'),
|
|
28
|
+
description: z.string().optional().describe('Card description'),
|
|
29
|
+
labels: z.array(z.string()).optional().describe('Card labels'),
|
|
30
|
+
assignees: z.array(z.string()).optional().describe('Card assignees'),
|
|
31
|
+
dueDate: z.union([z.string(), z.date()]).optional().describe('Due date'),
|
|
32
|
+
priority: z.enum(['low', 'medium', 'high', 'critical']).optional().describe('Card priority'),
|
|
33
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Custom content'),
|
|
34
|
+
data: z.any().optional().describe('Custom card data'),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Kanban Column Schema
|
|
39
|
+
*/
|
|
40
|
+
export const KanbanColumnSchema = z.object({
|
|
41
|
+
id: z.string().describe('Column ID'),
|
|
42
|
+
title: z.string().describe('Column title'),
|
|
43
|
+
items: z.array(KanbanCardSchema).describe('Column cards'),
|
|
44
|
+
color: z.string().optional().describe('Column color'),
|
|
45
|
+
limit: z.number().optional().describe('Card limit'),
|
|
46
|
+
collapsed: z.boolean().optional().describe('Whether column is collapsed'),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Kanban Schema - Kanban board component
|
|
51
|
+
*/
|
|
52
|
+
export const KanbanSchema = BaseSchema.extend({
|
|
53
|
+
type: z.literal('kanban'),
|
|
54
|
+
columns: z.array(KanbanColumnSchema).describe('Kanban columns'),
|
|
55
|
+
draggable: z.boolean().optional().describe('Whether cards are draggable'),
|
|
56
|
+
onCardMove: z.function().optional().describe('Card move handler'),
|
|
57
|
+
onCardClick: z.function().optional().describe('Card click handler'),
|
|
58
|
+
onColumnAdd: z.function().optional().describe('Column add handler'),
|
|
59
|
+
onCardAdd: z.function().optional().describe('Card add handler'),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Calendar View Mode
|
|
64
|
+
*/
|
|
65
|
+
export const CalendarViewModeSchema = z.enum(['month', 'week', 'day', 'agenda']);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Calendar Event Schema
|
|
69
|
+
*/
|
|
70
|
+
export const CalendarEventSchema = z.object({
|
|
71
|
+
id: z.string().describe('Event ID'),
|
|
72
|
+
title: z.string().describe('Event title'),
|
|
73
|
+
description: z.string().optional().describe('Event description'),
|
|
74
|
+
start: z.union([z.string(), z.date()]).describe('Event start time'),
|
|
75
|
+
end: z.union([z.string(), z.date()]).describe('Event end time'),
|
|
76
|
+
allDay: z.boolean().optional().describe('Whether event is all-day'),
|
|
77
|
+
color: z.string().optional().describe('Event color'),
|
|
78
|
+
data: z.any().optional().describe('Custom event data'),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Calendar View Schema - Calendar component
|
|
83
|
+
*/
|
|
84
|
+
export const CalendarViewSchema = BaseSchema.extend({
|
|
85
|
+
type: z.literal('calendar-view'),
|
|
86
|
+
events: z.array(CalendarEventSchema).describe('Calendar events'),
|
|
87
|
+
defaultView: CalendarViewModeSchema.optional().describe('Default view mode'),
|
|
88
|
+
view: CalendarViewModeSchema.optional().describe('Controlled view mode'),
|
|
89
|
+
defaultDate: z.union([z.string(), z.date()]).optional().describe('Default date'),
|
|
90
|
+
date: z.union([z.string(), z.date()]).optional().describe('Controlled date'),
|
|
91
|
+
views: z.array(CalendarViewModeSchema).optional().describe('Available views'),
|
|
92
|
+
editable: z.boolean().optional().describe('Whether events are editable'),
|
|
93
|
+
onEventClick: z.function().optional().describe('Event click handler'),
|
|
94
|
+
onEventCreate: z.function().optional().describe('Event create handler'),
|
|
95
|
+
onEventUpdate: z.function().optional().describe('Event update handler'),
|
|
96
|
+
onDateChange: z.function().optional().describe('Date change handler'),
|
|
97
|
+
onViewChange: z.function().optional().describe('View change handler'),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Filter Operator Enum
|
|
102
|
+
*/
|
|
103
|
+
export const FilterOperatorSchema = z.enum([
|
|
104
|
+
'equals',
|
|
105
|
+
'not_equals',
|
|
106
|
+
'contains',
|
|
107
|
+
'not_contains',
|
|
108
|
+
'starts_with',
|
|
109
|
+
'ends_with',
|
|
110
|
+
'greater_than',
|
|
111
|
+
'greater_than_or_equal',
|
|
112
|
+
'less_than',
|
|
113
|
+
'less_than_or_equal',
|
|
114
|
+
'in',
|
|
115
|
+
'not_in',
|
|
116
|
+
'is_null',
|
|
117
|
+
'is_not_null',
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Filter Condition Schema
|
|
122
|
+
*/
|
|
123
|
+
export const FilterConditionSchema: z.ZodType<any> = z.lazy(() =>
|
|
124
|
+
z.object({
|
|
125
|
+
field: z.string().describe('Field name'),
|
|
126
|
+
operator: FilterOperatorSchema.describe('Filter operator'),
|
|
127
|
+
value: z.any().optional().describe('Filter value'),
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Filter Group Schema
|
|
133
|
+
*/
|
|
134
|
+
export const FilterGroupSchema: z.ZodType<any> = z.lazy(() =>
|
|
135
|
+
z.object({
|
|
136
|
+
operator: z.enum(['and', 'or']).describe('Group operator'),
|
|
137
|
+
conditions: z.array(z.union([FilterConditionSchema, FilterGroupSchema])).describe('Conditions or sub-groups'),
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Filter Field Schema
|
|
143
|
+
*/
|
|
144
|
+
export const FilterFieldSchema = z.object({
|
|
145
|
+
name: z.string().describe('Field name'),
|
|
146
|
+
label: z.string().describe('Field label'),
|
|
147
|
+
type: z.enum(['string', 'number', 'date', 'boolean', 'select']).describe('Field type'),
|
|
148
|
+
operators: z.array(FilterOperatorSchema).optional().describe('Available operators'),
|
|
149
|
+
options: z.array(z.object({
|
|
150
|
+
label: z.string(),
|
|
151
|
+
value: z.any(),
|
|
152
|
+
})).optional().describe('Options for select type'),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Filter Builder Schema - Filter builder component
|
|
157
|
+
*/
|
|
158
|
+
export const FilterBuilderSchema = BaseSchema.extend({
|
|
159
|
+
type: z.literal('filter-builder'),
|
|
160
|
+
fields: z.array(FilterFieldSchema).describe('Available filter fields'),
|
|
161
|
+
defaultValue: z.union([FilterConditionSchema, FilterGroupSchema]).optional().describe('Default filter value'),
|
|
162
|
+
value: z.union([FilterConditionSchema, FilterGroupSchema]).optional().describe('Controlled filter value'),
|
|
163
|
+
onChange: z.function().optional().describe('Change handler'),
|
|
164
|
+
allowGroups: z.boolean().optional().describe('Allow grouped conditions'),
|
|
165
|
+
maxDepth: z.number().optional().describe('Maximum nesting depth'),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Carousel Item Schema
|
|
170
|
+
*/
|
|
171
|
+
export const CarouselItemSchema = z.object({
|
|
172
|
+
id: z.string().optional().describe('Item ID'),
|
|
173
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Item content'),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Carousel Schema - Carousel component
|
|
178
|
+
*/
|
|
179
|
+
export const CarouselSchema = BaseSchema.extend({
|
|
180
|
+
type: z.literal('carousel'),
|
|
181
|
+
items: z.array(CarouselItemSchema).describe('Carousel items'),
|
|
182
|
+
autoPlay: z.number().optional().describe('Auto-play interval (ms)'),
|
|
183
|
+
showArrows: z.boolean().optional().describe('Show navigation arrows'),
|
|
184
|
+
showDots: z.boolean().optional().describe('Show navigation dots'),
|
|
185
|
+
loop: z.boolean().optional().describe('Enable infinite loop'),
|
|
186
|
+
itemsPerView: z.number().optional().describe('Items per view'),
|
|
187
|
+
gap: z.number().optional().describe('Gap between items'),
|
|
188
|
+
onSlideChange: z.function().optional().describe('Slide change handler'),
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Chat Message Schema
|
|
193
|
+
*/
|
|
194
|
+
export const ChatMessageSchema = z.object({
|
|
195
|
+
id: z.string().describe('Message ID'),
|
|
196
|
+
role: z.enum(['user', 'assistant', 'system']).describe('Message role'),
|
|
197
|
+
content: z.string().describe('Message content'),
|
|
198
|
+
timestamp: z.union([z.string(), z.date()]).optional().describe('Message timestamp'),
|
|
199
|
+
metadata: z.record(z.string(), z.any()).optional().describe('Custom metadata'),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Chatbot Schema - Chatbot component
|
|
204
|
+
*/
|
|
205
|
+
export const ChatbotSchema = BaseSchema.extend({
|
|
206
|
+
type: z.literal('chatbot'),
|
|
207
|
+
messages: z.array(ChatMessageSchema).describe('Chat messages'),
|
|
208
|
+
placeholder: z.string().optional().describe('Input placeholder'),
|
|
209
|
+
loading: z.boolean().optional().describe('Whether chat is loading'),
|
|
210
|
+
onSendMessage: z.function().optional().describe('Send message handler'),
|
|
211
|
+
showAvatars: z.boolean().optional().describe('Show user avatars'),
|
|
212
|
+
userAvatar: z.string().optional().describe('User avatar URL'),
|
|
213
|
+
assistantAvatar: z.string().optional().describe('Assistant avatar URL'),
|
|
214
|
+
markdown: z.boolean().optional().describe('Enable markdown rendering'),
|
|
215
|
+
height: z.union([z.string(), z.number()]).optional().describe('Chatbot height'),
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Dashboard Widget Layout Schema
|
|
220
|
+
*/
|
|
221
|
+
export const DashboardWidgetLayoutSchema = z.object({
|
|
222
|
+
x: z.number().describe('Grid x position'),
|
|
223
|
+
y: z.number().describe('Grid y position'),
|
|
224
|
+
w: z.number().describe('Grid width'),
|
|
225
|
+
h: z.number().describe('Grid height'),
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Dashboard Widget Schema
|
|
230
|
+
*/
|
|
231
|
+
export const DashboardWidgetSchema = z.object({
|
|
232
|
+
id: z.string().describe('Widget ID'),
|
|
233
|
+
title: z.string().optional().describe('Widget Title'),
|
|
234
|
+
component: SchemaNodeSchema.describe('Widget Component'),
|
|
235
|
+
layout: DashboardWidgetLayoutSchema.optional().describe('Widget Layout'),
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Dashboard Schema - Dashboard component
|
|
240
|
+
*/
|
|
241
|
+
export const DashboardSchema = BaseSchema.extend({
|
|
242
|
+
type: z.literal('dashboard'),
|
|
243
|
+
columns: z.number().optional().describe('Number of columns'),
|
|
244
|
+
gap: z.number().optional().describe('Grid gap'),
|
|
245
|
+
widgets: z.array(DashboardWidgetSchema).describe('Dashboard widgets'),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Complex Schema Union - All complex component schemas
|
|
250
|
+
*/
|
|
251
|
+
export const ComplexSchema = z.union([
|
|
252
|
+
KanbanSchema,
|
|
253
|
+
CalendarViewSchema,
|
|
254
|
+
FilterBuilderSchema,
|
|
255
|
+
CarouselSchema,
|
|
256
|
+
ChatbotSchema,
|
|
257
|
+
DashboardSchema,
|
|
258
|
+
]);
|