forest_admin_datasource_rpc 1.13.1 → 1.13.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 +4 -4
- data/lib/forest_admin_datasource_rpc/Utils/rpc_client.rb +3 -1
- data/lib/forest_admin_datasource_rpc/collection.rb +21 -27
- data/lib/forest_admin_datasource_rpc/datasource.rb +9 -7
- data/lib/forest_admin_datasource_rpc/version.rb +1 -1
- data/lib/forest_admin_datasource_rpc.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5c715351293fd36cb411085ff8efb48b21746d8324f20abe23cb8b4921cd038
|
|
4
|
+
data.tar.gz: f8edd7ff3f772a3c2dcfeabadfe1d20a4c06989bc6ecb96a5c4273f7396c91d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d54622d8ab197d024e4f6a91e9ba300bcaec6553cd139bc03755cfe51f81da550a3d3998a13b0a855275fa8a1e8303b872dd30f6f8342540edc647d4b6fafdc
|
|
7
|
+
data.tar.gz: fb9429ec75ca3c1ceec014a3756e4424f546b741d3ca8b7c295d574bed7af08b91ea7b1e20e193aee565cd32ae46a308213e7a49190757221d9a75d238fa25b4
|
|
@@ -33,7 +33,7 @@ module ForestAdminDatasourceRpc
|
|
|
33
33
|
@auth_secret = auth_secret
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def call_rpc(endpoint, method: :get, payload: nil, symbolize_keys: false)
|
|
36
|
+
def call_rpc(endpoint, caller: nil, method: :get, payload: nil, symbolize_keys: false)
|
|
37
37
|
client = Faraday.new(url: @api_url) do |faraday|
|
|
38
38
|
faraday.request :json
|
|
39
39
|
faraday.response :json, parser_options: { symbolize_names: symbolize_keys }
|
|
@@ -50,6 +50,8 @@ module ForestAdminDatasourceRpc
|
|
|
50
50
|
'X_SIGNATURE' => signature
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
headers['forest_caller'] = caller.to_json if caller
|
|
54
|
+
|
|
53
55
|
response = client.send(method, endpoint, payload, headers)
|
|
54
56
|
|
|
55
57
|
handle_response(response)
|
|
@@ -9,7 +9,7 @@ module ForestAdminDatasourceRpc
|
|
|
9
9
|
def initialize(datasource, name, options, schema)
|
|
10
10
|
super(datasource, name)
|
|
11
11
|
@options = options
|
|
12
|
-
@client = RpcClient.new(@options[:uri], ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
12
|
+
@client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
13
13
|
@rpc_collection_uri = "/forest/rpc/#{name}"
|
|
14
14
|
@base_params = { collection_name: name }
|
|
15
15
|
|
|
@@ -30,6 +30,8 @@ module ForestAdminDatasourceRpc
|
|
|
30
30
|
field_name = field_name.to_s
|
|
31
31
|
type = schema[:type]
|
|
32
32
|
schema.delete(:type)
|
|
33
|
+
# remove these
|
|
34
|
+
schema.delete(:allow_null)
|
|
33
35
|
case type
|
|
34
36
|
when 'Column'
|
|
35
37
|
add_field(field_name, ForestAdminDatasourceToolkit::Schema::ColumnSchema.new(**schema))
|
|
@@ -55,8 +57,7 @@ module ForestAdminDatasourceRpc
|
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
def list(caller, filter, projection)
|
|
58
|
-
params = build_params(
|
|
59
|
-
timezone: caller.timezone)
|
|
60
|
+
params = build_params(filter: filter.to_h, projection: projection)
|
|
60
61
|
url = "#{@rpc_collection_uri}/list"
|
|
61
62
|
|
|
62
63
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -64,11 +65,11 @@ module ForestAdminDatasourceRpc
|
|
|
64
65
|
"Forwarding '#{@name}' list call to the Rpc agent on #{url}."
|
|
65
66
|
)
|
|
66
67
|
|
|
67
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
68
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
def create(caller, data)
|
|
71
|
-
params = build_params(
|
|
72
|
+
params = build_params(data: [data])
|
|
72
73
|
url = "#{@rpc_collection_uri}/create"
|
|
73
74
|
|
|
74
75
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -76,11 +77,12 @@ module ForestAdminDatasourceRpc
|
|
|
76
77
|
"Forwarding '#{@name}' creation call to the Rpc agent on #{url}."
|
|
77
78
|
)
|
|
78
79
|
|
|
79
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
80
|
+
res = @client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
81
|
+
res.first
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
def update(caller, filter, data)
|
|
83
|
-
params = build_params(
|
|
85
|
+
params = build_params(filter: filter.to_h, patch: data)
|
|
84
86
|
url = "#{@rpc_collection_uri}/update"
|
|
85
87
|
|
|
86
88
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -88,11 +90,11 @@ module ForestAdminDatasourceRpc
|
|
|
88
90
|
"Forwarding '#{@name}' update call to the Rpc agent on #{url}."
|
|
89
91
|
)
|
|
90
92
|
|
|
91
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
93
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
def delete(caller, filter)
|
|
95
|
-
params = build_params(
|
|
97
|
+
params = build_params(filter: filter.to_h)
|
|
96
98
|
url = "#{@rpc_collection_uri}/delete"
|
|
97
99
|
|
|
98
100
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -100,12 +102,11 @@ module ForestAdminDatasourceRpc
|
|
|
100
102
|
"Forwarding '#{@name}' deletion call to the Rpc agent on #{url}."
|
|
101
103
|
)
|
|
102
104
|
|
|
103
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
105
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
104
106
|
end
|
|
105
107
|
|
|
106
108
|
def aggregate(caller, filter, aggregation, limit = nil)
|
|
107
|
-
params = build_params(
|
|
108
|
-
timezone: caller.timezone)
|
|
109
|
+
params = build_params(filter: filter.to_h, aggregation: aggregation.to_h, limit: limit)
|
|
109
110
|
url = "#{@rpc_collection_uri}/aggregate"
|
|
110
111
|
|
|
111
112
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -113,18 +114,12 @@ module ForestAdminDatasourceRpc
|
|
|
113
114
|
"Forwarding '#{@name}' aggregate call to the Rpc agent on #{url}."
|
|
114
115
|
)
|
|
115
116
|
|
|
116
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
117
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
117
118
|
end
|
|
118
119
|
|
|
119
120
|
def execute(caller, name, data, filter = nil)
|
|
120
121
|
data = encode_form_data(data)
|
|
121
|
-
params = build_params(
|
|
122
|
-
caller: caller.to_h,
|
|
123
|
-
timezone: caller.timezone,
|
|
124
|
-
action: name,
|
|
125
|
-
filter: filter&.to_h,
|
|
126
|
-
data: data
|
|
127
|
-
)
|
|
122
|
+
params = build_params(action: name, filter: filter&.to_h, data: data)
|
|
128
123
|
url = "#{@rpc_collection_uri}/action-execute"
|
|
129
124
|
|
|
130
125
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -132,15 +127,14 @@ module ForestAdminDatasourceRpc
|
|
|
132
127
|
"Forwarding '#{@name}' action #{name} call to the Rpc agent on #{url}."
|
|
133
128
|
)
|
|
134
129
|
|
|
135
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
130
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
136
131
|
end
|
|
137
132
|
|
|
138
133
|
def get_form(caller, name, data = nil, filter = nil, metas = nil)
|
|
139
134
|
params = build_params(action: name)
|
|
140
135
|
if caller
|
|
141
136
|
data = encode_form_data(data)
|
|
142
|
-
params = params.merge({
|
|
143
|
-
data: data })
|
|
137
|
+
params = params.merge({ filter: filter&.to_h, metas: metas, data: data })
|
|
144
138
|
end
|
|
145
139
|
url = "#{@rpc_collection_uri}/action-form"
|
|
146
140
|
|
|
@@ -149,14 +143,14 @@ module ForestAdminDatasourceRpc
|
|
|
149
143
|
"Forwarding '#{@name}' action form #{name} call to the Rpc agent on #{url}."
|
|
150
144
|
)
|
|
151
145
|
|
|
152
|
-
result = @client.call_rpc(url, method: :post, payload: params, symbolize_keys: true)
|
|
153
|
-
|
|
146
|
+
result = @client.call_rpc(url, caller: caller, method: :post, payload: params, symbolize_keys: true)
|
|
147
|
+
result.map do |field|
|
|
154
148
|
Actions::ActionFieldFactory.build(field.to_h)
|
|
155
149
|
end
|
|
156
150
|
end
|
|
157
151
|
|
|
158
152
|
def render_chart(caller, name, record_id)
|
|
159
|
-
params = build_params(
|
|
153
|
+
params = build_params(chart: name, record_id: record_id)
|
|
160
154
|
url = "#{@rpc_collection_uri}/chart"
|
|
161
155
|
|
|
162
156
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
@@ -164,7 +158,7 @@ module ForestAdminDatasourceRpc
|
|
|
164
158
|
"Forwarding '#{@name}' chart #{name} call to the Rpc agent on #{url}."
|
|
165
159
|
)
|
|
166
160
|
|
|
167
|
-
@client.call_rpc(url, method: :post, payload: params)
|
|
161
|
+
@client.call_rpc(url, caller: caller, method: :post, payload: params)
|
|
168
162
|
end
|
|
169
163
|
|
|
170
164
|
private
|
|
@@ -19,34 +19,36 @@ module ForestAdminDatasourceRpc
|
|
|
19
19
|
@charts = introspection[:charts]
|
|
20
20
|
@rpc_relations = introspection[:rpc_relations]
|
|
21
21
|
|
|
22
|
-
native_query_connections = introspection[:
|
|
22
|
+
native_query_connections = introspection[:native_query_connections] || []
|
|
23
23
|
@live_query_connections = native_query_connections.to_h { |conn| [conn[:name], conn[:name]] }
|
|
24
24
|
|
|
25
25
|
@schema = { charts: @charts }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def render_chart(caller, name)
|
|
29
|
-
client = RpcClient.new(@options[:uri], ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
30
|
-
url = 'forest/rpc
|
|
29
|
+
client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
30
|
+
url = 'forest/rpc-datasource-chart'
|
|
31
31
|
|
|
32
32
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
33
33
|
'Debug',
|
|
34
34
|
"Forwarding datasource chart '#{name}' call to the Rpc agent on #{url}."
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
client.call_rpc(url, method: :post, payload: { chart: name
|
|
37
|
+
client.call_rpc(url, caller: caller, method: :post, payload: { chart: name })
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def execute_native_query(connection_name, query, binds)
|
|
41
|
-
client = RpcClient.new(@options[:uri], ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
42
|
-
url = 'forest/rpc
|
|
41
|
+
client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminRpcAgent::Facades::Container.cache(:auth_secret))
|
|
42
|
+
url = 'forest/rpc-native-query'
|
|
43
43
|
|
|
44
44
|
ForestAdminRpcAgent::Facades::Container.logger.log(
|
|
45
45
|
'Debug',
|
|
46
46
|
"Forwarding native query for connection '#{connection_name}' to the Rpc agent on #{url}."
|
|
47
47
|
)
|
|
48
48
|
|
|
49
|
-
client.call_rpc(url, method: :post,
|
|
49
|
+
result = client.call_rpc(url, method: :post,
|
|
50
|
+
payload: { connection_name: connection_name, query: query, binds: binds })
|
|
51
|
+
ForestAdminDatasourceToolkit::Utils::HashHelper.convert_keys(result.to_a)
|
|
50
52
|
end
|
|
51
53
|
end
|
|
52
54
|
end
|
|
@@ -10,7 +10,7 @@ module ForestAdminDatasourceRpc
|
|
|
10
10
|
|
|
11
11
|
def self.build(options)
|
|
12
12
|
uri = options[:uri]
|
|
13
|
-
auth_secret = ForestAdminRpcAgent::Facades::Container.cache(:auth_secret)
|
|
13
|
+
auth_secret = options[:auth_secret] || ForestAdminRpcAgent::Facades::Container.cache(:auth_secret)
|
|
14
14
|
ForestAdminRpcAgent::Facades::Container.logger.log('Info', "Getting schema from RPC agent on #{uri}.")
|
|
15
15
|
|
|
16
16
|
begin
|
|
@@ -28,7 +28,7 @@ module ForestAdminDatasourceRpc
|
|
|
28
28
|
# return empty datasource for not breaking stack
|
|
29
29
|
ForestAdminDatasourceToolkit::Datasource.new
|
|
30
30
|
else
|
|
31
|
-
sse = Utils::SseClient.new("#{uri}/forest/
|
|
31
|
+
sse = Utils::SseClient.new("#{uri}/forest/sse", auth_secret) do
|
|
32
32
|
ForestAdminRpcAgent::Facades::Container.logger.log('Info', 'RPC server stopped, checking schema...')
|
|
33
33
|
new_schema = rpc_client.call_rpc('/forest/rpc-schema', method: :get, symbolize_keys: true)
|
|
34
34
|
|
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.13.
|
|
4
|
+
version: 1.13.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-11-
|
|
12
|
+
date: 2025-11-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: base64
|