0.13.27 • Published 2 days ago

@sap-ux/preview-middleware v0.13.27

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 days ago

@sap-ux/preview-middleware

The @sap-ux/preview-middleware is a Custom UI5 Server Middleware for previewing an application in a local Fiori launchpad . It can be used either with the ui5 serve or the fiori run commands. It hosts a local Fiori launchpad based on your configuration as well as offers an API to modify flex changes in your project. The API is available at /preview/api and additional client code required for the preview is available at /preview/client.

When this middleware is used together with the reload-middleware, then the order in which the middlewares are loaded is important. The reload-middleware needs to be loaded before the preview-middleware. Hence the configuration in the ui5.yaml needs to look e.g. like this:

- name: reload-middleware
  afterMiddleware: compression
- name: preview-middleware
  afterMiddleware: reload-middleware

Configuration Options

OptionTypeDefault ValueDescription
flpOptional configuration object for the local Fiori launchpad
flp.pathstring/test/flp.htmlThe mount point of the local Fiori launchpad.
flp.initstringundefinedOptional UI5 module/script to be executed after the standard initialization
flp.intentOptional intent to be used for the application
flp.intent.objectstringappOptional intent object
flp.intent.actionstringpreviewOptional intent action
flp.appsarrayundefinedOptional additional local apps that are available in local Fiori launchpad
flp.libsbooleanundefinedOptional flag to add a generic script fetching the paths of used libraries not available in UI5. To disable set it to false, if not set, then the project is checked for a load-reuse-libs script and if available the libraries are fetched as well.
flp.themestringundefinedOptional flag for setting the UI5 Theme.
adp.targetRequired configuration for adaptation projects defining the connected backend
adp.ignoreCertErrorsbooleanfalseOptional setting to ignore certification validation errors when working with e.g. development systems with self signed certificates
rtaOptional configuration allowing to add mount points for runtime adaptation
rta.layerstring(calculated)Optional property for defining the runtime adaptation layer for changes (default is CUSTOMER_BASE or read from the project for adaptation projects)
rta.editorsarrayundefinedOptional list of mount points for editing
testarrayundefinedOptional list of configurations for automated testing
debugbooleanfalseEnables debug output

flp.apps

Array of additional application configurations: | Option | Type | Default Value | Description | | ------------------------ | -------- | -------------- | ------------------------------------------------------------------------------------------------------------- | | target | string | | Target path of the additional application | | local or componentId | string | | Either a local path to a folder containing the application or the componentId of a remote app is required | | intent | | | Optional intent to be used for the application | | intent.object | string | (calculated) | Optional intent object, if it is not provided then it will be calculated based on the application id | | intent.action | string | preview | Optional intent action |

adp.target

OptionTypeDescription
urlstring mandatory (local)Mandatory URL pointing to the backend system. *Not required if destination is provided and the proxy is running SAP Business Application Studio
destinationstring mandatory (if no url)Required if the backend system is available as destination in SAP Business Application Studio.
clientstring optionalsap-client parameter
scpboolean optionalIf set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP

rta.editors

OptionTypeDescription
pathstring mandatoryThe mount point to be used for the editor.
developerModeboolean optionalEnables/disables the runtime adaptation developer mode (only supported for adaptation projects)

test

OptionTypeDescription
frameworkstring mandatoryCurrently OPA5 and QUnit are supported
pathstring optionalThe mount point to be used for test suite
initstring optionalThe mount point to be used for test runner script
patternstring optionalOptional glob pattern to find the tests. By default /test/**/*Journey.* is used for OPA5 and /test/**/*Test.* is used for QUnit

Usage

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). Example: ./test/fixtures/simple-app/ui5.yaml

Minimal Configuration

With no configuration provided, the local FLP will be available at /test/flp.html and the log level is info.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression

Different Path and Debugging enabled

With this configuration, the local FLP will be available at /test/myFLP.html and the log level is debug.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      flp: 
        path: /test/myFLP.html
      debug: true

Additional Applications

If you want to test cross application navigation, then you can add additional applications into the local FLP. With this configuration, an application that is locally available in ../local-folder will be available at /apps/other-app and will also be added as tile to the local FLP as well as one of the UI5 sample apps will be bound to the intent TheOther-preview.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      apps:
        - target: /apps/other-app
          local: ../local-folder
          intent: 
            object: TheLocal
            action: preview
        - target: /test-resources/sap/ushell/demoapps/AppNavSample
          componentId: sap.ushell.demo.AppNavSample
          intent: 
            object: TheOther
            action: preview

Runtime Adaptation Support

If you want to create variants as part of your application, then you can create an additional mount point allowing to created and edit variants.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      rta:
        layer: CUSTOMER_BASE
        editors:
          - path: /test/variant-editor.html

Test Suites

If you want to also generate generic test suites and test runners for QUnit or OPA5 tests then you can use the following minimum configurations

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      test:
        - framework: QUnit
        - framework: OPA5

Adaptation Project

If you want to use the middleware in an adaption project, the additional adp object needs to be configured. This example would preview a local adaptation project merged with its reference application from the target system at http://sap.example and it will ignore certification validation errors. For adaptation projects, it is also recommended to add the rta configuration allowing to edit the project.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      adp: 
        target: 
          url: http://sap.example
        ignoreCertErrors: true
      rta:
        editors:
          - path: /test/adaptation-editor.html
            developerMode: true

Programmatic Usage

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.

import { FlpSandbox } from '@sap-ux/preview-middleware';
const flp = new FlpSandbox(flpConfig, rootProject, middlewareUtil, logger);
const files = await resources.rootProject.byGlob('/manifest.json');
flp.init(JSON.parse(await files[0].getString()));

return flp.router
  • flpConfig - the middleware configuration
  • rootProject - Reader to access resources of the root project
  • middlewareUtil - MiddlewareUtil of the UI5 server
  • logger - Logger instance for use in the middleware.
0.13.27

2 days ago

0.13.26

3 days ago

0.13.25

6 days ago

0.13.24

6 days ago

0.13.22

10 days ago

0.13.21

12 days ago

0.13.19

16 days ago

0.13.18

16 days ago

0.13.17

16 days ago

0.13.20

15 days ago

0.13.16

21 days ago

0.13.15

21 days ago

0.13.14

22 days ago

0.13.12

23 days ago

0.13.11

24 days ago

0.13.13

23 days ago

0.13.9

27 days ago

0.13.10

27 days ago

0.13.8

28 days ago

0.13.6

29 days ago

0.13.7

29 days ago

0.13.4

1 month ago

0.13.5

1 month ago

0.13.3

1 month ago

0.13.2

1 month ago

0.13.1

1 month ago

0.13.0

2 months ago

0.12.15

2 months ago

0.12.14

2 months ago

0.12.13

2 months ago

0.12.12

2 months ago

0.12.10

2 months ago

0.12.11

2 months ago

0.12.9

2 months ago

0.12.8

2 months ago

0.12.7

2 months ago

0.12.5

2 months ago

0.12.6

2 months ago

0.12.4

2 months ago

0.12.2

2 months ago

0.12.3

2 months ago

0.12.1

2 months ago

0.12.0

3 months ago

0.11.36

3 months ago

0.11.35

3 months ago

0.11.34

3 months ago

0.11.33

3 months ago

0.11.31

3 months ago

0.11.32

3 months ago

0.11.29

3 months ago

0.11.30

3 months ago

0.11.28

3 months ago

0.11.27

3 months ago

0.11.26

4 months ago

0.11.23

4 months ago

0.11.24

4 months ago

0.11.25

4 months ago

0.11.21

5 months ago

0.11.22

5 months ago

0.11.20

5 months ago

0.11.19

5 months ago

0.11.17

5 months ago

0.11.18

5 months ago

0.11.16

5 months ago

0.11.14

5 months ago

0.11.13

5 months ago

0.11.12

5 months ago

0.11.10

5 months ago

0.11.9

5 months ago

0.11.8

5 months ago

0.11.7

5 months ago

0.11.6

5 months ago

0.11.5

5 months ago

0.11.4

6 months ago

0.11.3

6 months ago

0.11.2

6 months ago

0.11.1

6 months ago

0.11.0

6 months ago

0.10.7

6 months ago

0.10.6

6 months ago

0.10.5

6 months ago

0.10.4

6 months ago

0.10.3

6 months ago

0.10.2

6 months ago

0.10.1

6 months ago

0.10.0

6 months ago

0.9.0

6 months ago

0.8.7

6 months ago

0.8.6

7 months ago

0.8.5

7 months ago

0.8.4

7 months ago

0.8.3

7 months ago

0.8.2

7 months ago

0.8.1

7 months ago

0.8.0

7 months ago

0.7.14

7 months ago

0.7.13

7 months ago

0.7.12

7 months ago

0.7.11

7 months ago

0.7.10

7 months ago

0.7.9

7 months ago

0.7.8

7 months ago

0.7.7

7 months ago

0.7.6

7 months ago

0.7.5

7 months ago

0.7.4

7 months ago

0.7.3

7 months ago

0.7.2

8 months ago

0.7.1

8 months ago

0.7.0

8 months ago

0.6.3

8 months ago

0.6.2

8 months ago

0.6.1

8 months ago

0.6.0

8 months ago

0.5.7

8 months ago

0.5.6

8 months ago

0.5.5

8 months ago

0.5.4

8 months ago

0.5.3

8 months ago

0.5.2

8 months ago

0.5.1

8 months ago

0.5.0

8 months ago

0.4.5

8 months ago

0.4.4

8 months ago

0.4.3

8 months ago

0.4.2

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.3.9

9 months ago

0.3.8

9 months ago

0.3.7

9 months ago

0.3.6

9 months ago

0.3.5

9 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.3.0

9 months ago

0.2.0

10 months ago

0.1.0

10 months ago