foobara 0.0.118 → 0.0.119
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/CHANGELOG.md +12 -0
- data/projects/command_connectors/src/serializers/aggregate_serializer.rb +2 -2
- data/projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb +2 -2
- data/projects/command_connectors/src/transformed_command.rb +8 -1
- data/projects/detached_entity/src/concerns/equality.rb +2 -0
- data/projects/model/src/sensitive_type_removers/model.rb +22 -5
- data/projects/model/src/sensitive_value_removers/model.rb +5 -1
- data/projects/namespace/src/is_namespace.rb +6 -0
- data/projects/namespace/src/namespace_helpers.rb +30 -3
- data/projects/type_declarations/lib/foobara/type_declarations.rb +3 -0
- data/projects/type_declarations/src/attributes_transformers/only.rb +12 -0
- data/projects/type_declarations/src/attributes_transformers/reject.rb +12 -0
- 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: 5bcf730a4685cf72bb0af0b04cbf7cd7929faa672d64300444bc24f441e2f1d4
|
4
|
+
data.tar.gz: edfb3e4998d9adf25271075017167ed1b750ae4bccbdec17eb2196f5c9c9ab93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6484e4c0fe4d50946922b0dedf3cd0a443c89c21294d2b8c32f9eb1433a7ddaab6cbf68715a7ad926ab256822d2c6ef0a317036bab3d5a8879ec861ef7cdddc5
|
7
|
+
data.tar.gz: 9d17dfacde7d8ad2ac42635ccc11d4c2d2aed619c47ffe6d6ee5e4dfa40ba6eeb7820238fc642fa5324aa113985782e260f6d342289c760065759ddc8e7a04be
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [0.0.119] - 2025-05-08
|
2
|
+
|
3
|
+
- Make anonymous transformers more deterministic in manifests
|
4
|
+
- Remove delegates and private attributes from exposed models
|
5
|
+
- Make sure delegated attributes make it out through aggregate serializers
|
6
|
+
|
7
|
+
# [0.0.118] - 2025-05-07
|
8
|
+
|
9
|
+
- Fix bug preventing allow_nil from being used with entities
|
10
|
+
- Fix bugs with .all and .load
|
11
|
+
- Fix bug with possible error class lookups for tuple types
|
12
|
+
|
1
13
|
# [0.0.117] - 2025-05-05
|
2
14
|
|
3
15
|
- Make sure we do not apply an authenticator unless it is applicable
|
@@ -11,9 +11,9 @@ module Foobara
|
|
11
11
|
object.class.load(object)
|
12
12
|
end
|
13
13
|
|
14
|
-
transform(object.
|
14
|
+
transform(object.attributes_with_delegates)
|
15
15
|
when Model
|
16
|
-
transform(object.
|
16
|
+
transform(object.attributes_with_delegates)
|
17
17
|
when Array
|
18
18
|
object.map { |element| transform(element) }
|
19
19
|
when Hash
|
@@ -14,10 +14,10 @@ module Foobara
|
|
14
14
|
if detached_to_primary_key?
|
15
15
|
object.primary_key
|
16
16
|
else
|
17
|
-
object.
|
17
|
+
object.attributes_with_delegates
|
18
18
|
end
|
19
19
|
when Model
|
20
|
-
object.
|
20
|
+
object.attributes_with_delegates
|
21
21
|
when ::Array
|
22
22
|
object.map { |element| serialize(element) }
|
23
23
|
when ::Hash
|
@@ -47,8 +47,15 @@ module Foobara
|
|
47
47
|
|
48
48
|
remover = Namespace.use scoped_namespace do
|
49
49
|
transformed_result_type = result_type_from_transformers(result_type, result_transformers)
|
50
|
+
|
51
|
+
path = if transformed_result_type.scoped_path_set?
|
52
|
+
transformed_result_type.scoped_full_path
|
53
|
+
else
|
54
|
+
[*command_class.scoped_path, *suffix, "Result"]
|
55
|
+
end
|
56
|
+
|
50
57
|
remover_class.new(from: transformed_result_type).tap do |r|
|
51
|
-
r.scoped_path = ["SensitiveValueRemover", *
|
58
|
+
r.scoped_path = ["SensitiveValueRemover", *path]
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
@@ -9,13 +9,30 @@ module Foobara
|
|
9
9
|
def transform(strict_type_declaration)
|
10
10
|
old_attributes_declaration = strict_type_declaration[:attributes_declaration]
|
11
11
|
|
12
|
-
new_attributes_declaration =
|
12
|
+
new_attributes_declaration = old_attributes_declaration
|
13
13
|
|
14
|
-
if
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
if strict_type_declaration.key?(:private)
|
15
|
+
new_attributes_declaration = TypeDeclarations::Attributes.reject(
|
16
|
+
old_attributes_declaration,
|
17
|
+
strict_type_declaration[:private]
|
18
|
+
)
|
18
19
|
end
|
20
|
+
|
21
|
+
new_attributes_declaration = remove_sensitive_types(new_attributes_declaration)
|
22
|
+
|
23
|
+
if new_attributes_declaration != old_attributes_declaration
|
24
|
+
strict_type_declaration = strict_type_declaration.merge(attributes_declaration: new_attributes_declaration)
|
25
|
+
end
|
26
|
+
|
27
|
+
if strict_type_declaration.key?(:delegates)
|
28
|
+
strict_type_declaration = strict_type_declaration.except(:delegates)
|
29
|
+
end
|
30
|
+
|
31
|
+
if strict_type_declaration.key?(:private)
|
32
|
+
strict_type_declaration = strict_type_declaration.except(:private)
|
33
|
+
end
|
34
|
+
|
35
|
+
strict_type_declaration
|
19
36
|
end
|
20
37
|
end
|
21
38
|
end
|
@@ -5,7 +5,11 @@ module Foobara
|
|
5
5
|
def transform(record)
|
6
6
|
attributes_type = from_type.element_types
|
7
7
|
|
8
|
-
sanitized_attributes, _changed = sanitize_value(attributes_type, record.
|
8
|
+
sanitized_attributes, _changed = sanitize_value(attributes_type, record.attributes_with_delegates)
|
9
|
+
|
10
|
+
if from_type.declaration_data.key?(:private)
|
11
|
+
sanitized_attributes = sanitized_attributes.except(*from_type.declaration_data[:private])
|
12
|
+
end
|
9
13
|
|
10
14
|
Namespace.use(to_type.created_in_namespace) do
|
11
15
|
to_type.target_class.send(build_method, sanitized_attributes)
|
@@ -19,7 +19,14 @@ module Foobara
|
|
19
19
|
subclass.extend ::Foobara::Scoped
|
20
20
|
|
21
21
|
NamespaceHelpers.foobara_autoset_namespace(subclass, default_namespace: scoped_default_namespace)
|
22
|
-
|
22
|
+
|
23
|
+
if !subclass.respond_to?(:will_set_scoped_path?) || !subclass.will_set_scoped_path?
|
24
|
+
NamespaceHelpers.foobara_autoset_scoped_path(
|
25
|
+
subclass,
|
26
|
+
set_namespace: true,
|
27
|
+
namespace_default: scoped_default_namespace
|
28
|
+
)
|
29
|
+
end
|
23
30
|
|
24
31
|
subclass.extend ::Foobara::Namespace::IsNamespace
|
25
32
|
end
|
@@ -35,6 +42,8 @@ module Foobara
|
|
35
42
|
|
36
43
|
subclass.extend ::Foobara::Scoped
|
37
44
|
|
45
|
+
return if subclass.respond_to?(:will_set_scoped_path?) && subclass.will_set_scoped_path?
|
46
|
+
|
38
47
|
NamespaceHelpers.foobara_autoset_namespace(subclass, default_namespace: scoped_default_namespace)
|
39
48
|
NamespaceHelpers.foobara_autoset_scoped_path(subclass)
|
40
49
|
|
@@ -161,7 +170,12 @@ module Foobara
|
|
161
170
|
mod.scoped_namespace = default_namespace if default_namespace
|
162
171
|
end
|
163
172
|
|
164
|
-
def
|
173
|
+
def anon_sequence(class_name)
|
174
|
+
@anon_sequences ||= {}
|
175
|
+
@anon_sequences.key?(class_name) ? @anon_sequences[class_name] += 1 : @anon_sequences[class_name] = 1
|
176
|
+
end
|
177
|
+
|
178
|
+
def foobara_autoset_scoped_path(mod, make_top_level: false, set_namespace: false, namespace_default: nil)
|
165
179
|
return if mod.scoped_path_set?
|
166
180
|
|
167
181
|
mod_name = mod.name
|
@@ -174,7 +188,13 @@ module Foobara
|
|
174
188
|
super_name = parent.scoped_path_set? ? parent.scoped_full_name : parent.name
|
175
189
|
end until super_name
|
176
190
|
|
177
|
-
|
191
|
+
short_name = if mod.respond_to?(:symbol) && mod.symbol
|
192
|
+
mod.symbol.to_s
|
193
|
+
else
|
194
|
+
"Anon#{NamespaceHelpers.anon_sequence(super_name)}"
|
195
|
+
end
|
196
|
+
|
197
|
+
mod_name = [super_name, short_name].join("::")
|
178
198
|
end
|
179
199
|
|
180
200
|
scoped_path = mod_name.split("::")
|
@@ -183,6 +203,8 @@ module Foobara
|
|
183
203
|
|
184
204
|
next_mod = Object
|
185
205
|
|
206
|
+
parent = namespace_default
|
207
|
+
|
186
208
|
while next_mod
|
187
209
|
path_part = scoped_path.shift
|
188
210
|
|
@@ -192,6 +214,7 @@ module Foobara
|
|
192
214
|
|
193
215
|
if next_mod.is_a?(IsNamespace) && next_mod != mod && !make_top_level
|
194
216
|
adjusted_scoped_path = []
|
217
|
+
parent = next_mod
|
195
218
|
next
|
196
219
|
end
|
197
220
|
|
@@ -201,6 +224,10 @@ module Foobara
|
|
201
224
|
mod.scoped_path_autoset = true
|
202
225
|
mod.scoped_path = adjusted_scoped_path
|
203
226
|
|
227
|
+
if set_namespace
|
228
|
+
mod.scoped_namespace = parent
|
229
|
+
end
|
230
|
+
|
204
231
|
if mod.is_a?(IsNamespace)
|
205
232
|
update_children_with_new_parent(mod)
|
206
233
|
end
|
@@ -73,6 +73,9 @@ module Foobara
|
|
73
73
|
register_sensitive_value_remover(attributes_handler, SensitiveValueRemovers::Attributes)
|
74
74
|
register_sensitive_type_remover(SensitiveTypeRemovers::Array.new(array_handler))
|
75
75
|
register_sensitive_value_remover(array_handler, SensitiveValueRemovers::Array)
|
76
|
+
|
77
|
+
Foobara::AttributesTransformers::Reject.foobara_unregister_all
|
78
|
+
Foobara::AttributesTransformers::Only.foobara_unregister_all
|
76
79
|
end
|
77
80
|
|
78
81
|
def install!
|
@@ -5,6 +5,10 @@ module Foobara
|
|
5
5
|
transformer_class = Class.new(Only)
|
6
6
|
transformer_class.only_attributes = attribute_names
|
7
7
|
|
8
|
+
Namespace::NamespaceHelpers.foobara_autoset_scoped_path(transformer_class, set_namespace: true)
|
9
|
+
transformer_class.foobara_parent_namespace = transformer_class.scoped_namespace
|
10
|
+
transformer_class.scoped_namespace.foobara_register(transformer_class)
|
11
|
+
|
8
12
|
transformer_class
|
9
13
|
end
|
10
14
|
end
|
@@ -12,6 +16,14 @@ module Foobara
|
|
12
16
|
class Only < AttributesTransformers
|
13
17
|
class << self
|
14
18
|
attr_accessor :only_attributes
|
19
|
+
|
20
|
+
def symbol
|
21
|
+
only_attributes&.sort&.join("_")&.to_sym
|
22
|
+
end
|
23
|
+
|
24
|
+
def will_set_scoped_path?
|
25
|
+
true
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
29
|
def to_type_declaration
|
@@ -5,6 +5,10 @@ module Foobara
|
|
5
5
|
transformer_class = Class.new(Reject)
|
6
6
|
transformer_class.reject_attributes = attribute_names
|
7
7
|
|
8
|
+
Namespace::NamespaceHelpers.foobara_autoset_scoped_path(transformer_class, set_namespace: true)
|
9
|
+
transformer_class.foobara_parent_namespace = transformer_class.scoped_namespace
|
10
|
+
transformer_class.scoped_namespace.foobara_register(transformer_class)
|
11
|
+
|
8
12
|
transformer_class
|
9
13
|
end
|
10
14
|
end
|
@@ -12,6 +16,14 @@ module Foobara
|
|
12
16
|
class Reject < AttributesTransformers
|
13
17
|
class << self
|
14
18
|
attr_accessor :reject_attributes
|
19
|
+
|
20
|
+
def symbol
|
21
|
+
reject_attributes&.sort&.join("_")&.to_sym
|
22
|
+
end
|
23
|
+
|
24
|
+
def will_set_scoped_path?
|
25
|
+
true
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
29
|
def to_type_declaration
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.119
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|