ui5-lib-guard-router 1.5.1 → 1.5.3
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/README.md +43 -10
- package/dist/.ui5/build-manifest.json +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/resources/ui5/guard/router/.library +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js +7 -5
- package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.d.ts +9 -8
- package/dist/resources/ui5/guard/router/GuardPipeline.d.ts.map +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.js +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.js.map +1 -1
- package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js +7 -6
- package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts +7 -6
- package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts.map +1 -1
- package/dist/resources/ui5/guard/router/NavigationOutcome.js.map +1 -1
- package/dist/resources/ui5/guard/router/Router-dbg.js +60 -59
- package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/Router.d.ts +28 -8
- package/dist/resources/ui5/guard/router/Router.d.ts.map +1 -1
- package/dist/resources/ui5/guard/router/Router.js +1 -1
- package/dist/resources/ui5/guard/router/Router.js.map +1 -1
- package/dist/resources/ui5/guard/router/library-dbg.js +1 -1
- package/dist/resources/ui5/guard/router/library-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/library-preload.js +4 -4
- package/dist/resources/ui5/guard/router/library-preload.js.map +1 -1
- package/dist/resources/ui5/guard/router/library.js +1 -1
- package/dist/resources/ui5/guard/router/library.js.map +1 -1
- package/dist/resources/ui5/guard/router/manifest.json +1 -1
- package/dist/resources/ui5/guard/router/types-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/types.d.ts +57 -7
- package/dist/resources/ui5/guard/router/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/GuardPipeline.ts +11 -10
- package/src/NavigationOutcome.ts +7 -6
- package/src/Router.ts +80 -66
- package/src/manifest.json +1 -1
- package/src/types.ts +57 -7
package/README.md
CHANGED
|
@@ -218,15 +218,15 @@ All guard registration and removal methods return `this` for chaining. `navigati
|
|
|
218
218
|
|
|
219
219
|
Every guard receives a `GuardContext` object:
|
|
220
220
|
|
|
221
|
-
| Property | Type | Description
|
|
222
|
-
| ------------- | -------------------------------------------------- |
|
|
223
|
-
| `toRoute` | `string` | Target route name (empty if no match)
|
|
224
|
-
| `toHash` | `string` | Raw hash being navigated to
|
|
225
|
-
| `toArguments` | `Record<string, string \| Record<string, string>>` | Parsed route parameters
|
|
226
|
-
| `fromRoute` | `string` | Current route name (empty on first navigation)
|
|
227
|
-
| `fromHash` | `string` | Current hash
|
|
228
|
-
| `signal` | `AbortSignal` | Aborted when navigation is superseded, or on `stop()`/`destroy()`
|
|
229
|
-
| `bag` | `Map<string, unknown>` | Shared mutable store for inter-guard data passing within one
|
|
221
|
+
| Property | Type | Description |
|
|
222
|
+
| ------------- | -------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
223
|
+
| `toRoute` | `string` | Target route name (empty if no match) |
|
|
224
|
+
| `toHash` | `string` | Raw hash being navigated to |
|
|
225
|
+
| `toArguments` | `Record<string, string \| Record<string, string>>` | Parsed route parameters |
|
|
226
|
+
| `fromRoute` | `string` | Current route name (empty on first navigation) |
|
|
227
|
+
| `fromHash` | `string` | Current hash |
|
|
228
|
+
| `signal` | `AbortSignal` | Aborted when navigation is superseded, or on `stop()`/`destroy()` |
|
|
229
|
+
| `bag` | `Map<string, unknown>` | Shared mutable store for inter-guard data passing within one navigation |
|
|
230
230
|
|
|
231
231
|
### Return values (`GuardResult`)
|
|
232
232
|
|
|
@@ -549,7 +549,7 @@ When `#` is used on a single-function module, the export key is ignored with a d
|
|
|
549
549
|
|
|
550
550
|
### Guard context `bag`
|
|
551
551
|
|
|
552
|
-
Guards
|
|
552
|
+
Guards can share data through `context.bag`, a `Map<string, unknown>` that is created fresh for each navigation and shared across all guards in that navigation, including across redirect chain hops:
|
|
553
553
|
|
|
554
554
|
```typescript
|
|
555
555
|
export default function firstGuard(context: GuardContext): GuardResult {
|
|
@@ -715,6 +715,39 @@ export default class HomeController extends BaseController {
|
|
|
715
715
|
>
|
|
716
716
|
> In FLP apps with `sap-keep-alive` enabled, the component persists when navigating to other apps. Guards remain registered since the same instance is reused.
|
|
717
717
|
|
|
718
|
+
### Metadata-driven guards via manifest
|
|
719
|
+
|
|
720
|
+
For common patterns like "this route requires authentication", you can store per-route metadata in a custom manifest section and use a single global guard instead of writing repetitive per-route guards:
|
|
721
|
+
|
|
722
|
+
```json
|
|
723
|
+
{
|
|
724
|
+
"ui5.guard.router": {
|
|
725
|
+
"routeMeta": {
|
|
726
|
+
"admin": { "requiresAuth": true, "roles": ["admin"] },
|
|
727
|
+
"profile": { "requiresAuth": true },
|
|
728
|
+
"home": { "public": true }
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
```typescript
|
|
735
|
+
// Component.ts — read the custom section via getManifestEntry (typed path lookup)
|
|
736
|
+
type RouteMeta = Record<string, Record<string, unknown>>;
|
|
737
|
+
const routeMeta = (this.getManifestEntry("/ui5.guard.router/routeMeta") ?? {}) as RouteMeta;
|
|
738
|
+
|
|
739
|
+
router.addGuard((context) => {
|
|
740
|
+
const meta = routeMeta[context.toRoute] ?? {};
|
|
741
|
+
if (meta.requiresAuth && !authModel.getProperty("/isLoggedIn")) return "login";
|
|
742
|
+
if (meta.roles && !hasAnyRole(meta.roles as string[])) return "forbidden";
|
|
743
|
+
return true;
|
|
744
|
+
});
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
`getManifestEntry()` accepts a path string (starting with `/`) to reach into nested manifest sections. The return type is `any`, so the local `RouteMeta` alias provides type safety at the consumption site.
|
|
748
|
+
|
|
749
|
+
This keeps guard logic in one place and route annotations in the manifest where they're visible and auditable. The custom namespace `ui5.guard.router` is ignored by the UI5 framework -- it's a convention for your application data.
|
|
750
|
+
|
|
718
751
|
### Native alternative for leave guards: Fiori Launchpad data loss prevention
|
|
719
752
|
|
|
720
753
|
If your app runs inside SAP Fiori Launchpad (FLP), the shell provides built-in data loss protection through two public APIs on `sap.ushell.Container`:
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"buildManifest": {
|
|
18
18
|
"manifestVersion": "0.2",
|
|
19
|
-
"timestamp": "2026-03-
|
|
19
|
+
"timestamp": "2026-03-25T20:16:53.021Z",
|
|
20
20
|
"versions": {
|
|
21
21
|
"builderVersion": "4.1.4",
|
|
22
22
|
"projectVersion": "4.0.13",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"includedTasks": [],
|
|
32
32
|
"excludedTasks": []
|
|
33
33
|
},
|
|
34
|
-
"version": "1.5.
|
|
34
|
+
"version": "1.5.3",
|
|
35
35
|
"namespace": "ui5/guard/router",
|
|
36
36
|
"tags": {
|
|
37
37
|
"/resources/ui5/guard/router/GuardPipeline-dbg.js": {
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// - @types/istanbul-lib-coverage@2.0.6
|
|
34
34
|
// - @types/qunit@2.19.13
|
|
35
35
|
/// <reference path="./resources/ui5/guard/router/library.d.ts"/>
|
|
36
|
+
/// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
|
|
36
37
|
/// <reference path="./resources/ui5/guard/router/Router.d.ts"/>
|
|
37
|
-
/// <reference path="./resources/ui5/guard/router/types.d.ts"/>
|
|
38
38
|
/// <reference path="./resources/ui5/guard/router/NavigationOutcome.d.ts"/>
|
|
39
|
-
/// <reference path="./resources/ui5/guard/router/
|
|
39
|
+
/// <reference path="./resources/ui5/guard/router/types.d.ts"/>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<library xmlns="http://www.sap.com/sap.ui.library.xsd">
|
|
3
3
|
<name>ui5.guard.router</name>
|
|
4
4
|
<vendor>Marco</vendor>
|
|
5
|
-
<version>1.5.
|
|
5
|
+
<version>1.5.3</version>
|
|
6
6
|
<copyright></copyright>
|
|
7
7
|
<title>UI5 Router extension with async navigation guards</title>
|
|
8
8
|
<documentation>Extends sap.m.routing.Router with async navigation guards, running before route matching begins.</documentation>
|
|
@@ -80,8 +80,12 @@ sap.ui.define(["sap/base/Log"], function (Log) {
|
|
|
80
80
|
/**
|
|
81
81
|
* Register a leave guard for a specific route.
|
|
82
82
|
*
|
|
83
|
+
* Accepts `GuardFn` to support manifest-declared guards loaded from
|
|
84
|
+
* untyped modules. Non-boolean return values are caught at runtime
|
|
85
|
+
* by {@link _validateLeaveGuardResult}.
|
|
86
|
+
*
|
|
83
87
|
* @param route - Route name as defined in `manifest.json`.
|
|
84
|
-
* @param guard -
|
|
88
|
+
* @param guard - Guard function to register as a leave guard.
|
|
85
89
|
*/
|
|
86
90
|
addLeaveGuard(route, guard) {
|
|
87
91
|
this._addToGuardMap(this._leaveGuards, route, guard);
|
|
@@ -91,7 +95,7 @@ sap.ui.define(["sap/base/Log"], function (Log) {
|
|
|
91
95
|
* Remove a previously registered leave guard by reference.
|
|
92
96
|
*
|
|
93
97
|
* @param route - Route name.
|
|
94
|
-
* @param guard -
|
|
98
|
+
* @param guard - Guard function to remove.
|
|
95
99
|
*/
|
|
96
100
|
removeLeaveGuard(route, guard) {
|
|
97
101
|
this._removeFromGuardMap(this._leaveGuards, route, guard);
|
|
@@ -289,9 +293,6 @@ sap.ui.define(["sap/base/Log"], function (Log) {
|
|
|
289
293
|
* determines what to return for non-true results: leave guards always
|
|
290
294
|
* return `false`, enter guards validate and may return redirects.
|
|
291
295
|
*
|
|
292
|
-
* `guards` is typed as `GuardFn[]` for reuse. Leave guard callers
|
|
293
|
-
* pass `LeaveGuardFn[]` which is assignable (narrower return type).
|
|
294
|
-
*
|
|
295
296
|
* @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.
|
|
296
297
|
*/
|
|
297
298
|
async _continueGuardsAsync(pendingResult, guards, currentIndex, context, onBlock, label, isLeaveGuard) {
|
|
@@ -332,6 +333,7 @@ sap.ui.define(["sap/base/Log"], function (Log) {
|
|
|
332
333
|
return false;
|
|
333
334
|
}
|
|
334
335
|
}
|
|
336
|
+
GuardPipeline.isPromiseLike = isPromiseLike;
|
|
335
337
|
return GuardPipeline;
|
|
336
338
|
});
|
|
337
339
|
//# sourceMappingURL=GuardPipeline-dbg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardPipeline-dbg.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","guard","push","removeGlobalGuard","index","indexOf","splice","addEnterGuard","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","hasLeaveGuards","skipLeaveGuards","fromRoute","has","hasEnterGuards","toRoute","action","processEnterResult","enterResult","r","target","catch","error","runEnterPhase","_runEnterGuards","leaveResult","_runLeaveGuards","allowed","signal","aborted","map","key","guards","get","set","delete","registered","slice","i","result","_continueGuardsAsync","candidate","_validateLeaveGuardResult","Log","String","globalResult","_runGuards","_runRouteGuards","_validateGuardResult","pendingResult","currentIndex","onBlock","label","isLeaveGuard","guardIndex","nextResult","warning"],"sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect, LeaveGuardFn } from \"./types\";\n\nconst LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\tconst { route } = value as GuardRedirect;\n\treturn typeof route === \"string\" && route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nfunction isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (value as PromiseLike<T>).then === \"function\";\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. Pure logic with\n * no dependency on Router state beyond the current route name\n * passed into evaluate().\n *\n * @namespace ui5.guard.router\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, LeaveGuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Leave guard function to register.\n\t */\n\taddLeaveGuard(route: string, guard: LeaveGuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Leave guard function to remove.\n\t */\n\tremoveLeaveGuard(route: string, guard: LeaveGuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(context: GuardContext, options?: { skipLeaveGuards?: boolean }): GuardDecision | Promise<GuardDecision> {\n\t\tconst hasLeaveGuards =\n\t\t\t!options?.skipLeaveGuards && context.fromRoute !== \"\" && this._leaveGuards.has(context.fromRoute);\n\t\tconst hasEnterGuards =\n\t\t\tthis._globalGuards.length > 0 || (context.toRoute !== \"\" && this._enterGuards.has(context.toRoute));\n\n\t\tif (!hasLeaveGuards && !hasEnterGuards) {\n\t\t\treturn { action: \"allow\" };\n\t\t}\n\n\t\tconst processEnterResult = (\n\t\t\tenterResult: GuardResult | Promise<GuardResult>,\n\t\t): GuardDecision | Promise<GuardDecision> => {\n\t\t\tif (isPromiseLike(enterResult)) {\n\t\t\t\treturn enterResult\n\t\t\t\t\t.then((r: GuardResult): GuardDecision => {\n\t\t\t\t\t\tif (r === true) return { action: \"allow\" };\n\t\t\t\t\t\tif (r === false) return { action: \"block\" };\n\t\t\t\t\t\treturn { action: \"redirect\", target: r };\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (enterResult === true) return { action: \"allow\" };\n\t\t\tif (enterResult === false) return { action: \"block\" };\n\t\t\treturn { action: \"redirect\", target: enterResult };\n\t\t};\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(context.toRoute, context);\n\t\t\treturn processEnterResult(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tif (hasLeaveGuards) {\n\t\t\t\tconst leaveResult = this._runLeaveGuards(context);\n\n\t\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\t\treturn leaveResult\n\t\t\t\t\t\t.then((allowed: boolean): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\t\t\t}\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn { action: \"error\", error };\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tguards.push(guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run leave guards for the current route. Returns boolean (no redirects).\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runLeaveGuards(context: GuardContext): boolean | Promise<boolean> {\n\t\tconst registered = this._leaveGuards.get(context.fromRoute);\n\t\tif (!registered || registered.length === 0) return true;\n\n\t\tconst guards = registered.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateLeaveGuardResult(candidate),\n\t\t\t\t\t\t\"Leave guard\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as Promise<boolean>;\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateLeaveGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Leave guard [${i}] on route \"${context.fromRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then route-specific guards. Stays sync when possible. */\n\tprivate _runEnterGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst globalResult = this._runGuards(this._globalGuards, context);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn this._runRouteGuards(toRoute, context);\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn this._runRouteGuards(toRoute, context);\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tif (!toRoute || !this._enterGuards.has(toRoute)) return true;\n\t\treturn this._runGuards(this._enterGuards.get(toRoute)!, context);\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runGuards(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateGuardResult(candidate),\n\t\t\t\t\t\t\"Enter guard\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Enter guard [${i}] on route \"${context.toRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * `guards` is typed as `GuardFn[]` for reuse. Leave guard callers\n\t * pass `LeaveGuardFn[]` which is assignable (narrower return type).\n\t *\n\t * @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.\n\t */\n\tprivate async _continueGuardsAsync(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => GuardResult,\n\t\tlabel: string,\n\t\tisLeaveGuard: boolean,\n\t): Promise<GuardResult> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tconst route = isLeaveGuard ? context.fromRoute : context.toRoute;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${label} [${guardIndex}] on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;EAGA,MAAMA,aAAa,GAAG,yBAAyB;EAE/C,SAASC,eAAeA,CAACC,KAAc,EAA0B;IAChE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAChD,OAAO,KAAK;IACb;IAEA,MAAM;MAAEC;IAAM,CAAC,GAAGD,KAAsB;IACxC,OAAO,OAAOC,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,MAAM,GAAG,CAAC;EACrD;;EAEA;AACA;AACA;AACA;AACA;AACA;EACA,SAASC,aAAaA,CAAIH,KAAc,EAA2B;IAClE,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,IAAKA,KAAK,KAAK,IAAI,EAAE;MACjF,OAAO,KAAK;IACb;IAEA,OAAO,OAAQA,KAAK,CAAoBI,IAAI,KAAK,UAAU;EAC5D;;EAEA;AACA;AACA;;EAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACe,MAAMC,aAAa,CAAC;IAC1BC,aAAa,GAAc,EAAE;IAC7BC,YAAY,GAAG,IAAIC,GAAG,CAAoB,CAAC;IAC3CC,YAAY,GAAG,IAAID,GAAG,CAAyB,CAAC;;IAExD;IACAE,cAAcA,CAACC,KAAc,EAAQ;MACpC,IAAI,CAACL,aAAa,CAACM,IAAI,CAACD,KAAK,CAAC;IAC/B;;IAEA;IACAE,iBAAiBA,CAACF,KAAc,EAAQ;MACvC,MAAMG,KAAK,GAAG,IAAI,CAACR,aAAa,CAACS,OAAO,CAACJ,KAAK,CAAC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IAAI+C,UAAU,KAAK,IAAI,EAAE,OAAOJ,OAAO,CAACI,UAAU,CAAC;QACpD;QACA,OAAO,IAAI;MACZ,CAAC,CAAC,OAAOjC,KAAK,EAAE;QACf,IAAI,CAACd,OAAO,CAACoB,MAAM,CAACC,OAAO,EAAE;UAC5B,MAAM7C,KAAK,GAAGqE,YAAY,GAAG7C,OAAO,CAACI,SAAS,GAAGJ,OAAO,CAACO,OAAO;UAChE4B,GAAG,CAACrB,KAAK,CACR,GAAG8B,KAAK,KAAKE,UAAU,eAAetE,KAAK,4BAA4B,EACvE4D,MAAM,CAACtB,KAAK,CAAC,EACbzC,aACD,CAAC;UACD,MAAMyC,KAAK;QACZ;QACA,OAAO,KAAK;MACb;IACD;;IAEA;IACQ0B,oBAAoBA,CAACT,MAAe,EAAe;MAC1D,IAAI,OAAOA,MAAM,KAAK,SAAS,EAAE,OAAOA,MAAM;MAC9C,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACtD,MAAM,GAAG,CAAC,EAAE,OAAOsD,MAAM;MAClE,IAAIzD,eAAe,CAACyD,MAAM,CAAC,EAAE,OAAOA,MAAM;MAC1CI,GAAG,CAACa,OAAO,CAAC,iDAAiD,EAAEZ,MAAM,CAACL,MAAM,CAAC,EAAE1D,aAAa,CAAC;MAC7F,OAAO,KAAK;IACb;;IAEA;IACQ6D,yBAAyBA,CAACH,MAAe,EAAW;MAC3D,IAAI,OAAOA,MAAM,KAAK,SAAS,EAAE,OAAOA,MAAM;MAC9CI,GAAG,CAACa,OAAO,CAAC,2DAA2D,EAAEZ,MAAM,CAACL,MAAM,CAAC,EAAE1D,aAAa,CAAC;MACvG,OAAO,KAAK;IACb;EACD;EAAC,OAAAO,aAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"GuardPipeline-dbg.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","guard","push","removeGlobalGuard","index","indexOf","splice","addEnterGuard","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","hasLeaveGuards","skipLeaveGuards","fromRoute","has","hasEnterGuards","toRoute","action","processEnterResult","enterResult","r","target","catch","error","runEnterPhase","_runEnterGuards","leaveResult","_runLeaveGuards","allowed","signal","aborted","map","key","guards","get","set","delete","registered","slice","i","result","_continueGuardsAsync","candidate","_validateLeaveGuardResult","Log","String","globalResult","_runGuards","_runRouteGuards","_validateGuardResult","pendingResult","currentIndex","onBlock","label","isLeaveGuard","guardIndex","nextResult","warning"],"sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\nconst LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\tconst { route } = value as GuardRedirect;\n\treturn typeof route === \"string\" && route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (value as PromiseLike<T>).then === \"function\";\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. Pure logic with\n * no dependency on Router state beyond the current route name\n * passed into evaluate().\n *\n * @namespace ui5.guard.router\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(context: GuardContext, options?: { skipLeaveGuards?: boolean }): GuardDecision | Promise<GuardDecision> {\n\t\tconst hasLeaveGuards =\n\t\t\t!options?.skipLeaveGuards && context.fromRoute !== \"\" && this._leaveGuards.has(context.fromRoute);\n\t\tconst hasEnterGuards =\n\t\t\tthis._globalGuards.length > 0 || (context.toRoute !== \"\" && this._enterGuards.has(context.toRoute));\n\n\t\tif (!hasLeaveGuards && !hasEnterGuards) {\n\t\t\treturn { action: \"allow\" };\n\t\t}\n\n\t\tconst processEnterResult = (\n\t\t\tenterResult: GuardResult | Promise<GuardResult>,\n\t\t): GuardDecision | Promise<GuardDecision> => {\n\t\t\tif (isPromiseLike(enterResult)) {\n\t\t\t\treturn enterResult\n\t\t\t\t\t.then((r: GuardResult): GuardDecision => {\n\t\t\t\t\t\tif (r === true) return { action: \"allow\" };\n\t\t\t\t\t\tif (r === false) return { action: \"block\" };\n\t\t\t\t\t\treturn { action: \"redirect\", target: r };\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (enterResult === true) return { action: \"allow\" };\n\t\t\tif (enterResult === false) return { action: \"block\" };\n\t\t\treturn { action: \"redirect\", target: enterResult };\n\t\t};\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(context.toRoute, context);\n\t\t\treturn processEnterResult(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tif (hasLeaveGuards) {\n\t\t\t\tconst leaveResult = this._runLeaveGuards(context);\n\n\t\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\t\treturn leaveResult\n\t\t\t\t\t\t.then((allowed: boolean): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\t\t\t}\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn { action: \"error\", error };\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tguards.push(guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run leave guards for the current route. Returns boolean (no redirects).\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runLeaveGuards(context: GuardContext): boolean | Promise<boolean> {\n\t\tconst registered = this._leaveGuards.get(context.fromRoute);\n\t\tif (!registered || registered.length === 0) return true;\n\n\t\tconst guards = registered.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateLeaveGuardResult(candidate),\n\t\t\t\t\t\t\"Leave guard\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as Promise<boolean>;\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateLeaveGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Leave guard [${i}] on route \"${context.fromRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then route-specific guards. Stays sync when possible. */\n\tprivate _runEnterGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst globalResult = this._runGuards(this._globalGuards, context);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn this._runRouteGuards(toRoute, context);\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn this._runRouteGuards(toRoute, context);\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tif (!toRoute || !this._enterGuards.has(toRoute)) return true;\n\t\treturn this._runGuards(this._enterGuards.get(toRoute)!, context);\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runGuards(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateGuardResult(candidate),\n\t\t\t\t\t\t\"Enter guard\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Enter guard [${i}] on route \"${context.toRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.\n\t */\n\tprivate async _continueGuardsAsync(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => GuardResult,\n\t\tlabel: string,\n\t\tisLeaveGuard: boolean,\n\t): Promise<GuardResult> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tconst route = isLeaveGuard ? context.fromRoute : context.toRoute;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${label} [${guardIndex}] on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;EAGA,MAAMA,aAAa,GAAG,yBAAyB;EAE/C,SAASC,eAAeA,CAACC,KAAc,EAA0B;IAChE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAChD,OAAO,KAAK;IACb;IAEA,MAAM;MAAEC;IAAM,CAAC,GAAGD,KAAsB;IACxC,OAAO,OAAOC,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,MAAM,GAAG,CAAC;EACrD;;EAEA;AACA;AACA;AACA;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AOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACtD,MAAM,GAAG,CAAC,EAAE,OAAOsD,MAAM;MAClE,IAAIzD,eAAe,CAACyD,MAAM,CAAC,EAAE,OAAOA,MAAM;MAC1CI,GAAG,CAACa,OAAO,CAAC,iDAAiD,EAAEZ,MAAM,CAACL,MAAM,CAAC,EAAE1D,aAAa,CAAC;MAC7F,OAAO,KAAK;IACb;;IAEA;IACQ6D,yBAAyBA,CAACH,MAAe,EAAW;MAC3D,IAAI,OAAOA,MAAM,KAAK,SAAS,EAAE,OAAOA,MAAM;MAC9CI,GAAG,CAACa,OAAO,CAAC,2DAA2D,EAAEZ,MAAM,CAACL,MAAM,CAAC,EAAE1D,aAAa,CAAC;MACvG,OAAO,KAAK;IACb;EACD;EAACO,aAAA,CAAAF,aAAA,GAAAA,aAAA;EAAA,OAAAE,aAAA;AAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module "ui5/guard/router/GuardPipeline" {
|
|
2
|
-
import type { GuardFn, GuardContext, GuardRedirect
|
|
2
|
+
import type { GuardFn, GuardContext, GuardRedirect } from "ui5/guard/router/types";
|
|
3
3
|
const LOG_COMPONENT = "ui5.guard.router.Router";
|
|
4
4
|
function isGuardRedirect(value: unknown): value is GuardRedirect;
|
|
5
5
|
/**
|
|
@@ -58,17 +58,21 @@ declare module "ui5/guard/router/GuardPipeline" {
|
|
|
58
58
|
/**
|
|
59
59
|
* Register a leave guard for a specific route.
|
|
60
60
|
*
|
|
61
|
+
* Accepts `GuardFn` to support manifest-declared guards loaded from
|
|
62
|
+
* untyped modules. Non-boolean return values are caught at runtime
|
|
63
|
+
* by {@link _validateLeaveGuardResult}.
|
|
64
|
+
*
|
|
61
65
|
* @param route - Route name as defined in `manifest.json`.
|
|
62
|
-
* @param guard -
|
|
66
|
+
* @param guard - Guard function to register as a leave guard.
|
|
63
67
|
*/
|
|
64
|
-
addLeaveGuard(route: string, guard:
|
|
68
|
+
addLeaveGuard(route: string, guard: GuardFn): void;
|
|
65
69
|
/**
|
|
66
70
|
* Remove a previously registered leave guard by reference.
|
|
67
71
|
*
|
|
68
72
|
* @param route - Route name.
|
|
69
|
-
* @param guard -
|
|
73
|
+
* @param guard - Guard function to remove.
|
|
70
74
|
*/
|
|
71
|
-
removeLeaveGuard(route: string, guard:
|
|
75
|
+
removeLeaveGuard(route: string, guard: GuardFn): void;
|
|
72
76
|
/**
|
|
73
77
|
* Remove all registered guards.
|
|
74
78
|
*/
|
|
@@ -119,9 +123,6 @@ declare module "ui5/guard/router/GuardPipeline" {
|
|
|
119
123
|
* determines what to return for non-true results: leave guards always
|
|
120
124
|
* return `false`, enter guards validate and may return redirects.
|
|
121
125
|
*
|
|
122
|
-
* `guards` is typed as `GuardFn[]` for reuse. Leave guard callers
|
|
123
|
-
* pass `LeaveGuardFn[]` which is assignable (narrower return type).
|
|
124
|
-
*
|
|
125
126
|
* @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.
|
|
126
127
|
*/
|
|
127
128
|
private _continueGuardsAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardPipeline.d.ts","sourceRoot":"../../../../..","sources":["src/GuardPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,gCAAgC,CAAC;IAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAe,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"GuardPipeline.d.ts","sourceRoot":"../../../../..","sources":["src/GuardPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,gCAAgC,CAAC;IAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAe,aAAa,EAAE,MAAM,wBAAwB,CAAC;IAEhG,MAAM,aAAa,4BAA4B,CAAC;IAEhD,SAAS,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAO/D;IAED;;;;;OAKG;IACH,SAAgB,aAAa,CAAC,CA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QAStB,OAAO,CAAC,mBAAmB;QAQ3B;;;;;;WAMG;QACH,OAAO,CAAC,eAAe;QAiCvB,+EAA+E;QAC/E,OAAO,CAAC,eAAe;QAcvB,uDAAuD;QACvD,OAAO,CAAC,eAAe;QAKvB;;;;;;WAMG;QACH,OAAO,CAAC,UAAU;QA8BlB;;;;;;;;WAQG;gBACW,oBAAoB;QAmClC,qEAAqE;QACrE,OAAO,CAAC,oBAAoB;QAQ5B,iFAAiF;QACjF,OAAO,CAAC,yBAAyB;KAKjC;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["sap/base/Log"],function(r){"use strict";const
|
|
1
|
+
sap.ui.define(["sap/base/Log"],function(r){"use strict";const e="ui5.guard.router.Router";function t(r){if(typeof r!=="object"||r===null){return false}const{route:e}=r;return typeof e==="string"&&e.length>0}function a(r){if(typeof r!=="object"&&typeof r!=="function"||r===null){return false}return typeof r.then==="function"}class n{_globalGuards=[];_enterGuards=new Map;_leaveGuards=new Map;addGlobalGuard(r){this._globalGuards.push(r)}removeGlobalGuard(r){const e=this._globalGuards.indexOf(r);if(e!==-1){this._globalGuards.splice(e,1)}}addEnterGuard(r,e){this._addToGuardMap(this._enterGuards,r,e)}removeEnterGuard(r,e){this._removeFromGuardMap(this._enterGuards,r,e)}addLeaveGuard(r,e){this._addToGuardMap(this._leaveGuards,r,e)}removeLeaveGuard(r,e){this._removeFromGuardMap(this._leaveGuards,r,e)}clear(){this._globalGuards=[];this._enterGuards.clear();this._leaveGuards.clear()}evaluate(r,e){const t=!e?.skipLeaveGuards&&r.fromRoute!==""&&this._leaveGuards.has(r.fromRoute);const n=this._globalGuards.length>0||r.toRoute!==""&&this._enterGuards.has(r.toRoute);if(!t&&!n){return{action:"allow"}}const u=r=>{if(a(r)){return r.then(r=>{if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}}).catch(r=>({action:"error",error:r}))}if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}};const o=()=>{const e=this._runEnterGuards(r.toRoute,r);return u(e)};try{if(t){const e=this._runLeaveGuards(r);if(a(e)){return e.then(e=>{if(e!==true)return{action:"block"};if(r.signal.aborted)return{action:"block"};return o()}).catch(r=>({action:"error",error:r}))}if(e!==true)return{action:"block"}}return o()}catch(r){return{action:"error",error:r}}}_addToGuardMap(r,e,t){let a=r.get(e);if(!a){a=[];r.set(e,a)}a.push(t)}_removeFromGuardMap(r,e,t){const a=r.get(e);if(!a)return;const n=a.indexOf(t);if(n!==-1)a.splice(n,1);if(a.length===0)r.delete(e)}_runLeaveGuards(t){const n=this._leaveGuards.get(t.fromRoute);if(!n||n.length===0)return true;const u=n.slice();for(let n=0;n<u.length;n++){try{const r=u[n](t);if(a(r)){return this._continueGuardsAsync(r,u,n,t,r=>this._validateLeaveGuardResult(r),"Leave guard",true)}if(r!==true)return this._validateLeaveGuardResult(r)}catch(a){r.error(`Leave guard [${n}] on route "${t.fromRoute}" threw, navigation failed`,String(a),e);if(t.signal.aborted)return false;throw a}}return true}_runEnterGuards(r,e){const t=this._runGuards(this._globalGuards,e);if(a(t)){return t.then(t=>{if(t!==true)return t;if(e.signal.aborted)return false;return this._runRouteGuards(r,e)})}if(t!==true)return t;return this._runRouteGuards(r,e)}_runRouteGuards(r,e){if(!r||!this._enterGuards.has(r))return true;return this._runGuards(this._enterGuards.get(r),e)}_runGuards(t,n){t=t.slice();for(let u=0;u<t.length;u++){try{const r=t[u](n);if(a(r)){return this._continueGuardsAsync(r,t,u,n,r=>this._validateGuardResult(r),"Enter guard",false)}if(r!==true)return this._validateGuardResult(r)}catch(t){r.error(`Enter guard [${u}] on route "${n.toRoute}" threw, navigation failed`,String(t),e);if(n.signal.aborted)return false;throw t}}return true}async _continueGuardsAsync(t,a,n,u,o,i,s){let l=n;try{const r=await t;if(r!==true)return o(r);for(let r=n+1;r<a.length;r++){if(u.signal.aborted)return false;l=r;const e=await a[r](u);if(e!==true)return o(e)}return true}catch(t){if(!u.signal.aborted){const a=s?u.fromRoute:u.toRoute;r.error(`${i} [${l}] on route "${a}" threw, navigation failed`,String(t),e);throw t}return false}}_validateGuardResult(a){if(typeof a==="boolean")return a;if(typeof a==="string"&&a.length>0)return a;if(t(a))return a;r.warning("Guard returned invalid value, treating as block",String(a),e);return false}_validateLeaveGuardResult(t){if(typeof t==="boolean")return t;r.warning("Leave guard returned non-boolean value, treating as block",String(t),e);return false}}n.isPromiseLike=a;return n});
|
|
2
2
|
//# sourceMappingURL=GuardPipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardPipeline.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","guard","this","push","removeGlobalGuard","index","indexOf","splice","addEnterGuard","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","hasLeaveGuards","skipLeaveGuards","fromRoute","has","hasEnterGuards","toRoute","action","processEnterResult","enterResult","r","target","catch","error","runEnterPhase","_runEnterGuards","leaveResult","_runLeaveGuards","allowed","signal","aborted","map","key","guards","get","set","delete","registered","slice","i","result","_continueGuardsAsync","candidate","_validateLeaveGuardResult","Log","String","globalResult","_runGuards","_runRouteGuards","_validateGuardResult","pendingResult","currentIndex","onBlock","label","isLeaveGuard","guardIndex","nextResult","warning"],"sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect, LeaveGuardFn } from \"./types\";\n\nconst LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\tconst { route } = value as GuardRedirect;\n\treturn typeof route === \"string\" && route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nfunction isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (value as PromiseLike<T>).then === \"function\";\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. Pure logic with\n * no dependency on Router state beyond the current route name\n * passed into evaluate().\n *\n * @namespace ui5.guard.router\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, LeaveGuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Leave guard function to register.\n\t */\n\taddLeaveGuard(route: string, guard: LeaveGuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Leave guard function to remove.\n\t */\n\tremoveLeaveGuard(route: string, guard: LeaveGuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(context: GuardContext, options?: { skipLeaveGuards?: boolean }): GuardDecision | Promise<GuardDecision> {\n\t\tconst hasLeaveGuards =\n\t\t\t!options?.skipLeaveGuards && context.fromRoute !== \"\" && this._leaveGuards.has(context.fromRoute);\n\t\tconst hasEnterGuards =\n\t\t\tthis._globalGuards.length > 0 || (context.toRoute !== \"\" && this._enterGuards.has(context.toRoute));\n\n\t\tif (!hasLeaveGuards && !hasEnterGuards) {\n\t\t\treturn { action: \"allow\" };\n\t\t}\n\n\t\tconst processEnterResult = (\n\t\t\tenterResult: GuardResult | Promise<GuardResult>,\n\t\t): GuardDecision | Promise<GuardDecision> => {\n\t\t\tif (isPromiseLike(enterResult)) {\n\t\t\t\treturn enterResult\n\t\t\t\t\t.then((r: GuardResult): GuardDecision => {\n\t\t\t\t\t\tif (r === true) return { action: \"allow\" };\n\t\t\t\t\t\tif (r === false) return { action: \"block\" };\n\t\t\t\t\t\treturn { action: \"redirect\", target: r };\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (enterResult === true) return { action: \"allow\" };\n\t\t\tif (enterResult === false) return { action: \"block\" };\n\t\t\treturn { action: \"redirect\", target: enterResult };\n\t\t};\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(context.toRoute, context);\n\t\t\treturn processEnterResult(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tif (hasLeaveGuards) {\n\t\t\t\tconst leaveResult = this._runLeaveGuards(context);\n\n\t\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\t\treturn leaveResult\n\t\t\t\t\t\t.then((allowed: boolean): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\t\t\t}\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn { action: \"error\", error };\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tguards.push(guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run leave guards for the current route. Returns boolean (no redirects).\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runLeaveGuards(context: GuardContext): boolean | Promise<boolean> {\n\t\tconst registered = this._leaveGuards.get(context.fromRoute);\n\t\tif (!registered || registered.length === 0) return true;\n\n\t\tconst guards = registered.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateLeaveGuardResult(candidate),\n\t\t\t\t\t\t\"Leave guard\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as Promise<boolean>;\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateLeaveGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Leave guard [${i}] on route \"${context.fromRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then route-specific guards. Stays sync when possible. */\n\tprivate _runEnterGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst globalResult = this._runGuards(this._globalGuards, context);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn this._runRouteGuards(toRoute, context);\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn this._runRouteGuards(toRoute, context);\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tif (!toRoute || !this._enterGuards.has(toRoute)) return true;\n\t\treturn this._runGuards(this._enterGuards.get(toRoute)!, context);\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runGuards(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateGuardResult(candidate),\n\t\t\t\t\t\t\"Enter guard\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Enter guard [${i}] on route \"${context.toRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * `guards` is typed as `GuardFn[]` for reuse. Leave guard callers\n\t * pass `LeaveGuardFn[]` which is assignable (narrower return type).\n\t *\n\t * @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.\n\t */\n\tprivate async _continueGuardsAsync(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => GuardResult,\n\t\tlabel: string,\n\t\tisLeaveGuard: boolean,\n\t): Promise<GuardResult> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tconst route = isLeaveGuard ? context.fromRoute : context.toRoute;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${label} [${guardIndex}] on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":"wDAGA,MAAMA,EAAgB,0BAEtB,SAASC,EAAgBC,GACxB,UAAWA,IAAU,UAAYA,IAAU,KAAM,CAChD,OAAO,KACR,CAEA,MAAMC,MAAEA,GAAUD,EAClB,cAAcC,IAAU,UAAYA,EAAMC,OAAS,CACpD,CAQA,SAASC,EAAiBH,GACzB,UAAYA,IAAU,iBAAmBA,IAAU,YAAeA,IAAU,KAAM,CACjF,OAAO,KACR,CAEA,cAAeA,EAAyBI,OAAS,UAClD,CAqBe,MAAMC,EACZC,cAA2B,GAC3BC,aAAe,IAAIC,IACnBC,aAAe,IAAID,IAG3BE,eAAeC,GACdC,KAAKN,cAAcO,KAAKF,EACzB,CAGAG,kBAAkBH,GACjB,MAAMI,EAAQH,KAAKN,cAAcU,QAAQL,GACzC,GAAII,KAAW,EAAG,CACjBH,KAAKN,cAAcW,OAAOF,EAAO,EAClC,CACD,CAQAG,cAAcjB,EAAeU,GAC5BC,KAAKO,eAAeP,KAAKL,aAAcN,EAAOU,EAC/C,CAQAS,iBAAiBnB,EAAeU,GAC/BC,KAAKS,oBAAoBT,KAAKL,aAAcN,EAAOU,EACpD,CAQAW,cAAcrB,EAAeU,GAC5BC,KAAKO,eAAeP,KAAKH,aAAcR,EAAOU,EAC/C,CAQAY,iBAAiBtB,EAAeU,GAC/BC,KAAKS,oBAAoBT,KAAKH,aAAcR,EAAOU,EACpD,CAKAa,QACCZ,KAAKN,cAAgB,GACrBM,KAAKL,aAAaiB,QAClBZ,KAAKH,aAAae,OACnB,CAgBAC,SAASC,EAAuBC,GAC/B,MAAMC,GACJD,GAASE,iBAAmBH,EAAQI,YAAc,IAAMlB,KAAKH,aAAasB,IAAIL,EAAQI,WACxF,MAAME,EAC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AOA,EACxC,UAAWA,IAAW,UAAYA,EAAOvD,OAAS,EAAG,OAAOuD,EAC5D,GAAI1D,EAAgB0D,GAAS,OAAOA,EACpCI,EAAIa,QAAQ,kDAAmDZ,OAAOL,GAAS3D,GAC/E,OAAO,KACR,CAGQ8D,0BAA0BH,GACjC,UAAWA,IAAW,UAAW,OAAOA,EACxCI,EAAIa,QAAQ,4DAA6DZ,OAAOL,GAAS3D,GACzF,OAAO,KACR,EACA,OAAAO,CAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"GuardPipeline.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","guard","this","push","removeGlobalGuard","index","indexOf","splice","addEnterGuard","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","hasLeaveGuards","skipLeaveGuards","fromRoute","has","hasEnterGuards","toRoute","action","processEnterResult","enterResult","r","target","catch","error","runEnterPhase","_runEnterGuards","leaveResult","_runLeaveGuards","allowed","signal","aborted","map","key","guards","get","set","delete","registered","slice","i","result","_continueGuardsAsync","candidate","_validateLeaveGuardResult","Log","String","globalResult","_runGuards","_runRouteGuards","_validateGuardResult","pendingResult","currentIndex","onBlock","label","isLeaveGuard","guardIndex","nextResult","warning"],"sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\nconst LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\tconst { route } = value as GuardRedirect;\n\treturn typeof route === \"string\" && route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (value as PromiseLike<T>).then === \"function\";\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. Pure logic with\n * no dependency on Router state beyond the current route name\n * passed into evaluate().\n *\n * @namespace ui5.guard.router\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t *\n\t * @param route - Route name.\n\t * @param guard - Guard function to remove.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(context: GuardContext, options?: { skipLeaveGuards?: boolean }): GuardDecision | Promise<GuardDecision> {\n\t\tconst hasLeaveGuards =\n\t\t\t!options?.skipLeaveGuards && context.fromRoute !== \"\" && this._leaveGuards.has(context.fromRoute);\n\t\tconst hasEnterGuards =\n\t\t\tthis._globalGuards.length > 0 || (context.toRoute !== \"\" && this._enterGuards.has(context.toRoute));\n\n\t\tif (!hasLeaveGuards && !hasEnterGuards) {\n\t\t\treturn { action: \"allow\" };\n\t\t}\n\n\t\tconst processEnterResult = (\n\t\t\tenterResult: GuardResult | Promise<GuardResult>,\n\t\t): GuardDecision | Promise<GuardDecision> => {\n\t\t\tif (isPromiseLike(enterResult)) {\n\t\t\t\treturn enterResult\n\t\t\t\t\t.then((r: GuardResult): GuardDecision => {\n\t\t\t\t\t\tif (r === true) return { action: \"allow\" };\n\t\t\t\t\t\tif (r === false) return { action: \"block\" };\n\t\t\t\t\t\treturn { action: \"redirect\", target: r };\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (enterResult === true) return { action: \"allow\" };\n\t\t\tif (enterResult === false) return { action: \"block\" };\n\t\t\treturn { action: \"redirect\", target: enterResult };\n\t\t};\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(context.toRoute, context);\n\t\t\treturn processEnterResult(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tif (hasLeaveGuards) {\n\t\t\t\tconst leaveResult = this._runLeaveGuards(context);\n\n\t\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\t\treturn leaveResult\n\t\t\t\t\t\t.then((allowed: boolean): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: unknown): GuardDecision => {\n\t\t\t\t\t\t\treturn { action: \"error\", error };\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\t\t\t}\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn { action: \"error\", error };\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tguards.push(guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run leave guards for the current route. Returns boolean (no redirects).\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runLeaveGuards(context: GuardContext): boolean | Promise<boolean> {\n\t\tconst registered = this._leaveGuards.get(context.fromRoute);\n\t\tif (!registered || registered.length === 0) return true;\n\n\t\tconst guards = registered.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateLeaveGuardResult(candidate),\n\t\t\t\t\t\t\"Leave guard\",\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t) as Promise<boolean>;\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateLeaveGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Leave guard [${i}] on route \"${context.fromRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then route-specific guards. Stays sync when possible. */\n\tprivate _runEnterGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst globalResult = this._runGuards(this._globalGuards, context);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn this._runRouteGuards(toRoute, context);\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn this._runRouteGuards(toRoute, context);\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tif (!toRoute || !this._enterGuards.has(toRoute)) return true;\n\t\treturn this._runGuards(this._enterGuards.get(toRoute)!, context);\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t */\n\tprivate _runGuards(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tguards,\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t(candidate) => this._validateGuardResult(candidate),\n\t\t\t\t\t\t\"Enter guard\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return this._validateGuardResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`Enter guard [${i}] on route \"${context.toRoute}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param isLeaveGuard - When true, error logs reference `fromRoute`; otherwise `toRoute`.\n\t */\n\tprivate async _continueGuardsAsync(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => GuardResult,\n\t\tlabel: string,\n\t\tisLeaveGuard: boolean,\n\t): Promise<GuardResult> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tconst route = isLeaveGuard ? context.fromRoute : context.toRoute;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${label} [${guardIndex}] on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\tString(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":"wDAGA,MAAMA,EAAgB,0BAEtB,SAASC,EAAgBC,GACxB,UAAWA,IAAU,UAAYA,IAAU,KAAM,CAChD,OAAO,KACR,CAEA,MAAMC,MAAEA,GAAUD,EAClB,cAAcC,IAAU,UAAYA,EAAMC,OAAS,CACpD,CAQO,SAASC,EAAiBH,GAChC,UAAYA,IAAU,iBAAmBA,IAAU,YAAeA,IAAU,KAAM,CACjF,OAAO,KACR,CAEA,cAAeA,EAAyBI,OAAS,UAClD,CAqBe,MAAMC,EACZC,cAA2B,GAC3BC,aAAe,IAAIC,IACnBC,aAAe,IAAID,IAG3BE,eAAeC,GACdC,KAAKN,cAAcO,KAAKF,EACzB,CAGAG,kBAAkBH,GACjB,MAAMI,EAAQH,KAAKN,cAAcU,QAAQL,GACzC,GAAII,KAAW,EAAG,CACjBH,KAAKN,cAAcW,OAAOF,EAAO,EAClC,CACD,CAQAG,cAAcjB,EAAeU,GAC5BC,KAAKO,eAAeP,KAAKL,aAAcN,EAAOU,EAC/C,CAQAS,iBAAiBnB,EAAeU,GAC/BC,KAAKS,oBAAoBT,KAAKL,aAAcN,EAAOU,EACpD,CAYAW,cAAcrB,EAAeU,GAC5BC,KAAKO,eAAeP,KAAKH,aAAcR,EAAOU,EAC/C,CAQAY,iBAAiBtB,EAAeU,GAC/BC,KAAKS,oBAAoBT,KAAKH,aAAcR,EAAOU,EACpD,CAKAa,QACCZ,KAAKN,cAAgB,GACrBM,KAAKL,aAAaiB,QAClBZ,KAAKH,aAAae,OACnB,CAgBAC,SAASC,EAAuBC,GAC/B,MAAMC,GACJD,GAASE,iBAAmBH,EAAQI,YAAc,IAAMlB,KAAKH,aAAasB,IAAIL,EAAQI,WACxF,MAAME,EACLpB,KAAKN,cAAcJ,OAAS,GAAMwB,EAAQO,UAA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EAAG,OAAOuD,EAC5D,GAAI1D,EAAgB0D,GAAS,OAAOA,EACpCI,EAAIa,QAAQ,kDAAmDZ,OAAOL,GAAS3D,GAC/E,OAAO,KACR,CAGQ8D,0BAA0BH,GACjC,UAAWA,IAAW,UAAW,OAAOA,EACxCI,EAAIa,QAAQ,4DAA6DZ,OAAOL,GAAS3D,GACzF,OAAO,KACR,EACAO,EAAAF,gBAAA,OAAAE,CAAA","ignoreList":[]}
|
|
@@ -10,19 +10,20 @@ sap.ui.define([], function () {
|
|
|
10
10
|
*
|
|
11
11
|
* @enum {string}
|
|
12
12
|
* @namespace ui5.guard.router
|
|
13
|
+
* @since 1.2.0
|
|
13
14
|
*/
|
|
14
15
|
const NavigationOutcome = Object.freeze({
|
|
15
|
-
/** Navigation was allowed and the target route activated. */
|
|
16
|
+
/** Navigation was allowed and the target route activated. @since 1.2.0 */
|
|
16
17
|
Committed: "committed",
|
|
17
|
-
/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. */
|
|
18
|
+
/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. @since 1.3.0 */
|
|
18
19
|
Bypassed: "bypassed",
|
|
19
|
-
/** A guard blocked navigation; the previous route remains active. */
|
|
20
|
+
/** A guard blocked navigation; the previous route remains active. @since 1.2.0 */
|
|
20
21
|
Blocked: "blocked",
|
|
21
|
-
/** A guard redirected navigation to a different route. */
|
|
22
|
+
/** A guard redirected navigation to a different route. @since 1.2.0 */
|
|
22
23
|
Redirected: "redirected",
|
|
23
|
-
/** Navigation was cancelled before settling (superseded, stopped, or destroyed). */
|
|
24
|
+
/** Navigation was cancelled before settling (superseded, stopped, or destroyed). @since 1.2.0 */
|
|
24
25
|
Cancelled: "cancelled",
|
|
25
|
-
/** A guard threw or rejected; the previous route remains active. */
|
|
26
|
+
/** A guard threw or rejected; the previous route remains active. @since 1.4.0 */
|
|
26
27
|
Error: "error"
|
|
27
28
|
});
|
|
28
29
|
return NavigationOutcome;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationOutcome-dbg.js","names":["NavigationOutcome","Object","freeze","Committed","Bypassed","Blocked","Redirected","Cancelled","Error"],"sources":["NavigationOutcome.ts"],"sourcesContent":["/**\n * Outcome of a navigation after the guard pipeline settles.\n *\n * Registered as a UI5 enum via `library.ts` so that it is discoverable\n * through `sap.ui.base.DataType.getType()`. Application code can import\n * the value object directly.\n *\n * @enum {string}\n * @namespace ui5.guard.router\n */\nconst NavigationOutcome = Object.freeze({\n\t/** Navigation was allowed and the target route activated. */\n\tCommitted: \"committed\",\n\t/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. */\n\tBypassed: \"bypassed\",\n\t/** A guard blocked navigation; the previous route remains active. */\n\tBlocked: \"blocked\",\n\t/** A guard redirected navigation to a different route. */\n\tRedirected: \"redirected\",\n\t/** Navigation was cancelled before settling (superseded, stopped, or destroyed). */\n\tCancelled: \"cancelled\",\n\t/** A guard threw or rejected; the previous route remains active. */\n\tError: \"error\",\n});\n\ntype NavigationOutcome = (typeof NavigationOutcome)[keyof typeof NavigationOutcome];\n\nexport default NavigationOutcome;\n"],"mappings":";;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACA,MAAMA,iBAAiB,GAAGC,MAAM,CAACC,MAAM,CAAC;IACvC;IACAC,SAAS,EAAE,WAAW;IACtB;IACAC,QAAQ,EAAE,UAAU;IACpB;IACAC,OAAO,EAAE,SAAS;IAClB;IACAC,UAAU,EAAE,YAAY;IACxB;IACAC,SAAS,EAAE,WAAW;IACtB;IACAC,KAAK,EAAE;EACR,CAAC,CAAC;EAAC,OAIYR,iBAAiB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NavigationOutcome-dbg.js","names":["NavigationOutcome","Object","freeze","Committed","Bypassed","Blocked","Redirected","Cancelled","Error"],"sources":["NavigationOutcome.ts"],"sourcesContent":["/**\n * Outcome of a navigation after the guard pipeline settles.\n *\n * Registered as a UI5 enum via `library.ts` so that it is discoverable\n * through `sap.ui.base.DataType.getType()`. Application code can import\n * the value object directly.\n *\n * @enum {string}\n * @namespace ui5.guard.router\n * @since 1.2.0\n */\nconst NavigationOutcome = Object.freeze({\n\t/** Navigation was allowed and the target route activated. @since 1.2.0 */\n\tCommitted: \"committed\",\n\t/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. @since 1.3.0 */\n\tBypassed: \"bypassed\",\n\t/** A guard blocked navigation; the previous route remains active. @since 1.2.0 */\n\tBlocked: \"blocked\",\n\t/** A guard redirected navigation to a different route. @since 1.2.0 */\n\tRedirected: \"redirected\",\n\t/** Navigation was cancelled before settling (superseded, stopped, or destroyed). @since 1.2.0 */\n\tCancelled: \"cancelled\",\n\t/** A guard threw or rejected; the previous route remains active. @since 1.4.0 */\n\tError: \"error\",\n});\n\ntype NavigationOutcome = (typeof NavigationOutcome)[keyof typeof NavigationOutcome];\n\nexport default NavigationOutcome;\n"],"mappings":";;;EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACA,MAAMA,iBAAiB,GAAGC,MAAM,CAACC,MAAM,CAAC;IACvC;IACAC,SAAS,EAAE,WAAW;IACtB;IACAC,QAAQ,EAAE,UAAU;IACpB;IACAC,OAAO,EAAE,SAAS;IAClB;IACAC,UAAU,EAAE,YAAY;IACxB;IACAC,SAAS,EAAE,WAAW;IACtB;IACAC,KAAK,EAAE;EACR,CAAC,CAAC;EAAC,OAIYR,iBAAiB;AAAA","ignoreList":[]}
|
|
@@ -8,19 +8,20 @@ declare module "ui5/guard/router/NavigationOutcome" {
|
|
|
8
8
|
*
|
|
9
9
|
* @enum {string}
|
|
10
10
|
* @namespace ui5.guard.router
|
|
11
|
+
* @since 1.2.0
|
|
11
12
|
*/
|
|
12
13
|
const NavigationOutcome: Readonly<{
|
|
13
|
-
/** Navigation was allowed and the target route activated. */
|
|
14
|
+
/** Navigation was allowed and the target route activated. @since 1.2.0 */
|
|
14
15
|
Committed: "committed";
|
|
15
|
-
/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. */
|
|
16
|
+
/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. @since 1.3.0 */
|
|
16
17
|
Bypassed: "bypassed";
|
|
17
|
-
/** A guard blocked navigation; the previous route remains active. */
|
|
18
|
+
/** A guard blocked navigation; the previous route remains active. @since 1.2.0 */
|
|
18
19
|
Blocked: "blocked";
|
|
19
|
-
/** A guard redirected navigation to a different route. */
|
|
20
|
+
/** A guard redirected navigation to a different route. @since 1.2.0 */
|
|
20
21
|
Redirected: "redirected";
|
|
21
|
-
/** Navigation was cancelled before settling (superseded, stopped, or destroyed). */
|
|
22
|
+
/** Navigation was cancelled before settling (superseded, stopped, or destroyed). @since 1.2.0 */
|
|
22
23
|
Cancelled: "cancelled";
|
|
23
|
-
/** A guard threw or rejected; the previous route remains active. */
|
|
24
|
+
/** A guard threw or rejected; the previous route remains active. @since 1.4.0 */
|
|
24
25
|
Error: "error";
|
|
25
26
|
}>;
|
|
26
27
|
type NavigationOutcome = (typeof NavigationOutcome)[keyof typeof NavigationOutcome];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationOutcome.d.ts","sourceRoot":"../../../../..","sources":["src/NavigationOutcome.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,oCAAoC,CAAC;IACpD
|
|
1
|
+
{"version":3,"file":"NavigationOutcome.d.ts","sourceRoot":"../../../../..","sources":["src/NavigationOutcome.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,oCAAoC,CAAC;IACpD;;;;;;;;;;OAUG;IACH,MAAM,iBAAiB;QACtB,0EAA0E;;QAE1E,uGAAuG;;QAEvG,kFAAkF;;QAElF,uEAAuE;;QAEvE,iGAAiG;;QAEjG,iFAAiF;;MAEhF,CAAC;IAEH,KAAK,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;IAEpF,eAAe,iBAAiB,CAAC;CAEhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationOutcome.js","names":["NavigationOutcome","Object","freeze","Committed","Bypassed","Blocked","Redirected","Cancelled","Error"],"sources":["NavigationOutcome.ts"],"sourcesContent":["/**\n * Outcome of a navigation after the guard pipeline settles.\n *\n * Registered as a UI5 enum via `library.ts` so that it is discoverable\n * through `sap.ui.base.DataType.getType()`. Application code can import\n * the value object directly.\n *\n * @enum {string}\n * @namespace ui5.guard.router\n */\nconst NavigationOutcome = Object.freeze({\n\t/** Navigation was allowed and the target route activated. */\n\tCommitted: \"committed\",\n\t/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. */\n\tBypassed: \"bypassed\",\n\t/** A guard blocked navigation; the previous route remains active. */\n\tBlocked: \"blocked\",\n\t/** A guard redirected navigation to a different route. */\n\tRedirected: \"redirected\",\n\t/** Navigation was cancelled before settling (superseded, stopped, or destroyed). */\n\tCancelled: \"cancelled\",\n\t/** A guard threw or rejected; the previous route remains active. */\n\tError: \"error\",\n});\n\ntype NavigationOutcome = (typeof NavigationOutcome)[keyof typeof NavigationOutcome];\n\nexport default NavigationOutcome;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavigationOutcome.js","names":["NavigationOutcome","Object","freeze","Committed","Bypassed","Blocked","Redirected","Cancelled","Error"],"sources":["NavigationOutcome.ts"],"sourcesContent":["/**\n * Outcome of a navigation after the guard pipeline settles.\n *\n * Registered as a UI5 enum via `library.ts` so that it is discoverable\n * through `sap.ui.base.DataType.getType()`. Application code can import\n * the value object directly.\n *\n * @enum {string}\n * @namespace ui5.guard.router\n * @since 1.2.0\n */\nconst NavigationOutcome = Object.freeze({\n\t/** Navigation was allowed and the target route activated. @since 1.2.0 */\n\tCommitted: \"committed\",\n\t/** Navigation was allowed, but no route matched; UI5 continued with bypassed handling. @since 1.3.0 */\n\tBypassed: \"bypassed\",\n\t/** A guard blocked navigation; the previous route remains active. @since 1.2.0 */\n\tBlocked: \"blocked\",\n\t/** A guard redirected navigation to a different route. @since 1.2.0 */\n\tRedirected: \"redirected\",\n\t/** Navigation was cancelled before settling (superseded, stopped, or destroyed). @since 1.2.0 */\n\tCancelled: \"cancelled\",\n\t/** A guard threw or rejected; the previous route remains active. @since 1.4.0 */\n\tError: \"error\",\n});\n\ntype NavigationOutcome = (typeof NavigationOutcome)[keyof typeof NavigationOutcome];\n\nexport default NavigationOutcome;\n"],"mappings":"yCAWA,MAAMA,EAAoBC,OAAOC,OAAO,CAEvCC,UAAW,YAEXC,SAAU,WAEVC,QAAS,UAETC,WAAY,aAEZC,UAAW,YAEXC,MAAO,UACL,OAIYR,CAAiB","ignoreList":[]}
|