@sap-ux/ui5-proxy-middleware 1.1.21 → 1.1.23

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,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -8,5 +8,5 @@ import type { ProxyConfig } from './types';
8
8
  * @param filter - custom filter function which will be applied to all requests
9
9
  * @returns Proxy function to use
10
10
  */
11
- export declare const ui5Proxy: (config: ProxyConfig, options?: Options | undefined, filter?: Filter | undefined) => import("http-proxy-middleware").RequestHandler;
11
+ export declare const ui5Proxy: (config: ProxyConfig, options?: Options, filter?: Filter) => import("http-proxy-middleware").RequestHandler;
12
12
  //# sourceMappingURL=proxy.d.ts.map
@@ -25,19 +25,19 @@ const ui5Proxy = (config, options, filter) => {
25
25
  target: config.url,
26
26
  changeOrigin: true,
27
27
  onProxyReq: (proxyReq, _req, res) => {
28
- utils_1.proxyRequestHandler(proxyReq, res, etag, logger);
28
+ (0, utils_1.proxyRequestHandler)(proxyReq, res, etag, logger);
29
29
  },
30
30
  pathRewrite: { [config.path]: ui5Ver + config.path },
31
31
  onProxyRes: (proxyRes) => {
32
- utils_1.proxyResponseHandler(proxyRes, etag);
32
+ (0, utils_1.proxyResponseHandler)(proxyRes, etag);
33
33
  },
34
34
  onError: (err, req, res, target) => {
35
- utils_1.proxyErrorHandler(err, req, logger, res, target);
35
+ (0, utils_1.proxyErrorHandler)(err, req, logger, res, target);
36
36
  }
37
37
  };
38
38
  // update proxy config with values coming from args or ui5.yaml
39
- utils_1.updateProxyEnv(config.proxy);
40
- const corporateProxy = proxy_from_env_1.getProxyForUrl(config.url);
39
+ (0, utils_1.updateProxyEnv)(config.proxy);
40
+ const corporateProxy = (0, proxy_from_env_1.getProxyForUrl)(config.url);
41
41
  if (corporateProxy) {
42
42
  proxyConfig.agent = new https_proxy_agent_1.HttpsProxyAgent(corporateProxy);
43
43
  }
@@ -46,7 +46,7 @@ const ui5Proxy = (config, options, filter) => {
46
46
  if (filter) {
47
47
  proxyFilter = filter;
48
48
  }
49
- return http_proxy_middleware_1.createProxyMiddleware(proxyFilter, proxyConfig);
49
+ return (0, http_proxy_middleware_1.createProxyMiddleware)(proxyFilter, proxyConfig);
50
50
  };
51
51
  exports.ui5Proxy = ui5Proxy;
52
52
  //# sourceMappingURL=proxy.js.map
@@ -2,7 +2,7 @@
2
2
  import type { NextFunction } from 'express';
3
3
  import type { IncomingMessage } from 'http';
4
4
  import type { UI5ProxyConfig } from '@sap-ux/ui5-config';
5
- export declare type Ui5MiddlewareConfig = UI5ProxyConfig;
5
+ export type Ui5MiddlewareConfig = UI5ProxyConfig;
6
6
  export interface ProxyConfig {
7
7
  path: string;
8
8
  url: string;
@@ -18,5 +18,5 @@ export interface MiddlewareParameters<T> {
18
18
  export interface UI5ProxyRequest {
19
19
  next?: NextFunction;
20
20
  }
21
- export declare type ProxyRequest = IncomingMessage & UI5ProxyRequest;
21
+ export type ProxyRequest = IncomingMessage & UI5ProxyRequest;
22
22
  //# sourceMappingURL=types.d.ts.map
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { ClientRequest, IncomingMessage, ServerResponse } from 'http';
3
4
  import type { ToolsLogger } from '@sap-ux/logger';
4
5
  import type { Manifest } from '@sap-ux/project-access';
@@ -159,8 +159,8 @@ exports.getYamlFile = getYamlFile;
159
159
  */
160
160
  const getWebAppFolderFromYaml = (ui5YamlPath) => __awaiter(void 0, void 0, void 0, function* () {
161
161
  var _a, _b;
162
- if (fs_1.existsSync(ui5YamlPath)) {
163
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs_1.readFileSync(ui5YamlPath, { encoding: 'utf8' }));
162
+ if ((0, fs_1.existsSync)(ui5YamlPath)) {
163
+ const ui5Config = yield ui5_config_1.UI5Config.newInstance((0, fs_1.readFileSync)(ui5YamlPath, { encoding: 'utf8' }));
164
164
  return (_b = (_a = ui5Config.getConfiguration().paths) === null || _a === void 0 ? void 0 : _a.webapp) !== null && _b !== void 0 ? _b : 'webapp';
165
165
  }
166
166
  else {
@@ -192,11 +192,11 @@ exports.setHtmlResponse = setHtmlResponse;
192
192
  */
193
193
  const getManifest = (args) => __awaiter(void 0, void 0, void 0, function* () {
194
194
  const projectRoot = process.cwd();
195
- const yamlFileName = exports.getYamlFile(args);
196
- const ui5YamlPath = path_1.join(projectRoot, yamlFileName);
197
- const webAppFolder = yield exports.getWebAppFolderFromYaml(ui5YamlPath);
198
- const manifestPath = path_1.join(projectRoot, webAppFolder, 'manifest.json');
199
- const manifest = JSON.parse(fs_1.readFileSync(manifestPath, { encoding: 'utf8' }));
195
+ const yamlFileName = (0, exports.getYamlFile)(args);
196
+ const ui5YamlPath = (0, path_1.join)(projectRoot, yamlFileName);
197
+ const webAppFolder = yield (0, exports.getWebAppFolderFromYaml)(ui5YamlPath);
198
+ const manifestPath = (0, path_1.join)(projectRoot, webAppFolder, 'manifest.json');
199
+ const manifest = JSON.parse((0, fs_1.readFileSync)(manifestPath, { encoding: 'utf8' }));
200
200
  return manifest;
201
201
  });
202
202
  exports.getManifest = getManifest;
@@ -209,7 +209,7 @@ exports.getManifest = getManifest;
209
209
  function getUI5VersionFromManifest(args) {
210
210
  var _a, _b;
211
211
  return __awaiter(this, void 0, void 0, function* () {
212
- const manifest = yield exports.getManifest(args);
212
+ const manifest = yield (0, exports.getManifest)(args);
213
213
  return (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.minUI5Version;
214
214
  });
215
215
  }
@@ -232,7 +232,7 @@ function resolveUI5Version(version, log) {
232
232
  }
233
233
  else if (version !== undefined) {
234
234
  ui5Version = version ? version : '';
235
- ui5VersionLocation = exports.getYamlFile(process.argv);
235
+ ui5VersionLocation = (0, exports.getYamlFile)(process.argv);
236
236
  }
237
237
  else {
238
238
  const minUI5Version = yield getUI5VersionFromManifest(process.argv);
@@ -241,7 +241,7 @@ function resolveUI5Version(version, log) {
241
241
  }
242
242
  if (log) {
243
243
  ui5VersionInfo = ui5Version ? ui5Version : 'latest';
244
- log.info(i18n_1.t('info.ui5VersionSource', { version: ui5VersionInfo, source: ui5VersionLocation }));
244
+ log.info((0, i18n_1.t)('info.ui5VersionSource', { version: ui5VersionInfo, source: ui5VersionLocation }));
245
245
  }
246
246
  return ui5Version;
247
247
  });
@@ -255,8 +255,8 @@ exports.resolveUI5Version = resolveUI5Version;
255
255
  * @returns The modified html file content
256
256
  */
257
257
  function injectUI5Url(htmlFilePath, ui5Configs) {
258
- if (fs_1.existsSync(htmlFilePath)) {
259
- let html = fs_1.readFileSync(htmlFilePath, { encoding: 'utf8' });
258
+ if ((0, fs_1.existsSync)(htmlFilePath)) {
259
+ let html = (0, fs_1.readFileSync)(htmlFilePath, { encoding: 'utf8' });
260
260
  for (const ui5Config of ui5Configs) {
261
261
  const ui5Host = ui5Config.url.replace(/\/$/, '');
262
262
  const ui5Url = ui5Config.version ? `${ui5Host}/${ui5Config.version}` : ui5Host;
@@ -288,14 +288,14 @@ const injectScripts = (req, res, next, ui5Configs) => __awaiter(void 0, void 0,
288
288
  try {
289
289
  const projectRoot = process.cwd();
290
290
  const args = process.argv;
291
- const htmlFileName = exports.getHtmlFile(req.baseUrl);
292
- const yamlFileName = exports.getYamlFile(args);
293
- const ui5YamlPath = path_1.join(projectRoot, yamlFileName);
294
- const webAppFolder = yield exports.getWebAppFolderFromYaml(ui5YamlPath);
295
- const htmlFilePath = path_1.join(projectRoot, webAppFolder, htmlFileName);
291
+ const htmlFileName = (0, exports.getHtmlFile)(req.baseUrl);
292
+ const yamlFileName = (0, exports.getYamlFile)(args);
293
+ const ui5YamlPath = (0, path_1.join)(projectRoot, yamlFileName);
294
+ const webAppFolder = yield (0, exports.getWebAppFolderFromYaml)(ui5YamlPath);
295
+ const htmlFilePath = (0, path_1.join)(projectRoot, webAppFolder, htmlFileName);
296
296
  const html = injectUI5Url(htmlFilePath, ui5Configs);
297
297
  if (html) {
298
- exports.setHtmlResponse(res, html);
298
+ (0, exports.setHtmlResponse)(res, html);
299
299
  }
300
300
  else {
301
301
  next();
@@ -344,7 +344,7 @@ function proxyErrorHandler(err, req, logger, _res, _target) {
344
344
  }
345
345
  }
346
346
  else {
347
- logger.debug(i18n_1.t('error.noCodeError', { error: JSON.stringify(err, null, 2), request: req.originalUrl }));
347
+ logger.debug((0, i18n_1.t)('error.noCodeError', { error: JSON.stringify(err, null, 2), request: req.originalUrl }));
348
348
  }
349
349
  }
350
350
  exports.proxyErrorHandler = proxyErrorHandler;
@@ -52,12 +52,12 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
52
52
  });
53
53
  dotenv_1.default.config();
54
54
  const config = options.configuration;
55
- const ui5Version = yield base_1.resolveUI5Version(config.version, logger);
55
+ const ui5Version = yield (0, base_1.resolveUI5Version)(config.version, logger);
56
56
  const envUI5Url = process.env.FIORI_TOOLS_UI5_URI;
57
57
  const directLoad = !!config.directLoad;
58
- const corporateProxyServer = base_1.getCorporateProxyServer(config.proxy);
58
+ const corporateProxyServer = (0, base_1.getCorporateProxyServer)(config.proxy);
59
59
  // hide user and pass from proxy configuration for displaying it in the terminal
60
- const proxyInfo = base_1.hideProxyCredentials(corporateProxyServer);
60
+ const proxyInfo = (0, base_1.hideProxyCredentials)(corporateProxyServer);
61
61
  const proxyOptions = createProxyOptions(logger, config);
62
62
  logger.info(`Starting ui5-proxy-middleware using following configuration:\nproxy: '${proxyInfo}'\nsecure: '${proxyOptions.secure}'\nlog: '${proxyOptions.logLevel}''\ndirectLoad: '${directLoad}'`);
63
63
  const configs = Array.isArray(config.ui5) ? config.ui5 : [config.ui5];
@@ -72,13 +72,13 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
72
72
  version: ui5Version,
73
73
  proxy: config.proxy
74
74
  };
75
- routes.push({ route: ui5Config.path, handler: base_1.ui5Proxy(ui5Config, proxyOptions) });
75
+ routes.push({ route: ui5Config.path, handler: (0, base_1.ui5Proxy)(ui5Config, proxyOptions) });
76
76
  ui5Configs.push(ui5Config);
77
77
  }
78
78
  }
79
79
  if (directLoad) {
80
80
  const directLoadProxy = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
81
- yield base_1.injectScripts(req, res, next, ui5Configs);
81
+ yield (0, base_1.injectScripts)(req, res, next, ui5Configs);
82
82
  });
83
83
  base_1.HTML_MOUNT_PATHS.forEach((path) => {
84
84
  routes.push({ route: path, handler: directLoadProxy });
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%3Aui5-proxy-middleware"
11
11
  },
12
- "version": "1.1.21",
12
+ "version": "1.1.23",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -21,8 +21,8 @@
21
21
  "!dist/**/*.map"
22
22
  ],
23
23
  "dependencies": {
24
- "@sap-ux/logger": "0.3.4",
25
- "@sap-ux/ui5-config": "0.16.2",
24
+ "@sap-ux/logger": "0.3.5",
25
+ "@sap-ux/ui5-config": "0.16.4",
26
26
  "dotenv": "16.0.0",
27
27
  "http-proxy-middleware": "2.0.1",
28
28
  "https-proxy-agent": "5.0.0",
@@ -30,7 +30,7 @@
30
30
  "proxy-from-env": "1.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@sap-ux/project-access": "1.0.6",
33
+ "@sap-ux/project-access": "1.1.3",
34
34
  "@types/express": "4.17.13",
35
35
  "@types/supertest": "2.0.12",
36
36
  "@types/proxy-from-env": "1.0.1",