@memberjunction/global 2.62.0 → 2.63.1
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/dist/ClassFactory.d.ts +13 -2
- package/dist/ClassFactory.d.ts.map +1 -1
- package/dist/ClassFactory.js +35 -7
- package/dist/ClassFactory.js.map +1 -1
- package/dist/ClassUtils.d.ts +72 -0
- package/dist/ClassUtils.d.ts.map +1 -0
- package/dist/ClassUtils.js +202 -0
- package/dist/ClassUtils.js.map +1 -0
- package/dist/DeepDiff.d.ts +191 -0
- package/dist/DeepDiff.d.ts.map +1 -0
- package/dist/DeepDiff.js +342 -0
- package/dist/DeepDiff.js.map +1 -0
- package/dist/Global.d.ts +51 -0
- package/dist/Global.d.ts.map +1 -0
- package/dist/Global.js +81 -0
- package/dist/Global.js.map +1 -0
- package/dist/RegisterClass.d.ts +11 -0
- package/dist/RegisterClass.d.ts.map +1 -0
- package/dist/RegisterClass.js +21 -0
- package/dist/RegisterClass.js.map +1 -0
- package/dist/__tests__/ClassUtils.test.d.ts +2 -0
- package/dist/__tests__/ClassUtils.test.d.ts.map +1 -0
- package/dist/__tests__/ClassUtils.test.js +173 -0
- package/dist/__tests__/ClassUtils.test.js.map +1 -0
- package/dist/index.d.ts +4 -59
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -96
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +190 -6
package/dist/DeepDiff.js
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Deep difference comparison utility for JavaScript objects
|
|
4
|
+
*
|
|
5
|
+
* This module provides comprehensive utilities to generate detailed diffs between
|
|
6
|
+
* any two JavaScript objects, arrays, or primitive values. It recursively traverses
|
|
7
|
+
* nested structures and produces both machine-readable change objects and human-readable
|
|
8
|
+
* formatted output.
|
|
9
|
+
*
|
|
10
|
+
* Key features:
|
|
11
|
+
* - Deep recursive comparison of objects and arrays
|
|
12
|
+
* - Configurable depth limits and output formatting
|
|
13
|
+
* - Path tracking for nested changes
|
|
14
|
+
* - Summary statistics for change types
|
|
15
|
+
* - Human-readable formatted output
|
|
16
|
+
* - Type-safe change tracking
|
|
17
|
+
*
|
|
18
|
+
* @module @memberjunction/global
|
|
19
|
+
* @author MemberJunction.com
|
|
20
|
+
* @since 2.63.0
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const differ = new DeepDiffer();
|
|
25
|
+
* const diff = differ.diff(
|
|
26
|
+
* { name: 'John', age: 30, hobbies: ['reading'] },
|
|
27
|
+
* { name: 'John', age: 31, hobbies: ['reading', 'gaming'] }
|
|
28
|
+
* );
|
|
29
|
+
* console.log(diff.formatted);
|
|
30
|
+
* // Output:
|
|
31
|
+
* // Modified: age
|
|
32
|
+
* // Changed from 30 to 31
|
|
33
|
+
* // Modified: hobbies
|
|
34
|
+
* // Array length changed from 1 to 2
|
|
35
|
+
* // Added: hobbies[1]
|
|
36
|
+
* // Added "gaming"
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
40
|
+
if (k2 === undefined) k2 = k;
|
|
41
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
42
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
43
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
44
|
+
}
|
|
45
|
+
Object.defineProperty(o, k2, desc);
|
|
46
|
+
}) : (function(o, m, k, k2) {
|
|
47
|
+
if (k2 === undefined) k2 = k;
|
|
48
|
+
o[k2] = m[k];
|
|
49
|
+
}));
|
|
50
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
51
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
52
|
+
}) : function(o, v) {
|
|
53
|
+
o["default"] = v;
|
|
54
|
+
});
|
|
55
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
56
|
+
if (mod && mod.__esModule) return mod;
|
|
57
|
+
var result = {};
|
|
58
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
59
|
+
__setModuleDefault(result, mod);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.DeepDiffer = exports.DiffChangeType = void 0;
|
|
64
|
+
const _ = __importStar(require("lodash"));
|
|
65
|
+
/**
|
|
66
|
+
* Types of changes that can occur in a deep diff operation
|
|
67
|
+
*/
|
|
68
|
+
var DiffChangeType;
|
|
69
|
+
(function (DiffChangeType) {
|
|
70
|
+
/** A new property or value was added */
|
|
71
|
+
DiffChangeType["Added"] = "added";
|
|
72
|
+
/** An existing property or value was removed */
|
|
73
|
+
DiffChangeType["Removed"] = "removed";
|
|
74
|
+
/** An existing value was changed to a different value */
|
|
75
|
+
DiffChangeType["Modified"] = "modified";
|
|
76
|
+
/** No change detected (only included when includeUnchanged is true) */
|
|
77
|
+
DiffChangeType["Unchanged"] = "unchanged";
|
|
78
|
+
})(DiffChangeType || (exports.DiffChangeType = DiffChangeType = {}));
|
|
79
|
+
/**
|
|
80
|
+
* Deep difference generator for comparing JavaScript objects, arrays, and primitives.
|
|
81
|
+
*
|
|
82
|
+
* This class provides comprehensive comparison capabilities with configurable
|
|
83
|
+
* output formatting and depth control.
|
|
84
|
+
*/
|
|
85
|
+
class DeepDiffer {
|
|
86
|
+
/**
|
|
87
|
+
* Creates a new DeepDiffer instance
|
|
88
|
+
* @param config - Optional configuration overrides
|
|
89
|
+
*/
|
|
90
|
+
constructor(config) {
|
|
91
|
+
this.config = {
|
|
92
|
+
includeUnchanged: false,
|
|
93
|
+
maxDepth: 10,
|
|
94
|
+
maxStringLength: 100,
|
|
95
|
+
includeArrayIndices: true,
|
|
96
|
+
...config
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate a deep diff between two values
|
|
101
|
+
*
|
|
102
|
+
* @param oldValue - The original value
|
|
103
|
+
* @param newValue - The new value to compare against
|
|
104
|
+
* @returns Complete diff results including changes, summary, and formatted output
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const differ = new DeepDiffer({ includeUnchanged: true });
|
|
109
|
+
* const result = differ.diff(
|
|
110
|
+
* { users: [{ id: 1, name: 'Alice' }] },
|
|
111
|
+
* { users: [{ id: 1, name: 'Alice Cooper' }] }
|
|
112
|
+
* );
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
diff(oldValue, newValue) {
|
|
116
|
+
const changes = [];
|
|
117
|
+
// Generate the diff recursively
|
|
118
|
+
this.generateDiff(oldValue, newValue, [], changes, 0);
|
|
119
|
+
// Sort changes by path for consistency
|
|
120
|
+
changes.sort((a, b) => a.path.localeCompare(b.path));
|
|
121
|
+
// Generate summary
|
|
122
|
+
const summary = {
|
|
123
|
+
added: changes.filter(c => c.type === DiffChangeType.Added).length,
|
|
124
|
+
removed: changes.filter(c => c.type === DiffChangeType.Removed).length,
|
|
125
|
+
modified: changes.filter(c => c.type === DiffChangeType.Modified).length,
|
|
126
|
+
unchanged: changes.filter(c => c.type === DiffChangeType.Unchanged).length,
|
|
127
|
+
totalPaths: changes.length
|
|
128
|
+
};
|
|
129
|
+
// Generate formatted output
|
|
130
|
+
const formatted = this.formatDiff(changes, summary);
|
|
131
|
+
return {
|
|
132
|
+
changes,
|
|
133
|
+
summary,
|
|
134
|
+
formatted
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Update configuration options
|
|
139
|
+
* @param config - Partial configuration to merge with existing config
|
|
140
|
+
*/
|
|
141
|
+
updateConfig(config) {
|
|
142
|
+
this.config = { ...this.config, ...config };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Recursively generate diff between two values
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
generateDiff(oldValue, newValue, path, changes, depth) {
|
|
149
|
+
// Check depth limit
|
|
150
|
+
if (depth > this.config.maxDepth) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const pathStr = path.join('.');
|
|
154
|
+
// Handle different cases
|
|
155
|
+
if (oldValue === newValue) {
|
|
156
|
+
if (this.config.includeUnchanged) {
|
|
157
|
+
changes.push({
|
|
158
|
+
path: pathStr || 'root',
|
|
159
|
+
type: DiffChangeType.Unchanged,
|
|
160
|
+
oldValue,
|
|
161
|
+
newValue,
|
|
162
|
+
description: 'No change'
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (oldValue === undefined && newValue !== undefined) {
|
|
167
|
+
changes.push({
|
|
168
|
+
path: pathStr || 'root',
|
|
169
|
+
type: DiffChangeType.Added,
|
|
170
|
+
newValue,
|
|
171
|
+
description: this.describeValue(newValue, 'Added')
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else if (oldValue !== undefined && newValue === undefined) {
|
|
175
|
+
changes.push({
|
|
176
|
+
path: pathStr || 'root',
|
|
177
|
+
type: DiffChangeType.Removed,
|
|
178
|
+
oldValue,
|
|
179
|
+
description: this.describeValue(oldValue, 'Removed')
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
183
|
+
this.diffArrays(oldValue, newValue, path, changes, depth);
|
|
184
|
+
}
|
|
185
|
+
else if (_.isObject(oldValue) && _.isObject(newValue)) {
|
|
186
|
+
this.diffObjects(oldValue, newValue, path, changes, depth);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// Values are different types or primitives
|
|
190
|
+
changes.push({
|
|
191
|
+
path: pathStr || 'root',
|
|
192
|
+
type: DiffChangeType.Modified,
|
|
193
|
+
oldValue,
|
|
194
|
+
newValue,
|
|
195
|
+
description: `Changed from ${this.describeValue(oldValue)} to ${this.describeValue(newValue)}`
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Compare two arrays and generate diff
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
diffArrays(oldArray, newArray, path, changes, depth) {
|
|
204
|
+
const pathStr = path.join('.');
|
|
205
|
+
// Check if array lengths are different
|
|
206
|
+
if (oldArray.length !== newArray.length) {
|
|
207
|
+
changes.push({
|
|
208
|
+
path: pathStr || 'root',
|
|
209
|
+
type: DiffChangeType.Modified,
|
|
210
|
+
oldValue: `Array[${oldArray.length}]`,
|
|
211
|
+
newValue: `Array[${newArray.length}]`,
|
|
212
|
+
description: `Array length changed from ${oldArray.length} to ${newArray.length}`
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// Compare array elements
|
|
216
|
+
const maxLength = Math.max(oldArray.length, newArray.length);
|
|
217
|
+
for (let i = 0; i < maxLength; i++) {
|
|
218
|
+
const elementPath = this.config.includeArrayIndices
|
|
219
|
+
? [...path, `[${i}]`]
|
|
220
|
+
: [...path, `[]`];
|
|
221
|
+
if (i < oldArray.length && i < newArray.length) {
|
|
222
|
+
// Element exists in both arrays
|
|
223
|
+
this.generateDiff(oldArray[i], newArray[i], elementPath, changes, depth + 1);
|
|
224
|
+
}
|
|
225
|
+
else if (i < oldArray.length) {
|
|
226
|
+
// Element was removed
|
|
227
|
+
changes.push({
|
|
228
|
+
path: elementPath.join('.'),
|
|
229
|
+
type: DiffChangeType.Removed,
|
|
230
|
+
oldValue: oldArray[i],
|
|
231
|
+
description: this.describeValue(oldArray[i], 'Removed')
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
// Element was added
|
|
236
|
+
changes.push({
|
|
237
|
+
path: elementPath.join('.'),
|
|
238
|
+
type: DiffChangeType.Added,
|
|
239
|
+
newValue: newArray[i],
|
|
240
|
+
description: this.describeValue(newArray[i], 'Added')
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Compare two objects and generate diff
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
diffObjects(oldObj, newObj, path, changes, depth) {
|
|
250
|
+
// Get all unique keys from both objects
|
|
251
|
+
const allKeys = new Set([
|
|
252
|
+
...Object.keys(oldObj),
|
|
253
|
+
...Object.keys(newObj)
|
|
254
|
+
]);
|
|
255
|
+
// Compare each key
|
|
256
|
+
for (const key of allKeys) {
|
|
257
|
+
const keyPath = [...path, key];
|
|
258
|
+
this.generateDiff(oldObj[key], newObj[key], keyPath, changes, depth + 1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Create a human-readable description of a value
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
describeValue(value, prefix) {
|
|
266
|
+
if (this.config.valueFormatter) {
|
|
267
|
+
const type = Array.isArray(value) ? 'array' : typeof value;
|
|
268
|
+
return this.config.valueFormatter(value, type);
|
|
269
|
+
}
|
|
270
|
+
const description = this.getValueDescription(value);
|
|
271
|
+
return prefix ? `${prefix} ${description}` : description;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get a description of a value for display
|
|
275
|
+
* @private
|
|
276
|
+
*/
|
|
277
|
+
getValueDescription(value) {
|
|
278
|
+
if (value === null)
|
|
279
|
+
return 'null';
|
|
280
|
+
if (value === undefined)
|
|
281
|
+
return 'undefined';
|
|
282
|
+
const type = typeof value;
|
|
283
|
+
if (type === 'string') {
|
|
284
|
+
const str = value.length > this.config.maxStringLength
|
|
285
|
+
? `"${value.substring(0, this.config.maxStringLength)}..."`
|
|
286
|
+
: `"${value}"`;
|
|
287
|
+
return str;
|
|
288
|
+
}
|
|
289
|
+
if (type === 'number' || type === 'boolean') {
|
|
290
|
+
return String(value);
|
|
291
|
+
}
|
|
292
|
+
if (Array.isArray(value)) {
|
|
293
|
+
return `Array[${value.length}]`;
|
|
294
|
+
}
|
|
295
|
+
if (_.isObject(value)) {
|
|
296
|
+
const keys = Object.keys(value);
|
|
297
|
+
return `Object{${keys.length} ${keys.length === 1 ? 'key' : 'keys'}}`;
|
|
298
|
+
}
|
|
299
|
+
return String(value);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Format the diff results as a human-readable string
|
|
303
|
+
* @private
|
|
304
|
+
*/
|
|
305
|
+
formatDiff(changes, summary) {
|
|
306
|
+
const lines = [];
|
|
307
|
+
// Add summary header
|
|
308
|
+
lines.push('=== Deep Diff Summary ===');
|
|
309
|
+
lines.push(`Total changes: ${summary.added + summary.removed + summary.modified}`);
|
|
310
|
+
if (summary.added > 0)
|
|
311
|
+
lines.push(` Added: ${summary.added}`);
|
|
312
|
+
if (summary.removed > 0)
|
|
313
|
+
lines.push(` Removed: ${summary.removed}`);
|
|
314
|
+
if (summary.modified > 0)
|
|
315
|
+
lines.push(` Modified: ${summary.modified}`);
|
|
316
|
+
if (this.config.includeUnchanged && summary.unchanged > 0) {
|
|
317
|
+
lines.push(` Unchanged: ${summary.unchanged}`);
|
|
318
|
+
}
|
|
319
|
+
lines.push('');
|
|
320
|
+
// Add changes
|
|
321
|
+
if (changes.length > 0) {
|
|
322
|
+
lines.push('=== Changes ===');
|
|
323
|
+
// Group changes by type for better readability
|
|
324
|
+
const changesByType = _.groupBy(changes, 'type');
|
|
325
|
+
for (const type of [DiffChangeType.Added, DiffChangeType.Removed, DiffChangeType.Modified]) {
|
|
326
|
+
const typeChanges = changesByType[type];
|
|
327
|
+
if (typeChanges && typeChanges.length > 0) {
|
|
328
|
+
lines.push(`\n${type.charAt(0).toUpperCase() + type.slice(1)}:`);
|
|
329
|
+
for (const change of typeChanges) {
|
|
330
|
+
lines.push(` ${change.path}: ${change.description}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (this.config.includeUnchanged && changesByType[DiffChangeType.Unchanged]) {
|
|
335
|
+
lines.push(`\nUnchanged (${changesByType[DiffChangeType.Unchanged].length} items)`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return lines.join('\n');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
exports.DeepDiffer = DeepDiffer;
|
|
342
|
+
//# sourceMappingURL=DeepDiff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeepDiff.js","sourceRoot":"","sources":["../src/DeepDiff.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0CAA4B;AAE5B;;GAEG;AACH,IAAY,cASX;AATD,WAAY,cAAc;IACtB,wCAAwC;IACxC,iCAAe,CAAA;IACf,gDAAgD;IAChD,qCAAmB,CAAA;IACnB,yDAAyD;IACzD,uCAAqB,CAAA;IACrB,uEAAuE;IACvE,yCAAuB,CAAA;AAC3B,CAAC,EATW,cAAc,8BAAd,cAAc,QASzB;AAmFD;;;;;GAKG;AACH,MAAa,UAAU;IAGnB;;;OAGG;IACH,YAAY,MAAgC;QACxC,IAAI,CAAC,MAAM,GAAG;YACV,gBAAgB,EAAE,KAAK;YACvB,QAAQ,EAAE,EAAE;YACZ,eAAe,EAAE,GAAG;YACpB,mBAAmB,EAAE,IAAI;YACzB,GAAG,MAAM;SACZ,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,IAAI,CAAU,QAAW,EAAE,QAAW;QACzC,MAAM,OAAO,GAAiB,EAAE,CAAC;QAEjC,gCAAgC;QAChC,IAAI,CAAC,YAAY,CACb,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,OAAO,EACP,CAAC,CACJ,CAAC;QAEF,uCAAuC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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AI,CAAC,gBAAgB,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC;YACxF,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACJ;AAnTD,gCAmTC"}
|
package/dist/Global.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as MJ from './interface';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ClassFactory } from './ClassFactory';
|
|
4
|
+
import { ObjectCache } from './ObjectCache';
|
|
5
|
+
import { BaseSingleton } from './BaseSingleton';
|
|
6
|
+
/**
|
|
7
|
+
* Global class used for coordinating events, creating class instances, and managing components across MemberJunction
|
|
8
|
+
*/
|
|
9
|
+
export declare class MJGlobal extends BaseSingleton<MJGlobal> {
|
|
10
|
+
private _eventsSubject;
|
|
11
|
+
private _eventsReplaySubject;
|
|
12
|
+
private _events$;
|
|
13
|
+
private _eventsReplay$;
|
|
14
|
+
private _components;
|
|
15
|
+
private _classFactory;
|
|
16
|
+
private _properties;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the global instance of the MJGlobal class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of MJGlobal, always use this method to get the instance.
|
|
19
|
+
*/
|
|
20
|
+
static get Instance(): MJGlobal;
|
|
21
|
+
RegisterComponent(component: MJ.IMJComponent): void;
|
|
22
|
+
/**
|
|
23
|
+
* Resets the class to its initial state. Use very carefully and sparingly.
|
|
24
|
+
*/
|
|
25
|
+
Reset(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Use this method to raise an event to all component who are listening for the event.
|
|
28
|
+
* @param event
|
|
29
|
+
*/
|
|
30
|
+
RaiseEvent(event: MJ.MJEvent): void;
|
|
31
|
+
/**
|
|
32
|
+
* Use this method to get an observable that will fire when an event is raised.
|
|
33
|
+
* @param withReplay
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
GetEventListener(withReplay?: boolean): Observable<MJ.MJEvent>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the instance of ClassFactory you should use in your application. Access this via the MJGlobal.Instance.ClassFactory property.
|
|
39
|
+
*/
|
|
40
|
+
get ClassFactory(): ClassFactory;
|
|
41
|
+
/**
|
|
42
|
+
* Global property bag
|
|
43
|
+
*/
|
|
44
|
+
get Properties(): MJ.MJGlobalProperty[];
|
|
45
|
+
private _objectCache;
|
|
46
|
+
/**
|
|
47
|
+
* ObjectCache can be used to cache objects as needed by any application in memory. These objects are NOT persisted to disk or any other storage medium, so they are only good for the lifetime of the application
|
|
48
|
+
*/
|
|
49
|
+
get ObjectCache(): ObjectCache;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=Global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Global.d.ts","sourceRoot":"","sources":["../src/Global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAA0B,UAAU,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAAa,CAAC,QAAQ,CAAC;IAEjD,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,oBAAoB,CAAkD;IAG9E,OAAO,CAAC,QAAQ,CAA8D;IAC9E,OAAO,CAAC,cAAc,CAAoE;IAE1F,OAAO,CAAC,WAAW,CAAyB;IAE5C,OAAO,CAAC,aAAa,CAAoC;IAEzD,OAAO,CAAC,WAAW,CAA6B;IAEhD;;OAEG;IACH,WAAkB,QAAQ,IAAI,QAAQ,CAErC;IAEM,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY;IAInD;;OAEG;IACI,KAAK;IAWZ;;;OAGG;IACI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO;IAKnC;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,GAAE,OAAe,GAAG,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC;IAI5E;;OAEG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAE7C;IAGD,OAAO,CAAC,YAAY,CAAkC;IACtD;;OAEG;IACH,IAAW,WAAW,IAAI,WAAW,CAEpC;CACJ"}
|
package/dist/Global.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MJGlobal = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const ClassFactory_1 = require("./ClassFactory");
|
|
6
|
+
const ObjectCache_1 = require("./ObjectCache");
|
|
7
|
+
const BaseSingleton_1 = require("./BaseSingleton");
|
|
8
|
+
/**
|
|
9
|
+
* Global class used for coordinating events, creating class instances, and managing components across MemberJunction
|
|
10
|
+
*/
|
|
11
|
+
class MJGlobal extends BaseSingleton_1.BaseSingleton {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
// subjects for observables to handle eventing
|
|
15
|
+
this._eventsSubject = new rxjs_1.Subject();
|
|
16
|
+
this._eventsReplaySubject = new rxjs_1.ReplaySubject();
|
|
17
|
+
// Convert the Subjects to Observables for public use.
|
|
18
|
+
this._events$ = this._eventsSubject.asObservable();
|
|
19
|
+
this._eventsReplay$ = this._eventsReplaySubject.asObservable();
|
|
20
|
+
this._components = [];
|
|
21
|
+
this._classFactory = new ClassFactory_1.ClassFactory();
|
|
22
|
+
this._properties = [];
|
|
23
|
+
this._objectCache = new ObjectCache_1.ObjectCache();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the global instance of the MJGlobal class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of MJGlobal, always use this method to get the instance.
|
|
27
|
+
*/
|
|
28
|
+
static get Instance() {
|
|
29
|
+
return super.getInstance();
|
|
30
|
+
}
|
|
31
|
+
RegisterComponent(component) {
|
|
32
|
+
this._components.push(component);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resets the class to its initial state. Use very carefully and sparingly.
|
|
36
|
+
*/
|
|
37
|
+
Reset() {
|
|
38
|
+
this._components = [];
|
|
39
|
+
this._eventsSubject = new rxjs_1.Subject();
|
|
40
|
+
this._eventsReplaySubject = new rxjs_1.ReplaySubject();
|
|
41
|
+
// Convert the Subjects to Observables for public use.
|
|
42
|
+
this._events$ = this._eventsSubject.asObservable();
|
|
43
|
+
this._eventsReplay$ = this._eventsReplaySubject.asObservable();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Use this method to raise an event to all component who are listening for the event.
|
|
47
|
+
* @param event
|
|
48
|
+
*/
|
|
49
|
+
RaiseEvent(event) {
|
|
50
|
+
this._eventsSubject.next(event);
|
|
51
|
+
this._eventsReplaySubject.next(event);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Use this method to get an observable that will fire when an event is raised.
|
|
55
|
+
* @param withReplay
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
GetEventListener(withReplay = false) {
|
|
59
|
+
return withReplay ? this._eventsReplay$ : this._events$;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the instance of ClassFactory you should use in your application. Access this via the MJGlobal.Instance.ClassFactory property.
|
|
63
|
+
*/
|
|
64
|
+
get ClassFactory() {
|
|
65
|
+
return this._classFactory;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Global property bag
|
|
69
|
+
*/
|
|
70
|
+
get Properties() {
|
|
71
|
+
return this._properties;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* ObjectCache can be used to cache objects as needed by any application in memory. These objects are NOT persisted to disk or any other storage medium, so they are only good for the lifetime of the application
|
|
75
|
+
*/
|
|
76
|
+
get ObjectCache() {
|
|
77
|
+
return this._objectCache;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.MJGlobal = MJGlobal;
|
|
81
|
+
//# sourceMappingURL=Global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Global.js","sourceRoot":"","sources":["../src/Global.ts"],"names":[],"mappings":";;;AACA,+BAA0D;AAC1D,iDAA6C;AAC7C,+CAA4C;AAC5C,mDAAgD;AAEhD;;GAEG;AACH,MAAa,QAAS,SAAQ,6BAAuB;IAArD;;QACI,8CAA8C;QACtC,mBAAc,GAAwB,IAAI,cAAO,EAAE,CAAC;QACpD,yBAAoB,GAA8B,IAAI,oBAAa,EAAE,CAAC;QAE9E,sDAAsD;QAC9C,aAAQ,GAA2B,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;QACtE,mBAAc,GAA2B,IAAI,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC;QAElF,gBAAW,GAAsB,EAAE,CAAC;QAEpC,kBAAa,GAAiB,IAAI,2BAAY,EAAE,CAAC;QAEjD,gBAAW,GAA0B,EAAE,CAAC;QA4DxC,iBAAY,GAAgB,IAAI,yBAAW,EAAE,CAAC;IAO1D,CAAC;IAjEG;;OAEG;IACI,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,EAAY,CAAC;IACzC,CAAC;IAEM,iBAAiB,CAAC,SAA0B;QAC/C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QAEtB,IAAI,CAAC,cAAc,GAAI,IAAI,cAAO,EAAE,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAa,EAAE,CAAC;QAEhD,sDAAsD;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,KAAiB;QAC/B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,aAAsB,KAAK;QAC/C,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAID;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AAhFD,4BAgFC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
3
|
+
* @param baseClass
|
|
4
|
+
* @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
|
|
5
|
+
* @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
|
|
6
|
+
* @param skipNullKeyWarning If true, will not print a warning if the key is null or undefined. This is useful for cases where you know that the key is not needed and you don't want to see the warning in the console.
|
|
7
|
+
* @param autoRegisterWithRootClass If true (default), will automatically register the subclass with the root class of the baseClass hierarchy. This ensures proper priority ordering when multiple subclasses are registered in a hierarchy.
|
|
8
|
+
* @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
|
|
9
|
+
*/
|
|
10
|
+
export declare function RegisterClass(baseClass: any, key?: string, priority?: number, skipNullKeyWarning?: boolean, autoRegisterWithRootClass?: boolean): (constructor: Function) => void;
|
|
11
|
+
//# sourceMappingURL=RegisterClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisterClass.d.ts","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAE,MAAa,EAAE,QAAQ,GAAE,MAAU,EAAE,kBAAkB,GAAE,OAAe,EAAE,yBAAyB,GAAE,OAAc,GAAG,CAAC,WAAW,EAAE,QAAQ,KAAK,IAAI,CAKvM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegisterClass = void 0;
|
|
4
|
+
const Global_1 = require("./Global");
|
|
5
|
+
/**
|
|
6
|
+
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
7
|
+
* @param baseClass
|
|
8
|
+
* @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
|
|
9
|
+
* @param priority Higher priority registrations will be used over lower priority registrations. If there are multiple registrations for a given base class/sub-class/key combination, the one with the highest priority will be used. If there are multiple registrations with the same priority, the last one registered will be used. Finally, if you do NOT provide this setting, the order of registrations will increment the priority automatically so dependency injection will typically care care of this. That is, in order for Class B, a subclass of Class A, to be registered properly, Class A code has to already have been loaded and therefore Class A's RegisterClass decorator was run. In that scenario, if neither Class A or B has a priority setting, Class A would be 1 and Class B would be 2 automatically. For this reason, you only need to explicitly set priority if you want to do something atypical as this mechanism normally will solve for setting the priority correctly based on the furthest descendant class that is registered.
|
|
10
|
+
* @param skipNullKeyWarning If true, will not print a warning if the key is null or undefined. This is useful for cases where you know that the key is not needed and you don't want to see the warning in the console.
|
|
11
|
+
* @param autoRegisterWithRootClass If true (default), will automatically register the subclass with the root class of the baseClass hierarchy. This ensures proper priority ordering when multiple subclasses are registered in a hierarchy.
|
|
12
|
+
* @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
|
|
13
|
+
*/
|
|
14
|
+
function RegisterClass(baseClass, key = null, priority = 0, skipNullKeyWarning = false, autoRegisterWithRootClass = true) {
|
|
15
|
+
return function (constructor) {
|
|
16
|
+
// Invoke the registration method
|
|
17
|
+
Global_1.MJGlobal.Instance.ClassFactory.Register(baseClass, constructor, key, priority, skipNullKeyWarning, autoRegisterWithRootClass);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.RegisterClass = RegisterClass;
|
|
21
|
+
//# sourceMappingURL=RegisterClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisterClass.js","sourceRoot":"","sources":["../src/RegisterClass.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAEpC;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,SAAc,EAAE,MAAc,IAAI,EAAE,WAAmB,CAAC,EAAE,qBAA8B,KAAK,EAAE,4BAAqC,IAAI;IAClK,OAAO,UAAU,WAAqB;QAClC,iCAAiC;QACjC,iBAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;IAClI,CAAC,CAAA;AACL,CAAC;AALD,sCAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassUtils.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ClassUtils.test.ts"],"names":[],"mappings":""}
|