16.3.15 • Published 3 months ago

@natec/mef-dev-platform-connector v16.3.15

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

Mef-Dev-Platform-Connector

The library is designed to write Angular plugins (as Trusted application on the architecture below) and simplify the interaction within the MEF.DEV serverless platform mef.dev.

Architecture platform

Get the right version

Angular / CLI@natec/mef-dev-platform-connector
13 / 131.0.0
14 / 1414.0.0
15 / 1515.0.0
16 / 1616.0.0

General types and classes

static class PlatformHelper

The main class in which the methods of working with the MEF.DEV platform

class MefDevAuthInterceptor

Ensures security headers are added to requests. It is used as an ordinary interceptor. An example is here

class PlatformSseHelper

A service class that takes over part of the logic for working with SSE. Can be used for cases where only work with SSE is required.

General methods

The library's features are located by the static class PlatformHelper. Its main methods are given in the table below:

NameReturn typeDescription
PluginDataSyncUiProfileViewModelReturn plugin data synchronous if data will previously downloaded (PlatformHelper.loadPlatformOptions() or PlatformHelper.setOptions(...))
getPluginData()Observable \<UiProfileViewModel>Return plugin data asynchronous. After successfully loading, data stored(session mode). Initiates loading of plugin data if no previusly loaded.
setOptions(options: GetInfoSpecificOptions)Observable \<UiProfileViewModel>This method used for setup data for running plugin on local machine(debug mode). Initiates loading of plugin data. Example and best practice on this demo
loadPlatformOptions()Observable\<UiProfileViewModel>Load and return plugin data asynchronous if plugin in production mode(work under platform). After successfully loading, store plugin data. For development mode use PlatformHelper.setOptions(...)
getAssetUrl ()stringReturn the asset path. In debug mode(on local machine) is 'assets'. But after uploading plugin in platform this path change
updatePluginsRoutes(routes: Routes)RoutesUpdate plugin components routes. After upload on platform path is changed. Its method help platform resolve plugin routes. Required to usage, code example
getSseStream()Observable\<any>Emit object from plugin SSE stream.
sendSseStream(data: any)Observable\<any>Send any object to plugin SSE stream.

Specific methods(Use for creating own secure interceptor or other stuff)

NameReturn typeDescription
setAuthHeaders(request: HttpRequest | any, bearerToken: string | undefined = undefined)HttpRequest\<any>Used for manual adding security headers for request.
refreshPlatformAccessToken()Observable\<string>Used for manual initiates refresh platform token. Token expire in few minutes. 455 request status signaled about token expiration.

Depricated methods list:

NameReturn typeDescription
getPluginLocalData()PluginLocalData | undefinedReturn plugin data (old interface). Works only in production mode
_getPlatformIHttpService()IHttpService | undefinedReturn platform instance of IHttpService (old interface). Works only in production mode

Scripts

There are two main scripts available: mef-dev-publish and generate-version-file. To run them, use the following command: npm explore @natec/mef-dev-platform-connector -- npm run {script} [argsName=argValue]

generate-version-file

This script creates a version.js file containing a unique identifier for any plugin version. It is required for publishing on the mef.dev platform.

Example: npm explore @natec/mef-dev-platform-connector -- npm run generate-version-file

mef-dev-publish

This script builds, generates the version.js file, and publishes the plugin to the mef.dev platform from the CLI, without any manipulations on the site interface.

Example: `npm explore @natec/mef-dev-platform-connector -- npm run mef-dev-publish debug=true

Argument List

ArgumentDescription
pluginBuildCommandnpm script what start build plugin process, default: build:plugin
apiUrlplatform API web address, default: https://sandbox.mef.dev
bauthBasic credentials for publish, format NAME:PASS
aliasAlias of plugin (optional)
updateTenantVersionUpdate tenant plugin version after upload, default: true
updateConfigurationUpdate plugin configuration after upload, default: false
debugLog expanded information, default: false

Environment file

You can declare any arguments in environment.ts. Note that CLI arguments take priority.

// /src/environments/environment.ts
import { PLUGIN_VERSION } from './version';

export const environment = {
  production: false,
  version: PLUGIN_VERSION.version,
  alias: 'test',
  bauth: 'NAME:PASS',
  apiUrl: 'https://api.mef.dev'
};

metadata.json file

At the root of the project (near the angular.json file), you need to create a metadata.json file. This file will be automatically applied for publication and stores the data required for publication

// /metadata.json
{
  "name": "basic-request-demo",
  "serviceType": "APIUI",
  "description": "basic-request-demo",
  "dependencies": [],
  "config":{
    "routesUI":[
      {
          "lang":"en",
          "routerLink":"plugin-information",
          "label":"plugin-information"
      }
    ]
  },
  "externalUrl": null,
  "configuration": "{ \"someProp\": \"some value\" }"
}
16.3.15

3 months ago

16.3.11

3 months ago

16.3.12

3 months ago

16.3.14

3 months ago

16.3.9

3 months ago

16.3.8

3 months ago

16.3.7

3 months ago

16.3.6

4 months ago

16.3.5

4 months ago

15.1.1

10 months ago

15.1.0

11 months ago

16.3.4

6 months ago

16.3.3

6 months ago

16.3.2

6 months ago

16.3.1

6 months ago

16.2.7

9 months ago

16.2.6

9 months ago

16.2.5

9 months ago

16.2.0

10 months ago

16.2.4

9 months ago

16.2.3

9 months ago

16.2.2

9 months ago

16.0.4

11 months ago

16.2.1

9 months ago

16.0.3

11 months ago

16.0.2

11 months ago

15.0.0

12 months ago

14.0.0

12 months ago

14.0.1

12 months ago

14.0.2

12 months ago

14.0.3

12 months ago

16.0.1

11 months ago

16.0.0

12 months ago

1.0.5

1 year ago

1.0.38

2 years ago

1.0.4

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.3

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.2

2 years ago

1.0.11

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago