forest_admin_rails 1.0.0.pre.beta.48 → 1.0.0.pre.beta.50

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: 7cd8ef4c3bf64c07d76874bd52c19b12ac52532a16e67978b6fc0053bb746cf2
4
- data.tar.gz: bdd776d4677a04f1d634fc51d787c180c34ef5e568b0bacb8ff9b0f2ee05fff4
3
+ metadata.gz: 6c56097711b2bf1f332d3d0838e1f7e1d9f36061defc5d9a761059a5779d194e
4
+ data.tar.gz: 8075de2350fdb37cf65a3c9c82d491a63f5cca7997dd43a7881bf75258b89f0f
5
5
  SHA512:
6
- metadata.gz: 8e438d102cea49a4df22eb7906f201ad784ec67cf34351ca4ee99428ef1a399974462c5a92f61a11d300c1960333d8be0771a73cca7e8438bb28543084f90b06
7
- data.tar.gz: f181f852157cb356981809319bd97aeaa6604cb8952a15800606782ef5a08183936a5b8da19ec96068232857cc25208bcac0976386a91c871aae08d59325ae07
6
+ metadata.gz: 6004b2e18b0a152f1b342bdfd3ca6ed8785ba64fa3ab696636b9cce49428c686d0515ca6cf473faeb8d6e8614dd55022b54d83834786360244b05ca457ae8407
7
+ data.tar.gz: 3fc132da4569d6fdbb133d2c4353c35ad77b7f869c6fc80bd8e2a84a322d31ca73d9aabe0e38ab03c60b5607f0432d7230edffdafe5ace35c72e4c3b1b963ce7
@@ -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,8 +24,10 @@ 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
32
  respond_to do |format|
29
33
  format.json { render json: data[:content], status: data[:status] || data[:content][:status] || 200 }
@@ -43,7 +47,7 @@ module ForestAdminRails
43
47
  errors: [
44
48
  {
45
49
  name: exception.name,
46
- detail: exception.message,
50
+ detail: get_error_message(exception),
47
51
  status: exception.try(:status)
48
52
  }
49
53
  ]
@@ -52,7 +56,7 @@ module ForestAdminRails
52
56
  data[:errors][0][:data] = exception.try(:data)
53
57
  end
54
58
 
55
- unless Facades::Container.cache(:is_production)
59
+ unless ForestAdminAgent::Facades::Container.cache(:is_production)
56
60
  ForestAdminAgent::Facades::Container.logger.log('Debug', exception.full_message)
57
61
  end
58
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,8 +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], defaults: { format: agent_route[:format] }, to: 'forest#index',
5
- 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
6
12
  end
7
13
  end
8
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.48"
2
+ VERSION = "1.0.0-beta.50"
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.48
4
+ version: 1.0.0.pre.beta.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu