forest_admin_agent 1.22.1 → 1.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8fffc77a88e0532998d8ffc2435dda3b80e80ab9ff79b4014ff9efdddc3c188
4
- data.tar.gz: eae38bbc7312915daf6bf7db753e0396f2ce14ee30ce7860d3cd4b2b8287d220
3
+ metadata.gz: f6b1a6dbfefd96dbfca1747408a469e1f1c958729bcb315bdca0e85c4e5ac793
4
+ data.tar.gz: c55afac42cd9d73409393db3f4623929ee0957c3d5ad7a8ebdef2fb670f35b4e
5
5
  SHA512:
6
- metadata.gz: e6cd2de42ff47b3dbf895eb480231c6dcd7e0ebff20b6df1afd0a5606a665d42499962ab33691531287149ea2cb5b815a7c82ae757650744cc691755f335c9e7
7
- data.tar.gz: f76d0eadee1e945ac5376151034e8bdf5246732b672499f30cc23428da15157865b67af2258f9487ffda48aba7b794f4e68874b6204d6a37b6732440808b01fa
6
+ metadata.gz: 4e37682ac9bffedc453f31b0f411ca655558586a1a8e6b5619f95faf220822364d16b20c97189159fcdb0c13f990e1b4e5d7e54afda4f13fa93c9a0329721351
7
+ data.tar.gz: 3d7c3749866fda27ba50c755dbefaab87a4637167804a35670737087318517c50c59b28eeda5cf5514f0cfe5671311b49bf04039437d53886f556038a38cbecd
@@ -40,10 +40,11 @@ module ForestAdminAgent
40
40
  add_polymorphic_type_fields(collection, requested_field_names)
41
41
  projection_fields = build_projection_fields(collection, requested_field_names, args)
42
42
 
43
- projection = Projection.new(projection_fields)
44
- ForestAdminDatasourceToolkit::Validations::ProjectionValidator.validate?(collection, projection)
43
+ ForestAdminDatasourceToolkit::Validations::ProjectionValidator.validate?(collection, projection_fields)
45
44
 
46
- projection
45
+ Projection.new(projection_fields)
46
+ rescue ForestAdminDatasourceToolkit::Exceptions::ForestException => e
47
+ raise BadRequestError, "Invalid projection: #{e.message}"
47
48
  end
48
49
 
49
50
  def self.add_polymorphic_type_fields(collection, requested_field_names)
@@ -63,17 +64,31 @@ module ForestAdminAgent
63
64
 
64
65
  def self.build_projection_fields(collection, requested_field_names, args)
65
66
  requested_field_names.map do |field_name|
66
- column = collection.schema[:fields][field_name]
67
- if column.type == 'Column'
67
+ field = get_field(collection, field_name)
68
+
69
+ case field.type
70
+ when 'Column'
68
71
  field_name
69
- elsif column.type == 'PolymorphicManyToOne'
72
+ when 'PolymorphicManyToOne'
70
73
  "#{field_name}:*"
71
74
  else
72
- "#{field_name}:#{args[:params][:fields][field_name]}"
75
+ relation_fields = args.dig(:params, :fields, field_name)
76
+ "#{field_name}:#{relation_fields}"
73
77
  end
74
78
  end
75
79
  end
76
- private_class_method :add_polymorphic_type_fields, :build_projection_fields
80
+
81
+ def self.get_field(collection, field_name)
82
+ field = collection.schema[:fields][field_name]
83
+ return field unless field.nil?
84
+
85
+ available_fields = collection.schema[:fields].keys.join(', ')
86
+ raise ForestAdminDatasourceToolkit::Exceptions::ValidationError,
87
+ "The '#{collection.name}.#{field_name}' field was not found. " \
88
+ "Available fields are: [#{available_fields}]. " \
89
+ 'Please check if the field name is correct.'
90
+ end
91
+ private_class_method :add_polymorphic_type_fields, :build_projection_fields, :get_field
77
92
 
78
93
  def self.parse_projection_with_pks(collection, args)
79
94
  projection = parse_projection(collection, args)
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.22.1"
9
+ LIANA_VERSION = "1.22.2"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.22.1"
2
+ VERSION = "1.22.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.1
4
+ version: 1.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-01-13 00:00:00.000000000 Z
12
+ date: 2026-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport