forest_admin_agent 1.13.1 → 1.13.2
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 +4 -4
- data/lib/forest_admin_agent/builder/agent_factory.rb +9 -2
- data/lib/forest_admin_agent/routes/action/actions.rb +3 -1
- data/lib/forest_admin_agent/utils/action_result.rb +43 -0
- data/lib/forest_admin_agent/utils/schema/frontend_validation_utils.rb +2 -2
- data/lib/forest_admin_agent/utils/schema/generator_field.rb +2 -2
- data/lib/forest_admin_agent/utils/schema/schema_emitter.rb +1 -1
- data/lib/forest_admin_agent/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34fac2392a88b543797ea3aa8ffe540416dd0971127a78715fd5d01a05088dac
|
|
4
|
+
data.tar.gz: 73685272543bdeee94fec2c1f40acc6c5e165bff74d36390e1da7ec7bd7a4ef3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e979b110602bfdc43d166cbf45bcea18b50654e104fbd9877159c78198715789f3144239d594d1c5df8a03e4c1480c72d47228beacb68bca8573c6c8a86a536
|
|
7
|
+
data.tar.gz: '08532940f8bb1fd1066d2cca71c76c6e8d8000edab0e45da00af11a32a15461c4b75ff91b5bf8558a83c082ca08468d3e3ec9f2161955e59bd9b235d6a139165'
|
|
@@ -149,9 +149,16 @@ module ForestAdminAgent
|
|
|
149
149
|
body = JSON.parse(response.body)
|
|
150
150
|
body['sendSchema']
|
|
151
151
|
rescue JSON::ParserError => e
|
|
152
|
+
http_status = begin
|
|
153
|
+
response.status
|
|
154
|
+
rescue StandardError
|
|
155
|
+
'unknown'
|
|
156
|
+
end
|
|
157
|
+
|
|
152
158
|
raise InternalServerError.new(
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
"Invalid JSON response from ForestAdmin server (HTTP #{http_status}). " \
|
|
160
|
+
"Expected JSON but received: #{response.body}",
|
|
161
|
+
details: { body: response.body, status: http_status },
|
|
155
162
|
cause: e
|
|
156
163
|
)
|
|
157
164
|
rescue Faraday::Error => e
|
|
@@ -75,7 +75,9 @@ module ForestAdminAgent
|
|
|
75
75
|
fields.reject { |field| field.type == 'Layout' }
|
|
76
76
|
)
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
result = context.collection.execute(context.caller, @action_name, data, filter_for_caller)
|
|
79
|
+
|
|
80
|
+
{ content: ForestAdminAgent::Utils::ActionResult.parse(result) }
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
def handle_hook_request(args = {})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module ForestAdminAgent
|
|
2
|
+
module Utils
|
|
3
|
+
module ActionResult
|
|
4
|
+
def self.parse(result)
|
|
5
|
+
keys = {}
|
|
6
|
+
case result[:type]
|
|
7
|
+
when 'Success'
|
|
8
|
+
keys = {
|
|
9
|
+
success: result[:message],
|
|
10
|
+
refresh: { relationships: result[:invalidated] },
|
|
11
|
+
html: result[:html]
|
|
12
|
+
}
|
|
13
|
+
when 'Error'
|
|
14
|
+
keys = {
|
|
15
|
+
status: 400,
|
|
16
|
+
error: result[:message],
|
|
17
|
+
html: result[:html]
|
|
18
|
+
}
|
|
19
|
+
when 'Webhook'
|
|
20
|
+
keys = {
|
|
21
|
+
webhook: {
|
|
22
|
+
body: result[:body],
|
|
23
|
+
headers: result[:headers],
|
|
24
|
+
method: result[:method],
|
|
25
|
+
url: result[:url]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
when 'File'
|
|
29
|
+
keys = {
|
|
30
|
+
name: result[:name],
|
|
31
|
+
mime_type: result[:mime_type],
|
|
32
|
+
stream: result[:content]
|
|
33
|
+
}
|
|
34
|
+
when 'Redirect'
|
|
35
|
+
keys = {
|
|
36
|
+
redirect_to: result[:path]
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
keys.merge({ headers: result[:response_headers] })
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -51,9 +51,9 @@ module ForestAdminAgent
|
|
|
51
51
|
}.freeze
|
|
52
52
|
|
|
53
53
|
def self.convert_validation_list(column)
|
|
54
|
-
return [] if column.
|
|
54
|
+
return [] if column.validation.empty?
|
|
55
55
|
|
|
56
|
-
rules = column.
|
|
56
|
+
rules = column.validation.map { |rule| simplify_rule(column.column_type, rule) }
|
|
57
57
|
remove_duplicates_in_place(rules)
|
|
58
58
|
|
|
59
59
|
rules.filter { |rule| rule.is_a?(Hash) && rule.key?(:operator) }
|
|
@@ -44,7 +44,7 @@ module ForestAdminAgent
|
|
|
44
44
|
# This may sound counter-intuitive: it is so that the user don't have two fields which
|
|
45
45
|
# allow updating the same foreign key in the detail-view form (fk + many to one)
|
|
46
46
|
isReadOnly: is_foreign_key || column.is_read_only,
|
|
47
|
-
isRequired: column.
|
|
47
|
+
isRequired: column.validation.any? { |v| v[:operator] == 'Present' },
|
|
48
48
|
isSortable: column.is_sortable,
|
|
49
49
|
isVirtual: false,
|
|
50
50
|
reference: nil,
|
|
@@ -144,7 +144,7 @@ module ForestAdminAgent
|
|
|
144
144
|
defaultValue: key_field.default_value,
|
|
145
145
|
isFilterable: foreign_collection_filterable?(foreign_collection),
|
|
146
146
|
isPrimaryKey: false,
|
|
147
|
-
isRequired: key_field.
|
|
147
|
+
isRequired: key_field.validation.any? { |v| v[:operator] == 'Present' },
|
|
148
148
|
isReadOnly: key_field.is_read_only,
|
|
149
149
|
isSortable: key_field.is_sortable,
|
|
150
150
|
validations: FrontendValidationUtils.convert_validation_list(key_field),
|
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.13.
|
|
4
|
+
version: 1.13.2
|
|
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: 2025-11-
|
|
12
|
+
date: 2025-11-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -341,6 +341,7 @@ files:
|
|
|
341
341
|
- lib/forest_admin_agent/services/permissions.rb
|
|
342
342
|
- lib/forest_admin_agent/services/smart_action_checker.rb
|
|
343
343
|
- lib/forest_admin_agent/services/sse_cache_invalidation.rb
|
|
344
|
+
- lib/forest_admin_agent/utils/action_result.rb
|
|
344
345
|
- lib/forest_admin_agent/utils/caller_parser.rb
|
|
345
346
|
- lib/forest_admin_agent/utils/condition_tree_parser.rb
|
|
346
347
|
- lib/forest_admin_agent/utils/context_variables.rb
|