forest_admin_agent 1.0.0.pre.beta.78 → 1.0.0.pre.beta.79

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: 27acf5eecdcc0214bb2f2c88c761a165e4c769e8790d10be2ed999e4e2b99c6f
4
- data.tar.gz: 6fc3368da9efe7a50120dfcf27fb731100be817075343f4d489efdbd6a225a26
3
+ metadata.gz: 0c6837279d632500c6245b172c625bae5ae5e4e459a396e90ed10cd7ac1f5591
4
+ data.tar.gz: 61dedb7cf077dd3ed87b178d59d78b557538fb83032cd3530cd791ff3442030f
5
5
  SHA512:
6
- metadata.gz: f6325a6a4130edf6c3589bcdcf1c0247693fa17a95dd6dea045058b48e4289e85b13d0a4c9f9d67414aa1d91c6b795e254b20f966611ceff8448c27ea24f85a6
7
- data.tar.gz: c68b8311af7cd615eaa1ef6b84dc9126098988d725885e6499acd9acb743d4023474fda0ec10176c7d3a6eb2b7ab405936db8335a11290b60290b6ca80fa76ef
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
@@ -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.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.78"
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.78
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