forest_admin_agent 1.16.1 → 1.16.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: 15c6cbb6b1cb1d6c35475674167c413353fa3e5fedaf75822629fcfda8159435
4
- data.tar.gz: a58d74e6e83eebf306c1db260eb09bc894664375f85a2278834c677f8262923c
3
+ metadata.gz: 2f90ac8e625cfedb53dfe0685f1e12421e3ed251533d8dd4b835e18a9ae7ff4c
4
+ data.tar.gz: 4aef98f5fb87facd85b073f1e9944802793b85df7d51acdc0965d282666d3754
5
5
  SHA512:
6
- metadata.gz: ed9a6483fb2c21cf4309dc0b27a0877397d8f93e9fa1eeca5ee3a9a000b982c3893f3565a913f59c54916973a2da3066db26a6d60899f0f7937bd6fd80e8d0ce
7
- data.tar.gz: 84c17c5af3728db42dc5ebf6f359d89b06f902f2da01889fe2bf84e2f2b5d76f2cc30a2de29a0192d00a7b439788ae1f251de943630adbf36179e74f5cdeba66
6
+ metadata.gz: 71b4340b013bb0763a1d81ef512c31de2985fccbfeae07ee92bd64936c465a81a6158398421b8e54cac47ee431318e60b69a5bf4afe23a1ff98756e0359e0445
7
+ data.tar.gz: 70406d27923e97d332ec887e9024ad46a678dedf73e9a9a2f49882bbcb43915176b7cb8aff7b5865fd364b92fe6b9319f1d0ad5f93e60f11af636e4cf0b42a7c
@@ -18,7 +18,20 @@ module ForestAdminAgent
18
18
  args[:params][:data][:relationships]&.map do |field, value|
19
19
  schema = collection.schema[:fields][field]
20
20
 
21
- record[schema.foreign_key] = value.dig('data', 'id') if schema.type == 'ManyToOne'
21
+ if schema.type == 'ManyToOne'
22
+ record[schema.foreign_key] = value.dig('data', 'id')
23
+ elsif schema.type == 'PolymorphicManyToOne'
24
+ record[schema.foreign_key] = value.dig('data', 'id')
25
+ json_api_type = value.dig('data', 'type')
26
+ # Find matching collection from foreign_collections (handles both singular and plural forms)
27
+ model_name = schema.foreign_collections.find do |coll_name|
28
+ coll = collection.datasource.get_collection(coll_name)
29
+ coll.name == json_api_type || coll.name.pluralize == json_api_type
30
+ rescue ForestAdminDatasourceToolkit::Exceptions::ForestException
31
+ false
32
+ end || json_api_type
33
+ record[schema.foreign_key_type_field] = model_name
34
+ end
22
35
  end
23
36
 
24
37
  record || {}
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.16.1"
9
+ LIANA_VERSION = "1.16.2"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.16.1"
2
+ VERSION = "1.16.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.16.1
4
+ version: 1.16.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: 2025-12-03 00:00:00.000000000 Z
12
+ date: 2025-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport