diff --git a/.gitignore b/.gitignore index 6548830..bff86b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ fbp-config.json fbp.json +flowhub.json *.tgz node_modules npm-debug.log diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..a2954cf --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,73 @@ +## Changes + +* 2018-08-18: **Version 0.8** + - Moved `secret` from payload to message top-level + - Introduced `requestId` and `responseTo` top-level keys for identifying requests and the response packets to them +* 2018-03-27: + - Added schema for `network:edges` output message + - Modified `subgraph` key of `network:data` and other network packet events to be an array as specified in the text +* 2018-03-26: + - Fixed documentation for `component:setsource` to use `component:source` input, and `component:component` output + - Added schema for `trace:error` message + - Added `:error` output to all capabilities where user can perform actions that may fail +* 2018-03-23: + - Added optional `graph` key to `network:error` payloads +* 2018-03-22: **Version 0.7** + - Added `network:debug` and `network:getstatus` to the `network:control` permission +* 2018-03-21: + - Fixed signature of `runtime:packet.payload`, `runtime:packetsent.payload`, and port definition `default` to accept any payload type + - Added `values` and `default` keys for port definitions + - Added schema for `component:componentsready` output message + - Added schema for `graph:clear` output message + - Added `packetsent` response for `runtime:packet` input message +* 2017-09-17: + - Added `schema` support for ports and packets + - Documented known metadata keys for various graph entities +* 2017-04-09: **Version 0.6** + - Version 0.6. No breaking changes over 0.5. + - Added additional capabilities `graph:readonly`, `network:control`, `network:data`, `network:status`. Especially useful for read-only access. + - Deprecated the `protocol:network` capability in favor of the new fine-gained `network:*` capabilities. + - Each capability now defines the set of messages contained in it. Available as `inputs` and `outputs` in the schema `/shared/capabilities`. +* 2017-05-04: + - Fixed protocol errors (`graph:error`, `component:error` and `runtime:error`) to have mandatory `message` string payload. + - Fixed missing `required` markers in some JSON schemas for `graph` protocol. Affected messages: +`graph:renamegroup`, `graph:renameinport`, `graph:removeinport`, `graph:addinitial`, `graph:changeedge` + - More readable HTML output, including property value types and examples +* 2017-05-03: + - Added more optional metadata to `runtime:runtime` message: `repository`, `repositoryVersion` and `namespace` +* 2017-02-20: + - Fixed payload definition of `network:edges` missing mandatory `graph` key +* 2016-07-01: + - `network:error` payload may now contain an optional `stacktrace` +* 2016-06-23: + - Trace subprotocol also available in machine-readable format +* 2016-06-17: + - Protocol definition available as machine-readable JSON [schemas](https://github.com/flowbased/fbp-protocol/tree/master/schema/yaml). + - The human-readable HTML documentation is generated from this defintion. + - The npm package `fbp-protocol` contains the schemas as YAML, JSON and .js modules. +* 2015-11-20: + - Initial `trace` subprotocol, for [Flowtrace](https://github.com/flowbased/flowtrace) support +* 2015-03-27: + - Documented `network` `persist` and `component` `componentsready` messages +* 2015-03-26: **Version 0.5** + - All messages sent to runtime should include the `secret` in payload + - Runtime description message includes an `allCapabilities` array describing capabilities of the runtime, including ones not available to current user +* 2014-10-23 + - added clarifications to network running state in `status`, `started`, and `stopped` messages +* 2014-09-26 + - Add `secret` as payload to `getruntime` to support [access levels](https://github.com/noflo/noflo-ui/issues/278) +* 2014-08-05: + - Add get, list, graph, graphsdone commands to the graph protocol + - Add list, network commands to the network protocol +* 2014-07-15: + - Add changenode, changeedge, addgroup, removegroup, renamegroup, + changegroup commands to the graph protocol +* 2014-03-13: **Version 0.4** + - Capability discovery support + - Network exported port messaging for remote subgraphs +* 2014-02-18: **Version 0.3** + - Support for exported graph ports +* 2014-01-09: **Version 0.2** + - Multi-graph support via the `graph` key in payload + - Harmonization with [JSON format](http://noflojs.org/documentation/json/) by renaming `from`/`to` in edges to `src`/`tgt` + - Network `edges` message diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 7f4fc01..b7c6188 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -143,15 +143,24 @@ module.exports = -> @registerTask 'default', ['test'] @registerTask 'json-to-js', -> - schemaJs = "module.exports = #{JSON.stringify documentation.getSchemas()}" - fs.writeFileSync './schema/schemas.js', schemaJs, 'utf8' + done = @async() + documentation.getSchemas (err, schemas) -> + return done err if err + schemaJs = "module.exports = #{JSON.stringify schemas}" + fs.writeFileSync './schema/schemas.js', schemaJs, 'utf8' + done() @registerTask 'build-markdown', -> - messages = documentation.renderMessages() - capabilities = documentation.renderCapabilities() - - file = fs.readFileSync 'spec/protocol.js.md', 'utf8' - file = file.replace '<%= messages %>\n', messages - file = file.replace '<%= capabilities %>', capabilities - fs.writeFileSync 'spec/protocol.md', file, 'utf8' + done = @async() + documentation.renderMessages (err, messages) -> + return done err if err + capabilities = documentation.renderCapabilities (err, capabilities) -> + return done err if err + changelog = fs.readFileSync 'CHANGES.md', 'utf8' + file = fs.readFileSync 'spec/protocol.js.md', 'utf8' + file = file.replace '<%= messages %>\n', messages + file = file.replace '<%= capabilities %>', capabilities + file = file.replace '<%= changelog %>', changelog + fs.writeFileSync 'spec/protocol.md', file, 'utf8' + done() diff --git a/package.json b/package.json index 37ee948..8220dba 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "fbp-test": "./bin/fbp-test" }, "scripts": { + "serve": "http-server dist", "test": "grunt test" }, "dependencies": { @@ -37,8 +38,11 @@ "grunt-jekyll": "^0.4.4", "grunt-mocha-test": "^0.13.2", "grunt-yaml": "^0.4.2", + "http-server": "^0.11.1", + "json-schema-ref-parser": "^5.1.2", "noflo-core": "^0.5.0", - "noflo-nodejs": "^0.10.0" + "noflo-nodejs": "^0.10.0", + "uuid": "^3.3.2" }, "main": "./schema/index.js" } diff --git a/schema/yaml/component.yml b/schema/yaml/component.yml index c23fa06..2efba53 100644 --- a/schema/yaml/component.yml +++ b/schema/yaml/component.yml @@ -6,7 +6,7 @@ output: id: 'output/error' description: 'Error response to a command on component protocol' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['component'] @@ -23,7 +23,7 @@ output: id: 'output/component' description: Transmit the metadata about a component instance. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['component'] @@ -50,26 +50,28 @@ output: description: 'boolean telling whether the component is a subgraph' inPorts: description: 'list of input ports of the component' - $ref: '/shared/port_definition' + $ref: '#/shared/port_definition' outPorts: description: 'list of output ports of the component' - $ref: '/shared/port_definition' + $ref: '#/shared/port_definition' componentsready: id: 'output/componentsready' description: Indication that a component listing has finished - properties: - protocol: - enum: ['component'] - type: string - description: 'type of protocol' - command: - enum: ['componentsready'] - description: 'command to be executed' - example: 'addnode' - payload: - type: 'integer' - description: 'number of components transmitted in this batch' - example: 42 + allOf: + - $ref: '#/shared/output_message' + - properties: + protocol: + enum: ['component'] + type: string + description: 'type of protocol' + command: + enum: ['componentsready'] + description: 'command to be executed' + example: 'addnode' + payload: + type: 'integer' + description: 'number of components transmitted in this batch' + example: 42 source: id: 'output/source' @@ -78,7 +80,7 @@ output: message, it should do whatever operations are needed for making that component available for graphs, including possible compilation. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['component'] @@ -116,7 +118,7 @@ input: Request a list of currently available components. Will be responded with a set of `component` messages. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['component'] @@ -124,10 +126,6 @@ input: enum: ['list'] payload: required: [] - properties: - secret: - type: string - description: access token to authorize user getsource: id: 'input/getsource' @@ -135,7 +133,7 @@ input: Request for the source code of a given component. Will be responded with a `source` message. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['component'] @@ -149,9 +147,6 @@ input: type: string description: 'Name of the component to for which to get source code. Should contain the library prefix' example: 'my-project/SomeComponent' - secret: - type: string - description: access token to authorize user source: id: 'input/source' @@ -160,7 +155,7 @@ input: message, it should do whatever operations are needed for making that component available for graphs, including possible compilation. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['component'] @@ -189,5 +184,3 @@ input: tests: type: string description: 'Unit tests for the component' - secret: - type: string diff --git a/schema/yaml/graph.yml b/schema/yaml/graph.yml index e605ed3..c16aea3 100644 --- a/schema/yaml/graph.yml +++ b/schema/yaml/graph.yml @@ -4,123 +4,542 @@ description: >- This protocol is utilized for communicating about graph changes in both directions. +messages: + error: + id: 'messages/error' + properties: + protocol: + enum: ['graph'] + command: + enum: ['error'] + payload: + required: ['message'] + properties: + message: + type: 'string' + description: 'Error message describing what went wrong' + clear: + id: 'messages/clear' + properties: + protocol: + enum: ['graph'] + command: + enum: ['clear'] + payload: + required: ['id'] + additionalProperties: false + properties: + id: + description: 'identifier for the graph being created. Used for all subsequent messages related to the graph instance' + $ref: '#/shared/graph_id' + name: + type: string + description: 'Human-readable label for the graph' + library: + type: string + description: 'Component library identifier' + main: + type: boolean + + description: "Identifies the graph as a main graph of a project that should not be registered as a component\nGraphs registered in this way should also be available for use as subgraphs in other graphs. Therefore a graph registration and later changes to it may cause component messages of the Component protocol to be sent back to the client informing of possible changes in the ports of the subgraph component." + icon: + type: string + description: >- + Icon to use for the graph when used as a component + description: + type: string + description: >- + Description to use for the graph when used as a component + addnode: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addnode'] + payload: + required: ['id', 'component', 'graph'] + additionalProperties: false + properties: + id: + type: string + description: 'identifier for the node' + component: + type: string + description: 'component name used for the node' + metadata: + description: 'structure of key-value pairs for node metadata' + $ref: '#/shared/metadata_node' + graph: { $ref: '#/shared/graph_id' } + removenode: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removenode'] + payload: + required: ['id', 'graph'] + additionalProperties: false + properties: + id: + type: string + description: 'identifier for the node' + graph: { $ref: '#/shared/graph_id' } + renamenode: + properties: + protocol: + enum: ['graph'] + command: + enum: ['renamenode'] + payload: + required: ['from', 'to', 'graph'] + additionalProperties: false + properties: + from: + type: string + description: 'original identifier for the node' + to: + type: string + description: 'new identifier for the node' + graph: { $ref: '#/shared/graph_id' } + changenode: + properties: + protocol: + enum: ['graph'] + command: + enum: ['changenode'] + payload: + required: ['id', 'metadata', 'graph'] + additionalProperties: false + properties: + id: + type: string + description: 'identifier for the node' + metadata: + description: 'structure of key-value pairs for node metadata' + $ref: '#/shared/metadata_node' + graph: { $ref: '#/shared/graph_id' } + addedge: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addedge'] + payload: + required: ['src', 'tgt', 'graph'] + additionalProperties: false + properties: + src: + $ref: '#/shared/port' + description: 'source node for the edge' + tgt: + $ref: '#/shared/port' + description: 'target node for the edge' + metadata: + description: 'Structure of key-value pairs for edge metadata' + $ref: '#/shared/metadata_edge' + graph: { $ref: '#/shared/graph_id' } + removeedge: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removeedge'] + payload: + additionalProperties: false + required: ['graph', 'src', 'tgt'] + properties: + src: + description: 'source node for the edge' + $ref: '#/shared/port' + tgt: + description: 'target node for the edge' + $ref: '#/shared/port' + graph: { $ref: '#/shared/graph_id' } + changeedge: + properties: + protocol: + enum: ['graph'] + command: + enum: ['changeedge'] + payload: + additionalProperties: false + required: ['graph', 'src', 'tgt'] + properties: + metadata: + description: 'struct of key-value pairs for edge metadata' + $ref: '#/shared/metadata_edge' + src: + description: 'source node for the edge' + $ref: '#/shared/port' + tgt: + description: 'target node for the edge' + $ref: '#/shared/port' + graph: { $ref: '#/shared/graph_id' } + addinitial: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addinitial'] + payload: + additionalProperties: false + required: ['graph', 'src', 'tgt'] + properties: + metadata: + type: object + description: 'structure of key-value pairs for IIP metadata' + $ref: '#/shared/metadata_edge' + src: + description: 'source data for the edge' + $ref: '#/shared/iip' + tgt: + description: 'target node/port for the edge' + $ref: '#/shared/port' + graph: { $ref: '#/shared/graph_id' } + removeinitial: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removeinitial'] + payload: + required: ['tgt', 'graph'] + additionalProperties: false + properties: + src: + description: 'IIP data' + $ref: '#/shared/iip' + tgt: + $ref: '#/shared/port' + description: 'target node/port for the edge' + graph: { $ref: '#/shared/graph_id' } + addinport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addinport'] + payload: + additionalProperties: false + required: ['public', 'port', 'node', 'graph'] + properties: + public: + description: 'the exported name of the port' + $ref: '#/shared/port_id' + node: + $ref: '#/shared/node_id' + port: + description: 'internal port name in the graph' + $ref: '#/shared/port_id' + metadata: + description: 'structure of key-value pairs for node metadata' + $ref: '#/shared/metadata_node' + graph: { $ref: '#/shared/graph_id' } + removeinport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removeinport'] + payload: + required: ['public', 'graph'] + additionalProperties: false + properties: + public: + description: 'the exported name of the port to remove' + $ref: '#/shared/port_id' + graph: { $ref: '#/shared/graph_id' } + renameinport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['renameinport'] + payload: + required: ['from', 'to', 'graph'] + additionalProperties: false + properties: + from: + description: 'original exported port name' + $ref: '#/shared/port_id' + to: + description: 'new exported port name' + $ref: '#/shared/port_id' + graph: { $ref: '#/shared/graph_id' } + addoutport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addoutport'] + payload: + required: ['public', 'node', 'port', 'graph'] + additionalProperties: false + properties: + public: + description: 'the exported name of the port' + $ref: '#/shared/port_id' + example: out + node: + description: 'node identifier' + $ref: '#/shared/node_id' + port: + description: 'internal port name' + $ref: '#/shared/port_id' + example: 'out[2]' + metadata: + description: 'structure of key-value pairs for port metadata' + $ref: '#/shared/metadata_node' + graph: { $ref: '#/shared/graph_id' } + removeoutport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removeoutport'] + payload: + required: ['public', 'graph'] + additionalProperties: false + properties: + public: + description: 'the exported name of the port to remove' + $ref: '#/shared/port_id' + example: out + graph: { $ref: '#/shared/graph_id' } + renameoutport: + properties: + protocol: + enum: ['graph'] + command: + enum: ['renameoutport'] + payload: + required: ['from', 'to', 'graph'] + additionalProperties: false + properties: + from: + description: 'original exported port name' + $ref: '#/shared/port_id' + to: + description: 'new exported port name' + $ref: '#/shared/port_id' + graph: { $ref: '#/shared/graph_id' } + addgroup: + properties: + protocol: + enum: ['graph'] + command: + enum: ['addgroup'] + payload: + required: ['name', 'nodes', 'graph'] + additionalProperties: false + properties: + name: + type: string + description: 'the group name' + nodes: + type: array + description: 'an array of node ids part of the group' + items: + $ref: '#/shared/node_id' + metadata: + description: 'structure of key-value pairs for group metadata' + $ref: '#/shared/metadata_group' + graph: { $ref: '#/shared/graph_id' } + removegroup: + properties: + protocol: + enum: ['graph'] + command: + enum: ['removegroup'] + payload: + required: ['name', 'graph'] + additionalProperties: false + properties: + name: + type: string + description: 'the group name' + graph: { $ref: '#/shared/graph_id' } + renamegroup: + properties: + protocol: + enum: ['graph'] + command: + enum: ['renamegroup'] + payload: + required: ['from', 'to', 'graph'] + properties: + from: + type: string + description: 'original group name' + to: + type: string + description: 'new group name' + graph: { $ref: '#/shared/graph_id' } + changegroup: + properties: + protocol: + enum: ['graph'] + command: + enum: ['changegroup'] + payload: + required: ['name', 'metadata', 'graph'] + additionalProperties: false + properties: + name: + type: string + description: 'the group name' + metadata: + description: 'structure of key-value pairs for group metadata' + $ref: '#/shared/metadata_group' + graph: { $ref: '#/shared/graph_id' } + output: error: id: 'output/error' description: 'Error response to a command on graph protocol' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['error'] - payload: - required: ['message'] - properties: - message: - type: 'string' - description: 'Error message describing what went wrong' + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/error' clear: id: 'output/clear' description: 'An empty graph was initialized' - $ref: '../input/clear' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/clear' addnode: id: 'output/addnode' - description: 'Add node to a graph.' - $ref: '../input/addnode' + description: 'A node was added to a graph.' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addnode' removenode: id: 'output/removenode' - description: 'Remove a node from a graph.' - $ref: '../input/removenode' + description: 'A node was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removenode' renamenode: id: 'output/renamenode' - description: 'Change the ID of a node in the graph' - $ref: '../input/renamenode' + description: 'A node was renamed in a graph.' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/renamenode' changenode: id: 'output/changenode' - description: 'Change the metadata associated to a node in the graph' - $ref: '../input/changenode' + description: 'Metadata of a node was changed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/changenode' addedge: id: 'output/addedge' - description: 'Add an edge to the graph' - $ref: '../input/addedge' + description: 'An edge was added to a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addedge' removeedge: id: 'output/removeedge' - description: 'Remove an edge from the graph' - $ref: '../input/removeedge' + description: 'An edge was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removeedge' changeedge: id: 'output/changeedge' - description: 'Change an edge''s metadata' - $ref: '../input/changeedge' + description: 'Metadata of an edge was changed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/changeedge' addinitial: id: 'output/addinitial' - description: 'Add an IIP to the graph' - $ref: '../input/addinitial' + description: 'An IIP was added to a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addinitial' removeinitial: id: 'output/removeinitial' - description: 'Remove an IIP from the graph' - $ref: '../input/removeinitial' + description: 'An IIP was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removeinitial' addinport: id: 'output/addinport' - description: 'Add an exported inport to the graph.' - $ref: '../input/addinport' + description: 'An exported inport was added to a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addinport' removeinport: id: 'output/removeinport' - description: 'Remove an exported port from the graph' - $ref: '../input/removeinport' + description: 'An exported inport was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removeinport' renameinport: id: 'output/renameinport' - description: 'Rename an exported port in the graph' - $ref: '../input/renameinport' + description: 'An exported inport was renamed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/renameinport' addoutport: id: 'output/addoutport' - description: 'Add an exported outport to the graph.' - $ref: '../input/addoutport' + description: 'An exported outport was added to a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addoutport' removeoutport: id: 'output/removeoutport' - description: 'Remove an exported port from the graph' - $ref: '../input/removeoutport' + description: 'An exported outport was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removeoutport' renameoutport: id: 'output/renameoutport' - description: 'Rename an exported port in the graph' - $ref: '../input/renameoutport' + description: 'An exported outport was renamed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/renameoutport' addgroup: id: 'output/addgroup' - description: 'Add a group to the graph' - $ref: '../input/addgroup' + description: 'A group was added to a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/addgroup' removegroup: id: 'output/removegroup' - description: 'Remove a group from the graph' - $ref: '../input/removegroup' + description: 'A group was removed from a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/removegroup' renamegroup: id: 'output/renamegroup' - description: 'Rename a group in the graph.' - $ref: '../input/renamegroup' + description: 'A group was renamed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/renamegroup' changegroup: id: 'output/changegroup' - description: 'Change a group''s metadata' - $ref: '../input/changegroup' + description: 'Metadata of a group was changed in a graph' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/graph/messages/changegroup' input: @@ -128,565 +547,138 @@ input: id: 'input/clear' description: 'Initialize an empty graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['clear'] - payload: - required: ['id'] - additionalProperties: false - properties: - id: - type: string - description: 'identifier for the graph being created. Used for all subsequent messages related to the graph instance' - name: - type: string - description: 'Human-readable label for the graph' - library: - type: string - description: 'Component library identifier' - main: - type: boolean - description: "Identifies the graph as a main graph of a project that should not be registered as a component\nGraphs registered in this way should also be available for use as subgraphs in other graphs. Therefore a graph registration and later changes to it may cause component messages of the Component protocol to be sent back to the client informing of possible changes in the ports of the subgraph component." - icon: - type: string - description: >- - Icon to use for the graph when used as a component - description: - type: string - description: >- - Description to use for the graph when used as a component - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/clear' addnode: id: 'input/addnode' description: 'Add node to a graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addnode'] - payload: - required: ['id', 'component', 'graph'] - additionalProperties: false - properties: - id: - type: string - description: 'identifier for the node' - component: - type: string - description: 'component name used for the node' - metadata: - description: 'structure of key-value pairs for node metadata' - $ref: '/shared/metadata_node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addnode' removenode: id: 'input/removenode' description: 'Remove a node from a graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removenode'] - payload: - required: ['id', 'graph'] - additionalProperties: false - properties: - id: - type: string - description: 'identifier for the node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removenode' renamenode: id: 'input/renamenode' description: 'Change the ID of a node in the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['renamenode'] - payload: - required: ['from', 'to', 'graph'] - additionalProperties: false - properties: - from: - type: string - description: 'original identifier for the node' - to: - type: string - description: 'new identifier for the node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/renamenode' changenode: id: 'input/changenode' description: 'Change the metadata associated to a node in the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['changenode'] - payload: - required: ['id', 'metadata', 'graph'] - additionalProperties: false - properties: - id: - type: string - description: 'identifier for the node' - metadata: - description: 'structure of key-value pairs for node metadata' - $ref: '/shared/metadata_node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/changenode' addedge: id: 'input/addedge' description: 'Add an edge to the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addedge'] - payload: - required: ['src', 'tgt', 'graph'] - additionalProperties: false - properties: - src: - $ref: '/shared/port' - description: 'source node for the edge' - tgt: - $ref: '/shared/port' - description: 'target node for the edge' - metadata: - description: 'Structure of key-value pairs for edge metadata' - $ref: '/shared/metadata_edge' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addedge' removeedge: id: 'input/removeedge' description: 'Remove an edge from the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removeedge'] - payload: - additionalProperties: false - required: ['graph', 'src', 'tgt'] - properties: - graph: - type: string - description: 'graph the action targets' - src: - description: 'source node for the edge' - $ref: '/shared/port' - tgt: - description: 'target node for the edge' - $ref: '/shared/port' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removeedge' changeedge: id: 'input/changeedge' description: 'Change an edge''s metadata' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['changeedge'] - payload: - additionalProperties: false - required: ['graph', 'src', 'tgt'] - properties: - graph: - type: string - description: 'graph the action targets' - metadata: - description: 'struct of key-value pairs for edge metadata' - $ref: '/shared/metadata_edge' - src: - description: 'source node for the edge' - $ref: '/shared/port' - tgt: - description: 'target node for the edge' - $ref: '/shared/port' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/changeedge' addinitial: id: 'input/addinitial' description: 'Add an IIP to the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addinitial'] - payload: - additionalProperties: false - required: ['graph', 'src', 'tgt'] - properties: - graph: - type: string - description: 'graph the action targets' - metadata: - type: object - description: 'structure of key-value pairs for IIP metadata' - $ref: '/shared/metadata_edge' - src: - description: 'source data for the edge' - $ref: '/shared/iip' - tgt: - description: 'target node/port for the edge' - $ref: '/shared/port' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addinitial' removeinitial: id: 'input/removeinitial' description: 'Remove an IIP from the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removeinitial'] - payload: - required: ['tgt', 'graph'] - additionalProperties: false - properties: - src: - description: 'IIP data' - $ref: '/shared/iip' - tgt: - $ref: '/shared/port' - description: 'target node/port for the edge' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removeinitial' addinport: id: 'input/addinport' description: 'Add an exported inport to the graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addinport'] - payload: - additionalProperties: false - required: ['public', 'port', 'node', 'graph'] - properties: - public: - type: string - description: 'the exported name of the port' - node: - type: string - description: 'node identifier' - port: - type: string - description: 'internal port name' - metadata: - description: 'structure of key-value pairs for node metadata' - $ref: '/shared/metadata_node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addinport' removeinport: id: 'input/removeinport' description: 'Remove an exported port from the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removeinport'] - payload: - required: ['public', 'graph'] - additionalProperties: false - properties: - public: - type: string - description: 'the exported name of the port to remove' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removeinport' renameinport: id: 'input/renameinport' description: 'Rename an exported port in the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['renameinport'] - payload: - required: ['from', 'to', 'graph'] - additionalProperties: false - properties: - from: - type: string - description: 'original exported port name' - to: - type: string - description: 'new exported port name' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/renameinport' addoutport: id: 'input/addoutport' description: 'Add an exported outport to the graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addoutport'] - payload: - required: ['public', 'node', 'port', 'graph'] - additionalProperties: false - properties: - public: - type: string - description: 'the exported name of the port' - node: - type: string - description: 'node identifier' - port: - type: string - description: 'internal port name' - metadata: - description: 'structure of key-value pairs for port metadata' - $ref: '/shared/metadata_node' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addoutport' removeoutport: id: 'input/removeoutport' description: 'Remove an exported port from the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removeoutport'] - payload: - required: ['public'] - additionalProperties: false - properties: - public: - type: string - description: 'the exported name of the port to remove' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removeoutport' renameoutport: id: 'input/renameoutport' description: 'Rename an exported port in the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['renameoutport'] - payload: - required: ['from', 'to', 'graph'] - additionalProperties: false - properties: - from: - type: string - description: 'original exported port name' - to: - type: string - description: 'new exported port name' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/renameoutport' addgroup: id: 'input/addgroup' description: 'Add a group to the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['addgroup'] - payload: - required: ['name', 'nodes', 'graph'] - additionalProperties: false - properties: - name: - type: string - description: 'the group name' - nodes: - type: array - description: 'an array of node ids part of the group' - metadata: - description: 'structure of key-value pairs for group metadata' - $ref: '/shared/metadata_group' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/addgroup' removegroup: id: 'input/removegroup' description: 'Remove a group from the graph' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['removegroup'] - payload: - required: ['name', 'graph'] - additionalProperties: false - properties: - name: - type: string - description: 'the group name' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/removegroup' renamegroup: id: 'input/renamegroup' description: 'Rename a group in the graph.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['renamegroup'] - payload: - required: ['from', 'to', 'graph'] - properties: - from: - type: string - description: 'original group name' - to: - type: string - description: 'new group name' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/renamegroup' changegroup: id: 'input/changegroup' description: 'Change a group''s metadata' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['graph'] - command: - enum: ['changegroup'] - payload: - required: ['name', 'metadata', 'graph'] - additionalProperties: false - properties: - name: - type: string - description: 'the group name' - metadata: - description: 'structure of key-value pairs for group metadata' - $ref: '/shared/metadata_group' - graph: - type: string - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user - + - $ref: '#/shared/input_message' + - $ref: '#/graph/messages/changegroup' diff --git a/schema/yaml/network.yml b/schema/yaml/network.yml index 25c93a1..354fb66 100644 --- a/schema/yaml/network.yml +++ b/schema/yaml/network.yml @@ -9,7 +9,7 @@ output: id: 'output/stopped' description: 'Inform that a given network has stopped.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -26,9 +26,7 @@ output: uptime: type: number description: 'time the network was running, in seconds' - graph: - type: "string" - description: 'graph the action targets' + graph: { $ref: '#/shared/graph_id' } running: type: boolean description: 'whether or not network is currently running' @@ -43,7 +41,7 @@ output: id: 'output/started' description: 'Inform that a given network has been started.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -57,9 +55,7 @@ output: type: "string" format: "date-time" description: 'time when the network was started' - graph: - type: "string" - description: 'graph the action targets' + graph: { $ref: '#/shared/graph_id' } started: type: "boolean" description: 'whether or not network has started running' @@ -74,7 +70,7 @@ output: id: 'output/status' description: 'Response to a getstatus message.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -84,9 +80,7 @@ output: required: ['running', 'graph'] additionalProperties: false properties: - graph: - type: string - description: 'graph the action targets' + graph: { $ref: '#/shared/graph_id' } uptime: type: number description: 'time the network has been running, in seconds' @@ -107,7 +101,7 @@ output: of a Unix process, or a line of console.log in JavaScript. Output can also be used for passing images from the runtime to the UI.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -135,7 +129,7 @@ output: An error from a running network, roughly similar to STDERR output of a Unix process, or a line of console.error in JavaScript.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -151,16 +145,14 @@ output: stack: description: 'stack trace' type: 'string' - graph: - type: string - description: graph the action targets + graph: { $ref: '#/shared/graph_id' } processerror: id: 'output/processerror' description: >- When in debug mode, a network can signal an error happening inside a process. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -171,20 +163,17 @@ output: additionalProperties: false properties: id: - type: string - description: identifier of the node + $ref: '#/shared/node_id' error: type: string description: error from the component - graph: - type: string - description: graph the action targets + graph: { $ref: '#/shared/graph_id' } icon: id: 'output/icon' description: 'Icon of a component instance has changed.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -195,34 +184,31 @@ output: additionalProperties: false properties: id: - type: "string" - description: 'identifier of the node' + $ref: '#/shared/node_id' icon: type: "string" description: 'new icon for the component instance' - graph: - type: "string" - description: 'graph the action targets' + graph: { $ref: '#/shared/graph_id' } connect: id: 'output/connect' description: 'Beginning of transmission on an edge.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] command: enum: ['connect'] payload: - $ref: '/shared/network_event' + $ref: '#/shared/network_event' additionalProperties: false begingroup: id: 'output/begingroup' description: 'Beginning of a group (bracket IP) on an edge.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -230,7 +216,7 @@ output: enum: ['begingroup'] payload: allOf: - - $ref: '/shared/network_event' + - $ref: '#/shared/network_event' - required: ['group'] properties: group: @@ -249,7 +235,7 @@ output: id: 'output/data' description: 'Data transmission on an edge.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -257,7 +243,7 @@ output: enum: ['data'] payload: allOf: - - $ref: '/shared/network_event' + - $ref: '#/shared/network_event' - required: ['data'] properties: data: @@ -286,7 +272,7 @@ output: id: 'output/endgroup' description: 'Ending of a group (bracket IP) on an edge.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] @@ -294,7 +280,7 @@ output: enum: ['endgroup'] payload: allOf: - - $ref: '/shared/network_event' + - $ref: '#/shared/network_event' - required: ['group'] properties: group: @@ -313,14 +299,14 @@ output: id: 'output/disconnect' description: 'End of transmission on an edge.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['network'] command: enum: ['disconnect'] payload: - $ref: '/shared/network_event' + $ref: '#/shared/network_event' additionalProperties: false edges: @@ -328,7 +314,7 @@ output: description: >- List of edges user has selected for inspection in a user interface or debugger, sent from runtime to UI. - $ref: '../input/edges' + $ref: '#/network/input/edges' input: @@ -336,7 +322,7 @@ input: id: 'input/start' description: 'Start execution of a FBP network based on a given graph.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -346,12 +332,7 @@ input: required: ['graph'] additionalProperties: false properties: - graph: - type: "string" - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + graph: { $ref: '#/shared/graph_id' } getstatus: id: 'input/getstatus' @@ -359,7 +340,7 @@ input: Get the current status of the runtime. The runtime should respond with a status message. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -369,18 +350,13 @@ input: required: ['graph'] additionalProperties: false properties: - graph: - type: "string" - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + graph: { $ref: '#/shared/graph_id' } stop: id: 'input/stop' description: 'Stop execution of a FBP network based on a given graph.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -390,12 +366,7 @@ input: required: ['graph'] additionalProperties: false properties: - graph: - type: "string" - description: 'graph the action targets' - secret: - type: string - description: access token to authorize user + graph: { $ref: '#/shared/graph_id' } persist: id: 'input/persist' @@ -404,7 +375,7 @@ input: so that they are available between restarts. Requires the network:persist capability. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -414,15 +385,12 @@ input: required: [] additionalProperties: false properties: - secret: - type: string - description: access token to authorize user debug: id: 'input/debug' description: Set a network into debug mode allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -435,12 +403,7 @@ input: enable: description: tells whether to put the network in debug mode type: boolean - graph: - description: graph the action targets - type: string - secret: - description: access token to authorize the user - type: string + graph: { $ref: '#/shared/graph_id' } edges: id: 'input/edges' @@ -448,7 +411,7 @@ input: List of edges user has selected for inspection in a user interface or debugger, sent from UI to a runtime. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['network'] @@ -458,9 +421,6 @@ input: required: ['graph', 'edges'] additionalProperties: false properties: - graph: - description: graph the action targets - type: string edges: type: array description: 'list of selected edges' @@ -471,11 +431,8 @@ input: properties: src: description: 'source node for the edge' - $ref: '/shared/port' + $ref: '#/shared/port' tgt: description: 'target node for the edge' - $ref: '/shared/port' - secret: - type: string - description: access token to authorize user - + $ref: '#/shared/port' + graph: { $ref: '#/shared/graph_id' } diff --git a/schema/yaml/runtime.yml b/schema/yaml/runtime.yml index 2dcb501..908e679 100644 --- a/schema/yaml/runtime.yml +++ b/schema/yaml/runtime.yml @@ -13,7 +13,7 @@ input: able to speak the full Runtime protocol, it should follow up with a ports message. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['runtime'] @@ -24,7 +24,7 @@ input: properties: secret: type: string - description: access token to authorize user + description: access token to authorize the client. Provided also in payload for compatibility with older runtimes packet: id: 'input/packet' @@ -36,7 +36,7 @@ input: These packets can be send from the client to the runtimes input ports, or from runtimes output ports to the client. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['runtime'] @@ -47,8 +47,7 @@ input: additionalProperties: false properties: port: - type: string - description: 'port name for the input or output port' + $ref: '#/shared/port_id' event: type: string enum: @@ -67,23 +66,18 @@ input: format: uri description: 'Link to JSON schema describing the format of the data' example: 'https://example.net/schemas/person.json' - graph: - type: string - description: 'graph the action targets' payload: description: >- payload for the packet. Used only with begingroup (for group names) and data packets - secret: - type: string - description: access token to authorize user + graph: { $ref: '#/shared/graph_id' } output: error: id: 'output/error' description: 'Error response to a command on runtime protocol' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['runtime'] @@ -103,7 +97,7 @@ output: is responsible for sending the up-to-date list of available ports back to client whenever it changes. allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['runtime'] @@ -113,23 +107,19 @@ output: required: ['graph', 'inPorts', 'outPorts'] additionalProperties: false properties: - graph: - type: string - description: >- - ID of the currently configured main graph running on the - runtime inPorts: description: 'list of input ports of the runtime' - $ref: '/shared/port_definition' + $ref: '#/shared/port_definition' outPorts: description: 'list of output ports of the runtime' - $ref: '/shared/port_definition' + $ref: '#/shared/port_definition' + graph: { $ref: '#/shared/graph_id' } runtime: id: 'output/runtime' description: 'Response from the runtime to the getruntime request.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['runtime'] @@ -155,17 +145,18 @@ output: description: >- capability strings for things the runtime is able to do. May include things not permitted for this client. - $ref: '/shared/capabilities' + $ref: '#/shared/capabilities' capabilities: description: >- capability strings for things the runtime is able to do for this client. - $ref: '/shared/capabilities' + $ref: '#/shared/capabilities' graph: description: >- ID of the currently configured main graph running on the runtime, if any type: string example: 'service-main' + $ref: '#/shared/graph_id' type: description: 'type of the runtime' type: string @@ -193,7 +184,7 @@ output: id: 'output/packetsent' description: Confirmation that a packet has been sent allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['runtime'] @@ -204,8 +195,8 @@ output: additionalProperties: false properties: port: - type: string description: 'port name for the input port' + $ref: '#/shared/port_id' event: type: string enum: @@ -224,13 +215,11 @@ output: format: uri description: 'Link to JSON schema describing the format of the data' example: 'https://example.net/schemas/person.json' - graph: - type: string - description: 'graph the action targeted' payload: description: >- payload for the packet. Used only with begingroup (for group names) and data packets + graph: { $ref: '#/shared/graph_id' } packet: id: 'output/packet' @@ -241,4 +230,4 @@ output: These packets can be send from the client to the runtimes input ports, or from runtimes output ports to the client. - $ref: '../input/packet' + $ref: '#/runtime/input/packet' diff --git a/schema/yaml/shared.yml b/schema/yaml/shared.yml index aecf101..d812a08 100644 --- a/schema/yaml/shared.yml +++ b/schema/yaml/shared.yml @@ -2,18 +2,54 @@ $schema: 'http://json-schema.org/draft-04/schema#' title: 'Shared' description: 'Shared schema fragments' -secret: - id: secret - description: access token to authorize the client - type: string graph_id: id: graph_id description: Graph identifier the message targets type: string -message: +node_id: + id: node_id + description: Node identifier in a graph + type: string + example: Repeat + +port_id: + id: port_id + description: Port identifier in a component or process + type: string + example: in + +input_message: + id: 'message' + description: 'protocol message sent by a client' + additionalProperties: false + required: ['protocol', 'command', 'payload', 'requestId'] + properties: + protocol: + type: string + description: 'type of protocol' + example: 'graph' + command: + type: string + description: 'command to be executed' + example: 'addnode' + payload: + type: object + description: 'content of message' + properties: + secret: + type: string + description: access token to authorize the client. Legacy location, use toplevel secret instead + secret: + type: string + description: access token to authorize the client + requestId: + type: string + description: unique request identifier + +output_message: id: 'message' - description: 'protocol message' + description: 'protocol message sent by a runtime' additionalProperties: false required: ['protocol', 'command', 'payload'] properties: @@ -28,6 +64,9 @@ message: payload: type: object description: 'content of message' + responseTo: + type: string + description: unique identifier of the request message is response to metadata_node: id: 'metadata_node' @@ -79,11 +118,9 @@ port: additionalProperties: false properties: node: - type: string - description: 'node identifier' + $ref: '#/shared/node_id' port: - type: string - description: 'port name' + $ref: '#/shared/port_id' index: type: ["string", "number"] description: 'connection index, for addressable ports' @@ -97,8 +134,7 @@ port_definition: additionalProperties: false properties: id: - type: string - description: 'port name' + $ref: '#/shared/port_id' type: description: 'port datatype' type: string @@ -148,20 +184,19 @@ network_event: a FBP language line src: description: 'source node for the edge' - $ref: '/shared/port' + $ref: '#/shared/port' tgt: description: 'target node for the edge' - $ref: '/shared/port' + $ref: '#/shared/port' graph: - type: 'string' - description: 'graph the action targets' + $ref: '#/shared/graph_id' subgraph: type: 'array' description: >- Subgraph identifier for the event. An array of node IDs. items: - type: string + $ref: '#/shared/node_id' capabilities: id: 'capabilities' diff --git a/schema/yaml/trace.yml b/schema/yaml/trace.yml index f6611e4..cc1548c 100644 --- a/schema/yaml/trace.yml +++ b/schema/yaml/trace.yml @@ -4,25 +4,67 @@ description: >- This protocol is utilized for triggering and transmitting [Flowtrace](https://github.com/flowbased/flowtrace)s -output: +messages: + start: + properties: + protocol: + enum: ['trace'] + command: + enum: ['start'] + payload: + required: ['graph'] + additionalProperties: false + properties: + graph: { $ref: '#/shared/graph_id' } + buffersize: + description: 'Size of tracing buffer to keep. In bytes' + type: integer + stop: + properties: + protocol: + enum: ['trace'] + command: + enum: ['stop'] + payload: + required: ['graph'] + additionalProperties: false + properties: + graph: { $ref: '#/shared/graph_id' } + clear: + properties: + protocol: + enum: ['trace'] + command: + enum: ['clear'] + payload: + required: ['graph'] + additionalProperties: false + properties: + graph: { $ref: '#/shared/graph_id' } +output: start: id: 'output/start' description: 'Tracing was started' - $ref: '../input/start' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/trace/messages/start' stop: id: 'output/stop' description: 'Tracing was stopped' - $ref: '../input/stop' + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/trace/messages/stop' clear: id: 'output/clear' description: 'Tracing buffer was cleared' - $ref: '../input/clear' - + allOf: + - $ref: '#/shared/output_message' + - $ref: '#/trace/messages/clear' dump: id: 'output/dump' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['trace'] @@ -32,7 +74,7 @@ output: required: ['graph', 'type', 'flowtrace'] additionalProperties: false properties: - graph: { $ref: '/shared/graph_id' } + graph: { $ref: '#/shared/graph_id' } type: description: String describing type of trace. type: string @@ -40,12 +82,11 @@ output: flowtrace: description: A Flowtrace file of `type` type: string - error: id: 'output/error' description: 'Error response to a command on trace protocol' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/output_message' - properties: protocol: enum: ['trace'] @@ -63,55 +104,31 @@ input: id: 'input/start' description: 'Enable/start tracing of a network.' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['trace'] - command: - enum: ['start'] - payload: - required: ['secret', 'graph'] - additionalProperties: false - properties: - secret: { $ref: '/shared/secret' } - graph: { $ref: '/shared/graph_id' } - buffersize: - description: 'Size of tracing buffer to keep. In bytes' - type: integer + - $ref: '#/shared/input_message' + - $ref: '#/trace/messages/start' stop: description: 'Stop/disable tracing of a network.' id: 'input/stop' allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['trace'] - command: - enum: ['stop'] - payload: - required: ['secret', 'graph'] - additionalProperties: false - properties: - secret: { $ref: '/shared/secret' } - graph: { $ref: '/shared/graph_id' } + - $ref: '#/shared/input_message' + - $ref: '#/trace/messages/stop' dump: id: 'input/dump' description: 'Trigger dumping of the current tracing buffer, to return it back to server.' allOf: - - $ref: '/shared/message' + - $ref: '#/shared/input_message' - properties: protocol: enum: ['trace'] command: enum: ['dump'] payload: - required: ['secret', 'graph', 'type'] + required: ['graph', 'type'] additionalProperties: false properties: - secret: { $ref: '/shared/secret' } - graph: { $ref: '/shared/graph_id' } + graph: { $ref: '#/shared/graph_id' } type: description: Type/format of trace to output type: string @@ -121,15 +138,5 @@ input: id: 'input/clear' description: Clear current tracing buffer. allOf: - - $ref: '/shared/message' - - properties: - protocol: - enum: ['trace'] - command: - enum: ['clear'] - payload: - required: ['secret', 'graph'] - additionalProperties: false - properties: - secret: { $ref: '/shared/secret' } - graph: { $ref: '/shared/graph_id' } + - $ref: '#/shared/input_message' + - $ref: '#/trace/messages/clear' diff --git a/spec/protocol.js.md b/spec/protocol.js.md index d9f58e8..724b2fc 100644 --- a/spec/protocol.js.md +++ b/spec/protocol.js.md @@ -31,77 +31,6 @@ Some [examples](https://github.com/flowbased/protocol-examples) have also been c The [fbp-protocol](https://github.com/flowbased/fbp-protocol) tool provides a set of tests for FBP protocol implementations. -## Changes - -* 2018-03-27: - - Added schema for `network:edges` output message - - Modified `subgraph` key of `network:data` and other network packet events to be an array as specified in the text -* 2018-03-26: - - Fixed documentation for `component:setsource` to use `component:source` input, and `component:component` output - - Added schema for `trace:error` message - - Added `:error` output to all capabilities where user can perform actions that may fail -* 2018-03-23: - - Added optional `graph` key to `network:error` payloads -* 2018-03-22: **Version 0.7** - - Added `network:debug` and `network:getstatus` to the `network:control` permission -* 2018-03-21: - - Fixed signature of `runtime:packet.payload`, `runtime:packetsent.payload`, and port definition `default` to accept any payload type - - Added `values` and `default` keys for port definitions - - Added schema for `component:componentsready` output message - - Added schema for `graph:clear` output message - - Added `packetsent` response for `runtime:packet` input message -* 2017-09-17: - - Added `schema` support for ports and packets - - Documented known metadata keys for various graph entities -* 2017-04-09: **Version 0.6** - - Version 0.6. No breaking changes over 0.5. - - Added additional capabilities `graph:readonly`, `network:control`, `network:data`, `network:status`. Especially useful for read-only access. - - Deprecated the `protocol:network` capability in favor of the new fine-gained `network:*` capabilities. - - Each capability now defines the set of messages contained in it. Available as `inputs` and `outputs` in the schema `/shared/capabilities`. -* 2017-05-04: - - Fixed protocol errors (`graph:error`, `component:error` and `runtime:error`) to have mandatory `message` string payload. - - Fixed missing `required` markers in some JSON schemas for `graph` protocol. Affected messages: -`graph:renamegroup`, `graph:renameinport`, `graph:removeinport`, `graph:addinitial`, `graph:changeedge` - - More readable HTML output, including property value types and examples -* 2017-05-03: - - Added more optional metadata to `runtime:runtime` message: `repository`, `repositoryVersion` and `namespace` -* 2017-02-20: - - Fixed payload definition of `network:edges` missing mandatory `graph` key -* 2016-07-01: - - `network:error` payload may now contain an optional `stacktrace` -* 2016-06-23: - - Trace subprotocol also available in machine-readable format -* 2016-06-17: - - Protocol definition available as machine-readable JSON [schemas](https://github.com/flowbased/fbp-protocol/tree/master/schema/yaml). - - The human-readable HTML documentation is generated from this defintion. - - The npm package `fbp-protocol` contains the schemas as YAML, JSON and .js modules. -* 2015-11-20: - - Initial `trace` subprotocol, for [Flowtrace](https://github.com/flowbased/flowtrace) support -* 2015-03-27: - - Documented `network` `persist` and `component` `componentsready` messages -* 2015-03-26: **Version 0.5** - - All messages sent to runtime should include the `secret` in payload - - Runtime description message includes an `allCapabilities` array describing capabilities of the runtime, including ones not available to current user -* 2014-10-23 - - added clarifications to network running state in `status`, `started`, and `stopped` messages -* 2014-09-26 - - Add `secret` as payload to `getruntime` to support [access levels](https://github.com/noflo/noflo-ui/issues/278) -* 2014-08-05: - - Add get, list, graph, graphsdone commands to the graph protocol - - Add list, network commands to the network protocol -* 2014-07-15: - - Add changenode, changeedge, addgroup, removegroup, renamegroup, - changegroup commands to the graph protocol -* 2014-03-13: **Version 0.4** - - Capability discovery support - - Network exported port messaging for remote subgraphs -* 2014-02-18: **Version 0.3** - - Support for exported graph ports -* 2014-01-09: **Version 0.2** - - Multi-graph support via the `graph` key in payload - - Harmonization with [JSON format](http://noflojs.org/documentation/json/) by renaming `from`/`to` in edges to `src`/`tgt` - - Network `edges` message - ## Basics The FBP protocol is a message-based protocol that can be handled using various different transport mechanisms. The messages are designed to be independent, and not to form a request-response cycle in order to allow highly asynchronous operations and situations where multiple protocol clients talk with the same runtime. @@ -114,6 +43,63 @@ There are currently three transports utilized commonly: Different transports can be utilized as needed. It could be interesting to implement the FBP protocol using [MQTT](http://en.wikipedia.org/wiki/MQ_Telemetry_Transport), for instance. +### Message structure + +There are three types of messages in FBP Protocol: + +1. Requests sent by client to runtime +2. Responses sent by runtime to client +3. Events sent by runtime to client unrelated to any request + +This document describes all messages as the data structures that are passed. The way these are encoded depends on the transport being used. For example, with WebSockets all messages are encoded as stringified JSON. + +All messages consist of three parts: + +* Sub-protocol identifier (`graph`, `component`, or `network`) +* Topic (for example, `addnode`) +* Message payload (typically a data structure specific to the sub-protocol and topic) + +Additionally requests made by clients include a unique `requestId` and optionally a `secret`. Responses sent by runtime include a `responseTo` referring to a request ID. Runtimes may also send messages on events that happen on the runtime without referring to a request ID. + +The keys listed in specific messages are for the message `payload`. + +An example message sent by a client: + +```json +{ + "protocol": "graph", + "command": "addnode", + "payload": { + "component": "canvas/Draw", + "graph": "hello-canvas-example", + "id": "draw", + "metadata": { + "label": "Draw onto canvas element" + } + }, + "secret": "fbp rocks", + "requestId: "10259710-bc70-4d2c-b0b3-e78075d9b960" +} +``` + +Response to this could look like: + +```json +{ + "protocol": "graph", + "command": "addnode", + "payload": { + "component": "canvas/Draw", + "graph": "hello-canvas-example", + "id": "draw", + "metadata": { + "label": "Draw onto canvas element" + } + }, + "responseTo: "10259710-bc70-4d2c-b0b3-e78075d9b960" +} +``` + ### Sub-protocols The FBP protocol is divided into sub-protocols for each of the major resources that can be manipulated: @@ -134,31 +120,6 @@ A few commands do not require any capabilities: the runtime info request/respons <%= capabilities %> -### Message structure - -This document describes all messages as the data structures that are passed. The way these are encoded depends on the transport being used. For example, with WebSockets all messages are encoded as stringified JSON. - -All messages consist of three parts: - -* Sub-protocol identifier (`graph`, `component`, or `network`) -* Topic (for example, `addnode`) -* Message payload (typically a data structure specific to the sub-protocol and topic) - -The keys listed in specific messages are for the message `payload`. - -An example message -``` -"protocol": "graph", -"command": "addnode", -"payload": { - "component": "canvas/Draw", - "graph": "hello-canvas-example", - "id": "draw", - "metadata": { - "label": "Draw onto canvas element" - } -} -``` - <%= messages %> +<%= changelog %> diff --git a/src/Documentation.coffee b/src/Documentation.coffee index 2a902a4..5d83a3e 100644 --- a/src/Documentation.coffee +++ b/src/Documentation.coffee @@ -1,8 +1,9 @@ fs = require 'fs' path = require 'path' +refParser = require 'json-schema-ref-parser' schemas = null -getSchemas = -> +getSchemas = (callback) -> unless schemas schemas = {} dir = './schema/json/' @@ -12,34 +13,10 @@ getSchemas = -> filename = path.join dir, jsonFile schema = JSON.parse fs.readFileSync filename schemas[name] = schema - - return schemas - -fillRefs = (obj, baseUrl) -> - tv4 = require '../schema/index.js' - - if typeof obj isnt 'object' - return obj - - else if (typeof obj) is 'object' and obj.length? - return obj.map (item) -> fillRefs item, baseUrl - - newObj = {} - for own key, value of obj - if key is '$ref' - schemaPath = value - if schemaPath.indexOf('../') isnt -1 - schemaPath = path.resolve path.dirname("#{baseUrl}#{obj.id}"), value - refObj = fillRefs tv4.getSchema(schemaPath), baseUrl - for own refKey, refValue of refObj - newObj[refKey] = refValue - - else - newObj[key] = fillRefs value, baseUrl - - return newObj + refParser.dereference schemas, callback mergeAllOf = (obj) -> + return obj unless obj unless typeof obj is "object" and not obj.length? return obj @@ -50,11 +27,7 @@ mergeAllOf = (obj) -> for propName, prop of mergeObj newObj[propName] ?= prop - else if typeof value is "object" and not value.length? - newObj[key] = mergeAllOf value - - else - newObj[key] = value + newObj[key] = mergeAllOf value return newObj @@ -78,7 +51,6 @@ getDescriptions = (schemas) -> for category in categories for event, schema of schemas[protocol][category] - schema = fillRefs schema, "/#{protocol}/" message = id: schema.id description: schema.description @@ -95,10 +67,8 @@ getDescriptions = (schemas) -> return desc isAllowedTypeless = (name, parent) -> - return true if parent.id is '/shared/port_definition' and name is 'default' - return true if parent.id is '/runtime/input/packet' and name is 'payload' + return true if parent.id is 'port_definition' and name is 'default' return true if parent.id is 'input/packet' and name is 'payload' - return true if parent.id is '/runtime/output/packet' and name is 'payload' return true if parent.id is 'output/packet' and name is 'payload' return true if parent.id is 'output/packetsent' and name is 'payload' false @@ -121,6 +91,10 @@ renderProperty = (name, def, parent) -> classes += " optional" if isOptional name = "" type = "" + + if def.enum?.length + def.description += " (one of: #{def.enum.join(', ')})" + description = "" example = "" example = "#{JSON.stringify(def.example)}" if def.example? @@ -203,22 +177,23 @@ renderCapabilities = () -> return lines.join('\n') -renderMessages = () -> - schemas = getSchemas() - descriptions = getDescriptions schemas +renderMessages = (callback) -> + getSchemas (err, schemas) -> + return callback err if err + descriptions = getDescriptions schemas - lines = [] - p = (line) -> lines.push line + lines = [] + p = (line) -> lines.push line - for protocol, protocolProps of descriptions - p "

#{protocolProps.title}

" - p "

#{protocolProps.description}

" + for protocol, protocolProps of descriptions + p "

#{protocolProps.title}

" + p "

#{protocolProps.description}

" - for messageType, message of protocolProps.messages - m = renderMessage messageType, message, protocol - lines = lines.concat m + for messageType, message of protocolProps.messages + m = renderMessage messageType, message, protocol + lines = lines.concat m - return lines.join('\n') + callback null, lines.join('\n') module.exports = renderMessages: renderMessages diff --git a/src/WebSocket.coffee b/src/WebSocket.coffee index b57fdd8..b0bfe29 100644 --- a/src/WebSocket.coffee +++ b/src/WebSocket.coffee @@ -59,11 +59,13 @@ exports.testRuntime = (runtimeType, startServer, stopServer, host='localhost', p send = (protocol, command, payload) -> payload = {} unless payload - payload.secret = process.env.FBP_PROTOCOL_SECRET if process.env.FBP_PROTOCOL_SECRET + # FIXME: Remove from payload once runtimes are on 0.8 + payload.secret = process.env.FBP_PROTOCOL_SECRET connection.sendUTF JSON.stringify protocol: protocol command: command payload: payload + secret: process.env.FBP_PROTOCOL_SECRET messageMatches = (msg, expected) -> return false unless msg.protocol is expected.protocol @@ -79,9 +81,14 @@ exports.testRuntime = (runtimeType, startServer, stopServer, host='localhost', p data = JSON.parse message.utf8Data chai.expect(data.protocol).to.be.a 'string' chai.expect(data.command).to.be.a 'string' + + # FIXME: Remove once runtimes are on 0.8 + delete data.payload.secret + # Validate all received packets against schema validateSchema data, getPacketSchema data # Don't ever expect payloads to return a secret + chai.expect(data.secret, 'Message should not contain secret').to.be.a 'undefined' chai.expect(data.payload.secret, 'Payload should not contain secret').to.be.a 'undefined' if allowExtraPackets and not messageMatches data, expects[0] # Ignore messages we don't care about in context of the test @@ -109,8 +116,10 @@ exports.testRuntime = (runtimeType, startServer, stopServer, host='localhost', p delete data.payload.stack delete expected.payload.stack - # Don't ever expect payloads to return a secret + # FIXME: Remove once runtimes are on 0.8 delete expected.payload.secret + # Don't ever expect payloads to return a secret + delete expected.secret chai.expect(data.payload).to.eql expected.payload # Received all expected packets diff --git a/test/schema/test_component.coffee b/test/schema/test_component.coffee index 72c238d..0650210 100644 --- a/test/schema/test_component.coffee +++ b/test/schema/test_component.coffee @@ -1,6 +1,7 @@ chai = require 'chai' schemas = require '../../schema/schemas.js' tv4 = require 'tv4' +uuid = require 'uuid/v4' describe 'Test component protocol schema on event', -> before -> @@ -78,6 +79,7 @@ describe 'Test component protocol schema on event', -> protocol: 'component' command: 'list' payload: {} + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true @@ -94,6 +96,7 @@ describe 'Test component protocol schema on event', -> command: 'getsource' payload: name: 'component1' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true @@ -112,7 +115,7 @@ describe 'Test component protocol schema on event', -> name: 'component1' language: 'coffeescript' code: '-> console.log Array.prototype.slice.call arguments' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true - diff --git a/test/schema/test_graph.coffee b/test/schema/test_graph.coffee index 5d4d903..00eacc7 100644 --- a/test/schema/test_graph.coffee +++ b/test/schema/test_graph.coffee @@ -1,6 +1,7 @@ chai = require 'chai' schemas = require '../../schema/schemas.js' tv4 = require 'tv4' +uuid = require 'uuid/v4' describe 'Test graph protocol schema on event', -> before -> @@ -27,6 +28,7 @@ describe 'Test graph protocol schema on event', -> id: 'node1' component: 'core/Kick' graph: 'mygraph' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true @@ -40,6 +42,7 @@ describe 'Test graph protocol schema on event', -> component: 'core/Kick' graph: 'mygraph' whatisthis: 'notallowed' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.false @@ -51,6 +54,7 @@ describe 'Test graph protocol schema on event', -> id: 'node1' component: 'core/Kick' graph: 'mygraph' + requestId: uuid() res = tv4.validate event, schema @@ -63,6 +67,7 @@ describe 'Test graph protocol schema on event', -> id: 'node1' component: 'core/Kick' graph: 'mygraph' + requestId: uuid() describe 'removenode', -> schema = '/graph/input/removenode' @@ -81,6 +86,7 @@ describe 'Test graph protocol schema on event', -> payload: id: 'node1' graph: 'mygraph' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -102,6 +108,7 @@ describe 'Test graph protocol schema on event', -> from: 'node1' to: 'node2' graph: 'mygraph' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -125,6 +132,7 @@ describe 'Test graph protocol schema on event', -> metadata: x: 5 y: -1000 + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -135,6 +143,7 @@ describe 'Test graph protocol schema on event', -> payload: id: 'node1' graph: 'mygraph' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -160,6 +169,7 @@ describe 'Test graph protocol schema on event', -> tgt: node: 'node2' port: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -173,6 +183,7 @@ describe 'Test graph protocol schema on event', -> port: 'OUT' tgt: port: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -198,6 +209,7 @@ describe 'Test graph protocol schema on event', -> tgt: node: 'node2' port: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -225,6 +237,7 @@ describe 'Test graph protocol schema on event', -> port: 'IN' metadata: route: 1 + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -249,6 +262,7 @@ describe 'Test graph protocol schema on event', -> tgt: node: 'node2' port: 'IN' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.missing).to.eql [] @@ -265,6 +279,7 @@ describe 'Test graph protocol schema on event', -> tgt: port: 'IN' node: 'node2' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -287,6 +302,7 @@ describe 'Test graph protocol schema on event', -> tgt: node: 'node2' port: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -301,6 +317,7 @@ describe 'Test graph protocol schema on event', -> tgt: node: 'node2' port: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -323,6 +340,7 @@ describe 'Test graph protocol schema on event', -> public: 'IN' node: 'core/Kick' port: 'DATA' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -336,6 +354,7 @@ describe 'Test graph protocol schema on event', -> node: 'core/Kick' port: 'DATA' extra: 'doesntwork' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -356,6 +375,7 @@ describe 'Test graph protocol schema on event', -> payload: graph: 'mygraph' public: 'IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -368,6 +388,7 @@ describe 'Test graph protocol schema on event', -> public: 'IN' node: 'core/Kick' port: 'DATA' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -389,6 +410,7 @@ describe 'Test graph protocol schema on event', -> graph: 'mygraph' from: 'IN' to: 'MORE_IN' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -411,6 +433,7 @@ describe 'Test graph protocol schema on event', -> public: 'OUT' node: 'core/Repeat' port: 'OUT' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -424,6 +447,7 @@ describe 'Test graph protocol schema on event', -> node: 'core/Repeat' port: 'OUT' extra: 'doesntwork' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -444,6 +468,7 @@ describe 'Test graph protocol schema on event', -> payload: graph: 'mygraph' public: 'OUT' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -456,6 +481,7 @@ describe 'Test graph protocol schema on event', -> public: 'OUT' node: 'core/Kick' port: 'DATA' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -477,6 +503,7 @@ describe 'Test graph protocol schema on event', -> graph: 'mygraph' from: 'OUT' to: 'MORE_OUT' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -498,6 +525,7 @@ describe 'Test graph protocol schema on event', -> graph: 'mygraph' name: 'mygroup' nodes: ['Kick', 'Drop'] + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -510,6 +538,7 @@ describe 'Test graph protocol schema on event', -> name: 'mygroup' nodes: ['Kick', 'Drop'] extra: 'nope' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.false @@ -530,6 +559,7 @@ describe 'Test graph protocol schema on event', -> payload: graph: 'mygraph' name: 'mygroup' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -551,6 +581,7 @@ describe 'Test graph protocol schema on event', -> graph: 'mygraph' from: 'mygroup' to: 'yourgroup' + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true @@ -572,5 +603,6 @@ describe 'Test graph protocol schema on event', -> graph: 'mygraph' name: 'mygroup' metadata: {} + requestId: uuid() chai.expect(tv4.validate event, schema).to.be.true diff --git a/test/schema/test_network.coffee b/test/schema/test_network.coffee index 49e0344..773e243 100644 --- a/test/schema/test_network.coffee +++ b/test/schema/test_network.coffee @@ -1,6 +1,7 @@ chai = require 'chai' schemas = require '../../schema/schemas.js' tv4 = require 'tv4' +uuid = require 'uuid/v4' format = require '../../schema/format' describe 'Test network protocol schema on events', -> @@ -373,6 +374,7 @@ describe 'Test network protocol schema on events', -> command: 'start' payload: graph: 'start' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -391,6 +393,7 @@ describe 'Test network protocol schema on events', -> command: 'getstatus' payload: graph: 'mygraph' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -409,6 +412,7 @@ describe 'Test network protocol schema on events', -> command: 'getstatus' payload: graph: 'mygraph' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -427,6 +431,7 @@ describe 'Test network protocol schema on events', -> command: 'stop' payload: graph: 'mygraph' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -444,6 +449,7 @@ describe 'Test network protocol schema on events', -> protocol: 'network' command: 'persist' payload: {} + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -463,6 +469,7 @@ describe 'Test network protocol schema on events', -> payload: enable: true graph: 'mygraph' + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] @@ -490,6 +497,7 @@ describe 'Test network protocol schema on events', -> port: 'IN' index: 0 ] + requestId: uuid() res = tv4.validateMultiple event, schema chai.expect(res.errors).to.eql [] diff --git a/test/schema/test_runtime.coffee b/test/schema/test_runtime.coffee index 5f796c9..c7a592c 100644 --- a/test/schema/test_runtime.coffee +++ b/test/schema/test_runtime.coffee @@ -1,6 +1,7 @@ chai = require 'chai' schemas = require '../../schema/schemas.js' tv4 = require 'tv4' +uuid = require 'uuid/v4' describe 'Test runtime protocol schema on event', -> before -> @@ -22,6 +23,7 @@ describe 'Test runtime protocol schema on event', -> protocol: 'runtime' command: 'getruntime' payload: {} + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true @@ -40,6 +42,7 @@ describe 'Test runtime protocol schema on event', -> port: 'IN' graph: 'mygraph' event: 'connect' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.true @@ -52,6 +55,7 @@ describe 'Test runtime protocol schema on event', -> port: 'IN' graph: 'mygraph' event: 'bad event' + requestId: uuid() res = tv4.validate event, schema chai.expect(res).to.be.false diff --git a/test/schema/test_trace.coffee b/test/schema/test_trace.coffee index cbf6ced..35831ba 100644 --- a/test/schema/test_trace.coffee +++ b/test/schema/test_trace.coffee @@ -1,6 +1,7 @@ chai = require 'chai' schemas = require '../../schema/schemas.js' tv4 = require 'tv4' +uuid = require 'uuid/v4' validExamples = 'start recording': @@ -8,26 +9,30 @@ validExamples = command: 'start' payload: graph: 'mygraph' - secret: 'verygood' + secret: 'verygood' + requestId: uuid() 'dump flowtrace.json': protocol: 'trace' command: 'dump' payload: graph: 'mygraph' - secret: 'verygood' type: 'flowtrace.json' + secret: 'verygood' + requestId: uuid() 'clear buffer': protocol: 'trace' command: 'clear' payload: graph: 'mygraph' - secret: 'verygood' + secret: 'verygood' + requestId: uuid() 'stop recording': protocol: 'trace' command: 'stop' payload: graph: 'mygraph' - secret: 'verygood' + secret: 'verygood' + requestId: uuid() invalidExamples = 'start with invalid graph id': @@ -35,26 +40,36 @@ invalidExamples = command: 'start' payload: graph: 112.0 - secret: 'nnice' + secret: 'nnice' + requestId: uuid() 'dump with invalid type': protocol: 'trace' command: 'dump' payload: graph: 'mygraph' - secret: 'verygood' type: 'not-a-valid-trace-type' + secret: 'verygood' + requestId: uuid() 'stop with missing secret': protocol: 'trace' command: 'start' payload: graph: 112.0 - secret: undefined + secret: undefined + requestId: uuid() 'clear without graph': protocol: 'trace' command: 'start' payload: graph: undefined - secret: 'verygood' + secret: 'verygood' + requestId: uuid() + 'start without requestId': + protocol: 'trace' + command: 'start' + payload: + graph: 'mygraph' + secret: 'verygood' testValid = (name) -> describe name, ->