@sap-ux/backend-proxy-middleware 0.10.1 → 0.10.2

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.
@@ -50,6 +50,13 @@ export declare function proxyErrorHandler(err: Error & {
50
50
  * Collection of path rewrite functions.
51
51
  */
52
52
  export declare const PathRewriters: {
53
+ /**
54
+ * Generates a rewrite function that replaces the matched string with '/manifest.json'.
55
+ *
56
+ * @param bspPath the bsp path from the yaml config
57
+ * @returns a path rewrite function
58
+ */
59
+ convertAppDescriptorToManifest(bspPath: string): (path: string) => string;
53
60
  /**
54
61
  * Generates a rewrite function that replaces the matched string with the prefix in the given string.
55
62
  *
@@ -59,7 +66,7 @@ export declare const PathRewriters: {
59
66
  */
60
67
  replacePrefix(match: string, prefix: string): (path: string) => string;
61
68
  /**
62
- * Add or replace the sap-client url parameter if missing or inocrrect in the original request path.
69
+ * Add or replace the sap-client url parameter if missing or incorrect in the original request path.
63
70
  *
64
71
  * @param client sap-client as string
65
72
  * @returns a path rewrite function
@@ -82,7 +89,7 @@ export declare function initI18n(): Promise<void>;
82
89
  * Enhance the proxy options and backend configurations for the usage of destinations in SAP Business Application Studio.
83
90
  *
84
91
  * @param proxyOptions reference to a proxy options object that the function will enhance
85
- * @param backend reference to the backend configuration that the the function may enhance
92
+ * @param backend reference to the backend configuration that the function may enhance
86
93
  */
87
94
  export declare function enhanceConfigsForDestination(proxyOptions: Options & {
88
95
  headers: object;
@@ -107,6 +107,16 @@ async function getApiHubKey(logger) {
107
107
  * Collection of path rewrite functions.
108
108
  */
109
109
  exports.PathRewriters = {
110
+ /**
111
+ * Generates a rewrite function that replaces the matched string with '/manifest.json'.
112
+ *
113
+ * @param bspPath the bsp path from the yaml config
114
+ * @returns a path rewrite function
115
+ */
116
+ convertAppDescriptorToManifest(bspPath) {
117
+ const regex = new RegExp('(' + bspPath + '/manifest\\.appdescr\\b)');
118
+ return (path) => (path.match(regex) ? '/manifest.json' : path);
119
+ },
110
120
  /**
111
121
  * Generates a rewrite function that replaces the matched string with the prefix in the given string.
112
122
  *
@@ -118,7 +128,7 @@ exports.PathRewriters = {
118
128
  return (path) => path.replace(match, prefix.replace(/\/$/, ''));
119
129
  },
120
130
  /**
121
- * Add or replace the sap-client url parameter if missing or inocrrect in the original request path.
131
+ * Add or replace the sap-client url parameter if missing or incorrect in the original request path.
122
132
  *
123
133
  * @param client sap-client as string
124
134
  * @returns a path rewrite function
@@ -154,6 +164,9 @@ exports.PathRewriters = {
154
164
  if (config.client) {
155
165
  functions.push(exports.PathRewriters.replaceClient(config.client));
156
166
  }
167
+ if (config.bsp) {
168
+ functions.push(exports.PathRewriters.convertAppDescriptorToManifest(config.bsp));
169
+ }
157
170
  if (functions.length > 0) {
158
171
  return (path, req) => {
159
172
  let newPath = path;
@@ -199,7 +212,7 @@ async function initI18n() {
199
212
  * Enhance the proxy options and backend configurations for the usage of destinations in SAP Business Application Studio.
200
213
  *
201
214
  * @param proxyOptions reference to a proxy options object that the function will enhance
202
- * @param backend reference to the backend configuration that the the function may enhance
215
+ * @param backend reference to the backend configuration that the function may enhance
203
216
  */
204
217
  async function enhanceConfigsForDestination(proxyOptions, backend) {
205
218
  proxyOptions.target = (0, btp_utils_1.getDestinationUrlForAppStudio)(backend.destination);
package/dist/ext/bsp.d.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  import type { Options } from 'http-proxy-middleware';
2
2
  import type { Logger } from '@sap-ux/logger';
3
- /**
4
- * Replace calls to manifest.appdescr file if we are running the FLP embedded flow.
5
- *
6
- * @param bsp path of the BSP page
7
- * @returns a path rewrite function
8
- */
9
- export declare function convertAppDescriptorToManifest(bsp: string): (path: string) => string;
10
3
  /**
11
4
  * Prompts the user for credentials.
12
5
  *
package/dist/ext/bsp.js CHANGED
@@ -3,23 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.convertAppDescriptorToManifest = convertAppDescriptorToManifest;
7
6
  exports.promptUserPass = promptUserPass;
8
7
  exports.addOptionsForEmbeddedBSP = addOptionsForEmbeddedBSP;
9
8
  const chalk_1 = require("chalk");
10
9
  const i18next_1 = __importDefault(require("i18next"));
11
10
  const prompts_1 = __importDefault(require("prompts"));
12
11
  const btp_utils_1 = require("@sap-ux/btp-utils");
13
- /**
14
- * Replace calls to manifest.appdescr file if we are running the FLP embedded flow.
15
- *
16
- * @param bsp path of the BSP page
17
- * @returns a path rewrite function
18
- */
19
- function convertAppDescriptorToManifest(bsp) {
20
- const regex = new RegExp('(' + bsp + '/manifest\\.appdescr\\b)');
21
- return (path) => (path.match(regex) ? '/manifest.json' : path);
22
- }
23
12
  /**
24
13
  * Prompts the user for credentials.
25
14
  *
@@ -98,14 +87,6 @@ async function addOptionsForEmbeddedBSP(bspPath, proxyOptions, logger) {
98
87
  return undefined;
99
88
  }
100
89
  };
101
- if (proxyOptions.pathRewrite) {
102
- const oldRewrite = proxyOptions.pathRewrite;
103
- const appDescrRewrite = convertAppDescriptorToManifest(bspPath);
104
- proxyOptions.pathRewrite = (path) => appDescrRewrite(oldRewrite(path));
105
- }
106
- else {
107
- proxyOptions.pathRewrite = convertAppDescriptorToManifest(bspPath);
108
- }
109
90
  if (!proxyOptions.auth) {
110
91
  proxyOptions.auth = await promptUserPass(logger);
111
92
  }
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%3Abackend-proxy-middleware"
11
11
  },
12
- "version": "0.10.1",
12
+ "version": "0.10.2",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",