@object-ui/types 0.3.1 → 2.0.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 (141) hide show
  1. package/README.md +1 -1
  2. package/dist/ai.d.ts +376 -0
  3. package/dist/ai.d.ts.map +1 -0
  4. package/dist/ai.js +8 -0
  5. package/dist/app.d.ts +10 -0
  6. package/dist/app.d.ts.map +1 -1
  7. package/dist/blocks.d.ts +332 -0
  8. package/dist/blocks.d.ts.map +1 -0
  9. package/dist/blocks.js +8 -0
  10. package/dist/crud.d.ts +177 -3
  11. package/dist/crud.d.ts.map +1 -1
  12. package/dist/data-display.d.ts +35 -0
  13. package/dist/data-display.d.ts.map +1 -1
  14. package/dist/data-protocol.d.ts +1268 -0
  15. package/dist/data-protocol.d.ts.map +1 -0
  16. package/dist/data-protocol.js +8 -0
  17. package/dist/data.d.ts +74 -1
  18. package/dist/data.d.ts.map +1 -1
  19. package/dist/designer.d.ts +473 -0
  20. package/dist/designer.d.ts.map +1 -0
  21. package/dist/designer.js +8 -0
  22. package/dist/field-types.d.ts +353 -11
  23. package/dist/field-types.d.ts.map +1 -1
  24. package/dist/form.d.ts +35 -1
  25. package/dist/form.d.ts.map +1 -1
  26. package/dist/index.d.ts +58 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +18 -0
  29. package/dist/layout.d.ts +63 -8
  30. package/dist/layout.d.ts.map +1 -1
  31. package/dist/mobile.d.ts +186 -0
  32. package/dist/mobile.d.ts.map +1 -0
  33. package/dist/mobile.js +8 -0
  34. package/dist/objectql.d.ts +337 -89
  35. package/dist/objectql.d.ts.map +1 -1
  36. package/dist/permissions.d.ts +150 -0
  37. package/dist/permissions.d.ts.map +1 -0
  38. package/dist/permissions.js +8 -0
  39. package/dist/plugin-scope.d.ts +194 -0
  40. package/dist/plugin-scope.d.ts.map +1 -0
  41. package/dist/plugin-scope.js +8 -0
  42. package/dist/reports.d.ts +336 -0
  43. package/dist/reports.d.ts.map +1 -0
  44. package/dist/reports.js +8 -0
  45. package/dist/tenant.d.ts +138 -0
  46. package/dist/tenant.d.ts.map +1 -0
  47. package/dist/tenant.js +8 -0
  48. package/dist/theme.d.ts +180 -0
  49. package/dist/theme.d.ts.map +1 -0
  50. package/dist/theme.js +8 -0
  51. package/dist/ui-action.d.ts +290 -0
  52. package/dist/ui-action.d.ts.map +1 -0
  53. package/dist/ui-action.js +8 -0
  54. package/dist/views.d.ts +427 -0
  55. package/dist/views.d.ts.map +1 -0
  56. package/dist/views.js +8 -0
  57. package/dist/widget.d.ts +181 -0
  58. package/dist/widget.d.ts.map +1 -0
  59. package/dist/widget.js +8 -0
  60. package/dist/workflow.d.ts +340 -0
  61. package/dist/workflow.d.ts.map +1 -0
  62. package/dist/workflow.js +8 -0
  63. package/dist/zod/app.zod.d.ts +120 -0
  64. package/dist/zod/app.zod.d.ts.map +1 -0
  65. package/dist/zod/app.zod.js +60 -0
  66. package/dist/zod/blocks.zod.d.ts +834 -0
  67. package/dist/zod/blocks.zod.d.ts.map +1 -0
  68. package/dist/zod/blocks.zod.js +145 -0
  69. package/dist/zod/complex.zod.d.ts +4 -4
  70. package/dist/zod/complex.zod.js +1 -1
  71. package/dist/zod/crud.zod.d.ts +598 -0
  72. package/dist/zod/crud.zod.d.ts.map +1 -0
  73. package/dist/zod/crud.zod.js +230 -0
  74. package/dist/zod/data-display.zod.js +1 -1
  75. package/dist/zod/disclosure.zod.js +1 -1
  76. package/dist/zod/feedback.zod.d.ts +10 -10
  77. package/dist/zod/feedback.zod.js +1 -1
  78. package/dist/zod/form.zod.d.ts +4 -4
  79. package/dist/zod/form.zod.js +1 -1
  80. package/dist/zod/index.zod.d.ts +2032 -30
  81. package/dist/zod/index.zod.d.ts.map +1 -1
  82. package/dist/zod/index.zod.js +96 -19
  83. package/dist/zod/layout.zod.d.ts +134 -2
  84. package/dist/zod/layout.zod.d.ts.map +1 -1
  85. package/dist/zod/layout.zod.js +35 -1
  86. package/dist/zod/navigation.zod.js +1 -1
  87. package/dist/zod/objectql.zod.d.ts +34 -18
  88. package/dist/zod/objectql.zod.d.ts.map +1 -1
  89. package/dist/zod/objectql.zod.js +9 -1
  90. package/dist/zod/overlay.zod.js +1 -1
  91. package/dist/zod/reports.zod.d.ts +1628 -0
  92. package/dist/zod/reports.zod.d.ts.map +1 -0
  93. package/dist/zod/reports.zod.js +152 -0
  94. package/dist/zod/theme.zod.d.ts +1292 -0
  95. package/dist/zod/theme.zod.d.ts.map +1 -0
  96. package/dist/zod/theme.zod.js +260 -0
  97. package/dist/zod/views.zod.d.ts +675 -0
  98. package/dist/zod/views.zod.d.ts.map +1 -0
  99. package/dist/zod/views.zod.js +159 -0
  100. package/package.json +3 -2
  101. package/src/__tests__/namespace-exports.test.ts +36 -0
  102. package/src/__tests__/phase2-schemas.test.ts +634 -0
  103. package/src/ai.ts +454 -0
  104. package/src/app.ts +12 -0
  105. package/src/blocks.ts +405 -0
  106. package/src/crud.ts +180 -3
  107. package/src/data-display.ts +31 -0
  108. package/src/data-protocol.ts +1679 -0
  109. package/src/data.ts +84 -1
  110. package/src/designer.ts +509 -0
  111. package/src/field-types.ts +392 -11
  112. package/src/form.ts +35 -1
  113. package/src/index.ts +426 -0
  114. package/src/layout.ts +66 -8
  115. package/src/mobile.ts +205 -0
  116. package/src/objectql.ts +412 -94
  117. package/src/permissions.ts +166 -0
  118. package/src/plugin-scope.ts +210 -0
  119. package/src/reports.ts +408 -0
  120. package/src/tenant.ts +153 -0
  121. package/src/theme.ts +238 -0
  122. package/src/ui-action.ts +415 -0
  123. package/src/views.ts +436 -0
  124. package/src/widget.ts +197 -0
  125. package/src/workflow.ts +409 -0
  126. package/src/zod/app.zod.ts +72 -0
  127. package/src/zod/blocks.zod.ts +170 -0
  128. package/src/zod/complex.zod.ts +1 -1
  129. package/src/zod/crud.zod.ts +259 -0
  130. package/src/zod/data-display.zod.ts +1 -1
  131. package/src/zod/disclosure.zod.ts +1 -1
  132. package/src/zod/feedback.zod.ts +1 -1
  133. package/src/zod/form.zod.ts +1 -1
  134. package/src/zod/index.zod.ts +178 -19
  135. package/src/zod/layout.zod.ts +39 -1
  136. package/src/zod/navigation.zod.ts +1 -1
  137. package/src/zod/objectql.zod.ts +9 -1
  138. package/src/zod/overlay.zod.ts +1 -1
  139. package/src/zod/reports.zod.ts +183 -0
  140. package/src/zod/theme.zod.ts +296 -0
  141. package/src/zod/views.zod.ts +182 -0
@@ -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>;