@sap-ux/preview-middleware 0.17.43 → 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
@@ -126,6 +126,10 @@ sap.ui.define([
126
126
  this.model.setProperty('/selectedIndex', indexArray.length - 1);
127
127
  this.model.setProperty('/targetAggregation', controlAggregation);
128
128
  this.model.setProperty('/index', indexArray);
129
+ const defaultIndex = Number(this.options.defaultAggregationArrayIndex);
130
+ if (defaultIndex >= 0) {
131
+ this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
132
+ }
129
133
  },
130
134
  createFragmentChange: async function _createFragmentChange(fragmentData) {
131
135
  const {fragmentName, index, targetAggregation} = fragmentData;
@@ -52,6 +52,7 @@ export type AddFragmentModel = JSONModel & {
52
52
  export interface AddFragmentOptions {
53
53
  title: string;
54
54
  aggregation?: string;
55
+ defaultAggregationArrayIndex?: number;
55
56
  }
56
57
 
57
58
  /**
@@ -203,6 +204,10 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
203
204
  this.model.setProperty('/selectedIndex', indexArray.length - 1);
204
205
  this.model.setProperty('/targetAggregation', controlAggregation);
205
206
  this.model.setProperty('/index', indexArray);
207
+ const defaultIndex = Number(this.options.defaultAggregationArrayIndex);
208
+ if (defaultIndex >= 0) {
209
+ this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
210
+ }
206
211
  }
207
212
 
208
213
  /**
@@ -54,6 +54,9 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
54
54
  ...('aggregation' in options && {
55
55
  aggregation: options.aggregation
56
56
  }),
57
+ ...('defaultAggregationArrayIndex' in options && {
58
+ defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
59
+ }),
57
60
  title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
58
61
  });
59
62
  break;
@@ -62,6 +62,9 @@ export class DialogFactory {
62
62
  case DialogNames.ADD_FRAGMENT:
63
63
  controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
64
64
  ...('aggregation' in options && { aggregation: options.aggregation }),
65
+ ...('defaultAggregationArrayIndex' in options && {
66
+ defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
67
+ }),
65
68
  title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
66
69
  });
67
70
  break;
@@ -19,11 +19,11 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../simple-q
19
19
  class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase {
20
20
  constructor(context) {
21
21
  super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context, [DIALOG_ENABLEMENT_VALIDATOR]);
22
+ this.appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
22
23
  }
23
24
  async initialize() {
24
- const appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
25
25
  const version = await getUi5Version();
26
- if (appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, {
26
+ if (this.appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, {
27
27
  major: 1,
28
28
  minor: 130
29
29
  })) {
@@ -36,7 +36,8 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../simple-q
36
36
  const overlay = OverlayRegistry.getOverlay(this.control) || [];
37
37
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
38
38
  aggregation: 'actions',
39
- title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION'
39
+ title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
40
+ defaultAggregationArrayIndex: 1
40
41
  });
41
42
  }
42
43
  return [];
@@ -4,7 +4,7 @@ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
4
4
  import { DialogFactory, DialogNames } from '../../dialog-factory';
5
5
  import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
6
6
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
7
- import { getApplicationType } from '../../../utils/application';
7
+ import { ApplicationType, getApplicationType } from '../../../utils/application';
8
8
  import { getUi5Version, isLowerThanMinimalUi5Version } from '../../../utils/version';
9
9
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
10
10
 
@@ -15,16 +15,17 @@ const CONTROL_TYPES = ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 's
15
15
  * Quick Action for adding a custom page action.
16
16
  */
17
17
  export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase implements SimpleQuickActionDefinition {
18
+ private readonly appType: ApplicationType;
18
19
  constructor(context: QuickActionContext) {
19
20
  super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context, [
20
21
  DIALOG_ENABLEMENT_VALIDATOR
21
22
  ]);
23
+ this.appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
22
24
  }
23
25
 
24
26
  async initialize(): Promise<void> {
25
- const appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
26
27
  const version = await getUi5Version();
27
- if (appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, { major: 1, minor: 130 })) {
28
+ if (this.appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, { major: 1, minor: 130 })) {
28
29
  return;
29
30
  }
30
31
  await super.initialize();
@@ -35,7 +36,8 @@ export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase im
35
36
  const overlay = OverlayRegistry.getOverlay(this.control) || [];
36
37
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
38
  aggregation: 'actions',
38
- title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION'
39
+ title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
40
+ defaultAggregationArrayIndex: 1
39
41
  });
40
42
  }
41
43
  return [];
@@ -68,7 +68,8 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog
68
68
  const overlay = OverlayRegistry.getOverlay(headerToolbar) || [];
69
69
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
70
70
  aggregation: 'content',
71
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
71
+ title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION',
72
+ defaultAggregationArrayIndex: 1
72
73
  });
73
74
  }
74
75
  return [];
@@ -73,7 +73,8 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
73
73
  const overlay = OverlayRegistry.getOverlay(headerToolbar as UI5Element) || [];
74
74
  await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
75
75
  aggregation: 'content',
76
- title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
76
+ title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION',
77
+ defaultAggregationArrayIndex: 1
77
78
  });
78
79
  }
79
80
  return [];
@@ -35,6 +35,7 @@ sap.ui.define(["sap/ui/dt/OverlayUtil", "../../../utils/core", "../../dialog-fac
35
35
  controlOverlay.setSelected(true);
36
36
  await DialogFactory.createDialog(controlOverlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
37
  aggregation: 'actions',
38
+ defaultAggregationArrayIndex: 0,
38
39
  title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
39
40
  });
40
41
  }
@@ -35,6 +35,7 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im
35
35
 
36
36
  await DialogFactory.createDialog(controlOverlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
37
37
  aggregation: 'actions',
38
+ defaultAggregationArrayIndex: 0,
38
39
  title: 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION'
39
40
  });
40
41
  }
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.43",
12
+ "version": "0.17.45",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -48,11 +48,11 @@
48
48
  "supertest": "6.3.3",
49
49
  "@sap-ux-private/playwright": "0.1.0",
50
50
  "dotenv": "16.3.1",
51
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.66",
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
+ "@sap-ux/store": "1.0.0",
53
54
  "@sap-ux/ui5-info": "0.8.3",
54
- "@sap-ux/i18n": "0.2.1",
55
- "@sap-ux/store": "1.0.0"
55
+ "@sap-ux/i18n": "0.2.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "express": "4"