@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,166 @@
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 - Permission & RBAC Types
11
+ *
12
+ * Complete RBAC (Role-Based Access Control) type definitions for
13
+ * object/field/row-level permissions aligned with @objectstack/spec v2.0.1.
14
+ *
15
+ * @module permissions
16
+ * @packageDocumentation
17
+ */
18
+
19
+ // ============================================================================
20
+ // Role-Based Access Control (RBAC)
21
+ // ============================================================================
22
+
23
+ /** Standard CRUD permission actions */
24
+ export type PermissionAction = 'create' | 'read' | 'update' | 'delete' | 'export' | 'import' | 'share' | 'admin';
25
+
26
+ /** Permission effect */
27
+ export type PermissionEffect = 'allow' | 'deny';
28
+
29
+ /** Role definition for RBAC */
30
+ export interface RoleDefinition {
31
+ /** Unique role identifier */
32
+ name: string;
33
+ /** Display label */
34
+ label: string;
35
+ /** Role description */
36
+ description?: string;
37
+ /** Parent role for inheritance */
38
+ inherits?: string[];
39
+ /** Whether this is a system role */
40
+ system?: boolean;
41
+ /** Object-level permissions */
42
+ permissions: ObjectLevelPermission[];
43
+ }
44
+
45
+ /** Object-level permission assignment */
46
+ export interface ObjectLevelPermission {
47
+ /** Target object name */
48
+ object: string;
49
+ /** Allowed actions */
50
+ actions: PermissionAction[];
51
+ /** Permission effect */
52
+ effect?: PermissionEffect;
53
+ /** Conditions for conditional permissions */
54
+ conditions?: PermissionCondition[];
55
+ }
56
+
57
+ /** Field-level permission */
58
+ export interface FieldLevelPermission {
59
+ /** Target field name */
60
+ field: string;
61
+ /** Read permission */
62
+ read?: boolean;
63
+ /** Write permission */
64
+ write?: boolean;
65
+ /** Permission effect */
66
+ effect?: PermissionEffect;
67
+ /** Mask value for restricted fields (e.g., '****' for SSN) */
68
+ mask?: string;
69
+ }
70
+
71
+ /** Row-level permission (record-level security) */
72
+ export interface RowLevelPermission {
73
+ /** Filter expression to scope visible records */
74
+ filter: string;
75
+ /** Actions allowed on matching records */
76
+ actions: PermissionAction[];
77
+ /** Description of the rule */
78
+ description?: string;
79
+ }
80
+
81
+ /** Permission condition for conditional access */
82
+ export interface PermissionCondition {
83
+ /** Field to evaluate */
84
+ field: string;
85
+ /** Comparison operator */
86
+ operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'contains' | 'is_null' | 'is_not_null';
87
+ /** Value to compare */
88
+ value: unknown;
89
+ }
90
+
91
+ /** Complete permission configuration for an object */
92
+ export interface ObjectPermissionConfig {
93
+ /** Object name */
94
+ object: string;
95
+ /** Default permissions for unauthenticated users */
96
+ publicAccess?: PermissionAction[];
97
+ /** Role-based permissions */
98
+ roles: Record<string, {
99
+ actions: PermissionAction[];
100
+ fieldPermissions?: FieldLevelPermission[];
101
+ rowPermissions?: RowLevelPermission[];
102
+ }>;
103
+ /** Field-level permission defaults */
104
+ fieldDefaults?: FieldLevelPermission[];
105
+ /** Sharing rules */
106
+ sharingRules?: SharingRuleConfig[];
107
+ }
108
+
109
+ /** Sharing rule configuration */
110
+ export interface SharingRuleConfig {
111
+ /** Rule name */
112
+ name: string;
113
+ /** Share with type */
114
+ type: 'role' | 'user' | 'group' | 'public';
115
+ /** Target entity (role name, user ID, group name) */
116
+ entity: string;
117
+ /** Permitted actions */
118
+ actions: PermissionAction[];
119
+ /** Filter to scope which records are shared */
120
+ filter?: string;
121
+ }
122
+
123
+ /** Permission check result */
124
+ export interface PermissionCheckResult {
125
+ /** Whether the action is allowed */
126
+ allowed: boolean;
127
+ /** Reason for denial */
128
+ reason?: string;
129
+ /** Applicable field restrictions */
130
+ fieldRestrictions?: FieldLevelPermission[];
131
+ /** Row filter to apply */
132
+ rowFilter?: string;
133
+ }
134
+
135
+ /** Permission context for evaluating permissions */
136
+ export interface PermissionContext {
137
+ /** Current user */
138
+ user: {
139
+ id: string;
140
+ roles: string[];
141
+ groups?: string[];
142
+ [key: string]: unknown;
143
+ };
144
+ /** Target object */
145
+ object: string;
146
+ /** Target action */
147
+ action: PermissionAction;
148
+ /** Target record (for row-level checks) */
149
+ record?: Record<string, unknown>;
150
+ /** Target field (for field-level checks) */
151
+ field?: string;
152
+ }
153
+
154
+ /** Permission guard configuration for UI components */
155
+ export interface PermissionGuardConfig {
156
+ /** Required permission */
157
+ permission: string | PermissionAction;
158
+ /** Target object */
159
+ object?: string;
160
+ /** Fallback behavior when denied */
161
+ fallback?: 'hide' | 'disable' | 'redirect' | 'custom';
162
+ /** Custom fallback component type */
163
+ fallbackComponent?: string;
164
+ /** Redirect path for 'redirect' fallback */
165
+ redirectPath?: string;
166
+ }
@@ -0,0 +1,210 @@
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 - Plugin Scope Isolation
11
+ *
12
+ * Section 3.3: Plugin scope isolation types to prevent conflicts between plugins.
13
+ * Provides scoped component registration, state management, and event bus.
14
+ *
15
+ * @module plugin-scope
16
+ * @packageDocumentation
17
+ */
18
+
19
+ /**
20
+ * Plugin Scope Interface
21
+ *
22
+ * Provides isolated access to the component registry, state management,
23
+ * and event bus for a specific plugin, preventing conflicts between plugins.
24
+ */
25
+ export interface PluginScope {
26
+ /**
27
+ * Plugin name
28
+ */
29
+ name: string;
30
+
31
+ /**
32
+ * Plugin version
33
+ */
34
+ version: string;
35
+
36
+ /**
37
+ * Register a component in the scoped namespace.
38
+ * Components will be registered as "pluginName:type" to prevent conflicts.
39
+ *
40
+ * @param type - Component type identifier (e.g., 'table', 'chart')
41
+ * @param component - Component renderer
42
+ * @param meta - Optional component metadata
43
+ *
44
+ * @example
45
+ * // Plugin 'my-grid' registers a 'table' component
46
+ * // Registered as 'my-grid:table'
47
+ * scope.registerComponent('table', TableComponent, {
48
+ * label: 'Data Table',
49
+ * category: 'data'
50
+ * });
51
+ */
52
+ registerComponent(type: string, component: any, meta?: ComponentMeta): void;
53
+
54
+ /**
55
+ * Get a component from the scoped namespace.
56
+ * First tries scoped lookup (pluginName:type), then falls back to global.
57
+ *
58
+ * @param type - Component type identifier
59
+ * @returns Component renderer or undefined if not found
60
+ */
61
+ getComponent(type: string): any | undefined;
62
+
63
+ /**
64
+ * Scoped state management.
65
+ * Each plugin has its own isolated state that won't conflict with others.
66
+ *
67
+ * @param key - State key unique to this plugin
68
+ * @param initialValue - Initial state value
69
+ * @returns Tuple of [currentValue, setValue]
70
+ *
71
+ * @example
72
+ * const [config, setConfig] = scope.useState('config', { theme: 'light' });
73
+ */
74
+ useState<T>(key: string, initialValue: T): [T, (value: T | ((prev: T) => T)) => void];
75
+
76
+ /**
77
+ * Get scoped state value without setter.
78
+ *
79
+ * @param key - State key
80
+ * @returns Current state value or undefined
81
+ */
82
+ getState<T>(key: string): T | undefined;
83
+
84
+ /**
85
+ * Set scoped state value directly.
86
+ *
87
+ * @param key - State key
88
+ * @param value - New state value
89
+ */
90
+ setState<T>(key: string, value: T): void;
91
+
92
+ /**
93
+ * Subscribe to scoped events.
94
+ * Events are namespaced to prevent cross-plugin conflicts.
95
+ *
96
+ * @param event - Event name (will be prefixed with plugin namespace)
97
+ * @param handler - Event handler function
98
+ * @returns Unsubscribe function
99
+ *
100
+ * @example
101
+ * const unsubscribe = scope.on('data-updated', (data) => {
102
+ * console.log('Scoped event received:', data);
103
+ * });
104
+ */
105
+ on(event: string, handler: PluginEventHandler): () => void;
106
+
107
+ /**
108
+ * Emit a scoped event.
109
+ * Only subscribers within this plugin scope will receive it.
110
+ *
111
+ * @param event - Event name
112
+ * @param data - Event data
113
+ *
114
+ * @example
115
+ * scope.emit('data-updated', { rows: 100 });
116
+ */
117
+ emit(event: string, data?: any): void;
118
+
119
+ /**
120
+ * Emit a global event that all plugins can receive.
121
+ * Use sparingly for cross-plugin communication.
122
+ *
123
+ * @param event - Event name
124
+ * @param data - Event data
125
+ */
126
+ emitGlobal(event: string, data?: any): void;
127
+
128
+ /**
129
+ * Subscribe to global events from any plugin.
130
+ *
131
+ * @param event - Event name
132
+ * @param handler - Event handler function
133
+ * @returns Unsubscribe function
134
+ */
135
+ onGlobal(event: string, handler: PluginEventHandler): () => void;
136
+
137
+ /**
138
+ * Clean up all plugin resources (state, event listeners, etc.)
139
+ * Called automatically when plugin is unloaded.
140
+ */
141
+ cleanup(): void;
142
+ }
143
+
144
+ /**
145
+ * Component metadata for registration
146
+ */
147
+ export interface ComponentMeta {
148
+ label?: string;
149
+ icon?: string;
150
+ category?: string;
151
+ inputs?: ComponentInput[];
152
+ defaultProps?: Record<string, any>;
153
+ defaultChildren?: any[];
154
+ examples?: Record<string, any>;
155
+ isContainer?: boolean;
156
+ resizable?: boolean;
157
+ resizeConstraints?: {
158
+ width?: boolean;
159
+ height?: boolean;
160
+ minWidth?: number;
161
+ maxWidth?: number;
162
+ minHeight?: number;
163
+ maxHeight?: number;
164
+ };
165
+ }
166
+
167
+ /**
168
+ * Component input definition
169
+ */
170
+ export interface ComponentInput {
171
+ name: string;
172
+ type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'color' | 'date' | 'code' | 'file' | 'slot';
173
+ label?: string;
174
+ defaultValue?: any;
175
+ required?: boolean;
176
+ enum?: string[] | { label: string; value: any }[];
177
+ description?: string;
178
+ advanced?: boolean;
179
+ inputType?: string;
180
+ }
181
+
182
+ /**
183
+ * Event handler type
184
+ */
185
+ export type PluginEventHandler = (data?: any) => void;
186
+
187
+ /**
188
+ * Plugin scope configuration
189
+ */
190
+ export interface PluginScopeConfig {
191
+ /**
192
+ * Whether to enable state isolation (default: true)
193
+ */
194
+ enableStateIsolation?: boolean;
195
+
196
+ /**
197
+ * Whether to enable event isolation (default: true)
198
+ */
199
+ enableEventIsolation?: boolean;
200
+
201
+ /**
202
+ * Whether to allow global event access (default: true)
203
+ */
204
+ allowGlobalEvents?: boolean;
205
+
206
+ /**
207
+ * Maximum state size per plugin in bytes (default: 5MB)
208
+ */
209
+ maxStateSize?: number;
210
+ }