forest_admin_agent 1.0.0.pre.beta.77 → 1.0.0.pre.beta.79

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acb44dc3e46d11e1cf6ff2cc910f8c337bf499df84a12e508f641af9b6a07188
4
- data.tar.gz: 65f2a20cebb62e62b9ed67de3ef692b71765eaf61b46eb0ff603606577efde9f
3
+ metadata.gz: 0c6837279d632500c6245b172c625bae5ae5e4e459a396e90ed10cd7ac1f5591
4
+ data.tar.gz: 61dedb7cf077dd3ed87b178d59d78b557538fb83032cd3530cd791ff3442030f
5
5
  SHA512:
6
- metadata.gz: 5086df998e3f22f9d04772f29375c33f13469aa98849045a6db9c96d1569286258f7c97fb75bb24a0d4a3dfbe61c7193d17932c625e66ee323541a37d9f676db
7
- data.tar.gz: 957247e377111b6b48c5e69fdf375bbf7c3890043a254a16af7cfe2a5ce366d7011222dffd60438413cd3c59444399a5d8eec0371787112370773d4a0f5e94c9
6
+ metadata.gz: 5dada3205734f2ba783a141428937b26d176ccfbf82e012b59742417e61c10497f3d6aa25a1399b4f604fe765d21e66f1d07fc1dfd02340a36777b9b79746f9a
7
+ data.tar.gz: 38d2f8294e77b004df22d448f185a6153b85c08d1c0591a388bffa7252e794d72e8ceecf8d19d4ec75322db8fb506a2de0fa80704026e759557a59b555dc5792
@@ -80,13 +80,10 @@ module ForestAdminAgent
80
80
  return unless @has_env_secret
81
81
 
82
82
  cache = @container.resolve(:cache)
83
- @options[:customize_error_message] = @options[:customize_error_message]
84
- &.source
85
- &.strip
86
- &.delete_prefix('config.customize_error_message =')
87
- &.strip
88
83
 
89
- @options[:logger] = @options[:logger]&.source&.strip&.delete_prefix('config.logger =')&.strip
84
+ @options[:customize_error_message] =
85
+ clean_option_value(@options[:customize_error_message], 'config.customize_error_message =')
86
+ @options[:logger] = clean_option_value(@options[:logger], 'config.logger =')
90
87
 
91
88
  cache.set('config', @options.to_h)
92
89
  end
@@ -95,6 +92,14 @@ module ForestAdminAgent
95
92
  @logger = Services::LoggerService.new(@options[:loggerLevel], @options[:logger])
96
93
  @container.register(:logger, @logger)
97
94
  end
95
+
96
+ def clean_option_value(option, prefix)
97
+ return unless option
98
+
99
+ source = option.source
100
+ cleaned_option = source&.strip if source
101
+ cleaned_option&.delete_prefix(prefix)&.strip
102
+ end
98
103
  end
99
104
  end
100
105
  end
@@ -5,7 +5,6 @@ module ForestAdminAgent
5
5
  module Resources
6
6
  class List < AbstractAuthenticatedRoute
7
7
  include ForestAdminDatasourceToolkit::Components::Query::ConditionTree
8
- include ForestAdminDatasourceToolkit::Validations
9
8
 
10
9
  def setup_routes
11
10
  add_route('forest_list', 'get', '/:collection_name', ->(args) { handle_request(args) })
@@ -31,8 +30,6 @@ module ForestAdminAgent
31
30
  segment: ForestAdminAgent::Utils::QueryStringParser.parse_segment(@collection, args)
32
31
  )
33
32
 
34
- ConditionTreeValidator.validate(filter.condition_tree, @collection) if filter.condition_tree
35
-
36
33
  projection = ForestAdminAgent::Utils::QueryStringParser.parse_projection_with_pks(@collection, args)
37
34
  records = @collection.list(@caller, filter, projection)
38
35
 
@@ -37,7 +37,7 @@ module ForestAdminAgent
37
37
 
38
38
  def can_approve?
39
39
  if smart_action[:userApprovalEnabled].include?(role_id) &&
40
- (smart_action[:userApprovalConditions].empty? || match_conditions(:userApprovalConditions)) &&
40
+ (condition_by_role_id(smart_action[:userApprovalConditions]).blank? || match_conditions(:userApprovalConditions)) &&
41
41
  (attributes[:signed_approval_request][:data][:attributes][:requester_id] != caller.id ||
42
42
  smart_action[:selfApprovalEnabled].include?(role_id))
43
43
  return true
@@ -48,15 +48,17 @@ module ForestAdminAgent
48
48
 
49
49
  def can_trigger?
50
50
  if smart_action[:triggerEnabled].include?(role_id) && !smart_action[:approvalRequired].include?(role_id)
51
- return true if smart_action[:triggerConditions].empty? || match_conditions(:triggerConditions)
51
+ if condition_by_role_id(smart_action[:triggerConditions]).blank? || match_conditions(:triggerConditions)
52
+ return true
53
+ end
52
54
  elsif smart_action[:approvalRequired].include?(role_id) && smart_action[:triggerEnabled].include?(role_id)
53
- if smart_action[:approvalRequiredConditions].empty? || match_conditions(:approvalRequiredConditions)
55
+ if condition_by_role_id(smart_action[:approvalRequiredConditions]).blank? || match_conditions(:approvalRequiredConditions)
54
56
  raise RequireApproval.new(
55
57
  'This action requires to be approved.',
56
58
  REQUIRE_APPROVAL_ERROR,
57
59
  smart_action[:userApprovalEnabled]
58
60
  )
59
- elsif smart_action[:triggerConditions].empty? || match_conditions(:triggerConditions)
61
+ elsif condition_by_role_id(smart_action[:triggerConditions]).blank? || match_conditions(:triggerConditions)
60
62
  return true
61
63
  end
62
64
  end
@@ -71,11 +73,11 @@ module ForestAdminAgent
71
73
  else
72
74
  Nodes::ConditionTreeLeaf.new(pk, 'IN', attributes[:ids])
73
75
  end
74
- condition = smart_action[condition_name][0][:filter]
76
+ condition = condition_by_role_id(smart_action[condition_name])
75
77
  conditional_filter = filter.override(
76
78
  condition_tree: ConditionTreeFactory.intersect(
77
79
  [
78
- ConditionTreeParser.from_plain_object(collection, condition),
80
+ ConditionTreeParser.from_plain_object(collection, condition[:filter]),
79
81
  filter.condition_tree,
80
82
  condition_filter
81
83
  ]
@@ -90,6 +92,10 @@ module ForestAdminAgent
90
92
  INVALID_ACTION_CONDITION_ERROR
91
93
  )
92
94
  end
95
+
96
+ def condition_by_role_id(condition)
97
+ condition.find { |c| c['roleId'] == role_id }
98
+ end
93
99
  end
94
100
  end
95
101
  end
@@ -52,6 +52,7 @@ module ForestAdminAgent
52
52
  )[0]
53
53
  token_data.delete('exp')
54
54
  token_data[:timezone] = timezone
55
+ token_data[:request] = { ip: args[:headers]['action_dispatch.remote_ip'].to_s }
55
56
 
56
57
  Caller.new(**token_data.transform_keys(&:to_sym))
57
58
  end
@@ -7,7 +7,7 @@ module ForestAdminAgent
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
9
 
10
- LIANA_VERSION = "1.0.0-beta.77"
10
+ LIANA_VERSION = "1.0.0-beta.79"
11
11
 
12
12
  def self.get_serialized_schema(datasource)
13
13
  schema_path = Facades::Container.cache(:schema_path)
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.0.0-beta.77"
2
+ VERSION = "1.0.0-beta.79"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.77
4
+ version: 1.0.0.pre.beta.79
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: 2024-10-28 00:00:00.000000000 Z
12
+ date: 2024-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport