On this page

# PluginInstance

PluginInstance

This is the model that enables the interaction with the plugin instances running on the network node pipelines. Please see the network documentation for a detailed description of the Plugin Instances.

A PluginInstance is defined by a config object, a set of tags and the instance working hours. Use the `make` method for creating new `PluginInstance`s to ensure the proper validation of all the assets needed for correct instantiation.

## Constructor

### (private) new PluginInstance(id, signature, config, schema, dirty)

The PluginInstance constructor.

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`id` | string |  |
`signature` | string |  |
`config` | * |  |
`schema` | SchemaDefinition | null |
`dirty` | boolean | false |

Source
  - models/plugin.instance.js, line 28

## Classes

PluginInstance

## Members

### collectorInstance :string|null

The collector instance if this instance has its results collected by another instance.

Type:

- string | null

Source
  - models/plugin.instance.js, line 119

### config :Object

The instance config as it is on the Plugin Instance running on the NaeuralEdgeProtocol Network node.

Type:

- Object

Source
  - models/plugin.instance.js, line 55

### frequency :number|null

The frequency with which this instance consumes inputs from the pipeline's DCT.

Type:

- number | null

Source
  - models/plugin.instance.js, line 98

### id :string|null

The instance id.

Type:

- string | null

Source
  - models/plugin.instance.js, line 41

### isDirty :boolean

Flag signaling that this plugin instance has changes that need to be committed to the network.

Type:

- boolean

Source
  - models/plugin.instance.js, line 34

### linkedInstances :Array.<string>

Instances to collect results from.

Type:

- Array.<string>

Source
  - models/plugin.instance.js, line 112

### outsideWorkingHours :boolean

Flag for signalling if this particular instance is outside its configured working schedule.

Type:

- boolean

Source
  - models/plugin.instance.js, line 91

### pipeline :Pipeline

Handler for the pipeline model this instance is deployed on.

Type:

- Pipeline

Source
  - models/plugin.instance.js, line 105

### schedule :Object

The instance schedule.

Type:

- Object

Source
  - models/plugin.instance.js, line 76

### (private) scheduleTimezone :string

The instance schedule timezone.

Type:

- string

Source
  - models/plugin.instance.js, line 84

### schema :SchemaDefinition|null

The config object schema definition.

Type:

- SchemaDefinition | null

Source
  - models/plugin.instance.js, line 126

### signature :string

The plugin signature.

Type:

- string

Source
  - models/plugin.instance.js, line 48

### stats :Object

Instance stats, including errors, error times, etc.

Type:

- Object

Source
  - models/plugin.instance.js, line 62

### tags :Object

Instance tags.

Type:

- Object

Source
  - models/plugin.instance.js, line 69

## Methods

### (private) _validateSchedule(schedule) → {boolean}

Validates the structure and content of the schedule object. For separate schedules, ensures each key is a valid day and each value is an array of time intervals. For a single schedule for all days, ensures it's an array of time intervals. Time intervals should be in the format ["HH:MM", "HH:MM"].

Parameters:

Name | Type | Description
--- | --- | ---
`schedule` | Object | Array | The schedule to validate.

Source
  - models/plugin.instance.js, line 632

Returns:

True if the schedule is valid, otherwise throws an Error.

Type:
  boolean

### addTag(key, value) → {PluginInstance}

Adds a tag to the instance or updates an existing tag.

Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | The key of the tag to add or update.
`value` | string | The value of the tag to add or update.

Source
  - models/plugin.instance.js, line 421

Returns:

The instance of PluginInstance to allow method chaining.

Type:
  PluginInstance

### bulkSetTags(tags) → {PluginInstance}

Sets multiple tags at once, replacing any existing tags.

Parameters:

Name | Type | Description
--- | --- | ---
`tags` | Object | An object containing multiple tags to set.

Source
  - models/plugin.instance.js, line 453

Returns:

The instance of PluginInstance to allow method chaining.

Type:
  PluginInstance

### compile() → {Object}

Puts together all the information in one config object.

Source
  - models/plugin.instance.js, line 565

Returns:

Type:
  Object

### getCollectorInstance() → {string|null}

Returns the path of the collecting instance.

Source
  - models/plugin.instance.js, line 303

Returns:

Type:
  string | null

### getConfig() → {Object}

Retrieves the running config from the PluginInstance model. The returned config will be remapped on the schema if it exists.

Source
  - models/plugin.instance.js, line 219

Returns:

Type:
  Object

### getInstanceStats() → {Object}

Returns the instance running statistics.

Source
  - models/plugin.instance.js, line 509

Returns:

Type:
  Object

### getLinkedInstances() → {Array.<string>}

Returns the list of collected instances.

Source
  - models/plugin.instance.js, line 294

Returns:

Type:
  Array.<string>

### getPipelineId() → {string}

Returns the id of the pipeline this plugin instance is working on.

Source
  - models/plugin.instance.js, line 200

Returns:

Type:
  string

### getRawInstanceCommandPayload(command) → {ZxAICommand}

Returns the instance command wrapped within an NaeuralEdgeProtocol Node command.

Parameters:

Name | Type | Description
--- | --- | ---
`command` |  |

Source
  - models/plugin.instance.js, line 606

Returns:

Type:
  ZxAICommand

### getSchedule() → {Object|Array}

Retrieves the current working hours schedule of the instance.

Source
  - models/plugin.instance.js, line 465

Returns:

The current schedule. Returns an object for schedules specific to days of the week, or an array for a uniform schedule across all days.

Type:
  Object | Array

### getSchema() → {SchemaDefinition}

Returns the instance's schema.

Source
  - models/plugin.instance.js, line 209

Returns:

Type:
  SchemaDefinition

### getTags() → {Object}

Retrieves all tags from the instance.

Source
  - models/plugin.instance.js, line 432

Returns:

An object containing all tags.

Type:
  Object

### isCollected() → {boolean}

Returns `true` if this particular instance's output is collected by another instance.

Source
  - models/plugin.instance.js, line 276

Returns:

Type:
  boolean

### isCollecting() → {boolean}

Returns `true` if this instance is the main instance, collecting and reporting output from other instances.

Source
  - models/plugin.instance.js, line 285

Returns:

Type:
  boolean

### isCollectingFrom(tester) → {boolean}

Returns `true` if this instance is collecting data from the `tester` instance provided.

Parameters:

Name | Type | Description
--- | --- | ---
`tester` | PluginInstance |

Source
  - models/plugin.instance.js, line 340

Returns:

Type:
  boolean

### isLinkable() → {boolean}

Returns `true` if this plugin instance is linkable with others based on the associated schema.

Source
  - models/plugin.instance.js, line 258

Returns:

Type:
  boolean

### isLinked() → {boolean}

Returns `true` if plugin instance is either collecting other instances or if its output is collected by another.

Source
  - models/plugin.instance.js, line 267

Returns:

Type:
  boolean

### link(candidate) → {PluginInstance}

Attempts to link `this` instance to the `candidate` instance.

Parameters:

Name | Type | Description
--- | --- | ---
`candidate` | PluginInstance |

Source
  - models/plugin.instance.js, line 361

Returns:

Type:
  PluginInstance

### (async) makeUpdateInstancePayload() → {Promise.<ZxAIUpdateInstanceConfig>}

Computes the instance update config by comparing the config running on the NaeuralEdgeProtocol Node with the proposed configuration stored on the instance model.

Source
  - models/plugin.instance.js, line 541

Returns:

Type:
  Promise.<ZxAIUpdateInstanceConfig>

### purgeLinks() → {PluginInstance}

Removes all links to this instance.

Source
  - models/plugin.instance.js, line 326

Returns:

Type:
  PluginInstance

### removeTag(key) → {PluginInstance}

Removes a tag from the instance if it exists.

Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | The key of the tag to remove.

Source
  - models/plugin.instance.js, line 406

Returns:

The instance of PluginInstance to allow method chaining.

Type:
  PluginInstance

### resetTags() → {PluginInstance}

Resets all tags to an empty object.

Source
  - models/plugin.instance.js, line 441

Returns:

The instance of PluginInstance to allow method chaining.

Type:
  PluginInstance

### sendCommand(command) → {Promise.<Object>}

Sends a command to the instance running on the NaeuralEdgeProtocol Network node.

Parameters:

Name | Type | Description
--- | --- | ---
`command` | Object |

Source
  - models/plugin.instance.js, line 531

Returns:

Type:
  Promise.<Object>

### setCollectorInstance(instance) → {PluginInstance}

Sets `this` instance as collected by the provided `instance`.

Parameters:

Name | Type | Description
--- | --- | ---
`instance` | PluginInstance |

Source
  - models/plugin.instance.js, line 313

Returns:

Type:
  PluginInstance

### setPipeline(pipeline) → {PluginInstance}

Sets the pipeline on which this instance is running.

Parameters:

Name | Type | Description
--- | --- | ---
`pipeline` | Pipeline |

Source
  - models/plugin.instance.js, line 519

Returns:

Type:
  PluginInstance

### setSchedule(schedule, timezone, dontMarkDirty) → {PluginInstance}

Sets the working hours schedule for the instance. This method accepts either a detailed schedule for each day of the week or a single schedule for all days.

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`schedule` | Object | Array |  | The schedule to set. If an object, it should map days to time intervals. If an array, it applies the same schedule to all days.
`timezone` | string | UTC+0 | The schedule timezone.
`dontMarkDirty` | boolean | false |

Source
  - models/plugin.instance.js, line 481

Returns:

The instance of PluginInstance to allow method chaining.

Type:
  PluginInstance

### unlink(linkedInstance) → {PluginInstance}

Removes the link between `this` instance and the provided `linkedInstance` instance.

Parameters:

Name | Type | Description
--- | --- | ---
`linkedInstance` | PluginInstance |

Source
  - models/plugin.instance.js, line 385

Returns:

Type:
  PluginInstance

### updateConfig(update) → {PluginInstance}

Method for updating the config on this instance.

Parameters:

Name | Type | Description
--- | --- | ---
`update` | Object |

Source
  - models/plugin.instance.js, line 240

Returns:

Type:
  PluginInstance

### updateStats(stats) → {PluginInstance}

Method for updating the running stats on this instance.

Parameters:

Name | Type | Description
--- | --- | ---
`stats` | Object |

Source
  - models/plugin.instance.js, line 496

Returns:

Type:
  PluginInstance

### (static) make(setup, pipeline) → {PluginInstance}

Factory method for creating new `PluginInstance`s.

The setup object should provide a config object and a schema for proper instantiation of the PluginInstance. If the `schema` is provided, then this method will attempt to validate the config object based on the schema rules and throw any errors.

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`setup` | Object |  |
`pipeline` | Pipeline | null | null |

Source
  - models/plugin.instance.js, line 158

Returns:

Type:
  PluginInstance

Type anything to view search result