Skip to content

Commit 3c6b199

Browse files
committed
Refactor generic types and mappers, update data type associations, and enhance validation services
1 parent 1e5b28e commit 3c6b199

File tree

50 files changed

+517
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+517
-301
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ gem 'good_job', '~> 4.0'
7979
gem 'rotp'
8080

8181
gem 'grpc', '~> 1.67'
82-
gem 'tucana', '0.0.27'
82+
gem 'tucana', '0.0.28'
8383

8484
gem 'code0-identities', '~> 0.0.1'
8585

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ GEM
362362
test-prof (1.4.4)
363363
thor (1.3.2)
364364
timeout (0.4.3)
365-
tucana (0.0.27)
365+
tucana (0.0.28)
366366
grpc (~> 1.64)
367367
tzinfo (2.0.6)
368368
concurrent-ruby (~> 1.0)
@@ -416,7 +416,7 @@ DEPENDENCIES
416416
simplecov (~> 0.22.0)
417417
simplecov-cobertura (~> 2.1)
418418
test-prof (~> 1.0)
419-
tucana (= 0.0.27)
419+
tucana (= 0.0.28)
420420
tzinfo-data
421421

422422
RUBY VERSION

app/graphql/types/input/generic_type_input_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Input
55
class GenericTypeInputType < Types::BaseInputObject
66
description 'Input type for generic type operations.'
77

8-
argument :data_type_id, Types::GlobaIdType[::DataType], required: true, description: 'The data type associated with this generic type.'
8+
argument :data_type_id, Types::GlobalIdType[::DataType], required: true, description: 'The data type associated with this generic type.'
99
argument :generic_mappers, [Types::Input::GenericMapperInputType], required: true,
1010
description: 'The mappers associated with this generic type.'
1111

app/models/data_type.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class DataType < ApplicationRecord
77
object: 3,
88
datatype: 4,
99
array: 5,
10-
generic: 6,
11-
function: 7,
10+
error: 6,
11+
node: 7,
1212
}.with_indifferent_access
1313

1414
enum :variant, VARIANTS, prefix: :variant
@@ -20,6 +20,7 @@ class DataType < ApplicationRecord
2020
has_many :names, -> { by_purpose(:name) }, class_name: 'Translation', as: :owner, inverse_of: :owner
2121
has_many :rules, class_name: 'DataTypeRule', inverse_of: :data_type
2222
has_many :data_type_identifiers, class_name: 'DataTypeIdentifier', inverse_of: :data_type
23+
has_many :generic_types, class_name: 'GenericType', inverse_of: :data_type
2324

2425
validates :variant, presence: true,
2526
inclusion: {

app/models/data_type_identifier.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
class DataTypeIdentifier < ApplicationRecord
44
belongs_to :data_type, optional: true, inverse_of: :data_type_identifiers
5-
belongs_to :generic_type, optional: true, inverse_of: :data_type_identifier
5+
belongs_to :generic_type, optional: true, inverse_of: :data_type_identifiers
66
belongs_to :runtime, inverse_of: :data_type_identifiers
77

8-
has_many :generic_types, inverse_of: :data_type_identifier
9-
has_many :generic_mappers, inverse_of: :data_type_identifier
10-
has_many :function_generic_mappers, class_name: 'GenericMapper', inverse_of: :data_type_identifier
8+
has_many :generic_mappers, inverse_of: :source
9+
has_many :function_generic_mappers, class_name: 'FunctionGenericMapper', inverse_of: :source
1110

1211
validate :exactly_one_of_generic_key_data_type_id_generic_type_id
1312

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
# frozen_string_literal: true
22

33
class FunctionGenericMapper < ApplicationRecord
4-
belongs_to :data_type_identifier, optional: true, inverse_of: :function_generic_mappers
4+
belongs_to :source, class_name: 'DataTypeIdentifier', inverse_of: :function_generic_mappers
55
belongs_to :runtime_function_definition, class_name: 'RuntimeFunctionDefinition', optional: true,
66
inverse_of: :generic_mappers
77
belongs_to :runtime_parameter_definition, class_name: 'RuntimeParameterDefinition', optional: true,
88
inverse_of: :function_generic_mappers
99

1010
validates :target, presence: true
11-
validate :exactly_one_of_generic_key_or_data_type_identifier_id
12-
13-
private
14-
15-
def exactly_one_of_generic_key_or_data_type_identifier_id
16-
values = [generic_key.present?, data_type_identifier.present?]
17-
return if values.count(true) == 1
18-
19-
errors.add(:base, 'Exactly one of generic_key or data_type_identifier_id must be present')
20-
end
2111
end

app/models/node_function.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ class NodeFunction < ApplicationRecord
44
belongs_to :runtime_function, class_name: 'RuntimeFunctionDefinition'
55
belongs_to :next_node, class_name: 'NodeFunction', optional: true
66

7-
has_many :node_parameters, inverse_of: :function_value
7+
has_many :node_parameter_values, class_name: 'NodeParameter', inverse_of: :function_value
8+
has_many :node_parameters, class_name: 'NodeParameter', inverse_of: :node_function
89

910

1011
validate :validate_recursion, if: :next_node_changed?

app/models/node_parameter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
class NodeParameter < ApplicationRecord
44
belongs_to :runtime_parameter, class_name: 'RuntimeParameterDefinition'
55
belongs_to :reference_value, optional: true
6-
belongs_to :function_value, class_name: 'NodeFunction', optional: true
6+
belongs_to :function_value, class_name: 'NodeFunction', optional: true, inverse_of: :node_parameter_values
7+
belongs_to :node_function, class_name: 'NodeFunction', inverse_of: :node_parameters
78

89
validate :only_one_value_present
910

app/services/namespaces/projects/flows/create_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def execute
4444
)
4545
end
4646

47-
res = ValidationService.new(current_authentication, flow).execute
47+
res = Validation::ValidationService.new(current_authentication, flow).execute
4848

4949
if res.error?
5050
t.rollback_and_return! ServiceResponse.error(

app/services/namespaces/projects/flows/update_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def execute
3131
)
3232
end
3333

34-
res = ValidationService.new(current_authentication, flow).execute
34+
res = Validation::ValidationService.new(current_authentication, flow).execute
3535

3636
if res.error?
3737
t.rollback_and_return! ServiceResponse.error(

0 commit comments

Comments
 (0)