forest_admin_datasource_toolkit 1.44.5 → 1.45.0
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_datasource_toolkit/schema/relations/many_to_one_schema.rb +3 -2
- data/lib/forest_admin_datasource_toolkit/schema/relations/one_to_one_schema.rb +3 -2
- data/lib/forest_admin_datasource_toolkit/validations/condition_tree_validator.rb +16 -1
- data/lib/forest_admin_datasource_toolkit/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: 10f5f2fa8864db325ce151f569c2e438775ae5c18738fa2bc3de7f54119f1b1a
|
|
4
|
+
data.tar.gz: 72c8a79a285a7457c3d8757d6ba4f99079076f8002c59ec64d0f41ac0411269c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75acf62baf319e7cc728897a42fc4d1edbece85d5a64bedb6a4720a6387c7b78ae5c84ac3b4c93027d0410215f7cf45de3b4b28766e7ff28d1d41def788ea2ec
|
|
7
|
+
data.tar.gz: 81af933d91fbdc333e2f2c9249d79bee037e436becfd8fd1046b4d6b3afbfd65ceb701e860769b50b2598c047193d130f798d161fe30373841ed88885fc0d2a5
|
|
@@ -2,10 +2,11 @@ module ForestAdminDatasourceToolkit
|
|
|
2
2
|
module Schema
|
|
3
3
|
module Relations
|
|
4
4
|
class ManyToOneSchema < RelationSchema
|
|
5
|
-
attr_accessor :foreign_key, :foreign_key_target
|
|
5
|
+
attr_accessor :foreign_key, :foreign_key_target, :is_filterable
|
|
6
6
|
|
|
7
|
-
def initialize(foreign_key:, foreign_key_target:, foreign_collection:, is_read_only: false)
|
|
7
|
+
def initialize(foreign_key:, foreign_key_target:, foreign_collection:, is_read_only: false, is_filterable: true)
|
|
8
8
|
super(foreign_collection, 'ManyToOne', is_read_only: is_read_only)
|
|
9
|
+
@is_filterable = is_filterable
|
|
9
10
|
@foreign_key = foreign_key
|
|
10
11
|
@foreign_key_target = foreign_key_target
|
|
11
12
|
end
|
|
@@ -2,10 +2,11 @@ module ForestAdminDatasourceToolkit
|
|
|
2
2
|
module Schema
|
|
3
3
|
module Relations
|
|
4
4
|
class OneToOneSchema < RelationSchema
|
|
5
|
-
attr_accessor :origin_key, :origin_key_target
|
|
5
|
+
attr_accessor :origin_key, :origin_key_target, :is_filterable
|
|
6
6
|
|
|
7
|
-
def initialize(origin_key:, origin_key_target:, foreign_collection:, is_read_only: false)
|
|
7
|
+
def initialize(origin_key:, origin_key_target:, foreign_collection:, is_read_only: false, is_filterable: true)
|
|
8
8
|
super(foreign_collection, 'OneToOne', is_read_only: is_read_only)
|
|
9
|
+
@is_filterable = is_filterable
|
|
9
10
|
@origin_key = origin_key
|
|
10
11
|
@origin_key_target = origin_key_target
|
|
11
12
|
end
|
|
@@ -32,6 +32,7 @@ module ForestAdminDatasourceToolkit
|
|
|
32
32
|
def self.validate_leaf(leaf, collection)
|
|
33
33
|
field_schema = Utils::Collection.get_field_schema(collection, leaf.field)
|
|
34
34
|
|
|
35
|
+
throw_if_relation_not_filterable(leaf, collection)
|
|
35
36
|
throw_if_operator_not_allowed_with_column(leaf, field_schema)
|
|
36
37
|
throw_if_value_not_allowed_with_operator(leaf, field_schema)
|
|
37
38
|
throw_if_operator_not_allowed_with_column_type(leaf, field_schema)
|
|
@@ -40,13 +41,27 @@ module ForestAdminDatasourceToolkit
|
|
|
40
41
|
nil
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
def self.throw_if_relation_not_filterable(leaf, collection)
|
|
45
|
+
current = collection
|
|
46
|
+
|
|
47
|
+
leaf.field.split(':')[0...-1].each do |relation_name|
|
|
48
|
+
relation = current.schema[:fields][relation_name]
|
|
49
|
+
|
|
50
|
+
if relation.respond_to?(:is_filterable) && relation.is_filterable == false
|
|
51
|
+
raise Exceptions::ValidationError, "The relation '#{current.name}.#{relation_name}' is not filterable"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
current = current.datasource.get_collection(relation.foreign_collection)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
43
58
|
def self.throw_if_operator_not_allowed_with_column(leaf, column_schema)
|
|
44
59
|
operators = column_schema.filter_operators
|
|
45
60
|
return if operators.include?(leaf.operator)
|
|
46
61
|
|
|
47
62
|
raise Exceptions::ValidationError,
|
|
48
63
|
"The given operator '#{leaf.operator}' is not supported by the column: '#{leaf.field}'." \
|
|
49
|
-
"#{operators.empty? ? " The allowed types are: #{operators.join(",")}"
|
|
64
|
+
"#{operators.empty? ? " The column is not filterable" : " The allowed types are: #{operators.join(",")}"}"
|
|
50
65
|
end
|
|
51
66
|
|
|
52
67
|
def self.throw_if_value_not_allowed_with_operator(leaf, column_schema)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_datasource_toolkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.45.0
|
|
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: 2026-10-
|
|
12
|
+
date: 2026-10-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|