@sap-ux/fiori-generator-shared 0.10.2 → 0.11.0

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.
@@ -6,12 +6,12 @@ import type { PackageJsonScripts, PackageScriptsOptions } from './types';
6
6
  * @param options.localOnly no server available
7
7
  * @param options.addMock add a script for using the mockserver
8
8
  * @param options.addTest add a script for executing OPA tests
9
- * @param options.sapClient SAP client required for connecting to the backend
10
9
  * @param options.flpAppId local FLP id
11
10
  * @param options.startFile path that should be opened with the start script
12
11
  * @param options.localStartFile path that should be opend with the start-local script
13
12
  * @param options.generateIndex exclude the start-noflp script
13
+ * @param options.supportVirtualEndpoints whether to support virtual endpoints - search params will not be added as they are injected at runtime
14
14
  * @returns package.json scripts
15
15
  */
16
- export declare function getPackageScripts({ localOnly, addMock, addTest, sapClient, flpAppId, startFile, localStartFile, generateIndex }: PackageScriptsOptions): PackageJsonScripts;
16
+ export declare function getPackageScripts({ localOnly, addMock, addTest, flpAppId, startFile, localStartFile, generateIndex, supportVirtualEndpoints }: PackageScriptsOptions): PackageJsonScripts;
17
17
  //# sourceMappingURL=getPackageScripts.d.ts.map
@@ -15,30 +15,13 @@ const i18n_1 = require("../i18n");
15
15
  * appropriate parameters.
16
16
  */
17
17
  function buildStartNoFLPCommand(localOnly, searchParams) {
18
- const searchParamString = searchParams.toString();
18
+ const searchParamString = searchParams?.toString();
19
19
  const searchParam = searchParamString ? `?${searchParamString}` : '';
20
20
  if (localOnly) {
21
21
  return `echo \\"${(0, i18n_1.t)('info.mockOnlyWarning')}\\"`;
22
22
  }
23
23
  return `fiori run --open "index.html${searchParam}"`;
24
24
  }
25
- /**
26
- * Constructs a `URLSearchParams` object with the specified query parameters.
27
- *
28
- * This function creates a `URLSearchParams` instance and appends the `sap-client` parameter if provided,
29
- * along with a default `sap-ui-xx-viewCache` parameter set to `false`.
30
- *
31
- * @param {string} [sapClient] - The SAP client value to be included as a query parameter.
32
- * @returns {URLSearchParams} - The `URLSearchParams` object containing the specified query parameters.
33
- */
34
- function buildSearchParams(sapClient) {
35
- const params = new URLSearchParams();
36
- if (sapClient) {
37
- params.append('sap-client', sapClient);
38
- }
39
- params.append('sap-ui-xx-viewCache', 'false');
40
- return params;
41
- }
42
25
  /**
43
26
  * Constructs a URL parameter string from search parameters and an optional FLP app ID.
44
27
  *
@@ -49,9 +32,8 @@ function buildSearchParams(sapClient) {
49
32
  * If `searchParams` is empty, only the fragment identifier will be included.
50
33
  */
51
34
  function buildParams(searchParams, flpAppId) {
52
- const searchParamString = searchParams.toString();
53
- const searchParam = searchParamString ? `?${searchParamString}` : '';
54
35
  const hashFragment = flpAppId ? `#${flpAppId}` : '';
36
+ const searchParam = searchParams ? `?${searchParams.toString()}` : '';
55
37
  return `${searchParam}${hashFragment}`;
56
38
  }
57
39
  /**
@@ -73,22 +55,22 @@ function buildStartCommand(localOnly, params, startFile) {
73
55
  }
74
56
  /**
75
57
  * Generates a variant management script in preview mode.
58
+ * Default search parameters are added to the command if `addSearchParams` is `true`.
59
+ * These parameters are necessary when virtual endpoints are not used.
60
+ * When virtual endpoints are used, the search parameters are injected at runtime.
76
61
  *
77
- * @param {string} sapClient - The SAP client parameter to include in the URL. If not provided, the URL will not include the `sap-client` parameter.
62
+ * @param {boolean} addSearchParams - Indicates whether to include search parameters in the command.
78
63
  * @returns {string} A variant management script to run the application in preview mode.
79
64
  */
80
- function getVariantPreviewAppScript(sapClient) {
81
- const previewAppAnchor = '#preview-app';
82
- const disableCacheParam = 'sap-ui-xx-viewCache=false';
83
- const sapClientParam = sapClient ? `&sap-client=${sapClient}` : '';
84
- const urlParam = `?${[
85
- sapClientParam,
86
- disableCacheParam,
87
- 'fiori-tools-rta-mode=true',
88
- 'sap-ui-rta-skip-flex-validation=true'
89
- ]
90
- .filter(Boolean)
91
- .join('&')}`;
65
+ function getVariantPreviewAppScript(addSearchParams) {
66
+ const previewAppAnchor = '#app-preview';
67
+ let urlParam = '';
68
+ if (addSearchParams) {
69
+ const disableCacheParam = 'sap-ui-xx-viewCache=false';
70
+ urlParam = `?${[disableCacheParam, 'fiori-tools-rta-mode=true', 'sap-ui-rta-skip-flex-validation=true']
71
+ .filter(Boolean)
72
+ .join('&')}`;
73
+ }
92
74
  // Please keep the special characters in the below command
93
75
  // as removing them may cause the browser to misinterpret the URI components without the necessary escaping and quotes.
94
76
  // eslint-disable-next-line no-useless-escape
@@ -101,32 +83,32 @@ function getVariantPreviewAppScript(sapClient) {
101
83
  * @param options.localOnly no server available
102
84
  * @param options.addMock add a script for using the mockserver
103
85
  * @param options.addTest add a script for executing OPA tests
104
- * @param options.sapClient SAP client required for connecting to the backend
105
86
  * @param options.flpAppId local FLP id
106
87
  * @param options.startFile path that should be opened with the start script
107
88
  * @param options.localStartFile path that should be opend with the start-local script
108
89
  * @param options.generateIndex exclude the start-noflp script
90
+ * @param options.supportVirtualEndpoints whether to support virtual endpoints - search params will not be added as they are injected at runtime
109
91
  * @returns package.json scripts
110
92
  */
111
- function getPackageScripts({ localOnly, addMock = true, addTest = false, sapClient, flpAppId = '', startFile, localStartFile, generateIndex = true }) {
112
- const searchParams = buildSearchParams(sapClient);
113
- const params = buildParams(searchParams, flpAppId);
93
+ function getPackageScripts({ localOnly, addMock = true, addTest = false, flpAppId = '', startFile, localStartFile, generateIndex = true, supportVirtualEndpoints = false }) {
94
+ const viewCacheSearchParams = new URLSearchParams([['sap-ui-xx-viewCache', 'false']]);
95
+ const queryParams = buildParams(supportVirtualEndpoints ? undefined : viewCacheSearchParams, flpAppId);
114
96
  const scripts = {
115
- start: buildStartCommand(localOnly, params, startFile),
116
- 'start-local': `fiori run --config ./ui5-local.yaml --open "${localStartFile ?? 'test/flpSandbox.html'}${params}"`
97
+ start: buildStartCommand(localOnly, queryParams, startFile),
98
+ 'start-local': `fiori run --config ./ui5-local.yaml --open "${localStartFile ?? 'test/flpSandbox.html'}${queryParams}"`
117
99
  };
118
100
  if (generateIndex) {
119
- scripts['start-noflp'] = buildStartNoFLPCommand(localOnly, searchParams);
101
+ scripts['start-noflp'] = buildStartNoFLPCommand(localOnly, viewCacheSearchParams);
120
102
  }
121
103
  if (addMock) {
122
- scripts['start-mock'] = `fiori run --config ./ui5-mock.yaml --open "test/flpSandbox.html${params}"`;
104
+ scripts['start-mock'] = `fiori run --config ./ui5-mock.yaml --open "${localStartFile ?? 'test/flpSandbox.html'}${queryParams}"`;
123
105
  }
124
106
  if (addTest) {
125
107
  scripts['int-test'] = 'fiori run --config ./ui5-mock.yaml --open "test/integration/opaTests.qunit.html"';
126
108
  }
127
109
  scripts['start-variants-management'] = localOnly
128
110
  ? `echo \\"${(0, i18n_1.t)('info.mockOnlyWarning')}\\"`
129
- : getVariantPreviewAppScript(sapClient);
111
+ : getVariantPreviewAppScript(!supportVirtualEndpoints);
130
112
  return scripts;
131
113
  }
132
114
  //# sourceMappingURL=getPackageScripts.js.map
@@ -37,5 +37,13 @@ export interface PackageScriptsOptions {
37
37
  localStartFile?: string;
38
38
  /** If true, a script for starting the app without flp will be generated. Defaults to true. */
39
39
  generateIndex?: boolean;
40
+ /**
41
+ * By default, search parameters are added to the preview scripts.
42
+ * If `supportVirtualEndpoints` is true, the generated scripts will not include the default search parameters.
43
+ * When virtual endpoints are used, the search parameters are injected at runtime.
44
+ *
45
+ * @default false
46
+ */
47
+ supportVirtualEndpoints?: boolean;
40
48
  }
41
49
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-generator-shared",
3
3
  "description": "Commonly used shared functionality and types to support the fiori generator.",
4
- "version": "0.10.2",
4
+ "version": "0.11.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -25,8 +25,8 @@
25
25
  "os-name": "4.0.1",
26
26
  "semver": "7.5.4",
27
27
  "@sap-ux/btp-utils": "1.0.3",
28
- "@sap-ux/project-access": "1.29.18",
29
- "@sap-ux/telemetry": "0.5.74"
28
+ "@sap-ux/project-access": "1.29.19",
29
+ "@sap-ux/telemetry": "0.5.75"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/mem-fs-editor": "7.0.1",