@object-ui/core 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.
Files changed (90) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +8 -0
  3. package/dist/actions/ActionRunner.d.ts +40 -0
  4. package/dist/actions/ActionRunner.js +160 -0
  5. package/dist/actions/index.d.ts +8 -0
  6. package/dist/actions/index.js +8 -0
  7. package/dist/adapters/index.d.ts +7 -0
  8. package/dist/adapters/index.js +10 -0
  9. package/dist/builder/schema-builder.d.ts +7 -0
  10. package/dist/builder/schema-builder.js +4 -6
  11. package/dist/evaluator/ExpressionCache.d.ts +101 -0
  12. package/dist/evaluator/ExpressionCache.js +135 -0
  13. package/dist/evaluator/ExpressionContext.d.ts +51 -0
  14. package/dist/evaluator/ExpressionContext.js +110 -0
  15. package/dist/evaluator/ExpressionEvaluator.d.ts +117 -0
  16. package/dist/evaluator/ExpressionEvaluator.js +220 -0
  17. package/dist/evaluator/index.d.ts +10 -0
  18. package/dist/evaluator/index.js +10 -0
  19. package/dist/index.d.ts +17 -4
  20. package/dist/index.js +16 -5
  21. package/dist/query/index.d.ts +6 -0
  22. package/dist/query/index.js +6 -0
  23. package/dist/query/query-ast.d.ts +32 -0
  24. package/dist/query/query-ast.js +268 -0
  25. package/dist/registry/PluginScopeImpl.d.ts +80 -0
  26. package/dist/registry/PluginScopeImpl.js +243 -0
  27. package/dist/registry/PluginSystem.d.ts +66 -0
  28. package/dist/registry/PluginSystem.js +142 -0
  29. package/dist/registry/Registry.d.ts +80 -4
  30. package/dist/registry/Registry.js +119 -7
  31. package/dist/types/index.d.ts +7 -0
  32. package/dist/types/index.js +7 -0
  33. package/dist/utils/filter-converter.d.ts +57 -0
  34. package/dist/utils/filter-converter.js +100 -0
  35. package/dist/validation/index.d.ts +9 -0
  36. package/dist/validation/index.js +9 -0
  37. package/dist/validation/schema-validator.d.ts +7 -0
  38. package/dist/validation/schema-validator.js +4 -6
  39. package/dist/validation/validation-engine.d.ts +70 -0
  40. package/dist/validation/validation-engine.js +363 -0
  41. package/dist/validation/validators/index.d.ts +16 -0
  42. package/dist/validation/validators/index.js +16 -0
  43. package/dist/validation/validators/object-validation-engine.d.ts +118 -0
  44. package/dist/validation/validators/object-validation-engine.js +538 -0
  45. package/package.json +26 -7
  46. package/src/actions/ActionRunner.ts +195 -0
  47. package/src/actions/index.ts +9 -0
  48. package/src/adapters/README.md +180 -0
  49. package/src/adapters/index.ts +10 -0
  50. package/src/builder/schema-builder.ts +8 -0
  51. package/src/evaluator/ExpressionCache.ts +192 -0
  52. package/src/evaluator/ExpressionContext.ts +118 -0
  53. package/src/evaluator/ExpressionEvaluator.ts +267 -0
  54. package/src/evaluator/__tests__/ExpressionCache.test.ts +135 -0
  55. package/src/evaluator/__tests__/ExpressionEvaluator.test.ts +101 -0
  56. package/src/evaluator/index.ts +11 -0
  57. package/src/index.test.ts +8 -0
  58. package/src/index.ts +18 -5
  59. package/src/query/__tests__/query-ast.test.ts +211 -0
  60. package/src/query/__tests__/window-functions.test.ts +275 -0
  61. package/src/query/index.ts +7 -0
  62. package/src/query/query-ast.ts +341 -0
  63. package/src/registry/PluginScopeImpl.ts +259 -0
  64. package/src/registry/PluginSystem.ts +161 -0
  65. package/src/registry/Registry.ts +133 -8
  66. package/src/registry/__tests__/PluginSystem.test.ts +226 -0
  67. package/src/registry/__tests__/Registry.test.ts +293 -0
  68. package/src/registry/__tests__/plugin-scope-integration.test.ts +283 -0
  69. package/src/types/index.ts +8 -0
  70. package/src/utils/__tests__/filter-converter.test.ts +118 -0
  71. package/src/utils/filter-converter.ts +133 -0
  72. package/src/validation/__tests__/object-validation-engine.test.ts +567 -0
  73. package/src/validation/__tests__/validation-engine.test.ts +102 -0
  74. package/src/validation/index.ts +10 -0
  75. package/src/validation/schema-validator.ts +8 -0
  76. package/src/validation/validation-engine.ts +461 -0
  77. package/src/validation/validators/index.ts +25 -0
  78. package/src/validation/validators/object-validation-engine.ts +722 -0
  79. package/tsconfig.tsbuildinfo +1 -1
  80. package/vitest.config.ts +2 -0
  81. package/src/builder/schema-builder.d.ts +0 -287
  82. package/src/builder/schema-builder.js +0 -505
  83. package/src/index.d.ts +0 -4
  84. package/src/index.js +0 -7
  85. package/src/registry/Registry.d.ts +0 -49
  86. package/src/registry/Registry.js +0 -36
  87. package/src/types/index.d.ts +0 -12
  88. package/src/types/index.js +0 -1
  89. package/src/validation/schema-validator.d.ts +0 -87
  90. package/src/validation/schema-validator.js +0 -280
@@ -1,505 +0,0 @@
1
- /**
2
- * @object-ui/core - Schema Builder
3
- *
4
- * Fluent API for building schemas programmatically.
5
- * Provides type-safe builder functions for common schema patterns.
6
- *
7
- * @module builder
8
- * @packageDocumentation
9
- */
10
- /**
11
- * Base builder class
12
- */
13
- class SchemaBuilder {
14
- constructor(type) {
15
- Object.defineProperty(this, "schema", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- this.schema = { type };
22
- }
23
- /**
24
- * Set the ID
25
- */
26
- id(id) {
27
- this.schema.id = id;
28
- return this;
29
- }
30
- /**
31
- * Set the className
32
- */
33
- className(className) {
34
- this.schema.className = className;
35
- return this;
36
- }
37
- /**
38
- * Set visibility
39
- */
40
- visible(visible) {
41
- this.schema.visible = visible;
42
- return this;
43
- }
44
- /**
45
- * Set conditional visibility
46
- */
47
- visibleOn(expression) {
48
- this.schema.visibleOn = expression;
49
- return this;
50
- }
51
- /**
52
- * Set disabled state
53
- */
54
- disabled(disabled) {
55
- this.schema.disabled = disabled;
56
- return this;
57
- }
58
- /**
59
- * Set test ID
60
- */
61
- testId(testId) {
62
- this.schema.testId = testId;
63
- return this;
64
- }
65
- /**
66
- * Build the final schema
67
- */
68
- build() {
69
- return this.schema;
70
- }
71
- }
72
- /**
73
- * Form builder
74
- */
75
- export class FormBuilder extends SchemaBuilder {
76
- constructor() {
77
- super('form');
78
- this.schema.fields = [];
79
- }
80
- /**
81
- * Add a field to the form
82
- */
83
- field(field) {
84
- this.schema.fields = [...(this.schema.fields || []), field];
85
- return this;
86
- }
87
- /**
88
- * Add multiple fields
89
- */
90
- fields(fields) {
91
- this.schema.fields = fields;
92
- return this;
93
- }
94
- /**
95
- * Set default values
96
- */
97
- defaultValues(values) {
98
- this.schema.defaultValues = values;
99
- return this;
100
- }
101
- /**
102
- * Set submit label
103
- */
104
- submitLabel(label) {
105
- this.schema.submitLabel = label;
106
- return this;
107
- }
108
- /**
109
- * Set form layout
110
- */
111
- layout(layout) {
112
- this.schema.layout = layout;
113
- return this;
114
- }
115
- /**
116
- * Set number of columns
117
- */
118
- columns(columns) {
119
- this.schema.columns = columns;
120
- return this;
121
- }
122
- /**
123
- * Set submit handler
124
- */
125
- onSubmit(handler) {
126
- this.schema.onSubmit = handler;
127
- return this;
128
- }
129
- }
130
- /**
131
- * CRUD builder
132
- */
133
- export class CRUDBuilder extends SchemaBuilder {
134
- constructor() {
135
- super('crud');
136
- this.schema.columns = [];
137
- }
138
- /**
139
- * Set resource name
140
- */
141
- resource(resource) {
142
- this.schema.resource = resource;
143
- return this;
144
- }
145
- /**
146
- * Set API endpoint
147
- */
148
- api(api) {
149
- this.schema.api = api;
150
- return this;
151
- }
152
- /**
153
- * Set title
154
- */
155
- title(title) {
156
- this.schema.title = title;
157
- return this;
158
- }
159
- /**
160
- * Set description
161
- */
162
- description(description) {
163
- this.schema.description = description;
164
- return this;
165
- }
166
- /**
167
- * Add a column
168
- */
169
- column(column) {
170
- this.schema.columns = [...(this.schema.columns || []), column];
171
- return this;
172
- }
173
- /**
174
- * Set all columns
175
- */
176
- columns(columns) {
177
- this.schema.columns = columns;
178
- return this;
179
- }
180
- /**
181
- * Set form fields
182
- */
183
- fields(fields) {
184
- this.schema.fields = fields;
185
- return this;
186
- }
187
- /**
188
- * Enable create operation
189
- */
190
- enableCreate(label) {
191
- if (!this.schema.operations)
192
- this.schema.operations = {};
193
- this.schema.operations.create = {
194
- enabled: true,
195
- label: label || 'Create',
196
- api: this.schema.api,
197
- method: 'POST'
198
- };
199
- return this;
200
- }
201
- /**
202
- * Enable update operation
203
- */
204
- enableUpdate(label) {
205
- if (!this.schema.operations)
206
- this.schema.operations = {};
207
- this.schema.operations.update = {
208
- enabled: true,
209
- label: label || 'Update',
210
- api: `${this.schema.api}/\${id}`,
211
- method: 'PUT'
212
- };
213
- return this;
214
- }
215
- /**
216
- * Enable delete operation
217
- */
218
- enableDelete(label, confirmText) {
219
- if (!this.schema.operations)
220
- this.schema.operations = {};
221
- this.schema.operations.delete = {
222
- enabled: true,
223
- label: label || 'Delete',
224
- api: `${this.schema.api}/\${id}`,
225
- method: 'DELETE',
226
- confirmText: confirmText || 'Are you sure?'
227
- };
228
- return this;
229
- }
230
- /**
231
- * Set pagination
232
- */
233
- pagination(pageSize = 20) {
234
- this.schema.pagination = {
235
- enabled: true,
236
- pageSize,
237
- pageSizeOptions: [10, 20, 50, 100],
238
- showTotal: true,
239
- showSizeChanger: true
240
- };
241
- return this;
242
- }
243
- /**
244
- * Enable row selection
245
- */
246
- selectable(mode = 'multiple') {
247
- this.schema.selectable = mode;
248
- return this;
249
- }
250
- /**
251
- * Add a batch action
252
- */
253
- batchAction(action) {
254
- this.schema.batchActions = [...(this.schema.batchActions || []), action];
255
- return this;
256
- }
257
- /**
258
- * Add a row action
259
- */
260
- rowAction(action) {
261
- this.schema.rowActions = [...(this.schema.rowActions || []), action];
262
- return this;
263
- }
264
- }
265
- /**
266
- * Button builder
267
- */
268
- export class ButtonBuilder extends SchemaBuilder {
269
- constructor() {
270
- super('button');
271
- }
272
- /**
273
- * Set button label
274
- */
275
- label(label) {
276
- this.schema.label = label;
277
- return this;
278
- }
279
- /**
280
- * Set button variant
281
- */
282
- variant(variant) {
283
- this.schema.variant = variant;
284
- return this;
285
- }
286
- /**
287
- * Set button size
288
- */
289
- size(size) {
290
- this.schema.size = size;
291
- return this;
292
- }
293
- /**
294
- * Set button icon
295
- */
296
- icon(icon) {
297
- this.schema.icon = icon;
298
- return this;
299
- }
300
- /**
301
- * Set click handler
302
- */
303
- onClick(handler) {
304
- this.schema.onClick = handler;
305
- return this;
306
- }
307
- /**
308
- * Set loading state
309
- */
310
- loading(loading) {
311
- this.schema.loading = loading;
312
- return this;
313
- }
314
- }
315
- /**
316
- * Input builder
317
- */
318
- export class InputBuilder extends SchemaBuilder {
319
- constructor() {
320
- super('input');
321
- }
322
- /**
323
- * Set field name
324
- */
325
- name(name) {
326
- this.schema.name = name;
327
- return this;
328
- }
329
- /**
330
- * Set label
331
- */
332
- label(label) {
333
- this.schema.label = label;
334
- return this;
335
- }
336
- /**
337
- * Set placeholder
338
- */
339
- placeholder(placeholder) {
340
- this.schema.placeholder = placeholder;
341
- return this;
342
- }
343
- /**
344
- * Set input type
345
- */
346
- inputType(type) {
347
- this.schema.inputType = type;
348
- return this;
349
- }
350
- /**
351
- * Mark as required
352
- */
353
- required(required = true) {
354
- this.schema.required = required;
355
- return this;
356
- }
357
- /**
358
- * Set default value
359
- */
360
- defaultValue(value) {
361
- this.schema.defaultValue = value;
362
- return this;
363
- }
364
- }
365
- /**
366
- * Card builder
367
- */
368
- export class CardBuilder extends SchemaBuilder {
369
- constructor() {
370
- super('card');
371
- }
372
- /**
373
- * Set card title
374
- */
375
- title(title) {
376
- this.schema.title = title;
377
- return this;
378
- }
379
- /**
380
- * Set card description
381
- */
382
- description(description) {
383
- this.schema.description = description;
384
- return this;
385
- }
386
- /**
387
- * Set card content
388
- */
389
- content(content) {
390
- this.schema.content = content;
391
- return this;
392
- }
393
- /**
394
- * Set card variant
395
- */
396
- variant(variant) {
397
- this.schema.variant = variant;
398
- return this;
399
- }
400
- /**
401
- * Make card hoverable
402
- */
403
- hoverable(hoverable = true) {
404
- this.schema.hoverable = hoverable;
405
- return this;
406
- }
407
- }
408
- /**
409
- * Grid builder
410
- */
411
- export class GridBuilder extends SchemaBuilder {
412
- constructor() {
413
- super('grid');
414
- this.schema.children = [];
415
- }
416
- /**
417
- * Set number of columns
418
- */
419
- columns(columns) {
420
- this.schema.columns = columns;
421
- return this;
422
- }
423
- /**
424
- * Set gap
425
- */
426
- gap(gap) {
427
- this.schema.gap = gap;
428
- return this;
429
- }
430
- /**
431
- * Add a child
432
- */
433
- child(child) {
434
- const children = Array.isArray(this.schema.children) ? this.schema.children : [];
435
- this.schema.children = [...children, child];
436
- return this;
437
- }
438
- /**
439
- * Set all children
440
- */
441
- children(children) {
442
- this.schema.children = children;
443
- return this;
444
- }
445
- }
446
- /**
447
- * Flex builder
448
- */
449
- export class FlexBuilder extends SchemaBuilder {
450
- constructor() {
451
- super('flex');
452
- this.schema.children = [];
453
- }
454
- /**
455
- * Set flex direction
456
- */
457
- direction(direction) {
458
- this.schema.direction = direction;
459
- return this;
460
- }
461
- /**
462
- * Set justify content
463
- */
464
- justify(justify) {
465
- this.schema.justify = justify;
466
- return this;
467
- }
468
- /**
469
- * Set align items
470
- */
471
- align(align) {
472
- this.schema.align = align;
473
- return this;
474
- }
475
- /**
476
- * Set gap
477
- */
478
- gap(gap) {
479
- this.schema.gap = gap;
480
- return this;
481
- }
482
- /**
483
- * Add a child
484
- */
485
- child(child) {
486
- const children = Array.isArray(this.schema.children) ? this.schema.children : [];
487
- this.schema.children = [...children, child];
488
- return this;
489
- }
490
- /**
491
- * Set all children
492
- */
493
- children(children) {
494
- this.schema.children = children;
495
- return this;
496
- }
497
- }
498
- // Export factory functions
499
- export const form = () => new FormBuilder();
500
- export const crud = () => new CRUDBuilder();
501
- export const button = () => new ButtonBuilder();
502
- export const input = () => new InputBuilder();
503
- export const card = () => new CardBuilder();
504
- export const grid = () => new GridBuilder();
505
- export const flex = () => new FlexBuilder();
package/src/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './types';
2
- export * from './registry/Registry';
3
- export * from './validation/schema-validator';
4
- export * from './builder/schema-builder';
package/src/index.js DELETED
@@ -1,7 +0,0 @@
1
- export * from './types';
2
- export * from './registry/Registry';
3
- export * from './validation/schema-validator';
4
- export * from './builder/schema-builder';
5
- // export * from './data-scope'; // TODO
6
- // export * from './evaluator'; // TODO
7
- // export * from './validators'; // TODO
@@ -1,49 +0,0 @@
1
- import type { SchemaNode } from '../types';
2
- export type ComponentRenderer<T = any> = T;
3
- export type ComponentInput = {
4
- name: string;
5
- type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'color' | 'date' | 'code' | 'file' | 'slot';
6
- label?: string;
7
- defaultValue?: any;
8
- required?: boolean;
9
- enum?: string[] | {
10
- label: string;
11
- value: any;
12
- }[];
13
- description?: string;
14
- advanced?: boolean;
15
- inputType?: string;
16
- };
17
- export type ComponentMeta = {
18
- label?: string;
19
- icon?: string;
20
- category?: string;
21
- inputs?: ComponentInput[];
22
- defaultProps?: Record<string, any>;
23
- defaultChildren?: SchemaNode[];
24
- examples?: Record<string, any>;
25
- isContainer?: boolean;
26
- resizable?: boolean;
27
- resizeConstraints?: {
28
- width?: boolean;
29
- height?: boolean;
30
- minWidth?: number;
31
- maxWidth?: number;
32
- minHeight?: number;
33
- maxHeight?: number;
34
- };
35
- };
36
- export type ComponentConfig<T = any> = ComponentMeta & {
37
- type: string;
38
- component: ComponentRenderer<T>;
39
- };
40
- export declare class Registry<T = any> {
41
- private components;
42
- register(type: string, component: ComponentRenderer<T>, meta?: ComponentMeta): void;
43
- get(type: string): ComponentRenderer<T> | undefined;
44
- getConfig(type: string): ComponentConfig<T> | undefined;
45
- has(type: string): boolean;
46
- getAllTypes(): string[];
47
- getAllConfigs(): ComponentConfig<T>[];
48
- }
49
- export declare const ComponentRegistry: Registry<any>;
@@ -1,36 +0,0 @@
1
- export class Registry {
2
- constructor() {
3
- Object.defineProperty(this, "components", {
4
- enumerable: true,
5
- configurable: true,
6
- writable: true,
7
- value: new Map()
8
- });
9
- }
10
- register(type, component, meta) {
11
- if (this.components.has(type)) {
12
- console.warn(`Component type "${type}" is already registered. Overwriting.`);
13
- }
14
- this.components.set(type, {
15
- type,
16
- component,
17
- ...meta
18
- });
19
- }
20
- get(type) {
21
- return this.components.get(type)?.component;
22
- }
23
- getConfig(type) {
24
- return this.components.get(type);
25
- }
26
- has(type) {
27
- return this.components.has(type);
28
- }
29
- getAllTypes() {
30
- return Array.from(this.components.keys());
31
- }
32
- getAllConfigs() {
33
- return Array.from(this.components.values());
34
- }
35
- }
36
- export const ComponentRegistry = new Registry();
@@ -1,12 +0,0 @@
1
- export interface SchemaNode {
2
- type: string;
3
- id?: string;
4
- className?: string;
5
- data?: any;
6
- body?: SchemaNode | SchemaNode[];
7
- [key: string]: any;
8
- }
9
- export interface ComponentRendererProps {
10
- schema: SchemaNode;
11
- [key: string]: any;
12
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,87 +0,0 @@
1
- /**
2
- * @object-ui/core - Schema Validation
3
- *
4
- * Runtime validation utilities for Object UI schemas.
5
- * These utilities help ensure schemas are valid before rendering.
6
- *
7
- * @module validation
8
- * @packageDocumentation
9
- */
10
- import type { BaseSchema } from '@object-ui/types';
11
- /**
12
- * Validation error details
13
- */
14
- export interface ValidationError {
15
- path: string;
16
- message: string;
17
- type: 'error' | 'warning';
18
- code?: string;
19
- }
20
- /**
21
- * Validation result
22
- */
23
- export interface ValidationResult {
24
- valid: boolean;
25
- errors: ValidationError[];
26
- warnings: ValidationError[];
27
- }
28
- /**
29
- * Validate a complete schema
30
- *
31
- * @param schema - The schema to validate
32
- * @param options - Validation options
33
- * @returns Validation result with errors and warnings
34
- *
35
- * @example
36
- * ```typescript
37
- * const result = validateSchema({
38
- * type: 'form',
39
- * fields: [
40
- * { name: 'email', type: 'input' }
41
- * ]
42
- * });
43
- *
44
- * if (!result.valid) {
45
- * console.error('Validation errors:', result.errors);
46
- * }
47
- * ```
48
- */
49
- export declare function validateSchema(schema: any, path?: string): ValidationResult;
50
- /**
51
- * Assert that a schema is valid, throwing an error if not
52
- *
53
- * @param schema - The schema to validate
54
- * @throws Error if schema is invalid
55
- *
56
- * @example
57
- * ```typescript
58
- * try {
59
- * assertValidSchema(schema);
60
- * // Schema is valid, continue rendering
61
- * } catch (error) {
62
- * console.error('Invalid schema:', error.message);
63
- * }
64
- * ```
65
- */
66
- export declare function assertValidSchema(schema: any): asserts schema is BaseSchema;
67
- /**
68
- * Check if a value is a valid schema
69
- *
70
- * @param value - The value to check
71
- * @returns True if the value is a valid schema
72
- *
73
- * @example
74
- * ```typescript
75
- * if (isValidSchema(data)) {
76
- * renderSchema(data);
77
- * }
78
- * ```
79
- */
80
- export declare function isValidSchema(value: any): value is BaseSchema;
81
- /**
82
- * Get a human-readable error summary
83
- *
84
- * @param result - The validation result
85
- * @returns Formatted error summary
86
- */
87
- export declare function formatValidationErrors(result: ValidationResult): string;