@sap-ux/adp-tooling 0.18.66 → 0.18.67

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.
@@ -22,11 +22,12 @@ export declare function getBackendUrlsFromServiceKeys(serviceKeys: ServiceKeys[]
22
22
  *
23
23
  * @param {ServiceKeys[]} serviceKeys - The service keys containing endpoints with destinations.
24
24
  * @param {string} basePath - Path to the .adp/reuse folder containing xs-app.json files.
25
- * @returns {Array<{ url: string; paths: string[] }>} Array of URL-to-paths mappings.
25
+ * @returns {Array<{ url: string; paths: string[]; pathRewrite?: string }>} Array of URL-to-paths mappings with optional pathRewrite.
26
26
  */
27
27
  export declare function getBackendUrlsWithPaths(serviceKeys: ServiceKeys[], basePath: string): Array<{
28
28
  url: string;
29
29
  paths: string[];
30
+ pathRewrite?: string;
30
31
  }>;
31
32
  /**
32
33
  * Extract endpoint destinations from service keys.
@@ -91,13 +91,15 @@ function cleanRoutePath(source) {
91
91
  while (path.includes('//')) {
92
92
  path = path.replaceAll('//', '/');
93
93
  }
94
+ // Remove trailing slash to ensure proper path matching
95
+ path = path.replace(/\/$/, '');
94
96
  return path;
95
97
  }
96
98
  /**
97
- * Process a route and add its cleaned path to the destination mapping.
99
+ * Process a route and extract path and pathRewrite from source and target.
98
100
  *
99
- * @param {XsApp['routes'][number]} route - The route object from xs-app.json.
100
- * @param {Map<string, Set<string>>} destinationToPaths - Map to store destination to paths mapping.
101
+ * @param {XsAppRoute} route - The route object from xs-app.json.
102
+ * @param {Map<string, { paths: Set<string>; pathRewrite?: string }>} destinationToPaths - Map to store destination info.
101
103
  */
102
104
  function processRouteForDestination(route, destinationToPaths) {
103
105
  const destination = route.destination;
@@ -108,16 +110,24 @@ function processRouteForDestination(route, destinationToPaths) {
108
110
  const path = cleanRoutePath(route.source);
109
111
  if (path) {
110
112
  if (!destinationToPaths.has(destination)) {
111
- destinationToPaths.set(destination, new Set());
113
+ destinationToPaths.set(destination, { paths: new Set() });
114
+ }
115
+ const destInfo = destinationToPaths.get(destination);
116
+ destInfo.paths.add(path);
117
+ // Extract pathRewrite from target if available
118
+ if (route.target && typeof route.target === 'string') {
119
+ const pathRewrite = cleanRoutePath(route.target);
120
+ if (pathRewrite && !destInfo.pathRewrite) {
121
+ destInfo.pathRewrite = pathRewrite;
122
+ }
112
123
  }
113
- destinationToPaths.get(destination).add(path);
114
124
  }
115
125
  }
116
126
  /**
117
- * Extract destination to paths mapping from xs-app.json routes.
127
+ * Extract destination to paths mapping from xs-app.json routes with pathRewrite info.
118
128
  *
119
129
  * @param {string} xsAppPath - Path to xs-app.json file.
120
- * @returns {Map<string, Set<string>>} Map of destination names to path sets.
130
+ * @returns {Map<string, { paths: Set<string>; pathRewrite?: string }>} Map of destination names to path info.
121
131
  */
122
132
  function extractDestinationToPathsMap(xsAppPath) {
123
133
  const destinationToPaths = new Map();
@@ -141,7 +151,7 @@ function extractDestinationToPathsMap(xsAppPath) {
141
151
  *
142
152
  * @param {ServiceKeys[]} serviceKeys - The service keys containing endpoints with destinations.
143
153
  * @param {string} basePath - Path to the .adp/reuse folder containing xs-app.json files.
144
- * @returns {Array<{ url: string; paths: string[] }>} Array of URL-to-paths mappings.
154
+ * @returns {Array<{ url: string; paths: string[]; pathRewrite?: string }>} Array of URL-to-paths mappings with optional pathRewrite.
145
155
  */
146
156
  function getBackendUrlsWithPaths(serviceKeys, basePath) {
147
157
  const destinationToUrl = extractDestinationToUrlMap(serviceKeys);
@@ -159,13 +169,17 @@ function getBackendUrlsWithPaths(serviceKeys, basePath) {
159
169
  }
160
170
  const destinationToPaths = extractDestinationToPathsMap(xsAppPath);
161
171
  const result = [];
162
- for (const [destination, paths] of destinationToPaths.entries()) {
172
+ for (const [destination, pathInfo] of destinationToPaths.entries()) {
163
173
  const url = destinationToUrl.get(destination);
164
174
  if (url) {
165
- result.push({
175
+ const entry = {
166
176
  url,
167
- paths: Array.from(paths)
168
- });
177
+ paths: Array.from(pathInfo.paths)
178
+ };
179
+ if (pathInfo.pathRewrite) {
180
+ entry.pathRewrite = pathInfo.pathRewrite;
181
+ }
182
+ result.push(entry);
169
183
  }
170
184
  }
171
185
  return result;
@@ -29,7 +29,7 @@ function getReusableLibraryPaths(basePath, logger) {
29
29
  return {
30
30
  path: resourcePath,
31
31
  src: `./.adp/reuse/${html5AppName}`,
32
- fallthrough: false
32
+ fallthrough: true
33
33
  };
34
34
  });
35
35
  }
package/dist/types.d.ts CHANGED
@@ -751,7 +751,10 @@ export interface InboundChange {
751
751
  */
752
752
  export interface XsAppRoute {
753
753
  source: string;
754
+ target?: string;
755
+ destination?: string;
754
756
  endpoint?: string;
757
+ service?: string;
755
758
  [key: string]: unknown;
756
759
  }
757
760
  export interface XsApp {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.18.66",
12
+ "version": "0.18.67",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",