forest_admin_rpc_agent 1.30.5 → 1.30.6

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: 7b87f32904f9a2d19ae17c3fc4a072fdd9b9507295650aad7b37f5f5422158e0
4
- data.tar.gz: 98ebfb88b77d5d27a1012e734d27d05c4626bf96530e0515e6fe25a38c3593a3
3
+ metadata.gz: 53b5e12f818c23964ae83123b35aa0c519c3ff2ac455ba2c518fea37b37e4d2c
4
+ data.tar.gz: fd85d6d60ab150a0375dbfb9681696b28b6f93c4f1e94a30646e2e34c3a8adad
5
5
  SHA512:
6
- metadata.gz: 9e80b93723b13efccc4c5e6682b3336024915354ade50cebae5044e166e4187334c4db35627ca184e0e78db05a3fb6ad7270889fadadd5049ba6db0de43d4f8e
7
- data.tar.gz: 6eaefdd80f3b2dfc96764f111773304f0adc5575e3b2e0376d7f1824b06b0426ba8b3d3483cfa517148a7370e44b2968f03fc64019e62478bef08f200b772302
6
+ metadata.gz: 80e426d3044d3d93494696987be64a46d2033d8547bb5aecb09cb101b69268864d450fc8a4a7c17ac813a1c1db56a173f82a699d4a6ff2b4b73aa420451338c6
7
+ data.tar.gz: 739cd6a8a363d9bc8ebb28480d958f5aed1fd488021cba32ee1568512c5a11517698f9d2f856776dcfcd0f4ab6936f1640c780c3c78e2ef3246aea0a282a8e86
@@ -12,8 +12,6 @@ module ForestAdminRpcAgent
12
12
  end
13
13
 
14
14
  def handle_request(args)
15
- return {} unless args[:params]['collection_name']
16
-
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
18
16
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
19
17
  filter = FilterFactory.from_plain_object(args[:params]['filter'])
@@ -12,8 +12,6 @@ module ForestAdminRpcAgent
12
12
  end
13
13
 
14
14
  def handle_request(args)
15
- return {} unless args[:params]['collection_name']
16
-
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
18
16
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
19
17
  filter = FilterFactory.from_plain_object(args[:params]['filter'])
@@ -12,15 +12,13 @@ module ForestAdminRpcAgent
12
12
  end
13
13
 
14
14
  def handle_request(args)
15
- return {} unless args[:params]['collection_name']
16
-
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
18
16
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
19
17
 
20
18
  aggregation = Aggregation.new(
21
19
  operation: args[:params]['aggregation']['operation'],
22
20
  field: args[:params]['aggregation']['field'],
23
- groups: args[:params]['aggregation']['groups']
21
+ groups: args[:params]['aggregation']['groups'] || []
24
22
  )
25
23
  filter = FilterFactory.from_plain_object(args[:params]['filter'])
26
24
 
@@ -39,16 +39,16 @@ module ForestAdminRpcAgent
39
39
 
40
40
  # Skip authentication for health check (root path)
41
41
  if @url == '/'
42
- params = deep_symbolize_keys(request.query_parameters.merge(request.request_parameters))
43
- result = handle_request({ params: params.with_indifferent_access, caller: nil, request: request })
42
+ params = extract_request_params(request)
43
+ result = handle_request({ params: params, caller: nil, request: request })
44
44
  build_rails_response(result)
45
45
  else
46
46
  auth_middleware = ForestAdminRpcAgent::Middleware::Authentication.new(->(_env) { [200, {}, ['OK']] })
47
47
  status, headers, response = auth_middleware.call(request.env)
48
48
 
49
49
  if status == 200
50
- params = deep_symbolize_keys(request.query_parameters.merge(request.request_parameters))
51
- result = handle_request({ params: params.with_indifferent_access, caller: headers[:caller], request: request })
50
+ params = extract_request_params(request)
51
+ result = handle_request({ params: params, caller: headers[:caller], request: request })
52
52
  build_rails_response(result)
53
53
  else
54
54
  [status, headers, response]
@@ -87,15 +87,15 @@ module ForestAdminRpcAgent
87
87
 
88
88
  private
89
89
 
90
- def deep_symbolize_keys(obj)
91
- case obj
92
- when Hash
93
- obj.transform_keys(&:to_sym).transform_values { |v| deep_symbolize_keys(v) }
94
- when Array
95
- obj.map { |v| deep_symbolize_keys(v) }
96
- else
97
- obj
98
- end
90
+ # Merge path params (e.g. :collection_name from the URL) with query and body params so
91
+ # consumers that don't duplicate `collection_name` in the body (the Node datasource-rpc)
92
+ # still resolve the route correctly.
93
+ def extract_request_params(request)
94
+ request.path_parameters
95
+ .except(:controller, :action, :format)
96
+ .merge(request.query_parameters)
97
+ .merge(request.request_parameters)
98
+ .with_indifferent_access
99
99
  end
100
100
 
101
101
  def serialize_response(result)
@@ -10,8 +10,6 @@ module ForestAdminRpcAgent
10
10
  end
11
11
 
12
12
  def handle_request(args)
13
- return {} unless args[:params]['collection_name']
14
-
15
13
  chart_name = args[:params]['chart']
16
14
  parameters = args[:params]['parameters']
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
@@ -8,8 +8,6 @@ module ForestAdminRpcAgent
8
8
  end
9
9
 
10
10
  def handle_request(args)
11
- return {} unless args[:params]['collection_name']
12
-
13
11
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
14
12
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
15
13
 
@@ -12,8 +12,6 @@ module ForestAdminRpcAgent
12
12
  end
13
13
 
14
14
  def handle_request(args)
15
- return {} unless args[:params]['collection_name']
16
-
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
18
16
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
19
17
  filter = FilterFactory.from_plain_object(args[:params]['filter'])
@@ -12,8 +12,6 @@ module ForestAdminRpcAgent
12
12
  end
13
13
 
14
14
  def handle_request(args)
15
- return {} unless args[:params]['collection_name']
16
-
17
15
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
18
16
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
19
17
  projection = Projection.new(args[:params]['projection'])
@@ -10,8 +10,6 @@ module ForestAdminRpcAgent
10
10
  end
11
11
 
12
12
  def handle_request(args)
13
- return {} unless args[:params]['collection_name']
14
-
15
13
  datasource = ForestAdminRpcAgent::Facades::Container.datasource
16
14
  collection = get_collection_safe(datasource, args[:params]['collection_name'])
17
15
  filter = FilterFactory.from_plain_object(args[:params]['filter'])
@@ -1,3 +1,3 @@
1
1
  module ForestAdminRpcAgent
2
- VERSION = "1.30.5"
2
+ VERSION = "1.30.6"
3
3
  end
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.30.5
4
+ version: 1.30.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu