new PluginBase()
Initializes a new instance of a plugin object, which should be a derived class.
Members
-
activeNode :module:Core~Node
-
Type:
-
activeSelection :Array.<module:Core~Node>
-
Type:
-
blobClient :BlobClient
-
Type:
-
core :Core
-
Type:
-
gmeConfig :GmeConfig
-
Type:
-
logger :GmeLogger
-
Type:
-
META :Object.<string, module:Core~Node>
-
The resolved META nodes based on the active namespace. Index by the fully qualified meta node names with the namespace stripped off at the start.
For example, if a project has a library A with a library B. If the project and the libraries all have two meta nodes named a and b. Depending on the namespace the META will have the following keys:
- namespace = '' -> ['a', 'b', 'A.a', 'A.b', 'A.B.a', 'A.B.b']
- namespace = 'A' -> ['a', 'b', 'B.a', 'B.b']
- namespace = 'A.B' -> ['a', 'b']
(N.B. 'a' and 'b' in example 3) are pointing to the meta nodes defined in A.B.)
Type:
- Object.<string, module:Core~Node>
-
namespace :string
-
The namespace the META nodes are coming from (set by invoker). The default is the full meta, i.e. the empty string namespace. For example, if a project has a library A with a library B. The possible namespaces are: '', 'A' and 'A.B'.
Type:
-
pluginMetadata :PluginMetadata
-
Type:
- PluginMetadata
-
project :ProjectInterface
-
Type:
-
result :PluginResultBase
-
Type:
- PluginResultBase
-
rootNode :module:Core~Node
-
Type:
Methods
-
addArtifact(name, files [, callback])
-
Adds multiple files to the blob storage and bundles them as an artifact of which the hash is added to the plugin-result.
Parameters:
Name Type Argument Description name
string name of the file bundle.
files
object.<string, (string|Buffer|ArrayBuffer)> Keys are file names and values the content.
callback
function <optional>
if provided no promise will be returned.
Properties
Name Type Description err
null | Error status of the call.
metadataHash
string the "id" of the uploaded artifact.
Returns:
If no callback is given, the result will be provided in a promise.
- Type
- external:Promise
-
addCommitToResult(status)
-
Adds the commit to the results. N.B. if you're using your own save method - make sure to update this.currentHash and this.branchName accordingly before adding the commit.
Parameters:
Name Type Description status
string Status of the commit 'SYNCED', 'FORKED', 'CANCELED', null.
-
addFile(name, data [, callback])
-
Adds a file to the blob storage and adds it to the plugin-result.
Parameters:
Name Type Argument Description name
string file name.
data
string | Buffer | ArrayBuffer file content.
callback
function <optional>
if provided no promise will be returned.
Properties
Name Type Description err
null | Error status of the call
metadataHash
string the "id" of the uploaded file
Returns:
If no callback is given, the result will be provided in a promise
- Type
- external:Promise
-
baseIsMeta(node)
-
Returns true if node is a direct instance of a meta-type node (or a meta-type node itself).
Parameters:
Name Type Description node
module:Core~Node Node to be checked.
Returns:
- Type
- boolean
-
configure(config)
-
Configures this instance of the plugin for a specific execution. This function is called before the main by the PluginManager. Initializes the result with a new object.
Parameters:
Name Type Description config
object specific context: project, branch, core, active object and active selection.
-
createMessage(node, message, severity)
-
Creates a new message for the user and adds it to the result.
Parameters:
Name Type Description node
module:Core~Node | object webgme object which is related to the message
message
string feedback to the user
severity
string severity level of the message: 'debug', 'info' (default), 'warning', 'error'.
-
fastForward( [callback])
-
If plugin is started from a branch - it will reload the instance's nodes and update the currentHash to the current hash of the branch.
N.B. Use this with caution, for instance manually referenced nodes in a plugin will still be part of the previous commit. Additionally if the namespaces have changed between commits - the this.META might end up being empty.
Parameters:
Name Type Argument Description callback
function <optional>
the result callback
Properties
Name Type Description err
null | Error status of the call
didUpdate
boolean true if there was a change and it updated the state to it
Returns:
If no callback is given, the result will be provided in a promise
- Type
- external:Promise
-
getArtifact(metadataHash)
-
Retrieves all the files in the artifact from the blob storage.
Parameters:
Name Type Description metadataHash
string the "id" of the artifact to retrieve.
callback.err
null | Error status of the call.
callback.files
object.<string, string> Keys are file names, and values the content.
Returns:
If no callback is given, the result will be provided in a promise.
- Type
- external:Promise
-
getConfigStructure()
-
Configuration structure with names, descriptions, minimum, maximum values, default values and type definitions.
Example:
[{ "name": "logChildrenNames", "displayName": "Log Children Names", "description": '', "value": true, // this is the 'default config' "valueType": "boolean", "readOnly": false },{ "name": "logLevel", "displayName": "Logger level", "description": '', "value": "info", "valueType": "string", "valueItems": [ "debug", "info", "warn", "error" ], "readOnly": false },{ "name": "maxChildrenToLog", "displayName": "Maximum children to log", "description": 'Set this parameter to blabla', "value": 4, "minValue": 1, "valueType": "number", "readOnly": false }]
Returns:
-
getCurrentConfig()
-
Gets the current configuration of the plugin that was set by the user and plugin manager.
Returns:
- Type
- PluginConfig
-
getDefaultConfig()
-
Gets the default configuration based on the configuration structure for this plugin.
Returns:
- Type
- PluginConfig
-
getDescription()
-
A detailed description of this plugin and its purpose. It can be one or more sentences.
Returns:
- Type
- string
-
getFile(metadataHash)
-
Retrieves the file from blob storage.
Parameters:
Name Type Description metadataHash
string the "id" of the file to retrieve.
callback.err
null | Error status of the call.
callback.content
string the file content.
Returns:
If no callback is given, the result will be provided in a promise.
- Type
- external:Promise
-
getId()
-
Readable name of this plugin that can contain spaces.
Returns:
- Type
- string
-
getMetadata()
-
Gets the metadata for the plugin.
Returns:
- Type
- PluginMetaData
-
getMetaType(node)
-
Finds and returns the node object defining the meta type for the given node.
Parameters:
Name Type Description node
module:Core~Node Node to be checked for type.
Returns:
- Node object defining the meta type of node.
- Type
- module:Core~Node
-
getName()
-
Readable name of this plugin that can contain spaces.
Returns:
- Type
- string
-
getPluginDependencies()
-
Gets the ids of the directly defined dependencies of the plugin
Returns:
-
getUserId()
-
Retrieves the identity of the current user of the opened project (the user who invoked the plugin).
Returns:
the userId
- Type
- string
-
getVersion()
-
Current version of this plugin using semantic versioning.
Returns:
- Type
- string
-
initialize(logger, blobClient, gmeConfig)
-
Initializes the plugin with objects that can be reused within the same plugin instance.
Parameters:
Name Type Description logger
GmeLogger logging capability to console (or file) based on PluginManager configuration
blobClient
BlobClient virtual file system where files can be generated then saved as a zip file.
gmeConfig
GmeConfig global configuration for webGME.
-
invokePlugin(pluginId [, context] [, callback])
-
Initializes and invokes the given plugin (at pluginId). Things to note:
- If the invoked plugin calls save - it will not persist nor make a commit. The message will be recorded in the InterPluginResult.
- Artifacts and files saved will be added to the blob-storage. Invoked plugins can expose the content by adding it to itself - the instance will be available in the InterPluginResult.
Parameters:
Name Type Argument Description pluginId
string Id of plugin that should be invoked
context
object <optional>
Optional context for the invoked plugin
Properties
Name Type Argument Default Description namespace
object <optional>
this.namespace Namespace (relative this.namespace)
activeNode
module:Core~Node <optional>
this.activeNode Active node of invoked plugin
activeSelection
Array.<module:Core~Node> <optional>
this.activeSelection Active selection of invoked plugin
pluginConfig
object <optional>
Specific configuration parameters that should be used for the invocation. If not provided will first check if the currentConfig of this plugin contains this plugin as dependency within the array this._currentConfig._dependencies. Finally it will fall back to the default config of the plugin.
callback
function <optional>
the result callback
Properties
Name Type Description err
null | Error status of the call
result
InterPluginResult result from the invoked plugin
Returns:
If no callback is given, the result will be provided in a promise
- Type
- external:Promise
-
isInvalidActiveNode(pluginId)
-
Checks if the activeNode has registered the plugin.
Parameters:
Name Type Description pluginId
string Id of plugin
Returns:
- returns undefined if valid and an Error if not.
- Type
- Error
-
isMetaTypeOf(node, metaNode)
-
Checks if the given node is of the given meta-type. Usage: self.isMetaTypeOf(aNode, self.META['FCO']);
Parameters:
Name Type Description node
module:Core~Node Node to be checked for type.
metaNode
module:Core~Node Node object defining the meta type.
Returns:
- True if the given object was of the META type.
- Type
- boolean
-
loadNodeMap( [node] [, callback])
-
Loads all the nodes in the subtree starting from node and returns a map from paths to nodes.
Parameters:
Name Type Argument Default Description node
module:Core~Node <optional>
self.rootNode Optional node to preload nodes from, by default all will be loaded.
callback
function <optional>
the result callback
Properties
Name Type Description err
null | Error status of the call
nodeMap
object keys are paths and values are nodes
Returns:
If no callback is given, the result will be provided in a promise
- Type
- external:Promise
-
main(callback)
-
Main function for the plugin to execute. This will perform the execution. Notes:
- Do NOT use console.log use this.logger.[error,warning,info,debug] instead.
- Do NOT put any user interaction logic UI, etc. inside this function.
- callback always have to be called even if error happened.Parameters:
Name Type Description callback
function the result callback
Properties
Name Type Description err
null | Error status of the call
result
PluginResult plugin result
-
onAbort()
-
Aborts the execution of a plugin.
-
onMessage(messageType, content)
-
Can send a message to the plugin.
Parameters:
Name Type Description messageType
string string identifier of the message.
content
object object that holds arbitrary content of the message.
-
save(message [, callback])
-
Saves all current changes if there is any to a new commit. If the commit result is either 'FORKED' or 'CANCELED', it creates a new branch.
N.B. This is a utility function for saving/persisting data. The plugin has access to the project and core instances and may persist and make the commit as define its own behavior for e.g. 'FORKED' commits. To report the commits in the PluginResult make sure to invoke this.addCommitToResult with the given status.
Parameters:
Name Type Argument Description message
string | null commit message
callback
function <optional>
the result callback
Properties
Name Type Description err
null | Error status of the call
commitResult
module:Storage~CommitResult status of the commit made
Returns:
If no callback is given, the result will be provided in a promise
- Type
- external:Promise
-
sendNotification(message [, callback])
-
Sends a notification back to the invoker of the plugin, can be used to notify about progress.
Parameters:
Name Type Argument Description message
string | object Message string or object containing message.
Properties
Name Type Argument Default Description message
string If object it must contain a message.
progress
number <optional>
Approximate progress (in %) of the plugin at time of sending.
severity
string <optional>
'info' Severity level ('success', 'info', 'warn', 'error')
toBranch
boolean <optional>
false If true, and the plugin is running on the server on a branch - will broadcast to all sockets in the branch room.
callback
function <optional>
optional callback invoked when message has been emitted from server.
Properties
Name Type Description err
null | Error status of the call
-
setCurrentConfig(newConfig)
-
Sets the current configuration of the plugin.
Parameters:
Name Type Description newConfig
PluginConfig this is the actual configuration and NOT the configuration structure.
-
updateMETA(generatedMETA)
-
WebGME can export the META types as path and this method updates the generated domain specific types with webgme node objects. These can be used to define the base class of new objects created through the webgme API.
Parameters:
Name Type Description generatedMETA
object -
updateSuccess(value, message)
-
Updates the current success flag with a new value.
NewValue = OldValue && Value
Parameters:
Name Type Description value
boolean apply this flag on current success value
message
string | null optional detailed message