@memberjunction/core-entities 6.1.4 → 6.2.0-edge.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/.tsbuildinfo +1 -1
- package/dist/artifact-extraction/artifact-extractor.d.ts +1 -1
- package/dist/artifact-extraction/artifact-extractor.js +2 -2
- package/dist/custom/MJConversationDetailEntityExtended.d.ts +1 -1
- package/dist/custom/MJConversationDetailEntityExtended.js +5 -5
- package/dist/custom/MJTemplateEntityExtended.d.ts +2 -2
- package/dist/custom/MJTemplateEntityExtended.js +6 -6
- package/dist/custom/MJUserViewEntityExtended.d.ts +4 -4
- package/dist/custom/MJUserViewEntityExtended.js +22 -22
- package/dist/custom/MJUserViewEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts +8 -0
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.js +20 -4
- package/dist/custom/Permissions/BaseShareEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/MJAccessControlRuleEntityExtended.js +4 -4
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js +5 -5
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js +5 -5
- package/dist/custom/Permissions/MJDashboardPermissionEntityExtended.js +5 -5
- package/dist/custom/ResourcePermissions/MJResourcePermissionEntityExtended.js +2 -2
- package/dist/custom/ResourcePermissions/ResourcePermissionEngine.d.ts +2 -2
- package/dist/custom/ResourcePermissions/ResourcePermissionEngine.js +5 -5
- package/dist/engines/ApplicationSettingEngine.d.ts +1 -1
- package/dist/engines/ApplicationSettingEngine.js +8 -8
- package/dist/engines/AuditLogTypeEngine.d.ts +1 -1
- package/dist/engines/AuditLogTypeEngine.js +4 -4
- package/dist/engines/InstanceConfigEngine.d.ts +1 -1
- package/dist/engines/InstanceConfigEngine.js +2 -2
- package/dist/engines/MCPEngine.d.ts +4 -4
- package/dist/engines/MCPEngine.js +24 -24
- package/dist/engines/PermissionEngine.d.ts +2 -0
- package/dist/engines/PermissionEngine.d.ts.map +1 -1
- package/dist/engines/PermissionEngine.js +5 -1
- package/dist/engines/PermissionEngine.js.map +1 -1
- package/dist/engines/ResourceTypeEngine.d.ts +1 -1
- package/dist/engines/ResourceTypeEngine.js +4 -4
- package/dist/engines/TypeTablesCache.d.ts +1 -1
- package/dist/engines/TypeTablesCache.js +3 -3
- package/dist/engines/UserInfoEngine.d.ts +8 -8
- package/dist/engines/UserInfoEngine.js +48 -48
- package/dist/engines/UserRoutineEngine.d.ts +3 -3
- package/dist/engines/UserRoutineEngine.js +15 -15
- package/dist/engines/conversations.d.ts +183 -7
- package/dist/engines/conversations.d.ts.map +1 -1
- package/dist/engines/conversations.js +418 -57
- package/dist/engines/conversations.js.map +1 -1
- package/dist/generated/entities/__mj.d.ts +1999 -292
- package/dist/generated/entities/__mj.d.ts.map +1 -1
- package/dist/generated/entities/__mj.js +1430 -13
- package/dist/generated/entities/__mj.js.map +1 -1
- package/dist/generated/remote_operations.d.ts +100 -0
- package/dist/generated/remote_operations.d.ts.map +1 -1
- package/dist/generated/remote_operations.js +18 -0
- package/dist/generated/remote_operations.js.map +1 -1
- package/package.json +5 -5
|
@@ -5,14 +5,14 @@ import { BaseEngine } from "@memberjunction/core";
|
|
|
5
5
|
export class TypeTablesCache extends BaseEngine {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
|
-
this.
|
|
8
|
+
this._entityRelationshipDisplayComponents = [];
|
|
9
9
|
}
|
|
10
10
|
async Config(forceRefresh, contextUser, provider) {
|
|
11
11
|
const c = [
|
|
12
12
|
{
|
|
13
13
|
Type: 'entity',
|
|
14
14
|
EntityName: 'MJ: Entity Relationship Display Components',
|
|
15
|
-
PropertyName: '
|
|
15
|
+
PropertyName: '_entityRelationshipDisplayComponents',
|
|
16
16
|
CacheLocal: true
|
|
17
17
|
}
|
|
18
18
|
];
|
|
@@ -22,7 +22,7 @@ export class TypeTablesCache extends BaseEngine {
|
|
|
22
22
|
return super.getInstance();
|
|
23
23
|
}
|
|
24
24
|
get EntityRelationshipDisplayComponents() {
|
|
25
|
-
return this.GetConfigData('
|
|
25
|
+
return this.GetConfigData('_entityRelationshipDisplayComponents');
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=TypeTablesCache.js.map
|
|
@@ -59,14 +59,14 @@ export declare class UserInfoEngine extends BaseEngine<UserInfoEngine> {
|
|
|
59
59
|
* Do not directly create new instances of it, always use this method to get the instance.
|
|
60
60
|
*/
|
|
61
61
|
static get Instance(): UserInfoEngine;
|
|
62
|
-
private
|
|
63
|
-
private
|
|
64
|
-
private
|
|
65
|
-
private
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
private
|
|
69
|
-
private
|
|
62
|
+
private _userNotifications;
|
|
63
|
+
private _workspaces;
|
|
64
|
+
private _userApplications;
|
|
65
|
+
private _userFavorites;
|
|
66
|
+
private _userRecordLogs;
|
|
67
|
+
private _userSettings;
|
|
68
|
+
private _notificationTypes;
|
|
69
|
+
private _userNotificationPreferences;
|
|
70
70
|
private _applicationRoles;
|
|
71
71
|
private _applicationAccessFilter;
|
|
72
72
|
private _applicationAdminFilter;
|
|
@@ -32,16 +32,16 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
32
32
|
constructor() {
|
|
33
33
|
super(...arguments);
|
|
34
34
|
// Private storage for entity data
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
35
|
+
this._userNotifications = [];
|
|
36
|
+
this._workspaces = [];
|
|
37
|
+
this._userApplications = [];
|
|
38
|
+
this._userFavorites = [];
|
|
39
|
+
this._userRecordLogs = [];
|
|
40
|
+
this._userSettings = [];
|
|
41
41
|
// Notification types (global - not user-specific)
|
|
42
|
-
this.
|
|
42
|
+
this._notificationTypes = [];
|
|
43
43
|
// User notification preferences (user-specific)
|
|
44
|
-
this.
|
|
44
|
+
this._userNotificationPreferences = [];
|
|
45
45
|
// Application role assignments (global - not user-specific)
|
|
46
46
|
this._applicationRoles = [];
|
|
47
47
|
// Optional filters for customizing application access/admin checks (e.g., tenant-scoped roles)
|
|
@@ -109,35 +109,35 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
109
109
|
{
|
|
110
110
|
Type: 'entity',
|
|
111
111
|
EntityName: 'MJ: User Notifications',
|
|
112
|
-
PropertyName: '
|
|
112
|
+
PropertyName: '_userNotifications',
|
|
113
113
|
CacheLocal: true,
|
|
114
114
|
Filter: userFilter,
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
Type: 'entity',
|
|
118
118
|
EntityName: 'MJ: User Notification Types',
|
|
119
|
-
PropertyName: '
|
|
119
|
+
PropertyName: '_notificationTypes',
|
|
120
120
|
CacheLocal: true,
|
|
121
121
|
// Global reference table — no user filter
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
Type: 'entity',
|
|
125
125
|
EntityName: 'MJ: Workspaces',
|
|
126
|
-
PropertyName: '
|
|
126
|
+
PropertyName: '_workspaces',
|
|
127
127
|
CacheLocal: true,
|
|
128
128
|
Filter: userFilter,
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
Type: 'entity',
|
|
132
132
|
EntityName: 'MJ: User Settings',
|
|
133
|
-
PropertyName: '
|
|
133
|
+
PropertyName: '_userSettings',
|
|
134
134
|
CacheLocal: true,
|
|
135
135
|
Filter: userFilter,
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
Type: 'entity',
|
|
139
139
|
EntityName: 'MJ: User Applications',
|
|
140
|
-
PropertyName: '
|
|
140
|
+
PropertyName: '_userApplications',
|
|
141
141
|
CacheLocal: true,
|
|
142
142
|
Filter: userFilter,
|
|
143
143
|
// Short debounce (vs the 1500ms BaseEngine default). The app switcher, the
|
|
@@ -150,21 +150,21 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
150
150
|
{
|
|
151
151
|
Type: 'entity',
|
|
152
152
|
EntityName: 'MJ: User Favorites',
|
|
153
|
-
PropertyName: '
|
|
153
|
+
PropertyName: '_userFavorites',
|
|
154
154
|
CacheLocal: true,
|
|
155
155
|
Filter: userFilter,
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
Type: 'entity',
|
|
159
159
|
EntityName: 'MJ: User Record Logs',
|
|
160
|
-
PropertyName: '
|
|
160
|
+
PropertyName: '_userRecordLogs',
|
|
161
161
|
CacheLocal: true,
|
|
162
162
|
Filter: userFilter,
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
Type: 'entity',
|
|
166
166
|
EntityName: 'MJ: User Notification Preferences',
|
|
167
|
-
PropertyName: '
|
|
167
|
+
PropertyName: '_userNotificationPreferences',
|
|
168
168
|
CacheLocal: true,
|
|
169
169
|
Filter: userFilter,
|
|
170
170
|
},
|
|
@@ -190,21 +190,21 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
190
190
|
* `pipe(map(...))` — the public {@link UserNotifications} getter applies the current-user filter.
|
|
191
191
|
*/
|
|
192
192
|
get UserNotifications$() {
|
|
193
|
-
return this.ObserveProperty('
|
|
193
|
+
return this.ObserveProperty('_userNotifications');
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* Observable stream of the user favorites cache array. Emits the current array on subscribe
|
|
197
197
|
* and re-emits whenever the cache is mutated.
|
|
198
198
|
*/
|
|
199
199
|
get UserFavorites$() {
|
|
200
|
-
return this.ObserveProperty('
|
|
200
|
+
return this.ObserveProperty('_userFavorites');
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Observable stream of the user applications cache array. Emits the current array on subscribe
|
|
204
204
|
* and re-emits whenever the cache is mutated.
|
|
205
205
|
*/
|
|
206
206
|
get UserApplications$() {
|
|
207
|
-
return this.ObserveProperty('
|
|
207
|
+
return this.ObserveProperty('_userApplications');
|
|
208
208
|
}
|
|
209
209
|
// ========================================================================
|
|
210
210
|
// PUBLIC ACCESSORS
|
|
@@ -215,7 +215,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
215
215
|
get UserNotifications() {
|
|
216
216
|
if (!this._loadedForUserId)
|
|
217
217
|
return [];
|
|
218
|
-
return this.GetConfigData('
|
|
218
|
+
return this.GetConfigData('_userNotifications')
|
|
219
219
|
.filter((n) => UUIDsEqual(n.UserID, this._loadedForUserId))
|
|
220
220
|
.sort((a, b) => new Date(b.Get('__mj_CreatedAt')).getTime() - new Date(a.Get('__mj_CreatedAt')).getTime());
|
|
221
221
|
}
|
|
@@ -225,7 +225,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
225
225
|
get UserSettings() {
|
|
226
226
|
if (!this._loadedForUserId)
|
|
227
227
|
return [];
|
|
228
|
-
return this.GetConfigData('
|
|
228
|
+
return this.GetConfigData('_userSettings')
|
|
229
229
|
.filter((s) => UUIDsEqual(s.UserID, this._loadedForUserId));
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
@@ -297,7 +297,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
297
297
|
// session/device, or out-of-band) — the UPDATE matched nothing. Recover by
|
|
298
298
|
// recreating the setting instead of failing the write.
|
|
299
299
|
console.warn(`UserInfoEngine.SetSetting: update for '${settingKey}' matched no row — recreating`);
|
|
300
|
-
this.
|
|
300
|
+
this._userSettings = this._userSettings.filter((s) => !UUIDsEqual(s.ID, setting.ID));
|
|
301
301
|
setting = await md.GetEntityObject('MJ: User Settings', contextUser);
|
|
302
302
|
setting.NewRecord();
|
|
303
303
|
setting.UserID = userId;
|
|
@@ -307,8 +307,8 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
307
307
|
}
|
|
308
308
|
if (saved) {
|
|
309
309
|
// If it was a new record, add to cache
|
|
310
|
-
if (!this.
|
|
311
|
-
this.
|
|
310
|
+
if (!this._userSettings.some((s) => UUIDsEqual(s.ID, setting.ID))) {
|
|
311
|
+
this._userSettings.push(setting);
|
|
312
312
|
}
|
|
313
313
|
return true;
|
|
314
314
|
}
|
|
@@ -337,9 +337,9 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
337
337
|
const deleted = await setting.Delete();
|
|
338
338
|
if (deleted) {
|
|
339
339
|
// Remove from cache
|
|
340
|
-
const index = this.
|
|
340
|
+
const index = this._userSettings.findIndex((s) => UUIDsEqual(s.ID, setting.ID));
|
|
341
341
|
if (index >= 0) {
|
|
342
|
-
this.
|
|
342
|
+
this._userSettings.splice(index, 1);
|
|
343
343
|
}
|
|
344
344
|
return true;
|
|
345
345
|
}
|
|
@@ -491,7 +491,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
491
491
|
get Workspaces() {
|
|
492
492
|
if (!this._loadedForUserId)
|
|
493
493
|
return [];
|
|
494
|
-
return this.GetConfigData('
|
|
494
|
+
return this.GetConfigData('_workspaces')
|
|
495
495
|
.filter((w) => UUIDsEqual(w.UserID, this._loadedForUserId));
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
@@ -508,7 +508,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
508
508
|
get UserApplications() {
|
|
509
509
|
if (!this._loadedForUserId)
|
|
510
510
|
return [];
|
|
511
|
-
return this.GetConfigData('
|
|
511
|
+
return this.GetConfigData('_userApplications')
|
|
512
512
|
.filter((ua) => UUIDsEqual(ua.UserID, this._loadedForUserId))
|
|
513
513
|
.sort((a, b) => this.compareUserApplications(a, b));
|
|
514
514
|
}
|
|
@@ -543,7 +543,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
543
543
|
get UserFavorites() {
|
|
544
544
|
if (!this._loadedForUserId)
|
|
545
545
|
return [];
|
|
546
|
-
return this.GetConfigData('
|
|
546
|
+
return this.GetConfigData('_userFavorites')
|
|
547
547
|
.filter((f) => UUIDsEqual(f.UserID, this._loadedForUserId))
|
|
548
548
|
.sort((a, b) => new Date(b.Get('__mj_CreatedAt')).getTime() - new Date(a.Get('__mj_CreatedAt')).getTime());
|
|
549
549
|
}
|
|
@@ -553,7 +553,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
553
553
|
get UserRecordLogs() {
|
|
554
554
|
if (!this._loadedForUserId)
|
|
555
555
|
return [];
|
|
556
|
-
return this.GetConfigData('
|
|
556
|
+
return this.GetConfigData('_userRecordLogs')
|
|
557
557
|
.filter((r) => UUIDsEqual(r.UserID, this._loadedForUserId))
|
|
558
558
|
.sort((a, b) => new Date(b.LatestAt).getTime() - new Date(a.LatestAt).getTime());
|
|
559
559
|
}
|
|
@@ -565,21 +565,21 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
565
565
|
* Useful for server-side admin scenarios.
|
|
566
566
|
*/
|
|
567
567
|
get AllNotifications() {
|
|
568
|
-
return this.GetConfigData('
|
|
568
|
+
return this.GetConfigData('_userNotifications');
|
|
569
569
|
}
|
|
570
570
|
/**
|
|
571
571
|
* Get ALL user applications in the cache (unfiltered by user).
|
|
572
572
|
* Useful for server-side admin scenarios.
|
|
573
573
|
*/
|
|
574
574
|
get AllUserApplications() {
|
|
575
|
-
return this.GetConfigData('
|
|
575
|
+
return this.GetConfigData('_userApplications');
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
578
578
|
* Get notifications for a specific user
|
|
579
579
|
* @param userId - The user ID to filter by
|
|
580
580
|
*/
|
|
581
581
|
GetNotificationsForUser(userId) {
|
|
582
|
-
return (this.
|
|
582
|
+
return (this._userNotifications || [])
|
|
583
583
|
.filter((n) => UUIDsEqual(n.UserID, userId))
|
|
584
584
|
.sort((a, b) => new Date(b.Get('__mj_CreatedAt')).getTime() - new Date(a.Get('__mj_CreatedAt')).getTime());
|
|
585
585
|
}
|
|
@@ -588,7 +588,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
588
588
|
* @param userId - The user ID to filter by
|
|
589
589
|
*/
|
|
590
590
|
GetUserApplicationsForUser(userId) {
|
|
591
|
-
return (this.
|
|
591
|
+
return (this._userApplications || [])
|
|
592
592
|
.filter((ua) => UUIDsEqual(ua.UserID, userId))
|
|
593
593
|
.sort((a, b) => this.compareUserApplications(a, b));
|
|
594
594
|
}
|
|
@@ -892,7 +892,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
892
892
|
const saved = await userApp.Save();
|
|
893
893
|
if (saved) {
|
|
894
894
|
// Add to cached array
|
|
895
|
-
this.
|
|
895
|
+
this._userApplications.push(userApp);
|
|
896
896
|
console.log(`UserInfoEngine.InstallApplication: Installed application ${applicationId} for user ${userId}`);
|
|
897
897
|
return userApp;
|
|
898
898
|
}
|
|
@@ -1007,15 +1007,15 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1007
1007
|
const deleted = await userApp.Delete();
|
|
1008
1008
|
if (deleted) {
|
|
1009
1009
|
// Remove from cached array
|
|
1010
|
-
const index = this.
|
|
1010
|
+
const index = this._userApplications.findIndex((ua) => UUIDsEqual(ua.ApplicationID, applicationId));
|
|
1011
1011
|
if (index >= 0) {
|
|
1012
|
-
this.
|
|
1012
|
+
this._userApplications.splice(index, 1);
|
|
1013
1013
|
// The debounced BaseEngine delete handler stays silent for rows already absent
|
|
1014
1014
|
// from the array (it can't distinguish "we spliced it" from "never matched the
|
|
1015
1015
|
// config's Filter"), so the code that spliced must notify observers itself —
|
|
1016
1016
|
// otherwise DataChange$ consumers (ApplicationManager → app switcher / Home)
|
|
1017
1017
|
// never learn the app was removed.
|
|
1018
|
-
const config = this.Configs.find((c) => c.PropertyName === '
|
|
1018
|
+
const config = this.Configs.find((c) => c.PropertyName === '_userApplications');
|
|
1019
1019
|
if (config) {
|
|
1020
1020
|
this.notifyAlreadyAppliedMutation(config, 'delete', userApp);
|
|
1021
1021
|
}
|
|
@@ -1075,9 +1075,9 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1075
1075
|
BypassCache: true
|
|
1076
1076
|
}, contextUser ?? this.ContextUser);
|
|
1077
1077
|
if (dbResult.Success && dbResult.Results.length > 0) {
|
|
1078
|
-
LogStatus(`UserInfoEngine: Repaired
|
|
1079
|
-
this.
|
|
1080
|
-
this.emitPropertyChange('
|
|
1078
|
+
LogStatus(`UserInfoEngine: Repaired _userApplications from database (${dbResult.Results.length} records) — in-memory cache was empty`);
|
|
1079
|
+
this._userApplications = dbResult.Results;
|
|
1080
|
+
this.emitPropertyChange('_userApplications');
|
|
1081
1081
|
return dbResult.Results;
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
@@ -1100,7 +1100,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1100
1100
|
// Verify against the database before creating — if the in-memory cache is empty
|
|
1101
1101
|
// due to a load failure (e.g., cache timestamp bug), we'd otherwise attempt to
|
|
1102
1102
|
// create records that already exist, hitting unique constraint violations.
|
|
1103
|
-
const userAppsForUser = this.
|
|
1103
|
+
const userAppsForUser = this._userApplications.filter((ua) => UUIDsEqual(ua.UserID, userId));
|
|
1104
1104
|
if (userAppsForUser.length === 0) {
|
|
1105
1105
|
const repaired = await this.repairUserApplicationsFromDatabase(userId, contextUser);
|
|
1106
1106
|
if (repaired.length > 0) {
|
|
@@ -1108,7 +1108,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
1110
|
// Get existing UserApplication records for this user to prevent duplicates
|
|
1111
|
-
const existingAppIds = new Set(this.
|
|
1111
|
+
const existingAppIds = new Set(this._userApplications.filter((ua) => UUIDsEqual(ua.UserID, userId)).map((ua) => ua.ApplicationID));
|
|
1112
1112
|
// Active apps flagged DefaultForNewUser, in DefaultSequence order (shared source of truth),
|
|
1113
1113
|
// then exclude apps that already have UserApplication records for this user.
|
|
1114
1114
|
const defaultApps = UserInfoEngine_1.GetDefaultApplicationsForNewUser(md).filter((a) => !existingAppIds.has(a.ID));
|
|
@@ -1119,7 +1119,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1119
1119
|
console.log(`UserInfoEngine.CreateDefaultApplications: Found ${defaultApps.length} default apps to install`);
|
|
1120
1120
|
const createdUserApps = [];
|
|
1121
1121
|
// Calculate starting sequence based on existing apps
|
|
1122
|
-
const maxExistingSequence = this.
|
|
1122
|
+
const maxExistingSequence = this._userApplications.filter((ua) => UUIDsEqual(ua.UserID, userId)).reduce((max, ua) => Math.max(max, ua.Sequence), -1);
|
|
1123
1123
|
for (const [index, appInfo] of defaultApps.entries()) {
|
|
1124
1124
|
try {
|
|
1125
1125
|
const userApp = await md.GetEntityObject('MJ: User Applications', contextUser);
|
|
@@ -1130,7 +1130,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1130
1130
|
userApp.IsActive = true;
|
|
1131
1131
|
const saved = await userApp.Save();
|
|
1132
1132
|
if (saved) {
|
|
1133
|
-
this.
|
|
1133
|
+
this._userApplications.push(userApp);
|
|
1134
1134
|
createdUserApps.push(userApp);
|
|
1135
1135
|
console.log(`UserInfoEngine.CreateDefaultApplications: Created UserApplication for ${appInfo.Name}`);
|
|
1136
1136
|
}
|
|
@@ -1150,11 +1150,11 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1150
1150
|
get NotificationPreferences() {
|
|
1151
1151
|
if (!this._loadedForUserId)
|
|
1152
1152
|
return [];
|
|
1153
|
-
return this.GetConfigData('
|
|
1153
|
+
return this.GetConfigData('_userNotificationPreferences')
|
|
1154
1154
|
.filter((p) => UUIDsEqual(p.UserID, this._loadedForUserId));
|
|
1155
1155
|
}
|
|
1156
1156
|
GetUserPreferenceForType(userId, typeId) {
|
|
1157
|
-
return (this.
|
|
1157
|
+
return (this._userNotificationPreferences || []).find((p) => UUIDsEqual(p.UserID, userId) && UUIDsEqual(p.NotificationTypeID, typeId));
|
|
1158
1158
|
}
|
|
1159
1159
|
/**
|
|
1160
1160
|
* Get current user's preference for a specific notification type
|
|
@@ -1169,7 +1169,7 @@ let UserInfoEngine = UserInfoEngine_1 = class UserInfoEngine extends BaseEngine
|
|
|
1169
1169
|
* Notification types are global (not user-specific) and define the available notification categories.
|
|
1170
1170
|
*/
|
|
1171
1171
|
get NotificationTypes() {
|
|
1172
|
-
return this.GetConfigData('
|
|
1172
|
+
return this.GetConfigData('_notificationTypes');
|
|
1173
1173
|
}
|
|
1174
1174
|
};
|
|
1175
1175
|
UserInfoEngine = UserInfoEngine_1 = __decorate([
|
|
@@ -36,9 +36,9 @@ export declare class UserRoutineEngine extends BaseEngine<UserRoutineEngine> {
|
|
|
36
36
|
* of it, always use this method (or `GetProviderInstance` for non-default providers).
|
|
37
37
|
*/
|
|
38
38
|
static get Instance(): UserRoutineEngine;
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
39
|
+
private _routines;
|
|
40
|
+
private _recipients;
|
|
41
|
+
private _runs;
|
|
42
42
|
private _loadedForUserId;
|
|
43
43
|
/**
|
|
44
44
|
* Configures the engine by loading the current user's routines, recipients, and runs.
|
|
@@ -34,9 +34,9 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
36
|
// Private storage for entity data (populated by BaseEngine.Load via Configs)
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
37
|
+
this._routines = [];
|
|
38
|
+
this._recipients = [];
|
|
39
|
+
this._runs = [];
|
|
40
40
|
// Track the user ID we loaded data for
|
|
41
41
|
this._loadedForUserId = null;
|
|
42
42
|
}
|
|
@@ -70,19 +70,19 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
70
70
|
{
|
|
71
71
|
Type: 'entity',
|
|
72
72
|
EntityName: 'MJ: User Routines',
|
|
73
|
-
PropertyName: '
|
|
73
|
+
PropertyName: '_routines',
|
|
74
74
|
CacheLocal: true,
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
Type: 'entity',
|
|
78
78
|
EntityName: 'MJ: User Routine Recipients',
|
|
79
|
-
PropertyName: '
|
|
79
|
+
PropertyName: '_recipients',
|
|
80
80
|
CacheLocal: true,
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
Type: 'entity',
|
|
84
84
|
EntityName: 'MJ: User Routine Runs',
|
|
85
|
-
PropertyName: '
|
|
85
|
+
PropertyName: '_runs',
|
|
86
86
|
CacheLocal: true,
|
|
87
87
|
},
|
|
88
88
|
];
|
|
@@ -98,15 +98,15 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
98
98
|
* need the per-user view should read the {@link Routines} getter inside the subscription.
|
|
99
99
|
*/
|
|
100
100
|
get Routines$() {
|
|
101
|
-
return this.ObserveProperty('
|
|
101
|
+
return this.ObserveProperty('_routines');
|
|
102
102
|
}
|
|
103
103
|
/** Observable stream of the recipients cache (raw). */
|
|
104
104
|
get Recipients$() {
|
|
105
|
-
return this.ObserveProperty('
|
|
105
|
+
return this.ObserveProperty('_recipients');
|
|
106
106
|
}
|
|
107
107
|
/** Observable stream of the runs cache (raw). */
|
|
108
108
|
get Runs$() {
|
|
109
|
-
return this.ObserveProperty('
|
|
109
|
+
return this.ObserveProperty('_runs');
|
|
110
110
|
}
|
|
111
111
|
// ========================================================================
|
|
112
112
|
// PUBLIC ACCESSORS (per-user filtered)
|
|
@@ -115,14 +115,14 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
115
115
|
get Routines() {
|
|
116
116
|
if (!this._loadedForUserId)
|
|
117
117
|
return [];
|
|
118
|
-
return this.GetConfigData('
|
|
118
|
+
return this.GetConfigData('_routines')
|
|
119
119
|
.filter((r) => UUIDsEqual(r.UserID, this._loadedForUserId))
|
|
120
120
|
.sort((a, b) => (a.Name || '').localeCompare(b.Name || ''));
|
|
121
121
|
}
|
|
122
122
|
/** All recipients across the loaded user's routines. */
|
|
123
123
|
get Recipients() {
|
|
124
124
|
const routineIds = this.loadedRoutineIdSet();
|
|
125
|
-
return this.GetConfigData('
|
|
125
|
+
return this.GetConfigData('_recipients').filter((r) => routineIds.has(NormalizeUUID(r.RoutineID)));
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Recent runs across the loaded user's routines, most recent first (capped at
|
|
@@ -130,7 +130,7 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
130
130
|
*/
|
|
131
131
|
get RecentRuns() {
|
|
132
132
|
const routineIds = this.loadedRoutineIdSet();
|
|
133
|
-
return this.GetConfigData('
|
|
133
|
+
return this.GetConfigData('_runs')
|
|
134
134
|
.filter((r) => routineIds.has(NormalizeUUID(r.RoutineID)))
|
|
135
135
|
.sort((a, b) => new Date(b.StartedAt).getTime() - new Date(a.StartedAt).getTime())
|
|
136
136
|
.slice(0, RECENT_RUNS_CAP);
|
|
@@ -144,20 +144,20 @@ export class UserRoutineEngine extends BaseEngine {
|
|
|
144
144
|
}
|
|
145
145
|
/** Runs for one routine, most recent first. */
|
|
146
146
|
RunsForRoutine(routineId, maxRuns) {
|
|
147
|
-
const runs = this.GetConfigData('
|
|
147
|
+
const runs = this.GetConfigData('_runs')
|
|
148
148
|
.filter((r) => UUIDsEqual(r.RoutineID, routineId))
|
|
149
149
|
.sort((a, b) => new Date(b.StartedAt).getTime() - new Date(a.StartedAt).getTime());
|
|
150
150
|
return maxRuns != null && maxRuns > 0 ? runs.slice(0, maxRuns) : runs;
|
|
151
151
|
}
|
|
152
152
|
/** Recipients for one routine, in Sequence order. */
|
|
153
153
|
RecipientsForRoutine(routineId) {
|
|
154
|
-
return this.GetConfigData('
|
|
154
|
+
return this.GetConfigData('_recipients')
|
|
155
155
|
.filter((r) => UUIDsEqual(r.RoutineID, routineId))
|
|
156
156
|
.sort((a, b) => a.Sequence - b.Sequence);
|
|
157
157
|
}
|
|
158
158
|
/** Routines for an arbitrary user (server-side / admin scenarios; raw cache scan). */
|
|
159
159
|
GetRoutinesForUser(userId) {
|
|
160
|
-
return (this.
|
|
160
|
+
return (this._routines || [])
|
|
161
161
|
.filter((r) => UUIDsEqual(r.UserID, userId))
|
|
162
162
|
.sort((a, b) => (a.Name || '').localeCompare(b.Name || ''));
|
|
163
163
|
}
|