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 : Promise<ApplicationRemotePlugins>

Returns updated application remotes.

Async getAllMFExports
getAllMFExports()

Extracts a list of exports from each available package.

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)

Extracts a list of exported plugins from the application object.

Parameters :
Name Type Optional Description
application IApplication No

Application managed object.

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 : ApplicationRemotePlugins

Returns list of remotes.

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.

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 : Promise<ApplicationRemotePlugins>

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

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

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

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

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)

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.

Returns : Promise<ApplicationRemotePlugins>

Returns updated application remotes.

results matching ""

    No results matching ""