-
Notifications
You must be signed in to change notification settings - Fork 0
support sub flows #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
support sub flows #980
Changes from all commits
f8edfb6
3e57aa4
c79b48e
9dade74
9aec8ee
c280de1
2b3def6
d47a3ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Types | ||
| class FlowSubFlowSettingType < Types::BaseObject | ||
| description 'Represents a sub-flow setting.' | ||
|
|
||
| field :default_value, GraphQL::Types::JSON, | ||
| null: true, | ||
| description: 'The default value of the sub-flow setting.' | ||
| field :hidden, Boolean, | ||
| null: true, | ||
| description: 'Whether the sub-flow setting is hidden.' | ||
| field :identifier, String, | ||
| null: false, | ||
| description: 'The identifier of the sub-flow setting.' | ||
| field :optional, Boolean, | ||
| null: true, | ||
| description: 'Whether the sub-flow setting is optional.' | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Types | ||
| class FlowSubFlowType < Types::BaseObject | ||
| description 'Represents a sub-flow parameter value.' | ||
|
|
||
| field :function_identifier, String, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the input type should take the |
||
| null: true, | ||
| description: 'The function identifier to execute.' | ||
| field :settings, [Types::FlowSubFlowSettingType], | ||
| method: :sub_flow_settings, | ||
| null: false, | ||
| description: 'The sub-flow settings.' | ||
| field :signature, String, | ||
| null: false, | ||
| description: 'The sub-flow signature.' | ||
| field :starting_node_id, GlobalIdType[::NodeFunction], | ||
| null: true, | ||
| description: 'The starting node to execute.' | ||
|
|
||
| def starting_node_id | ||
| object.starting_node&.to_global_id | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Types | ||
| module Input | ||
| class FlowSubFlowInputType < Types::BaseInputObject | ||
| description 'Input type for sub-flow parameter values' | ||
|
|
||
| argument :function_identifier, String, | ||
| required: false, | ||
| description: 'The function identifier to execute' | ||
| argument :settings, [Types::Input::FlowSubFlowSettingInputType], | ||
| required: false, | ||
| description: 'The sub-flow settings' | ||
| argument :signature, String, | ||
|
Taucher2003 marked this conversation as resolved.
|
||
| required: true, | ||
| description: 'The sub-flow signature' | ||
| argument :starting_node_id, Types::GlobalIdType[::NodeFunction], | ||
| required: false, | ||
| description: 'The starting node to execute' | ||
|
|
||
| require_one_of %i[starting_node_id function_identifier] | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Types | ||
| module Input | ||
| class FlowSubFlowSettingInputType < Types::BaseInputObject | ||
| description 'Input type for sub-flow settings' | ||
|
|
||
| argument :default_value, GraphQL::Types::JSON, | ||
|
Taucher2003 marked this conversation as resolved.
|
||
| required: false, | ||
| description: 'The default value of the sub-flow setting' | ||
| argument :hidden, Boolean, | ||
|
Taucher2003 marked this conversation as resolved.
|
||
| required: false, | ||
| description: 'Whether the sub-flow setting is hidden' | ||
| argument :identifier, String, | ||
| required: true, | ||
| description: 'The identifier of the sub-flow setting' | ||
| argument :optional, Boolean, | ||
|
Taucher2003 marked this conversation as resolved.
|
||
| required: false, | ||
| description: 'Whether the sub-flow setting is optional' | ||
| end | ||
| end | ||
| end | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class SubFlow < ApplicationRecord | ||
| belongs_to :node_parameter, inverse_of: :sub_flow | ||
| belongs_to :starting_node, class_name: 'NodeFunction', optional: true | ||
| belongs_to :function_definition, optional: true | ||
|
|
||
| has_many :sub_flow_settings, inverse_of: :sub_flow, autosave: true | ||
|
|
||
| validate :validate_execution_reference | ||
|
|
||
| def function_identifier | ||
| function_definition&.identifier | ||
| end | ||
|
|
||
| def to_grpc | ||
| Tucana::Shared::SubFlow.new( | ||
| starting_node_id: starting_node_id, | ||
| function_identifier: function_identifier, | ||
| signature: signature, | ||
| settings: sub_flow_settings.map(&:to_grpc) | ||
| ) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def validate_execution_reference | ||
| return if [starting_node_id.present?, function_definition_id.present?].count(true) == 1 | ||
|
|
||
| errors.add(:base, 'Exactly one of starting_node or function_definition must be present') | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class SubFlowSetting < ApplicationRecord | ||
| belongs_to :sub_flow, inverse_of: :sub_flow_settings | ||
|
|
||
| validates :identifier, presence: true | ||
|
|
||
| def to_grpc | ||
| Tucana::Shared::SubFlowSetting.new( | ||
| identifier: identifier, | ||
| default_value: default_value.nil? ? nil : Tucana::Shared::Value.from_ruby(default_value), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if that is important for you on the runtime side, but |
||
| optional: optional, | ||
| hidden: hidden | ||
| ) | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.