forest_admin_rails 1.0.0.pre.beta.47 → 1.0.0.pre.beta.49

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: 9098b82f74fcdf551b0036f545660a761cd87cadef7f25e9a449de1a34a425f2
4
- data.tar.gz: 39d641d336baa783b3b0d50ce25f11d64c93f07ccd0fc188d2f49e82ce878cd5
3
+ metadata.gz: 67436e50177b80815908a56e521e344ef770ff6f3f4b3d8d4a1969d62aff96e7
4
+ data.tar.gz: 3fd653d28b29598d08ef7587391ca8a554d7e5b722c69fafe234964229413266
5
5
  SHA512:
6
- metadata.gz: 9932e6634074a8fc67bcbe398f44ef880816c65c5b1dfdd4af924e7fce1527fd81ada5e0c82eaa4b03d73fc0e5fe7e3e2df2eb5307cc2fb7fb96c6399020526e
7
- data.tar.gz: ec208cc7ae039185234ad226f4584de6685ea58be880e925e5e71fef98cd65d6abfa93a157c271842e6acbf09f1a2cc394535125d69410d62f1b198744f3e70a
6
+ metadata.gz: 4db457f778f5824edf92e58f6978e75dd42bafff982fed1939cd07649d589ade46ea84b18b7b3359ab37a538d4f55bbb421ebef576433022aff072c2a7017396
7
+ data.tar.gz: fce8ea0aaa4cbc5ee516796415908b3f0db1a967e91df7b2d5fc034083432575c777900a2247ed5d840438f492d27f03f5e3f2467201fbdb5371c0ad8206ab32
@@ -1,5 +1,7 @@
1
1
  module ForestAdminRails
2
2
  class ForestController < ActionController::Base
3
+ include ForestAdminAgent::Http::ErrorHandling
4
+
3
5
  skip_forgery_protection
4
6
 
5
7
  def index
@@ -22,10 +24,15 @@ module ForestAdminRails
22
24
  disposition: 'attachment'
23
25
  end
24
26
 
25
- response.headers.merge!(data[:content][:headers] || {})
26
- data[:content].delete(:headers)
27
+ if data.dig(:content, :headers)
28
+ response.headers.merge!(data[:content][:headers] || {})
29
+ data[:content].delete(:headers)
30
+ end
27
31
 
28
- render json: data[:content], head: headers, status: data[:status] || data[:content][:status] || 200
32
+ respond_to do |format|
33
+ format.json { render json: data[:content], status: data[:status] || data[:content][:status] || 200 }
34
+ format.csv { render plain: data[:content][:export], status: 200, filename: data[:filename] }
35
+ end
29
36
  end
30
37
 
31
38
  def exception_handler(exception)
@@ -40,7 +47,7 @@ module ForestAdminRails
40
47
  errors: [
41
48
  {
42
49
  name: exception.name,
43
- detail: exception.message,
50
+ detail: get_error_message(exception),
44
51
  status: exception.try(:status)
45
52
  }
46
53
  ]
@@ -49,7 +56,7 @@ module ForestAdminRails
49
56
  data[:errors][0][:data] = exception.try(:data)
50
57
  end
51
58
 
52
- unless Facades::Container.cache(:is_production)
59
+ unless ForestAdminAgent::Facades::Container.cache(:is_production)
53
60
  ForestAdminAgent::Facades::Container.logger.log('Debug', exception.full_message)
54
61
  end
55
62
 
@@ -1,6 +1,6 @@
1
1
  class ForestAdminErrorSubscriber
2
- def report(error, _handled:, _severity:, _context:, _source: nil)
3
- return if Facades::Container.cache(:is_production)
2
+ def report(error, handled:, severity:, context:, source: nil)
3
+ return if ForestAdminAgent::Facades::Container.cache(:is_production)
4
4
 
5
5
  ForestAdminAgent::Facades::Container.logger.log('Debug', error.full_message)
6
6
  end
data/config/routes.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  ForestAdminRails::Engine.routes.draw do
2
2
  Rails.error.handle(ForestAdminDatasourceToolkit::Exceptions::ForestException) do
3
- ForestAdminAgent::Http::Router.routes.each do |name, agent_route|
4
- match agent_route[:uri], to: 'forest#index', via: agent_route[:method], as: name, route_alias: name
3
+ scope '/forest' do
4
+ ForestAdminAgent::Http::Router.routes.each do |name, agent_route|
5
+ match agent_route[:uri],
6
+ defaults: { format: agent_route[:format] },
7
+ to: 'forest#index',
8
+ via: agent_route[:method],
9
+ as: name,
10
+ route_alias: name
11
+ end
5
12
  end
6
13
  end
7
14
  end
@@ -38,14 +38,11 @@ module ForestAdminRails
38
38
  end
39
39
 
40
40
  def load_configuration
41
- return unless File.exist?(Rails.root.join('lib', 'forest_admin_rails', 'create_agent.rb'))
41
+ return unless File.exist?(Rails.root.join('app', 'lib', 'forest_admin_rails', 'create_agent.rb'))
42
42
 
43
43
  # force eager loading models
44
44
  Rails.application.eager_load!
45
45
 
46
- # setup agent
47
- Dir[Rails.root.join('lib', 'forest_admin_rails', '**', '*.rb')].each { |file| require file }
48
-
49
46
  ForestAdminRails::CreateAgent.setup!
50
47
 
51
48
  sse = ForestAdminAgent::Services::SSECacheInvalidation
@@ -1,3 +1,3 @@
1
1
  module ForestAdminRails
2
- VERSION = "1.0.0-beta.47"
2
+ VERSION = "1.0.0-beta.49"
3
3
  end
@@ -17,13 +17,14 @@ module ForestAdminRails
17
17
  setting :env_secret
18
18
  setting :forest_server_url, default: 'https://api.forestadmin.com'
19
19
  setting :is_production, default: Rails.env.production?
20
- setting :prefix, default: 'forest'
20
+ setting :prefix, default: nil
21
21
  setting :permission_expiration, default: 900
22
22
  setting :cache_dir, default: :'tmp/cache/forest_admin'
23
23
  setting :schema_path, default: File.join(Dir.pwd, '.forestadmin-schema.json')
24
24
  setting :project_dir, default: Dir.pwd
25
25
  setting :loggerLevel, default: 'info'
26
26
  setting :logger, default: nil
27
+ setting :customize_error_message, default: nil
27
28
  setting :instant_cache_refresh, default: Rails.env.production?
28
29
 
29
30
  if defined?(Rails::Railtie)
@@ -8,8 +8,8 @@ module ForestAdminRails
8
8
  @auth_secret = SecureRandom.hex(20)
9
9
  @env_secret = env_secret
10
10
  template 'initializers/config.rb', 'config/initializers/forest_admin_rails.rb'
11
- template 'create_agent.rb', 'lib/forest_admin_rails/create_agent.rb'
12
- route "mount ForestAdminRails::Engine => '/#{ForestAdminRails.config[:prefix]}'"
11
+ template 'create_agent.rb', 'app/lib/forest_admin_rails/create_agent.rb'
12
+ route 'mount ForestAdminRails::Engine => "#{ForestAdminRails.config[:prefix]}"'
13
13
  end
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.47
4
+ version: 1.0.0.pre.beta.49
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: 2024-05-22 00:00:00.000000000 Z
12
+ date: 2024-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable
@@ -64,7 +64,6 @@ extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
66
  - LICENSE
67
- - README.md
68
67
  - Rakefile
69
68
  - app/controllers/forest_admin_rails/forest_controller.rb
70
69
  - app/helpers/forest_admin_rails/application_helper.rb
@@ -82,8 +81,8 @@ licenses:
82
81
  - GPL-3.0
83
82
  metadata:
84
83
  homepage_uri: https://www.forestadmin.com
85
- source_code_uri: https://github.com/ForestAdmin/rails-forest_admin
86
- changelog_uri: https://github.com/ForestAdmin/rails-forest_admin/CHANGELOG.md
84
+ source_code_uri: https://github.com/ForestAdmin/agent-ruby
85
+ changelog_uri: https://github.com/ForestAdmin/agent-ruby/blob/main/CHANGELOG.md
87
86
  rubygems_mfa_required: 'false'
88
87
  post_install_message:
89
88
  rdoc_options: []
data/README.md DELETED
@@ -1,28 +0,0 @@
1
- # ForestAdmin
2
- Short description and motivation.
3
-
4
- ## Usage
5
- How to use my plugin.
6
-
7
- ## Installation
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem "forest_admin"
12
- ```
13
-
14
- And then execute:
15
- ```bash
16
- $ bundle
17
- ```
18
-
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install forest_admin
22
- ```
23
-
24
- ## Contributing
25
- Contribution directions go here.
26
-
27
- ## License
28
- The gem is available as open source under the terms of the [GPL-3.0 License](https://www.gnu.org/licenses/gpl-3.0.en.html).