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 +4 -4
- data/lib/forest_admin_agent/builder/agent_factory.rb +11 -6
- data/lib/forest_admin_agent/routes/resources/list.rb +0 -3
- data/lib/forest_admin_agent/services/smart_action_checker.rb +12 -6
- data/lib/forest_admin_agent/utils/query_string_parser.rb +1 -0
- data/lib/forest_admin_agent/utils/schema/schema_emitter.rb +1 -1
- data/lib/forest_admin_agent/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c6837279d632500c6245b172c625bae5ae5e4e459a396e90ed10cd7ac1f5591
|
4
|
+
data.tar.gz: 61dedb7cf077dd3ed87b178d59d78b557538fb83032cd3530cd791ff3442030f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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[:
|
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].
|
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
|
-
|
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].
|
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].
|
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]
|
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
|
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.
|
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-
|
12
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|