@signaltree/enterprise 4.0.4 → 4.0.7

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 (2) hide show
  1. package/README.md +203 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # @signaltree/enterprise
2
+
3
+ Enterprise-grade optimizations for SignalTree. Designed for large-scale applications with 500+ signals and high-frequency bulk updates.
4
+
5
+ ## Features
6
+
7
+ - **Diff-based updates** - Only update signals that actually changed
8
+ - **Bulk operation optimization** - 2-5x faster for large state updates
9
+ - **Advanced change tracking** - Detailed statistics and monitoring
10
+ - **Path indexing** - Optimized signal lookup for large trees
11
+ - **Lazy initialization** - Zero overhead until first use
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @signaltree/core @signaltree/enterprise
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { signalTree } from '@signaltree/core';
23
+ import { withEnterprise } from '@signaltree/enterprise';
24
+
25
+ const tree = signalTree(largeState).with(withEnterprise());
26
+
27
+ // Use optimized bulk updates
28
+ const result = tree.updateOptimized(newData, {
29
+ ignoreArrayOrder: true,
30
+ maxDepth: 10,
31
+ });
32
+
33
+ console.log(result.stats);
34
+ // { totalChanges: 45, adds: 10, updates: 30, deletes: 5 }
35
+ ```
36
+
37
+ ## When to Use
38
+
39
+ ### ✅ Use @signaltree/enterprise when:
40
+
41
+ - You have 500+ signals in your state tree
42
+ - Bulk updates happen at high frequency (60Hz+)
43
+ - You need real-time dashboards or data feeds
44
+ - You're building enterprise-scale applications
45
+ - You need detailed update monitoring and statistics
46
+
47
+ ### ❌ Skip @signaltree/enterprise when:
48
+
49
+ - Small to medium apps (<100 signals)
50
+ - Infrequent state updates
51
+ - Startup/prototype projects
52
+ - Bundle size is critical (adds +2.4KB gzipped)
53
+
54
+ ## API
55
+
56
+ ### `withEnterprise()`
57
+
58
+ Enhancer that adds enterprise optimizations to a SignalTree.
59
+
60
+ ```typescript
61
+ import { signalTree } from '@signaltree/core';
62
+ import { withEnterprise } from '@signaltree/enterprise';
63
+
64
+ const tree = signalTree(initialState).with(withEnterprise());
65
+ ```
66
+
67
+ ### `tree.updateOptimized(updates, options?)`
68
+
69
+ Performs optimized bulk updates using diff-based change detection.
70
+
71
+ **Parameters:**
72
+
73
+ - `updates: Partial<T>` - The new state values
74
+ - `options?: UpdateOptions` - Configuration options
75
+
76
+ **Options:**
77
+
78
+ ```typescript
79
+ {
80
+ maxDepth?: number; // Maximum depth to traverse (default: 100)
81
+ ignoreArrayOrder?: boolean; // Ignore array element order (default: false)
82
+ equalityFn?: (a, b) => boolean; // Custom equality function
83
+ autoBatch?: boolean; // Automatically batch updates (default: true)
84
+ batchSize?: number; // Patches per batch (default: 10)
85
+ }
86
+ ```
87
+
88
+ **Returns:**
89
+
90
+ ```typescript
91
+ {
92
+ changed: boolean; // Whether any changes were made
93
+ stats: {
94
+ totalChanges: number; // Total number of changes
95
+ adds: number; // New properties added
96
+ updates: number; // Properties updated
97
+ deletes: number; // Properties deleted
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### `tree.getPathIndex()`
103
+
104
+ Get the PathIndex for debugging/monitoring. Returns `null` if `updateOptimized` hasn't been called yet (lazy initialization).
105
+
106
+ ```typescript
107
+ const index = tree.getPathIndex();
108
+ if (index) {
109
+ console.log('Path index active');
110
+ }
111
+ ```
112
+
113
+ ## Examples
114
+
115
+ ### Real-time Dashboard
116
+
117
+ ```typescript
118
+ import { signalTree } from '@signaltree/core';
119
+ import { withEnterprise } from '@signaltree/enterprise';
120
+
121
+ interface DashboardState {
122
+ metrics: Record<string, number>;
123
+ alerts: Alert[];
124
+ users: User[];
125
+ // ... hundreds more properties
126
+ }
127
+
128
+ const dashboard = signalTree<DashboardState>(initialState).with(withEnterprise());
129
+
130
+ // High-frequency updates from WebSocket
131
+ socket.on('metrics', (newMetrics) => {
132
+ const result = dashboard.updateOptimized({ metrics: newMetrics }, { ignoreArrayOrder: true });
133
+
134
+ console.log(`Updated ${result.stats.updates} metrics`);
135
+ });
136
+ ```
137
+
138
+ ### Data Grid with Bulk Operations
139
+
140
+ ```typescript
141
+ import { signalTree } from '@signaltree/core';
142
+ import { withEnterprise } from '@signaltree/enterprise';
143
+
144
+ const grid = signalTree({
145
+ rows: [] as GridRow[],
146
+ columns: [] as GridColumn[],
147
+ filters: {} as FilterState,
148
+ selection: new Set<string>(),
149
+ }).with(withEnterprise());
150
+
151
+ // Bulk update from API
152
+ async function loadData() {
153
+ const data = await fetchGridData();
154
+
155
+ const result = grid.updateOptimized(data, {
156
+ maxDepth: 5,
157
+ autoBatch: true,
158
+ });
159
+
160
+ console.log(`Loaded ${result.stats.adds} rows in bulk`);
161
+ }
162
+ ```
163
+
164
+ ### Custom Equality for Complex Objects
165
+
166
+ ```typescript
167
+ const tree = signalTree(complexState).with(withEnterprise());
168
+
169
+ tree.updateOptimized(newState, {
170
+ equalityFn: (a, b) => {
171
+ // Custom deep equality for specific object types
172
+ if (a instanceof Date && b instanceof Date) {
173
+ return a.getTime() === b.getTime();
174
+ }
175
+ return a === b;
176
+ },
177
+ });
178
+ ```
179
+
180
+ ## Performance
181
+
182
+ **Bundle Size:**
183
+
184
+ - Adds +2.4KB gzipped to your bundle
185
+ - Zero overhead until first `updateOptimized()` call (lazy initialization)
186
+
187
+ **Performance Gains:**
188
+
189
+ - 2-5x faster for bulk updates on large state trees
190
+ - Scales efficiently with tree depth and complexity
191
+ - Minimal memory overhead with path indexing
192
+
193
+ ## License
194
+
195
+ Business Source License 1.1 (BSL-1.1) - See [LICENSE](../../LICENSE) for details.
196
+
197
+ Converts to MIT license on the Change Date specified in the license.
198
+
199
+ ## Related Packages
200
+
201
+ - [@signaltree/core](../core) - Core SignalTree functionality
202
+ - [@signaltree/ng-forms](../ng-forms) - Angular forms integration
203
+ - [@signaltree/callable-syntax](../callable-syntax) - Callable syntax transform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaltree/enterprise",
3
- "version": "4.0.4",
3
+ "version": "4.0.7",
4
4
  "description": "Enterprise-grade optimizations for SignalTree. Provides diff-based updates, bulk operation optimization, and advanced change tracking for large-scale applications.",
5
5
  "type": "module",
6
6
  "sideEffects": false,