@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,135 +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
- import { describe, it, expect, beforeEach } from 'vitest';
10
- import { ExpressionCache } from '../ExpressionCache';
11
-
12
- describe('ExpressionCache', () => {
13
- let cache: ExpressionCache;
14
-
15
- beforeEach(() => {
16
- cache = new ExpressionCache();
17
- });
18
-
19
- it('should compile and cache an expression', () => {
20
- const expr = 'data.amount > 1000';
21
- const varNames = ['data'];
22
-
23
- const compiled = cache.compile(expr, varNames);
24
-
25
- expect(compiled).toBeDefined();
26
- expect(compiled.expression).toBe(expr);
27
- expect(compiled.varNames).toEqual(varNames);
28
- expect(compiled.hitCount).toBe(1);
29
- });
30
-
31
- it('should return cached expression on second call', () => {
32
- const expr = 'data.amount > 1000';
33
- const varNames = ['data'];
34
-
35
- const first = cache.compile(expr, varNames);
36
- const second = cache.compile(expr, varNames);
37
-
38
- expect(first).toBe(second);
39
- expect(second.hitCount).toBe(2);
40
- });
41
-
42
- it('should execute compiled expression correctly', () => {
43
- const expr = 'data.amount > 1000';
44
- const varNames = ['data'];
45
-
46
- const compiled = cache.compile(expr, varNames);
47
- const result = compiled.fn({ amount: 1500 });
48
-
49
- expect(result).toBe(true);
50
- });
51
-
52
- it('should handle multiple expressions', () => {
53
- const expr1 = 'data.amount > 1000';
54
- const expr2 = 'data.name === "John"';
55
- const varNames = ['data'];
56
-
57
- const compiled1 = cache.compile(expr1, varNames);
58
- const compiled2 = cache.compile(expr2, varNames);
59
-
60
- expect(compiled1).not.toBe(compiled2);
61
- expect(compiled1.fn({ amount: 1500 })).toBe(true);
62
- expect(compiled2.fn({ name: 'John' })).toBe(true);
63
- });
64
-
65
- it('should differentiate between different variable contexts', () => {
66
- const expr = 'x + y';
67
-
68
- const compiled1 = cache.compile(expr, ['x', 'y']);
69
- const compiled2 = cache.compile(expr, ['x', 'y', 'z']);
70
-
71
- // Different variable contexts should create different cache entries
72
- expect(compiled1).not.toBe(compiled2);
73
- });
74
-
75
- it('should provide cache statistics', () => {
76
- cache.compile('data.amount > 1000', ['data']);
77
- cache.compile('data.amount > 1000', ['data']); // Second call, increment hit
78
- cache.compile('data.name === "John"', ['data']);
79
-
80
- const stats = cache.getStats();
81
-
82
- expect(stats.size).toBe(2);
83
- expect(stats.totalHits).toBe(3);
84
- expect(stats.entries).toHaveLength(2);
85
- expect(stats.entries[0].hitCount).toBe(2); // Most frequently used
86
- });
87
-
88
- it('should evict LRU when cache is full', () => {
89
- const smallCache = new ExpressionCache(3);
90
-
91
- smallCache.compile('expr1', ['x']);
92
- smallCache.compile('expr2', ['x']);
93
- smallCache.compile('expr3', ['x']);
94
-
95
- // Access expr1 multiple times to increase hit count
96
- smallCache.compile('expr1', ['x']);
97
- smallCache.compile('expr1', ['x']);
98
-
99
- // Add a 4th expression, should evict least used (expr2 or expr3)
100
- smallCache.compile('expr4', ['x']);
101
-
102
- const stats = smallCache.getStats();
103
- expect(stats.size).toBe(3);
104
-
105
- // expr1 should still be cached (highest hit count)
106
- expect(smallCache.has('expr1', ['x'])).toBe(true);
107
- });
108
-
109
- it('should clear cache', () => {
110
- cache.compile('data.amount > 1000', ['data']);
111
- cache.compile('data.name === "John"', ['data']);
112
-
113
- expect(cache.getStats().size).toBe(2);
114
-
115
- cache.clear();
116
-
117
- expect(cache.getStats().size).toBe(0);
118
- });
119
-
120
- it('should handle complex expressions', () => {
121
- const expr = 'data.items.filter(item => item.price > 100).length';
122
- const varNames = ['data'];
123
-
124
- const compiled = cache.compile(expr, varNames);
125
- const result = compiled.fn({
126
- items: [
127
- { price: 50 },
128
- { price: 150 },
129
- { price: 200 },
130
- ],
131
- });
132
-
133
- expect(result).toBe(2);
134
- });
135
- });
@@ -1,110 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { ExpressionContext } from '../../evaluator/ExpressionContext';
3
-
4
- describe('ExpressionContext', () => {
5
- it('creates a context with initial data', () => {
6
- const ctx = new ExpressionContext({ name: 'Alice', age: 30 });
7
- expect(ctx.get('name')).toBe('Alice');
8
- expect(ctx.get('age')).toBe(30);
9
- });
10
-
11
- it('creates an empty context', () => {
12
- const ctx = new ExpressionContext();
13
- expect(ctx.get('anything')).toBeUndefined();
14
- });
15
-
16
- it('sets and gets values', () => {
17
- const ctx = new ExpressionContext();
18
- ctx.set('key', 'value');
19
- expect(ctx.get('key')).toBe('value');
20
- });
21
-
22
- it('checks existence with has()', () => {
23
- const ctx = new ExpressionContext({ x: 1 });
24
- expect(ctx.has('x')).toBe(true);
25
- expect(ctx.has('y')).toBe(false);
26
- });
27
-
28
- it('supports dot notation for nested access', () => {
29
- const ctx = new ExpressionContext({ user: { name: 'Bob', address: { city: 'NYC' } } });
30
- expect(ctx.get('user.name')).toBe('Bob');
31
- expect(ctx.get('user.address.city')).toBe('NYC');
32
- });
33
-
34
- it('returns undefined for non-existent nested paths', () => {
35
- const ctx = new ExpressionContext({ user: { name: 'Bob' } });
36
- expect(ctx.get('user.email')).toBeUndefined();
37
- expect(ctx.get('user.address.city')).toBeUndefined();
38
- });
39
-
40
- describe('scope management', () => {
41
- it('pushScope adds a new scope', () => {
42
- const ctx = new ExpressionContext({ base: 'value' });
43
- ctx.pushScope({ scoped: 'data' });
44
- expect(ctx.get('scoped')).toBe('data');
45
- expect(ctx.get('base')).toBe('value');
46
- });
47
-
48
- it('popScope removes the latest scope', () => {
49
- const ctx = new ExpressionContext({ base: 'value' });
50
- ctx.pushScope({ temp: 'data' });
51
- expect(ctx.get('temp')).toBe('data');
52
- ctx.popScope();
53
- expect(ctx.get('temp')).toBeUndefined();
54
- expect(ctx.get('base')).toBe('value');
55
- });
56
-
57
- it('inner scope shadows outer scope', () => {
58
- const ctx = new ExpressionContext({ name: 'outer' });
59
- ctx.pushScope({ name: 'inner' });
60
- expect(ctx.get('name')).toBe('inner');
61
- ctx.popScope();
62
- expect(ctx.get('name')).toBe('outer');
63
- });
64
-
65
- it('supports multiple nested scopes', () => {
66
- const ctx = new ExpressionContext({ level: 0 });
67
- ctx.pushScope({ level: 1 });
68
- ctx.pushScope({ level: 2 });
69
- expect(ctx.get('level')).toBe(2);
70
- ctx.popScope();
71
- expect(ctx.get('level')).toBe(1);
72
- ctx.popScope();
73
- expect(ctx.get('level')).toBe(0);
74
- });
75
- });
76
-
77
- describe('toObject', () => {
78
- it('flattens all scopes into one object', () => {
79
- const ctx = new ExpressionContext({ a: 1 });
80
- ctx.pushScope({ b: 2 });
81
- const obj = ctx.toObject();
82
- expect(obj.a).toBe(1);
83
- expect(obj.b).toBe(2);
84
- });
85
-
86
- it('inner scope values take precedence in flattened object', () => {
87
- const ctx = new ExpressionContext({ x: 'outer' });
88
- ctx.pushScope({ x: 'inner' });
89
- const obj = ctx.toObject();
90
- expect(obj.x).toBe('inner');
91
- });
92
- });
93
-
94
- describe('createChild', () => {
95
- it('creates a child context with additional data', () => {
96
- const parent = new ExpressionContext({ parent: 'value' });
97
- const child = parent.createChild({ child: 'data' });
98
- expect(child.get('parent')).toBe('value');
99
- expect(child.get('child')).toBe('data');
100
- });
101
-
102
- it('child modifications do not affect parent', () => {
103
- const parent = new ExpressionContext({ shared: 'original' });
104
- const child = parent.createChild({});
105
- child.set('shared', 'modified');
106
- expect(child.get('shared')).toBe('modified');
107
- expect(parent.get('shared')).toBe('original');
108
- });
109
- });
110
- });