@memberjunction/ng-shared-generic 6.2.0-edge.3 → 6.2.0-edge.5
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/lib/_tokens.scss +52 -6
- package/dist/lib/recent-access.service.d.ts +1 -1
- package/dist/lib/recent-access.service.d.ts.map +1 -1
- package/dist/lib/recent-access.service.js +19 -21
- package/dist/lib/recent-access.service.js.map +1 -1
- package/dist/lib/recent-resource-type.d.ts +7 -0
- package/dist/lib/recent-resource-type.d.ts.map +1 -0
- package/dist/lib/recent-resource-type.js +17 -0
- package/dist/lib/recent-resource-type.js.map +1 -0
- package/dist/public-api.d.ts +1 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +1 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +7 -7
package/dist/lib/_tokens.scss
CHANGED
|
@@ -104,6 +104,9 @@
|
|
|
104
104
|
|
|
105
105
|
--mj-color-info-50: #eff6ff;
|
|
106
106
|
--mj-color-info-100: #dbeafe;
|
|
107
|
+
--mj-color-info-200: #bfdbfe;
|
|
108
|
+
--mj-color-info-300: #93c5fd;
|
|
109
|
+
--mj-color-info-400: #60a5fa;
|
|
107
110
|
--mj-color-info-500: #3b82f6;
|
|
108
111
|
--mj-color-info-600: #2563eb;
|
|
109
112
|
--mj-color-info-700: #1d4ed8;
|
|
@@ -457,7 +460,36 @@
|
|
|
457
460
|
|
|
458
461
|
/* ========================================
|
|
459
462
|
Z-INDEX SCALE
|
|
460
|
-
========================================
|
|
463
|
+
========================================
|
|
464
|
+
The stacking contract hosts build against. Two layers:
|
|
465
|
+
|
|
466
|
+
Legacy rungs (0–800) — in-flow layering inside a page: dropdowns,
|
|
467
|
+
sticky headers, tooltips. A handful of consumers use them; their
|
|
468
|
+
values predate the overlay band below and are NOT comparable to it.
|
|
469
|
+
|
|
470
|
+
Overlay rungs (1000+) — the surfaces the shell actually stacks, in
|
|
471
|
+
the order they must win. These numbers are the de-facto ladder the
|
|
472
|
+
components ship on, published here so a host composing its own
|
|
473
|
+
surfaces (a board room, a dock, a capsule) knows where to land:
|
|
474
|
+
|
|
475
|
+
shell header .......... 500 (shell.component.css)
|
|
476
|
+
--mj-z-drawer ......... 1000 mj-slide-panel backdrop; the panel
|
|
477
|
+
itself is calc(drawer + 1)
|
|
478
|
+
--mj-z-dialog ......... 1200 mj-dialog backdrop — ABOVE the
|
|
479
|
+
drawer, so a modal opened from a
|
|
480
|
+
drawer is reachable (bespoke panels
|
|
481
|
+
up to ~1101 also stay under it)
|
|
482
|
+
mobile chrome band .... 9998/9999 (left-nav drawer, bottom sheet)
|
|
483
|
+
mj-window ............. 10000
|
|
484
|
+
MJDialogService ....... 10001 service-rendered dialog (dialog.service.ts);
|
|
485
|
+
above windows on purpose, unlike <mj-dialog>
|
|
486
|
+
MJConfirmService ...... 20000
|
|
487
|
+
search bar ............ 99999
|
|
488
|
+
toasts ................ 100000
|
|
489
|
+
|
|
490
|
+
Only the two named rungs are tokens today; the rest are listed so the
|
|
491
|
+
ladder is one picture. New overlay surfaces take a token, not a number.
|
|
492
|
+
*/
|
|
461
493
|
|
|
462
494
|
--mj-z-base: 0;
|
|
463
495
|
--mj-z-dropdown: 100;
|
|
@@ -468,6 +500,10 @@
|
|
|
468
500
|
--mj-z-popover: 600;
|
|
469
501
|
--mj-z-tooltip: 700;
|
|
470
502
|
--mj-z-toast: 800;
|
|
503
|
+
|
|
504
|
+
/* Overlay band */
|
|
505
|
+
--mj-z-drawer: 1000;
|
|
506
|
+
--mj-z-dialog: 1200;
|
|
471
507
|
}
|
|
472
508
|
|
|
473
509
|
/* ========================================
|
|
@@ -531,13 +567,23 @@
|
|
|
531
567
|
--mj-highlight-hover: var(--mj-color-accent-200);
|
|
532
568
|
--mj-highlight-subtle: var(--mj-brand-accent-subtle);
|
|
533
569
|
|
|
534
|
-
/* Status Colors (adjusted for dark backgrounds)
|
|
570
|
+
/* Status Colors (adjusted for dark backgrounds)
|
|
571
|
+
-text uses the 300 step: the 100 step is a near-white tint that is
|
|
572
|
+
indistinguishable from --mj-text-primary (1.00-1.12:1), so it carries no
|
|
573
|
+
status signal. 300 reads as its hue and clears WCAG AA on every RESTING
|
|
574
|
+
dark surface (page, surface, card, elevated, sunken) and on the matching
|
|
575
|
+
-bg tint; 400 fails AA for error/info on --mj-bg-surface-elevated.
|
|
576
|
+
Known limitation: on --mj-bg-surface-hover and --mj-bg-surface-active the
|
|
577
|
+
300 step drops below AA for error/info (and warning on its tint). Those
|
|
578
|
+
two surfaces sit 2-3 ramp steps off the base and no saturated text color
|
|
579
|
+
survives them; that is a surface-token problem, not a status-text one.
|
|
580
|
+
See MJ#4564. Keep ThemeEngine derive.ts STATUS.*Text300 in lockstep. */
|
|
535
581
|
--mj-status-success-bg: rgba(34, 197, 94, 0.15);
|
|
536
|
-
--mj-status-success-text: var(--mj-color-success-
|
|
582
|
+
--mj-status-success-text: var(--mj-color-success-300);
|
|
537
583
|
--mj-status-success-border: var(--mj-color-success-600);
|
|
538
584
|
|
|
539
585
|
--mj-status-warning-bg: rgba(245, 158, 11, 0.15);
|
|
540
|
-
--mj-status-warning-text: var(--mj-color-warning-
|
|
586
|
+
--mj-status-warning-text: var(--mj-color-warning-300);
|
|
541
587
|
--mj-status-warning-border: var(--mj-color-warning-600);
|
|
542
588
|
|
|
543
589
|
/* Slightly stronger search highlight on dark surfaces so it stays visible. */
|
|
@@ -545,11 +591,11 @@
|
|
|
545
591
|
--mj-search-highlight-text: var(--mj-text-primary);
|
|
546
592
|
|
|
547
593
|
--mj-status-error-bg: rgba(239, 68, 68, 0.15);
|
|
548
|
-
--mj-status-error-text: var(--mj-color-error-
|
|
594
|
+
--mj-status-error-text: var(--mj-color-error-300);
|
|
549
595
|
--mj-status-error-border: var(--mj-color-error-600);
|
|
550
596
|
|
|
551
597
|
--mj-status-info-bg: rgba(59, 130, 246, 0.15);
|
|
552
|
-
--mj-status-info-text: var(--mj-color-info-
|
|
598
|
+
--mj-status-info-text: var(--mj-color-info-300);
|
|
553
599
|
--mj-status-info-border: var(--mj-color-info-600);
|
|
554
600
|
|
|
555
601
|
/* Application Accent (dark mode adjustment) */
|
|
@@ -57,7 +57,7 @@ export declare class RecentAccessService {
|
|
|
57
57
|
/** @deprecated Use {@link LogAccess}. */
|
|
58
58
|
logAccess(entityName: string, recordId: string | CompositeKey, resourceType?: 'record' | 'view' | 'dashboard' | 'artifact' | 'report'): Promise<void>;
|
|
59
59
|
/**
|
|
60
|
-
* Loads recent access items for the current user
|
|
60
|
+
* Loads recent access items for the current user from `MJ: User Record Logs`.
|
|
61
61
|
* @param maxItems - Maximum number of items to return (default 15)
|
|
62
62
|
* @param forceRefresh - Force refresh even if already loaded
|
|
63
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recent-access.service.d.ts","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,YAAY,EAAmC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"recent-access.service.d.ts","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,YAAY,EAAmC,MAAM,sBAAsB,CAAC;AAG3H,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;;AAGnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,IAAI,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,YAAY,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;CACvE;AAED;;;GAGG;AACH;;;GAGG;AACH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C;IAIhD,kDAAkD;IACrC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhD;;;OAGG;YACW,kBAAkB;IA+BhC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAsBlC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACI,UAAU,IAAI,IAAI;IAKzB,0CAA0C;IACnC,UAAU,IAAI,IAAI;yCAtSd,mBAAmB;6CAAnB,mBAAmB;CAyS/B"}
|
|
@@ -2,8 +2,8 @@ import { Injectable } from '@angular/core';
|
|
|
2
2
|
import { Metadata, RunView, CompositeKey, LogError } from '@memberjunction/core';
|
|
3
3
|
import { GetGlobalObjectStore } from '@memberjunction/global';
|
|
4
4
|
import { UserInfoEngine } from '@memberjunction/core-entities';
|
|
5
|
-
import { UUIDsEqual } from '@memberjunction/global';
|
|
6
5
|
import { BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { ResourceTypeForEntity } from './recent-resource-type';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
/**
|
|
9
9
|
* Service for tracking and retrieving recently accessed resources.
|
|
@@ -69,6 +69,12 @@ export class RecentAccessService {
|
|
|
69
69
|
console.warn(`RecentAccessService: Entity "${entityName}" not found in metadata`);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
+
// Skip logging when the current user's roles do not grant Create/Update on MJ: User Record Logs
|
|
73
|
+
const logEntityInfo = md.Entities.find(e => e.Name === 'MJ: User Record Logs');
|
|
74
|
+
const logPerms = logEntityInfo?.GetUserPermisions(md.CurrentUser);
|
|
75
|
+
if (logPerms && !logPerms.CanCreate && !logPerms.CanUpdate) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
72
78
|
// Persist the key in the compact CompositeKey segment form — the bare value for a single-column
|
|
73
79
|
// primary key (so existing rows and lookups are unchanged), "F1|v1||F2|v2" for a composite one.
|
|
74
80
|
// That is the form CompositeKey.FromURLSegment reads back; the previous Values(',') dropped
|
|
@@ -89,16 +95,22 @@ export class RecentAccessService {
|
|
|
89
95
|
return;
|
|
90
96
|
}
|
|
91
97
|
if (existingResult.Results && existingResult.Results.length > 0) {
|
|
98
|
+
if (logPerms && !logPerms.CanUpdate) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
92
101
|
// Update existing entry
|
|
93
102
|
const existing = existingResult.Results[0];
|
|
94
103
|
existing.LatestAt = new Date();
|
|
95
104
|
existing.TotalCount = (existing.TotalCount || 0) + 1;
|
|
96
105
|
const saveResult = await existing.Save();
|
|
97
106
|
if (!saveResult) {
|
|
98
|
-
console.error('RecentAccessService: Failed to update log entry');
|
|
107
|
+
console.error('RecentAccessService: Failed to update log entry', existing.LatestResult?.CompleteMessage || '');
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
110
|
else {
|
|
111
|
+
if (logPerms && !logPerms.CanCreate) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
102
114
|
// Create new entry
|
|
103
115
|
const newLog = await md.GetEntityObject('MJ: User Record Logs', md.CurrentUser);
|
|
104
116
|
newLog.UserID = md.CurrentUser.ID;
|
|
@@ -109,7 +121,7 @@ export class RecentAccessService {
|
|
|
109
121
|
newLog.TotalCount = 1;
|
|
110
122
|
const saveResult = await newLog.Save();
|
|
111
123
|
if (!saveResult) {
|
|
112
|
-
console.error('RecentAccessService: Failed to create log entry');
|
|
124
|
+
console.error('RecentAccessService: Failed to create log entry', newLog.LatestResult?.CompleteMessage || '');
|
|
113
125
|
}
|
|
114
126
|
}
|
|
115
127
|
// Refresh the recent items list in background
|
|
@@ -125,7 +137,7 @@ export class RecentAccessService {
|
|
|
125
137
|
return this.LogAccess(entityName, recordId, resourceType);
|
|
126
138
|
}
|
|
127
139
|
/**
|
|
128
|
-
* Loads recent access items for the current user
|
|
140
|
+
* Loads recent access items for the current user from `MJ: User Record Logs`.
|
|
129
141
|
* @param maxItems - Maximum number of items to return (default 15)
|
|
130
142
|
* @param forceRefresh - Force refresh even if already loaded
|
|
131
143
|
*/
|
|
@@ -136,11 +148,10 @@ export class RecentAccessService {
|
|
|
136
148
|
try {
|
|
137
149
|
this._isLoading$.next(true);
|
|
138
150
|
const md = this.Provider;
|
|
139
|
-
|
|
140
|
-
const userRecordLogs = UserInfoEngine.Instance.UserRecordLogs.slice(0, maxItems);
|
|
151
|
+
const userRecordLogs = await UserInfoEngine.Instance.LoadRecentRecordLogs(maxItems, md.CurrentUser, md);
|
|
141
152
|
const items = [];
|
|
142
153
|
for (const log of userRecordLogs) {
|
|
143
|
-
const entityInfo = md.
|
|
154
|
+
const entityInfo = md.EntityByID(log.EntityID);
|
|
144
155
|
if (!entityInfo)
|
|
145
156
|
continue;
|
|
146
157
|
// Determine resource type based on entity name
|
|
@@ -248,20 +259,7 @@ export class RecentAccessService {
|
|
|
248
259
|
* Determines the resource type based on entity name
|
|
249
260
|
*/
|
|
250
261
|
determineResourceType(entityName) {
|
|
251
|
-
|
|
252
|
-
if (normalizedName === 'user views') {
|
|
253
|
-
return 'view';
|
|
254
|
-
}
|
|
255
|
-
if (normalizedName === 'dashboards') {
|
|
256
|
-
return 'dashboard';
|
|
257
|
-
}
|
|
258
|
-
if (normalizedName === 'mj: conversation artifacts' || normalizedName === 'conversation artifacts') {
|
|
259
|
-
return 'artifact';
|
|
260
|
-
}
|
|
261
|
-
if (normalizedName === 'reports') {
|
|
262
|
-
return 'report';
|
|
263
|
-
}
|
|
264
|
-
return 'record';
|
|
262
|
+
return ResourceTypeForEntity(entityName);
|
|
265
263
|
}
|
|
266
264
|
/**
|
|
267
265
|
* Clears the cached recent items (useful for logout)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recent-access.service.js","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAqB,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAyB,MAAM,sBAAsB,CAAC;AAC3H,OAAO,EAA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f,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;6GA3SU,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB,mBAFlB,MAAM;;iFAEP,mBAAmB;cAH/B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { IMetadataProvider, Metadata, RunView, CompositeKey, LogError, EntityRecordNameInput } from '@memberjunction/core';\nimport { GetGlobalObjectStore } from '@memberjunction/global';\nimport { MJUserRecordLogEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\n/**\n * Represents a recently accessed resource\n */\nexport interface RecentAccessItem {\n id: string;\n entityId: string;\n entityName: string;\n recordId: string;\n recordName?: string;\n latestAt: Date;\n totalCount: number;\n /** Resource type for special handling (record, view, dashboard, artifact) */\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report';\n}\n\n/**\n * Service for tracking and retrieving recently accessed resources.\n * Uses the User Record Logs entity to persist access history.\n */\n/**\n * Multi-provider note: callers under a non-default provider should set\n * `service.Provider = component.ProviderToUse` before invoking any methods.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class RecentAccessService {\n private static readonly _globalStoreKey = '___SINGLETON__RecentAccessService';\n private _recentItems$ = new BehaviorSubject<RecentAccessItem[]>([]);\n private _isLoading$ = new BehaviorSubject<boolean>(false);\n private _isLoaded = false;\n\n private _provider: IMetadataProvider | null = null;\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n constructor() {\n const g = GetGlobalObjectStore()!;\n if (g[RecentAccessService._globalStoreKey]) {\n return g[RecentAccessService._globalStoreKey] as RecentAccessService;\n }\n g[RecentAccessService._globalStoreKey] = this;\n }\n\n public static get Instance(): RecentAccessService {\n return GetGlobalObjectStore()![RecentAccessService._globalStoreKey] as RecentAccessService;\n }\n\n /**\n * Observable of recent access items, sorted by most recent first\n */\n public get RecentItems(): Observable<RecentAccessItem[]> {\n return this._recentItems$.asObservable();\n }\n\n /**\n * Current value of recent items\n */\n public get RecentItemsValue(): RecentAccessItem[] {\n return this._recentItems$.value;\n }\n\n /**\n * Observable loading state\n */\n public get IsLoading(): Observable<boolean> {\n return this._isLoading$.asObservable();\n }\n\n /**\n * Logs access to a record. Creates or updates the User Record Log entry.\n * This is a fire-and-forget operation - errors are logged but don't interrupt the user.\n *\n * @param entityName - The name of the entity being accessed\n * @param recordId - The record ID (single value or CompositeKey string)\n * @param resourceType - The type of resource being accessed\n */\n public async LogAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n try {\n const md = this.Provider;\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) {\n console.warn(`RecentAccessService: Entity \"${entityName}\" not found in metadata`);\n return;\n }\n\n // Persist the key in the compact CompositeKey segment form — the bare value for a single-column\n // primary key (so existing rows and lookups are unchanged), \"F1|v1||F2|v2\" for a composite one.\n // That is the form CompositeKey.FromURLSegment reads back; the previous Values(',') dropped\n // the field names, so a composite key written here could never be re-opened.\n const recordIdString = recordId instanceof CompositeKey\n ? recordId.ToCompactURLSegment()\n : recordId;\n\n // Check if we already have a log entry for this user/entity/record combination\n const rv = RunView.FromMetadataProvider(this.Provider);\n const existingResult = await rv.RunView<MJUserRecordLogEntity>({\n EntityName: 'MJ: User Record Logs',\n ExtraFilter: `UserID='${md.CurrentUser.ID}' AND EntityID='${entityInfo.ID}' AND RecordID='${recordIdString}'`,\n ResultType: 'entity_object',\n MaxRows: 1\n });\n\n if (!existingResult.Success) {\n console.error('RecentAccessService: Failed to check existing log', existingResult.ErrorMessage);\n return;\n }\n\n if (existingResult.Results && existingResult.Results.length > 0) {\n // Update existing entry\n const existing = existingResult.Results[0];\n existing.LatestAt = new Date();\n existing.TotalCount = (existing.TotalCount || 0) + 1;\n\n const saveResult = await existing.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to update log entry');\n }\n } else {\n // Create new entry\n const newLog = await md.GetEntityObject<MJUserRecordLogEntity>('MJ: User Record Logs', md.CurrentUser);\n newLog.UserID = md.CurrentUser.ID;\n newLog.EntityID = entityInfo.ID;\n newLog.RecordID = recordIdString;\n // EarliestAt and LatestAt have default values of getdate() in the DB\n // TotalCount defaults to 0, so we set it to 1\n newLog.TotalCount = 1;\n\n const saveResult = await newLog.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to create log entry');\n }\n }\n\n // Refresh the recent items list in background\n this.RefreshRecentItems();\n } catch (error) {\n // Don't throw - this is non-critical functionality\n console.error('RecentAccessService: Error logging access', error);\n }\n }\n\n /** @deprecated Use {@link LogAccess}. */\n public async logAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n return this.LogAccess(entityName, recordId, resourceType);\n }\n\n /**\n * Loads recent access items for the current user using UserInfoEngine (cached).\n * @param maxItems - Maximum number of items to return (default 15)\n * @param forceRefresh - Force refresh even if already loaded\n */\n public async LoadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n if (this._isLoaded && !forceRefresh) {\n return this._recentItems$.value;\n }\n\n try {\n this._isLoading$.next(true);\n\n const md = this.Provider;\n\n // Get recent records, limited to maxItems (already ordered by LatestAt DESC in engine)\n const userRecordLogs = UserInfoEngine.Instance.UserRecordLogs.slice(0, maxItems);\n\n const items: RecentAccessItem[] = [];\n\n for (const log of userRecordLogs) {\n const entityInfo = md.Entities.find(e => UUIDsEqual(e.ID, log.EntityID));\n if (!entityInfo) continue;\n\n // Determine resource type based on entity name\n const resourceType = this.determineResourceType(entityInfo.Name);\n\n items.push({\n id: log.ID,\n entityId: log.EntityID,\n entityName: entityInfo.Name,\n recordId: log.RecordID,\n latestAt: log.LatestAt,\n totalCount: log.TotalCount,\n resourceType\n });\n }\n\n // Batch-resolve record names for all items\n await this.resolveRecordNames(items, md);\n\n this._recentItems$.next(items);\n this._isLoaded = true;\n\n return items;\n } catch (error) {\n LogError('RecentAccessService: Error loading recent items', undefined, error);\n return [];\n } finally {\n this._isLoading$.next(false);\n }\n }\n\n /** @deprecated Use {@link LoadRecentItems}. */\n public async loadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n return this.LoadRecentItems(maxItems, forceRefresh);\n }\n\n /**\n * Refresh recent items in background\n */\n public async RefreshRecentItems(): Promise<void> {\n await this.LoadRecentItems(15, true);\n }\n\n /** @deprecated Use {@link RefreshRecentItems}. */\n public async refreshRecentItems(): Promise<void> {\n return this.RefreshRecentItems();\n }\n\n /**\n * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().\n * Mutates the items in-place to set recordName where resolved.\n */\n private async resolveRecordNames(items: RecentAccessItem[], md: IMetadataProvider): Promise<void> {\n const nameInputs: EntityRecordNameInput[] = [];\n const indexMap = new Map<string, number>();\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const compositeKey = this.buildCompositeKeyForRecord(item.entityName, item.recordId, md);\n if (!compositeKey) continue;\n\n nameInputs.push({ EntityName: item.entityName, CompositeKey: compositeKey });\n indexMap.set(`${item.entityName}||${compositeKey.ToConcatenatedString()}`, i);\n }\n\n if (nameInputs.length === 0) return;\n\n try {\n const nameResults = await md.GetEntityRecordNames(nameInputs);\n for (const result of nameResults) {\n if (result.Success && result.RecordName) {\n const key = `${result.EntityName}||${result.CompositeKey.ToConcatenatedString()}`;\n const index = indexMap.get(key);\n if (index !== undefined) {\n items[index].recordName = result.RecordName;\n }\n }\n }\n } catch (error) {\n console.warn('RecentAccessService: Failed to resolve record names', error);\n }\n }\n\n /**\n * Build a CompositeKey for a record. RecordID may be stored as either:\n * - Concatenated format: \"FieldName|Value\" or \"Field1|Val1||Field2|Val2\"\n * - Plain value: just the raw value (e.g. a GUID)\n * Detects the format and constructs the key accordingly.\n */\n private buildCompositeKeyForRecord(entityName: string, recordId: string, md: IMetadataProvider): CompositeKey | null {\n if (!recordId) return null;\n\n // If recordId contains '|', it's in concatenated format\n if (recordId.includes('|')) {\n try {\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromConcatenatedString(recordId);\n if (compositeKey.KeyValuePairs.length > 0) return compositeKey;\n } catch {\n // Fall through to entity-based lookup\n }\n }\n\n // Plain value — map it onto the entity's real primary key column (whatever it is called).\n // FromURLSegment also re-parses a delimited segment, covering the case where the try above failed.\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo || entityInfo.PrimaryKeys.length === 0) return null;\n\n return CompositeKey.FromURLSegment(entityInfo, recordId);\n }\n\n /**\n * Determines the resource type based on entity name\n */\n private determineResourceType(entityName: string): 'record' | 'view' | 'dashboard' | 'artifact' | 'report' {\n const normalizedName = entityName.toLowerCase();\n\n if (normalizedName === 'user views') {\n return 'view';\n }\n if (normalizedName === 'dashboards') {\n return 'dashboard';\n }\n if (normalizedName === 'mj: conversation artifacts' || normalizedName === 'conversation artifacts') {\n return 'artifact';\n }\n if (normalizedName === 'reports') {\n return 'report';\n }\n\n return 'record';\n }\n\n /**\n * Clears the cached recent items (useful for logout)\n */\n public ClearCache(): void {\n this._recentItems$.next([]);\n this._isLoaded = false;\n }\n\n /** @deprecated Use {@link ClearCache}. */\n public clearCache(): void {\n return this.ClearCache();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recent-access.service.js","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAqB,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAyB,MAAM,sBAAsB,CAAC;AAC3H,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAyB,cAAc,EAAE,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AAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,0CAA0C;IACnC,UAAU;QACf,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;6GAxSU,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB,mBAFlB,MAAM;;iFAEP,mBAAmB;cAH/B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { IMetadataProvider, Metadata, RunView, CompositeKey, LogError, EntityRecordNameInput } from '@memberjunction/core';\nimport { GetGlobalObjectStore } from '@memberjunction/global';\nimport { MJUserRecordLogEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { ResourceTypeForEntity } from './recent-resource-type';\n\n/**\n * Represents a recently accessed resource\n */\nexport interface RecentAccessItem {\n id: string;\n entityId: string;\n entityName: string;\n recordId: string;\n recordName?: string;\n latestAt: Date;\n totalCount: number;\n /** Resource type for special handling (record, view, dashboard, artifact) */\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report';\n}\n\n/**\n * Service for tracking and retrieving recently accessed resources.\n * Uses the User Record Logs entity to persist access history.\n */\n/**\n * Multi-provider note: callers under a non-default provider should set\n * `service.Provider = component.ProviderToUse` before invoking any methods.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class RecentAccessService {\n private static readonly _globalStoreKey = '___SINGLETON__RecentAccessService';\n private _recentItems$ = new BehaviorSubject<RecentAccessItem[]>([]);\n private _isLoading$ = new BehaviorSubject<boolean>(false);\n private _isLoaded = false;\n\n private _provider: IMetadataProvider | null = null;\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n constructor() {\n const g = GetGlobalObjectStore()!;\n if (g[RecentAccessService._globalStoreKey]) {\n return g[RecentAccessService._globalStoreKey] as RecentAccessService;\n }\n g[RecentAccessService._globalStoreKey] = this;\n }\n\n public static get Instance(): RecentAccessService {\n return GetGlobalObjectStore()![RecentAccessService._globalStoreKey] as RecentAccessService;\n }\n\n /**\n * Observable of recent access items, sorted by most recent first\n */\n public get RecentItems(): Observable<RecentAccessItem[]> {\n return this._recentItems$.asObservable();\n }\n\n /**\n * Current value of recent items\n */\n public get RecentItemsValue(): RecentAccessItem[] {\n return this._recentItems$.value;\n }\n\n /**\n * Observable loading state\n */\n public get IsLoading(): Observable<boolean> {\n return this._isLoading$.asObservable();\n }\n\n /**\n * Logs access to a record. Creates or updates the User Record Log entry.\n * This is a fire-and-forget operation - errors are logged but don't interrupt the user.\n *\n * @param entityName - The name of the entity being accessed\n * @param recordId - The record ID (single value or CompositeKey string)\n * @param resourceType - The type of resource being accessed\n */\n public async LogAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n try {\n const md = this.Provider;\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) {\n console.warn(`RecentAccessService: Entity \"${entityName}\" not found in metadata`);\n return;\n }\n\n // Skip logging when the current user's roles do not grant Create/Update on MJ: User Record Logs\n const logEntityInfo = md.Entities.find(e => e.Name === 'MJ: User Record Logs');\n const logPerms = logEntityInfo?.GetUserPermisions(md.CurrentUser);\n if (logPerms && !logPerms.CanCreate && !logPerms.CanUpdate) {\n return;\n }\n\n // Persist the key in the compact CompositeKey segment form — the bare value for a single-column\n // primary key (so existing rows and lookups are unchanged), \"F1|v1||F2|v2\" for a composite one.\n // That is the form CompositeKey.FromURLSegment reads back; the previous Values(',') dropped\n // the field names, so a composite key written here could never be re-opened.\n const recordIdString = recordId instanceof CompositeKey\n ? recordId.ToCompactURLSegment()\n : recordId;\n\n // Check if we already have a log entry for this user/entity/record combination\n const rv = RunView.FromMetadataProvider(this.Provider);\n const existingResult = await rv.RunView<MJUserRecordLogEntity>({\n EntityName: 'MJ: User Record Logs',\n ExtraFilter: `UserID='${md.CurrentUser.ID}' AND EntityID='${entityInfo.ID}' AND RecordID='${recordIdString}'`,\n ResultType: 'entity_object',\n MaxRows: 1\n });\n\n if (!existingResult.Success) {\n console.error('RecentAccessService: Failed to check existing log', existingResult.ErrorMessage);\n return;\n }\n\n if (existingResult.Results && existingResult.Results.length > 0) {\n if (logPerms && !logPerms.CanUpdate) {\n return;\n }\n // Update existing entry\n const existing = existingResult.Results[0];\n existing.LatestAt = new Date();\n existing.TotalCount = (existing.TotalCount || 0) + 1;\n\n const saveResult = await existing.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to update log entry', existing.LatestResult?.CompleteMessage || '');\n }\n } else {\n if (logPerms && !logPerms.CanCreate) {\n return;\n }\n // Create new entry\n const newLog = await md.GetEntityObject<MJUserRecordLogEntity>('MJ: User Record Logs', md.CurrentUser);\n newLog.UserID = md.CurrentUser.ID;\n newLog.EntityID = entityInfo.ID;\n newLog.RecordID = recordIdString;\n // EarliestAt and LatestAt have default values of getdate() in the DB\n // TotalCount defaults to 0, so we set it to 1\n newLog.TotalCount = 1;\n\n const saveResult = await newLog.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to create log entry', newLog.LatestResult?.CompleteMessage || '');\n }\n }\n\n // Refresh the recent items list in background\n this.RefreshRecentItems();\n } catch (error) {\n // Don't throw - this is non-critical functionality\n console.error('RecentAccessService: Error logging access', error);\n }\n }\n\n /** @deprecated Use {@link LogAccess}. */\n public async logAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n return this.LogAccess(entityName, recordId, resourceType);\n }\n\n /**\n * Loads recent access items for the current user from `MJ: User Record Logs`.\n * @param maxItems - Maximum number of items to return (default 15)\n * @param forceRefresh - Force refresh even if already loaded\n */\n public async LoadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n if (this._isLoaded && !forceRefresh) {\n return this._recentItems$.value;\n }\n\n try {\n this._isLoading$.next(true);\n\n const md = this.Provider;\n\n const userRecordLogs = await UserInfoEngine.Instance.LoadRecentRecordLogs(maxItems, md.CurrentUser, md);\n\n const items: RecentAccessItem[] = [];\n\n for (const log of userRecordLogs) {\n const entityInfo = md.EntityByID(log.EntityID);\n if (!entityInfo) continue;\n\n // Determine resource type based on entity name\n const resourceType = this.determineResourceType(entityInfo.Name);\n\n items.push({\n id: log.ID,\n entityId: log.EntityID,\n entityName: entityInfo.Name,\n recordId: log.RecordID,\n latestAt: log.LatestAt,\n totalCount: log.TotalCount,\n resourceType\n });\n }\n\n // Batch-resolve record names for all items\n await this.resolveRecordNames(items, md);\n\n this._recentItems$.next(items);\n this._isLoaded = true;\n\n return items;\n } catch (error) {\n LogError('RecentAccessService: Error loading recent items', undefined, error);\n return [];\n } finally {\n this._isLoading$.next(false);\n }\n }\n\n /** @deprecated Use {@link LoadRecentItems}. */\n public async loadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n return this.LoadRecentItems(maxItems, forceRefresh);\n }\n\n /**\n * Refresh recent items in background\n */\n public async RefreshRecentItems(): Promise<void> {\n await this.LoadRecentItems(15, true);\n }\n\n /** @deprecated Use {@link RefreshRecentItems}. */\n public async refreshRecentItems(): Promise<void> {\n return this.RefreshRecentItems();\n }\n\n /**\n * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().\n * Mutates the items in-place to set recordName where resolved.\n */\n private async resolveRecordNames(items: RecentAccessItem[], md: IMetadataProvider): Promise<void> {\n const nameInputs: EntityRecordNameInput[] = [];\n const indexMap = new Map<string, number>();\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const compositeKey = this.buildCompositeKeyForRecord(item.entityName, item.recordId, md);\n if (!compositeKey) continue;\n\n nameInputs.push({ EntityName: item.entityName, CompositeKey: compositeKey });\n indexMap.set(`${item.entityName}||${compositeKey.ToConcatenatedString()}`, i);\n }\n\n if (nameInputs.length === 0) return;\n\n try {\n const nameResults = await md.GetEntityRecordNames(nameInputs);\n for (const result of nameResults) {\n if (result.Success && result.RecordName) {\n const key = `${result.EntityName}||${result.CompositeKey.ToConcatenatedString()}`;\n const index = indexMap.get(key);\n if (index !== undefined) {\n items[index].recordName = result.RecordName;\n }\n }\n }\n } catch (error) {\n console.warn('RecentAccessService: Failed to resolve record names', error);\n }\n }\n\n /**\n * Build a CompositeKey for a record. RecordID may be stored as either:\n * - Concatenated format: \"FieldName|Value\" or \"Field1|Val1||Field2|Val2\"\n * - Plain value: just the raw value (e.g. a GUID)\n * Detects the format and constructs the key accordingly.\n */\n private buildCompositeKeyForRecord(entityName: string, recordId: string, md: IMetadataProvider): CompositeKey | null {\n if (!recordId) return null;\n\n // If recordId contains '|', it's in concatenated format\n if (recordId.includes('|')) {\n try {\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromConcatenatedString(recordId);\n if (compositeKey.KeyValuePairs.length > 0) return compositeKey;\n } catch {\n // Fall through to entity-based lookup\n }\n }\n\n // Plain value — map it onto the entity's real primary key column (whatever it is called).\n // FromURLSegment also re-parses a delimited segment, covering the case where the try above failed.\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo || entityInfo.PrimaryKeys.length === 0) return null;\n\n return CompositeKey.FromURLSegment(entityInfo, recordId);\n }\n\n /**\n * Determines the resource type based on entity name\n */\n private determineResourceType(entityName: string): 'record' | 'view' | 'dashboard' | 'artifact' | 'report' {\n return ResourceTypeForEntity(entityName);\n }\n\n /**\n * Clears the cached recent items (useful for logout)\n */\n public ClearCache(): void {\n this._recentItems$.next([]);\n this._isLoaded = false;\n }\n\n /** @deprecated Use {@link ClearCache}. */\n public clearCache(): void {\n return this.ClearCache();\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RecentResourceType = 'record' | 'view' | 'dashboard' | 'artifact' | 'report';
|
|
2
|
+
/**
|
|
3
|
+
* Resource type for an entity name in the recents list. Accepts the `MJ: ` prefix and the legacy
|
|
4
|
+
* unprefixed names.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ResourceTypeForEntity(entityName: string): RecentResourceType;
|
|
7
|
+
//# sourceMappingURL=recent-resource-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recent-resource-type.d.ts","sourceRoot":"","sources":["../../src/lib/recent-resource-type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEzF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAO5E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource type for an entity name in the recents list. Accepts the `MJ: ` prefix and the legacy
|
|
3
|
+
* unprefixed names.
|
|
4
|
+
*/
|
|
5
|
+
export function ResourceTypeForEntity(entityName) {
|
|
6
|
+
const normalized = (entityName || '').trim().toLowerCase().replace(/^mj:\s*/, '');
|
|
7
|
+
if (normalized === 'user views')
|
|
8
|
+
return 'view';
|
|
9
|
+
if (normalized === 'dashboards')
|
|
10
|
+
return 'dashboard';
|
|
11
|
+
if (normalized === 'conversation artifacts')
|
|
12
|
+
return 'artifact';
|
|
13
|
+
if (normalized === 'reports')
|
|
14
|
+
return 'report';
|
|
15
|
+
return 'record';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=recent-resource-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recent-resource-type.js","sourceRoot":"","sources":["../../src/lib/recent-resource-type.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,MAAM,UAAU,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAClF,IAAI,UAAU,KAAK,YAAY;QAAE,OAAO,MAAM,CAAC;IAC/C,IAAI,UAAU,KAAK,YAAY;QAAE,OAAO,WAAW,CAAC;IACpD,IAAI,UAAU,KAAK,wBAAwB;QAAE,OAAO,UAAU,CAAC;IAC/D,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC9C,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["export type RecentResourceType = 'record' | 'view' | 'dashboard' | 'artifact' | 'report';\n\n/**\n * Resource type for an entity name in the recents list. Accepts the `MJ: ` prefix and the legacy\n * unprefixed names.\n */\nexport function ResourceTypeForEntity(entityName: string): RecentResourceType {\n const normalized = (entityName || '').trim().toLowerCase().replace(/^mj:\\s*/, '');\n if (normalized === 'user views') return 'view';\n if (normalized === 'dashboards') return 'dashboard';\n if (normalized === 'conversation artifacts') return 'artifact';\n if (normalized === 'reports') return 'report';\n return 'record';\n}\n"]}
|
package/dist/public-api.d.ts
CHANGED
package/dist/public-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAGpC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,iCAAiC,CAAC;AAGhD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AAGpC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,iCAAiC,CAAC;AAGhD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
package/dist/public-api.js
CHANGED
package/dist/public-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAEpC,cAAc;AACd,cAAc,iBAAiB,CAAC;AAEhC,oBAAoB;AACpB,cAAc,4BAA4B,CAAC;AAE3C,aAAa;AACb,cAAc,iCAAiC,CAAC;AAEhD,mDAAmD;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC","sourcesContent":["/*\n * Public API Surface for @memberjunction/ng-shared-generic\n */\n\n// Module\nexport * from './lib/module';\n\n// Services\nexport * from './lib/recent-access.service';\nexport * from './lib/theme.service';\n\n// DOM helpers\nexport * from './lib/dom-utils';\n\n// Theming constants\nexport * from './lib/ag-grid-theme-params';\n\n// Components\nexport * from './lib/loading/loading.component';\n\n// Rich-text rendering (safe HTML/SVG sanitization)\nexport * from './lib/rich-text/rich-text-sanitize';\nexport * from './lib/rich-text/safe-rich-html.pipe';\n"]}
|
|
1
|
+
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AAEpC,cAAc;AACd,cAAc,iBAAiB,CAAC;AAEhC,oBAAoB;AACpB,cAAc,4BAA4B,CAAC;AAE3C,aAAa;AACb,cAAc,iCAAiC,CAAC;AAEhD,mDAAmD;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC","sourcesContent":["/*\n * Public API Surface for @memberjunction/ng-shared-generic\n */\n\n// Module\nexport * from './lib/module';\n\n// Services\nexport * from './lib/recent-access.service';\nexport * from './lib/recent-resource-type';\nexport * from './lib/theme.service';\n\n// DOM helpers\nexport * from './lib/dom-utils';\n\n// Theming constants\nexport * from './lib/ag-grid-theme-params';\n\n// Components\nexport * from './lib/loading/loading.component';\n\n// Rich-text rendering (safe HTML/SVG sanitization)\nexport * from './lib/rich-text/rich-text-sanitize';\nexport * from './lib/rich-text/safe-rich-html.pipe';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-shared-generic",
|
|
3
|
-
"version": "6.2.0-edge.
|
|
3
|
+
"version": "6.2.0-edge.5",
|
|
4
4
|
"description": "MemberJunction: Generic Angular Shared Package - utility services and reusable elements used in any Angular application.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@angular/compiler": "21.2.22",
|
|
18
18
|
"@angular/compiler-cli": "21.2.22",
|
|
19
|
-
"@memberjunction/ng-test-utils": "6.2.0-edge.
|
|
19
|
+
"@memberjunction/ng-test-utils": "6.2.0-edge.5",
|
|
20
20
|
"vitest": "^4.0.18"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"rxjs": "^7.8.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@memberjunction/core": "6.2.0-edge.
|
|
30
|
-
"@memberjunction/ng-base-types": "6.2.0-edge.
|
|
31
|
-
"@memberjunction/core-entities": "6.2.0-edge.
|
|
32
|
-
"@memberjunction/global": "6.2.0-edge.
|
|
33
|
-
"@memberjunction/theme-engine": "6.2.0-edge.
|
|
29
|
+
"@memberjunction/core": "6.2.0-edge.5",
|
|
30
|
+
"@memberjunction/ng-base-types": "6.2.0-edge.5",
|
|
31
|
+
"@memberjunction/core-entities": "6.2.0-edge.5",
|
|
32
|
+
"@memberjunction/global": "6.2.0-edge.5",
|
|
33
|
+
"@memberjunction/theme-engine": "6.2.0-edge.5",
|
|
34
34
|
"dompurify": "^3.3.0",
|
|
35
35
|
"tslib": "^2.8.1"
|
|
36
36
|
},
|