How to use npm package in flow editor frontend

Hi folks,

I need to make my first change in the flow editor, but it already became clear to me that it won't be ready tomorrow ...

Anyway, I need to call $RefParser.dereference (from this npm package) in the flow editor. But not sure how to call a new npm package from the flow editor frontend. I already had a look in the red.js file to see how e.g. jsonata functionality is called, but don't understand it (in my very limited free time) :frowning_face:

  1. Do I need to make the library available (via 'some' existing admin endpoint) to the frontend, and call the dereference function in the frontend?
  2. Do I need to create my own dereferenceJson function (in 'some' existing admin endpoint or in a new dedicated endpoint?), and execute the library function on the server?
  3. ...

Thanks a lot !!!

Not a quick answer I can give via my phone, but the basic approach would be to update the Gruntfile.js to get the browser suitable js file included into vendor.js

However that module doesn't provide a browser suitable module out of the box - it requires using Babel or webpack to generate. We don't currently use any bundler in Node-RED and I'm not very keen to introduce one.

So no quick answer here. Would need some more investigation to understand what that module is for and see if there's a suitable alternative module.

Ok thanks! Will try to find another one...

In a JSON schema you can reuse defintions at multiple locations via a $ref.
Following example shows how use the same json defintion both for billing and shipping addresses:

  "$schema": "",

  "definitions": {
    "address": {
      "type": "object",
      "properties": {
        "street_address": { "type": "string" },
        "city":           { "type": "string" },
        "state":          { "type": "string" }
      "required": ["street_address", "city", "state"]

  "type": "object",

  "properties": {
    "billing_address": { "$ref": "#/definitions/address" },
    "shipping_address": { "$ref": "#/definitions/address" }

The json schema resolver libraries resolve those references, and create one big Javascript object (for the schema) which is easy and fast to use.

Could write my own one (e.g. by starting from this one which is written for NodeJs), however now I'm not sure anymore which way to go ... Because the reference can be an URL to another JSON schema file, which could e.g. be hosted somewhere else. Not sure whether it is a good idea that the flow editor needs to do this kind of stuff...

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.