Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-emfcloud/coffee-custom-validators-example

Package Overview
Dependencies
Maintainers
7
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-emfcloud/coffee-custom-validators-example

Example custom validation plug-in for the Model Server.

  • 0.2.0-next.961a1a0.14
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
7
Weekly downloads
 
Created
Source

Custom Commands Example

This package provides an example of a validation provider plug-in for the Model Server. It provides an implementation of a custom validation rule for the root Machine in a Coffee model that randomly reports a warning condition.

Setup

See the parent readme for details of how to set up and build the project.

How to Run

For detailed instructions how to run the example server configuration that includes this plug-in example, see the Example Server readme.

Send Requests to the Model Server

There are a variety of tools available for ad hoc REST interactions with services such as the Model Server. A recommended option is the Postman application.

Start by fetching the current state of the model. Send a GET request to

    http://localhost:8082/api/v2/models?modeluri=SuperBrewer3000.coffee

The result should look something like this:

{
  "type": "success",
  "data": {
    "$type": "http://www.eclipsesource.com/modelserver/example/coffeemodel#//Machine",
    "$id": "/",
    "children": [
      {
        "$type": "http://www.eclipsesource.com/modelserver/example/coffeemodel#//BrewingUnit",
        "$id": "//@children.0"
      },
      {
        "$type": "http://www.eclipsesource.com/modelserver/example/coffeemodel#//ControlUnit",
        "$id": "//@children.1",
        "processor": {
          "$id": "//@children.1/@processor",
          "clockSpeed": 5,
          "numberOfCores": 10,
          "socketconnectorType": "Z51",
          "thermalDesignPower": 100
        },
        "display": {
          "$id": "//@children.1/@display",
          "width": 10,
          "height": 20
        }
      }
    ],
    "name": "Super Brewer 3000",
    "workflows": [
      // ... workflow model here ...
    ]
  }
}

Now send a validation request to check the model against its intrinsic rules and also the custom validation rule provided by the example plug-in. Send a GET request to

    http://localhost:8082/api/v2/validation?modeluri=SuperBrewer3000.coffee

No body content is required.

The response may include a warning like the following:

{
  "severity": 2,
  "source": "@eclipse-emfcloud/coffee-custom-validators-example",
  "code": 1,
  "message": "This is a randomly occurring example diagnostic.",
  "data": [0.7710443792767079],
  "children": [],
  "id": "//@children.1"
}

in which the data is a random number between 0 and 1 that decided whether to report the warning.

Live Validation

This plug-in provider is included in live model validation, also. So if there are any clients subscribed for live validation updates (which also may be accomplished via testing tools like Postman) then executing commands as described in the command providers example should sometimes include this example warning diagnostic in the validation broadcasts.

FAQs

Package last updated on 03 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc