@sap-ux/preview-middleware 0.17.9 → 0.17.11

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/dist/base/flp.js CHANGED
@@ -217,7 +217,7 @@ class FlpSandbox {
217
217
  this.router.get(previewUrl, async (req, res) => {
218
218
  if (!req.query['fiori-tools-rta-mode']) {
219
219
  // Redirect to the same URL but add the necessary parameter
220
- const params = JSON.parse(JSON.stringify(req.query));
220
+ const params = structuredClone(req.query);
221
221
  params['sap-ui-xx-viewCache'] = 'false';
222
222
  params['fiori-tools-rta-mode'] = 'true';
223
223
  params['sap-ui-rta-skip-flex-validation'] = 'true';
@@ -25,7 +25,7 @@ sap.ui.define([
25
25
  const isBindingModel = isBindingString && modifiedControlModifiedProperties?.type === 'string';
26
26
  const changeType = isBindingString ? 'BindProperty' : 'Property';
27
27
  if (isBindingModel) {
28
- validateBindingModel(modifiedControl, change.value);
28
+ await validateBindingModel(modifiedControl, change.value);
29
29
  }
30
30
  const property = isBindingString ? 'newBinding' : 'newValue';
31
31
  const modifiedValue = {
@@ -35,7 +35,7 @@ export async function applyChange(options: UI5AdaptationOptions, change: Propert
35
35
  const changeType = isBindingString ? 'BindProperty' : 'Property';
36
36
 
37
37
  if (isBindingModel) {
38
- validateBindingModel(modifiedControl, change.value as string);
38
+ await validateBindingModel(modifiedControl, change.value as string);
39
39
  }
40
40
 
41
41
  const property = isBindingString ? 'newBinding' : 'newValue';
@@ -1,30 +1,35 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define([], function () {
3
+ sap.ui.define(["../../i18n"], function (____i18n) {
4
4
  "use strict";
5
5
 
6
+ const getTextBundle = ____i18n["getTextBundle"];
6
7
  /**
7
8
  * Function to validate if a given value is a valid binding model.
8
9
  *
9
10
  * @param modifiedControl control to be modified.
10
11
  * @param value value to be checked.
11
12
  */
12
- function validateBindingModel(modifiedControl, value) {
13
+ async function validateBindingModel(modifiedControl, value) {
14
+ const textBundle = await getTextBundle();
13
15
  const bindingValue = value.replace(/[{}]/gi, '').trim();
14
16
  const bindingParts = bindingValue.split('>').filter(el => el !== '');
15
17
  if (!bindingParts.length) {
16
- throw new SyntaxError('Invalid binding string.');
18
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING'));
17
19
  }
18
- if (bindingParts[0].trim() === 'i18n') {
19
- if (bindingParts.length === 2) {
20
- const resourceKey = bindingParts[1].trim();
21
- const resourceBundle = modifiedControl.getModel('i18n').getResourceBundle();
22
- if (!resourceBundle.getText(resourceKey, undefined, true)) {
23
- throw new SyntaxError('Invalid key in the binding string. Supported value pattern is {i18n>YOUR_KEY}. Check if the key already exists in i18n.properties.' + 'If not, add the key in the i18n.properties file and reload the editor for the new key to take effect.');
24
- }
25
- } else {
26
- throw new SyntaxError('Invalid binding string. Supported value pattern is {i18n>YOUR_KEY}');
20
+ if (bindingParts.length === 2) {
21
+ const bindingModel = bindingParts[0];
22
+ const resourceKey = bindingParts[1].trim();
23
+ const resourceModel = modifiedControl.getModel(bindingModel);
24
+ if (!resourceModel) {
25
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL'));
27
26
  }
27
+ const resourceBundle = resourceModel.getResourceBundle();
28
+ if (!resourceBundle.getText(resourceKey, undefined, true)) {
29
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL_KEY'));
30
+ }
31
+ } else {
32
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING_FORMAT'));
28
33
  }
29
34
  }
30
35
  var __exports = {
@@ -1,6 +1,7 @@
1
1
  import ResourceBundle from 'sap/base/i18n/ResourceBundle';
2
2
  import ResourceModel from 'sap/ui/model/resource/ResourceModel';
3
3
  import type UI5Element from 'sap/ui/core/Element';
4
+ import { getTextBundle } from '../../i18n';
4
5
 
5
6
  /**
6
7
  * Function to validate if a given value is a valid binding model.
@@ -8,26 +9,27 @@ import type UI5Element from 'sap/ui/core/Element';
8
9
  * @param modifiedControl control to be modified.
9
10
  * @param value value to be checked.
10
11
  */
11
- export function validateBindingModel(modifiedControl: UI5Element, value: string): void {
12
+ export async function validateBindingModel(modifiedControl: UI5Element, value: string): Promise<void> {
13
+ const textBundle = await getTextBundle();
12
14
  const bindingValue = value.replace(/[{}]/gi, '').trim();
13
15
  const bindingParts = bindingValue.split('>').filter((el) => el !== '');
14
16
 
15
17
  if (!bindingParts.length) {
16
- throw new SyntaxError('Invalid binding string.');
18
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING'));
17
19
  }
18
20
 
19
- if (bindingParts[0].trim() === 'i18n') {
20
- if (bindingParts.length === 2) {
21
- const resourceKey = bindingParts[1].trim();
22
- const resourceBundle = (modifiedControl.getModel('i18n') as ResourceModel).getResourceBundle() as ResourceBundle;
23
- if (!resourceBundle.getText(resourceKey, undefined, true)) {
24
- throw new SyntaxError(
25
- 'Invalid key in the binding string. Supported value pattern is {i18n>YOUR_KEY}. Check if the key already exists in i18n.properties.' +
26
- 'If not, add the key in the i18n.properties file and reload the editor for the new key to take effect.'
27
- );
28
- }
29
- } else {
30
- throw new SyntaxError('Invalid binding string. Supported value pattern is {i18n>YOUR_KEY}');
21
+ if (bindingParts.length === 2) {
22
+ const bindingModel = bindingParts[0];
23
+ const resourceKey = bindingParts[1].trim();
24
+ const resourceModel = (modifiedControl.getModel(bindingModel) as ResourceModel);
25
+ if(!resourceModel) {
26
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL'));
31
27
  }
28
+ const resourceBundle = resourceModel.getResourceBundle() as ResourceBundle;
29
+ if (!resourceBundle.getText(resourceKey, undefined, true)) {
30
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_MODEL_KEY'));
31
+ }
32
+ } else {
33
+ throw new SyntaxError(textBundle.getText('INVALID_BINDING_STRING_FORMAT'));
32
34
  }
33
35
  }
@@ -56,3 +56,8 @@ EXTEND_WITH_ANNOTATION=Extend With Annotation
56
56
  ANNOTATION_FILE_HAS_BEEN_FOUND=An annotation file has been found.
57
57
  SHOW_FILE_IN_VSCODE=Show File in VSCode
58
58
 
59
+ INVALID_BINDING_STRING=Invalid binding string.
60
+ INVALID_BINDING_STRING_FORMAT=Invalid binding string. Supported value pattern is {i18n>YOUR_KEY}
61
+ INVALID_BINDING_MODEL=Invalid binding model.
62
+ INVALID_BINDING_MODEL_KEY=Invalid key in the binding string. Supported value pattern is {i18n>YOUR_KEY}. Check if the key already exists in i18n.properties.If not, add the key in the i18n.properties file and reload the editor for the new key to take effect.
63
+
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.9",
12
+ "version": "0.17.11",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,12 +25,12 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/feature-toggle": "0.2.3",
29
28
  "@sap-ux/btp-utils": "0.18.0",
29
+ "@sap-ux/feature-toggle": "0.2.3",
30
30
  "@sap-ux/logger": "0.6.0",
31
- "@sap-ux/adp-tooling": "0.12.119",
31
+ "@sap-ux/project-access": "1.29.3",
32
32
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.33",
33
- "@sap-ux/project-access": "1.29.3"
33
+ "@sap-ux/adp-tooling": "0.12.119"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/ejs": "3.1.2",
@@ -46,11 +46,11 @@
46
46
  "supertest": "6.3.3",
47
47
  "@sap-ux-private/playwright": "0.1.0",
48
48
  "dotenv": "16.3.1",
49
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.54",
50
- "@sap-ux/store": "1.0.0",
51
- "@sap-ux/i18n": "0.2.0",
49
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.55",
52
50
  "@sap-ux/axios-extension": "1.18.3",
53
- "@sap-ux/ui5-info": "0.8.3"
51
+ "@sap-ux/store": "1.0.0",
52
+ "@sap-ux/ui5-info": "0.8.3",
53
+ "@sap-ux/i18n": "0.2.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "express": "4"