{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "node-schema",
  "title": "Node Json Schema",
  "description": "Structure of the inputs and outputs of the developed nodes",
  "debounce": {
    "title": "Debounce node",
    "input": true,
    "output": true
  },
  "action-audit": {
    "title": "Action audit node",
    "input": {
      "type": "object",
      "properties": {
        "action_or_ack": {
          "description": "Description of an issued action or ack",
          "type": "any",
          "enum": ["action", "ack"]
        }
      }
    },
    "output": {
      "type": "object",
      "properties": {
        "action": {
          "description": "Description of the acknowledged action",
          "type": "any"
        },
        "error": {
          "description": "An error in case of timeout during acknowledgement",
          "type": "String"
        },
        "exception": {
          "description": "Exception message",
          "type": "String"
        }
      }
    }
  },
  "balancing": {
    "title": "Balancing node",
    "input": true,
    "output": true
  },
  "checkpoint": {
    "title": "Checkpoint node",
    "input": true,
    "output": true
  },
  "compensate": {
    "title": "Compensate Node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "number"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "number"
        },
        "confidenceValue": {
          "description": "Confidence value of the message sent",
          "type": "number"
        },
        "timestamp": {
          "description": "Time of when the message was sent",
          "type": "string"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload", "timestamp"]
    }
  },
  "flow-control": {
    "title": "Flow control node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "boolean"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["string", "object"],
          "properties": {
            "flow": {
              "description": "Target flow",
              "type": "string"
            },
            "disabled": {
              "description": "State of the target flow",
              "type": "boolean"
            },
            "required": ["flow", "disabled"]
          }
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    }
  },
  "heartbeat": {
    "title": "Heartbeat Node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "number"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": []
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "object"
        }
      }
    },
    "required": ["payload"]
  },
  "http-aware": {
    "title": "Http aware node",
    "input": true,
    "output": {
      "description": "All valid IPs found in the network",
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "string"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    }
  },
  "kalman-noise-filter": {
    "title": "Kalman noise filter",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["number", "array"]
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["number", "array"]
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    }
  },
  "network-aware": {
    "title": "Network aware node",
    "input": true,
    "output": [
      {
        "description": "All valid devices found in the network",
        "type": "object",
        "properties": {
          "payload": {
            "description": "Value of the message",
            "type": "object",
            "properties": {
              "id": {
                "description": "Device's id",
                "type": "string"
              },
              "ip": {
                "description": "Device's ip",
                "type": "string"
              },
              "name": {
                "description": "Device's name",
                "type": "string"
              },
              "manufacturer": {
                "description": "Device's manufacturer",
                "type": "string"
              },
              "timestamp": {
                "description": "Time of device's reading",
                "type": "string"
              }
            },
            "required": ["id", "ip", "name", "manufacturer", "timestamp"]
          },
          "topic": {
            "description": "Topic of the message",
            "type": "string"
          }
        },
        "required": ["payload"]
      },
      {
        "description": "Devices with invalid MAC adress found in the network",
        "type": "object",
        "properties": {
          "payload": {
            "description": "Value of the message",
            "type": "object",
            "properties": {
              "ip": {
                "description": "Device's ip",
                "type": "string"
              },
              "name": {
                "description": "Device's name",
                "type": "string"
              },
              "manufacturer": {
                "description": "Device's manufacturer",
                "type": "string"
              },
              "timestamp": {
                "description": "Time of device's reading",
                "type": "string"
              }
            },
            "required": ["ip", "name", "manufacturer", "timestamp"]
          },
          "topic": {
            "description": "Topic of the message",
            "type": "string"
          }
        },
        "required": ["payload"]
      }
    ]
  },
  "readings-watcher": {
    "title": "Readings watcher node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "number"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["number", "array"]
        },
        "timestamp": {
          "description": "Time of when the message was sent",
          "type": "string"
        },
        "type": {
          "description": "Error description if exists",
          "type": "string"
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload", "timestamp"]
    }
  },
  "redundancy-manager": {
    "title": "Replication voter node",
    "input": {
      "type": "mqtt output"
    },
    "output": [
      {
        "type": "object",
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "master": {
                "description": "If the node is the master instance or not",
                "type": "boolean"
              }
            },
            "required": ["master"]
          },
          "required": ["payload"]
        }
      },
      {
        "type": "object",
        "properties": {
          "payload": {
            "decription": "List of devices' IP addresses",
            "type": ["array", "string"]
          },
          "required": ["payload"]
        }
      },
      {
        "type": "object",
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "sync": {
                "description": "Sync type",
                "type": "string",
                "value": "ping"
              },
              "master": {
                "description": "If the node is the master instance or not",
                "type": "boolean"
              },
              "hostip": {
                "description": "IP address of the host node",
                "type": "string"
              }
            },
            "required": ["sync", "master", "hostip"]
          },
          "required": ["payload"]
        }
      }
    ]
  },
  "replication-voter": {
    "title": "Replication voter node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["number", "array"]
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["number", "string"]
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    }
  },
  "resource-monitor": {
    "title": "Resource monitor node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": "object",
          "properties": {
            "CPU": {
              "description": "CPU usage maximum value",
              "type": "number"
            },
            "RAM": {
              "description": "RAM usage maximum value",
              "type": "number"
            },
            "storage": {
              "description": "Storage usage maximum value",
              "type": "number"
            },
            "battery": {
              "description": "Battery level minimum value",
              "type": "number"
            }
          }
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": [
      {
        "description": "Overall resources status",
        "type": "object",
        "properties": {
          "payload": {
            "description": "Value of the message",
            "type": "string"
          },
          "type": {
            "description": "Resources out of bounds",
            "type": "object",
            "properties": {
              "CPU": {
                "description": "CPU usage exceeded limit",
                "type": "string"
              },
              "RAM": {
                "description": "RAM usage exceeded limit",
                "type": "string"
              },
              "storage": {
                "description": "Storage exceeded limit",
                "type": "string"
              },
              "battery": {
                "description": "Battery is below limit",
                "type": "string"
              }
            }
          },
          "topic": {
            "description": "Topic of the message",
            "type": "string"
          }
        },
        "required": ["payload"]
      },
      {
        "description": "Specific resource status",
        "type": "object",
        "properties": {
          "payload": {
            "description": "Value of the message",
            "type": "string"
          },
          "topic": {
            "description": "Topic of the message",
            "type": "string"
          }
        },
        "required": ["payload"]
      }
    ]
  },
  "threshold-check": {
    "title": "Threshold check node",
    "input": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["string", "number", "object", "array", "boolean", "null"]
        },
        "topic": {
          "description": "Topic of the message",
          "type": "string"
        }
      },
      "required": ["payload"]
    },
    "output": {
      "type": "object",
      "properties": {
        "payload": {
          "description": "Value of the message",
          "type": ["string", "number", "object", "array", "boolean", "null"]
        },
        "fault": {
          "description": "Explains why the message failed.",
          "type": "string"
        },
        "topic": {
          "description": "Topic of the message.",
          "type": "string"
        }
      },
      "required": ["payload"]
    }
  },
  "timing-check": {
    "title": "Timing check node",
    "input": true,
    "output": true
  },
  "device-registry": {
    "title": "Device Registry node",
    "input": true,
    "output": true
  }
}
