@sap-ux/preview-middleware 0.17.44 → 0.17.45

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.
@@ -1,6 +1,6 @@
1
1
  import type { ReaderCollection } from '@ui5/fs';
2
2
  import type { Editor as MemFsEditor } from 'mem-fs-editor';
3
- import type { Router } from 'express';
3
+ import type { Request, Router } from 'express';
4
4
  import type { Logger, ToolsLogger } from '@sap-ux/logger';
5
5
  import type { MiddlewareUtils } from '@ui5/server';
6
6
  import { type Manifest } from '@sap-ux/project-access';
@@ -13,6 +13,14 @@ import { type TemplateConfig } from './config';
13
13
  export type EnhancedRouter = Router & {
14
14
  getAppPages?: () => string[];
15
15
  };
16
+ /**
17
+ * Enhanced request object that contains additional properties from cds-plugin-ui5.
18
+ */
19
+ export type EnhancedRequest = Request & {
20
+ 'ui5-patched-router'?: {
21
+ baseUrl?: string;
22
+ };
23
+ };
16
24
  type OnChangeRequestHandler = (type: OperationType, change: CommonChangeProperties, fs: MemFsEditor, logger: Logger) => Promise<void>;
17
25
  /**
18
26
  * Class handling preview of a sandbox FLP.
package/dist/base/flp.js CHANGED
@@ -219,12 +219,13 @@ class FlpSandbox {
219
219
  async editorGetHandler(req, res, rta, previewUrl, editor) {
220
220
  if (!req.query['fiori-tools-rta-mode']) {
221
221
  // Redirect to the same URL but add the necessary parameter
222
+ const url = 'ui5-patched-router' in req ? (0, path_1.join)(req['ui5-patched-router']?.baseUrl ?? '', previewUrl) : previewUrl;
222
223
  const params = structuredClone(req.query);
223
224
  params['sap-ui-xx-viewCache'] = 'false';
224
225
  params['fiori-tools-rta-mode'] = 'true';
225
226
  params['sap-ui-rta-skip-flex-validation'] = 'true';
226
227
  params['sap-ui-xx-condense-changes'] = 'true';
227
- res.redirect(302, `${previewUrl}?${new URLSearchParams(params)}`);
228
+ res.redirect(302, `${url}?${new URLSearchParams(params)}`);
228
229
  return;
229
230
  }
230
231
  const html = (await this.generateSandboxForEditor(req, rta, editor)).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
@@ -267,10 +268,13 @@ class FlpSandbox {
267
268
  async flpGetHandler(req, res, next) {
268
269
  // connect API (karma test runner) has no request query property
269
270
  if ('query' in req && 'redirect' in res && !req.query['sap-ui-xx-viewCache']) {
271
+ const url = 'ui5-patched-router' in req
272
+ ? (0, path_1.join)(req['ui5-patched-router']?.baseUrl ?? '', this.flpConfig.path)
273
+ : this.flpConfig.path;
270
274
  // Redirect to the same URL but add the necessary parameter
271
275
  const params = structuredClone(req.query);
272
276
  params['sap-ui-xx-viewCache'] = 'false';
273
- res.redirect(302, `${this.flpConfig.path}?${new URLSearchParams(params)}`);
277
+ res.redirect(302, `${url}?${new URLSearchParams(params)}`);
274
278
  return;
275
279
  }
276
280
  await this.setApplicationDependencies();
@@ -1,3 +1,3 @@
1
1
  export { FlpSandbox, initAdp } from './flp';
2
- export { generatePreviewFiles, getPreviewPaths } from './config';
2
+ export { generatePreviewFiles, getPreviewPaths, sanitizeRtaConfig } from './config';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPreviewPaths = exports.generatePreviewFiles = exports.initAdp = exports.FlpSandbox = void 0;
3
+ exports.sanitizeRtaConfig = exports.getPreviewPaths = exports.generatePreviewFiles = exports.initAdp = exports.FlpSandbox = void 0;
4
4
  var flp_1 = require("./flp");
5
5
  Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return flp_1.FlpSandbox; } });
6
6
  Object.defineProperty(exports, "initAdp", { enumerable: true, get: function () { return flp_1.initAdp; } });
7
7
  var config_1 = require("./config");
8
8
  Object.defineProperty(exports, "generatePreviewFiles", { enumerable: true, get: function () { return config_1.generatePreviewFiles; } });
9
9
  Object.defineProperty(exports, "getPreviewPaths", { enumerable: true, get: function () { return config_1.getPreviewPaths; } });
10
+ Object.defineProperty(exports, "sanitizeRtaConfig", { enumerable: true, get: function () { return config_1.sanitizeRtaConfig; } });
10
11
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './ui5/middleware';
2
- export { FlpSandbox, initAdp, generatePreviewFiles, getPreviewPaths } from './base';
2
+ export { FlpSandbox, initAdp, generatePreviewFiles, getPreviewPaths, sanitizeRtaConfig } from './base';
3
3
  export { FlpConfig, RtaConfig, TestConfig, MiddlewareConfig, DefaultFlpPath, DefaultIntent, TestConfigDefaults } from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getPreviewPaths = exports.generatePreviewFiles = exports.initAdp = exports.FlpSandbox = void 0;
17
+ exports.sanitizeRtaConfig = exports.getPreviewPaths = exports.generatePreviewFiles = exports.initAdp = exports.FlpSandbox = void 0;
18
18
  __exportStar(require("./ui5/middleware"), exports);
19
19
  var base_1 = require("./base");
20
20
  Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return base_1.FlpSandbox; } });
21
21
  Object.defineProperty(exports, "initAdp", { enumerable: true, get: function () { return base_1.initAdp; } });
22
22
  Object.defineProperty(exports, "generatePreviewFiles", { enumerable: true, get: function () { return base_1.generatePreviewFiles; } });
23
23
  Object.defineProperty(exports, "getPreviewPaths", { enumerable: true, get: function () { return base_1.getPreviewPaths; } });
24
+ Object.defineProperty(exports, "sanitizeRtaConfig", { enumerable: true, get: function () { return base_1.sanitizeRtaConfig; } });
24
25
  //# sourceMappingURL=index.js.map
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%3Apreview-middleware"
11
11
  },
12
- "version": "0.17.44",
12
+ "version": "0.17.45",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,9 +27,9 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.3",
30
+ "@sap-ux/btp-utils": "1.0.1",
30
31
  "@sap-ux/adp-tooling": "0.12.136",
31
32
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.37",
32
- "@sap-ux/btp-utils": "1.0.1",
33
33
  "@sap-ux/project-access": "1.29.8"
34
34
  },
35
35
  "devDependencies": {
@@ -51,8 +51,8 @@
51
51
  "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.67",
52
52
  "@sap-ux/axios-extension": "1.18.6",
53
53
  "@sap-ux/store": "1.0.0",
54
- "@sap-ux/i18n": "0.2.1",
55
- "@sap-ux/ui5-info": "0.8.3"
54
+ "@sap-ux/ui5-info": "0.8.3",
55
+ "@sap-ux/i18n": "0.2.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "express": "4"