forest_admin_datasource_rpc 1.19.2 → 1.20.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3654db7ed62a81cca890f6e490cd82a05330911319c4406c987133255d985ce0
|
|
4
|
+
data.tar.gz: 50e9adbb8a0c605f1936c8dadb013be356159af99c2f31ebd9ac02778ee3d4ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe1c08c4f60b742bb7110a1f6df8bbe6760c4b996e68307388b3c7ed2a617adaf3e51e2b3fd13b8def532ddc79491b06f9ec7cd97f2007e071ada533bd66b808
|
|
7
|
+
data.tar.gz: aecb3af3e1bd1ce74851ed6d7c87b7337e906e37cfcec774dbde0567d782fc680505ebcf4c339a792444de826af43ed8c5ef7b2a73bed553a5d98719269c3eef
|
|
@@ -2,7 +2,7 @@ module ForestAdminDatasourceRpc
|
|
|
2
2
|
class Datasource < ForestAdminDatasourceToolkit::Datasource
|
|
3
3
|
include ForestAdminDatasourceRpc::Utils
|
|
4
4
|
|
|
5
|
-
attr_reader :shared_rpc_client
|
|
5
|
+
attr_reader :shared_rpc_client, :rpc_relations
|
|
6
6
|
|
|
7
7
|
def initialize(options, introspection, schema_polling_client = nil)
|
|
8
8
|
super()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module ForestAdminDatasourceRpc
|
|
2
|
+
class ReconciliateRpc < ForestAdminDatasourceCustomizer::Plugins::Plugin
|
|
3
|
+
def run(datasource_customizer, _collection_customizer = nil, options = {})
|
|
4
|
+
datasource_customizer.composite_datasource.datasources.each do |datasource|
|
|
5
|
+
real_datasource = get_datasource(datasource)
|
|
6
|
+
next unless real_datasource.is_a?(ForestAdminDatasourceRpc::Datasource)
|
|
7
|
+
|
|
8
|
+
# Disable search for non-searchable collections
|
|
9
|
+
real_datasource.collections.each_value do |collection|
|
|
10
|
+
unless collection.schema[:searchable]
|
|
11
|
+
cz = datasource_customizer.get_collection(get_collection_name(options[:rename], collection.name))
|
|
12
|
+
cz.disable_search
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Add relations from rpc_relations
|
|
17
|
+
(real_datasource.rpc_relations || {}).each do |collection_name, relations|
|
|
18
|
+
collection_name = get_collection_name(options[:rename], collection_name)
|
|
19
|
+
cz = datasource_customizer.get_collection(collection_name)
|
|
20
|
+
|
|
21
|
+
relations.each do |relation_name, relation_definition|
|
|
22
|
+
add_relation(cz, options[:rename], relation_name.to_s, relation_definition)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def get_datasource(datasource)
|
|
31
|
+
# can be publication -> rename deco or a custom one
|
|
32
|
+
while datasource.is_a?(ForestAdminDatasourceToolkit::Decorators::DatasourceDecorator)
|
|
33
|
+
datasource = datasource.child_datasource
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
datasource
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_collection_name(renames, collection_name)
|
|
40
|
+
name = collection_name
|
|
41
|
+
|
|
42
|
+
if renames.is_a?(Proc)
|
|
43
|
+
name = renames.call(collection_name)
|
|
44
|
+
elsif renames.is_a?(Hash) && renames.key?(collection_name.to_s)
|
|
45
|
+
name = renames[collection_name.to_s]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
name
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def add_relation(collection_customizer, renames, relation_name, relation_definition)
|
|
52
|
+
relation = relation_definition.transform_keys(&:to_sym)
|
|
53
|
+
foreign_collection = get_collection_name(renames, relation[:foreign_collection])
|
|
54
|
+
options = relation.except(:type, :foreign_collection, :through_collection)
|
|
55
|
+
|
|
56
|
+
case relation[:type]
|
|
57
|
+
when 'ManyToMany'
|
|
58
|
+
through_collection = get_collection_name(renames, relation[:through_collection])
|
|
59
|
+
collection_customizer.add_many_to_many_relation(relation_name, foreign_collection, through_collection, options)
|
|
60
|
+
when 'OneToMany'
|
|
61
|
+
collection_customizer.add_one_to_many_relation(relation_name, foreign_collection, options)
|
|
62
|
+
when 'OneToOne'
|
|
63
|
+
collection_customizer.add_one_to_one_relation(relation_name, foreign_collection, options)
|
|
64
|
+
when 'ManyToOne'
|
|
65
|
+
collection_customizer.add_many_to_one_relation(relation_name, foreign_collection, options)
|
|
66
|
+
else
|
|
67
|
+
raise ForestAdminDatasourceToolkit::Exceptions::ForestException, "Unsupported relation type: #{relation[:type]}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -55,6 +55,7 @@ module ForestAdminDatasourceRpc
|
|
|
55
55
|
'Fatal: Unable to build RPC datasource - no introspection schema was provided and schema fetch failed'
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
options.delete(:introspection)
|
|
58
59
|
ForestAdminDatasourceRpc::Datasource.new(options, schema, schema_polling)
|
|
59
60
|
end
|
|
60
61
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_datasource_rpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.20.0
|
|
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-
|
|
12
|
+
date: 2026-01-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: base64
|
|
@@ -129,6 +129,7 @@ files:
|
|
|
129
129
|
- lib/forest_admin_datasource_rpc/Utils/schema_polling_pool.rb
|
|
130
130
|
- lib/forest_admin_datasource_rpc/collection.rb
|
|
131
131
|
- lib/forest_admin_datasource_rpc/datasource.rb
|
|
132
|
+
- lib/forest_admin_datasource_rpc/reconciliate_rpc.rb
|
|
132
133
|
- lib/forest_admin_datasource_rpc/version.rb
|
|
133
134
|
homepage: https://www.forestadmin.com
|
|
134
135
|
licenses:
|