@signaltree/enterprise 4.0.13 → 4.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaltree/enterprise",
3
- "version": "4.0.13",
3
+ "version": "4.0.15",
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,
@@ -43,6 +43,9 @@
43
43
  "dependencies": {
44
44
  "tslib": "^2.3.0"
45
45
  },
46
+ "devDependencies": {
47
+ "@signaltree/core": "workspace:*"
48
+ },
46
49
  "files": [
47
50
  "src",
48
51
  "README.md",
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './lib/diff-engine';
2
+ export * from './lib/path-index';
3
+ export * from './lib/update-engine';
4
+ export * from './lib/enterprise-enhancer';
5
+ export * from './lib/scheduler';
6
+ export * from './lib/thread-pools';
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/diff-engine"), exports);
5
+ tslib_1.__exportStar(require("./lib/path-index"), exports);
6
+ tslib_1.__exportStar(require("./lib/update-engine"), exports);
7
+ tslib_1.__exportStar(require("./lib/enterprise-enhancer"), exports);
8
+ tslib_1.__exportStar(require("./lib/scheduler"), exports);
9
+ tslib_1.__exportStar(require("./lib/thread-pools"), exports);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/enterprise/src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,0DAAgC;AAChC,6DAAmC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * DiffEngine - Efficient change detection for tree updates
3
+ * @packageDocumentation
4
+ */
5
+ import type { Path } from './path-index';
6
+ /**
7
+ * Type of change detected
8
+ */
9
+ export declare enum ChangeType {
10
+ ADD = "add",
11
+ UPDATE = "update",
12
+ DELETE = "delete",
13
+ REPLACE = "replace"
14
+ }
15
+ /**
16
+ * A detected change
17
+ */
18
+ export interface Change {
19
+ /** Type of change */
20
+ type: ChangeType;
21
+ /** Path to the changed value */
22
+ path: Path;
23
+ /** New value */
24
+ value?: unknown;
25
+ /** Old value (for updates/deletes) */
26
+ oldValue?: unknown;
27
+ }
28
+ /**
29
+ * Diff result
30
+ */
31
+ export interface Diff {
32
+ /** List of changes */
33
+ changes: Change[];
34
+ /** Whether any changes were detected */
35
+ hasChanges: boolean;
36
+ }
37
+ /**
38
+ * Configuration for diff operation
39
+ */
40
+ export interface DiffOptions {
41
+ /** Maximum depth to traverse */
42
+ maxDepth?: number;
43
+ /** Whether to detect deletions */
44
+ detectDeletions?: boolean;
45
+ /** Whether to ignore array order */
46
+ ignoreArrayOrder?: boolean;
47
+ /** Custom equality function */
48
+ equalityFn?: (a: unknown, b: unknown) => boolean;
49
+ /** Optional key validator for security (e.g., to prevent prototype pollution) */
50
+ keyValidator?: (key: string) => boolean;
51
+ }
52
+ /**
53
+ * DiffEngine
54
+ *
55
+ * Efficiently detects changes between two objects to minimize unnecessary updates.
56
+ *
57
+ * Features:
58
+ * - Deep object comparison
59
+ * - Circular reference detection
60
+ * - Configurable equality checking
61
+ * - Array diffing (ordered and unordered)
62
+ * - Path tracking for precise updates
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const engine = new DiffEngine();
67
+ *
68
+ * const current = { user: { name: 'Alice', age: 30 } };
69
+ * const updates = { user: { name: 'Alice', age: 31 } };
70
+ *
71
+ * const diff = engine.diff(current, updates);
72
+ *
73
+ * console.log(diff.changes);
74
+ * // [{ type: 'update', path: ['user', 'age'], value: 31, oldValue: 30 }]
75
+ * ```
76
+ */
77
+ export declare class DiffEngine {
78
+ private defaultOptions;
79
+ /**
80
+ * Diff two objects and return changes
81
+ *
82
+ * @param current - Current state
83
+ * @param updates - Updated state
84
+ * @param options - Diff options
85
+ * @returns Diff result with all changes
86
+ */
87
+ diff(current: unknown, updates: unknown, options?: DiffOptions): Diff;
88
+ /**
89
+ * Traverse and compare objects recursively
90
+ */
91
+ private traverse;
92
+ /**
93
+ * Diff arrays
94
+ */
95
+ private diffArrays;
96
+ /**
97
+ * Diff arrays in order (index-based)
98
+ */
99
+ private diffArraysOrdered;
100
+ /**
101
+ * Diff arrays ignoring order (value-based)
102
+ */
103
+ private diffArraysUnordered;
104
+ /**
105
+ * Stringify value for set comparison
106
+ */
107
+ private stringify;
108
+ }
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ /**
3
+ * DiffEngine - Efficient change detection for tree updates
4
+ * @packageDocumentation
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DiffEngine = exports.ChangeType = void 0;
8
+ /**
9
+ * Type of change detected
10
+ */
11
+ var ChangeType;
12
+ (function (ChangeType) {
13
+ ChangeType["ADD"] = "add";
14
+ ChangeType["UPDATE"] = "update";
15
+ ChangeType["DELETE"] = "delete";
16
+ ChangeType["REPLACE"] = "replace";
17
+ })(ChangeType || (exports.ChangeType = ChangeType = {}));
18
+ /**
19
+ * DiffEngine
20
+ *
21
+ * Efficiently detects changes between two objects to minimize unnecessary updates.
22
+ *
23
+ * Features:
24
+ * - Deep object comparison
25
+ * - Circular reference detection
26
+ * - Configurable equality checking
27
+ * - Array diffing (ordered and unordered)
28
+ * - Path tracking for precise updates
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const engine = new DiffEngine();
33
+ *
34
+ * const current = { user: { name: 'Alice', age: 30 } };
35
+ * const updates = { user: { name: 'Alice', age: 31 } };
36
+ *
37
+ * const diff = engine.diff(current, updates);
38
+ *
39
+ * console.log(diff.changes);
40
+ * // [{ type: 'update', path: ['user', 'age'], value: 31, oldValue: 30 }]
41
+ * ```
42
+ */
43
+ class DiffEngine {
44
+ constructor() {
45
+ this.defaultOptions = {
46
+ maxDepth: 100,
47
+ detectDeletions: false,
48
+ ignoreArrayOrder: false,
49
+ equalityFn: (a, b) => a === b,
50
+ keyValidator: undefined,
51
+ };
52
+ }
53
+ /**
54
+ * Diff two objects and return changes
55
+ *
56
+ * @param current - Current state
57
+ * @param updates - Updated state
58
+ * @param options - Diff options
59
+ * @returns Diff result with all changes
60
+ */
61
+ diff(current, updates, options = {}) {
62
+ const opts = Object.assign(Object.assign({}, this.defaultOptions), options);
63
+ const changes = [];
64
+ const visited = new WeakSet();
65
+ this.traverse(current, updates, [], changes, visited, opts, 0);
66
+ return {
67
+ changes,
68
+ hasChanges: changes.length > 0,
69
+ };
70
+ }
71
+ /**
72
+ * Traverse and compare objects recursively
73
+ */
74
+ traverse(curr, upd, path, changes, visited, opts, depth) {
75
+ // Depth limit
76
+ if (depth > opts.maxDepth) {
77
+ return;
78
+ }
79
+ // Handle primitives
80
+ if (typeof upd !== 'object' || upd === null) {
81
+ if (!opts.equalityFn(curr, upd)) {
82
+ changes.push({
83
+ type: curr === undefined ? ChangeType.ADD : ChangeType.UPDATE,
84
+ path: [...path],
85
+ value: upd,
86
+ oldValue: curr,
87
+ });
88
+ }
89
+ return;
90
+ }
91
+ // Circular reference detection
92
+ if (visited.has(upd)) {
93
+ return;
94
+ }
95
+ visited.add(upd);
96
+ // Handle arrays
97
+ if (Array.isArray(upd)) {
98
+ this.diffArrays(curr, upd, path, changes, visited, opts, depth);
99
+ return;
100
+ }
101
+ // Handle objects
102
+ if (!curr || typeof curr !== 'object' || Array.isArray(curr)) {
103
+ // Type mismatch - replace entire subtree
104
+ changes.push({
105
+ type: ChangeType.REPLACE,
106
+ path: [...path],
107
+ value: upd,
108
+ oldValue: curr,
109
+ });
110
+ return;
111
+ }
112
+ // Diff object properties
113
+ const currObj = curr;
114
+ const updObj = upd;
115
+ for (const key in updObj) {
116
+ if (Object.prototype.hasOwnProperty.call(updObj, key)) {
117
+ // Validate key for security (e.g., prevent prototype pollution)
118
+ if (opts.keyValidator && !opts.keyValidator(key)) {
119
+ // Skip dangerous keys silently
120
+ continue;
121
+ }
122
+ this.traverse(currObj[key], updObj[key], [...path, key], changes, visited, opts, depth + 1);
123
+ }
124
+ }
125
+ // Check for deletions if enabled
126
+ if (opts.detectDeletions) {
127
+ for (const key in currObj) {
128
+ if (Object.prototype.hasOwnProperty.call(currObj, key) &&
129
+ !(key in updObj)) {
130
+ changes.push({
131
+ type: ChangeType.DELETE,
132
+ path: [...path, key],
133
+ oldValue: currObj[key],
134
+ });
135
+ }
136
+ }
137
+ }
138
+ }
139
+ /**
140
+ * Diff arrays
141
+ */
142
+ diffArrays(curr, upd, path, changes, visited, opts, depth) {
143
+ if (!Array.isArray(curr)) {
144
+ // Not an array - replace
145
+ changes.push({
146
+ type: ChangeType.REPLACE,
147
+ path: [...path],
148
+ value: upd,
149
+ oldValue: curr,
150
+ });
151
+ return;
152
+ }
153
+ if (opts.ignoreArrayOrder) {
154
+ this.diffArraysUnordered(curr, upd, path, changes, opts);
155
+ }
156
+ else {
157
+ this.diffArraysOrdered(curr, upd, path, changes, visited, opts, depth);
158
+ }
159
+ }
160
+ /**
161
+ * Diff arrays in order (index-based)
162
+ */
163
+ diffArraysOrdered(curr, upd, path, changes, visited, opts, depth) {
164
+ // Check each index
165
+ const maxLength = Math.max(curr.length, upd.length);
166
+ for (let i = 0; i < maxLength; i++) {
167
+ if (i >= upd.length) {
168
+ // Deletion (if enabled)
169
+ if (opts.detectDeletions) {
170
+ changes.push({
171
+ type: ChangeType.DELETE,
172
+ path: [...path, i],
173
+ oldValue: curr[i],
174
+ });
175
+ }
176
+ }
177
+ else if (i >= curr.length) {
178
+ // Addition
179
+ changes.push({
180
+ type: ChangeType.ADD,
181
+ path: [...path, i],
182
+ value: upd[i],
183
+ });
184
+ }
185
+ else {
186
+ // Potential update
187
+ this.traverse(curr[i], upd[i], [...path, i], changes, visited, opts, depth + 1);
188
+ }
189
+ }
190
+ }
191
+ /**
192
+ * Diff arrays ignoring order (value-based)
193
+ */
194
+ diffArraysUnordered(curr, upd, path, changes, opts) {
195
+ // Build value sets
196
+ const currSet = new Set(curr.map((v) => this.stringify(v)));
197
+ const updSet = new Set(upd.map((v) => this.stringify(v)));
198
+ // Find additions
199
+ upd.forEach((value, index) => {
200
+ const str = this.stringify(value);
201
+ if (!currSet.has(str)) {
202
+ changes.push({
203
+ type: ChangeType.ADD,
204
+ path: [...path, index],
205
+ value,
206
+ });
207
+ }
208
+ });
209
+ // Find deletions (if enabled)
210
+ if (opts.detectDeletions) {
211
+ curr.forEach((value, index) => {
212
+ const str = this.stringify(value);
213
+ if (!updSet.has(str)) {
214
+ changes.push({
215
+ type: ChangeType.DELETE,
216
+ path: [...path, index],
217
+ oldValue: value,
218
+ });
219
+ }
220
+ });
221
+ }
222
+ }
223
+ /**
224
+ * Stringify value for set comparison
225
+ */
226
+ stringify(value) {
227
+ try {
228
+ return JSON.stringify(value);
229
+ }
230
+ catch (_a) {
231
+ return String(value);
232
+ }
233
+ }
234
+ }
235
+ exports.DiffEngine = DiffEngine;
236
+ //# sourceMappingURL=diff-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-engine.js","sourceRoot":"","sources":["../../../../../packages/enterprise/src/lib/diff-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;AACrB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAyDD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,UAAU;IAAvB;QACU,mBAAc,GAAwB;YAC5C,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,KAAK;YACtB,gBAAgB,EAAE,KAAK;YACvB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EA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AAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AA7PD,gCA6PC"}
@@ -0,0 +1,81 @@
1
+ import { PathIndex } from './path-index';
2
+ import { UpdateResult } from './update-engine';
3
+ import type { Signal } from '@angular/core';
4
+ import type { Enhancer } from '@signaltree/core';
5
+ /**
6
+ * Enterprise-grade optimizations for large-scale applications.
7
+ *
8
+ * **Includes:**
9
+ * - Diff-based updates (only update changed signals)
10
+ * - Bulk operation optimization (2-5x faster)
11
+ * - Advanced change tracking
12
+ * - Update statistics and monitoring
13
+ *
14
+ * **Use when:**
15
+ * - 500+ signals in state tree
16
+ * - Bulk updates at high frequency (60Hz+)
17
+ * - Real-time dashboards or data feeds
18
+ * - Enterprise-scale applications
19
+ *
20
+ * **Skip when:**
21
+ * - Small to medium apps (<100 signals)
22
+ * - Infrequent state updates
23
+ * - Startup/prototype projects
24
+ *
25
+ * **Bundle cost:** +2.4KB gzipped
26
+ * **Performance gain:** 2-5x faster bulk updates, detailed monitoring
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { signalTree } from '@signaltree/core';
31
+ * import { withEnterprise } from '@signaltree/enterprise';
32
+ *
33
+ * const tree = signalTree(largeState).with(withEnterprise());
34
+ *
35
+ * // Now available: optimized bulk updates
36
+ * const result = tree.updateOptimized(newData, {
37
+ * ignoreArrayOrder: true,
38
+ * maxDepth: 10
39
+ * });
40
+ *
41
+ * console.log(result.stats);
42
+ * // { totalChanges: 45, adds: 10, updates: 30, deletes: 5 }
43
+ * ```
44
+ *
45
+ * @public
46
+ */
47
+ export declare function withEnterprise<T extends Record<string, unknown>>(): Enhancer<T, T & EnterpriseEnhancedTree<T>>;
48
+ /**
49
+ * Type augmentation for trees enhanced with enterprise features.
50
+ * This is applied when using withEnterprise().
51
+ *
52
+ * @public
53
+ */
54
+ export interface EnterpriseEnhancedTree<T> {
55
+ /**
56
+ * Optimized bulk update method using diff-based change detection.
57
+ * Only available when using withEnterprise().
58
+ *
59
+ * @param newValue - The new state value
60
+ * @param options - Update options
61
+ * @returns Update result with statistics
62
+ */
63
+ updateOptimized(newValue: T, options?: {
64
+ /** Maximum depth to traverse (default: 100) */
65
+ maxDepth?: number;
66
+ /** Ignore array element order (default: false) */
67
+ ignoreArrayOrder?: boolean;
68
+ /** Custom equality function */
69
+ equalityFn?: (a: unknown, b: unknown) => boolean;
70
+ /** Automatically batch updates (default: true) */
71
+ autoBatch?: boolean;
72
+ /** Number of patches per batch (default: 10) */
73
+ batchSize?: number;
74
+ }): UpdateResult;
75
+ /**
76
+ * Get the PathIndex for debugging/monitoring.
77
+ * Only available when using withEnterprise().
78
+ * Returns null if updateOptimized hasn't been called yet (lazy initialization).
79
+ */
80
+ getPathIndex(): PathIndex<Signal<unknown>> | null;
81
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withEnterprise = withEnterprise;
4
+ const path_index_1 = require("./path-index");
5
+ const update_engine_1 = require("./update-engine");
6
+ /**
7
+ * Enterprise-grade optimizations for large-scale applications.
8
+ *
9
+ * **Includes:**
10
+ * - Diff-based updates (only update changed signals)
11
+ * - Bulk operation optimization (2-5x faster)
12
+ * - Advanced change tracking
13
+ * - Update statistics and monitoring
14
+ *
15
+ * **Use when:**
16
+ * - 500+ signals in state tree
17
+ * - Bulk updates at high frequency (60Hz+)
18
+ * - Real-time dashboards or data feeds
19
+ * - Enterprise-scale applications
20
+ *
21
+ * **Skip when:**
22
+ * - Small to medium apps (<100 signals)
23
+ * - Infrequent state updates
24
+ * - Startup/prototype projects
25
+ *
26
+ * **Bundle cost:** +2.4KB gzipped
27
+ * **Performance gain:** 2-5x faster bulk updates, detailed monitoring
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { signalTree } from '@signaltree/core';
32
+ * import { withEnterprise } from '@signaltree/enterprise';
33
+ *
34
+ * const tree = signalTree(largeState).with(withEnterprise());
35
+ *
36
+ * // Now available: optimized bulk updates
37
+ * const result = tree.updateOptimized(newData, {
38
+ * ignoreArrayOrder: true,
39
+ * maxDepth: 10
40
+ * });
41
+ *
42
+ * console.log(result.stats);
43
+ * // { totalChanges: 45, adds: 10, updates: 30, deletes: 5 }
44
+ * ```
45
+ *
46
+ * @public
47
+ */
48
+ function withEnterprise() {
49
+ return (tree) => {
50
+ // Lazy initialization - only create when first needed
51
+ let pathIndex = null;
52
+ let updateEngine = null;
53
+ // Type assertion to access SignalTree properties
54
+ const signalTree = tree;
55
+ // Cast tree to enhanced type for safe property assignment
56
+ const enhancedTree = tree;
57
+ // Add updateOptimized method to tree
58
+ enhancedTree.updateOptimized = (updates, options) => {
59
+ // Lazy initialize on first use
60
+ if (!updateEngine) {
61
+ pathIndex = new path_index_1.PathIndex();
62
+ pathIndex.buildFromTree(signalTree.state);
63
+ updateEngine = new update_engine_1.OptimizedUpdateEngine(signalTree.state);
64
+ }
65
+ const result = updateEngine.update(signalTree.state, updates, options);
66
+ // Rebuild index if changes were made
67
+ if (result.changed && result.stats && pathIndex) {
68
+ pathIndex.clear();
69
+ pathIndex.buildFromTree(signalTree.state);
70
+ }
71
+ return result;
72
+ };
73
+ // Add PathIndex access for debugging/monitoring
74
+ enhancedTree.getPathIndex = () => pathIndex;
75
+ return enhancedTree;
76
+ };
77
+ }
78
+ //# sourceMappingURL=enterprise-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enterprise-enhancer.js","sourceRoot":"","sources":["../../../../../packages/enterprise/src/lib/enterprise-enhancer.ts"],"names":[],"mappings":";;AA+CA,wCAiDC;AAhGD,6CAAyC;AACzC,mDAAsE;AAItE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,SAAgB,cAAc;IAI5B,OAAO,CAAC,IAAO,EAAiC,EAAE;QAChD,sDAAsD;QACtD,IAAI,SAAS,GAAsC,IAAI,CAAC;QACxD,IAAI,YAAY,GAAiC,IAAI,CAAC;QAEtD,iDAAiD;QACjD,MAAM,UAAU,GAAG,IAAqC,CAAC;QAEzD,0DAA0D;QAC1D,MAAM,YAAY,GAAG,IAAqC,CAAC;QAE3D,qCAAqC;QACrC,YAAY,CAAC,eAAe,GAAG,CAC7B,OAAmB,EACnB,OAMC,EACa,EAAE;YAChB,+BAA+B;YAC/B,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS,GAAG,IAAI,sBAAS,EAAmB,CAAC;gBAC7C,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAC1C,YAAY,GAAG,IAAI,qCAAqB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC7D,CAAC;YAED,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAEvE,qCAAqC;YACrC,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC;gBAChD,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,gDAAgD;QAChD,YAAY,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;QAE5C,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function enterprise(): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enterprise = enterprise;
4
+ function enterprise() {
5
+ return 'enterprise';
6
+ }
7
+ //# sourceMappingURL=enterprise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enterprise.js","sourceRoot":"","sources":["../../../../../packages/enterprise/src/lib/enterprise.ts"],"names":[],"mappings":";;AAAA,gCAEC;AAFD,SAAgB,UAAU;IACxB,OAAO,YAAY,CAAC;AACtB,CAAC"}