diff --git a/common-canvas/canvas-info/canvas-info-v3-schema.json b/common-canvas/canvas-info/canvas-info-v3-schema.json new file mode 100644 index 0000000..c48a57d --- /dev/null +++ b/common-canvas/canvas-info/canvas-info-v3-schema.json @@ -0,0 +1,974 @@ + +{ + "$schema": "https://json-schema.org/draft-04/schema#", + "description": "Canvas Info Flow Schema - for internal Common Canvas use.", + "type": "object", + "id": "https://api.dataplatform.ibm.com/schemas/common-canvas/canvas-info/canvas-info-v3-schema.json", + "properties": { + "doc_type": { + "description": "Document type", + "type": "string" + }, + "version": { + "description": "Canvas info flow schema version", + "enum": [ + "3.0" + ] + }, + "json_schema": { + "description": "Refers to the JSON schema used to validate documents of this type", + "enum": [ + "http://api.dataplatform.ibm.com/schemas/common-canvas/canvas-info/canvas-info-v3-schema.json", + "https://api.dataplatform.ibm.com/schemas/common-canvas/canvas-info/canvas-info-v3-schema.json" + ] + }, + "open_with_tool": { + "description": "Preferred authoring application", + "type": "string" + }, + "id": { + "description": "Document identifier, GUID recommended", + "type": "string" + }, + "name": { + "description": "User-defined name", + "type": "string" + }, + "description": { + "description": "User-defined description", + "type": "string" + }, + "class_name": { + "description": "CSS class name", + "type": "string" + }, + "parameters": { + "description": "Parameters for the flow document", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "primary_pipeline": { + "description": "Reference to the primary (main) pipeline flow within the document", + "type": "string" + }, + "pipelines": { + "description": "Array of pipelines", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/canvas_pipeline" + }, + "uniqueItems": true + }, + "schemas": { + "description": "Array of data record schemas used in the document", + "type": "array", + "minItems": 0, + "items": { + "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/datarecord-metadata/datarecord-metadata-v3-schema.json#/definitions/record_schema" + }, + "uniqueItems": true + }, + "runtimes": { + "description": "Array of runtime objects referred to in the document", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-v3-schema.json#/definitions/runtime_def" + }, + "uniqueItems": true + }, + "external_paramsets": { + "description": "Array of parameter set references", + "type": "array", + "minItems": 0, + "items": { + "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/parameters/parametersets-v3-schema.json#/definitions/paramset_ref" + }, + "uniqueItems": true + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "id", + "doc_type", + "version", + "primary_pipeline", + "pipelines" + ], + "additionalProperties": false, + "definitions": { + "canvas_pipeline": { + "description": "Definition of a single canvas-info pipeline", + "type": "object", + "properties": { + "id": { + "description": "Unique identifier for this canvas-info pipeline", + "type": "string" + }, + "description": { + "description": "Description for this canvas-info pipeline", + "type": "string" + }, + "name": { + "description": "User-readable for this canvas-info pipeline", + "type": "string" + }, + "runtime_ref": { + "description": "Reference to the id of the runtime associated with the operations in the current pipeline", + "type": "string" + }, + "nodes": { + "description": "Array of canvas nodes for this canvas pipeline", + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/canvas_node" + }, + "uniqueItems": true + }, + "comments": { + "description": "Array of canvas comments for this canvas pipeline", + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/canvas_comment" + }, + "uniqueItems": true + }, + "links": { + "description": "Array of canvas links for this canvas pipeline", + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/canvas_link" + }, + "uniqueItems": true + }, + "parameters": { + "description": "Parameters for this canvas-info pipeline", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "zoom": { + "oneOf": [ + { + "description": "Deprecated - use zoom object instead. Scale factor as a percentage. 100% is standard scale amount. Smaller values zoom out. Larger values zoom in.", + "type": "integer", + "deprecated": true + }, + { + "description": "A zoom object containing translation and scale amounts.", + "type": "object", + "properties": { + "x": { + "description": "Horizontal translation amount. Positive value moves right, negative to the left.", + "type": "number" + }, + "y": { + "description": "Vertical translation amount. Positive value moves down, negative moves up.", + "type": "number" + }, + "k": { + "description": "Scale amount. 1.0 is the standard scale amount. Smaller values zoom out. Larger values zoom in.", + "type": "number" + } + }, + "required": [ + "x", + "y", + "k" + ], + "additionalProperties": false + } + ] + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "id", + "nodes" + ], + "additionalProperties": false + }, + "canvas_node": { + "oneOf": [ + { + "$ref": "#/definitions/canvas_execution_node" + }, + { + "$ref": "#/definitions/canvas_supernode" + }, + { + "$ref": "#/definitions/canvas_binding_entry_node" + }, + { + "$ref": "#/definitions/canvas_binding_exit_node" + }, + { + "$ref": "#/definitions/canvas_model_node" + } + ] + }, + "canvas_node_shared_properties": { + "type": "object", + "properties": { + "id": { + "description": "Unique identifier for canvas node within the current pipeline", + "type": "string" + }, + "label": { + "description": "Label of this canvas execution node.", + "type": "string" + }, + "description": { + "description": "Description of this canvas execution node.", + "type": "string" + }, + "class_name": { + "description": "CSS class name - can be a space separated list of classes", + "type": "string" + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the node.", + "type": ["string", "object"] + }, + "image": { + "description": "URL to image source. Although a data URL can be used to embed an image inline, it is not recommended. The 'image' property can also be a JSX object that displays an image using an element however, JSX images must be set programmatically and cannot be stringified into JSON.", + "type": ["string", "object"] + }, + "x_pos": { + "description": "x-position of this canvas execution node.", + "type": "number" + }, + "y_pos": { + "description": "y-position of this canvas execution node.", + "type": "number" + }, + "is_resized": { + "description": "Indicates whether a node has been resized or not. If true, resize_width and resize_height are used for node display. If false, the default width and height are used.", + "type": "boolean" + }, + "resize_height": { + "description": "Height of resized node. The node will be displayed with this height, when is_resized is true, in preference to its default height.", + "type": "number" + }, + "resize_width": { + "description": "Width of resized node. The node will be displayed with this width, when is_resized is true, in preference to its default width.", + "type": "number" + }, + "attributes": { + "description": "additional attributes", + "type": "string" + }, + "messages": { + "description": "An array of messages for the node", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-ui-v3-schema.json#/definitions/message_def" + }, + "uniqueItems": true + }, + "palette_image": { + "description": "Image name for the node displayed in palette. If omitted the image from 'image' field will be used.", + "type": "string" + }, + "palette_class_name": { + "description": "CSS class name applied to the
shown in palette for the node", + "type": "string" + }, + "palette_disabled": { + "description": "Indicates whether the node in the palette is disabled. If true, prevents the node being dragged or double-clicked from palette.", + "type": "boolean" + }, + "decorations": { + "description": "Array of decorations used to decorate nodes", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-ui-v3-schema.json#/definitions/decoration_def" + }, + "uniqueItems": true + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + } + }, + "canvas_execution_node": { + "allOf": [ + { + "description": "Definition of a single canvas execution node", + "type": "object", + "properties": { + "type": { + "description": "Node type - always 'execution_node'", + "enum": [ + "execution_node" + ] + }, + "op": { + "description": "Operator type identifier", + "type": "string" + }, + "ui_parameters": { + "description": "UI only parameter values for the node", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "inputs": { + "$ref": "#/definitions/canvas_ports" + }, + "outputs": { + "$ref": "#/definitions/canvas_ports" + }, + "parameters": { + "description": "Input parameters for the operator", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "runtime_ref": { + "description": "Optional reference to the id of the runtime associated with the current node", + "type": "string" + } + }, + "required": [ + "id", + "type", + "op" + ], + "additionalProperties": false + }, + { "$ref": "#/definitions/canvas_node_shared_properties" } + ] + }, + "canvas_supernode": { + "allOf": [ + { + "description": "Definition of a supernode which serves as the entry point for a sub-pipeline", + "type": "object", + "properties": { + "type": { + "description": "Node type - always 'super_node' for supernode elements", + "enum": [ + "super_node" + ] + }, + "open_with_tool": { + "description": "Name of the tool which can be used to view or edit the sub-flow for this supernode. The default is 'canvas'", + "type": "string" + }, + "subflow_ref": { + "description": "Refers to the sub-flow associated with this supernode", + "type": "object", + "properties": { + "url": { + "description": "Reference to an external sub-flow. When not present the sub-flow is assumed to be in the current document. A value of 'app_defined' indicates a sub-flow identifier is present, but the controlling application will serve up the sub-pipeline in the form of a new pipeline-flow document (no sub-flow is present in the document).", + "type": "string" + }, + "pipeline_id_ref": { + "description": "Sub-flow identifier reference", + "type": "string" + } + }, + "required": [ + "pipeline_id_ref" + ] + }, + "is_expanded": { + "description": "Indicates whether a supernode is shown in expanded state or as a regular node.", + "type": "boolean" + }, + "expanded_height": { + "description": "Height of expanded supernode. If not provided an appropriate height is calculated.", + "type": "number" + }, + "expanded_width": { + "description": "Width of expanded supernode. If not provided an appropriate width is calculated.", + "type": "number" + }, + "sub_pipelines": { + "description": "An array of pipelines referenced when this node is a supernode. This field is only used when the supernode is in a palette or on the clipboard. It will be an empty array when the supernode references an external pipeline.", + "type": "array", + "minItems": 0, + "uniqueItems": true + }, + "ui_parameters": { + "description": "UI only parameter values for the node", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "inputs": { + "$ref": "#/definitions/canvas_bound_ports" + }, + "outputs": { + "$ref": "#/definitions/canvas_bound_ports" + }, + "parameters": { + "description": "Input parameters for the supernode", + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "required": [ + "id", + "type", + "subflow_ref" + ], + "additionalProperties": false + }, + { "$ref": "#/definitions/canvas_node_shared_properties" } + ] + }, + "canvas_binding_entry_node": { + "allOf": [ + { + "description": "Defines an entry point (source) for a pipeline. Bindings can be concrete: the concrete_binding element is present on the port; or bindings can be abstract: bindings are performed externally via configuration or a wrapper document.", + "type": "object", + "properties": { + "type": { + "description": "Node type - always 'binding' for binding elements", + "enum": [ + "binding" + ] + }, + "outputs": { + "$ref": "#/definitions/canvas_ports" + }, + "connection": { + "$ref": "./pipeline-connection-v3-schema.json#/definitions/common_pipeline_connection_def" + }, + "data_asset": { + "$ref": "./pipeline-connection-v3-schema.json#/definitions/common_pipeline_data_asset_def" + }, + "op": { + "description": "Binding node type identifier", + "type": "string" + }, + "ui_parameters": { + "description": "UI only parameter values for the node", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "parameters": { + "description": "Parameters for the binding entry node", + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "required": [ + "id", + "type", + "outputs" + ], + "additionalProperties": false + }, + { "$ref": "#/definitions/canvas_node_shared_properties" } + ] + }, + "canvas_binding_exit_node": { + "allOf": [ + { + "description": "Defines an exit point (sink) for a pipeline. Bindings can be concrete: the concrete_binding element is present on the port; or bindings can be abstract: bindings are performed externally via configuration or a wrapper document.", + "type": "object", + "properties": { + "type": { + "description": "Node type - always 'binding' for binding elements", + "enum": [ + "binding" + ] + }, + "inputs": { + "$ref": "#/definitions/canvas_ports" + }, + "outputs": { + "description": "An optional set of output ports, typically used for directing error information out of the binding node.", + "$ref": "#/definitions/canvas_ports" + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + }, + "connection": { + "$ref": "./pipeline-connection-v3-schema.json#/definitions/common_pipeline_connection_def" + }, + "data_asset": { + "$ref": "./pipeline-connection-v3-schema.json#/definitions/common_pipeline_data_asset_def" + }, + "op": { + "description": "Binding node type identifier", + "type": "string" + }, + "parameters": { + "description": "Parameters for the binding exit node", + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "required": [ + "id", + "type", + "inputs" + ], + "additionalProperties": false + }, + { "$ref": "#/definitions/canvas_node_shared_properties" } + ] + }, + "canvas_model_node": { + "allOf": [ + { + "description": "Definition of a single predictive model node", + "type": "object", + "properties": { + "type": { + "description": "Node type - always 'model_node' for model pipeline elements", + "enum": [ + "model_node" + ] + }, + "model_ref": { + "description": "Reference to the binary model", + "type": "string" + }, + "inputs": { + "$ref": "#/definitions/canvas_ports" + }, + "outputs": { + "$ref": "#/definitions/canvas_ports" + }, + "op": { + "description": "Node type identifier of modeling node that created this model.", + "type": "string" + }, + "parameters": { + "description": "Input parameters for the operator", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "runtime_ref": { + "description": "Reference to the runtime associated with the current node", + "type": "string" + } + }, + "required": [ + "id", + "type", + "inputs" + ], + "additionalProperties": false + }, + { "$ref": "#/definitions/canvas_node_shared_properties" } + ] + }, + "canvas_ports": { + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/canvas_port" + }, + "uniqueItems": true + }, + "canvas_port": { + "description": "Port definition (input/output) on a node", + "type": "object", + "properties": { + "id": { + "description": "Unique identifier for the port", + "type": "string" + }, + "schema_ref": { + "description": "Optional data record schema reference associated with the port", + "type": "string" + }, + "parameters": { + "description": "Parameters for the port", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "cardinality": { + "description": "Property to capture how many data assets are allowed for this port, e.g., min: 1, max:1 implies you must supply 1 and only 1; min:0, max:1 implies it is optional and a max of one, min:0, max:-1 means it is optional and you can may have any number of data assets. The default value is 1:1 for inputs and 1:-1 for outputs.", + "type": "object", + "properties": { + "min": { + "description": "Minimum data sets that are required for this port", + "type": "integer", + "default": 1 + }, + "max": { + "description": "Maximum data sets that are allowed on this port. A negative value indicates unlimited. The default value is 1 for inputs and -1 for outputs.", + "type": "integer" + } + }, + "additionalProperties": false + }, + "class_name": { + "description": "CSS class name", + "type": "string" + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the port.", + "type": ["string", "object"] + }, + "label": { + "description": "Port name", + "type": "string" + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "id" + ], + "additionalProperties": false + }, + "canvas_bound_ports": { + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/canvas_bound_port" + }, + "uniqueItems": true + }, + "canvas_bound_port": { + "description": "Port definition (input/output) on a node with optional pipeline port binding for supernodes", + "type": "object", + "properties": { + "id": { + "description": "Unique identifier for this port", + "type": "string" + }, + "schema_ref": { + "description": "Optional data record schema associated with the port", + "type": "string" + }, + "subflow_node_ref": { + "description": "Optional node id binding within the current document.", + "type": "string" + }, + "parameters": { + "description": "Parameters for the binding port", + "type": "object", + "properties": {}, + "additionalProperties": true + }, + "cardinality": { + "description": "Property to capture how many data assets are allowed for this port, e.g., min: 1, max:1 implies you must supply 1 and only 1; min:0, max:1 implies it is optional and a max of one, min:0, max:-1 means it is optional and you can may have any number of data assets. The default value is 1:1 for inputs and 1:-1 for outputs.", + "type": "object", + "properties": { + "min": { + "description": "Minimum data sets that are required for this port", + "type": "integer", + "default": 1 + }, + "max": { + "description": "Maximum data sets that are allowed on this port. A negative value indicates unlimited. The default value is 1 for inputs and -1 for outputs.", + "type": "integer" + } + }, + "additionalProperties": false + }, + "class_name": { + "description": "CSS class name", + "type": "string" + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the port.", + "type": ["string", "object"] + }, + "label": { + "description": "Port name", + "type": "string" + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "id" + ], + "additionalProperties": false + }, + "canvas_comment": { + "type": "object", + "properties": { + "id": { + "description": "Comment identifier. Must be unique.", + "type": "string" + }, + "x_pos": { + "description": "Horizontal comment position", + "type": "number" + }, + "y_pos": { + "description": "Vertical comment position", + "type": "number" + }, + "width": { + "description": "Comment width", + "type": "number", + "minimum": 10 + }, + "height": { + "description": "Comment height", + "type": "number", + "minimum": 10 + }, + "content": { + "description": "Comment content", + "type": "string" + }, + "class_name": { + "description": "CSS class(es) to apply to the comment", + "type": "string" + }, + "content_type": { + "description": "Type of content", + "type": "string" + }, + "formats": { + "description": "Type of content", + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "field" + ] + } + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the comment.", + "type": ["string", "object"], + "additionalProperties": false + } + }, + "required": [ + "id", + "x_pos", + "y_pos", + "width", + "height" + ], + "additionalProperties": true + }, + "canvas_link": { + "oneOf": [ + { + "$ref": "#/definitions/canvas_comment_link" + }, + { + "$ref": "#/definitions/canvas_node_link" + }, + { + "$ref": "#/definitions/canvas_association_link" + } + ] + }, + "canvas_comment_link": { + "description": "Comment link definition", + "type": "object", + "properties": { + "id": { + "description": "Unique id of this comment link.", + "type": "string" + }, + "type": { + "description": "Link type - always 'commentLink' for links from comments to nodes", + "enum": [ + "commentLink" + ] + }, + "src_node_id": { + "description": "ID of the comment this link connects from.", + "type": "string" + }, + "trg_node_id": { + "description": "ID of the node this link connects to.", + "type": "string" + }, + "class_name": { + "description": "CSS class name for link styling", + "type": "string" + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the comment link.", + "type": ["string", "object"] + }, + "decorations": { + "description": "Array of decorations used to decorate node links", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-ui-v3-schema.json#/definitions/decoration_def" + }, + "uniqueItems": true + } + }, + "required": [ + "node_ref" + ], + "additionalProperties": true + }, + "canvas_node_link": { + "description": "Node link definition", + "type": "object", + "properties": { + "id": { + "description": "Unique id of this link within the pipelineFlow.", + "type": "string" + }, + "type": { + "description": "Link type - always 'nodeLink' for directional links from nodes to nodes", + "enum": [ + "nodeLink" + ] + }, + "src_node_id": { + "description": "ID of the source node this link connects from.", + "type": "string" + }, + "src_node_port_id": { + "description": "Optional ID of the port on the source node this link connects from. Defaults to the first port if omitted.", + "type": "string" + }, + "trg_node_id": { + "description": "ID of the target node this link connects to.", + "type": "string" + }, + "trg_node_port_id": { + "description": "Optional ID of the port on the target node this link connects from. Defaults to the first port if omitted.", + "type": "string" + }, + "src_pos": { + "x_pos": "number", + "y_pos": "number" + }, + "trg_pos": { + "x_pos": "number", + "y_pos": "number" + }, + "link_name": { + "description": "optional link name (used in parameter sets when there are multiple input sources)", + "type": "string" + }, + "type_attr": { + "description": "Optional type attribute for the link. This can store optional atribute info.", + "type": "string" + }, + "description": { + "description": "User-defined description", + "type": "string" + }, + "class_name": { + "description": "CSS class name", + "type": "string" + }, + "style": { + "description": "A 'style spec' object containing CSS strings to be applied to the SVG objects of the node to node link.", + "type": ["string", "object"] + }, + "decorations": { + "description": "Array of decorations used to decorate node links", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-ui-v3-schema.json#/definitions/decoration_def" + }, + "uniqueItems": true + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "node_id_ref" + ], + "additionalProperties": false + }, + "canvas_association_link": { + "description": "Association link definition", + "type": "object", + "properties": { + "id": { + "description": "Unique id of this link within the pipelineFlow.", + "type": "string" + }, + "type": { + "description": "Link type - always 'associationLink' for associations between two nodes", + "enum": [ + "associationLink" + ] + }, + "src_node_id": { + "description": "ID of the source node of the association.", + "type": "string" + }, + "trg_node_id": { + "description": "ID of the target node of the association.", + "type": "string" + }, + "class_name": { + "description": "CSS class name", + "type": "string" + }, + "decorations": { + "description": "Array of decorations used to decorate node links", + "type": "array", + "minItems": 0, + "items": { + "$ref": "./pipeline-flow-ui-v3-schema.json#/definitions/decoration_def" + }, + "uniqueItems": true + }, + "app_data": { + "description": "Object containing app-specific data", + "type": "object", + "additionalProperties": true + } + }, + "required": [ + "node_id_ref" + ], + "additionalProperties": false + } + } + } diff --git a/common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json b/common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json index 020bd87..f5172d6 100644 --- a/common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json +++ b/common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json @@ -65,9 +65,7 @@ "properties": { "description": "Properties controlling how the data asset is used.", "type": "object", - "additionalProperties": { - "type": "object" - }, + "additionalProperties": true, "properties": { "attachment_ref": { "description": "The ID of the data asset attachment to use. If not specified and used as a source, the first suitable attachment found will be used. If not specified and used as a target, a new attachment will be created.", diff --git a/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json b/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json index a35f71e..acdcb46 100644 --- a/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json +++ b/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json @@ -6,7 +6,7 @@ "properties": {}, "additionalProperties": true, "definitions": { - "pipeline_overview_def": { + "pipeline_flow_ui_def": { "description": "Top level UI information", "type": "object", "properties": { @@ -25,7 +25,7 @@ }, "additionalProperties": true }, - "pipeline_def": { + "pipeline_ui_def": { "description": "Pipeline level UI information", "type": "object", "properties": { @@ -173,9 +173,6 @@ "description": "An array of pipelines referenced when this node is a supernode. This field is only used when the supernode is in a palette or on the clipboard. It will be an empty array when the supernode references an external pipeline.", "type": "array", "minItems": 0, - "items": { - "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json#/definitions/pipeline_def" - }, "uniqueItems": true }, "attributes": { @@ -300,23 +297,20 @@ "additionalProperties": false }, "decoration_def": { + "oneOf": [ + { + "$ref": "#/definitions/node_decoration_def" + }, + { + "$ref": "#/definitions/link_decoration_def" + } + ] + }, + "node_decoration_def": { "description": "Decoration used to decorate a node", - "type": "object", "properties": { - "id": { - "description": "An identifier used to identify the decoration", - "type": "string" - }, - "hotspot": { - "description": "Indicates whether the decorator is a hotspot or not. ie does it send an event to consuming app. when clicked", - "type": "boolean" - }, - "class_name": { - "description": "CSS class name for decoration styling", - "type": "string" - }, "position": { - "description": "Indicates an anchor point on the node or link from which the decoration will be displayed. If x_pos and y_pos are not provided the decoration is displayed with a default offset from this position.", + "description": "Indicates an anchor point on the node at which the decoration will be displayed.", "enum": [ "topLeft", "topCenter", @@ -326,29 +320,188 @@ "middleRight", "bottomLeft", "bottomCenter", - "bottomRight", + "bottomRight" + ] + } + }, + "oneOf": [ + { + "$ref": "#/definitions/image_decoration_def" + }, + { + "$ref": "#/definitions/label_decoration_def" + }, + { + "$ref": "#/definitions/shape_decoration_def" + }, + { + "$ref": "#/definitions/jsx_decoration_def" + } + ] + }, + "link_decoration_def": { + "description": "Decoration used to decorate a link", + "properties": { + "position": { + "description": "Indicates an anchor point on the link at which the decoration will be displayed.", + "enum": [ "source", "middle", "target" ] }, + "distance": { + "description": "Only applicable to straight link lines. Will move the decoration the specified number of pixels from its 'position'.", + "type": "integer" + } + }, + "oneOf": [ + { + "$ref": "#/definitions/image_decoration_def" + }, + { + "$ref": "#/definitions/label_decoration_def" + }, + { + "$ref": "#/definitions/shape_decoration_def" + }, + { + "$ref": "#/definitions/jsx_decoration_def" + } + ] + }, + "image_decoration_def": { + "description": "Image decoration properties including shared properties.", + "type": "object", + "allOf": [ + { + "properties": { + "image": { + "description": "Image displayed at the decoration position. Provide either this or a label.", + "type": "string" + }, + "outline": { + "description": "If true and outline is drawn around the image.", + "type": "boolean" + } + } + }, + { "$ref": "#/definitions/shared_decoration_def" } + ] + }, + "label_decoration_def": { + "description": "Label decoration properties including shared properties.", + "type": "object", + "allOf": [ + { + "properties": { + "label": { + "description": "Label displayed at the decoration position. Provide either this or an image.", + "type": "string" + }, + "label_editable": { + "description": "If true, the label decoration can be edited. It displays an edit icon which can be clicked to enter edit mode.", + "type": "boolean" + }, + "label_align": { + "description": "The alignment of the label.", + "enum": [ + "left", + "center" + ] + }, + "label_single_line": { + "description": "If true, the label is displayed as a single line and is truncated at the width.", + "type": "boolean" + }, + "label_max_characters": { + "description": "The maximum number of characters that can be entered in the label decoration when it is editable.", + "type": "integer" + }, + "label_allow_return_key": { + "description": "If false, pressing the return key in edit mode will not do anything: label will wrap at width. If true, return will enter a newline character. ", + "type": "boolean" + } + } + }, + { "$ref": "#/definitions/shared_decoration_def" } + ] + }, + "shape_decoration_def": { + "description": "Shape decoration properties including shared properties.", + "type": "object", + "allOf": [ + { + "properties": { + "path": { + "description": "An SVG path that describes a shape to be drawn at the decoration position.", + "type": "string" + } + } + }, + { "$ref": "#/definitions/shared_decoration_def" } + ] + }, + "jsx_decoration_def": { + "description": "JSX decoration properties including shared properties These are never serialized in the pipeline flow.", + "type": "object", + "allOf": [ + { + "properties": { + "jsx": { + "description": "A JSX expression that will be used to display the content of the decoration.", + "type": "object" + } + } + }, + { "$ref": "#/definitions/shared_decoration_def" } + ] + }, + "shared_decoration_def": { + "description": "Shared properties across all types of decoration.", + "type": "object", + "properties": { + "id": { + "description": "A unique identifier used to identify the decoration", + "type": "string" + }, "x_pos": { - "description": "X position of the decorator relative to the node's position field. If position is not provided it is relative to the 'topLeft' position", + "description": "X position of the decorator relative to the decorations's position field.", "type": "integer" }, "y_pos": { - "description": "Y position of the decorator relative to the node's position field. If position is not provided it is relative to the 'topLeft' position", + "description": "Y position of the decorator relative to the decorations's position field.", "type": "integer" }, - "image": { - "description": "Image displayed at the decoration position. Provide either this or a label.", + "width": { + "description": "Display width of decoration.", + "type": "integer" + }, + "height": { + "description": "Display height of decoration.", + "type": "integer" + }, + "hotspot": { + "description": "Indicates whether the decorator is a hotspot or not. If true, it calls sends an event to the host app. when clicked", + "type": "boolean" + }, + "class_name": { + "description": "CSS class name for decoration styling. It can be a space-separated list of classes.", "type": "string" }, - "label": { - "description": "Label displayed at the decoration position. Provide either this or an image.", + "tooltip": { + "description": "Tooltip text for the decoration.", "type": "string" + }, + "temporary": { + "description": "If set to true, the decoration will not be serialized in the pipeline flow.", + "type": "boolean" } - } + }, + "required": [ + "id" + ] + }, "message_def": { "description": "Node message definition", diff --git a/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json b/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json index 9cf79ca..0891abd 100644 --- a/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json +++ b/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json @@ -80,7 +80,7 @@ "type": "object", "properties": { "ui_data": { - "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json#/definitions/pipeline_overview_def" + "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json#/definitions/pipeline_flow_ui_def" } }, "additionalProperties": true @@ -135,7 +135,7 @@ "type": "object", "properties": { "ui_data": { - "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json#/definitions/pipeline_def" + "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json#/definitions/pipeline_ui_def" } }, "additionalProperties": true diff --git a/package.json b/package.json index 7f8f0cd..7073dc7 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,7 @@ "url": "https://github.com/elyra-ai/pipeline-schemas/issues" }, "devDependencies": {}, - "dependencies": {} + "dependencies": { + "json-schema-to-typescript": "^15.0.4" + } } diff --git a/scripts/generateTS.sh b/scripts/generateTS.sh new file mode 100755 index 0000000..113d9dc --- /dev/null +++ b/scripts/generateTS.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# +# Copyright 2025 Elyra Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This script generates Typescript declarations files from the JSON schemas +# contained in this repo. It does this by: +# 1. Copying all schemas to the ../schemas directory +# 2. Changing any references to child schemas in this form: +# "$ref": "https://api.dataplatform.ibm.com/schemas/common-pipeline/parameters/parametersets-v3-schema.json#/definitions/paramset_ref" +# to look like this: +# "$ref": "./parametersets-v3-schema.json#/definitions/paramset_ref" +# This makes the schemas like pipeline-flow-v3-schema.json have correct +# references to its child schemas like parametersets-v3-schema.json. +# 3. Runs the json2ts utility command on each of the top level schemas to +# generate the typescript declaration files. +# + +set -e + +WORKING_DIR="$PWD" + +echo "Generating Typescript declarations." + +# Replaces the lines in the file beginning with "$ref" +replace_string_in_file() { + local file_path="$1" + local url="$2" + + local old_string="\"\$ref\": \"https:\/\/api.dataplatform.ibm.com\/schemas\/common-pipeline\/"$url"\/" + local new_string="\"\$ref\": \".\/" + + sed -i '' "s/$old_string/$new_string/g" "$file_path" +} + +# Call the replace string for each of the types of child schema +replace_string_schema() { + local file=$1 + replace_string_in_file "$file" "datarecord-metadata" + replace_string_in_file "$file" "pipeline-flow" + replace_string_in_file "$file" "parameters" + replace_string_in_file "$file" "pipeline-connection" +} + +# Make sure we have an empty ../schemas directory and change to it + +rm -rf ../schemas +mkdir ../schemas +cd ../schemas + +# Copy all JSON schemas into the ../schemas directory + +cp ../common-canvas/canvas-info/canvas-info-v3-schema.json . +cp ../common-canvas/palette/palette-v3-schema.json . + +cp ../common-pipeline/datarecord-metadata/datarecord-metadata-v3-schema.json . +cp ../common-pipeline/parameters/parameters-v3-schema.json . +cp ../common-pipeline/parameters/parametersets-v3-schema.json . +cp ../common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json . +cp ../common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json . +cp ../common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json . + +# Replace the "ref": "http://... references to become "ref": "./... + +replace_string_schema "canvas-info-v3-schema.json" +replace_string_schema "pipeline-flow-v3-schema.json" + +replace_string_schema "canvas-info-v3-schema.json" +replace_string_schema "palette-v3-schema.json" +replace_string_schema "datarecord-metadata-v3-schema.json" +replace_string_schema "parameters-v3-schema.json" +replace_string_schema "parametersets-v3-schema.json" +replace_string_schema "pipeline-connection-v3-schema.json" +replace_string_schema "pipeline-flow-ui-v3-schema.json" +replace_string_schema "pipeline-flow-v3-schema.json" + +# Create a prologue to use for our TS declaration files +prologue=" +/* + * Copyright 2025 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the \"License\"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an \"AS IS\" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the ../script/generateTS.sh script to regenerate all TS files. + */ +/* eslint-disable */ +" + +# Makes sure we have an empty ../types directory +rm -rf ../types +mkdir ../types + +# Run the json2ts utilities for the top level schemas + +npx json2ts --bannerComment "$prologue" canvas-info-v3-schema.json ../types/canvas-info-v3.ts +npx json2ts --bannerComment "$prologue" pipeline-flow-v3-schema.json ../types/pipeline-flow-v3.ts +npx json2ts --bannerComment "$prologue" palette-v3-schema.json ../types/palette-v3.ts + +cd $WORKING_DIR + +echo "TS declarations generated successfully"