forest_admin_agent 1.0.0.pre.beta.78 → 1.0.0.pre.beta.80

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: 27acf5eecdcc0214bb2f2c88c761a165e4c769e8790d10be2ed999e4e2b99c6f
4
- data.tar.gz: 6fc3368da9efe7a50120dfcf27fb731100be817075343f4d489efdbd6a225a26
3
+ metadata.gz: a01610bd932ab1fbf77523d7643b5d88e2cb6570bbe35ed0cef4a64d15be43a3
4
+ data.tar.gz: 29ecd9585091340a2f3c34347afcaf31c3b973baf765ac82451e356eede1bbb9
5
5
  SHA512:
6
- metadata.gz: f6325a6a4130edf6c3589bcdcf1c0247693fa17a95dd6dea045058b48e4289e85b13d0a4c9f9d67414aa1d91c6b795e254b20f966611ceff8448c27ea24f85a6
7
- data.tar.gz: c68b8311af7cd615eaa1ef6b84dc9126098988d725885e6499acd9acb743d4023474fda0ec10176c7d3a6eb2b7ab405936db8335a11290b60290b6ca80fa76ef
6
+ metadata.gz: 766c95a6b69884075911e6aa7da8cf0b247007a0c4eb0fe26c4f6ca71d33de23cdc7008e1702ca88c2ae815521b11f7845363dfce7a95d8fbdf3f4c4f3ff842a
7
+ data.tar.gz: 18ef288c93d62c83f0900e9df9715ee6d14e6d52340e47e1283139e79fc07e440f19b84bdf0f5861b9ddb80d8421cf1e139039bed303f6220b853e04c2bc6ccb
@@ -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
@@ -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
@@ -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.78"
10
+ LIANA_VERSION = "1.0.0-beta.80"
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.78"
2
+ VERSION = "1.0.0-beta.80"
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.78
4
+ version: 1.0.0.pre.beta.80
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-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport