File

core/plugins/plugins.service.ts

Index

Methods

Constructor

constructor(applicationService: ApplicationService, appStateService: AppStateService)
Parameters :
Name Type Optional
applicationService ApplicationService No
appStateService AppStateService No

Methods

Async addRemotes
addRemotes(application: IApplication, plugins: ApplicationPlugin | ApplicationPlugin[])

Updates the remotes field in the application configuration by adding new plugins. Important: if the remotes object is not set on the configuration object, remotes will not be added. Make sure that this object exists in the application configuration.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

plugins ApplicationPlugin | ApplicationPlugin[] No

List of remotes to be added.

Returns updated application remotes.

Static convertInstalledRemotesToIds
convertInstalledRemotesToIds(remotes: ApplicationRemotePlugins)
Parameters :
Name Type Optional
remotes ApplicationRemotePlugins No
Returns : string[]
Static createPluginId
createPluginId(contextPath: string, plugin: ApplicationPlugin | string, version: string, useLatest)
Parameters :
Name Type Optional Default value
contextPath string No
plugin ApplicationPlugin | string No
version string No
useLatest No false
Returns : string
Async getAllMFExports
getAllMFExports(allVersions, excludedScopes: [])

Extracts a list of exports from each available package.

Parameters :
Name Type Optional Default value Description
allVersions No false

If set to true, all and not only latest versions are included.

excludedScopes [] No [ PluginsExportScopes.SELF, PluginsExportScopes.SELF_OPTIONAL, PluginsExportScopes.GLOBAL ]

Defines which scopes should not be loaded.

Returns : Promise<ApplicationPlugin[]>

Returns a list of all exported plugins.

Async getCumulocityJsonFile
getCumulocityJsonFile(application: IApplication)

Fetches the application manifest.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

Returns : unknown

Returns the application manifest.

getMFExports
getMFExports(application: IApplication, excludedScopes: [], useLatest)

Extracts a list of exported plugins from the application object.

Parameters :
Name Type Optional Default value Description
application IApplication No

Application managed object.

excludedScopes [] No [ PluginsExportScopes.SELF, PluginsExportScopes.SELF_OPTIONAL, PluginsExportScopes.GLOBAL ]
useLatest No false

Set this to true, to not bind the plugin to any version.

Returns : ApplicationPlugin[]

Returns a list of exported plugins.

getMFRemotes
getMFRemotes(application: IApplication)

Extracts a list of remotes from the application object.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

Returns list of remotes.

getPackageType
getPackageType(packageApplication: IApplication)

Determines the type of a package. A package is OFFICIAL if it comes from management tenant and has a label attached called OFFICIAL. A package is COMMUNITY if it has a label called COMMUNITY. A package is CUSTOM if it does not have any label attached. A package is UNKNOWN if it has a label attached but it does not match COMMUNITY or OFFICIAL.

Labels can be used to identify the status of a package. Community packages always need a license validation. The label will be shown on the application card to tell a user whether they are looking into an official or community package.

Parameters :
Name Type Optional Description
packageApplication IApplication No

The package application object to check.

Returns : PackageType

The package type.

isOwnedByManagement
isOwnedByManagement(app: IApplication)

Verifies if an application is owned by management tenant.

Parameters :
Name Type Optional Description
app IApplication No

The application to verify.

Returns : boolean

True if owned by management tenant.

isPackage
isPackage(application: IApplication)

Checks if an application is a package.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

Returns : boolean

Returns true if the application is a package.

Async listPackages
listPackages(params: any)

Fetches a list of available packages.

Parameters :
Name Type Optional Default value Description
params any No {}

Additional query parameters.

Returns a list of packages.

pluginsFromManifest
pluginsFromManifest(manifest: IManifest)
Parameters :
Name Type Optional
manifest IManifest No
Returns : ApplicationPlugin[]
Async removeRemotes
removeRemotes(application: IApplication, plugins: ApplicationPlugin | ApplicationPlugin[])

Updates the remotes field in the application configuration by removing plugins.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

plugins ApplicationPlugin | ApplicationPlugin[] No

List of remotes to be removed.

Returns updated application remotes.

Async setInitialRemotes
setInitialRemotes(application: IApplication)

Sets the initial state of remotes in the configuration (when it's missing), based on the list of remotes being in the application manifest.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

Returns : unknown

Returns a list of remotes that has been assigned to the configuration object.

sortVersions
sortVersions(source: literal type, order: "asc" | "desc")
Type parameters :
  • T

Sorts versions list or list of objects by version property

Example

Example :
const data = ['1.5.0', '2.0.0'];
const sortedData = pluginsService.sortVersions(versions, 'desc');
// sortedData:
// ['2.0.0', '1.5.0']

Example

Example :
const data = [
 {app: {appVersion: '1.5.0'}},
 {app: {appVersion: '2.0.0'}},
];
const sortedData = pluginsService.sortVersions({list: data, path: ['app', 'appVersion']}, 'desc');
// sortedData:
// [
//  {app: {appVersion: '2.0.0'}},
//  {app: {appVersion: '1.5.0'}}
// ]
Parameters :
Name Type Optional Description
source literal type No

data to sort

order "asc" | "desc" No

ascending or descending order of sorting

Example

Example :
const data = ['1.5.0', '2.0.0'];
const sortedData = pluginsService.sortVersions(versions, 'desc');
// sortedData:
// ['2.0.0', '1.5.0']

Example

Example :
const data = [
{app: {appVersion: '1.5.0'}},
{app: {appVersion: '2.0.0'}},
];
const sortedData = pluginsService.sortVersions({list: data, path: ['app', 'appVersion']}, 'desc');
// sortedData:
// [
//  {app: {appVersion: '2.0.0'}},
//  {app: {appVersion: '1.5.0'}}
// ]
Returns : T[]

list of versions as array of strings or array of objects sorted by version property

sortVersions
sortVersions(source: string[], order: "asc" | "desc")
Parameters :
Name Type Optional
source string[] No
order "asc" | "desc" No
Returns : string[]
sortVersions
sortVersions(source: any, order: "asc" | "desc")
Parameters :
Name Type Optional
source any No
order "asc" | "desc" No
Returns : any
Async updateRemotesInAppConfig
updateRemotesInAppConfig(application: IApplication, plugins: ApplicationRemotePlugins, excludedRemotes?: ApplicationRemotePlugins)

Updates the remotes field in the application configuration.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

plugins ApplicationRemotePlugins No

List of remotes to be added.

excludedRemotes ApplicationRemotePlugins Yes

Returns updated application remotes.

results matching ""

    No results matching ""