[ { "id": "587d0d64.709bac", "type": "http in", "z": "51af8c53.929c6c", "name": "", "url": "/schemas/:schema", "method": "get", "upload": false, "swaggerDoc": "", "x": 200, "y": 1220, "wires": [ [ "55807652.b2dd38" ] ] }, { "id": "d222ec97.269898", "type": "http response", "z": "51af8c53.929c6c", "name": "JSON response", "statusCode": "", "headers": { "content-type": "application/json" }, "x": 880, "y": 1180, "wires": [] }, { "id": "eb83d168.8f37b8", "type": "template", "z": "51af8c53.929c6c", "name": "smart-data-models.json", "field": "payload", "fieldType": "msg", "format": "json", "syntax": "plain", "template": "[\n\t{\n\t\t\"description\": \"JSON Schemas for NGSI v2 models in 'Normalized NGSI response representation' (JSON-LD or not) from https://smart-data-models.github.io/data-models/ (https://github.com/smart-data-models/data-models)\",\n\t\t\"query\": \"*.value ? type : false\",\n\t\t\"cases\": {\n\t\t\t\"Alert\": \"https://smart-data-models.github.io/data-models/specs/Alert/alert-schema.json\",\n\t\t\t\"\": \"\"\n\t\t}\n\t},\n\t{\n\t\t\"description\": \"JSON Schemas for NGSI v2 models in 'Simplified representation' from https://fiware.github.io/data-models/ (https://github.com/FIWARE/data-models) and https://smart-data-models.github.io/data-models/ (https://github.com/smart-data-models/data-models)\",\n\t\t\"query\": \"$exists(*.value) ? false : type\",\n\t\t\"cases\": {\n\t\t\t\"AeroAllergenObserved\": \"https://smart-data-models.github.io/data-models/specs/Environment/AeroAllergenObserved/schema.json\",\n\t\t\t\"AgriApp\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriApp/schema.json\",\n\t\t\t\"AgriCrop\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriCrop/schema.json\",\n\t\t\t\"AgriFarm\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriFarm/schema.json\",\n\t\t\t\"AgriGreenhouse\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriGreenhouse/schema.json\",\n\t\t\t\"AgriParcel\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriParcel/schema.json\",\n\t\t\t\"AgriParcelOperation\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriParcelOperation/schema.json\",\n\t\t\t\"AgriParcelRecord\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriParcelRecord/schema.json\",\n\t\t\t\"AgriPest\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriPest/schema.json\",\n\t\t\t\"AgriProductType\": \"https://fiware.github.io/data-models/specs/AgriFood/AgriProductType/schema.json\",\n\t\t\t\"AirQualityObserved\": \"https://smart-data-models.github.io/data-models/specs/Environment/AirQualityObserved/schema.json\",\n\t\t\t\"Alert\": \"https://smart-data-models.github.io/data-models/specs/Alert/schema.json\",\n\t\t\t\"Animal\": \"https://fiware.github.io/data-models/specs/AgriFood/Animal/schema.json\",\n\t\t\t\"ArrivalEstimation\": \"https://fiware.github.io/data-models/specs/UrbanMobility/ArrivalEstimation/schema.json\",\n\t\t\t\"Beach\": \"https://smart-data-models.github.io/data-models/specs/PointOfInterest/Beach/schema.json\",\n\t\t\t\"BikeHireDockingStation\": \"https://smart-data-models.github.io/data-models/specs/Transportation/Bike/BikeHireDockingStation/schema.json\",\n\t\t\t\"Building\": \"https://fiware.github.io/data-models/specs/Building/Building/schema.json\",\n\t\t\t\"BuildingOperation\": \"https://fiware.github.io/data-models/specs/Building/BuildingOperation/schema.json\",\n\t\t\t\"CrowdFlowObserved\": \"https://smart-data-models.github.io/data-models/specs/Transportation/CrowdFlowObserved/schema.json\",\n\t\t\t\"Device\": \"https://smart-data-models.github.io/data-models/specs/Device/Device/schema.json\",\n\t\t\t\"DeviceModel\": \"https://smart-data-models.github.io/data-models/specs/Device/DeviceModel/schema.json\",\n\t\t\t\"EVChargingStation\": \"https://smart-data-models.github.io/data-models/specs/Transportation/EVChargingStation/schema.json\",\n\t\t\t\"FlowerBed\": \"https://fiware.github.io/data-models/specs/ParksAndGardens/FlowerBed/schema.json\",\n\t\t\t\"Garden\": \"https://fiware.github.io/data-models/specs/ParksAndGardens/Garden/schema.json\",\n\t\t\t\"GreenspaceRecord\": \"https://fiware.github.io/data-models/specs/ParksAndGardens/GreenspaceRecord/schema.json\",\n\t\t\t\"GtfsAccessPoint\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsAccessPoint/schema.json\",\n\t\t\t\"GtfsAgency\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsAgency/schema.json\",\n\t\t\t\"GtfsCalendarDateRule\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsCalendarDateRule/schema.json\",\n\t\t\t\"GtfsCalendarRule\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsCalendarRule/schema.json\",\n\t\t\t\"GtfsFrequency\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsFrequency/schema.json\",\n\t\t\t\"GtfsRoute\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsRoute/schema.json\",\n\t\t\t\"GtfsService\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsService/schema.json\",\n\t\t\t\"GtfsShape\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsShape/schema.json\",\n\t\t\t\"GtfsStation\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsStation/schema.json\",\n\t\t\t\"GtfsStop\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsStop/schema.json\",\n\t\t\t\"GtfsStopTime\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsStopTime/schema.json\",\n\t\t\t\"GtfsTransferRule\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsTransferRule/schema.json\",\n\t\t\t\"GtfsTrip\": \"https://fiware.github.io/data-models/specs/UrbanMobility/GtfsTrip/schema.json\",\n\t\t\t\"KeyPerformanceIndicator\": \"https://fiware.github.io/data-models/specs/KeyPerformanceIndicator/schema.json\",\n\t\t\t\"Museum\": \"https://smart-data-models.github.io/data-models/specs/PointOfInterest/Museum/schema.json\",\n\t\t\t\"NoiseLevelObserved\": \"https://smart-data-models.github.io/data-models/specs/Environment/NoiseLevelObserved/schema.json\",\n\t\t\t\"OffStreetParking\": \"https://smart-data-models.github.io/data-models/specs/Parking/OffStreetParking/schema.json\",\n\t\t\t\"OnStreetParking\": \"https://smart-data-models.github.io/data-models/specs/Parking/OnStreetParking/schema.json\",\n\t\t\t\"Open311ServiceRequest\": \"https://fiware.github.io/data-models/specs/IssueTracking/Open311_ServiceRequest/schema.json\",\n\t\t\t\"Open311ServiceType\": \"https://fiware.github.io/data-models/specs/IssueTracking/Open311_ServiceType/schema.json\",\n\t\t\t\"ParkingAccess\": \"https://smart-data-models.github.io/data-models/specs/Parking/ParkingAccess/schema.json\",\n\t\t\t\"ParkingGroup\": \"https://smart-data-models.github.io/data-models/specs/Parking/ParkingGroup/schema.json\",\n\t\t\t\"ParkingSpot\": \"https://smart-data-models.github.io/data-models/specs/Parking/ParkingSpot/schema.json\",\n\t\t\t\"PointOfInterest\": \"https://smart-data-models.github.io/data-models/specs/PointOfInterest/PointOfInterest/schema.json\",\n\t\t\t\"Road\": \"https://smart-data-models.github.io/data-models/specs/Transportation/Road/schema.json\",\n\t\t\t\"RoadSegment\": \"https://smart-data-models.github.io/data-models/specs/Transportation/RoadSegment/schema.json\",\n\t\t\t\"SmartPointOfInteraction\": \"https://fiware.github.io/data-models/specs/PointOfInteraction/SmartPointOfInteraction/schema.json\",\n\t\t\t\"SmartSpot\": \"https://fiware.github.io/data-models/specs/PointOfInteraction/SmartSpot/schema.json\",\n\t\t\t\"Streetlight\": \"https://fiware.github.io/data-models/specs/StreetLighting/Streetlight/schema.json\",\n\t\t\t\"StreetlightControlCabinet\": \"https://fiware.github.io/data-models/specs/StreetLighting/StreetlightControlCabinet/schema.json\",\n\t\t\t\"StreetlightGroup\": \"https://fiware.github.io/data-models/specs/StreetLighting/StreetlightGroup/schema.json\",\n\t\t\t\"StreetlightModel\": \"https://fiware.github.io/data-models/specs/StreetLighting/StreetlightModel/schema.json\",\n\t\t\t\"ThreePhaseAcMeasurement\": \"https://fiware.github.io/data-models/specs/Energy/ThreePhaseAcMeasurement/schema.json\",\n\t\t\t\"TrafficFlowObserved\": \"https://smart-data-models.github.io/data-models/specs/Transportation/TrafficFlowObserved/schema.json\",\n\t\t\t\"UserActivity\": \"https://fiware.github.io/data-models/specs/User/Activity/schema.json\",\n\t\t\t\"UserContext\": \"https://fiware.github.io/data-models/specs/User/UserContext/schema.json\",\n\t\t\t\"Vehicle\": \"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json\",\n\t\t\t\"VehicleModel\": \"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/VehicleModel/schema.json\",\n\t\t\t\"WasteContainer\": \"https://smart-data-models.github.io/data-models/specs/WasteManagement/WasteContainer/schema.json\",\n\t\t\t\"WasteContainerIsle\": \"https://smart-data-models.github.io/data-models/specs/WasteManagement/WasteContainerIsle/schema.json\",\n\t\t\t\"WasteContainerModel\": \"https://smart-data-models.github.io/data-models/specs/WasteManagement/WasteContainerModel/schema.json\",\n\t\t\t\"WaterQualityObserved\": \"https://smart-data-models.github.io/data-models/specs/Environment/WaterQualityObserved/schema.json\",\n\t\t\t\"WeatherForecast\": \"https://smart-data-models.github.io/data-models/specs/Weather/WeatherForecast/schema.json\",\n\t\t\t\"WeatherObserved\": \"https://smart-data-models.github.io/data-models/specs/Weather/WeatherObserved/schema.json\",\n\t\t\t\"\": \"\"\n\t\t}\n\t}\n]\n", "output": "str", "x": 610, "y": 1180, "wires": [ [ "d222ec97.269898" ] ] }, { "id": "24f6fab7.2318f6", "type": "template", "z": "51af8c53.929c6c", "name": "smart-data-transforms.json", "field": "payload", "fieldType": "msg", "format": "json", "syntax": "plain", "template": "[\n\t{\n\t\t\"description\": \"Transformation from NGSI v2 models from 'Normalized response representation' (JSON-LD version partially supported) to 'Simplified representation'\",\n\t\t\"query\": \"type and *.value\",\n\t\t\"cases\": {\n\t\t\t\"true\": \"http://localhost:1880/schemas/NGSI-Normalised-to-keyValues.jsonata.js\"\n\t\t}\n\t},\n\t{\n\t\t\"description\": \"Transformation from Cesva-TA120 to NGSI v2 NoiseLevelObserved in Simplified representation\",\n\t\t\"query\": \"type='Cesva-TA120' and NoiseLevelObserved\",\n\t\t\"cases\": {\n\t\t\t\"true\": \"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/main/examples/Cesva-TA120-to-NoiseLevelObserved.jsonata.js\"\n\t\t}\n\t}\n]\n", "output": "str", "x": 620, "y": 1220, "wires": [ [ "d222ec97.269898" ] ] }, { "id": "55807652.b2dd38", "type": "switch", "z": "51af8c53.929c6c", "name": "", "property": "req.params.schema", "propertyType": "msg", "rules": [ { "t": "eq", "v": "smart-data-models.json", "vt": "str" }, { "t": "eq", "v": "smart-data-transforms.json", "vt": "str" }, { "t": "eq", "v": "NGSI-Normalised-to-keyValues.jsonata.js", "vt": "str" }, { "t": "else" } ], "checkall": "false", "repair": false, "outputs": 4, "x": 390, "y": 1220, "wires": [ [ "eb83d168.8f37b8" ], [ "24f6fab7.2318f6" ], [ "7d37684a.806a" ], [ "81cb0a38.5a15d8" ] ] }, { "id": "81cb0a38.5a15d8", "type": "http response", "z": "51af8c53.929c6c", "name": "", "statusCode": "404", "headers": {}, "x": 560, "y": 1300, "wires": [] }, { "id": "30dff466.fd0104", "type": "http response", "z": "51af8c53.929c6c", "name": "JSONata response", "statusCode": "", "headers": { "content-type": "text/plain" }, "x": 930, "y": 1260, "wires": [] }, { "id": "7d37684a.806a", "type": "template", "z": "51af8c53.929c6c", "name": "NGSI-Normalised-to-keyValues.jsonata.js", "field": "payload", "fieldType": "msg", "format": "text", "syntax": "plain", "template": "/**\n * JSONata for converting from NGSI Normalised format to Simplified representation with key-value pairs.\n *\n * Inspired by https://github.com/FIWARE/data-models/blob/master/tools/normalized2LD.py but reversed.\n *\n * @author Alexandre Alapetite \n * @copyright Alexandra Institute for the SynchroniCity European project as a contribution to FIWARE .\n * @license MIT\n * @date 2019-12-13 / 2019-12-17\n */\n(\n\t$fixObj := function($v, $k) {\n\t\t/* Ensure ISO 8601 date format for minor syntax errors like missing timezone, or produce an error */\n\t\t$v.type = \"DateTime\" and $substring(\"\" & $v.value, -1) != \"Z\" ? { $k: $fromMillis($toMillis($v.value)) } :\n\t\t{ $k: $v.value }\n\t};\n\n\t/* Transform to Simplified structure */\n\t$merge($each($, function($v, $k) {\n\t\t$exists($v.value) ? $fixObj($v, $k) :\n\t\t$exists($v.object) ? { $k: $v.object } :\n\t\t{ $k: $v }\n\t}))\n\n\t/* Replace (i.e. update, delete) some key names */\n\t~> | ** [createdAt] | {\"dateCreated\": createdAt}, [\"createdAt\"] |\n\t~> | ** [modifiedAt] | {\"dateModified\": modifiedAt}, [\"modifiedAt\"] |\n)\n", "output": "str", "x": 660, "y": 1260, "wires": [ [ "30dff466.fd0104" ] ] } ]