foobara 0.1.10 → 0.1.11
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 +6 -0
- data/projects/domain/src/domain_module_extension.rb +0 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +1 -1
- data/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +6 -4
- data/projects/namespace/src/is_namespace.rb +5 -3
- data/projects/namespace/src/namespace/lookup_mode.rb +1 -0
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb +1 -1
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb +1 -1
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/to_type_transformer.rb +1 -1
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb +1 -1
- data/projects/type_declarations/src/lazy_element_types/array.rb +7 -5
- data/projects/type_declarations/src/lazy_element_types/attributes.rb +12 -10
- data/projects/type_declarations/src/lazy_element_types/hash.rb +18 -16
- data/projects/type_declarations/src/lazy_element_types/tuple.rb +9 -7
- data/projects/type_declarations/src/type_builder.rb +2 -8
- data/projects/types/src/type.rb +15 -18
- data/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d84d4d11b964a30291cd92382117fa45a7736e0ee0b6a247224427a33e6598
|
4
|
+
data.tar.gz: d1a2b86a1983b354412c1e83e2dbfc2ad259feddba8d09a01d3ef39038a27163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c8ed8a92fbc3c1e37172881f855aa0072ffb50cd5f3c652677ddaee2af021aa937a60c2aa35d5c61f110c5b2968474b3cfaf72c593d3f9c5a405f1a3ace968
|
7
|
+
data.tar.gz: e772dc00b34a3293111f49f958c7615507c206c47f10932c461852d0b4a1ada737a9c0c5f198da11bded280aa69d1f0f383e408b241977ec3521fa5e98e76796
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# [0.1.11] - 2025-09-24
|
2
|
+
|
3
|
+
- Make sure type builder caches are cleared when namespace caches are cleared
|
4
|
+
- Make sure element type resolution is performed in the right namespace
|
5
|
+
- Do not dual-purpose memoized @element_type(s) var, and memoize in IsNamespace.lru_cache instead
|
6
|
+
|
1
7
|
# [0.1.10] - 2025-09-11
|
2
8
|
|
3
9
|
- Add NotFoundError when an entity input doesn't exist
|
@@ -5,11 +5,13 @@ module Foobara
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
def resolve(type)
|
8
|
-
|
8
|
+
Namespace.use type.created_in_namespace do
|
9
|
+
attributes_type_declaration = type.declaration_data[:attributes_declaration]
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
type.element_types = TypeDeclarations.strict do
|
12
|
+
handler = Domain.current.foobara_type_builder.handler_for_class(Handlers::ExtendAttributesTypeDeclaration)
|
13
|
+
handler.process_value!(TypeDeclaration.new(attributes_type_declaration))
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -5,11 +5,13 @@ module Foobara
|
|
5
5
|
module IsNamespace
|
6
6
|
class << self
|
7
7
|
def lru_cache
|
8
|
-
@lru_cache ||= Foobara::LruCache.new(
|
8
|
+
@lru_cache ||= Foobara::LruCache.new(200)
|
9
9
|
end
|
10
10
|
|
11
11
|
def clear_lru_cache!
|
12
|
-
@lru_cache
|
12
|
+
if @lru_cache
|
13
|
+
lru_cache.reset!
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -141,7 +143,7 @@ module Foobara
|
|
141
143
|
LookupMode.validate!(mode)
|
142
144
|
path = Namespace.to_registry_path(path)
|
143
145
|
|
144
|
-
lru_cache.cached([path, mode,
|
146
|
+
lru_cache.cached([self, path, mode, *filter]) do
|
145
147
|
visited = Set.new
|
146
148
|
foobara_lookup_without_cache(path, filter:, mode:, visited:)
|
147
149
|
end
|
@@ -27,6 +27,7 @@ module Foobara
|
|
27
27
|
# parent: n
|
28
28
|
# dependent: n
|
29
29
|
# TODO: don't we have an enumerated class/project for this?
|
30
|
+
# Maybe use bitmasks for the above 3 places to look instead of a list of 7 lookup types? (There should be 8...)
|
30
31
|
module LookupMode
|
31
32
|
GENERAL = :general
|
32
33
|
RELAXED = :relaxed
|
@@ -8,7 +8,7 @@ module Foobara
|
|
8
8
|
class ToTypeTransformer < ExtendAssociativeArrayTypeDeclaration::ToTypeTransformer
|
9
9
|
def transform(strict_type_declaration)
|
10
10
|
type = super
|
11
|
-
type.
|
11
|
+
type.element_types_loader = LazyElementTypes::Attributes
|
12
12
|
type
|
13
13
|
end
|
14
14
|
end
|
data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb
CHANGED
@@ -8,7 +8,7 @@ module Foobara
|
|
8
8
|
class ToTypeTransformer < ExtendAssociativeArrayTypeDeclaration::ToTypeTransformer
|
9
9
|
def transform(strict_type_declaration)
|
10
10
|
type = super
|
11
|
-
type.
|
11
|
+
type.element_types_loader = LazyElementTypes::Tuple
|
12
12
|
type
|
13
13
|
end
|
14
14
|
end
|
@@ -5,13 +5,15 @@ module Foobara
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
def resolve(type)
|
8
|
-
|
8
|
+
Namespace.use type.created_in_namespace do
|
9
|
+
element_type_declaration = type.declaration_data[:element_type_declaration]
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
type.element_type = if element_type_declaration
|
12
|
+
TypeDeclarations.strict do
|
13
|
+
Domain.current.foobara_type_from_declaration(element_type_declaration)
|
14
|
+
end
|
13
15
|
end
|
14
|
-
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -5,21 +5,23 @@ module Foobara
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
def resolve(type)
|
8
|
-
|
8
|
+
Namespace.use type.created_in_namespace do
|
9
|
+
type_declarations = type.declaration_data[:element_type_declarations]
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
type.element_types = if type_declarations
|
12
|
+
if type_declarations.empty?
|
13
|
+
{}
|
14
|
+
else
|
15
|
+
TypeDeclarations.strict do
|
16
|
+
domain = Domain.current
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
type_declarations.transform_values do |attribute_declaration|
|
19
|
+
domain.foobara_type_from_declaration(attribute_declaration)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
|
-
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -7,30 +7,32 @@ module Foobara
|
|
7
7
|
module_function
|
8
8
|
|
9
9
|
def resolve(type)
|
10
|
-
|
10
|
+
Namespace.use type.created_in_namespace do
|
11
|
+
declaration_data = type.declaration_data
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
key_type_declaration = declaration_data[:key_type_declaration]
|
14
|
+
value_type_declaration = declaration_data[:value_type_declaration]
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
type.element_types = if key_type_declaration || value_type_declaration
|
17
|
+
TypeDeclarations.strict do
|
18
|
+
domain = Domain.current
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
else
|
22
|
-
BuiltinTypes[:duck]
|
23
|
-
end
|
24
|
-
|
25
|
-
value_declaration = if value_type_declaration
|
26
|
-
domain.foobara_type_from_declaration(value_type_declaration)
|
20
|
+
key_declaration = if key_type_declaration
|
21
|
+
domain.foobara_type_from_declaration(key_type_declaration)
|
27
22
|
else
|
28
23
|
BuiltinTypes[:duck]
|
29
24
|
end
|
30
25
|
|
31
|
-
|
26
|
+
value_declaration = if value_type_declaration
|
27
|
+
domain.foobara_type_from_declaration(value_type_declaration)
|
28
|
+
else
|
29
|
+
BuiltinTypes[:duck]
|
30
|
+
end
|
31
|
+
|
32
|
+
[key_declaration, value_declaration]
|
33
|
+
end
|
32
34
|
end
|
33
|
-
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -5,17 +5,19 @@ module Foobara
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
def resolve(type)
|
8
|
-
|
8
|
+
Namespace.use type.created_in_namespace do
|
9
|
+
element_type_declarations = type.declaration_data[:element_type_declarations]
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
type.element_types = if element_type_declarations
|
12
|
+
TypeDeclarations.strict do
|
13
|
+
domain = Domain.current
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
element_type_declarations.map do |element_type_declaration|
|
16
|
+
domain.foobara_type_from_declaration(element_type_declaration)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -129,7 +129,7 @@ module Foobara
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def type_for_declaration(*type_declaration_bits, &block)
|
132
|
-
lru_cache.cached([
|
132
|
+
lru_cache.cached([self, *block&.object_id, *type_declaration_bits]) do
|
133
133
|
type_for_declaration_without_cache(*type_declaration_bits, &block)
|
134
134
|
end
|
135
135
|
rescue NoTypeDeclarationHandlerFoundError
|
@@ -152,16 +152,10 @@ module Foobara
|
|
152
152
|
handler.process_value!(type_declaration)
|
153
153
|
end
|
154
154
|
|
155
|
-
def clear_cache
|
156
|
-
if @lru_cache
|
157
|
-
lru_cache.reset!
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
155
|
private
|
162
156
|
|
163
157
|
def lru_cache
|
164
|
-
|
158
|
+
Namespace::IsNamespace.lru_cache
|
165
159
|
end
|
166
160
|
end
|
167
161
|
end
|
data/projects/types/src/type.rb
CHANGED
@@ -20,7 +20,9 @@ module Foobara
|
|
20
20
|
:name,
|
21
21
|
:description,
|
22
22
|
:sensitive,
|
23
|
-
:sensitive_exposed
|
23
|
+
:sensitive_exposed,
|
24
|
+
:element_type_loader,
|
25
|
+
:element_types_loader
|
24
26
|
|
25
27
|
attr_reader :type_symbol,
|
26
28
|
:casters,
|
@@ -44,8 +46,6 @@ module Foobara
|
|
44
46
|
transformers: [],
|
45
47
|
validators: [],
|
46
48
|
element_processors: nil,
|
47
|
-
element_type: nil,
|
48
|
-
element_types: nil,
|
49
49
|
structure_count: nil,
|
50
50
|
processor_classes_requiring_type: nil,
|
51
51
|
sensitive: nil,
|
@@ -64,9 +64,6 @@ module Foobara
|
|
64
64
|
self.element_processors = [*element_processors, *base_type&.element_processors]
|
65
65
|
|
66
66
|
self.structure_count = structure_count
|
67
|
-
# TODO: combine these maybe with the term "children_types"?
|
68
|
-
self.element_types = element_types
|
69
|
-
self.element_type = element_type
|
70
67
|
self.target_classes = Util.array(target_classes)
|
71
68
|
self.processor_classes_requiring_type = processor_classes_requiring_type
|
72
69
|
|
@@ -95,23 +92,23 @@ module Foobara
|
|
95
92
|
end
|
96
93
|
|
97
94
|
def element_type
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
95
|
+
lru_cache.cached([self, :element_type]) do
|
96
|
+
if element_type_loader
|
97
|
+
element_type_loader.resolve(self)
|
98
|
+
else
|
99
|
+
base_type&.element_type
|
100
|
+
end
|
102
101
|
end
|
103
|
-
|
104
|
-
type
|
105
102
|
end
|
106
103
|
|
107
104
|
def element_types
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
105
|
+
lru_cache.cached([self, :element_types]) do
|
106
|
+
if element_types_loader
|
107
|
+
element_types_loader.resolve(self)
|
108
|
+
else
|
109
|
+
base_type&.element_types
|
110
|
+
end
|
112
111
|
end
|
113
|
-
|
114
|
-
types
|
115
112
|
end
|
116
113
|
|
117
114
|
def has_sensitive_types?
|
data/version.rb
CHANGED