@object-ui/types 0.5.0 → 3.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.
- package/README.md +1 -1
- package/dist/ai.d.ts +376 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +8 -0
- package/dist/app.d.ts +2 -2
- package/dist/complex.d.ts +2 -0
- package/dist/complex.d.ts.map +1 -1
- package/dist/crud.d.ts +3 -0
- package/dist/crud.d.ts.map +1 -1
- package/dist/data-display.d.ts +40 -0
- package/dist/data-display.d.ts.map +1 -1
- package/dist/data-protocol.d.ts +19 -19
- package/dist/data.d.ts +77 -0
- package/dist/data.d.ts.map +1 -1
- package/dist/designer.d.ts +473 -0
- package/dist/designer.d.ts.map +1 -0
- package/dist/designer.js +8 -0
- package/dist/form.d.ts +35 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/index.d.ts +46 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/layout.d.ts +63 -8
- package/dist/layout.d.ts.map +1 -1
- package/dist/mobile.d.ts +186 -0
- package/dist/mobile.d.ts.map +1 -0
- package/dist/mobile.js +8 -0
- package/dist/objectql.d.ts +341 -88
- package/dist/objectql.d.ts.map +1 -1
- package/dist/permissions.d.ts +150 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +8 -0
- package/dist/tenant.d.ts +138 -0
- package/dist/tenant.d.ts.map +1 -0
- package/dist/tenant.js +8 -0
- package/dist/theme.d.ts +115 -224
- package/dist/theme.d.ts.map +1 -1
- package/dist/ui-action.d.ts +126 -11
- package/dist/ui-action.d.ts.map +1 -1
- package/dist/views.d.ts +20 -0
- package/dist/views.d.ts.map +1 -1
- package/dist/widget.d.ts +181 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +8 -0
- package/dist/workflow.d.ts +340 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +8 -0
- package/dist/zod/blocks.zod.d.ts +2 -2
- package/dist/zod/blocks.zod.d.ts.map +1 -1
- package/dist/zod/blocks.zod.js +1 -1
- package/dist/zod/complex.zod.d.ts +6 -6
- package/dist/zod/complex.zod.d.ts.map +1 -1
- package/dist/zod/complex.zod.js +1 -1
- package/dist/zod/crud.zod.d.ts +5 -5
- package/dist/zod/data-display.zod.d.ts +2 -2
- package/dist/zod/data-display.zod.d.ts.map +1 -1
- package/dist/zod/data-display.zod.js +1 -1
- package/dist/zod/disclosure.zod.d.ts +2 -2
- package/dist/zod/disclosure.zod.d.ts.map +1 -1
- package/dist/zod/disclosure.zod.js +1 -1
- package/dist/zod/feedback.zod.d.ts +12 -12
- package/dist/zod/feedback.zod.d.ts.map +1 -1
- package/dist/zod/feedback.zod.js +1 -1
- package/dist/zod/form.zod.d.ts +6 -6
- package/dist/zod/form.zod.d.ts.map +1 -1
- package/dist/zod/form.zod.js +1 -1
- package/dist/zod/index.zod.d.ts +337 -146
- package/dist/zod/index.zod.d.ts.map +1 -1
- package/dist/zod/index.zod.js +4 -4
- package/dist/zod/layout.zod.d.ts +134 -2
- package/dist/zod/layout.zod.d.ts.map +1 -1
- package/dist/zod/layout.zod.js +35 -1
- package/dist/zod/navigation.zod.d.ts +2 -2
- package/dist/zod/navigation.zod.d.ts.map +1 -1
- package/dist/zod/navigation.zod.js +1 -1
- package/dist/zod/objectql.zod.d.ts +32 -16
- package/dist/zod/objectql.zod.d.ts.map +1 -1
- package/dist/zod/objectql.zod.js +8 -0
- package/dist/zod/overlay.zod.d.ts +2 -2
- package/dist/zod/overlay.zod.d.ts.map +1 -1
- package/dist/zod/overlay.zod.js +1 -1
- package/dist/zod/reports.zod.d.ts +19 -19
- package/dist/zod/reports.zod.d.ts.map +1 -1
- package/dist/zod/reports.zod.js +1 -1
- package/dist/zod/theme.zod.d.ts +948 -267
- package/dist/zod/theme.zod.d.ts.map +1 -1
- package/dist/zod/theme.zod.js +175 -45
- package/dist/zod/views.zod.d.ts +22 -22
- package/dist/zod/views.zod.d.ts.map +1 -1
- package/dist/zod/views.zod.js +1 -1
- package/package.json +3 -2
- package/src/__tests__/namespace-exports.test.ts +23 -68
- package/src/__tests__/phase2-schemas.test.ts +8 -13
- package/src/ai.ts +454 -0
- package/src/app.ts +2 -2
- package/src/complex.ts +2 -0
- package/src/crud.ts +3 -0
- package/src/data-display.ts +36 -0
- package/src/data-protocol.ts +19 -19
- package/src/data.ts +91 -0
- package/src/designer.ts +509 -0
- package/src/form.ts +35 -1
- package/src/index.ts +397 -8
- package/src/layout.ts +66 -8
- package/src/mobile.ts +205 -0
- package/src/objectql.ts +419 -93
- package/src/permissions.ts +166 -0
- package/src/tenant.ts +153 -0
- package/src/theme.ts +147 -260
- package/src/ui-action.ts +166 -27
- package/src/views.ts +17 -0
- package/src/widget.ts +197 -0
- package/src/workflow.ts +409 -0
- package/src/zod/blocks.zod.ts +1 -1
- package/src/zod/complex.zod.ts +1 -1
- 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 +14 -3
- package/src/zod/layout.zod.ts +39 -1
- package/src/zod/navigation.zod.ts +1 -1
- package/src/zod/objectql.zod.ts +8 -0
- package/src/zod/overlay.zod.ts +1 -1
- package/src/zod/reports.zod.ts +1 -1
- package/src/zod/theme.zod.ts +189 -48
- package/src/zod/views.zod.ts +1 -1
package/src/ui-action.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* @object-ui/types - UI Action Schema
|
|
11
11
|
*
|
|
12
|
-
* ObjectStack Spec
|
|
12
|
+
* ObjectStack Spec v2.0.1 compliant action schema with enhanced capabilities:
|
|
13
13
|
* - Location-based action placement
|
|
14
14
|
* - Parameter collection
|
|
15
15
|
* - Conditional visibility and enablement
|
|
@@ -19,30 +19,13 @@
|
|
|
19
19
|
* @packageDocumentation
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
export type ActionParamFieldType =
|
|
27
|
-
| 'text'
|
|
28
|
-
| 'textarea'
|
|
29
|
-
| 'number'
|
|
30
|
-
| 'boolean'
|
|
31
|
-
| 'date'
|
|
32
|
-
| 'datetime'
|
|
33
|
-
| 'time'
|
|
34
|
-
| 'select'
|
|
35
|
-
| 'email'
|
|
36
|
-
| 'phone'
|
|
37
|
-
| 'url'
|
|
38
|
-
| 'password'
|
|
39
|
-
| 'file'
|
|
40
|
-
| 'color'
|
|
41
|
-
| 'slider'
|
|
42
|
-
| 'rating';
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Spec-Canonical Action Sub-types — imported from @objectstack/spec/ui
|
|
24
|
+
// ============================================================================
|
|
43
25
|
|
|
44
26
|
/**
|
|
45
|
-
* Action placement locations
|
|
27
|
+
* Action placement locations
|
|
28
|
+
* Canonical definition from @objectstack/spec/ui ActionSchema.locations.
|
|
46
29
|
*/
|
|
47
30
|
export type ActionLocation =
|
|
48
31
|
| 'list_toolbar' // Top toolbar in list views
|
|
@@ -53,7 +36,8 @@ export type ActionLocation =
|
|
|
53
36
|
| 'global_nav'; // Global navigation bar
|
|
54
37
|
|
|
55
38
|
/**
|
|
56
|
-
* Visual component type for actions
|
|
39
|
+
* Visual component type for actions
|
|
40
|
+
* Canonical definition from @objectstack/spec/ui ActionSchema.component.
|
|
57
41
|
*/
|
|
58
42
|
export type ActionComponent =
|
|
59
43
|
| 'action:button' // Standard button
|
|
@@ -62,7 +46,8 @@ export type ActionComponent =
|
|
|
62
46
|
| 'action:group'; // Action group/dropdown
|
|
63
47
|
|
|
64
48
|
/**
|
|
65
|
-
* Action execution type
|
|
49
|
+
* Action execution type
|
|
50
|
+
* Canonical definition from @objectstack/spec/ui ActionSchema.type.
|
|
66
51
|
*/
|
|
67
52
|
export type ActionType =
|
|
68
53
|
| 'script' // Execute JavaScript/expression
|
|
@@ -72,7 +57,30 @@ export type ActionType =
|
|
|
72
57
|
| 'api'; // Call API endpoint
|
|
73
58
|
|
|
74
59
|
/**
|
|
75
|
-
*
|
|
60
|
+
* Field type for action parameters
|
|
61
|
+
* Subset of field types commonly used in action parameter collection UIs.
|
|
62
|
+
* Aligned with the field types available in @objectstack/spec ActionParamSchema.
|
|
63
|
+
*/
|
|
64
|
+
export type ActionParamFieldType =
|
|
65
|
+
| 'text'
|
|
66
|
+
| 'textarea'
|
|
67
|
+
| 'number'
|
|
68
|
+
| 'boolean'
|
|
69
|
+
| 'date'
|
|
70
|
+
| 'datetime'
|
|
71
|
+
| 'time'
|
|
72
|
+
| 'select'
|
|
73
|
+
| 'email'
|
|
74
|
+
| 'phone'
|
|
75
|
+
| 'url'
|
|
76
|
+
| 'password'
|
|
77
|
+
| 'file'
|
|
78
|
+
| 'color'
|
|
79
|
+
| 'slider'
|
|
80
|
+
| 'rating';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Action parameter definition (ObjectStack Spec v2.0.1)
|
|
76
84
|
*/
|
|
77
85
|
export interface ActionParam {
|
|
78
86
|
/** Parameter name (snake_case) */
|
|
@@ -104,7 +112,7 @@ export interface ActionParam {
|
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
/**
|
|
107
|
-
* Enhanced Action Schema (ObjectStack Spec
|
|
115
|
+
* Enhanced Action Schema (ObjectStack Spec v2.0.1)
|
|
108
116
|
*
|
|
109
117
|
* This is the primary action schema that should be used for all new implementations.
|
|
110
118
|
* The legacy ActionSchema in crud.ts is maintained for backward compatibility.
|
|
@@ -274,3 +282,134 @@ export type ActionExecutor = (
|
|
|
274
282
|
context: ActionContext,
|
|
275
283
|
params?: Record<string, any>
|
|
276
284
|
) => Promise<ActionResult>;
|
|
285
|
+
|
|
286
|
+
// ============================================================================
|
|
287
|
+
// Batch Operations (Q2 2026 - Spec v2.0.1 Enhancement)
|
|
288
|
+
// ============================================================================
|
|
289
|
+
|
|
290
|
+
/** Batch operation configuration */
|
|
291
|
+
export interface BatchOperationConfig {
|
|
292
|
+
/** Operation name */
|
|
293
|
+
name: string;
|
|
294
|
+
/** Display label */
|
|
295
|
+
label: string;
|
|
296
|
+
/** Target action to execute on each record */
|
|
297
|
+
action: string;
|
|
298
|
+
/** Whether to run in parallel */
|
|
299
|
+
parallel?: boolean;
|
|
300
|
+
/** Maximum concurrent operations */
|
|
301
|
+
concurrency?: number;
|
|
302
|
+
/** Whether to continue on error */
|
|
303
|
+
continueOnError?: boolean;
|
|
304
|
+
/** Progress callback expression */
|
|
305
|
+
onProgress?: string;
|
|
306
|
+
/** Completion callback expression */
|
|
307
|
+
onComplete?: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Batch operation result */
|
|
311
|
+
export interface BatchOperationResult {
|
|
312
|
+
/** Total items processed */
|
|
313
|
+
total: number;
|
|
314
|
+
/** Successfully processed count */
|
|
315
|
+
succeeded: number;
|
|
316
|
+
/** Failed count */
|
|
317
|
+
failed: number;
|
|
318
|
+
/** Individual results */
|
|
319
|
+
results: Array<{
|
|
320
|
+
recordId: string;
|
|
321
|
+
success: boolean;
|
|
322
|
+
error?: string;
|
|
323
|
+
}>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ============================================================================
|
|
327
|
+
// Transaction Support (Q2 2026 - Spec v2.0.1 Enhancement)
|
|
328
|
+
// ============================================================================
|
|
329
|
+
|
|
330
|
+
/** Transaction isolation level */
|
|
331
|
+
export type TransactionIsolationLevel = 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable';
|
|
332
|
+
|
|
333
|
+
/** Transaction configuration */
|
|
334
|
+
export interface TransactionConfig {
|
|
335
|
+
/** Transaction name for identification */
|
|
336
|
+
name?: string;
|
|
337
|
+
/** Isolation level */
|
|
338
|
+
isolation?: TransactionIsolationLevel;
|
|
339
|
+
/** Timeout in milliseconds */
|
|
340
|
+
timeout?: number;
|
|
341
|
+
/** Actions to execute within the transaction */
|
|
342
|
+
actions: ActionSchema[];
|
|
343
|
+
/** Rollback action on failure */
|
|
344
|
+
rollbackAction?: string;
|
|
345
|
+
/** Whether to auto-retry on conflict */
|
|
346
|
+
retryOnConflict?: boolean;
|
|
347
|
+
/** Maximum retry attempts */
|
|
348
|
+
maxRetries?: number;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Transaction result */
|
|
352
|
+
export interface TransactionResult {
|
|
353
|
+
/** Whether all actions succeeded */
|
|
354
|
+
success: boolean;
|
|
355
|
+
/** Transaction ID */
|
|
356
|
+
transactionId: string;
|
|
357
|
+
/** Individual action results */
|
|
358
|
+
actionResults: ActionResult[];
|
|
359
|
+
/** Error if transaction failed */
|
|
360
|
+
error?: string;
|
|
361
|
+
/** Whether the transaction was rolled back */
|
|
362
|
+
rolledBack?: boolean;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// ============================================================================
|
|
366
|
+
// Undo/Redo Support (Q2 2026 - Spec v2.0.1 Enhancement)
|
|
367
|
+
// ============================================================================
|
|
368
|
+
|
|
369
|
+
/** Undo/redo operation entry */
|
|
370
|
+
export interface UndoRedoEntry {
|
|
371
|
+
/** Entry identifier */
|
|
372
|
+
id: string;
|
|
373
|
+
/** Action that was performed */
|
|
374
|
+
action: string;
|
|
375
|
+
/** Description of the action */
|
|
376
|
+
description: string;
|
|
377
|
+
/** Timestamp */
|
|
378
|
+
timestamp: string;
|
|
379
|
+
/** Data before the action (for undo) */
|
|
380
|
+
previousState: Record<string, unknown>;
|
|
381
|
+
/** Data after the action (for redo) */
|
|
382
|
+
nextState: Record<string, unknown>;
|
|
383
|
+
/** Target object */
|
|
384
|
+
object?: string;
|
|
385
|
+
/** Target record ID */
|
|
386
|
+
recordId?: string;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** Undo/redo configuration */
|
|
390
|
+
export interface UndoRedoConfig {
|
|
391
|
+
/** Enable undo/redo */
|
|
392
|
+
enabled: boolean;
|
|
393
|
+
/** Maximum history size */
|
|
394
|
+
maxHistorySize?: number;
|
|
395
|
+
/** Actions that support undo */
|
|
396
|
+
undoableActions?: string[];
|
|
397
|
+
/** Whether to group rapid changes */
|
|
398
|
+
groupChanges?: boolean;
|
|
399
|
+
/** Group timeout in milliseconds */
|
|
400
|
+
groupTimeout?: number;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** Undo/redo state */
|
|
404
|
+
export interface UndoRedoState {
|
|
405
|
+
/** Whether undo is available */
|
|
406
|
+
canUndo: boolean;
|
|
407
|
+
/** Whether redo is available */
|
|
408
|
+
canRedo: boolean;
|
|
409
|
+
/** Undo stack */
|
|
410
|
+
undoStack: UndoRedoEntry[];
|
|
411
|
+
/** Redo stack */
|
|
412
|
+
redoStack: UndoRedoEntry[];
|
|
413
|
+
/** Current position in history */
|
|
414
|
+
currentIndex: number;
|
|
415
|
+
}
|
package/src/views.ts
CHANGED
|
@@ -104,6 +104,16 @@ export interface DetailViewSection {
|
|
|
104
104
|
* Section visibility condition
|
|
105
105
|
*/
|
|
106
106
|
visible?: boolean | string;
|
|
107
|
+
/**
|
|
108
|
+
* Show border around section
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
showBorder?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Header background color (Tailwind class)
|
|
114
|
+
* @example 'muted', 'primary/10'
|
|
115
|
+
*/
|
|
116
|
+
headerColor?: string;
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
/**
|
|
@@ -228,6 +238,13 @@ export interface DetailViewSchema extends BaseSchema {
|
|
|
228
238
|
* Custom footer content
|
|
229
239
|
*/
|
|
230
240
|
footer?: SchemaNode;
|
|
241
|
+
/**
|
|
242
|
+
* Navigation handler for SPA-aware routing.
|
|
243
|
+
* Called instead of window.location.href for back/edit navigation.
|
|
244
|
+
* @param url - The URL to navigate to
|
|
245
|
+
* @param options - Navigation options (replace, newTab, etc.)
|
|
246
|
+
*/
|
|
247
|
+
onNavigate?: (url: string, options?: { replace?: boolean; newTab?: boolean }) => void;
|
|
231
248
|
/**
|
|
232
249
|
* Related records section
|
|
233
250
|
*/
|
package/src/widget.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
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 - Widget Manifest & Registry Types
|
|
11
|
+
*
|
|
12
|
+
* Defines the WidgetManifest interface for runtime widget registration,
|
|
13
|
+
* plugin auto-discovery from server metadata, and custom widget registry
|
|
14
|
+
* for user-defined components.
|
|
15
|
+
*
|
|
16
|
+
* @module widget
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Widget manifest describing a runtime-loadable widget.
|
|
22
|
+
*
|
|
23
|
+
* A manifest provides all metadata needed to discover, load, and render
|
|
24
|
+
* a widget without requiring an upfront import of its code.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const manifest: WidgetManifest = {
|
|
29
|
+
* name: 'custom-chart',
|
|
30
|
+
* version: '1.0.0',
|
|
31
|
+
* type: 'chart',
|
|
32
|
+
* label: 'Custom Chart Widget',
|
|
33
|
+
* description: 'A custom chart powered by D3.',
|
|
34
|
+
* category: 'data-visualization',
|
|
35
|
+
* icon: 'BarChart',
|
|
36
|
+
* source: { type: 'module', url: '/widgets/custom-chart.js' },
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface WidgetManifest {
|
|
41
|
+
/** Unique widget identifier (e.g., 'custom-chart', 'org.acme.table') */
|
|
42
|
+
name: string;
|
|
43
|
+
|
|
44
|
+
/** Semver version string */
|
|
45
|
+
version: string;
|
|
46
|
+
|
|
47
|
+
/** Component type key used for schema rendering (e.g., 'chart', 'grid') */
|
|
48
|
+
type: string;
|
|
49
|
+
|
|
50
|
+
/** Human-readable label for the widget */
|
|
51
|
+
label: string;
|
|
52
|
+
|
|
53
|
+
/** Short description of the widget */
|
|
54
|
+
description?: string;
|
|
55
|
+
|
|
56
|
+
/** Category for grouping in the designer palette */
|
|
57
|
+
category?: string;
|
|
58
|
+
|
|
59
|
+
/** Icon name (Lucide icon name) or SVG string */
|
|
60
|
+
icon?: string;
|
|
61
|
+
|
|
62
|
+
/** Thumbnail image URL for the designer palette */
|
|
63
|
+
thumbnail?: string;
|
|
64
|
+
|
|
65
|
+
/** Widget loading source configuration */
|
|
66
|
+
source: WidgetSource;
|
|
67
|
+
|
|
68
|
+
/** Required peer dependencies (e.g., { 'react': '^18.0.0' }) */
|
|
69
|
+
peerDependencies?: Record<string, string>;
|
|
70
|
+
|
|
71
|
+
/** Dependencies on other widgets by name */
|
|
72
|
+
dependencies?: string[];
|
|
73
|
+
|
|
74
|
+
/** Default props to apply when the widget is first dropped in the designer */
|
|
75
|
+
defaultProps?: Record<string, unknown>;
|
|
76
|
+
|
|
77
|
+
/** Input schema for the widget's configurable properties */
|
|
78
|
+
inputs?: WidgetInput[];
|
|
79
|
+
|
|
80
|
+
/** Whether the widget can contain child components */
|
|
81
|
+
isContainer?: boolean;
|
|
82
|
+
|
|
83
|
+
/** Widget capabilities */
|
|
84
|
+
capabilities?: WidgetCapabilities;
|
|
85
|
+
|
|
86
|
+
/** Additional metadata */
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Describes how to load the widget's code at runtime.
|
|
92
|
+
*/
|
|
93
|
+
export type WidgetSource =
|
|
94
|
+
| WidgetSourceModule
|
|
95
|
+
| WidgetSourceInline
|
|
96
|
+
| WidgetSourceRegistry;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Load from an ES module URL.
|
|
100
|
+
*
|
|
101
|
+
* ⚠️ SECURITY WARNING: Only use URLs from trusted sources.
|
|
102
|
+
* Never pass user-supplied URLs directly. URLs should be validated
|
|
103
|
+
* and controlled by your application. This feature uses dynamic imports
|
|
104
|
+
* which bypass static analysis and may be restricted by Content Security Policy.
|
|
105
|
+
*/
|
|
106
|
+
export interface WidgetSourceModule {
|
|
107
|
+
type: 'module';
|
|
108
|
+
/**
|
|
109
|
+
* URL to the ES module (e.g., '/widgets/chart.js' or 'https://cdn.example.com/widget.mjs')
|
|
110
|
+
* Must be from a trusted source - never user input.
|
|
111
|
+
*/
|
|
112
|
+
url: string;
|
|
113
|
+
/** Named export to use (default: 'default') */
|
|
114
|
+
exportName?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The component is provided inline (already loaded) */
|
|
118
|
+
export interface WidgetSourceInline {
|
|
119
|
+
type: 'inline';
|
|
120
|
+
/** The React component (already resolved) */
|
|
121
|
+
component: unknown;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The component is registered in the global component registry */
|
|
125
|
+
export interface WidgetSourceRegistry {
|
|
126
|
+
type: 'registry';
|
|
127
|
+
/** The component type key in the registry */
|
|
128
|
+
registryKey: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Configurable input for a widget.
|
|
133
|
+
*/
|
|
134
|
+
export interface WidgetInput {
|
|
135
|
+
/** Input field name (maps to prop name) */
|
|
136
|
+
name: string;
|
|
137
|
+
/** Input field type */
|
|
138
|
+
type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'color' | 'date' | 'code' | 'file' | 'slot';
|
|
139
|
+
/** Human-readable label */
|
|
140
|
+
label?: string;
|
|
141
|
+
/** Default value */
|
|
142
|
+
defaultValue?: unknown;
|
|
143
|
+
/** Whether this input is required */
|
|
144
|
+
required?: boolean;
|
|
145
|
+
/** Enum options (for type: 'enum') */
|
|
146
|
+
options?: string[] | Array<{ label: string; value: unknown }>;
|
|
147
|
+
/** Help text */
|
|
148
|
+
description?: string;
|
|
149
|
+
/** Whether this is an advanced setting (hidden by default) */
|
|
150
|
+
advanced?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Widget capabilities flag set.
|
|
155
|
+
*/
|
|
156
|
+
export interface WidgetCapabilities {
|
|
157
|
+
/** Widget supports data binding via dataSource */
|
|
158
|
+
dataBinding?: boolean;
|
|
159
|
+
/** Widget supports real-time updates */
|
|
160
|
+
realTime?: boolean;
|
|
161
|
+
/** Widget supports export (PDF, CSV, etc.) */
|
|
162
|
+
export?: boolean;
|
|
163
|
+
/** Widget supports responsive sizing */
|
|
164
|
+
responsive?: boolean;
|
|
165
|
+
/** Widget supports theming */
|
|
166
|
+
themeable?: boolean;
|
|
167
|
+
/** Widget supports drag and drop */
|
|
168
|
+
draggable?: boolean;
|
|
169
|
+
/** Widget supports resize */
|
|
170
|
+
resizable?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Resolved widget: a manifest with its loaded component.
|
|
175
|
+
*/
|
|
176
|
+
export interface ResolvedWidget {
|
|
177
|
+
/** The original manifest */
|
|
178
|
+
manifest: WidgetManifest;
|
|
179
|
+
/** The loaded React component */
|
|
180
|
+
component: unknown;
|
|
181
|
+
/** Timestamp when the widget was loaded */
|
|
182
|
+
loadedAt: number;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Widget registry event types.
|
|
187
|
+
*/
|
|
188
|
+
export type WidgetRegistryEvent =
|
|
189
|
+
| { type: 'widget:registered'; widget: WidgetManifest }
|
|
190
|
+
| { type: 'widget:unregistered'; name: string }
|
|
191
|
+
| { type: 'widget:loaded'; widget: ResolvedWidget }
|
|
192
|
+
| { type: 'widget:error'; name: string; error: Error };
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Widget registry event listener.
|
|
196
|
+
*/
|
|
197
|
+
export type WidgetRegistryListener = (event: WidgetRegistryEvent) => void;
|