Node Definition

For the front-end to display the newly created node, a node definition has to be created and submitted it to the front-end's node database.

Steps

  1. Create node definition

    1. type; should be set to native

    2. data contains general information about the node

    3. inputs and outputs !!! Note: the node definition uses targets to describe inputs, and sources to describe outputs. Remnants of front-end library which uses the point-of-view of a directional edge, going from a source to a target.

    4. optional: to accept static inputs on the UI, you need to define a form schema.

      We use the JSON Schema to define the form.

      1. build a form here: https://rjsf-team.github.io/react-jsonschema-form/ or here https://ginkgobioworks.github.io/react-json-schema-form-builder/

      2. both JSONSchema and UISchema are needed

  2. Commit node definition to our repo

    https://github.com/space-operator/flow-backend

  3. POST node definition to DB

Sample node definition

{
  "type": "native", // WASM, deno 
  "data": {
    "node_definition_version": "0.1",
    "unique_id": "",
    "node_id": "transfer_sol",
    "version": "0.1",
    "display_name": "Transfer SOL",
    "description": "",
    "tags": [],
    "related_to": [
      {
        "id": "",
        "type": "",
        "relationship": ""
      }
    ],
    "resources": {
      "source_code_url": "",
      "documentation_url": ""
    },
    "usage": {
      "license": "Apache-2.0",
      "license_url": "",
      "pricing": {
        "currency": "USDC",
        "purchase_price": 0,
        "price_per_run": 0,
        "custom": {
          "unit": "monthly",
          "value": "0"
        }
      }
    },
    "authors": [
      {
        "name": "Space Operator",
        "contact": ""
      }
    ],
    "design": {
      "width": 0,
      "height": 0,
      "icon_url": "",
      "backgroundColorDark": "#000000",
      "backgroundColor": "#fff"
    },
    "options": {}
  },
  "sources": [
    {
      "name": "signature",
      "type": "signature",
      "defaultValue": null,
      "tooltip": ""
    }
  ],
  "targets": [
    {
      "name": "sender",
      "type_bounds": ["keypair"],
      "required": true,
      "defaultValue": null,
      "tooltip": "",
      "passthrough": false
    },
    {
      "name": "recipient",
      "type_bounds": ["pubkey"],
      "required": true,
      "defaultValue": null,
      "tooltip": "",
      "passthrough": false
    },
    {
      "name": "amount",
      "type_bounds": ["f64"],
      "required": true,
      "defaultValue": null,
      "tooltip": "",
      "passthrough": false
    },
    {
      "name": "submit",
      "type_bounds": ["bool"],
      "required": false,
      "defaultValue": true,
      "tooltip": "",
      "passthrough": false
    }
  ],
  "targets_form.json_schema": {},
  "targets_form.ui_schema": {}
}

POST node definition to DB

body should be the node definition JSON

https://hyjboblkjeevkzaqsyxe.supabase.co/rest/v1/nodes

Last updated

Was this helpful?