forest_admin_rpc_agent 1.30.6 → 1.30.7

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: 53b5e12f818c23964ae83123b35aa0c519c3ff2ac455ba2c518fea37b37e4d2c
4
- data.tar.gz: fd85d6d60ab150a0375dbfb9681696b28b6f93c4f1e94a30646e2e34c3a8adad
3
+ metadata.gz: 943cb5cbbec8a205970615612a16fa5f1700db0ae7ccf284720d35f0c21202bc
4
+ data.tar.gz: 0271eaed846c182822afc4dbf1159fd584989b87c3d0f09f876de284270d676c
5
5
  SHA512:
6
- metadata.gz: 80e426d3044d3d93494696987be64a46d2033d8547bb5aecb09cb101b69268864d450fc8a4a7c17ac813a1c1db56a173f82a699d4a6ff2b4b73aa420451338c6
7
- data.tar.gz: 739cd6a8a363d9bc8ebb28480d958f5aed1fd488021cba32ee1568512c5a11517698f9d2f856776dcfcd0f4ab6936f1640c780c3c78e2ef3246aea0a282a8e86
6
+ metadata.gz: e1c51a56c98dcd566d0580ab7895c1421225340bccfb2fc495ccd13dc403f3bccf71d016241e2573334ff090a309829ecfb7467b1e7deba789b879138eb8b196
7
+ data.tar.gz: e9492a5e03758c31b6481977964bccdae3faf7e9a967e6903bab63b5931c2a2510a912e1256c8a817931f91dd59267fbad86a7f80b70f28f97c0adff27e75403
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+ require 'json'
1
3
  require 'jsonapi-serializers'
2
4
 
3
5
  module ForestAdminRpcAgent
@@ -18,7 +20,31 @@ module ForestAdminRpcAgent
18
20
  data = args[:params]['data']
19
21
  action = args[:params]['action']
20
22
 
21
- collection.execute(args[:caller], action, data, filter)
23
+ result = collection.execute(args[:caller], action, data, filter)
24
+
25
+ return build_file_response(result) if file_result?(result)
26
+
27
+ result
28
+ end
29
+
30
+ private
31
+
32
+ def file_result?(result)
33
+ result.is_a?(Hash) && result[:type] == 'File'
34
+ end
35
+
36
+ def build_file_response(result)
37
+ encoded_name = CGI.escape(result[:name].to_s)
38
+ headers = {
39
+ 'Content-Type' => result[:mime_type],
40
+ 'Content-Disposition' => %(attachment; filename="#{encoded_name}"),
41
+ 'X-Forest-Action-Type' => 'File',
42
+ 'X-Forest-Action-File-Name' => encoded_name
43
+ }
44
+ headers['X-Forest-Action-Response-Headers'] = result[:response_headers].to_json if result[:response_headers]
45
+
46
+ # raw: true skips JSON encoding — file streams are arbitrary binary bytes.
47
+ { status: 200, headers: headers, content: result[:stream], raw: true }
22
48
  end
23
49
  end
24
50
  end
@@ -26,7 +26,13 @@ module ForestAdminRpcAgent
26
26
  status result[:status]
27
27
  # Set custom headers if provided
28
28
  result[:headers]&.each { |key, value| headers[key] = value }
29
- result[:content] ? serialize_response(result[:content]) : ''
29
+ if result[:content].nil?
30
+ ''
31
+ elsif result[:raw]
32
+ result[:content].to_s
33
+ else
34
+ serialize_response(result[:content])
35
+ end
30
36
  else
31
37
  serialize_response(result)
32
38
  end
@@ -68,7 +74,13 @@ module ForestAdminRpcAgent
68
74
  if result.is_a?(Hash) && result.key?(:status)
69
75
  response_headers = { 'Content-Type' => 'application/json' }
70
76
  response_headers.merge!(result[:headers]) if result[:headers]
71
- body = result[:content] ? serialize_response(result[:content]) : ''
77
+ body = if result[:content].nil?
78
+ ''
79
+ elsif result[:raw]
80
+ result[:content].to_s
81
+ else
82
+ serialize_response(result[:content])
83
+ end
72
84
  [result[:status], response_headers, [body]]
73
85
  else
74
86
  [200, { 'Content-Type' => 'application/json' }, [serialize_response(result)]]
@@ -1,3 +1,3 @@
1
1
  module ForestAdminRpcAgent
2
- VERSION = "1.30.6"
2
+ VERSION = "1.30.7"
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.6
4
+ version: 1.30.7
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-05-22 00:00:00.000000000 Z
12
+ date: 2026-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: base64