@memberjunction/ng-base-application 6.2.0-edge.4 → 6.2.0-edge.6
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/__tests__/permission-constrained-boot.test.d.ts +2 -0
- package/dist/lib/__tests__/permission-constrained-boot.test.d.ts.map +1 -0
- package/dist/lib/__tests__/permission-constrained-boot.test.js +114 -0
- package/dist/lib/__tests__/permission-constrained-boot.test.js.map +1 -0
- package/dist/lib/__tests__/tab-service-url-replacement.test.d.ts +2 -0
- package/dist/lib/__tests__/tab-service-url-replacement.test.d.ts.map +1 -0
- package/dist/lib/__tests__/tab-service-url-replacement.test.js +33 -0
- package/dist/lib/__tests__/tab-service-url-replacement.test.js.map +1 -0
- package/dist/lib/__tests__/workspace-journal.test.d.ts +2 -0
- package/dist/lib/__tests__/workspace-journal.test.d.ts.map +1 -0
- package/dist/lib/__tests__/workspace-journal.test.js +317 -0
- package/dist/lib/__tests__/workspace-journal.test.js.map +1 -0
- package/dist/lib/application-manager.d.ts +21 -0
- package/dist/lib/application-manager.d.ts.map +1 -1
- package/dist/lib/application-manager.js +59 -5
- package/dist/lib/application-manager.js.map +1 -1
- package/dist/lib/tab.service.d.ts +21 -0
- package/dist/lib/tab.service.d.ts.map +1 -1
- package/dist/lib/tab.service.js +34 -0
- package/dist/lib/tab.service.js.map +1 -1
- package/dist/lib/workspace-journal.d.ts +87 -0
- package/dist/lib/workspace-journal.d.ts.map +1 -0
- package/dist/lib/workspace-journal.js +123 -0
- package/dist/lib/workspace-journal.js.map +1 -0
- package/dist/lib/workspace-state-manager.d.ts +57 -1
- package/dist/lib/workspace-state-manager.d.ts.map +1 -1
- package/dist/lib/workspace-state-manager.js +159 -11
- package/dist/lib/workspace-state-manager.js.map +1 -1
- 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 +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-manager.d.ts","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAkE,iBAAiB,EAA8B,MAAM,sBAAsB,CAAC;AACrJ,OAAO,EAAE,uBAAuB,EAAkB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAErD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,eAAe,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAGa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAS;IAC1C,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAqD;IACvE,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,WAAW,CAAS;IAE5B,kEAAkE;IAClE,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,aAAa,CAAmE;IAExF;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1B;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,CAEhD;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,CAEnD;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC,CAEhD;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,CAElD;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,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AAM,EAAE,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,eAAe,GAAG,UAAU,GAAG,gBAAgB,CAAC;IAClG,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';
|
|
3
|
+
import { IndexByUUID, MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';
|
|
4
4
|
import { Metadata, LogError, LogStatus, StartupManager } from '@memberjunction/core';
|
|
5
5
|
import { UserInfoEngine } from '@memberjunction/core-entities';
|
|
6
6
|
import { BaseApplication } from './base-application';
|
|
@@ -121,7 +121,11 @@ export class ApplicationManager {
|
|
|
121
121
|
MJGlobal.Instance.GetEventListener(true).subscribe(async (event) => {
|
|
122
122
|
if (event.event === MJEventType.LoggedIn) {
|
|
123
123
|
await StartupManager.Instance.Startup(); // make sure this is done
|
|
124
|
-
|
|
124
|
+
// Fire-and-forget from an event callback: loadApplications() already logs its failure
|
|
125
|
+
// and resolves WhenReady() waiters before rethrowing (for callers that await it), so
|
|
126
|
+
// the rethrow has nobody to land on here — catch it rather than leave an unhandled
|
|
127
|
+
// rejection on the page.
|
|
128
|
+
this.loadApplications().catch(() => { });
|
|
125
129
|
this.subscribeToEngineChanges();
|
|
126
130
|
}
|
|
127
131
|
});
|
|
@@ -257,7 +261,13 @@ export class ApplicationManager {
|
|
|
257
261
|
// Attempt one recovery by force-refreshing UserInfoEngine before giving up.
|
|
258
262
|
const activeApps = this.applications$.value;
|
|
259
263
|
const hasMetadataApps = md.Applications.some(a => a.Status === 'Active');
|
|
260
|
-
|
|
264
|
+
// A permission-constrained session (e.g. an external magic-link user holding only
|
|
265
|
+
// 'Magic Link Baseline' plus a granted role) has zero user apps BY DESIGN — that is
|
|
266
|
+
// not cache corruption, and a forced engine refresh cannot grant read access. Without
|
|
267
|
+
// this guard the recovery log below read UserApplications, which throws
|
|
268
|
+
// PermissionConstrainedError, and loadApplications() rejected unhandled at every boot.
|
|
269
|
+
if (activeApps.length === 0 && hasMetadataApps && !ApplicationManager._recoveryAttempted
|
|
270
|
+
&& !UserInfoEngine.Instance.IsPermissionConstrained) {
|
|
261
271
|
ApplicationManager._recoveryAttempted = true;
|
|
262
272
|
const activeAppCount = md.Applications.filter(a => a.Status === 'Active').length;
|
|
263
273
|
const engineHealthy = UserInfoEngine.Instance.AllPropertiesLoadedSuccessfully;
|
|
@@ -297,9 +307,10 @@ export class ApplicationManager {
|
|
|
297
307
|
// If the engine can't read user application data, skip the self-healing path —
|
|
298
308
|
// a permission-denied user is NOT the same as a new user with no records.
|
|
299
309
|
if (engine.IsPermissionConstrained) {
|
|
300
|
-
|
|
310
|
+
const sessionApps = this.permissionConstrainedSessionApps(allApps);
|
|
311
|
+
LogStatus(`${this.constructor.name}: UserInfoEngine is permission-constrained, skipping application config load; ${sessionApps.length} default app(s) offered for this session`);
|
|
301
312
|
this.userAppConfigs$.next([]);
|
|
302
|
-
this.applications$.next(
|
|
313
|
+
this.applications$.next(sessionApps);
|
|
303
314
|
return;
|
|
304
315
|
}
|
|
305
316
|
let userApps = engine.UserApplications;
|
|
@@ -326,6 +337,49 @@ export class ApplicationManager {
|
|
|
326
337
|
this.userAppConfigs$.next(userAppConfigs);
|
|
327
338
|
this.applications$.next(activeApps);
|
|
328
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* The apps a permission-constrained session (e.g. an external magic-link user) is offered when it
|
|
342
|
+
* cannot read its own `MJ: User Applications` rows: what a brand-new user would get —
|
|
343
|
+
* DefaultForNewUser apps the user may access, in DefaultSequence order — but held in memory
|
|
344
|
+
* only, never saved as records. When the session cannot read application roles either, access
|
|
345
|
+
* cannot be judged (an unreadable role list reads as "open to everyone"), so nothing is offered;
|
|
346
|
+
* an app-locked session still reaches its scoped app through {@link AdoptSessionApplication}.
|
|
347
|
+
*/
|
|
348
|
+
permissionConstrainedSessionApps(allApps) {
|
|
349
|
+
const engine = UserInfoEngine.Instance;
|
|
350
|
+
if (engine.IsPropertyPermissionConstrained('_applicationRoles')) {
|
|
351
|
+
return [];
|
|
352
|
+
}
|
|
353
|
+
const defaults = this.Provider.Applications
|
|
354
|
+
.filter(a => a.DefaultForNewUser && a.Status === 'Active' && engine.UserHasApplicationAccess(a.ID))
|
|
355
|
+
.sort((a, b) => (a.DefaultSequence ?? 100) - (b.DefaultSequence ?? 100));
|
|
356
|
+
const appsByID = IndexByUUID(allApps);
|
|
357
|
+
return defaults
|
|
358
|
+
.map(info => appsByID.Get(info.ID))
|
|
359
|
+
.filter((app) => !!app);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Makes an application the SESSION is scoped to available in {@link Applications} when the
|
|
363
|
+
* user's own app list does not include it — an app-locked session (a magic-link invite scoped
|
|
364
|
+
* to one app) whose user cannot read, or has no, `MJ: User Applications` rows. In memory only:
|
|
365
|
+
* no record is created. The scope comes from the server-signed session, and the server still
|
|
366
|
+
* enforces every entity permission inside the app.
|
|
367
|
+
*
|
|
368
|
+
* @param appId - the application the session is restricted to
|
|
369
|
+
* @returns true when the app was added (so {@link Applications} re-emits); false when it was
|
|
370
|
+
* already available or is not an active application at all
|
|
371
|
+
*/
|
|
372
|
+
AdoptSessionApplication(appId) {
|
|
373
|
+
if (!appId || this.GetAppById(appId)) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
const app = this.allApplications$.value.find(a => UUIDsEqual(a.ID, appId));
|
|
377
|
+
if (!app) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
this.applications$.next([...this.applications$.value, app]);
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
329
383
|
/**
|
|
330
384
|
* Creates UserApplication records for apps with DefaultForNewUser=true and Status='Active'.
|
|
331
385
|
* Called when a user has no existing UserApplication records (self-healing).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-manager.js","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAmB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAiD,MAAM,sBAAsB,CAAC;AACrJ,OAAO,EAA2B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAYrD;;;;;;GAMG;AAIH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,aAAa,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC3D,gBAAgB,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC9D,eAAe,GAAG,IAAI,eAAe,CAAkB,EAAE,CAAC,CAAC;IAC3D,UAAU,GAAG,IAAI,eAAe,CAAyB,IAAI,CAAC,CAAC;IAC/D,QAAQ,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;IAC/C,WAAW,GAAG,KAAK,CAAC;IAE5B,kEAAkE;IAC1D,aAAa,CAAc;IAC3B,aAAa,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAExF;;;OAGG;IACH,SAAS;QACP,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jB,UAAU,EAAE,IAAI;iBACjB,CAAC;QACN,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACnC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,6EAA6E;QAC7E,sFAAsF;QACtF,OAAO,MAAM,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,KAAa;QAClC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,4EAA4E;QAC5E,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACnC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,4EAA4E;QAC5E,OAAO,MAAM,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB,CAAC,KAAa;QACrC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,8EAA8E;QAC9E,OAAO,MAAM,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;4GA3pBU,kBAAkB;gEAAlB,kBAAkB,WAAlB,kBAAkB,mBAFjB,MAAM;;iFAEP,kBAAkB;cAH9B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';\nimport { Metadata, ApplicationInfo, LogError, LogStatus, StartupManager, IMetadataProvider, PermissionConstrainedError } from '@memberjunction/core';\nimport { MJUserApplicationEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BaseApplication } from './base-application';\n\n/**\n * Represents a user's application configuration including visibility and order\n */\nexport interface UserAppConfig {\n app: BaseApplication;\n userAppId: string;\n sequence: number;\n isActive: boolean;\n}\n\n/**\n * Manages application instances and active application state.\n *\n * Loads applications filtered by the user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n * Orders applications by UserApplication.Sequence.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class ApplicationManager {\n private static _recoveryAttempted = false;\n private applications$ = new BehaviorSubject<BaseApplication[]>([]);\n private allApplications$ = new BehaviorSubject<BaseApplication[]>([]);\n private userAppConfigs$ = new BehaviorSubject<UserAppConfig[]>([]);\n private activeApp$ = new BehaviorSubject<BaseApplication | null>(null);\n private loading$ = new BehaviorSubject<boolean>(false);\n private initialized = false;\n\n /** Resolves when loadApplications() has completed successfully */\n private _readyResolve!: () => void;\n private _readyPromise = new Promise<void>(resolve => { this._readyResolve = resolve; });\n\n /**\n * Returns a promise that resolves when applications have been loaded and the manager is ready.\n * Safe to call multiple times — returns the same promise.\n */\n WhenReady(): Promise<void> {\n return this._readyPromise;\n }\n\n /**\n * Observable of user's active applications (filtered and ordered by UserApplication)\n */\n get Applications(): Observable<BaseApplication[]> {\n return this.applications$.asObservable();\n }\n\n /**\n * Observable of ALL applications in the system (unfiltered)\n */\n get AllApplications(): Observable<BaseApplication[]> {\n return this.allApplications$.asObservable();\n }\n\n /**\n * Observable of user's application configurations (includes sequence, isActive)\n */\n get UserAppConfigs(): Observable<UserAppConfig[]> {\n return this.userAppConfigs$.asObservable();\n }\n\n /**\n * Observable of the currently active application\n */\n get ActiveApp(): Observable<BaseApplication | null> {\n return this.activeApp$.asObservable();\n }\n\n /**\n * Observable of loading state\n */\n get Loading(): Observable<boolean> {\n return this.loading$.asObservable();\n }\n\n /**\n * Get user's active applications synchronously (filtered and ordered)\n */\n GetAllApps(): BaseApplication[] {\n return this.applications$.value;\n }\n\n /**\n * Get ALL applications synchronously (unfiltered)\n */\n GetAllSystemApps(): BaseApplication[] {\n return this.allApplications$.value;\n }\n\n /**\n * Get all applications the current user's roles grant access to.\n * Filters out apps where ApplicationRole records exist but the user's roles lack CanAccess.\n */\n GetAuthorizedSystemApps(): BaseApplication[] {\n const engine = UserInfoEngine.Instance;\n return this.allApplications$.value.filter(app => engine.UserHasApplicationAccess(app.ID));\n }\n\n /**\n * Get user's application configurations synchronously\n */\n GetUserAppConfigs(): UserAppConfig[] {\n return this.userAppConfigs$.value;\n }\n\n /**\n * Get active application synchronously\n */\n GetActiveApp(): BaseApplication | null {\n return this.activeApp$.value;\n }\n\n /**\n * Optional explicit metadata provider. When set, all provider lookups\n * use this instead of falling back to `Metadata.Provider`. This is the\n * threading point for multi-provider Angular apps — the shell calls\n * `setProvider(this.ProviderToUse)` after the manager is acquired from DI.\n */\n private _provider: IMetadataProvider | null = null;\n\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n\n constructor() {\n this.Initialize();\n }\n\n /**\n * Initialize the application manager by subscribing to the LoggedIn event.\n * Applications are loaded when the event fires, ensuring metadata is ready.\n * Also subscribes to UserInfoEngine data changes to auto-sync when user apps change.\n */\n Initialize(): void {\n if (this.initialized) {\n return;\n }\n\n // Subscribe with replay (true) to catch the event even if it already fired\n MJGlobal.Instance.GetEventListener(true).subscribe(async (event) => {\n if (event.event === MJEventType.LoggedIn) {\n await StartupManager.Instance.Startup() // make sure this is done\n this.loadApplications();\n this.subscribeToEngineChanges();\n }\n });\n }\n\n /**\n * Subscribe to UserInfoEngine data changes to automatically sync our observables\n * when UserApplication records are modified.\n *\n * Match on EntityName (the stable public identifier) rather than PropertyName —\n * PropertyName is the engine's internal backing-field name (e.g. `_UserApplications`\n * with an underscore prefix), which is an implementation detail that has bitten\n * consumers before. EntityName is the documented contract on every config and\n * never changes shape.\n */\n private subscribeToEngineChanges(): void {\n const engine = UserInfoEngine.Instance;\n engine.DataChange$.subscribe(event => {\n // When UserApplications data changes in the engine, sync our observables\n if (event.config.EntityName?.trim().toLowerCase() === 'mj: user applications') {\n this.syncFromEngine();\n }\n });\n }\n\n /**\n * Sync our BehaviorSubjects with the current data from UserInfoEngine.\n * Called when the engine emits a data change event for UserApplications.\n */\n private syncFromEngine(): void {\n const allApps = this.allApplications$.value;\n const engine = UserInfoEngine.Instance;\n if (engine.IsPermissionConstrained) return; // No data available — nothing to sync\n const userApps = engine.UserApplications;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Reload the user's application configuration.\n * Call this after changes to UserApplication records to refresh the app list.\n *\n * Reads engine.UserApplications and rebuilds our derived observables. The engine's\n * own event-driven refresh (via subscribeToEngineChanges + the UserApplications\n * config's short DebounceTime) keeps the underlying data fresh — we no longer need\n * a synchronous force-refresh here, which previously triggered NG0100 in callers\n * with `@if`/`@for` bindings whose values mutate during their save loop.\n */\n async ReloadUserApplications(): Promise<void> {\n this.loading$.next(true);\n\n try {\n await this.loadUserApplicationConfig();\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load applications from metadata, filtered and ordered by user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n */\n private async loadApplications(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n this.loading$.next(true);\n\n try {\n const md = this.Provider;\n const appInfoList: ApplicationInfo[] = md.Applications;\n\n // First, create BaseApplication instances for ALL apps\n const allApps: BaseApplication[] = [];\n\n for (const appInfo of appInfoList) {\n // Only create instances for Active applications\n if (appInfo.Status !== 'Active') {\n continue;\n }\n\n const args = {\n ID: appInfo.ID,\n Name: appInfo.Name,\n Description: appInfo.Description || '',\n Icon: appInfo.Icon || '',\n Color: appInfo.Color,\n DefaultNavItems: appInfo.DefaultNavItems,\n ClassName: appInfo.ClassName,\n DefaultSequence: appInfo.DefaultSequence,\n Status: appInfo.Status,\n NavigationStyle: appInfo.NavigationStyle,\n TopNavLocation: appInfo.TopNavLocation,\n HideNavBarIconWhenActive: appInfo.HideNavBarIconWhenActive,\n Path: appInfo.Path || '',\n AutoUpdatePath: appInfo.AutoUpdatePath\n };\n\n let app: BaseApplication | null;\n if (appInfo.ClassName && appInfo.ClassName.trim().length > 0) {\n app = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync<BaseApplication>(\n BaseApplication,\n appInfo.ClassName,\n args\n );\n }\n else {\n // no class provided in app definition.\n app = new BaseApplication(args)\n }\n\n if (app) {\n // should always get here unless failure to load registered sub-class but CreateInstance has\n // fallback to base class anyway so should always get here\n if (this._provider) {\n app.Provider = this._provider;\n }\n allApps.push(app);\n }\n }\n\n this.allApplications$.next(allApps);\n\n // Load and apply user's app configuration\n await this.loadUserApplicationConfig();\n\n // Recovery check: if no active apps but metadata has Active applications,\n // the engine may have failed to load UserApplications (e.g., cache corruption).\n // Attempt one recovery by force-refreshing UserInfoEngine before giving up.\n const activeApps = this.applications$.value;\n const hasMetadataApps = md.Applications.some(a => a.Status === 'Active');\n if (activeApps.length === 0 && hasMetadataApps && !ApplicationManager._recoveryAttempted) {\n ApplicationManager._recoveryAttempted = true;\n const activeAppCount = md.Applications.filter(a => a.Status === 'Active').length;\n const engineHealthy = UserInfoEngine.Instance.AllPropertiesLoadedSuccessfully;\n const userAppCount = UserInfoEngine.Instance.UserApplications?.length ?? 0;\n LogStatus(\n `ApplicationManager: Recovery triggered — ` +\n `activeApps=0, metadataActiveApps=${activeAppCount}, ` +\n `engineHealthy=${engineHealthy}, userAppRecords=${userAppCount}`\n );\n await this.attemptRecovery();\n }\n\n this.initialized = true;\n this._readyResolve();\n\n } catch (error) {\n // Resolve even on failure so waiters don't hang forever — they'll see initialized=false\n this._readyResolve();\n LogError('Failed to load applications:', undefined, error instanceof Error ? error.message : String(error));\n throw error;\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load user's UserApplication records and update the filtered/ordered app list.\n * This can be called to refresh after configuration changes.\n */\n private async loadUserApplicationConfig(): Promise<void> {\n const md = this.Provider;\n const allApps = this.allApplications$.value;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Load user's UserApplication records using UserInfoEngine for caching\n const engine = UserInfoEngine.Instance;\n\n // If the engine can't read user application data, skip the self-healing path —\n // a permission-denied user is NOT the same as a new user with no records.\n if (engine.IsPermissionConstrained) {\n LogStatus(`${this.constructor.name}: UserInfoEngine is permission-constrained, skipping application config load`);\n this.userAppConfigs$.next([]);\n this.applications$.next([]);\n return;\n }\n\n let userApps: MJUserApplicationEntity[] = engine.UserApplications;\n\n // Self-healing: If user has no UserApplication records, create from DefaultForNewUser apps\n if (userApps.length === 0) {\n LogStatus(`User ${md.CurrentUser.Name} has no UserApplication records, creating from DefaultForNewUser apps`);\n userApps = await this.createDefaultUserApplications();\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Creates UserApplication records for apps with DefaultForNewUser=true and Status='Active'.\n * Called when a user has no existing UserApplication records (self-healing).\n * Delegates to UserInfoEngine for the actual creation.\n */\n private async createDefaultUserApplications(): Promise<MJUserApplicationEntity[]> {\n const engine = UserInfoEngine.Instance;\n return await engine.CreateDefaultApplications();\n }\n\n /**\n * One-shot recovery attempt when the initial load produces zero apps despite\n * Active applications existing in metadata. Force-refreshes UserInfoEngine\n * to bypass any corrupted cache, then re-runs the user app configuration\n * (which includes the self-healing path for new users).\n */\n private async attemptRecovery(): Promise<void> {\n try {\n const engine = UserInfoEngine.Instance;\n await engine.Config(true);\n await this.loadUserApplicationConfig();\n\n const recoveredCount = this.applications$.value.length;\n const engineHealthy = engine.AllPropertiesLoadedSuccessfully;\n if (recoveredCount > 0) {\n LogStatus(`ApplicationManager: Recovery succeeded — ${recoveredCount} apps loaded, engineHealthy=${engineHealthy}`);\n } else {\n LogError(`ApplicationManager: Recovery completed but still 0 apps — engineHealthy=${engineHealthy}`);\n }\n } catch (error) {\n LogError('ApplicationManager: Recovery attempt failed:', undefined, error instanceof Error ? error.message : String(error));\n }\n }\n\n /**\n * Set the active application by ID\n */\n async SetActiveApp(appId: string): Promise<void> {\n const currentApp = this.activeApp$.value;\n const newApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n\n if (!newApp) {\n return;\n }\n\n if (UUIDsEqual(currentApp?.ID, appId)) {\n return; // Already active\n }\n\n // Deactivate current app\n if (currentApp) {\n await currentApp.OnDeactivate();\n }\n\n // Activate new app\n await newApp.OnActivate();\n this.activeApp$.next(newApp);\n }\n\n /**\n * Get application by ID\n */\n GetAppById(appId: string): BaseApplication | undefined {\n return this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n }\n\n /**\n * The app a fresh session should land on when the URL names no app and there is no\n * workspace state to restore: the user's active, access-granted application with the\n * lowest `Application.DefaultSequence` (Home ships at -1; everything else defaults\n * to 100). Ties keep the earlier app in the user's Sequence-ordered list, so when no\n * app is flagged below the default the result degrades to the first app the user\n * ordered — deterministic either way.\n *\n * Deliberately independent of `UserApplication.Sequence`: that value is a user-owned\n * DISPLAY preference for the app switcher, and reordering the switcher must never\n * change where a session lands.\n */\n GetDefaultLandingApp(): BaseApplication | null {\n const apps = this.applications$.value;\n if (apps.length === 0) {\n return null;\n }\n // Mirror UserInfoEngine.applicationDefaultSequence's missing-value guard (?? 100):\n // the constructor's Object.assign can overwrite the class default with undefined,\n // and a NaN comparison would make this reduce silently order-dependent.\n const defaultSequence = (app: BaseApplication): number => (Number.isFinite(app.DefaultSequence) ? app.DefaultSequence : 100);\n return apps.reduce((best, app) => (defaultSequence(app) < defaultSequence(best) ? app : best));\n }\n\n /**\n * Canonical `/app/:slug` URL for an application. Uses the app's `Path`\n * (what {@link GetAppByPath} matches on), falling back to `Name`, and\n * url-encodes the segment. This is the single source of truth for app URLs —\n * never hand-roll a slug from `Name` (e.g. spaces→hyphens), because a custom\n * `Path` would then diverge from the URL and `GetAppByPath` would fail to\n * resolve it (broken navigation / redirect loops).\n */\n GetAppUrl(app: BaseApplication): string {\n return `/app/${encodeURIComponent(app.Path || app.Name)}`;\n }\n\n /**\n * Get application by name\n */\n GetAppByName(name: string): BaseApplication | undefined {\n return this.applications$.value.find(a => a.Name === name);\n }\n\n /**\n * Get application by URL path slug.\n * Matches case-insensitively against the app's Path property.\n * Falls back to Name match if Path is not found (for backwards compatibility).\n */\n GetAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.applications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name (for backwards compatibility with old URLs)\n return this.applications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Get applications that should appear in the Nav Bar (NavigationStyle = 'Nav Bar' or 'Both')\n * filtered by TopNavLocation.\n */\n GetNavBarApps(location: 'Left of App Switcher' | 'Left of User Menu'): BaseApplication[] {\n return this.applications$.value.filter(app =>\n (app.NavigationStyle === 'Nav Bar' || app.NavigationStyle === 'Both') &&\n app.TopNavLocation === location\n );\n }\n\n /**\n * Get applications that should appear in the App Switcher (NavigationStyle = 'App Switcher' or 'Both')\n */\n GetAppSwitcherApps(): BaseApplication[] {\n return this.applications$.value.filter(app =>\n app.NavigationStyle === 'App Switcher' || app.NavigationStyle === 'Both'\n );\n }\n\n /**\n * Check if an app exists in the system by path or name (case-insensitive).\n * Returns the app from allApplications$ if found, regardless of user access.\n */\n GetSystemAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.allApplications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name\n return this.allApplications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Check if a system app is inactive (Status !== 'Active').\n * Delegates to UserInfoEngine for the metadata lookup.\n */\n IsAppInactive(path: string): boolean {\n const engine = UserInfoEngine.Instance;\n const appInfo = engine.FindApplicationByPathOrName(path);\n return appInfo != null && engine.IsApplicationInactive(appInfo.ID);\n }\n\n /**\n * Determine why a user cannot access an app by its URL path.\n * Uses UserInfoEngine for core access checking logic.\n * Returns detailed access information for error handling.\n */\n CheckAppAccess(path: string): AppAccessResult {\n const engine = UserInfoEngine.Instance;\n\n // Step 1: Check if app exists in metadata at all\n const appInfo = engine.FindApplicationByPathOrName(path);\n\n if (!appInfo) {\n return {\n status: 'not_found',\n message: `The application \"${path}\" does not exist.`,\n appName: path\n };\n }\n\n // Step 2: Check if app is inactive\n if (engine.IsApplicationInactive(appInfo.ID)) {\n return {\n status: 'inactive',\n message: `The application \"${appInfo.Name}\" is currently inactive.`,\n appName: appInfo.Name,\n appId: appInfo.ID\n };\n }\n\n // Step 3: Check user's access status via engine\n const accessStatus = engine.CheckUserApplicationAccess(appInfo.ID);\n\n switch (accessStatus) {\n case 'installed_active': {\n // User has access - find the BaseApplication instance\n const baseApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appInfo.ID));\n return {\n status: 'accessible',\n message: 'User has access to this app',\n appName: appInfo.Name,\n appId: appInfo.ID,\n app: baseApp\n };\n }\n\n case 'not_authorized':\n return {\n status: 'not_authorized',\n message: `You do not have the required role to access \"${appInfo.Name}\".`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: false\n };\n\n case 'installed_inactive':\n return {\n status: 'disabled',\n message: `You have disabled \"${appInfo.Name}\" in your app configuration.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n\n case 'not_installed':\n default:\n return {\n status: 'not_installed',\n message: `You don't have \"${appInfo.Name}\" installed.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n }\n }\n\n /**\n * Install an application for the current user by creating a UserApplication record.\n * Delegates to UserInfoEngine for the actual installation.\n * Returns the newly created UserApplication entity.\n */\n async InstallAppForUser(appId: string): Promise<MJUserApplicationEntity | null> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh,\n // which our subscribeToEngineChanges() handler will pick up and call syncFromEngine()\n return await engine.InstallApplication(appId);\n }\n\n /**\n * Enable an existing but disabled UserApplication record.\n * Delegates to UserInfoEngine for the actual enabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async EnableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.EnableApplication(appId);\n }\n\n /**\n * Disable an application for the current user.\n * Delegates to UserInfoEngine for the actual disabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async DisableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.DisableApplication(appId);\n }\n\n /**\n * Uninstall an application for the current user.\n * Delegates to UserInfoEngine for the actual uninstallation.\n * Sync happens automatically via DataChange$ subscription.\n */\n async UninstallAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity delete triggers a refresh\n return await engine.UninstallApplication(appId);\n }\n}\n\n/**\n * Result of checking a user's access to an application\n */\nexport interface AppAccessResult {\n /** Status of the access check */\n status: 'accessible' | 'not_found' | 'inactive' | 'not_installed' | 'disabled' | 'not_authorized';\n /** Human-readable message describing the access status */\n message: string;\n /** Name of the application (if found) */\n appName: string;\n /** ID of the application (if found) */\n appId?: string;\n /** The BaseApplication instance (if accessible) */\n app?: BaseApplication;\n /** Whether the user can install/enable this app */\n canInstall?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"application-manager.js","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAmB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAiD,MAAM,sBAAsB,CAAC;AACrJ,OAAO,EAA2B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAYrD;;;;;;GAMG;AAIH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,aAAa,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC3D,gBAAgB,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC9D,eAAe,GAAG,IAAI,eAAe,CAAkB,EAAE,CAAC,CAAC;IAC3D,UAAU,GAAG,IAAI,eAAe,CAAyB,IAAI,CAAC,CAAC;IAC/D,QAAQ,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;IAC/C,WAAW,GAAG,KAAK,CA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;QAC5E,OAAO,MAAM,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB,CAAC,KAAa;QACrC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,8EAA8E;QAC9E,OAAO,MAAM,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;4GAntBU,kBAAkB;gEAAlB,kBAAkB,WAAlB,kBAAkB,mBAFjB,MAAM;;iFAEP,kBAAkB;cAH9B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { IndexByUUID, MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';\nimport { Metadata, ApplicationInfo, LogError, LogStatus, StartupManager, IMetadataProvider, PermissionConstrainedError } from '@memberjunction/core';\nimport { MJUserApplicationEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BaseApplication } from './base-application';\n\n/**\n * Represents a user's application configuration including visibility and order\n */\nexport interface UserAppConfig {\n app: BaseApplication;\n userAppId: string;\n sequence: number;\n isActive: boolean;\n}\n\n/**\n * Manages application instances and active application state.\n *\n * Loads applications filtered by the user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n * Orders applications by UserApplication.Sequence.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class ApplicationManager {\n private static _recoveryAttempted = false;\n private applications$ = new BehaviorSubject<BaseApplication[]>([]);\n private allApplications$ = new BehaviorSubject<BaseApplication[]>([]);\n private userAppConfigs$ = new BehaviorSubject<UserAppConfig[]>([]);\n private activeApp$ = new BehaviorSubject<BaseApplication | null>(null);\n private loading$ = new BehaviorSubject<boolean>(false);\n private initialized = false;\n\n /** Resolves when loadApplications() has completed successfully */\n private _readyResolve!: () => void;\n private _readyPromise = new Promise<void>(resolve => { this._readyResolve = resolve; });\n\n /**\n * Returns a promise that resolves when applications have been loaded and the manager is ready.\n * Safe to call multiple times — returns the same promise.\n */\n WhenReady(): Promise<void> {\n return this._readyPromise;\n }\n\n /**\n * Observable of user's active applications (filtered and ordered by UserApplication)\n */\n get Applications(): Observable<BaseApplication[]> {\n return this.applications$.asObservable();\n }\n\n /**\n * Observable of ALL applications in the system (unfiltered)\n */\n get AllApplications(): Observable<BaseApplication[]> {\n return this.allApplications$.asObservable();\n }\n\n /**\n * Observable of user's application configurations (includes sequence, isActive)\n */\n get UserAppConfigs(): Observable<UserAppConfig[]> {\n return this.userAppConfigs$.asObservable();\n }\n\n /**\n * Observable of the currently active application\n */\n get ActiveApp(): Observable<BaseApplication | null> {\n return this.activeApp$.asObservable();\n }\n\n /**\n * Observable of loading state\n */\n get Loading(): Observable<boolean> {\n return this.loading$.asObservable();\n }\n\n /**\n * Get user's active applications synchronously (filtered and ordered)\n */\n GetAllApps(): BaseApplication[] {\n return this.applications$.value;\n }\n\n /**\n * Get ALL applications synchronously (unfiltered)\n */\n GetAllSystemApps(): BaseApplication[] {\n return this.allApplications$.value;\n }\n\n /**\n * Get all applications the current user's roles grant access to.\n * Filters out apps where ApplicationRole records exist but the user's roles lack CanAccess.\n */\n GetAuthorizedSystemApps(): BaseApplication[] {\n const engine = UserInfoEngine.Instance;\n return this.allApplications$.value.filter(app => engine.UserHasApplicationAccess(app.ID));\n }\n\n /**\n * Get user's application configurations synchronously\n */\n GetUserAppConfigs(): UserAppConfig[] {\n return this.userAppConfigs$.value;\n }\n\n /**\n * Get active application synchronously\n */\n GetActiveApp(): BaseApplication | null {\n return this.activeApp$.value;\n }\n\n /**\n * Optional explicit metadata provider. When set, all provider lookups\n * use this instead of falling back to `Metadata.Provider`. This is the\n * threading point for multi-provider Angular apps — the shell calls\n * `setProvider(this.ProviderToUse)` after the manager is acquired from DI.\n */\n private _provider: IMetadataProvider | null = null;\n\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n\n constructor() {\n this.Initialize();\n }\n\n /**\n * Initialize the application manager by subscribing to the LoggedIn event.\n * Applications are loaded when the event fires, ensuring metadata is ready.\n * Also subscribes to UserInfoEngine data changes to auto-sync when user apps change.\n */\n Initialize(): void {\n if (this.initialized) {\n return;\n }\n\n // Subscribe with replay (true) to catch the event even if it already fired\n MJGlobal.Instance.GetEventListener(true).subscribe(async (event) => {\n if (event.event === MJEventType.LoggedIn) {\n await StartupManager.Instance.Startup() // make sure this is done\n // Fire-and-forget from an event callback: loadApplications() already logs its failure\n // and resolves WhenReady() waiters before rethrowing (for callers that await it), so\n // the rethrow has nobody to land on here — catch it rather than leave an unhandled\n // rejection on the page.\n this.loadApplications().catch(() => { /* logged inside loadApplications */ });\n this.subscribeToEngineChanges();\n }\n });\n }\n\n /**\n * Subscribe to UserInfoEngine data changes to automatically sync our observables\n * when UserApplication records are modified.\n *\n * Match on EntityName (the stable public identifier) rather than PropertyName —\n * PropertyName is the engine's internal backing-field name (e.g. `_UserApplications`\n * with an underscore prefix), which is an implementation detail that has bitten\n * consumers before. EntityName is the documented contract on every config and\n * never changes shape.\n */\n private subscribeToEngineChanges(): void {\n const engine = UserInfoEngine.Instance;\n engine.DataChange$.subscribe(event => {\n // When UserApplications data changes in the engine, sync our observables\n if (event.config.EntityName?.trim().toLowerCase() === 'mj: user applications') {\n this.syncFromEngine();\n }\n });\n }\n\n /**\n * Sync our BehaviorSubjects with the current data from UserInfoEngine.\n * Called when the engine emits a data change event for UserApplications.\n */\n private syncFromEngine(): void {\n const allApps = this.allApplications$.value;\n const engine = UserInfoEngine.Instance;\n if (engine.IsPermissionConstrained) return; // No data available — nothing to sync\n const userApps = engine.UserApplications;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Reload the user's application configuration.\n * Call this after changes to UserApplication records to refresh the app list.\n *\n * Reads engine.UserApplications and rebuilds our derived observables. The engine's\n * own event-driven refresh (via subscribeToEngineChanges + the UserApplications\n * config's short DebounceTime) keeps the underlying data fresh — we no longer need\n * a synchronous force-refresh here, which previously triggered NG0100 in callers\n * with `@if`/`@for` bindings whose values mutate during their save loop.\n */\n async ReloadUserApplications(): Promise<void> {\n this.loading$.next(true);\n\n try {\n await this.loadUserApplicationConfig();\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load applications from metadata, filtered and ordered by user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n */\n private async loadApplications(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n this.loading$.next(true);\n\n try {\n const md = this.Provider;\n const appInfoList: ApplicationInfo[] = md.Applications;\n\n // First, create BaseApplication instances for ALL apps\n const allApps: BaseApplication[] = [];\n\n for (const appInfo of appInfoList) {\n // Only create instances for Active applications\n if (appInfo.Status !== 'Active') {\n continue;\n }\n\n const args = {\n ID: appInfo.ID,\n Name: appInfo.Name,\n Description: appInfo.Description || '',\n Icon: appInfo.Icon || '',\n Color: appInfo.Color,\n DefaultNavItems: appInfo.DefaultNavItems,\n ClassName: appInfo.ClassName,\n DefaultSequence: appInfo.DefaultSequence,\n Status: appInfo.Status,\n NavigationStyle: appInfo.NavigationStyle,\n TopNavLocation: appInfo.TopNavLocation,\n HideNavBarIconWhenActive: appInfo.HideNavBarIconWhenActive,\n Path: appInfo.Path || '',\n AutoUpdatePath: appInfo.AutoUpdatePath\n };\n\n let app: BaseApplication | null;\n if (appInfo.ClassName && appInfo.ClassName.trim().length > 0) {\n app = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync<BaseApplication>(\n BaseApplication,\n appInfo.ClassName,\n args\n );\n }\n else {\n // no class provided in app definition.\n app = new BaseApplication(args)\n }\n\n if (app) {\n // should always get here unless failure to load registered sub-class but CreateInstance has\n // fallback to base class anyway so should always get here\n if (this._provider) {\n app.Provider = this._provider;\n }\n allApps.push(app);\n }\n }\n\n this.allApplications$.next(allApps);\n\n // Load and apply user's app configuration\n await this.loadUserApplicationConfig();\n\n // Recovery check: if no active apps but metadata has Active applications,\n // the engine may have failed to load UserApplications (e.g., cache corruption).\n // Attempt one recovery by force-refreshing UserInfoEngine before giving up.\n const activeApps = this.applications$.value;\n const hasMetadataApps = md.Applications.some(a => a.Status === 'Active');\n // A permission-constrained session (e.g. an external magic-link user holding only\n // 'Magic Link Baseline' plus a granted role) has zero user apps BY DESIGN — that is\n // not cache corruption, and a forced engine refresh cannot grant read access. Without\n // this guard the recovery log below read UserApplications, which throws\n // PermissionConstrainedError, and loadApplications() rejected unhandled at every boot.\n if (activeApps.length === 0 && hasMetadataApps && !ApplicationManager._recoveryAttempted\n && !UserInfoEngine.Instance.IsPermissionConstrained) {\n ApplicationManager._recoveryAttempted = true;\n const activeAppCount = md.Applications.filter(a => a.Status === 'Active').length;\n const engineHealthy = UserInfoEngine.Instance.AllPropertiesLoadedSuccessfully;\n const userAppCount = UserInfoEngine.Instance.UserApplications?.length ?? 0;\n LogStatus(\n `ApplicationManager: Recovery triggered — ` +\n `activeApps=0, metadataActiveApps=${activeAppCount}, ` +\n `engineHealthy=${engineHealthy}, userAppRecords=${userAppCount}`\n );\n await this.attemptRecovery();\n }\n\n this.initialized = true;\n this._readyResolve();\n\n } catch (error) {\n // Resolve even on failure so waiters don't hang forever — they'll see initialized=false\n this._readyResolve();\n LogError('Failed to load applications:', undefined, error instanceof Error ? error.message : String(error));\n throw error;\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load user's UserApplication records and update the filtered/ordered app list.\n * This can be called to refresh after configuration changes.\n */\n private async loadUserApplicationConfig(): Promise<void> {\n const md = this.Provider;\n const allApps = this.allApplications$.value;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Load user's UserApplication records using UserInfoEngine for caching\n const engine = UserInfoEngine.Instance;\n\n // If the engine can't read user application data, skip the self-healing path —\n // a permission-denied user is NOT the same as a new user with no records.\n if (engine.IsPermissionConstrained) {\n const sessionApps = this.permissionConstrainedSessionApps(allApps);\n LogStatus(`${this.constructor.name}: UserInfoEngine is permission-constrained, skipping application config load; ${sessionApps.length} default app(s) offered for this session`);\n this.userAppConfigs$.next([]);\n this.applications$.next(sessionApps);\n return;\n }\n\n let userApps: MJUserApplicationEntity[] = engine.UserApplications;\n\n // Self-healing: If user has no UserApplication records, create from DefaultForNewUser apps\n if (userApps.length === 0) {\n LogStatus(`User ${md.CurrentUser.Name} has no UserApplication records, creating from DefaultForNewUser apps`);\n userApps = await this.createDefaultUserApplications();\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * The apps a permission-constrained session (e.g. an external magic-link user) is offered when it\n * cannot read its own `MJ: User Applications` rows: what a brand-new user would get —\n * DefaultForNewUser apps the user may access, in DefaultSequence order — but held in memory\n * only, never saved as records. When the session cannot read application roles either, access\n * cannot be judged (an unreadable role list reads as \"open to everyone\"), so nothing is offered;\n * an app-locked session still reaches its scoped app through {@link AdoptSessionApplication}.\n */\n private permissionConstrainedSessionApps(allApps: readonly BaseApplication[]): BaseApplication[] {\n const engine = UserInfoEngine.Instance;\n if (engine.IsPropertyPermissionConstrained('_applicationRoles')) {\n return [];\n }\n const defaults = this.Provider.Applications\n .filter(a => a.DefaultForNewUser && a.Status === 'Active' && engine.UserHasApplicationAccess(a.ID))\n .sort((a, b) => (a.DefaultSequence ?? 100) - (b.DefaultSequence ?? 100));\n const appsByID = IndexByUUID(allApps);\n return defaults\n .map(info => appsByID.Get(info.ID))\n .filter((app): app is BaseApplication => !!app);\n }\n\n /**\n * Makes an application the SESSION is scoped to available in {@link Applications} when the\n * user's own app list does not include it — an app-locked session (a magic-link invite scoped\n * to one app) whose user cannot read, or has no, `MJ: User Applications` rows. In memory only:\n * no record is created. The scope comes from the server-signed session, and the server still\n * enforces every entity permission inside the app.\n *\n * @param appId - the application the session is restricted to\n * @returns true when the app was added (so {@link Applications} re-emits); false when it was\n * already available or is not an active application at all\n */\n AdoptSessionApplication(appId: string): boolean {\n if (!appId || this.GetAppById(appId)) {\n return false;\n }\n const app = this.allApplications$.value.find(a => UUIDsEqual(a.ID, appId));\n if (!app) {\n return false;\n }\n this.applications$.next([...this.applications$.value, app]);\n return true;\n }\n\n /**\n * Creates UserApplication records for apps with DefaultForNewUser=true and Status='Active'.\n * Called when a user has no existing UserApplication records (self-healing).\n * Delegates to UserInfoEngine for the actual creation.\n */\n private async createDefaultUserApplications(): Promise<MJUserApplicationEntity[]> {\n const engine = UserInfoEngine.Instance;\n return await engine.CreateDefaultApplications();\n }\n\n /**\n * One-shot recovery attempt when the initial load produces zero apps despite\n * Active applications existing in metadata. Force-refreshes UserInfoEngine\n * to bypass any corrupted cache, then re-runs the user app configuration\n * (which includes the self-healing path for new users).\n */\n private async attemptRecovery(): Promise<void> {\n try {\n const engine = UserInfoEngine.Instance;\n await engine.Config(true);\n await this.loadUserApplicationConfig();\n\n const recoveredCount = this.applications$.value.length;\n const engineHealthy = engine.AllPropertiesLoadedSuccessfully;\n if (recoveredCount > 0) {\n LogStatus(`ApplicationManager: Recovery succeeded — ${recoveredCount} apps loaded, engineHealthy=${engineHealthy}`);\n } else {\n LogError(`ApplicationManager: Recovery completed but still 0 apps — engineHealthy=${engineHealthy}`);\n }\n } catch (error) {\n LogError('ApplicationManager: Recovery attempt failed:', undefined, error instanceof Error ? error.message : String(error));\n }\n }\n\n /**\n * Set the active application by ID\n */\n async SetActiveApp(appId: string): Promise<void> {\n const currentApp = this.activeApp$.value;\n const newApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n\n if (!newApp) {\n return;\n }\n\n if (UUIDsEqual(currentApp?.ID, appId)) {\n return; // Already active\n }\n\n // Deactivate current app\n if (currentApp) {\n await currentApp.OnDeactivate();\n }\n\n // Activate new app\n await newApp.OnActivate();\n this.activeApp$.next(newApp);\n }\n\n /**\n * Get application by ID\n */\n GetAppById(appId: string): BaseApplication | undefined {\n return this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n }\n\n /**\n * The app a fresh session should land on when the URL names no app and there is no\n * workspace state to restore: the user's active, access-granted application with the\n * lowest `Application.DefaultSequence` (Home ships at -1; everything else defaults\n * to 100). Ties keep the earlier app in the user's Sequence-ordered list, so when no\n * app is flagged below the default the result degrades to the first app the user\n * ordered — deterministic either way.\n *\n * Deliberately independent of `UserApplication.Sequence`: that value is a user-owned\n * DISPLAY preference for the app switcher, and reordering the switcher must never\n * change where a session lands.\n */\n GetDefaultLandingApp(): BaseApplication | null {\n const apps = this.applications$.value;\n if (apps.length === 0) {\n return null;\n }\n // Mirror UserInfoEngine.applicationDefaultSequence's missing-value guard (?? 100):\n // the constructor's Object.assign can overwrite the class default with undefined,\n // and a NaN comparison would make this reduce silently order-dependent.\n const defaultSequence = (app: BaseApplication): number => (Number.isFinite(app.DefaultSequence) ? app.DefaultSequence : 100);\n return apps.reduce((best, app) => (defaultSequence(app) < defaultSequence(best) ? app : best));\n }\n\n /**\n * Canonical `/app/:slug` URL for an application. Uses the app's `Path`\n * (what {@link GetAppByPath} matches on), falling back to `Name`, and\n * url-encodes the segment. This is the single source of truth for app URLs —\n * never hand-roll a slug from `Name` (e.g. spaces→hyphens), because a custom\n * `Path` would then diverge from the URL and `GetAppByPath` would fail to\n * resolve it (broken navigation / redirect loops).\n */\n GetAppUrl(app: BaseApplication): string {\n return `/app/${encodeURIComponent(app.Path || app.Name)}`;\n }\n\n /**\n * Get application by name\n */\n GetAppByName(name: string): BaseApplication | undefined {\n return this.applications$.value.find(a => a.Name === name);\n }\n\n /**\n * Get application by URL path slug.\n * Matches case-insensitively against the app's Path property.\n * Falls back to Name match if Path is not found (for backwards compatibility).\n */\n GetAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.applications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name (for backwards compatibility with old URLs)\n return this.applications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Get applications that should appear in the Nav Bar (NavigationStyle = 'Nav Bar' or 'Both')\n * filtered by TopNavLocation.\n */\n GetNavBarApps(location: 'Left of App Switcher' | 'Left of User Menu'): BaseApplication[] {\n return this.applications$.value.filter(app =>\n (app.NavigationStyle === 'Nav Bar' || app.NavigationStyle === 'Both') &&\n app.TopNavLocation === location\n );\n }\n\n /**\n * Get applications that should appear in the App Switcher (NavigationStyle = 'App Switcher' or 'Both')\n */\n GetAppSwitcherApps(): BaseApplication[] {\n return this.applications$.value.filter(app =>\n app.NavigationStyle === 'App Switcher' || app.NavigationStyle === 'Both'\n );\n }\n\n /**\n * Check if an app exists in the system by path or name (case-insensitive).\n * Returns the app from allApplications$ if found, regardless of user access.\n */\n GetSystemAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.allApplications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name\n return this.allApplications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Check if a system app is inactive (Status !== 'Active').\n * Delegates to UserInfoEngine for the metadata lookup.\n */\n IsAppInactive(path: string): boolean {\n const engine = UserInfoEngine.Instance;\n const appInfo = engine.FindApplicationByPathOrName(path);\n return appInfo != null && engine.IsApplicationInactive(appInfo.ID);\n }\n\n /**\n * Determine why a user cannot access an app by its URL path.\n * Uses UserInfoEngine for core access checking logic.\n * Returns detailed access information for error handling.\n */\n CheckAppAccess(path: string): AppAccessResult {\n const engine = UserInfoEngine.Instance;\n\n // Step 1: Check if app exists in metadata at all\n const appInfo = engine.FindApplicationByPathOrName(path);\n\n if (!appInfo) {\n return {\n status: 'not_found',\n message: `The application \"${path}\" does not exist.`,\n appName: path\n };\n }\n\n // Step 2: Check if app is inactive\n if (engine.IsApplicationInactive(appInfo.ID)) {\n return {\n status: 'inactive',\n message: `The application \"${appInfo.Name}\" is currently inactive.`,\n appName: appInfo.Name,\n appId: appInfo.ID\n };\n }\n\n // Step 3: Check user's access status via engine\n const accessStatus = engine.CheckUserApplicationAccess(appInfo.ID);\n\n switch (accessStatus) {\n case 'installed_active': {\n // User has access - find the BaseApplication instance\n const baseApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appInfo.ID));\n return {\n status: 'accessible',\n message: 'User has access to this app',\n appName: appInfo.Name,\n appId: appInfo.ID,\n app: baseApp\n };\n }\n\n case 'not_authorized':\n return {\n status: 'not_authorized',\n message: `You do not have the required role to access \"${appInfo.Name}\".`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: false\n };\n\n case 'installed_inactive':\n return {\n status: 'disabled',\n message: `You have disabled \"${appInfo.Name}\" in your app configuration.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n\n case 'not_installed':\n default:\n return {\n status: 'not_installed',\n message: `You don't have \"${appInfo.Name}\" installed.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n }\n }\n\n /**\n * Install an application for the current user by creating a UserApplication record.\n * Delegates to UserInfoEngine for the actual installation.\n * Returns the newly created UserApplication entity.\n */\n async InstallAppForUser(appId: string): Promise<MJUserApplicationEntity | null> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh,\n // which our subscribeToEngineChanges() handler will pick up and call syncFromEngine()\n return await engine.InstallApplication(appId);\n }\n\n /**\n * Enable an existing but disabled UserApplication record.\n * Delegates to UserInfoEngine for the actual enabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async EnableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.EnableApplication(appId);\n }\n\n /**\n * Disable an application for the current user.\n * Delegates to UserInfoEngine for the actual disabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async DisableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.DisableApplication(appId);\n }\n\n /**\n * Uninstall an application for the current user.\n * Delegates to UserInfoEngine for the actual uninstallation.\n * Sync happens automatically via DataChange$ subscription.\n */\n async UninstallAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity delete triggers a refresh\n return await engine.UninstallApplication(appId);\n }\n}\n\n/**\n * Result of checking a user's access to an application\n */\nexport interface AppAccessResult {\n /** Status of the access check */\n status: 'accessible' | 'not_found' | 'inactive' | 'not_installed' | 'disabled' | 'not_authorized';\n /** Human-readable message describing the access status */\n message: string;\n /** Name of the application (if found) */\n appName: string;\n /** ID of the application (if found) */\n appId?: string;\n /** The BaseApplication instance (if accessible) */\n app?: BaseApplication;\n /** Whether the user can install/enable this app */\n canInstall?: boolean;\n}\n"]}
|
|
@@ -72,6 +72,27 @@ export declare class TabService {
|
|
|
72
72
|
* to reset the flag for future navigations.
|
|
73
73
|
*/
|
|
74
74
|
ClearSuppressFlag(): void;
|
|
75
|
+
/**
|
|
76
|
+
* A record whose URL's browser-history entry should be REPLACED, not kept,
|
|
77
|
+
* when the workspace next navigates away from it. See
|
|
78
|
+
* {@link MarkRecordUrlForReplacement}.
|
|
79
|
+
*/
|
|
80
|
+
private _recordUrlToReplace;
|
|
81
|
+
/**
|
|
82
|
+
* Ask that the next URL sync leaving this record's URL replace its history
|
|
83
|
+
* entry instead of pushing a new one. Used when the record was deleted:
|
|
84
|
+
* browser Back must not land on it again and reopen it as a blank form.
|
|
85
|
+
*
|
|
86
|
+
* Keyed by the record rather than "the next sync": URL syncs run
|
|
87
|
+
* asynchronously, and an unrelated one may land first.
|
|
88
|
+
*/
|
|
89
|
+
MarkRecordUrlForReplacement(entityName: string, recordId: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* True, once, when the URL being left shows the marked record. Clears the
|
|
92
|
+
* mark when it matches. Entity and id compare case-insensitively, like the
|
|
93
|
+
* record-tab matching that set the mark.
|
|
94
|
+
*/
|
|
95
|
+
ConsumeRecordUrlReplacement(entityName: string, recordId: string): boolean;
|
|
75
96
|
static ɵfac: i0.ɵɵFactoryDeclaration<TabService, never>;
|
|
76
97
|
static ɵprov: i0.ɵɵInjectableDeclaration<TabService>;
|
|
77
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab.service.d.ts","sourceRoot":"","sources":["../../src/lib/tab.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,UAAU,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;;AAEhE;;;;;;;;;GASG;AACH,qBAGa,UAAU;IACrB,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,cAAc,CAAoB;IAE1C;;;;OAIG;IACH,OAAO,CAAC,oBAAoB,CAAS;I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{
|
|
142
142
|
this._suppressNextResolve = false;
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* A record whose URL's browser-history entry should be REPLACED, not kept,
|
|
146
|
+
* when the workspace next navigates away from it. See
|
|
147
|
+
* {@link MarkRecordUrlForReplacement}.
|
|
148
|
+
*/
|
|
149
|
+
_recordUrlToReplace = null;
|
|
150
|
+
/**
|
|
151
|
+
* Ask that the next URL sync leaving this record's URL replace its history
|
|
152
|
+
* entry instead of pushing a new one. Used when the record was deleted:
|
|
153
|
+
* browser Back must not land on it again and reopen it as a blank form.
|
|
154
|
+
*
|
|
155
|
+
* Keyed by the record rather than "the next sync": URL syncs run
|
|
156
|
+
* asynchronously, and an unrelated one may land first.
|
|
157
|
+
*/
|
|
158
|
+
MarkRecordUrlForReplacement(entityName, recordId) {
|
|
159
|
+
this._recordUrlToReplace = { EntityName: entityName, RecordId: recordId };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* True, once, when the URL being left shows the marked record. Clears the
|
|
163
|
+
* mark when it matches. Entity and id compare case-insensitively, like the
|
|
164
|
+
* record-tab matching that set the mark.
|
|
165
|
+
*/
|
|
166
|
+
ConsumeRecordUrlReplacement(entityName, recordId) {
|
|
167
|
+
const mark = this._recordUrlToReplace;
|
|
168
|
+
if (!mark) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const matches = mark.EntityName.trim().toLowerCase() === entityName.trim().toLowerCase()
|
|
172
|
+
&& mark.RecordId.trim().toLowerCase() === recordId.trim().toLowerCase();
|
|
173
|
+
if (matches) {
|
|
174
|
+
this._recordUrlToReplace = null;
|
|
175
|
+
}
|
|
176
|
+
return matches;
|
|
177
|
+
}
|
|
144
178
|
static ɵfac = function TabService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TabService)(); };
|
|
145
179
|
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TabService, factory: TabService.ɵfac, providedIn: 'root' });
|
|
146
180
|
}
|
|
@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;;;OAIG;IACK,mBAAmB,GAAoD,IAAI,CAAC;IAEpF;;;;;;;OAOG;IACH,2BAA2B,CAAC,UAAkB,EAAE,QAAgB;QAC9D,IAAI,CAAC,mBAAmB,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC5E,CAAC;IAED;;;;OAIG;IACH,2BAA2B,CAAC,UAAkB,EAAE,QAAgB;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACtC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;eACnF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1E,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAClC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;oGApLU,UAAU;gEAAV,UAAU,WAAV,UAAU,mBAFT,MAAM;;iFAEP,UAAU;cAHtB,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject, Observable } from 'rxjs';\nimport { TabRequest } from './interfaces/tab-request.interface';\n\n/**\n * Service for requesting tabs to be opened.\n *\n * This service provides a way for any component in the app to request\n * that a new tab be opened without needing direct access to the\n * WorkspaceStateManager.\n *\n * Tab requests are queued and can be replayed when subscribers connect.\n * This ensures requests aren't lost if they arrive before the shell is ready.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class TabService {\n private tabRequest$ = new Subject<TabRequest>();\n private queuedRequests: TabRequest[] = [];\n\n /**\n * Flag to suppress the next ResourceResolver processing.\n * Used when URL changes are just syncing to the current active tab,\n * not actual navigation requests that should create/focus tabs.\n */\n private _suppressNextResolve = false;\n\n /**\n * Observable of tab open requests\n */\n get TabRequests(): Observable<TabRequest> {\n return this.tabRequest$.asObservable();\n }\n\n /**\n * Request that a new tab be opened\n */\n OpenTab(request: TabRequest): void {\n // Store in queue for replay\n this.queuedRequests.push(request);\n\n // Emit to current subscribers\n this.tabRequest$.next(request);\n }\n\n /**\n * Get all queued tab requests (for replay on subscription)\n */\n GetQueuedRequests(): TabRequest[] {\n return [...this.queuedRequests];\n }\n\n /**\n * Clear the queue after requests have been processed\n */\n ClearQueue(): void {\n this.queuedRequests = [];\n }\n\n /**\n * Helper method to open a record in a tab\n */\n OpenRecord(entityName: string, recordId: string, applicationId: string): void {\n this.OpenTab({\n ApplicationId: applicationId,\n Title: `${entityName}`,\n Route: `/record/${entityName}/${recordId}`,\n Configuration: {\n resourceType: 'record',\n entityName,\n recordId\n }\n });\n }\n\n /**\n * Helper method to open a view in a tab\n */\n OpenView(viewId: string, viewName: string, applicationId: string): void {\n this.OpenTab({\n ApplicationId: applicationId,\n Title: viewName,\n Route: `/view/${viewId}`,\n Configuration: {\n resourceType: 'view',\n viewId\n }\n });\n }\n\n /**\n * Helper method to open a dashboard in a tab\n */\n OpenDashboard(dashboardId: string, dashboardName: string, applicationId: string): void {\n this.OpenTab({\n ApplicationId: applicationId,\n Title: dashboardName,\n Route: `/dashboard/${dashboardId}`,\n Configuration: {\n resourceType: 'dashboard',\n dashboardId\n }\n });\n }\n\n /**\n * Helper method to open a query in a tab\n */\n OpenQuery(queryId: string, queryName: string, applicationId: string): void {\n this.OpenTab({\n ApplicationId: applicationId,\n Title: queryName,\n Route: `/query/${queryId}`,\n Configuration: {\n resourceType: 'query',\n queryId\n }\n });\n }\n\n /**\n * Helper method to open a list in a tab\n */\n OpenList(listId: string, listName: string, applicationId: string): void {\n this.OpenTab({\n ApplicationId: applicationId,\n Title: listName,\n ResourceRecordId: listId,\n Configuration: {\n resourceType: 'Custom',\n driverClass: 'ListDetailResource',\n recordId: listId\n }\n });\n }\n\n /**\n * Signal that the next ResourceResolver call should be suppressed.\n * Call this before navigating when the URL change is just syncing\n * to the current active tab, not a real navigation request.\n */\n SuppressNextResolve(): void {\n this._suppressNextResolve = true;\n }\n\n /**\n * Check if the current resolve should be suppressed.\n * Returns true if SuppressNextResolve() was called and the flag hasn't been cleared.\n */\n ShouldSuppressResolve(): boolean {\n return this._suppressNextResolve;\n }\n\n /**\n * Clear the suppress flag. Call this after checking ShouldSuppressResolve()\n * to reset the flag for future navigations.\n */\n ClearSuppressFlag(): void {\n this._suppressNextResolve = false;\n }\n\n /**\n * A record whose URL's browser-history entry should be REPLACED, not kept,\n * when the workspace next navigates away from it. See\n * {@link MarkRecordUrlForReplacement}.\n */\n private _recordUrlToReplace: { EntityName: string; RecordId: string } | null = null;\n\n /**\n * Ask that the next URL sync leaving this record's URL replace its history\n * entry instead of pushing a new one. Used when the record was deleted:\n * browser Back must not land on it again and reopen it as a blank form.\n *\n * Keyed by the record rather than \"the next sync\": URL syncs run\n * asynchronously, and an unrelated one may land first.\n */\n MarkRecordUrlForReplacement(entityName: string, recordId: string): void {\n this._recordUrlToReplace = { EntityName: entityName, RecordId: recordId };\n }\n\n /**\n * True, once, when the URL being left shows the marked record. Clears the\n * mark when it matches. Entity and id compare case-insensitively, like the\n * record-tab matching that set the mark.\n */\n ConsumeRecordUrlReplacement(entityName: string, recordId: string): boolean {\n const mark = this._recordUrlToReplace;\n if (!mark) {\n return false;\n }\n const matches = mark.EntityName.trim().toLowerCase() === entityName.trim().toLowerCase()\n && mark.RecordId.trim().toLowerCase() === recordId.trim().toLowerCase();\n if (matches) {\n this._recordUrlToReplace = null;\n }\n return matches;\n }\n}\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { WorkspaceConfiguration } from './interfaces/workspace-configuration.interface';
|
|
2
|
+
/**
|
|
3
|
+
* One browser-local snapshot of the user's workspace configuration.
|
|
4
|
+
*
|
|
5
|
+
* The workspace is persisted to `MJ: Workspaces` through a debounced, asynchronous entity
|
|
6
|
+
* save. A refresh that lands inside that window (debounce + network round trip) used to
|
|
7
|
+
* come back one step behind: the newest tab/selection change existed only in memory. The
|
|
8
|
+
* journal is written SYNCHRONOUSLY on every change, so the newest state survives any unload.
|
|
9
|
+
*/
|
|
10
|
+
export interface WorkspaceJournalEntry {
|
|
11
|
+
/** Format version of this entry; entries with another version are ignored. */
|
|
12
|
+
Version: 1;
|
|
13
|
+
/** The user the snapshot belongs to. */
|
|
14
|
+
UserID: string;
|
|
15
|
+
/** The `MJ: Workspaces` row the snapshot was built on, or null when the user has none (permission-constrained sessions). */
|
|
16
|
+
WorkspaceID: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* The row's server `__mj_UpdatedAt` (ISO) that this snapshot is built on top of: the stamp of
|
|
19
|
+
* the last save this browser saw complete, or of the row as loaded. Compared only with another
|
|
20
|
+
* SERVER stamp, never with this browser's clock, so client clock skew cannot pick the wrong side.
|
|
21
|
+
*/
|
|
22
|
+
BaseUpdatedAt: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* The serialized configuration of a save this browser started but has not yet seen complete,
|
|
25
|
+
* or null/absent when no save is in flight. A save that lands on the server while the page is
|
|
26
|
+
* unloading advances the row's stamp past {@link BaseUpdatedAt} without this browser ever
|
|
27
|
+
* re-basing; matching the row against this value is how the next load recognises that newer
|
|
28
|
+
* row as its OWN write (which the snapshot already supersedes) rather than another device's.
|
|
29
|
+
*/
|
|
30
|
+
InFlightConfiguration?: string | null;
|
|
31
|
+
/** The configuration itself. */
|
|
32
|
+
Configuration: WorkspaceConfiguration;
|
|
33
|
+
}
|
|
34
|
+
/** The storage surface the journal needs — `window.localStorage` in a browser. */
|
|
35
|
+
export interface WorkspaceJournalStorage {
|
|
36
|
+
getItem(key: string): string | null;
|
|
37
|
+
setItem(key: string, value: string): void;
|
|
38
|
+
removeItem(key: string): void;
|
|
39
|
+
}
|
|
40
|
+
/** Reads a server timestamp that may arrive as a Date or an ISO string; null when absent or unparseable. */
|
|
41
|
+
export declare function WorkspaceStampToEpoch(value: Date | string | null | undefined): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* Decides whether a journal snapshot is newer than the configuration the server returned.
|
|
44
|
+
*
|
|
45
|
+
* The journal wins only when it belongs to the same workspace row AND the server row has not
|
|
46
|
+
* been saved since the snapshot's base stamp. A server row stamped LATER than the base was
|
|
47
|
+
* saved by something this browser never saw (another device or browser tab), so the server
|
|
48
|
+
* wins. A server row stamped at or before the base is what this browser already built on —
|
|
49
|
+
* including a stale locally-cached copy of the row — so the journal, which holds every change
|
|
50
|
+
* made since, wins.
|
|
51
|
+
*
|
|
52
|
+
* One exception to "later row wins": the row is this browser's OWN save that landed after the
|
|
53
|
+
* page unloaded (its stamp moved past the base, but the browser never saw the response). The row's
|
|
54
|
+
* configuration then equals the snapshot's {@link WorkspaceJournalEntry.InFlightConfiguration},
|
|
55
|
+
* and the snapshot, which holds every change made after that save started, still wins.
|
|
56
|
+
*
|
|
57
|
+
* @param entry the journal snapshot, if any.
|
|
58
|
+
* @param workspaceId the loaded workspace row's ID, or null when the user has none.
|
|
59
|
+
* @param serverUpdatedAt the loaded row's `__mj_UpdatedAt`, or null when there is no row.
|
|
60
|
+
* @param serverConfiguration the loaded row's raw `Configuration` text, when there is a row.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ShouldUseWorkspaceJournal(entry: WorkspaceJournalEntry | null, workspaceId: string | null, serverUpdatedAt: Date | string | null | undefined, serverConfiguration?: string | null): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Synchronous, per-user workspace snapshot in browser storage. Every operation is
|
|
65
|
+
* exception-safe: storage can be absent, full, or blocked (private mode), and the journal
|
|
66
|
+
* is only ever a recovery aid — the database stays the system of record.
|
|
67
|
+
*/
|
|
68
|
+
export declare class WorkspaceJournal {
|
|
69
|
+
private readonly getStorage;
|
|
70
|
+
private static readonly keyPrefix;
|
|
71
|
+
/**
|
|
72
|
+
* @param getStorage resolves the storage lazily on each call, so a missing or throwing
|
|
73
|
+
* `localStorage` is handled per call rather than at construction.
|
|
74
|
+
*/
|
|
75
|
+
constructor(getStorage: () => WorkspaceJournalStorage | null);
|
|
76
|
+
/** The storage key for a user's snapshot. */
|
|
77
|
+
static KeyFor(userId: string): string;
|
|
78
|
+
/** Writes (replaces) the user's snapshot. Silently does nothing when storage is unavailable. */
|
|
79
|
+
Write(entry: WorkspaceJournalEntry): void;
|
|
80
|
+
/** Reads the user's snapshot, or null when absent, unreadable, or of another format version. */
|
|
81
|
+
Read(userId: string): WorkspaceJournalEntry | null;
|
|
82
|
+
/** Removes the user's snapshot. */
|
|
83
|
+
Clear(userId: string): void;
|
|
84
|
+
}
|
|
85
|
+
/** `window.localStorage` when it exists and can be touched, else null. */
|
|
86
|
+
export declare function BrowserWorkspaceJournalStorage(): WorkspaceJournalStorage | null;
|
|
87
|
+
//# sourceMappingURL=workspace-journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-journal.d.ts","sourceRoot":"","sources":["../../src/lib/workspace-journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAExF;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IAClC,8EAA8E;IAC9E,OAAO,EAAE,CAAC,CAAC;IACX,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,4HAA4H;IAC5H,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,gCAAgC;IAChC,aAAa,EAAE,sBAAsB,CAAC;CACzC;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,G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