@sap-ux/ui5-proxy-middleware 1.0.2 → 1.0.5
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/index.d.ts +0 -1
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.js +0 -1
- package/dist/base/index.js.map +1 -1
- package/dist/base/proxy.d.ts +3 -3
- package/dist/base/proxy.d.ts.map +1 -1
- package/dist/base/proxy.js +4 -5
- package/dist/base/proxy.js.map +1 -1
- package/dist/base/types.d.ts +3 -14
- package/dist/base/types.d.ts.map +1 -1
- package/dist/base/utils.d.ts +6 -6
- package/dist/base/utils.d.ts.map +1 -1
- package/dist/base/utils.js +46 -64
- package/dist/base/utils.js.map +1 -1
- package/dist/ui5/middleware.js +16 -22
- package/dist/ui5/middleware.js.map +1 -1
- package/package.json +8 -9
- package/dist/base/manifest.d.ts +0 -2821
- package/dist/base/manifest.d.ts.map +0 -1
- package/dist/base/manifest.js +0 -4
- package/dist/base/manifest.js.map +0 -1
package/dist/base/index.d.ts
CHANGED
package/dist/base/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/dist/base/index.js
CHANGED
|
@@ -16,5 +16,4 @@ Object.defineProperty(exports, "ui5Proxy", { enumerable: true, get: function ()
|
|
|
16
16
|
__exportStar(require("./constants"), exports);
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
-
__exportStar(require("./manifest"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/dist/base/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB"}
|
package/dist/base/proxy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Options } from 'http-proxy-middleware';
|
|
2
|
+
import type { ProxyConfig } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Function for proxying UI5 sources.
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@ import type { UI5Config } 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:
|
|
11
|
+
export declare const ui5Proxy: (config: ProxyConfig, options?: Options | undefined, filter?: string | string[] | ((pathname: string, req: import("http-proxy-middleware/dist/types").Request) => boolean) | undefined) => import("http-proxy-middleware").RequestHandler;
|
|
12
12
|
//# sourceMappingURL=proxy.d.ts.map
|
package/dist/base/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/base/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/base/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,WAAY,WAAW,qNA0B3C,CAAC"}
|
package/dist/base/proxy.js
CHANGED
|
@@ -12,7 +12,7 @@ const logger_1 = require("@sap-ux/logger");
|
|
|
12
12
|
* @param filter - custom filter function which will be applied to all requests
|
|
13
13
|
* @returns Proxy function to use
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
exports.ui5Proxy = (config, options, filter) => {
|
|
16
16
|
const logger = new logger_1.ToolsLogger({
|
|
17
17
|
transports: [new logger_1.UI5ToolingTransport({ moduleName: 'ui5-proxy-middleware' })]
|
|
18
18
|
});
|
|
@@ -23,11 +23,11 @@ const ui5Proxy = (config, options, filter) => {
|
|
|
23
23
|
target: config.url,
|
|
24
24
|
changeOrigin: true,
|
|
25
25
|
onProxyReq: (proxyReq, _req, res) => {
|
|
26
|
-
|
|
26
|
+
utils_1.proxyRequestHandler(proxyReq, res, etag, logger);
|
|
27
27
|
},
|
|
28
28
|
pathRewrite: { [config.path]: ui5Ver + config.path },
|
|
29
29
|
onProxyRes: (proxyRes) => {
|
|
30
|
-
|
|
30
|
+
utils_1.proxyResponseHandler(proxyRes, etag);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
Object.assign(proxyConfig, options);
|
|
@@ -35,7 +35,6 @@ const ui5Proxy = (config, options, filter) => {
|
|
|
35
35
|
if (filter) {
|
|
36
36
|
proxyFilter = filter;
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return http_proxy_middleware_1.createProxyMiddleware(proxyFilter, proxyConfig);
|
|
39
39
|
};
|
|
40
|
-
exports.ui5Proxy = ui5Proxy;
|
|
41
40
|
//# sourceMappingURL=proxy.js.map
|
package/dist/base/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/base/proxy.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAG9D,mCAA+F;AAC/F,2CAAkE;AAElE;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/base/proxy.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAG9D,mCAA+F;AAC/F,2CAAkE;AAElE;;;;;;;GAOG;AACU,QAAA,QAAQ,GAAG,CAAC,MAAmB,EAAE,OAAiB,EAAE,MAAe,EAAE,EAAE;IAChF,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC3B,UAAU,EAAE,CAAC,IAAI,4BAAmB,CAAC,EAAE,UAAU,EAAE,sBAAsB,EAAE,CAAC,CAAC;KAChF,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,IAAI,aAAa,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC;IACjH,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,MAAM,WAAW,GAAY;QACzB,MAAM,EAAE,MAAM,CAAC,GAAG;QAClB,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,CAAC,QAAuB,EAAE,IAAqB,EAAE,GAAmB,EAAQ,EAAE;YACtF,2BAAmB,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE;QACpD,UAAU,EAAE,CAAC,QAAyB,EAAQ,EAAE;YAC5C,4BAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;KACJ,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpC,IAAI,WAAW,GAAW,iCAAyB,CAAC;IAEpD,IAAI,MAAM,EAAE;QACR,WAAW,GAAG,MAAM,CAAC;KACxB;IAED,OAAO,6CAAqB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC3D,CAAC,CAAC"}
|
package/dist/base/types.d.ts
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
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;
|
|
6
|
+
export interface ProxyConfig {
|
|
5
7
|
path: string;
|
|
6
8
|
url: string;
|
|
7
9
|
version?: string;
|
|
8
10
|
}
|
|
9
|
-
export interface UI5ConfigObject {
|
|
10
|
-
path: string[];
|
|
11
|
-
url: string;
|
|
12
|
-
version?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface ProxyConfig {
|
|
15
|
-
ui5: UI5Config[] | UI5ConfigObject;
|
|
16
|
-
proxy?: string;
|
|
17
|
-
debug?: boolean;
|
|
18
|
-
secure?: boolean;
|
|
19
|
-
directLoad?: boolean;
|
|
20
|
-
version?: string;
|
|
21
|
-
}
|
|
22
11
|
export interface MiddlewareParameters<T> {
|
|
23
12
|
resources: object;
|
|
24
13
|
options: {
|
package/dist/base/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,oBAAY,mBAAmB,GAAG,cAAc,CAAC;AAEjD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACL,aAAa,EAAE,CAAC,CAAC;KACpB,CAAC;CACL;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB;AACD,oBAAY,YAAY,GAAG,eAAe,GAAG,eAAe,CAAC"}
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ClientRequest, IncomingMessage, ServerResponse } from 'http';
|
|
2
2
|
import type { ToolsLogger } from '@sap-ux/logger';
|
|
3
|
+
import type { Manifest } from '@sap-ux/ui5-config';
|
|
3
4
|
import type { NextFunction, Request, Response } from 'express';
|
|
4
|
-
import type {
|
|
5
|
-
import type { SAPJSONSchemaForWebApplicationManifestFile } from './manifest';
|
|
5
|
+
import type { ProxyConfig } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Handler for the proxy response event.
|
|
8
8
|
* Sets an Etag which will be used for re-validation of the cached UI5 sources.
|
|
@@ -78,7 +78,7 @@ export declare const setHtmlResponse: (res: any, html: string) => void;
|
|
|
78
78
|
* @param args list of runtime arguments
|
|
79
79
|
* @returns The content of the manifest.json
|
|
80
80
|
*/
|
|
81
|
-
export declare const getManifest: (args: string[]) => Promise<
|
|
81
|
+
export declare const getManifest: (args: string[]) => Promise<Manifest>;
|
|
82
82
|
/**
|
|
83
83
|
* Gets the minUI5Version from the manifest.json.
|
|
84
84
|
*
|
|
@@ -93,7 +93,7 @@ export declare function getUI5VersionFromManifest(args: string[]): Promise<strin
|
|
|
93
93
|
* @param log logger for outputing information from where ui5 version config is coming
|
|
94
94
|
* @returns The UI5 version with which the application will be started
|
|
95
95
|
*/
|
|
96
|
-
export declare function resolveUI5Version(version
|
|
96
|
+
export declare function resolveUI5Version(version?: string, log?: ToolsLogger): Promise<string>;
|
|
97
97
|
/**
|
|
98
98
|
* Injects the absolute UI5 urls into the html file, which is used to preview the application.
|
|
99
99
|
*
|
|
@@ -101,7 +101,7 @@ export declare function resolveUI5Version(version: string | undefined, log?: Too
|
|
|
101
101
|
* @param ui5Configs - the configuration of the ui5-proxy-middleware
|
|
102
102
|
* @returns The modified html file content
|
|
103
103
|
*/
|
|
104
|
-
export declare
|
|
104
|
+
export declare function injectUI5Url(htmlFilePath: string, ui5Configs: ProxyConfig[]): string | undefined;
|
|
105
105
|
/**
|
|
106
106
|
* Injects scripts into the html file, which is used to preview the application.
|
|
107
107
|
*
|
|
@@ -110,7 +110,7 @@ export declare const injectUI5Url: (htmlFilePath: string, ui5Configs: UI5Config[
|
|
|
110
110
|
* @param next - the next function, used to forward the request to the next available handler
|
|
111
111
|
* @param ui5Configs - the UI5 configuration of the ui5-proxy-middleware
|
|
112
112
|
*/
|
|
113
|
-
export declare const injectScripts: (req: Request, res: Response, next: NextFunction, ui5Configs:
|
|
113
|
+
export declare const injectScripts: (req: Request, res: Response, next: NextFunction, ui5Configs: ProxyConfig[]) => Promise<void>;
|
|
114
114
|
/**
|
|
115
115
|
* Filters comressed html files from UI5 CDN.
|
|
116
116
|
* Avoid ERR_CONTENT_DECODING_FAILED on http request for gzip'd html files.
|
package/dist/base/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAO3C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,aAAc,eAAe,QAAQ,MAAM,KAAG,IAG9E,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,aAClB,aAAa,OAClB,cAAc,QACb,MAAM,UACJ,WAAW,KACpB,IAMF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,oBAAqB,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAWtF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAWzE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,kBAAmB,MAAM,GAAG,SAAS,OAAO,MAAM,KAAG,OAUxF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAWzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,EAAE,KAAG,MAS5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,gBAAuB,MAAM,KAAG,QAAQ,MAAM,CAOjF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,GAAG,QAAQ,MAAM,KAAG,IAOxD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAAgB,MAAM,EAAE,KAAG,QAAQ,QAAQ,CASlE,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG3F;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB5F;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,SAAS,CAqBhG;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QACjB,OAAO,OACP,QAAQ,QACP,YAAY,cACN,WAAW,EAAE,KAC1B,QAAQ,IAAI,CAmBd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,cAAe,MAAM,OAAO,eAAe,KAAG,OASnF,CAAC"}
|
package/dist/base/utils.js
CHANGED
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.filterCompressedHtmlFiles = exports.injectScripts = exports.injectUI5Url = exports.resolveUI5Version = exports.getUI5VersionFromManifest = exports.getManifest = exports.setHtmlResponse = exports.getWebAppFolderFromYaml = exports.getYamlFile = exports.getHtmlFile = exports.isHostExcludedFromProxy = exports.hideProxyCredentials = exports.getCorporateProxyServer = exports.proxyRequestHandler = exports.proxyResponseHandler = void 0;
|
|
13
|
+
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
13
14
|
const fs_1 = require("fs");
|
|
14
|
-
const yaml_1 = require("yaml");
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const i18n_1 = require("../i18n");
|
|
@@ -22,11 +22,10 @@ const i18n_1 = require("../i18n");
|
|
|
22
22
|
* @param proxyRes - proxy response object
|
|
23
23
|
* @param etag - ETag for the cached sources, normally the UI5 version
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
exports.proxyResponseHandler = (proxyRes, etag) => {
|
|
26
26
|
proxyRes.headers['Etag'] = etag;
|
|
27
27
|
proxyRes.headers['cache-control'] = 'no-cache';
|
|
28
28
|
};
|
|
29
|
-
exports.proxyResponseHandler = proxyResponseHandler;
|
|
30
29
|
/**
|
|
31
30
|
* Handler for the proxy request event.
|
|
32
31
|
* Re-validates the cached UI5 sources based on the ETag.
|
|
@@ -37,21 +36,20 @@ exports.proxyResponseHandler = proxyResponseHandler;
|
|
|
37
36
|
* @param etag - Etag of the cached UI5 sources, normally the UI5 version
|
|
38
37
|
* @param logger - Logger for loging the requests
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
exports.proxyRequestHandler = (proxyReq, res, etag, logger) => {
|
|
41
40
|
logger.info(proxyReq.path);
|
|
42
41
|
if (proxyReq.getHeader('if-none-match') === etag) {
|
|
43
42
|
res.statusCode = 304;
|
|
44
43
|
res.end();
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
|
-
exports.proxyRequestHandler = proxyRequestHandler;
|
|
48
46
|
/**
|
|
49
47
|
* Get user's proxy configuration.
|
|
50
48
|
*
|
|
51
49
|
* @param yamlProxyServer - proxy server config from yaml file
|
|
52
50
|
* @returns User's proxy configuration or undefined
|
|
53
51
|
*/
|
|
54
|
-
|
|
52
|
+
exports.getCorporateProxyServer = (yamlProxyServer) => {
|
|
55
53
|
return (yamlProxyServer ||
|
|
56
54
|
process.env.FIORI_TOOLS_PROXY ||
|
|
57
55
|
process.env.http_proxy ||
|
|
@@ -61,14 +59,13 @@ const getCorporateProxyServer = (yamlProxyServer) => {
|
|
|
61
59
|
process.env.npm_config_proxy ||
|
|
62
60
|
process.env.npm_config_https_proxy);
|
|
63
61
|
};
|
|
64
|
-
exports.getCorporateProxyServer = getCorporateProxyServer;
|
|
65
62
|
/**
|
|
66
63
|
* Hides the proxy credentials for displaying the proxy configuration in the console.
|
|
67
64
|
*
|
|
68
65
|
* @param proxy - user's proxy server
|
|
69
66
|
* @returns proxy with hidden credentials for displaying in the console
|
|
70
67
|
*/
|
|
71
|
-
|
|
68
|
+
exports.hideProxyCredentials = (proxy) => {
|
|
72
69
|
if (proxy) {
|
|
73
70
|
const forwardSlashIndex = proxy.indexOf('//');
|
|
74
71
|
const atIndex = proxy.indexOf('@');
|
|
@@ -78,7 +75,6 @@ const hideProxyCredentials = (proxy) => {
|
|
|
78
75
|
}
|
|
79
76
|
return proxy;
|
|
80
77
|
};
|
|
81
|
-
exports.hideProxyCredentials = hideProxyCredentials;
|
|
82
78
|
/**
|
|
83
79
|
* Checks if a host is excluded from user's corporate proxy.
|
|
84
80
|
*
|
|
@@ -86,31 +82,23 @@ exports.hideProxyCredentials = hideProxyCredentials;
|
|
|
86
82
|
* @param url - url to be checked
|
|
87
83
|
* @returns true if host is excluded from user's corporate server, false otherwise
|
|
88
84
|
*/
|
|
89
|
-
|
|
85
|
+
exports.isHostExcludedFromProxy = (noProxyConfig, url) => {
|
|
90
86
|
if (noProxyConfig === '*') {
|
|
91
87
|
return true;
|
|
92
88
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (entry.startsWith('.') && host.endsWith(entry)) {
|
|
98
|
-
isExcluded = true;
|
|
99
|
-
}
|
|
100
|
-
else if (`.${host}`.endsWith(`.${entry}`)) {
|
|
101
|
-
isExcluded = true;
|
|
102
|
-
}
|
|
89
|
+
else {
|
|
90
|
+
const host = new URL(url).host;
|
|
91
|
+
const noProxyList = noProxyConfig ? noProxyConfig.split(',') : [];
|
|
92
|
+
return !!noProxyList.find((entry) => entry.startsWith('.') ? host.endsWith(entry) : host.endsWith(`.${entry}`));
|
|
103
93
|
}
|
|
104
|
-
return isExcluded;
|
|
105
94
|
};
|
|
106
|
-
exports.isHostExcludedFromProxy = isHostExcludedFromProxy;
|
|
107
95
|
/**
|
|
108
96
|
* Returns the name of html file, which is used to preview the application, from the URL.
|
|
109
97
|
*
|
|
110
98
|
* @param url - html request url
|
|
111
99
|
* @returns Name of the html file
|
|
112
100
|
*/
|
|
113
|
-
|
|
101
|
+
exports.getHtmlFile = (url) => {
|
|
114
102
|
let html = url;
|
|
115
103
|
if (html.indexOf('?') !== -1) {
|
|
116
104
|
html = html.split('?')[0].replace(/["']/g, '');
|
|
@@ -123,14 +111,13 @@ const getHtmlFile = (url) => {
|
|
|
123
111
|
}
|
|
124
112
|
return html;
|
|
125
113
|
};
|
|
126
|
-
exports.getHtmlFile = getHtmlFile;
|
|
127
114
|
/**
|
|
128
115
|
* Returns the name of the yaml file, which is used to for the server configuration, from the runtime arguments.
|
|
129
116
|
*
|
|
130
117
|
* @param args - runtime arguments
|
|
131
118
|
* @returns Name of the YAML file
|
|
132
119
|
*/
|
|
133
|
-
|
|
120
|
+
exports.getYamlFile = (args) => {
|
|
134
121
|
let yaml = 'ui5.yaml';
|
|
135
122
|
const index = args.indexOf('--config') !== -1 ? args.indexOf('--config') : args.indexOf('-c');
|
|
136
123
|
if (index !== -1) {
|
|
@@ -138,32 +125,29 @@ const getYamlFile = (args) => {
|
|
|
138
125
|
}
|
|
139
126
|
return yaml;
|
|
140
127
|
};
|
|
141
|
-
exports.getYamlFile = getYamlFile;
|
|
142
128
|
/**
|
|
143
129
|
* Gets the path to the webapp folder from the YAML file.
|
|
144
130
|
*
|
|
145
131
|
* @param ui5YamlPath - path to the yaml file
|
|
146
132
|
* @returns Path to the webapp folder
|
|
147
133
|
*/
|
|
148
|
-
|
|
149
|
-
var _a, _b
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
134
|
+
exports.getWebAppFolderFromYaml = (ui5YamlPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
if (fs_1.existsSync(ui5YamlPath)) {
|
|
137
|
+
const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs_1.readFileSync(ui5YamlPath, { encoding: 'utf8' }));
|
|
138
|
+
return (_b = (_a = ui5Config.getConfiguration().paths) === null || _a === void 0 ? void 0 : _a.webapp) !== null && _b !== void 0 ? _b : 'webapp';
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return 'webapp';
|
|
156
142
|
}
|
|
157
|
-
return webAppFolder;
|
|
158
143
|
});
|
|
159
|
-
exports.getWebAppFolderFromYaml = getWebAppFolderFromYaml;
|
|
160
144
|
/**
|
|
161
145
|
* Sends HTML content as a response.
|
|
162
146
|
*
|
|
163
147
|
* @param res - The http response object
|
|
164
148
|
* @param html - The HTML content
|
|
165
149
|
*/
|
|
166
|
-
|
|
150
|
+
exports.setHtmlResponse = (res, html) => {
|
|
167
151
|
if (res['_livereload']) {
|
|
168
152
|
res.write(html);
|
|
169
153
|
res.end();
|
|
@@ -172,23 +156,21 @@ const setHtmlResponse = (res, html) => {
|
|
|
172
156
|
res.status(200).contentType('html').send(html);
|
|
173
157
|
}
|
|
174
158
|
};
|
|
175
|
-
exports.setHtmlResponse = setHtmlResponse;
|
|
176
159
|
/**
|
|
177
160
|
* Gets the manifest.json for a given application.
|
|
178
161
|
*
|
|
179
162
|
* @param args list of runtime arguments
|
|
180
163
|
* @returns The content of the manifest.json
|
|
181
164
|
*/
|
|
182
|
-
|
|
165
|
+
exports.getManifest = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
166
|
const projectRoot = process.cwd();
|
|
184
|
-
const yamlFileName =
|
|
185
|
-
const ui5YamlPath =
|
|
186
|
-
const webAppFolder = yield
|
|
187
|
-
const manifestPath =
|
|
188
|
-
const manifest = JSON.parse(
|
|
167
|
+
const yamlFileName = exports.getYamlFile(args);
|
|
168
|
+
const ui5YamlPath = path_1.join(projectRoot, yamlFileName);
|
|
169
|
+
const webAppFolder = yield exports.getWebAppFolderFromYaml(ui5YamlPath);
|
|
170
|
+
const manifestPath = path_1.join(projectRoot, webAppFolder, 'manifest.json');
|
|
171
|
+
const manifest = JSON.parse(fs_1.readFileSync(manifestPath, { encoding: 'utf8' }));
|
|
189
172
|
return manifest;
|
|
190
173
|
});
|
|
191
|
-
exports.getManifest = getManifest;
|
|
192
174
|
/**
|
|
193
175
|
* Gets the minUI5Version from the manifest.json.
|
|
194
176
|
*
|
|
@@ -198,7 +180,7 @@ exports.getManifest = getManifest;
|
|
|
198
180
|
function getUI5VersionFromManifest(args) {
|
|
199
181
|
var _a, _b;
|
|
200
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
const manifest = yield
|
|
183
|
+
const manifest = yield exports.getManifest(args);
|
|
202
184
|
return (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.minUI5Version;
|
|
203
185
|
});
|
|
204
186
|
}
|
|
@@ -220,7 +202,7 @@ function resolveUI5Version(version, log) {
|
|
|
220
202
|
ui5VersionLocation =
|
|
221
203
|
process.env.FIORI_TOOLS_UI5_VERSION || process.env.FIORI_TOOLS_UI5_VERSION === ''
|
|
222
204
|
? 'CLI arguments / Run configuration'
|
|
223
|
-
:
|
|
205
|
+
: exports.getYamlFile(process.argv);
|
|
224
206
|
}
|
|
225
207
|
else {
|
|
226
208
|
const minUI5Version = yield getUI5VersionFromManifest(process.argv);
|
|
@@ -230,7 +212,7 @@ function resolveUI5Version(version, log) {
|
|
|
230
212
|
}
|
|
231
213
|
if (log) {
|
|
232
214
|
ui5VersionInfo = ui5Version ? ui5Version : 'latest';
|
|
233
|
-
log.info(
|
|
215
|
+
log.info(i18n_1.t('info.ui5VersionSource', { version: ui5VersionInfo, source: ui5VersionLocation }));
|
|
234
216
|
}
|
|
235
217
|
return ui5Version;
|
|
236
218
|
});
|
|
@@ -243,9 +225,9 @@ exports.resolveUI5Version = resolveUI5Version;
|
|
|
243
225
|
* @param ui5Configs - the configuration of the ui5-proxy-middleware
|
|
244
226
|
* @returns The modified html file content
|
|
245
227
|
*/
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
let html =
|
|
228
|
+
function injectUI5Url(htmlFilePath, ui5Configs) {
|
|
229
|
+
if (fs_1.existsSync(htmlFilePath)) {
|
|
230
|
+
let html = fs_1.readFileSync(htmlFilePath, { encoding: 'utf8' });
|
|
249
231
|
for (const ui5Config of ui5Configs) {
|
|
250
232
|
const ui5Host = ui5Config.url.replace(/\/$/, '');
|
|
251
233
|
const ui5Url = ui5Config.version ? `${ui5Host}/${ui5Config.version}` : ui5Host;
|
|
@@ -260,8 +242,10 @@ const injectUI5Url = (htmlFilePath, ui5Configs) => __awaiter(void 0, void 0, voi
|
|
|
260
242
|
}
|
|
261
243
|
return html;
|
|
262
244
|
}
|
|
263
|
-
|
|
264
|
-
|
|
245
|
+
else {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
265
249
|
exports.injectUI5Url = injectUI5Url;
|
|
266
250
|
/**
|
|
267
251
|
* Injects scripts into the html file, which is used to preview the application.
|
|
@@ -271,18 +255,18 @@ exports.injectUI5Url = injectUI5Url;
|
|
|
271
255
|
* @param next - the next function, used to forward the request to the next available handler
|
|
272
256
|
* @param ui5Configs - the UI5 configuration of the ui5-proxy-middleware
|
|
273
257
|
*/
|
|
274
|
-
|
|
258
|
+
exports.injectScripts = (req, res, next, ui5Configs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
275
259
|
try {
|
|
276
260
|
const projectRoot = process.cwd();
|
|
277
261
|
const args = process.argv;
|
|
278
|
-
const htmlFileName =
|
|
279
|
-
const yamlFileName =
|
|
280
|
-
const ui5YamlPath =
|
|
281
|
-
const webAppFolder = yield
|
|
282
|
-
const htmlFilePath =
|
|
283
|
-
const html =
|
|
262
|
+
const htmlFileName = exports.getHtmlFile(req.baseUrl);
|
|
263
|
+
const yamlFileName = exports.getYamlFile(args);
|
|
264
|
+
const ui5YamlPath = path_1.join(projectRoot, yamlFileName);
|
|
265
|
+
const webAppFolder = yield exports.getWebAppFolderFromYaml(ui5YamlPath);
|
|
266
|
+
const htmlFilePath = path_1.join(projectRoot, webAppFolder, htmlFileName);
|
|
267
|
+
const html = injectUI5Url(htmlFilePath, ui5Configs);
|
|
284
268
|
if (html) {
|
|
285
|
-
|
|
269
|
+
exports.setHtmlResponse(res, html);
|
|
286
270
|
}
|
|
287
271
|
else {
|
|
288
272
|
next();
|
|
@@ -292,7 +276,6 @@ const injectScripts = (req, res, next, ui5Configs) => __awaiter(void 0, void 0,
|
|
|
292
276
|
next(error);
|
|
293
277
|
}
|
|
294
278
|
});
|
|
295
|
-
exports.injectScripts = injectScripts;
|
|
296
279
|
/**
|
|
297
280
|
* Filters comressed html files from UI5 CDN.
|
|
298
281
|
* Avoid ERR_CONTENT_DECODING_FAILED on http request for gzip'd html files.
|
|
@@ -302,7 +285,7 @@ exports.injectScripts = injectScripts;
|
|
|
302
285
|
* @param req - the http request object
|
|
303
286
|
* @returns True, indicating that the request should be proxied
|
|
304
287
|
*/
|
|
305
|
-
|
|
288
|
+
exports.filterCompressedHtmlFiles = (_pathname, req) => {
|
|
306
289
|
const acceptHeader = req.headers['accept'] || '';
|
|
307
290
|
if (req.headers['accept-encoding'] &&
|
|
308
291
|
(acceptHeader.includes('text/html') || acceptHeader.includes('application/xhtml+xml'))) {
|
|
@@ -310,5 +293,4 @@ const filterCompressedHtmlFiles = (_pathname, req) => {
|
|
|
310
293
|
}
|
|
311
294
|
return true;
|
|
312
295
|
};
|
|
313
|
-
exports.filterCompressedHtmlFiles = filterCompressedHtmlFiles;
|
|
314
296
|
//# sourceMappingURL=utils.js.map
|
package/dist/base/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/base/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/base/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,mDAA+C;AAG/C,2BAA8C;AAC9C,+BAA4B;AAC5B,2CAA2G;AAE3G,kCAA4B;AAE5B;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,CAAC,QAAyB,EAAE,IAAY,EAAQ,EAAE;IAClF,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;AACnD,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,mBAAmB,GAAG,CAC/B,QAAuB,EACvB,GAAmB,EACnB,IAAY,EACZ,MAAmB,EACf,EAAE;IACN,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE;QAC9C,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;QACrB,GAAG,CAAC,GAAG,EAAE,CAAC;KACb;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,CAAC,eAAmC,EAAsB,EAAE;IAC/F,OAAO,CACH,eAAe;QACf,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAC7B,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,OAAO,CAAC,GAAG,CAAC,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AE,YAAY,CAAC,CAAC;QACpD,MAAM,YAAY,GAAG,MAAM,+BAAuB,CAAC,WAAW,CAAC,CAAC;QAChE,MAAM,YAAY,GAAG,WAAI,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAEpD,IAAI,IAAI,EAAE;YACN,uBAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SAC9B;aAAM;YACH,IAAI,EAAE,CAAC;SACV;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,IAAI,CAAC,KAAK,CAAC,CAAC;KACf;AACL,CAAC,CAAA,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,yBAAyB,GAAG,CAAC,SAAiB,EAAE,GAAoB,EAAW,EAAE;IAC1F,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjD,IACI,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC9B,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,EACxF;QACE,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,kDAAkD;KAC5F;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/ui5/middleware.js
CHANGED
|
@@ -22,46 +22,40 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
22
22
|
});
|
|
23
23
|
const router = express_1.default.Router();
|
|
24
24
|
const config = options.configuration;
|
|
25
|
-
const ui5Version = yield
|
|
25
|
+
const ui5Version = yield base_1.resolveUI5Version(config.version, logger);
|
|
26
26
|
const secure = !!config.secure;
|
|
27
27
|
const debug = !!config.debug;
|
|
28
28
|
const directLoad = !!config.directLoad;
|
|
29
29
|
const noProxyVal = process.env.no_proxy || process.env.npm_config_noproxy;
|
|
30
|
-
const corporateProxyServer =
|
|
30
|
+
const corporateProxyServer = base_1.getCorporateProxyServer(config.proxy);
|
|
31
31
|
// hide user and pass from proxy configuration for displaying it in the terminal
|
|
32
|
-
const proxyInfo =
|
|
32
|
+
const proxyInfo = base_1.hideProxyCredentials(corporateProxyServer);
|
|
33
33
|
const proxyOptions = {
|
|
34
34
|
secure,
|
|
35
35
|
logLevel: debug ? 'debug' : 'info',
|
|
36
|
-
logProvider: () =>
|
|
37
|
-
return logger;
|
|
38
|
-
}
|
|
36
|
+
logProvider: () => logger
|
|
39
37
|
};
|
|
40
|
-
logger.info(`Starting ui5-proxy-middleware using following configuration:\nproxy: '${proxyInfo}'\nsecure: '${secure
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
for (const ui5Path of config.ui5.path) {
|
|
38
|
+
logger.info(`Starting ui5-proxy-middleware using following configuration:\nproxy: '${proxyInfo}'\nsecure: '${secure}'\ndebug: '${debug}''\ndirectLoad: '${directLoad}'`);
|
|
39
|
+
const configs = Array.isArray(config.ui5) ? config.ui5 : [config.ui5];
|
|
40
|
+
const ui5Configs = [];
|
|
41
|
+
for (const ui5 of configs) {
|
|
42
|
+
const paths = Array.isArray(ui5.path) ? ui5.path : [ui5.path];
|
|
43
|
+
for (const ui5Path of paths) {
|
|
47
44
|
const ui5Config = {
|
|
48
45
|
path: ui5Path,
|
|
49
|
-
url:
|
|
46
|
+
url: ui5.url,
|
|
50
47
|
version: ui5Version
|
|
51
48
|
};
|
|
49
|
+
if (corporateProxyServer && !base_1.isHostExcludedFromProxy(noProxyVal, ui5Config.url)) {
|
|
50
|
+
proxyOptions.agent = new https_proxy_agent_1.HttpsProxyAgent(corporateProxyServer);
|
|
51
|
+
}
|
|
52
|
+
router.use(ui5Config.path, base_1.ui5Proxy(ui5Config, proxyOptions));
|
|
52
53
|
ui5Configs.push(ui5Config);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
for (const ui5Config of ui5Configs) {
|
|
56
|
-
ui5Config.version = ui5Version;
|
|
57
|
-
if (corporateProxyServer && !(0, base_1.isHostExcludedFromProxy)(noProxyVal, ui5Config.url)) {
|
|
58
|
-
proxyOptions.agent = new https_proxy_agent_1.HttpsProxyAgent(corporateProxyServer);
|
|
59
|
-
}
|
|
60
|
-
router.use(ui5Config.path, (0, base_1.ui5Proxy)(ui5Config, proxyOptions));
|
|
61
|
-
}
|
|
62
56
|
if (directLoad) {
|
|
63
57
|
router.use(base_1.HTML_MOUNT_PATHS, (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
yield
|
|
58
|
+
yield base_1.injectScripts(req, res, next, ui5Configs);
|
|
65
59
|
}));
|
|
66
60
|
}
|
|
67
61
|
return router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/ui5/middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,sDAA8B;AAE9B,yDAAoD;AACpD,2CAAkE;AAElE,kCAQiB;AAEjB,MAAM,CAAC,OAAO,GAAG,CAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/ui5/middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,sDAA8B;AAE9B,yDAAoD;AACpD,2CAAkE;AAElE,kCAQiB;AAEjB,MAAM,CAAC,OAAO,GAAG,CAAO,EAAE,OAAO,EAA6C,EAA2B,EAAE;IACvG,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC3B,UAAU,EAAE,CAAC,IAAI,4BAAmB,CAAC,EAAE,UAAU,EAAE,sBAAsB,EAAE,CAAC,CAAC;KAChF,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IACrC,MAAM,UAAU,GAAG,MAAM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B,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,OAAO,EAAE,UAAU;aACtB,CAAC;YACF,IAAI,oBAAoB,IAAI,CAAC,8BAAuB,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE;gBAC7E,YAAY,CAAC,KAAK,GAAG,IAAI,mCAAe,CAAC,oBAAoB,CAAC,CAAC;aAClE;YACD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,eAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;YAC9D,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9B;KACJ;IAED,IAAI,UAAU,EAAE;QACZ,MAAM,CAAC,GAAG,CAAC,uBAAgB,EAAE,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAiB,EAAE;YAClG,MAAM,oBAAa,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC,CAAA,CAAC,CAAC;KACN;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA,CAAC"}
|
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.0.
|
|
12
|
+
"version": "1.0.5",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"files": [
|
|
@@ -18,20 +18,19 @@
|
|
|
18
18
|
"ui5.yaml"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sap-ux/logger": "0.1.
|
|
21
|
+
"@sap-ux/logger": "0.1.5",
|
|
22
|
+
"@sap-ux/ui5-config": "0.13.1",
|
|
22
23
|
"express": "4.17.2",
|
|
23
24
|
"http-proxy-middleware": "2.0.1",
|
|
24
25
|
"https-proxy-agent": "5.0.0",
|
|
25
|
-
"i18next": "20.3.2"
|
|
26
|
-
"yaml": "2.0.0-10"
|
|
26
|
+
"i18next": "20.3.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/express": "4.17.13",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"request-promise": "4.2.6"
|
|
30
|
+
"nock": "13.2.4",
|
|
31
|
+
"supertest": "6.2.2",
|
|
32
|
+
"@types/supertest": "2.0.12",
|
|
33
|
+
"yaml": "2.0.0-10"
|
|
35
34
|
},
|
|
36
35
|
"ui5": {
|
|
37
36
|
"dependencies": []
|