ui5-lib-guard-router 1.6.2 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/{dist/.ui5 → .ui5}/build-manifest.json +56 -8
  2. package/CHANGELOG.md +197 -0
  3. package/README.md +695 -327
  4. package/dist/index.d.ts +9 -5
  5. package/dist/resources/ui5/guard/router/.library +1 -1
  6. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js +222 -0
  7. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js.map +1 -0
  8. package/dist/resources/ui5/guard/router/GuardConfig.d.ts +89 -0
  9. package/dist/resources/ui5/guard/router/GuardConfig.d.ts.map +1 -0
  10. package/dist/resources/ui5/guard/router/GuardConfig.js +2 -0
  11. package/dist/resources/ui5/guard/router/GuardConfig.js.map +1 -0
  12. package/dist/resources/ui5/guard/router/GuardModules-dbg.js +253 -0
  13. package/dist/resources/ui5/guard/router/GuardModules-dbg.js.map +1 -0
  14. package/dist/resources/ui5/guard/router/GuardModules.d.ts +72 -0
  15. package/dist/resources/ui5/guard/router/GuardModules.d.ts.map +1 -0
  16. package/dist/resources/ui5/guard/router/GuardModules.js +2 -0
  17. package/dist/resources/ui5/guard/router/GuardModules.js.map +1 -0
  18. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js +125 -122
  19. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js.map +1 -1
  20. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts +45 -26
  21. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts.map +1 -1
  22. package/dist/resources/ui5/guard/router/GuardPipeline.js +1 -1
  23. package/dist/resources/ui5/guard/router/GuardPipeline.js.map +1 -1
  24. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js +3 -3
  25. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js.map +1 -1
  26. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts +3 -3
  27. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts.map +1 -1
  28. package/dist/resources/ui5/guard/router/NavigationOutcome.js.map +1 -1
  29. package/dist/resources/ui5/guard/router/PatternTree-dbg.js +156 -0
  30. package/dist/resources/ui5/guard/router/PatternTree-dbg.js.map +1 -0
  31. package/dist/resources/ui5/guard/router/PatternTree.d.ts +71 -0
  32. package/dist/resources/ui5/guard/router/PatternTree.d.ts.map +1 -0
  33. package/dist/resources/ui5/guard/router/PatternTree.js +2 -0
  34. package/dist/resources/ui5/guard/router/PatternTree.js.map +1 -0
  35. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js +84 -0
  36. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js.map +1 -0
  37. package/dist/resources/ui5/guard/router/RouteMeta.d.ts +33 -0
  38. package/dist/resources/ui5/guard/router/RouteMeta.d.ts.map +1 -0
  39. package/dist/resources/ui5/guard/router/RouteMeta.js +2 -0
  40. package/dist/resources/ui5/guard/router/RouteMeta.js.map +1 -0
  41. package/dist/resources/ui5/guard/router/Router-dbg.js +900 -1033
  42. package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
  43. package/dist/resources/ui5/guard/router/Router.d.ts +362 -212
  44. package/dist/resources/ui5/guard/router/Router.d.ts.map +1 -1
  45. package/dist/resources/ui5/guard/router/Router.js +1 -1
  46. package/dist/resources/ui5/guard/router/Router.js.map +1 -1
  47. package/dist/resources/ui5/guard/router/library-dbg.js +1 -1
  48. package/dist/resources/ui5/guard/router/library-dbg.js.map +1 -1
  49. package/dist/resources/ui5/guard/router/library-preload.js +8 -4
  50. package/dist/resources/ui5/guard/router/library-preload.js.map +1 -1
  51. package/dist/resources/ui5/guard/router/library.js +1 -1
  52. package/dist/resources/ui5/guard/router/library.js.map +1 -1
  53. package/dist/resources/ui5/guard/router/manifest.json +5 -2
  54. package/dist/resources/ui5/guard/router/types-dbg.js.map +1 -1
  55. package/dist/resources/ui5/guard/router/types.d.ts +94 -39
  56. package/dist/resources/ui5/guard/router/types.d.ts.map +1 -1
  57. package/package.json +10 -6
  58. package/src/GuardConfig.ts +272 -0
  59. package/src/GuardModules.ts +249 -0
  60. package/src/GuardPipeline.ts +158 -129
  61. package/src/NavigationOutcome.ts +3 -3
  62. package/src/PatternTree.ts +145 -0
  63. package/src/RouteMeta.ts +82 -0
  64. package/src/Router.ts +1110 -1150
  65. package/src/manifest.json +5 -2
  66. package/src/types.ts +79 -22
  67. package/tsconfig.json +0 -11
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- // Generated with TypeScript 6.0.2 / OpenUI5 1.144.0 using:
2
- // - typescript@6.0.2
3
- /// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
1
+ // Generated with TypeScript 6.0.3 / OpenUI5 1.144.0 using:
2
+ // - typescript@6.0.3
3
+ /// <reference path="./resources/ui5/guard/router/RouteMeta.d.ts"/>
4
4
  /// <reference path="./resources/ui5/guard/router/library.d.ts"/>
5
5
  /// <reference path="./resources/ui5/guard/router/Router.d.ts"/>
6
- /// <reference path="./resources/ui5/guard/router/types.d.ts"/>
7
- /// <reference path="./resources/ui5/guard/router/NavigationOutcome.d.ts"/>
6
+ /// <reference path="./resources/ui5/guard/router/GuardConfig.d.ts"/>
7
+ /// <reference path="./resources/ui5/guard/router/PatternTree.d.ts"/>
8
+ /// <reference path="./resources/ui5/guard/router/NavigationOutcome.d.ts"/>
9
+ /// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
10
+ /// <reference path="./resources/ui5/guard/router/GuardModules.d.ts"/>
11
+ /// <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.6.2</version>
5
+ <version>1.7.1</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>
@@ -0,0 +1,222 @@
1
+ sap.ui.define(["sap/base/Log", "./GuardPipeline"], function (Log, ___GuardPipeline) {
2
+ "use strict";
3
+
4
+ const LOG_COMPONENT = ___GuardPipeline["LOG_COMPONENT"];
5
+ /** Type guard for plain objects. */
6
+ function isRecord(value) {
7
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
8
+ const proto = Object.getPrototypeOf(value);
9
+ return proto === Object.prototype || proto === null;
10
+ }
11
+
12
+ /** Create a type-narrowing validator for a finite set of string literal values. */
13
+ function isOneOf(...values) {
14
+ const set = new Set(values);
15
+ return v => typeof v === "string" && set.has(v);
16
+ }
17
+ const isUnknownRouteRegistrationPolicy = isOneOf("ignore", "warn", "throw");
18
+ const isNavToPreflightMode = isOneOf("guard", "bypass", "off");
19
+ const isGuardLoading = isOneOf("block", "lazy");
20
+ const isInheritance = isOneOf("none", "pattern-tree");
21
+ const LOG_LEVELS = {
22
+ error: Log.Level.ERROR,
23
+ warning: Log.Level.WARNING,
24
+ info: Log.Level.INFO,
25
+ debug: Log.Level.DEBUG
26
+ };
27
+ const isLogLevel = v => typeof v === "string" && Object.hasOwn(LOG_LEVELS, v);
28
+
29
+ /** Parsed guard declaration from the manifest `guards` block. */
30
+
31
+ /**
32
+ * Resolve a guard module path to a slash-separated AMD module path.
33
+ *
34
+ * Inspired by `sap.ui.core.routing.Target._getEffectiveObjectName()`,
35
+ * which skips namespace prepending for `"module:"`-prefixed paths. This
36
+ * function goes further: it also converts dots to slashes in a single
37
+ * step, so both dot notation (`module:some.lib.guard`) and slash
38
+ * notation (`module:some/lib/guard`) are accepted.
39
+ *
40
+ * - Paths prefixed with `"module:"` are treated as absolute (the prefix
41
+ * is stripped, dots become slashes).
42
+ * - All other paths are prefixed with the component namespace, then dots
43
+ * become slashes.
44
+ */
45
+ function resolveGuardModulePath(dotPath, componentNamespace) {
46
+ if (dotPath.startsWith("module:")) {
47
+ return dotPath.slice("module:".length).replace(/\./g, "/");
48
+ }
49
+ const fullDotPath = componentNamespace ? componentNamespace + "." + dotPath : dotPath;
50
+ return fullDotPath.replace(/\./g, "/");
51
+ }
52
+
53
+ /**
54
+ * Split a manifest guard entry on the first `#` to separate the module path
55
+ * from an optional export key.
56
+ */
57
+ function parseGuardEntry(entry, componentNamespace) {
58
+ const hashIndex = entry.indexOf("#");
59
+ const rawPath = hashIndex === -1 ? entry : entry.slice(0, hashIndex);
60
+ const exportKey = hashIndex === -1 ? undefined : entry.slice(hashIndex + 1);
61
+ return {
62
+ modulePath: resolveGuardModulePath(rawPath, componentNamespace),
63
+ exportKey
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Parse the `guards` block from the guardRouter config into an array of
69
+ * {@link GuardDescriptor} objects.
70
+ *
71
+ * Handles:
72
+ * - `"*"` key with `string[]` -> global enter guards
73
+ * - Route name with `string[]` (shorthand) -> enter guards
74
+ * - Route name with `{ enter: [...], leave: [...] }` -> enter + leave guards
75
+ * - `"*"` with object form -> log info, treat enter as global
76
+ * - `"*"` leave -> warn, skip (global leave guards not supported)
77
+ * - Invalid entries, object values that are not arrays, unknown object keys -> warn, skip
78
+ */
79
+ function parseGuardDescriptors(guards, componentNamespace) {
80
+ if (!isRecord(guards)) {
81
+ Log.warning("guardRouter.guards is not a plain object, skipping", JSON.stringify(guards), LOG_COMPONENT);
82
+ return [];
83
+ }
84
+ const descriptors = [];
85
+ function pushEntries(entries, route, type, label) {
86
+ for (const entry of entries) {
87
+ if (typeof entry !== "string" || entry.length === 0) {
88
+ Log.warning(`guardRouter.guards${label}: invalid entry, skipping`, JSON.stringify(entry), LOG_COMPONENT);
89
+ continue;
90
+ }
91
+ const parsed = parseGuardEntry(entry, componentNamespace);
92
+ descriptors.push({
93
+ route,
94
+ type,
95
+ ...parsed
96
+ });
97
+ }
98
+ }
99
+ for (const [key, value] of Object.entries(guards)) {
100
+ if (Array.isArray(value)) {
101
+ pushEntries(value, key, "enter", `["${key}"]`);
102
+ } else if (isRecord(value)) {
103
+ if (key === "*" && value.leave !== undefined) {
104
+ Log.warning('guardRouter.guards["*"].leave: global leave guards are not supported, skipping', undefined, LOG_COMPONENT);
105
+ }
106
+ for (const name of Object.keys(value)) {
107
+ if (name === "enter" || name === "leave") continue;
108
+ Log.warning(`guardRouter.guards["${key}"].${name}: unknown key, expected enter or leave, skipping`, undefined, LOG_COMPONENT);
109
+ }
110
+ for (const type of ["enter", "leave"]) {
111
+ const entries = value[type];
112
+ if (entries === undefined || key === "*" && type === "leave") continue;
113
+ if (!Array.isArray(entries)) {
114
+ Log.warning(`guardRouter.guards["${key}"].${type}: expected string[], skipping`, JSON.stringify(entries), LOG_COMPONENT);
115
+ continue;
116
+ }
117
+ if (key === "*") {
118
+ Log.info('guardRouter.guards["*"]: object form; treating enter as global', undefined, LOG_COMPONENT);
119
+ }
120
+ pushEntries(entries, key, type, `["${key}"].${type}`);
121
+ }
122
+ } else {
123
+ Log.warning(`guardRouter.guards["${key}"]: expected string[] or { enter?, leave? }, skipping`, JSON.stringify(value), LOG_COMPONENT);
124
+ }
125
+ }
126
+ return descriptors;
127
+ }
128
+ const DEFAULT_OPTIONS = {
129
+ unknownRouteRegistration: "warn",
130
+ navToPreflight: "guard",
131
+ guardLoading: "lazy",
132
+ inheritance: "none"
133
+ };
134
+ function applyOption(raw, key, guard, target) {
135
+ const value = raw[key];
136
+ if (value === undefined) return;
137
+ if (guard(value)) {
138
+ target[key] = value;
139
+ } else {
140
+ Log.warning(`guardRouter.${key} has invalid value, using default`, JSON.stringify(value), LOG_COMPONENT);
141
+ }
142
+ }
143
+
144
+ /** Raise the page-wide level of the router's log component; a more verbose level is kept. */
145
+ function applyLogLevel(value) {
146
+ if (value === undefined) return;
147
+ if (!isLogLevel(value)) {
148
+ // An error, not a warning: the level is not raised, so a warning would be filtered out at the default ERROR level.
149
+ Log.error("guardRouter.logLevel has invalid value, ignoring it", JSON.stringify(value), LOG_COMPONENT);
150
+ return;
151
+ }
152
+ const level = LOG_LEVELS[value];
153
+ if (level > Log.getLevel(LOG_COMPONENT)) Log.setLevel(level, LOG_COMPONENT);
154
+ }
155
+ function normalizeGuardRouterOptions(raw) {
156
+ if (!isRecord(raw)) {
157
+ if (raw !== undefined) {
158
+ Log.warning("guardRouter config is not a plain object, using defaults", JSON.stringify(raw), LOG_COMPONENT);
159
+ }
160
+ return DEFAULT_OPTIONS;
161
+ }
162
+
163
+ // First, so that the warnings about the other options are logged at the new level.
164
+ applyLogLevel(raw.logLevel);
165
+ const result = {
166
+ ...DEFAULT_OPTIONS
167
+ };
168
+ applyOption(raw, "unknownRouteRegistration", isUnknownRouteRegistrationPolicy, result);
169
+ applyOption(raw, "navToPreflight", isNavToPreflightMode, result);
170
+ applyOption(raw, "guardLoading", isGuardLoading, result);
171
+ applyOption(raw, "inheritance", isInheritance, result);
172
+ return result;
173
+ }
174
+
175
+ /** Parse the `routeMeta` block: one frozen plain object per route name. */
176
+ function parseRouteMeta(raw) {
177
+ const routeMeta = new Map();
178
+ if (raw === undefined) return routeMeta;
179
+ if (!isRecord(raw)) {
180
+ Log.warning("guardRouter.routeMeta: expected object, skipping", JSON.stringify(raw), LOG_COMPONENT);
181
+ return routeMeta;
182
+ }
183
+ for (const [routeName, meta] of Object.entries(raw)) {
184
+ if (isRecord(meta)) {
185
+ routeMeta.set(routeName, Object.freeze({
186
+ ...meta
187
+ }));
188
+ } else {
189
+ Log.warning(`guardRouter.routeMeta["${routeName}"]: expected object, skipping`, JSON.stringify(meta), LOG_COMPONENT);
190
+ }
191
+ }
192
+ return routeMeta;
193
+ }
194
+
195
+ /** The `guardRouter` config block, validated. Invalid parts are warned about and dropped. */
196
+
197
+ /**
198
+ * Parse the `guardRouter` config block: options, `routeMeta` and the manifest `guards`.
199
+ * Guard module paths are resolved against `componentNamespace` (the owner's `sap.app/id`).
200
+ * Side effect: a valid `logLevel` raises the page-wide level of the router's log component.
201
+ */
202
+ function parseGuardRouterConfig(raw, componentNamespace) {
203
+ const options = normalizeGuardRouterOptions(raw);
204
+ if (!isRecord(raw)) return {
205
+ options,
206
+ routeMeta: new Map(),
207
+ guards: []
208
+ };
209
+ return {
210
+ options,
211
+ routeMeta: parseRouteMeta(raw.routeMeta),
212
+ guards: raw.guards === undefined ? [] : parseGuardDescriptors(raw.guards, componentNamespace)
213
+ };
214
+ }
215
+ var __exports = {
216
+ __esModule: true
217
+ };
218
+ __exports.isRecord = isRecord;
219
+ __exports.parseGuardRouterConfig = parseGuardRouterConfig;
220
+ return __exports;
221
+ });
222
+ //# sourceMappingURL=GuardConfig-dbg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardConfig-dbg.js","names":["LOG_COMPONENT","___GuardPipeline","isRecord","value","Array","isArray","proto","Object","getPrototypeOf","prototype","isOneOf","values","set","Set","v","has","isUnknownRouteRegistrationPolicy","isNavToPreflightMode","isGuardLoading","isInheritance","LOG_LEVELS","error","Log","Level","ERROR","warning","WARNING","info","INFO","debug","DEBUG","isLogLevel","hasOwn","resolveGuardModulePath","dotPath","componentNamespace","startsWith","slice","length","replace","fullDotPath","parseGuardEntry","entry","hashIndex","indexOf","rawPath","exportKey","undefined","modulePath","parseGuardDescriptors","guards","JSON","stringify","descriptors","pushEntries","entries","route","type","label","parsed","push","key","leave","name","keys","DEFAULT_OPTIONS","unknownRouteRegistration","navToPreflight","guardLoading","inheritance","applyOption","raw","guard","target","applyLogLevel","level","getLevel","setLevel","normalizeGuardRouterOptions","logLevel","result","parseRouteMeta","routeMeta","Map","routeName","meta","freeze","parseGuardRouterConfig","options","__exports","__esModule"],"sourceRoot":"./","sources":["GuardConfig.ts"],"sourcesContent":["/**\n * Parsing and validation of the `guardRouter` config block.\n */\nimport Log from \"sap/base/Log\";\nimport type {\n\tGuardLoading,\n\tGuardRouterLogLevel,\n\tInheritance,\n\tNavToPreflightMode,\n\tUnknownRouteRegistrationPolicy,\n} from \"./types\";\nimport { LOG_COMPONENT } from \"./GuardPipeline\";\n\n/** Type guard for plain objects. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\tconst proto: unknown = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\n\n/** Create a type-narrowing validator for a finite set of string literal values. */\nfunction isOneOf<T extends string>(...values: T[]): (v: unknown) => v is T {\n\tconst set: ReadonlySet<string> = new Set(values);\n\treturn (v: unknown): v is T => typeof v === \"string\" && set.has(v);\n}\n\nconst isUnknownRouteRegistrationPolicy = isOneOf<UnknownRouteRegistrationPolicy>(\"ignore\", \"warn\", \"throw\");\nconst isNavToPreflightMode = isOneOf<NavToPreflightMode>(\"guard\", \"bypass\", \"off\");\nconst isGuardLoading = isOneOf<GuardLoading>(\"block\", \"lazy\");\nconst isInheritance = isOneOf<Inheritance>(\"none\", \"pattern-tree\");\n\nconst LOG_LEVELS = {\n\terror: Log.Level.ERROR,\n\twarning: Log.Level.WARNING,\n\tinfo: Log.Level.INFO,\n\tdebug: Log.Level.DEBUG,\n} satisfies Record<GuardRouterLogLevel, unknown>;\n\nconst isLogLevel = (v: unknown): v is GuardRouterLogLevel => typeof v === \"string\" && Object.hasOwn(LOG_LEVELS, v);\n\n/** Parsed guard declaration from the manifest `guards` block. */\nexport interface GuardDescriptor {\n\treadonly route: string; // \"*\" for global, route name for per-route\n\treadonly type: \"enter\" | \"leave\";\n\treadonly modulePath: string;\n\treadonly exportKey?: string;\n}\n\n/**\n * Resolve a guard module path to a slash-separated AMD module path.\n *\n * Inspired by `sap.ui.core.routing.Target._getEffectiveObjectName()`,\n * which skips namespace prepending for `\"module:\"`-prefixed paths. This\n * function goes further: it also converts dots to slashes in a single\n * step, so both dot notation (`module:some.lib.guard`) and slash\n * notation (`module:some/lib/guard`) are accepted.\n *\n * - Paths prefixed with `\"module:\"` are treated as absolute (the prefix\n * is stripped, dots become slashes).\n * - All other paths are prefixed with the component namespace, then dots\n * become slashes.\n */\nfunction resolveGuardModulePath(dotPath: string, componentNamespace: string): string {\n\tif (dotPath.startsWith(\"module:\")) {\n\t\treturn dotPath.slice(\"module:\".length).replace(/\\./g, \"/\");\n\t}\n\tconst fullDotPath = componentNamespace ? componentNamespace + \".\" + dotPath : dotPath;\n\treturn fullDotPath.replace(/\\./g, \"/\");\n}\n\n/**\n * Split a manifest guard entry on the first `#` to separate the module path\n * from an optional export key.\n */\nfunction parseGuardEntry(entry: string, componentNamespace: string): { modulePath: string; exportKey?: string } {\n\tconst hashIndex = entry.indexOf(\"#\");\n\tconst rawPath = hashIndex === -1 ? entry : entry.slice(0, hashIndex);\n\tconst exportKey = hashIndex === -1 ? undefined : entry.slice(hashIndex + 1);\n\n\treturn { modulePath: resolveGuardModulePath(rawPath, componentNamespace), exportKey };\n}\n\n/**\n * Parse the `guards` block from the guardRouter config into an array of\n * {@link GuardDescriptor} objects.\n *\n * Handles:\n * - `\"*\"` key with `string[]` -> global enter guards\n * - Route name with `string[]` (shorthand) -> enter guards\n * - Route name with `{ enter: [...], leave: [...] }` -> enter + leave guards\n * - `\"*\"` with object form -> log info, treat enter as global\n * - `\"*\"` leave -> warn, skip (global leave guards not supported)\n * - Invalid entries, object values that are not arrays, unknown object keys -> warn, skip\n */\nfunction parseGuardDescriptors(guards: unknown, componentNamespace: string): GuardDescriptor[] {\n\tif (!isRecord(guards)) {\n\t\tLog.warning(\"guardRouter.guards is not a plain object, skipping\", JSON.stringify(guards), LOG_COMPONENT);\n\t\treturn [];\n\t}\n\n\tconst descriptors: GuardDescriptor[] = [];\n\n\tfunction pushEntries(entries: unknown[], route: string, type: \"enter\" | \"leave\", label: string): void {\n\t\tfor (const entry of entries) {\n\t\t\tif (typeof entry !== \"string\" || entry.length === 0) {\n\t\t\t\tLog.warning(\n\t\t\t\t\t`guardRouter.guards${label}: invalid entry, skipping`,\n\t\t\t\t\tJSON.stringify(entry),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst parsed = parseGuardEntry(entry, componentNamespace);\n\t\t\tdescriptors.push({ route, type, ...parsed });\n\t\t}\n\t}\n\n\tfor (const [key, value] of Object.entries(guards)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tpushEntries(value, key, \"enter\", `[\"${key}\"]`);\n\t\t} else if (isRecord(value)) {\n\t\t\tif (key === \"*\" && value.leave !== undefined) {\n\t\t\t\tLog.warning(\n\t\t\t\t\t'guardRouter.guards[\"*\"].leave: global leave guards are not supported, skipping',\n\t\t\t\t\tundefined,\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const name of Object.keys(value)) {\n\t\t\t\tif (name === \"enter\" || name === \"leave\") continue;\n\t\t\t\tLog.warning(\n\t\t\t\t\t`guardRouter.guards[\"${key}\"].${name}: unknown key, expected enter or leave, skipping`,\n\t\t\t\t\tundefined,\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const type of [\"enter\", \"leave\"] as const) {\n\t\t\t\tconst entries = value[type];\n\t\t\t\tif (entries === undefined || (key === \"*\" && type === \"leave\")) continue;\n\t\t\t\tif (!Array.isArray(entries)) {\n\t\t\t\t\tLog.warning(\n\t\t\t\t\t\t`guardRouter.guards[\"${key}\"].${type}: expected string[], skipping`,\n\t\t\t\t\t\tJSON.stringify(entries),\n\t\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (key === \"*\") {\n\t\t\t\t\tLog.info(\n\t\t\t\t\t\t'guardRouter.guards[\"*\"]: object form; treating enter as global',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tpushEntries(entries, key, type, `[\"${key}\"].${type}`);\n\t\t\t}\n\t\t} else {\n\t\t\tLog.warning(\n\t\t\t\t`guardRouter.guards[\"${key}\"]: expected string[] or { enter?, leave? }, skipping`,\n\t\t\t\tJSON.stringify(value),\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn descriptors;\n}\n\nexport interface ResolvedGuardRouterOptions {\n\treadonly unknownRouteRegistration: UnknownRouteRegistrationPolicy;\n\treadonly navToPreflight: NavToPreflightMode;\n\treadonly guardLoading: GuardLoading;\n\treadonly inheritance: Inheritance;\n}\n\nconst DEFAULT_OPTIONS: ResolvedGuardRouterOptions = {\n\tunknownRouteRegistration: \"warn\",\n\tnavToPreflight: \"guard\",\n\tguardLoading: \"lazy\",\n\tinheritance: \"none\",\n};\n\nfunction applyOption<K extends keyof ResolvedGuardRouterOptions>(\n\traw: Record<string, unknown>,\n\tkey: K,\n\tguard: (v: unknown) => v is ResolvedGuardRouterOptions[K],\n\ttarget: { -readonly [P in keyof ResolvedGuardRouterOptions]: ResolvedGuardRouterOptions[P] },\n): void {\n\tconst value = raw[key];\n\tif (value === undefined) return;\n\tif (guard(value)) {\n\t\ttarget[key] = value;\n\t} else {\n\t\tLog.warning(`guardRouter.${key} has invalid value, using default`, JSON.stringify(value), LOG_COMPONENT);\n\t}\n}\n\n/** Raise the page-wide level of the router's log component; a more verbose level is kept. */\nfunction applyLogLevel(value: unknown): void {\n\tif (value === undefined) return;\n\tif (!isLogLevel(value)) {\n\t\t// An error, not a warning: the level is not raised, so a warning would be filtered out at the default ERROR level.\n\t\tLog.error(\"guardRouter.logLevel has invalid value, ignoring it\", JSON.stringify(value), LOG_COMPONENT);\n\t\treturn;\n\t}\n\tconst level = LOG_LEVELS[value];\n\tif (level > Log.getLevel(LOG_COMPONENT)) Log.setLevel(level, LOG_COMPONENT);\n}\n\nfunction normalizeGuardRouterOptions(raw: unknown): ResolvedGuardRouterOptions {\n\tif (!isRecord(raw)) {\n\t\tif (raw !== undefined) {\n\t\t\tLog.warning(\"guardRouter config is not a plain object, using defaults\", JSON.stringify(raw), LOG_COMPONENT);\n\t\t}\n\t\treturn DEFAULT_OPTIONS;\n\t}\n\n\t// First, so that the warnings about the other options are logged at the new level.\n\tapplyLogLevel(raw.logLevel);\n\tconst result = { ...DEFAULT_OPTIONS };\n\tapplyOption(raw, \"unknownRouteRegistration\", isUnknownRouteRegistrationPolicy, result);\n\tapplyOption(raw, \"navToPreflight\", isNavToPreflightMode, result);\n\tapplyOption(raw, \"guardLoading\", isGuardLoading, result);\n\tapplyOption(raw, \"inheritance\", isInheritance, result);\n\treturn result;\n}\n\n/** Parse the `routeMeta` block: one frozen plain object per route name. */\nfunction parseRouteMeta(raw: unknown): Map<string, Readonly<Record<string, unknown>>> {\n\tconst routeMeta = new Map<string, Readonly<Record<string, unknown>>>();\n\tif (raw === undefined) return routeMeta;\n\tif (!isRecord(raw)) {\n\t\tLog.warning(\"guardRouter.routeMeta: expected object, skipping\", JSON.stringify(raw), LOG_COMPONENT);\n\t\treturn routeMeta;\n\t}\n\tfor (const [routeName, meta] of Object.entries(raw)) {\n\t\tif (isRecord(meta)) {\n\t\t\trouteMeta.set(routeName, Object.freeze({ ...meta }));\n\t\t} else {\n\t\t\tLog.warning(\n\t\t\t\t`guardRouter.routeMeta[\"${routeName}\"]: expected object, skipping`,\n\t\t\t\tJSON.stringify(meta),\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t}\n\treturn routeMeta;\n}\n\n/** The `guardRouter` config block, validated. Invalid parts are warned about and dropped. */\ninterface ParsedGuardRouterConfig {\n\treadonly options: ResolvedGuardRouterOptions;\n\treadonly routeMeta: Map<string, Readonly<Record<string, unknown>>>;\n\treadonly guards: GuardDescriptor[];\n}\n\n/**\n * Parse the `guardRouter` config block: options, `routeMeta` and the manifest `guards`.\n * Guard module paths are resolved against `componentNamespace` (the owner's `sap.app/id`).\n * Side effect: a valid `logLevel` raises the page-wide level of the router's log component.\n */\nexport function parseGuardRouterConfig(raw: unknown, componentNamespace: string): ParsedGuardRouterConfig {\n\tconst options = normalizeGuardRouterOptions(raw);\n\tif (!isRecord(raw)) return { options, routeMeta: new Map(), guards: [] };\n\treturn {\n\t\toptions,\n\t\trouteMeta: parseRouteMeta(raw.routeMeta),\n\t\tguards: raw.guards === undefined ? [] : parseGuardDescriptors(raw.guards, componentNamespace),\n\t};\n}\n"],"mappings":";;;QAWSA,aAAa,GAAAC,gBAAA;EAEtB;EACO,SAASC,QAAQA,CAACC,KAAc,EAAoC;IAC1E,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE,OAAO,KAAK;IACrF,MAAMG,KAAc,GAAGC,MAAM,CAACC,cAAc,CAACL,KAAK,CAAC;IACnD,OAAOG,KAAK,KAAKC,MAAM,CAACE,SAAS,IAAIH,KAAK,KAAK,IAAI;EACpD;;EAEA;EACA,SAASI,OAAOA,CAAmB,GAAGC,MAAW,EAA0B;IAC1E,MAAMC,GAAwB,GAAG,IAAIC,GAAG,CAACF,MAAM,CAAC;IAChD,OAAQG,CAAU,IAAa,OAAOA,CAAC,KAAK,QAAQ,IAAIF,GAAG,CAACG,GAAG,CAACD,CAAC,CAAC;EACnE;EAEA,MAAME,gCAAgC,GAAGN,OAAO,CAAiC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;EAC3G,MAAMO,oBAAoB,GAAGP,OAAO,CAAqB,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC;EAClF,MAAMQ,cAAc,GAAGR,OAAO,CAAe,OAAO,EAAE,MAAM,CAAC;EAC7D,MAAMS,aAAa,GAAGT,OAAO,CAAc,MAAM,EAAE,cAAc,CAAC;EAElE,MAAMU,UAAU,GAAG;IAClBC,KAAK,EAAEC,GAAG,CAACC,KAAK,CAACC,KAAK;IACtBC,OAAO,EAAEH,GAAG,CAACC,KAAK,CAACG,OAAO;IAC1BC,IAAI,EAAEL,GAAG,CAACC,KAAK,CAACK,IAAI;IACpBC,KAAK,EAAEP,GAAG,CAACC,KAAK,CAACO;EAClB,CAAgD;EAEhD,MAAMC,UAAU,GAAIjB,CAAU,IAA+B,OAAOA,CA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,OAAO;MACPN,SAAS,EAAED,cAAc,CAACV,GAAG,CAACW,SAAS,CAAC;MACxChC,MAAM,EAAEqB,GAAG,CAACrB,MAAM,KAAKH,SAAS,GAAG,EAAE,GAAGE,qBAAqB,CAACsB,GAAG,CAACrB,MAAM,EAAEf,kBAAkB;IAC7F,CAAC;EACF;EAAC,IAAAsD,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAvF,QAAA,GAAAA,QAAA;EAAAuF,SAAA,CAAAF,sBAAA,GAAAA,sBAAA;EAAA,OAAAE,SAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,89 @@
1
+ declare module "ui5/guard/router/GuardConfig" {
2
+ import type { GuardLoading, GuardRouterLogLevel, Inheritance, NavToPreflightMode, UnknownRouteRegistrationPolicy } from "ui5/guard/router/types";
3
+ /** Type guard for plain objects. */
4
+ export function isRecord(value: unknown): value is Record<string, unknown>;
5
+ /** Create a type-narrowing validator for a finite set of string literal values. */
6
+ function isOneOf<T extends string>(...values: T[]): (v: unknown) => v is T;
7
+ const isUnknownRouteRegistrationPolicy: (v: unknown) => v is UnknownRouteRegistrationPolicy;
8
+ const isNavToPreflightMode: (v: unknown) => v is NavToPreflightMode;
9
+ const isGuardLoading: (v: unknown) => v is GuardLoading;
10
+ const isInheritance: (v: unknown) => v is Inheritance;
11
+ const LOG_LEVELS: {
12
+ error: any;
13
+ warning: any;
14
+ info: any;
15
+ debug: any;
16
+ };
17
+ const isLogLevel: (v: unknown) => v is GuardRouterLogLevel;
18
+ /** Parsed guard declaration from the manifest `guards` block. */
19
+ export interface GuardDescriptor {
20
+ readonly route: string;
21
+ readonly type: "enter" | "leave";
22
+ readonly modulePath: string;
23
+ readonly exportKey?: string;
24
+ }
25
+ /**
26
+ * Resolve a guard module path to a slash-separated AMD module path.
27
+ *
28
+ * Inspired by `sap.ui.core.routing.Target._getEffectiveObjectName()`,
29
+ * which skips namespace prepending for `"module:"`-prefixed paths. This
30
+ * function goes further: it also converts dots to slashes in a single
31
+ * step, so both dot notation (`module:some.lib.guard`) and slash
32
+ * notation (`module:some/lib/guard`) are accepted.
33
+ *
34
+ * - Paths prefixed with `"module:"` are treated as absolute (the prefix
35
+ * is stripped, dots become slashes).
36
+ * - All other paths are prefixed with the component namespace, then dots
37
+ * become slashes.
38
+ */
39
+ function resolveGuardModulePath(dotPath: string, componentNamespace: string): string;
40
+ /**
41
+ * Split a manifest guard entry on the first `#` to separate the module path
42
+ * from an optional export key.
43
+ */
44
+ function parseGuardEntry(entry: string, componentNamespace: string): {
45
+ modulePath: string;
46
+ exportKey?: string;
47
+ };
48
+ /**
49
+ * Parse the `guards` block from the guardRouter config into an array of
50
+ * {@link GuardDescriptor} objects.
51
+ *
52
+ * Handles:
53
+ * - `"*"` key with `string[]` -> global enter guards
54
+ * - Route name with `string[]` (shorthand) -> enter guards
55
+ * - Route name with `{ enter: [...], leave: [...] }` -> enter + leave guards
56
+ * - `"*"` with object form -> log info, treat enter as global
57
+ * - `"*"` leave -> warn, skip (global leave guards not supported)
58
+ * - Invalid entries, object values that are not arrays, unknown object keys -> warn, skip
59
+ */
60
+ function parseGuardDescriptors(guards: unknown, componentNamespace: string): GuardDescriptor[];
61
+ export interface ResolvedGuardRouterOptions {
62
+ readonly unknownRouteRegistration: UnknownRouteRegistrationPolicy;
63
+ readonly navToPreflight: NavToPreflightMode;
64
+ readonly guardLoading: GuardLoading;
65
+ readonly inheritance: Inheritance;
66
+ }
67
+ const DEFAULT_OPTIONS: ResolvedGuardRouterOptions;
68
+ function applyOption<K extends keyof ResolvedGuardRouterOptions>(raw: Record<string, unknown>, key: K, guard: (v: unknown) => v is ResolvedGuardRouterOptions[K], target: {
69
+ -readonly [P in keyof ResolvedGuardRouterOptions]: ResolvedGuardRouterOptions[P];
70
+ }): void;
71
+ /** Raise the page-wide level of the router's log component; a more verbose level is kept. */
72
+ function applyLogLevel(value: unknown): void;
73
+ function normalizeGuardRouterOptions(raw: unknown): ResolvedGuardRouterOptions;
74
+ /** Parse the `routeMeta` block: one frozen plain object per route name. */
75
+ function parseRouteMeta(raw: unknown): Map<string, Readonly<Record<string, unknown>>>;
76
+ /** The `guardRouter` config block, validated. Invalid parts are warned about and dropped. */
77
+ interface ParsedGuardRouterConfig {
78
+ readonly options: ResolvedGuardRouterOptions;
79
+ readonly routeMeta: Map<string, Readonly<Record<string, unknown>>>;
80
+ readonly guards: GuardDescriptor[];
81
+ }
82
+ /**
83
+ * Parse the `guardRouter` config block: options, `routeMeta` and the manifest `guards`.
84
+ * Guard module paths are resolved against `componentNamespace` (the owner's `sap.app/id`).
85
+ * Side effect: a valid `logLevel` raises the page-wide level of the router's log component.
86
+ */
87
+ export function parseGuardRouterConfig(raw: unknown, componentNamespace: string): ParsedGuardRouterConfig;
88
+ }
89
+ //# sourceMappingURL=GuardConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardConfig.d.ts","sourceRoot":"../../../../..","sources":["src/GuardConfig.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,8BAA8B,CAAC;IAK9C,OAAO,KAAK,EACX,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,8BAA8B,EAC9B,MAAM,wBAAwB,CAAC;IAGhC,oCAAoC;IACpC,SAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzE;IAED,mFAAmF;IACnF,SAAS,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAGzE;IAED,MAAM,gCAAgC,MALkB,OAAO,KAAK,CAAC,kCAKsC,CAAC;IAC5G,MAAM,oBAAoB,MAN8B,OAAO,KAAK,CAAC,sBAMa,CAAC;IACnF,MAAM,cAAc,MAPoC,OAAO,KAAK,CAAC,gBAOR,CAAC;IAC9D,MAAM,aAAa,MARqC,OAAO,K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D,MAAM,EAAE;QAAE,CAAC,UAAU,CAAC,IAAI,MAAM,0BAA0B,GAAG,0BAA0B,CAAC,CAAC,CAAC;KAAE,GAC1F,IAAI,CAQN;IAED,6FAA6F;IAC7F,SAAS,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAS3C;IAED,SAAS,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,0BAA0B,CAgB7E;IAED,2EAA2E;IAC3E,SAAS,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAmBpF;IAED,6FAA6F;IAC7F,UAAU,uBAAuB;QAChC,QAAQ,CAAC,OAAO,EAAE,0BAA0B,CAAC;QAC7C,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACnE,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;KACnC;IAED;;;;OAIG;IACH,SAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,uBAAuB,CAQxG;CAEA"}
@@ -0,0 +1,2 @@
1
+ sap.ui.define(["sap/base/Log","./GuardPipeline"],function(e,n){"use strict";const t=n["LOG_COMPONENT"];function r(e){if(typeof e!=="object"||e===null||Array.isArray(e))return false;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function i(...e){const n=new Set(e);return e=>typeof e==="string"&&n.has(e)}const o=i("ignore","warn","throw");const u=i("guard","bypass","off");const a=i("block","lazy");const s=i("none","pattern-tree");const g={error:e.Level.ERROR,warning:e.Level.WARNING,info:e.Level.INFO,debug:e.Level.DEBUG};const f=e=>typeof e==="string"&&Object.hasOwn(g,e);function d(e,n){if(e.startsWith("module:")){return e.slice("module:".length).replace(/\./g,"/")}const t=n?n+"."+e:e;return t.replace(/\./g,"/")}function c(e,n){const t=e.indexOf("#");const r=t===-1?e:e.slice(0,t);const i=t===-1?undefined:e.slice(t+1);return{modulePath:d(r,n),exportKey:i}}function l(n,i){if(!r(n)){e.warning("guardRouter.guards is not a plain object, skipping",JSON.stringify(n),t);return[]}const o=[];function u(n,r,u,a){for(const s of n){if(typeof s!=="string"||s.length===0){e.warning(`guardRouter.guards${a}: invalid entry, skipping`,JSON.stringify(s),t);continue}const n=c(s,i);o.push({route:r,type:u,...n})}}for(const[i,o]of Object.entries(n)){if(Array.isArray(o)){u(o,i,"enter",`["${i}"]`)}else if(r(o)){if(i==="*"&&o.leave!==undefined){e.warning('guardRouter.guards["*"].leave: global leave guards are not supported, skipping',undefined,t)}for(const n of Object.keys(o)){if(n==="enter"||n==="leave")continue;e.warning(`guardRouter.guards["${i}"].${n}: unknown key, expected enter or leave, skipping`,undefined,t)}for(const n of["enter","leave"]){const r=o[n];if(r===undefined||i==="*"&&n==="leave")continue;if(!Array.isArray(r)){e.warning(`guardRouter.guards["${i}"].${n}: expected string[], skipping`,JSON.stringify(r),t);continue}if(i==="*"){e.info('guardRouter.guards["*"]: object form; treating enter as global',undefined,t)}u(r,i,n,`["${i}"].${n}`)}}else{e.warning(`guardRouter.guards["${i}"]: expected string[] or { enter?, leave? }, skipping`,JSON.stringify(o),t)}}return o}const p={unknownRouteRegistration:"warn",navToPreflight:"guard",guardLoading:"lazy",inheritance:"none"};function y(n,r,i,o){const u=n[r];if(u===undefined)return;if(i(u)){o[r]=u}else{e.warning(`guardRouter.${r} has invalid value, using default`,JSON.stringify(u),t)}}function v(n){if(n===undefined)return;if(!f(n)){e.error("guardRouter.logLevel has invalid value, ignoring it",JSON.stringify(n),t);return}const r=g[n];if(r>e.getLevel(t))e.setLevel(r,t)}function O(n){if(!r(n)){if(n!==undefined){e.warning("guardRouter config is not a plain object, using defaults",JSON.stringify(n),t)}return p}v(n.logLevel);const i={...p};y(n,"unknownRouteRegistration",o,i);y(n,"navToPreflight",u,i);y(n,"guardLoading",a,i);y(n,"inheritance",s,i);return i}function R(n){const i=new Map;if(n===undefined)return i;if(!r(n)){e.warning("guardRouter.routeMeta: expected object, skipping",JSON.stringify(n),t);return i}for(const[o,u]of Object.entries(n)){if(r(u)){i.set(o,Object.freeze({...u}))}else{e.warning(`guardRouter.routeMeta["${o}"]: expected object, skipping`,JSON.stringify(u),t)}}return i}function w(e,n){const t=O(e);if(!r(e))return{options:t,routeMeta:new Map,guards:[]};return{options:t,routeMeta:R(e.routeMeta),guards:e.guards===undefined?[]:l(e.guards,n)}}var b={__esModule:true};b.isRecord=r;b.parseGuardRouterConfig=w;return b});
2
+ //# sourceMappingURL=GuardConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardConfig.js","names":["LOG_COMPONENT","___GuardPipeline","isRecord","value","Array","isArray","proto","Object","getPrototypeOf","prototype","isOneOf","values","set","Set","v","has","isUnknownRouteRegistrationPolicy","isNavToPreflightMode","isGuardLoading","isInheritance","LOG_LEVELS","error","Log","Level","ERROR","warning","WARNING","info","INFO","debug","DEBUG","isLogLevel","hasOwn","resolveGuardModulePath","dotPath","componentNamespace","startsWith","slice","length","replace","fullDotPath","parseGuardEntry","entry","hashIndex","indexOf","rawPath","exportKey","undefined","modulePath","parseGuardDescriptors","guards","JSON","stringify","descriptors","pushEntries","entries","route","type","label","parsed","push","key","leave","name","keys","DEFAULT_OPTIONS","unknownRouteRegistration","navToPreflight","guardLoading","inheritance","applyOption","raw","guard","target","applyLogLevel","level","getLevel","setLevel","normalizeGuardRouterOptions","logLevel","result","parseRouteMeta","routeMeta","Map","routeName","meta","freeze","parseGuardRouterConfig","options","__exports","__esModule"],"sources":["./GuardConfig.ts"],"sourcesContent":["/**\n * Parsing and validation of the `guardRouter` config block.\n */\nimport Log from \"sap/base/Log\";\nimport type {\n\tGuardLoading,\n\tGuardRouterLogLevel,\n\tInheritance,\n\tNavToPreflightMode,\n\tUnknownRouteRegistrationPolicy,\n} from \"./types\";\nimport { LOG_COMPONENT } from \"./GuardPipeline\";\n\n/** Type guard for plain objects. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\tconst proto: unknown = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\n\n/** Create a type-narrowing validator for a finite set of string literal values. */\nfunction isOneOf<T extends string>(...values: T[]): (v: unknown) => v is T {\n\tconst set: ReadonlySet<string> = new Set(values);\n\treturn (v: unknown): v is T => typeof v === \"string\" && set.has(v);\n}\n\nconst isUnknownRouteRegistrationPolicy = isOneOf<UnknownRouteRegistrationPolicy>(\"ignore\", \"warn\", \"throw\");\nconst isNavToPreflightMode = isOneOf<NavToPreflightMode>(\"guard\", \"bypass\", \"off\");\nconst isGuardLoading = isOneOf<GuardLoading>(\"block\", \"lazy\");\nconst isInheritance = isOneOf<Inheritance>(\"none\", \"pattern-tree\");\n\nconst LOG_LEVELS = {\n\terror: Log.Level.ERROR,\n\twarning: Log.Level.WARNING,\n\tinfo: Log.Level.INFO,\n\tdebug: Log.Level.DEBUG,\n} satisfies Record<GuardRouterLogLevel, unknown>;\n\nconst isLogLevel = (v: unknown): v is GuardRouterLogLevel => typeof v === \"string\" && Object.hasOwn(LOG_LEVELS, v);\n\n/** Parsed guard declaration from the manifest `guards` block. */\nexport interface GuardDescriptor {\n\treadonly route: string; // \"*\" for global, route name for per-route\n\treadonly type: \"enter\" | \"leave\";\n\treadonly modulePath: string;\n\treadonly exportKey?: string;\n}\n\n/**\n * Resolve a guard module path to a slash-separated AMD module path.\n *\n * Inspired by `sap.ui.core.routing.Target._getEffectiveObjectName()`,\n * which skips namespace prepending for `\"module:\"`-prefixed paths. This\n * function goes further: it also converts dots to slashes in a single\n * step, so both dot notation (`module:some.lib.guard`) and slash\n * notation (`module:some/lib/guard`) are accepted.\n *\n * - Paths prefixed with `\"module:\"` are treated as absolute (the prefix\n * is stripped, dots become slashes).\n * - All other paths are prefixed with the component namespace, then dots\n * become slashes.\n */\nfunction resolveGuardModulePath(dotPath: string, componentNamespace: string): string {\n\tif (dotPath.startsWith(\"module:\")) {\n\t\treturn dotPath.slice(\"module:\".length).replace(/\\./g, \"/\");\n\t}\n\tconst fullDotPath = componentNamespace ? componentNamespace + \".\" + dotPath : dotPath;\n\treturn fullDotPath.replace(/\\./g, \"/\");\n}\n\n/**\n * Split a manifest guard entry on the first `#` to separate the module path\n * from an optional export key.\n */\nfunction parseGuardEntry(entry: string, componentNamespace: string): { modulePath: string; exportKey?: string } {\n\tconst hashIndex = entry.indexOf(\"#\");\n\tconst rawPath = hashIndex === -1 ? entry : entry.slice(0, hashIndex);\n\tconst exportKey = hashIndex === -1 ? undefined : entry.slice(hashIndex + 1);\n\n\treturn { modulePath: resolveGuardModulePath(rawPath, componentNamespace), exportKey };\n}\n\n/**\n * Parse the `guards` block from the guardRouter config into an array of\n * {@link GuardDescriptor} objects.\n *\n * Handles:\n * - `\"*\"` key with `string[]` -> global enter guards\n * - Route name with `string[]` (shorthand) -> enter guards\n * - Route name with `{ enter: [...], leave: [...] }` -> enter + leave guards\n * - `\"*\"` with object form -> log info, treat enter as global\n * - `\"*\"` leave -> warn, skip (global leave guards not supported)\n * - Invalid entries, object values that are not arrays, unknown object keys -> warn, skip\n */\nfunction parseGuardDescriptors(guards: unknown, componentNamespace: string): GuardDescriptor[] {\n\tif (!isRecord(guards)) {\n\t\tLog.warning(\"guardRouter.guards is not a plain object, skipping\", JSON.stringify(guards), LOG_COMPONENT);\n\t\treturn [];\n\t}\n\n\tconst descriptors: GuardDescriptor[] = [];\n\n\tfunction pushEntries(entries: unknown[], route: string, type: \"enter\" | \"leave\", label: string): void {\n\t\tfor (const entry of entries) {\n\t\t\tif (typeof entry !== \"string\" || entry.length === 0) {\n\t\t\t\tLog.warning(\n\t\t\t\t\t`guardRouter.guards${label}: invalid entry, skipping`,\n\t\t\t\t\tJSON.stringify(entry),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst parsed = parseGuardEntry(entry, componentNamespace);\n\t\t\tdescriptors.push({ route, type, ...parsed });\n\t\t}\n\t}\n\n\tfor (const [key, value] of Object.entries(guards)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tpushEntries(value, key, \"enter\", `[\"${key}\"]`);\n\t\t} else if (isRecord(value)) {\n\t\t\tif (key === \"*\" && value.leave !== undefined) {\n\t\t\t\tLog.warning(\n\t\t\t\t\t'guardRouter.guards[\"*\"].leave: global leave guards are not supported, skipping',\n\t\t\t\t\tundefined,\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const name of Object.keys(value)) {\n\t\t\t\tif (name === \"enter\" || name === \"leave\") continue;\n\t\t\t\tLog.warning(\n\t\t\t\t\t`guardRouter.guards[\"${key}\"].${name}: unknown key, expected enter or leave, skipping`,\n\t\t\t\t\tundefined,\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfor (const type of [\"enter\", \"leave\"] as const) {\n\t\t\t\tconst entries = value[type];\n\t\t\t\tif (entries === undefined || (key === \"*\" && type === \"leave\")) continue;\n\t\t\t\tif (!Array.isArray(entries)) {\n\t\t\t\t\tLog.warning(\n\t\t\t\t\t\t`guardRouter.guards[\"${key}\"].${type}: expected string[], skipping`,\n\t\t\t\t\t\tJSON.stringify(entries),\n\t\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (key === \"*\") {\n\t\t\t\t\tLog.info(\n\t\t\t\t\t\t'guardRouter.guards[\"*\"]: object form; treating enter as global',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tpushEntries(entries, key, type, `[\"${key}\"].${type}`);\n\t\t\t}\n\t\t} else {\n\t\t\tLog.warning(\n\t\t\t\t`guardRouter.guards[\"${key}\"]: expected string[] or { enter?, leave? }, skipping`,\n\t\t\t\tJSON.stringify(value),\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn descriptors;\n}\n\nexport interface ResolvedGuardRouterOptions {\n\treadonly unknownRouteRegistration: UnknownRouteRegistrationPolicy;\n\treadonly navToPreflight: NavToPreflightMode;\n\treadonly guardLoading: GuardLoading;\n\treadonly inheritance: Inheritance;\n}\n\nconst DEFAULT_OPTIONS: ResolvedGuardRouterOptions = {\n\tunknownRouteRegistration: \"warn\",\n\tnavToPreflight: \"guard\",\n\tguardLoading: \"lazy\",\n\tinheritance: \"none\",\n};\n\nfunction applyOption<K extends keyof ResolvedGuardRouterOptions>(\n\traw: Record<string, unknown>,\n\tkey: K,\n\tguard: (v: unknown) => v is ResolvedGuardRouterOptions[K],\n\ttarget: { -readonly [P in keyof ResolvedGuardRouterOptions]: ResolvedGuardRouterOptions[P] },\n): void {\n\tconst value = raw[key];\n\tif (value === undefined) return;\n\tif (guard(value)) {\n\t\ttarget[key] = value;\n\t} else {\n\t\tLog.warning(`guardRouter.${key} has invalid value, using default`, JSON.stringify(value), LOG_COMPONENT);\n\t}\n}\n\n/** Raise the page-wide level of the router's log component; a more verbose level is kept. */\nfunction applyLogLevel(value: unknown): void {\n\tif (value === undefined) return;\n\tif (!isLogLevel(value)) {\n\t\t// An error, not a warning: the level is not raised, so a warning would be filtered out at the default ERROR level.\n\t\tLog.error(\"guardRouter.logLevel has invalid value, ignoring it\", JSON.stringify(value), LOG_COMPONENT);\n\t\treturn;\n\t}\n\tconst level = LOG_LEVELS[value];\n\tif (level > Log.getLevel(LOG_COMPONENT)) Log.setLevel(level, LOG_COMPONENT);\n}\n\nfunction normalizeGuardRouterOptions(raw: unknown): ResolvedGuardRouterOptions {\n\tif (!isRecord(raw)) {\n\t\tif (raw !== undefined) {\n\t\t\tLog.warning(\"guardRouter config is not a plain object, using defaults\", JSON.stringify(raw), LOG_COMPONENT);\n\t\t}\n\t\treturn DEFAULT_OPTIONS;\n\t}\n\n\t// First, so that the warnings about the other options are logged at the new level.\n\tapplyLogLevel(raw.logLevel);\n\tconst result = { ...DEFAULT_OPTIONS };\n\tapplyOption(raw, \"unknownRouteRegistration\", isUnknownRouteRegistrationPolicy, result);\n\tapplyOption(raw, \"navToPreflight\", isNavToPreflightMode, result);\n\tapplyOption(raw, \"guardLoading\", isGuardLoading, result);\n\tapplyOption(raw, \"inheritance\", isInheritance, result);\n\treturn result;\n}\n\n/** Parse the `routeMeta` block: one frozen plain object per route name. */\nfunction parseRouteMeta(raw: unknown): Map<string, Readonly<Record<string, unknown>>> {\n\tconst routeMeta = new Map<string, Readonly<Record<string, unknown>>>();\n\tif (raw === undefined) return routeMeta;\n\tif (!isRecord(raw)) {\n\t\tLog.warning(\"guardRouter.routeMeta: expected object, skipping\", JSON.stringify(raw), LOG_COMPONENT);\n\t\treturn routeMeta;\n\t}\n\tfor (const [routeName, meta] of Object.entries(raw)) {\n\t\tif (isRecord(meta)) {\n\t\t\trouteMeta.set(routeName, Object.freeze({ ...meta }));\n\t\t} else {\n\t\t\tLog.warning(\n\t\t\t\t`guardRouter.routeMeta[\"${routeName}\"]: expected object, skipping`,\n\t\t\t\tJSON.stringify(meta),\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t}\n\treturn routeMeta;\n}\n\n/** The `guardRouter` config block, validated. Invalid parts are warned about and dropped. */\ninterface ParsedGuardRouterConfig {\n\treadonly options: ResolvedGuardRouterOptions;\n\treadonly routeMeta: Map<string, Readonly<Record<string, unknown>>>;\n\treadonly guards: GuardDescriptor[];\n}\n\n/**\n * Parse the `guardRouter` config block: options, `routeMeta` and the manifest `guards`.\n * Guard module paths are resolved against `componentNamespace` (the owner's `sap.app/id`).\n * Side effect: a valid `logLevel` raises the page-wide level of the router's log component.\n */\nexport function parseGuardRouterConfig(raw: unknown, componentNamespace: string): ParsedGuardRouterConfig {\n\tconst options = normalizeGuardRouterOptions(raw);\n\tif (!isRecord(raw)) return { options, routeMeta: new Map(), guards: [] };\n\treturn {\n\t\toptions,\n\t\trouteMeta: parseRouteMeta(raw.routeMeta),\n\t\tguards: raw.guards === undefined ? [] : parseGuardDescriptors(raw.guards, componentNamespace),\n\t};\n}\n"],"mappings":"kFAWSA,EAAaC,EAAA,iBAGf,SAASC,EAASC,GACxB,UAAWA,IAAU,UAAYA,IAAU,MAAQC,MAAMC,QAAQF,GAAQ,OAAO,MAChF,MAAMG,EAAiBC,OAAOC,eAAeL,GAC7C,OAAOG,IAAUC,OAAOE,WAAaH,IAAU,IAChD,CAGA,SAASI,KAA6BC,GACrC,MAAMC,EAA2B,IAAIC,IAAIF,GACzC,OAAQG,UAA8BA,IAAM,UAAYF,EAAIG,IAAID,EACjE,CAEA,MAAME,EAAmCN,EAAwC,SAAU,OAAQ,SACnG,MAAMO,EAAuBP,EAA4B,QAAS,SAAU,OAC5E,MAAMQ,EAAiBR,EAAsB,QAAS,QACtD,MAAMS,EAAgBT,EAAqB,OAAQ,gBAEnD,MAAMU,EAAa,CAClBC,MAAOC,EAAIC,MAAMC,MACjBC,QAASH,EAAIC,MAAMG,QACnBC,KAAML,EAAIC,MAAMK,KAChBC,MAAOP,EAAIC,MAAMO,OAGlB,MAAMC,EAAcjB,UAAgDA,IAAM,UAAYP,OAAOyB,OAAOZ,EAAYN,GAwBhH,SAASmB,EAAuBC,EAAiBC,GAChD,GAAID,EAAQE,WAAW,WAAY,CAClC,OAAOF,EAAQG,MAAM,UAAUC,QAAQC,QAAQ,MAAO,IACvD,CACA,MAAMC,EAAcL,EAAqBA,EAAqB,IAAMD,EAAUA,EAC9E,OAAOM,EAAYD,QAAQ,MAAO,IACnC,CAMA,SAASE,EAAgBC,EAAeP,GACvC,MAAMQ,EAAYD,EAAME,QAAQ,KAChC,MAAMC,EAAUF,KAAe,EAAID,EAAQA,EAAML,MAAM,EAAGM,GAC1D,MAAMG,EAAYH,KAAe,EAAII,UAA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