@sap-ux/preview-middleware 0.2.0 → 0.3.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.
- package/README.md +39 -21
- package/dist/base/flp.js +11 -6
- package/dist/base/index.d.ts +2 -0
- package/dist/base/index.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/types/index.d.ts +7 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,32 +3,35 @@
|
|
|
3
3
|
The `@sap-ux/preview-middleware` is a [Custom UI5 Server Middleware](https://sap.github.io/ui5-tooling/pages/extensibility/CustomServerMiddleware) for previewing an application in a local Fiori launchpad . It can be used either with the `ui5 serve` or the `fiori run` commands.
|
|
4
4
|
|
|
5
5
|
## Configuration Options
|
|
6
|
-
| Option
|
|
7
|
-
|
|
|
8
|
-
| `flp`
|
|
9
|
-
| `flp.path`
|
|
10
|
-
| `flp.
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
6
|
+
| Option | Type | Default Value | Description |
|
|
7
|
+
| ---------------------- | --------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
8
|
+
| `flp` | | | Optional configuration object for the local Fiori launchpad |
|
|
9
|
+
| `flp.path` | `string` | `/test/flp.html` | The mount point of the local Fiori launchpad. |
|
|
10
|
+
| `flp.intent` | | | Optional intent to be used for the application |
|
|
11
|
+
| `flp.intent.object` | `string` | `app` | Optional intent object |
|
|
12
|
+
| `flp.intent.action` | `string` | `preview` | Optional intent action |
|
|
13
|
+
| `flp.apps` | `array` | `[]` | Optional additional local apps that are available in local Fiori launchpad |
|
|
14
|
+
| `adp.target` | | | Required configuration for adaptation projects defining the connected backend |
|
|
15
|
+
| `adp.ignoreCertErrors` | `boolean` | `false` | Optional setting to ignore certification validation errors when working with e.g. development systems with self signed certificates |
|
|
16
|
+
| `debug` | `boolean` | false | Enables debug output |
|
|
14
17
|
|
|
15
18
|
### `flp.apps`
|
|
16
19
|
Array of additional application configurations:
|
|
17
|
-
| Option
|
|
18
|
-
|
|
|
19
|
-
| `target` | `string` |
|
|
20
|
-
| `local` | `string` |
|
|
21
|
-
| `intent` | |
|
|
22
|
-
| `intent.object` | `string` | `(calculated)
|
|
23
|
-
| `intent.action` | `string` | `preview`
|
|
20
|
+
| Option | Type | Default Value | Description |
|
|
21
|
+
| --------------- | -------- | -------------- | ---------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `target` | `string` | | Target path of the additional application |
|
|
23
|
+
| `local` | `string` | | Local path to the folder containing the application |
|
|
24
|
+
| `intent` | | | Optional intent to be used for the application |
|
|
25
|
+
| `intent.object` | `string` | `(calculated)` | Optional intent object, if it is not provided then it will be calculated based on the application id |
|
|
26
|
+
| `intent.action` | `string` | `preview` | Optional intent action |
|
|
24
27
|
|
|
25
28
|
### `adp.target`
|
|
26
|
-
| Option | Type
|
|
27
|
-
| ------------- |
|
|
28
|
-
| `url` | `string` mandatory (local)
|
|
29
|
-
| `destination` | `string` mandatory (if no url) | Required if the backend system is available as destination in SAP Business Application Studio.
|
|
30
|
-
| `client` | `string` optional
|
|
31
|
-
| `scp` | `boolean` optional
|
|
29
|
+
| Option | Type | Description |
|
|
30
|
+
| ------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `url` | `string` mandatory (local) | Mandatory URL pointing to the backend system. *Not required if destination is provided and the proxy is running SAP Business Application Studio |
|
|
32
|
+
| `destination` | `string` mandatory (if no url) | Required if the backend system is available as destination in SAP Business Application Studio. |
|
|
33
|
+
| `client` | `string` optional | sap-client parameter |
|
|
34
|
+
| `scp` | `boolean` optional | If set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP |
|
|
32
35
|
|
|
33
36
|
## Usage
|
|
34
37
|
The middleware can be used without configuration. However, since the middleware intercepts a few requests that might otherwise be handled by a different middleware, it is strongly recommended to run other file serving middlewares after the `preview-middleware` e.g. `backend-proxy-middleware` and `ui5-proxy-middleware` (and the corresponding middlewares in the `@sap/ux-ui5-tooling`).
|
|
@@ -83,3 +86,18 @@ server:
|
|
|
83
86
|
url: http://sap.example
|
|
84
87
|
ignoreCertErrors: true
|
|
85
88
|
```
|
|
89
|
+
### Programmatic Usage
|
|
90
|
+
Alternatively you can use the underlying middleware fuction programmatically, e.g. for the case when you want to incorporate the `preview-middleware` functionality in your own middleware.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
import { FlpSandbox } from '@sap-ux/preview-middleware';
|
|
94
|
+
const flp = new FlpSandbox(flpConfig, rootProject, middlewareUtil, logger);
|
|
95
|
+
const files = await resources.rootProject.byGlob('/manifest.json');
|
|
96
|
+
flp.init(JSON.parse(await files[0].getString()));
|
|
97
|
+
|
|
98
|
+
return flp.router
|
|
99
|
+
```
|
|
100
|
+
- `flpConfig` - the FLP configuration
|
|
101
|
+
- `rootProject` - [Reader](https://sap.github.io/ui5-tooling/stable/api/@ui5_fs_AbstractReader.html) to access resources of the root project
|
|
102
|
+
- `middlewareUtil` - [MiddlewareUtil](https://sap.github.io/ui5-tooling/v3/api/@ui5_server_middleware_MiddlewareUtil.html) of the UI5 server
|
|
103
|
+
- `logger` - Logger instance for use in the middleware.
|
package/dist/base/flp.js
CHANGED
|
@@ -23,6 +23,13 @@ const DEFAULT_THEME = 'sap_horizon';
|
|
|
23
23
|
* Default path for mounting the local FLP.
|
|
24
24
|
*/
|
|
25
25
|
const DEFAULT_PATH = '/test/flp.html';
|
|
26
|
+
/**
|
|
27
|
+
* Default intent
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_INTENT = {
|
|
30
|
+
object: 'app',
|
|
31
|
+
action: 'preview'
|
|
32
|
+
};
|
|
26
33
|
/**
|
|
27
34
|
* Class handling preview of a sandbox FLP.
|
|
28
35
|
*/
|
|
@@ -36,13 +43,14 @@ class FlpSandbox {
|
|
|
36
43
|
* @param logger logger instance
|
|
37
44
|
*/
|
|
38
45
|
constructor(config, project, utils, logger) {
|
|
39
|
-
var _a, _b;
|
|
46
|
+
var _a, _b, _c;
|
|
40
47
|
this.project = project;
|
|
41
48
|
this.utils = utils;
|
|
42
49
|
this.logger = logger;
|
|
43
50
|
this.config = {
|
|
44
51
|
path: (_a = config.path) !== null && _a !== void 0 ? _a : DEFAULT_PATH,
|
|
45
|
-
|
|
52
|
+
intent: (_b = config.intent) !== null && _b !== void 0 ? _b : DEFAULT_INTENT,
|
|
53
|
+
apps: (_c = config.apps) !== null && _c !== void 0 ? _c : [],
|
|
46
54
|
rta: config.rta
|
|
47
55
|
};
|
|
48
56
|
logger.debug(`Config: ${JSON.stringify(this.config)}`);
|
|
@@ -74,10 +82,7 @@ class FlpSandbox {
|
|
|
74
82
|
componentId,
|
|
75
83
|
target: (_f = resources[componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id]) !== null && _f !== void 0 ? _f : '/',
|
|
76
84
|
local: '.',
|
|
77
|
-
intent:
|
|
78
|
-
object: 'app',
|
|
79
|
-
action: 'preview'
|
|
80
|
-
}
|
|
85
|
+
intent: this.config.intent
|
|
81
86
|
});
|
|
82
87
|
// add route for the sandbox.html
|
|
83
88
|
this.router.get(this.config.path, (req, res) => {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlpSandbox = void 0;
|
|
4
|
+
var flp_1 = require("./flp");
|
|
5
|
+
Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return flp_1.FlpSandbox; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FlpSandbox = void 0;
|
|
17
18
|
__exportStar(require("./ui5/middleware"), exports);
|
|
19
|
+
var base_1 = require("./base");
|
|
20
|
+
Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return base_1.FlpSandbox; } });
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { AdpPreviewConfig } from '@sap-ux/adp-tooling';
|
|
2
2
|
import type { UI5FlexLayer } from '@sap-ux/project-access';
|
|
3
|
+
interface Intent {
|
|
4
|
+
object: string;
|
|
5
|
+
action: string;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Configuration for additional applications
|
|
5
9
|
*/
|
|
@@ -10,16 +14,14 @@ export interface App {
|
|
|
10
14
|
* Optional component id if it differs from the manifest (e.g. for adaptation projects)
|
|
11
15
|
*/
|
|
12
16
|
componentId?: string;
|
|
13
|
-
intent?:
|
|
14
|
-
object: string;
|
|
15
|
-
action: string;
|
|
16
|
-
};
|
|
17
|
+
intent?: Intent;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* FLP preview configuration.
|
|
20
21
|
*/
|
|
21
22
|
export interface FlpConfig {
|
|
22
23
|
path: string;
|
|
24
|
+
intent?: Intent;
|
|
23
25
|
rta?: {
|
|
24
26
|
layer?: UI5FlexLayer;
|
|
25
27
|
};
|
|
@@ -33,4 +35,5 @@ export interface Config {
|
|
|
33
35
|
adp?: AdpPreviewConfig;
|
|
34
36
|
debug?: boolean;
|
|
35
37
|
}
|
|
38
|
+
export {};
|
|
36
39
|
//# sourceMappingURL=index.d.ts.map
|
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.
|
|
12
|
+
"version": "0.3.0",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"express": "4.18.2",
|
|
35
35
|
"nock": "13.2.1",
|
|
36
36
|
"supertest": "6.3.2",
|
|
37
|
-
"@sap-ux/project-access": "1.
|
|
37
|
+
"@sap-ux/project-access": "1.11.0",
|
|
38
38
|
"@sap-ux/store": "0.3.12"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|