forest_admin_rpc_agent 1.19.3 → 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: bc8cccff4fd75ea7fe14273663c7dec3b6abdc72dc79e9b479a9f5b5934f58e5
|
|
4
|
+
data.tar.gz: 85c668c4227e6eb22bbbc374b205c3951928b79a8b805690a91b36c25ebd441b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43dd1d0a2195cb331d3762ac0f48db95ba8f98ebbb87a7b501cb818805a747502cb63b14d8602e71759534780f47e7b37cf6e30f677aa00d2e6889eb9f5f8599
|
|
7
|
+
data.tar.gz: 2809c3c0153087f4c8e3d4ecac42d94ae63cdf325bba34dc825ca07c444bf7609e600dd31dc999671791435e63086ac82a6186f194ed2986074107f7eedd48c2
|
|
@@ -45,15 +45,6 @@ module ForestAdminRpcAgent
|
|
|
45
45
|
self
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# Returns the cached schema for the /rpc-schema route
|
|
49
|
-
# Falls back to building schema from datasource if not cached
|
|
50
|
-
def rpc_schema
|
|
51
|
-
return @cached_schema if @cached_schema
|
|
52
|
-
|
|
53
|
-
build_and_cache_rpc_schema_from_datasource
|
|
54
|
-
@cached_schema
|
|
55
|
-
end
|
|
56
|
-
|
|
57
48
|
# Check if provided hash matches the cached schema hash
|
|
58
49
|
def schema_hash_matches?(provided_hash)
|
|
59
50
|
return false unless @cached_schema_hash && provided_hash
|
|
@@ -84,19 +75,49 @@ module ForestAdminRpcAgent
|
|
|
84
75
|
)
|
|
85
76
|
end
|
|
86
77
|
|
|
87
|
-
def build_and_cache_rpc_schema_from_datasource
|
|
88
|
-
datasource = @container.resolve(:datasource)
|
|
89
|
-
|
|
90
|
-
@cached_schema = build_rpc_schema_from_datasource(datasource)
|
|
91
|
-
compute_and_cache_hash
|
|
92
|
-
end
|
|
93
|
-
|
|
94
78
|
def build_rpc_schema_from_datasource(datasource)
|
|
95
79
|
schema = customizer.schema
|
|
96
80
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
rpc_relations = {}
|
|
82
|
+
collections = []
|
|
83
|
+
|
|
84
|
+
datasource.collections.each_value do |collection|
|
|
85
|
+
relations = {}
|
|
86
|
+
|
|
87
|
+
if @rpc_collections.include?(collection.name)
|
|
88
|
+
# RPC collection → extract relations to non-RPC collections
|
|
89
|
+
collection.schema[:fields].each do |field_name, field|
|
|
90
|
+
next if field.type == 'Column'
|
|
91
|
+
next if @rpc_collections.include?(field.foreign_collection)
|
|
92
|
+
|
|
93
|
+
relations[field_name] = field
|
|
94
|
+
end
|
|
95
|
+
else
|
|
96
|
+
fields = {}
|
|
97
|
+
|
|
98
|
+
collection.schema[:fields].each do |field_name, field|
|
|
99
|
+
if field.type != 'Column' && @rpc_collections.include?(field.foreign_collection)
|
|
100
|
+
relations[field_name] = field
|
|
101
|
+
else
|
|
102
|
+
if field.type == 'Column'
|
|
103
|
+
field.filter_operators = ForestAdminAgent::Utils::Schema::FrontendFilterable.sort_operators(
|
|
104
|
+
field.filter_operators
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
fields[field_name] = field
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Normal collection → include in schema
|
|
113
|
+
collections << collection.schema.merge({ name: collection.name, fields: fields })
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
rpc_relations[collection.name] = relations unless relations.empty?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
schema[:collections] = collections.sort_by { |c| c[:name] }
|
|
120
|
+
schema[:rpc_relations] = rpc_relations
|
|
100
121
|
|
|
101
122
|
schema[:native_query_connections] = datasource.live_query_connections.keys
|
|
102
123
|
.map { |connection_name| { name: connection_name } }
|
|
@@ -104,31 +125,6 @@ module ForestAdminRpcAgent
|
|
|
104
125
|
schema
|
|
105
126
|
end
|
|
106
127
|
|
|
107
|
-
# Serialize collection schema, converting field objects to plain hashes
|
|
108
|
-
def serialize_collection_schema(collection)
|
|
109
|
-
schema = collection.schema.dup
|
|
110
|
-
schema[:name] = collection.name
|
|
111
|
-
schema[:fields] = schema[:fields].transform_values { |field| object_to_hash(field) }
|
|
112
|
-
schema
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# Convert any object to a hash using its instance variables
|
|
116
|
-
def object_to_hash(obj)
|
|
117
|
-
return obj if obj.is_a?(Hash) || obj.is_a?(Array) || obj.is_a?(String) || obj.is_a?(Numeric) || obj.nil?
|
|
118
|
-
|
|
119
|
-
hash = obj.instance_variables.to_h do |var|
|
|
120
|
-
[var.to_s.delete('@').to_sym, obj.instance_variable_get(var)]
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
if hash[:filter_operators].is_a?(Array)
|
|
124
|
-
hash[:filter_operators] = ForestAdminAgent::Utils::Schema::FrontendFilterable.sort_operators(
|
|
125
|
-
hash[:filter_operators]
|
|
126
|
-
)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
hash
|
|
130
|
-
end
|
|
131
|
-
|
|
132
128
|
def compute_and_cache_hash
|
|
133
129
|
return unless @cached_schema
|
|
134
130
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_rpc_agent
|
|
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: bin
|
|
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
|