@object-ui/core 3.3.0 → 3.3.2

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 (101) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +20 -1
  3. package/dist/actions/ActionRunner.d.ts +9 -0
  4. package/dist/actions/ActionRunner.js +41 -4
  5. package/dist/adapters/ValueDataSource.js +3 -1
  6. package/dist/registry/Registry.d.ts +47 -0
  7. package/dist/registry/Registry.js +92 -0
  8. package/dist/utils/filter-converter.js +25 -5
  9. package/package.json +32 -8
  10. package/.turbo/turbo-build.log +0 -4
  11. package/src/__benchmarks__/core.bench.ts +0 -64
  12. package/src/__tests__/protocols/DndProtocol.test.ts +0 -186
  13. package/src/__tests__/protocols/KeyboardProtocol.test.ts +0 -177
  14. package/src/__tests__/protocols/NotificationProtocol.test.ts +0 -142
  15. package/src/__tests__/protocols/ResponsiveProtocol.test.ts +0 -176
  16. package/src/__tests__/protocols/SharingProtocol.test.ts +0 -188
  17. package/src/actions/ActionEngine.ts +0 -268
  18. package/src/actions/ActionRunner.ts +0 -717
  19. package/src/actions/TransactionManager.ts +0 -521
  20. package/src/actions/UndoManager.ts +0 -215
  21. package/src/actions/__tests__/ActionEngine.test.ts +0 -206
  22. package/src/actions/__tests__/ActionRunner.params.test.ts +0 -134
  23. package/src/actions/__tests__/ActionRunner.test.ts +0 -711
  24. package/src/actions/__tests__/TransactionManager.test.ts +0 -447
  25. package/src/actions/__tests__/UndoManager.test.ts +0 -320
  26. package/src/actions/index.ts +0 -12
  27. package/src/adapters/ApiDataSource.ts +0 -376
  28. package/src/adapters/README.md +0 -180
  29. package/src/adapters/ValueDataSource.ts +0 -459
  30. package/src/adapters/__tests__/ApiDataSource.test.ts +0 -418
  31. package/src/adapters/__tests__/ValueDataSource.test.ts +0 -571
  32. package/src/adapters/__tests__/resolveDataSource.test.ts +0 -144
  33. package/src/adapters/index.ts +0 -15
  34. package/src/adapters/resolveDataSource.ts +0 -79
  35. package/src/builder/__tests__/schema-builder.test.ts +0 -235
  36. package/src/builder/schema-builder.ts +0 -584
  37. package/src/data-scope/DataScopeManager.ts +0 -269
  38. package/src/data-scope/ViewDataProvider.ts +0 -282
  39. package/src/data-scope/__tests__/DataScopeManager.test.ts +0 -211
  40. package/src/data-scope/__tests__/ViewDataProvider.test.ts +0 -270
  41. package/src/data-scope/index.ts +0 -24
  42. package/src/errors/__tests__/errors.test.ts +0 -292
  43. package/src/errors/index.ts +0 -269
  44. package/src/evaluator/ExpressionCache.ts +0 -206
  45. package/src/evaluator/ExpressionContext.ts +0 -118
  46. package/src/evaluator/ExpressionEvaluator.ts +0 -315
  47. package/src/evaluator/FormulaFunctions.ts +0 -398
  48. package/src/evaluator/SafeExpressionParser.ts +0 -893
  49. package/src/evaluator/__tests__/ExpressionCache.test.ts +0 -135
  50. package/src/evaluator/__tests__/ExpressionContext.test.ts +0 -110
  51. package/src/evaluator/__tests__/ExpressionEvaluator.test.ts +0 -558
  52. package/src/evaluator/__tests__/FormulaFunctions.test.ts +0 -447
  53. package/src/evaluator/index.ts +0 -13
  54. package/src/index.ts +0 -38
  55. package/src/protocols/DndProtocol.ts +0 -168
  56. package/src/protocols/KeyboardProtocol.ts +0 -181
  57. package/src/protocols/NotificationProtocol.ts +0 -150
  58. package/src/protocols/ResponsiveProtocol.ts +0 -210
  59. package/src/protocols/SharingProtocol.ts +0 -185
  60. package/src/protocols/index.ts +0 -13
  61. package/src/query/__tests__/query-ast.test.ts +0 -211
  62. package/src/query/__tests__/window-functions.test.ts +0 -275
  63. package/src/query/index.ts +0 -7
  64. package/src/query/query-ast.ts +0 -341
  65. package/src/registry/PluginScopeImpl.ts +0 -259
  66. package/src/registry/PluginSystem.ts +0 -206
  67. package/src/registry/Registry.ts +0 -219
  68. package/src/registry/WidgetRegistry.ts +0 -316
  69. package/src/registry/__tests__/PluginSystem.test.ts +0 -309
  70. package/src/registry/__tests__/Registry.test.ts +0 -293
  71. package/src/registry/__tests__/WidgetRegistry.test.ts +0 -321
  72. package/src/registry/__tests__/plugin-scope-integration.test.ts +0 -283
  73. package/src/theme/ThemeEngine.ts +0 -530
  74. package/src/theme/__tests__/ThemeEngine.test.ts +0 -668
  75. package/src/theme/index.ts +0 -24
  76. package/src/types/index.ts +0 -21
  77. package/src/utils/__tests__/debug-collector.test.ts +0 -102
  78. package/src/utils/__tests__/debug.test.ts +0 -134
  79. package/src/utils/__tests__/expand-fields.test.ts +0 -120
  80. package/src/utils/__tests__/extract-records.test.ts +0 -50
  81. package/src/utils/__tests__/filter-converter.test.ts +0 -118
  82. package/src/utils/__tests__/merge-views-into-objects.test.ts +0 -110
  83. package/src/utils/__tests__/normalize-quick-filter.test.ts +0 -123
  84. package/src/utils/debug-collector.ts +0 -100
  85. package/src/utils/debug.ts +0 -148
  86. package/src/utils/expand-fields.ts +0 -76
  87. package/src/utils/extract-records.ts +0 -33
  88. package/src/utils/filter-converter.ts +0 -133
  89. package/src/utils/merge-views-into-objects.ts +0 -36
  90. package/src/utils/normalize-quick-filter.ts +0 -78
  91. package/src/validation/__tests__/object-validation-engine.test.ts +0 -567
  92. package/src/validation/__tests__/schema-validator.test.ts +0 -118
  93. package/src/validation/__tests__/validation-engine.test.ts +0 -102
  94. package/src/validation/index.ts +0 -10
  95. package/src/validation/schema-validator.ts +0 -344
  96. package/src/validation/validation-engine.ts +0 -528
  97. package/src/validation/validators/index.ts +0 -25
  98. package/src/validation/validators/object-validation-engine.ts +0 -722
  99. package/tsconfig.json +0 -15
  100. package/tsconfig.tsbuildinfo +0 -1
  101. package/vitest.config.ts +0 -2
@@ -1,584 +0,0 @@
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/core - Schema Builder
11
- *
12
- * Fluent API for building schemas programmatically.
13
- * Provides type-safe builder functions for common schema patterns.
14
- *
15
- * @module builder
16
- * @packageDocumentation
17
- */
18
-
19
- import type {
20
- BaseSchema,
21
- FormSchema,
22
- FormField,
23
- CRUDSchema,
24
- TableColumn,
25
- ActionSchema,
26
- ButtonSchema,
27
- InputSchema,
28
- CardSchema,
29
- GridSchema,
30
- FlexSchema
31
- } from '@object-ui/types';
32
-
33
- /**
34
- * Base builder class
35
- */
36
- class SchemaBuilder<T extends BaseSchema> {
37
- protected schema: any;
38
-
39
- constructor(type: string) {
40
- this.schema = { type };
41
- }
42
-
43
- /**
44
- * Set the ID
45
- */
46
- id(id: string): this {
47
- this.schema.id = id;
48
- return this;
49
- }
50
-
51
- /**
52
- * Set the className
53
- */
54
- className(className: string): this {
55
- this.schema.className = className;
56
- return this;
57
- }
58
-
59
- /**
60
- * Set visibility
61
- */
62
- visible(visible: boolean): this {
63
- this.schema.visible = visible;
64
- return this;
65
- }
66
-
67
- /**
68
- * Set conditional visibility
69
- */
70
- visibleOn(expression: string): this {
71
- this.schema.visibleOn = expression;
72
- return this;
73
- }
74
-
75
- /**
76
- * Set disabled state
77
- */
78
- disabled(disabled: boolean): this {
79
- this.schema.disabled = disabled;
80
- return this;
81
- }
82
-
83
- /**
84
- * Set test ID
85
- */
86
- testId(testId: string): this {
87
- this.schema.testId = testId;
88
- return this;
89
- }
90
-
91
- /**
92
- * Build the final schema
93
- */
94
- build(): T {
95
- return this.schema as T;
96
- }
97
- }
98
-
99
- /**
100
- * Form builder
101
- */
102
- export class FormBuilder extends SchemaBuilder<FormSchema> {
103
- constructor() {
104
- super('form');
105
- this.schema.fields = [];
106
- }
107
-
108
- /**
109
- * Add a field to the form
110
- */
111
- field(field: FormField): this {
112
- this.schema.fields = [...(this.schema.fields || []), field];
113
- return this;
114
- }
115
-
116
- /**
117
- * Add multiple fields
118
- */
119
- fields(fields: FormField[]): this {
120
- this.schema.fields = fields;
121
- return this;
122
- }
123
-
124
- /**
125
- * Set default values
126
- */
127
- defaultValues(values: Record<string, any>): this {
128
- this.schema.defaultValues = values;
129
- return this;
130
- }
131
-
132
- /**
133
- * Set submit label
134
- */
135
- submitLabel(label: string): this {
136
- this.schema.submitLabel = label;
137
- return this;
138
- }
139
-
140
- /**
141
- * Set form layout
142
- */
143
- layout(layout: 'vertical' | 'horizontal'): this {
144
- this.schema.layout = layout;
145
- return this;
146
- }
147
-
148
- /**
149
- * Set number of columns
150
- */
151
- columns(columns: number): this {
152
- this.schema.columns = columns;
153
- return this;
154
- }
155
-
156
- /**
157
- * Set submit handler
158
- */
159
- onSubmit(handler: (data: Record<string, any>) => void | Promise<void>): this {
160
- this.schema.onSubmit = handler;
161
- return this;
162
- }
163
- }
164
-
165
- /**
166
- * CRUD builder
167
- */
168
- export class CRUDBuilder extends SchemaBuilder<CRUDSchema> {
169
- constructor() {
170
- super('crud');
171
- this.schema.columns = [];
172
- }
173
-
174
- /**
175
- * Set resource name
176
- */
177
- resource(resource: string): this {
178
- this.schema.resource = resource;
179
- return this;
180
- }
181
-
182
- /**
183
- * Set API endpoint
184
- */
185
- api(api: string): this {
186
- this.schema.api = api;
187
- return this;
188
- }
189
-
190
- /**
191
- * Set title
192
- */
193
- title(title: string): this {
194
- this.schema.title = title;
195
- return this;
196
- }
197
-
198
- /**
199
- * Set description
200
- */
201
- description(description: string): this {
202
- this.schema.description = description;
203
- return this;
204
- }
205
-
206
- /**
207
- * Add a column
208
- */
209
- column(column: TableColumn): this {
210
- this.schema.columns = [...(this.schema.columns || []), column];
211
- return this;
212
- }
213
-
214
- /**
215
- * Set all columns
216
- */
217
- columns(columns: TableColumn[]): this {
218
- this.schema.columns = columns;
219
- return this;
220
- }
221
-
222
- /**
223
- * Set form fields
224
- */
225
- fields(fields: FormField[]): this {
226
- this.schema.fields = fields;
227
- return this;
228
- }
229
-
230
- /**
231
- * Enable create operation
232
- */
233
- enableCreate(label?: string): this {
234
- if (!this.schema.operations) this.schema.operations = {};
235
- this.schema.operations.create = {
236
- enabled: true,
237
- label: label || 'Create',
238
- api: this.schema.api,
239
- method: 'POST'
240
- };
241
- return this;
242
- }
243
-
244
- /**
245
- * Enable update operation
246
- */
247
- enableUpdate(label?: string): this {
248
- if (!this.schema.operations) this.schema.operations = {};
249
- this.schema.operations.update = {
250
- enabled: true,
251
- label: label || 'Update',
252
- api: `${this.schema.api}/\${id}`,
253
- method: 'PUT'
254
- };
255
- return this;
256
- }
257
-
258
- /**
259
- * Enable delete operation
260
- */
261
- enableDelete(label?: string, confirmText?: string): this {
262
- if (!this.schema.operations) this.schema.operations = {};
263
- this.schema.operations.delete = {
264
- enabled: true,
265
- label: label || 'Delete',
266
- api: `${this.schema.api}/\${id}`,
267
- method: 'DELETE',
268
- confirmText: confirmText || 'Are you sure?'
269
- };
270
- return this;
271
- }
272
-
273
- /**
274
- * Set pagination
275
- */
276
- pagination(pageSize: number = 20): this {
277
- this.schema.pagination = {
278
- enabled: true,
279
- pageSize,
280
- pageSizeOptions: [10, 20, 50, 100],
281
- showTotal: true,
282
- showSizeChanger: true
283
- };
284
- return this;
285
- }
286
-
287
- /**
288
- * Enable row selection
289
- */
290
- selectable(mode: 'single' | 'multiple' = 'multiple'): this {
291
- this.schema.selectable = mode;
292
- return this;
293
- }
294
-
295
- /**
296
- * Add a batch action
297
- */
298
- batchAction(action: ActionSchema): this {
299
- this.schema.batchActions = [...(this.schema.batchActions || []), action];
300
- return this;
301
- }
302
-
303
- /**
304
- * Add a row action
305
- */
306
- rowAction(action: ActionSchema): this {
307
- this.schema.rowActions = [...(this.schema.rowActions || []), action];
308
- return this;
309
- }
310
- }
311
-
312
- /**
313
- * Button builder
314
- */
315
- export class ButtonBuilder extends SchemaBuilder<ButtonSchema> {
316
- constructor() {
317
- super('button');
318
- }
319
-
320
- /**
321
- * Set button label
322
- */
323
- label(label: string): this {
324
- this.schema.label = label;
325
- return this;
326
- }
327
-
328
- /**
329
- * Set button variant
330
- */
331
- variant(variant: 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link'): this {
332
- this.schema.variant = variant;
333
- return this;
334
- }
335
-
336
- /**
337
- * Set button size
338
- */
339
- size(size: 'default' | 'sm' | 'lg' | 'icon'): this {
340
- this.schema.size = size;
341
- return this;
342
- }
343
-
344
- /**
345
- * Set button icon
346
- */
347
- icon(icon: string): this {
348
- this.schema.icon = icon;
349
- return this;
350
- }
351
-
352
- /**
353
- * Set click handler
354
- */
355
- onClick(handler: () => void | Promise<void>): this {
356
- this.schema.onClick = handler;
357
- return this;
358
- }
359
-
360
- /**
361
- * Set loading state
362
- */
363
- loading(loading: boolean): this {
364
- this.schema.loading = loading;
365
- return this;
366
- }
367
- }
368
-
369
- /**
370
- * Input builder
371
- */
372
- export class InputBuilder extends SchemaBuilder<InputSchema> {
373
- constructor() {
374
- super('input');
375
- }
376
-
377
- /**
378
- * Set field name
379
- */
380
- name(name: string): this {
381
- this.schema.name = name;
382
- return this;
383
- }
384
-
385
- /**
386
- * Set label
387
- */
388
- label(label: string): this {
389
- this.schema.label = label;
390
- return this;
391
- }
392
-
393
- /**
394
- * Set placeholder
395
- */
396
- placeholder(placeholder: string): this {
397
- this.schema.placeholder = placeholder;
398
- return this;
399
- }
400
-
401
- /**
402
- * Set input type
403
- */
404
- inputType(type: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url'): this {
405
- this.schema.inputType = type;
406
- return this;
407
- }
408
-
409
- /**
410
- * Mark as required
411
- */
412
- required(required: boolean = true): this {
413
- this.schema.required = required;
414
- return this;
415
- }
416
-
417
- /**
418
- * Set default value
419
- */
420
- defaultValue(value: string | number): this {
421
- this.schema.defaultValue = value;
422
- return this;
423
- }
424
- }
425
-
426
- /**
427
- * Card builder
428
- */
429
- export class CardBuilder extends SchemaBuilder<CardSchema> {
430
- constructor() {
431
- super('card');
432
- }
433
-
434
- /**
435
- * Set card title
436
- */
437
- title(title: string): this {
438
- this.schema.title = title;
439
- return this;
440
- }
441
-
442
- /**
443
- * Set card description
444
- */
445
- description(description: string): this {
446
- this.schema.description = description;
447
- return this;
448
- }
449
-
450
- /**
451
- * Set card content
452
- */
453
- content(content: BaseSchema | BaseSchema[]): this {
454
- this.schema.content = content;
455
- return this;
456
- }
457
-
458
- /**
459
- * Set card variant
460
- */
461
- variant(variant: 'default' | 'outline' | 'ghost'): this {
462
- this.schema.variant = variant;
463
- return this;
464
- }
465
-
466
- /**
467
- * Make card hoverable
468
- */
469
- hoverable(hoverable: boolean = true): this {
470
- this.schema.hoverable = hoverable;
471
- return this;
472
- }
473
- }
474
-
475
- /**
476
- * Grid builder
477
- */
478
- export class GridBuilder extends SchemaBuilder<GridSchema> {
479
- constructor() {
480
- super('grid');
481
- this.schema.children = [];
482
- }
483
-
484
- /**
485
- * Set number of columns
486
- */
487
- columns(columns: number): this {
488
- this.schema.columns = columns;
489
- return this;
490
- }
491
-
492
- /**
493
- * Set gap
494
- */
495
- gap(gap: number): this {
496
- this.schema.gap = gap;
497
- return this;
498
- }
499
-
500
- /**
501
- * Add a child
502
- */
503
- child(child: BaseSchema): this {
504
- const children = Array.isArray(this.schema.children) ? this.schema.children : [];
505
- this.schema.children = [...children, child];
506
- return this;
507
- }
508
-
509
- /**
510
- * Set all children
511
- */
512
- children(children: BaseSchema[]): this {
513
- this.schema.children = children;
514
- return this;
515
- }
516
- }
517
-
518
- /**
519
- * Flex builder
520
- */
521
- export class FlexBuilder extends SchemaBuilder<FlexSchema> {
522
- constructor() {
523
- super('flex');
524
- this.schema.children = [];
525
- }
526
-
527
- /**
528
- * Set flex direction
529
- */
530
- direction(direction: 'row' | 'col' | 'row-reverse' | 'col-reverse'): this {
531
- this.schema.direction = direction;
532
- return this;
533
- }
534
-
535
- /**
536
- * Set justify content
537
- */
538
- justify(justify: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'): this {
539
- this.schema.justify = justify;
540
- return this;
541
- }
542
-
543
- /**
544
- * Set align items
545
- */
546
- align(align: 'start' | 'end' | 'center' | 'baseline' | 'stretch'): this {
547
- this.schema.align = align;
548
- return this;
549
- }
550
-
551
- /**
552
- * Set gap
553
- */
554
- gap(gap: number): this {
555
- this.schema.gap = gap;
556
- return this;
557
- }
558
-
559
- /**
560
- * Add a child
561
- */
562
- child(child: BaseSchema): this {
563
- const children = Array.isArray(this.schema.children) ? this.schema.children : [];
564
- this.schema.children = [...children, child];
565
- return this;
566
- }
567
-
568
- /**
569
- * Set all children
570
- */
571
- children(children: BaseSchema[]): this {
572
- this.schema.children = children;
573
- return this;
574
- }
575
- }
576
-
577
- // Export factory functions
578
- export const form = () => new FormBuilder();
579
- export const crud = () => new CRUDBuilder();
580
- export const button = () => new ButtonBuilder();
581
- export const input = () => new InputBuilder();
582
- export const card = () => new CardBuilder();
583
- export const grid = () => new GridBuilder();
584
- export const flex = () => new FlexBuilder();