foobara 0.6.5 → 0.7.1
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 +9 -0
- data/projects/command/src/command_pattern_implementation/concerns/namespace.rb +2 -0
- data/projects/command_connectors/src/command_registry/exposed_command.rb +2 -0
- data/projects/command_connectors/src/serializers/success_serializer.rb +1 -0
- data/projects/entities_plumbing/src/serializers/aggregate_serializer.rb +4 -0
- data/projects/typesystem/projects/builtin_types/lib/foobara/builtin_types.rb +5 -0
- data/projects/typesystem/projects/builtin_types/src/builtin_types.rb +13 -1
- data/projects/typesystem/projects/domain/src/domain_module_extension.rb +16 -5
- data/projects/typesystem/projects/domain/src/extensions/foobara.rb +1 -1
- data/projects/typesystem/projects/domain/src/module_extension.rb +2 -2
- data/projects/typesystem/projects/namespace/src/namespace_helpers.rb +15 -4
- data/projects/typesystem/projects/namespace/src/scoped.rb +0 -1
- data/projects/typesystem/projects/type_declarations/lib/foobara/type_declarations.rb +72 -25
- data/projects/typesystem/projects/type_declarations/src/error_extension.rb +6 -22
- data/projects/typesystem/projects/type_declarations/src/type_declarations.rb +11 -3
- data/projects/typesystem/projects/types/src/extensions/error.rb +4 -15
- 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: 64b471d0d0bf93acf6326e484b67d1be35f7c0c883bc315738f680e4c8119613
|
|
4
|
+
data.tar.gz: 9477f64763952ea8d819576545d6f9d06d7bb1ad562ea6dca83532297331859a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 941279f67447a52f9632f620637f011f21bae87766b4a8040846744751e17ba779a21db495cd0ef010152f908af015f8aad87246ab0215a9cd684673bb2c8793
|
|
7
|
+
data.tar.gz: de42b7abaff5512bdc00eba73d862778866034dd1a5d9b354649648a27b2ba2208062550e99ae4c91df8f51456f96bad4f7b4b89d2e263e13cc87c6d1daed231
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# [0.7.1] - 2026-10-09
|
|
2
|
+
|
|
3
|
+
- Fix bug that removes Foobara::RuntimeError from GlobalDomain during type declaration init
|
|
4
|
+
|
|
5
|
+
# [0.7.0] - 2026-10-09
|
|
6
|
+
|
|
7
|
+
- Do not allow anything but domains (and orgs as a hack) to be children of orgs
|
|
8
|
+
- Eliminate NoContextTypeSetError and add default context type of {}
|
|
9
|
+
|
|
1
10
|
# [0.6.5] - 2026-10-04
|
|
2
11
|
|
|
3
12
|
- Fix a problem where some nested sugary types don't expand correctly when using attributes dsl
|
|
@@ -11,6 +11,8 @@ module Foobara
|
|
|
11
11
|
:result_transformers,
|
|
12
12
|
:errors_transformers,
|
|
13
13
|
:pre_commit_transformers,
|
|
14
|
+
# Should we have separate success and error serializers so that serializers can be
|
|
15
|
+
# more reusable?
|
|
14
16
|
:serializers,
|
|
15
17
|
:request_mutators,
|
|
16
18
|
:response_mutators,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module Foobara
|
|
2
2
|
module CommandConnectors
|
|
3
3
|
module Serializers
|
|
4
|
+
# TODO: put an entity-free version of this in model_plumbing!
|
|
5
|
+
# TODO: can't this just inherit from Serializer??
|
|
6
|
+
# TODO: shouldn't this be a transformer? It's not really serializing anything
|
|
7
|
+
# just preparing the data for serialization.
|
|
4
8
|
class AggregateSerializer < SuccessSerializer
|
|
5
9
|
def serialize(object)
|
|
6
10
|
case object
|
|
@@ -62,6 +62,11 @@ module Foobara
|
|
|
62
62
|
associative_array = build_and_register!(:associative_array, duckture, ::Hash)
|
|
63
63
|
# TODO: uh oh... we do some translations in the casting here...
|
|
64
64
|
build_and_register!(:attributes, associative_array, nil)
|
|
65
|
+
|
|
66
|
+
if needs_to_handle_reregistered_types
|
|
67
|
+
GlobalDomain.foobara_each_command(&:handle_reregistered_types!)
|
|
68
|
+
self.needs_to_handle_reregistered_types = false
|
|
69
|
+
end
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
def reset_all
|
|
@@ -5,6 +5,8 @@ module Foobara
|
|
|
5
5
|
|
|
6
6
|
module BuiltinTypes
|
|
7
7
|
class << self
|
|
8
|
+
attr_accessor :needs_to_handle_reregistered_types
|
|
9
|
+
|
|
8
10
|
# TODO: break this up
|
|
9
11
|
# TODO: much of this behavior is helpful to non-builtin types as well.
|
|
10
12
|
def build_and_register!(
|
|
@@ -86,7 +88,17 @@ module Foobara
|
|
|
86
88
|
|
|
87
89
|
# TODO: really need to encapsulate this somehow...
|
|
88
90
|
type.type_symbol = type_symbol
|
|
89
|
-
|
|
91
|
+
|
|
92
|
+
domain = type.foobara_parent_namespace || GlobalDomain
|
|
93
|
+
mode = Namespace::LookupMode::DIRECT
|
|
94
|
+
|
|
95
|
+
exists = domain.foobara_registered?(type_symbol, mode:)
|
|
96
|
+
if exists
|
|
97
|
+
domain.foobara_unregister(domain.foobara_lookup_type(type_symbol, mode:))
|
|
98
|
+
self.needs_to_handle_reregistered_types = true
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
domain.foobara_register(type)
|
|
90
102
|
|
|
91
103
|
supported_casters_module = Util.constant_value(builtin_type_module, :SupportedCasters)
|
|
92
104
|
supported_caster_classes = if supported_casters_module
|
|
@@ -234,12 +234,23 @@ module Foobara
|
|
|
234
234
|
domain.foobara_manifest_reference
|
|
235
235
|
end.sort
|
|
236
236
|
|
|
237
|
-
types =
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
types = []
|
|
238
|
+
|
|
239
|
+
# Using this to support deprecated Foobara.manifest without risking
|
|
240
|
+
# breakage elsewhere
|
|
241
|
+
if TypeDeclarations.foobara_manifest_context_include_unreachable?
|
|
242
|
+
foobara_all(mode: Namespace::LookupMode::DIRECT).each do |scoped|
|
|
243
|
+
to_include << scoped if to_include
|
|
244
|
+
types << scoped.foobara_manifest_reference if scoped.scoped_category == :type
|
|
240
245
|
end
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
else
|
|
247
|
+
foobara_all_type(mode: Namespace::LookupMode::DIRECT).each do |scoped|
|
|
248
|
+
to_include << scoped if to_include
|
|
249
|
+
types << scoped.foobara_manifest_reference
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
types.sort!
|
|
243
254
|
|
|
244
255
|
manifest = super.merge(types:)
|
|
245
256
|
|
|
@@ -11,7 +11,7 @@ module Foobara
|
|
|
11
11
|
private def debug_manifest
|
|
12
12
|
to_include = Namespace.global.foobara_all_organization.to_set
|
|
13
13
|
|
|
14
|
-
TypeDeclarations.with_manifest_context(to_include:) do
|
|
14
|
+
TypeDeclarations.with_manifest_context(to_include:, include_unreachable: true) do
|
|
15
15
|
included = {}
|
|
16
16
|
|
|
17
17
|
h = {}
|
|
@@ -17,6 +17,8 @@ module Foobara
|
|
|
17
17
|
# simplecov:enable
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
include DomainModuleExtension
|
|
21
|
+
|
|
20
22
|
unless is_a?(Namespace::IsNamespace)
|
|
21
23
|
foobara_namespace!
|
|
22
24
|
foobara_autoset_namespace!(default_namespace: Foobara::GlobalOrganization)
|
|
@@ -24,8 +26,6 @@ module Foobara
|
|
|
24
26
|
|
|
25
27
|
foobara_parent_namespace.foobara_register(self)
|
|
26
28
|
end
|
|
27
|
-
|
|
28
|
-
include(DomainModuleExtension)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def foobara_organization!
|
|
@@ -155,11 +155,15 @@ module Foobara
|
|
|
155
155
|
|
|
156
156
|
while parent_mod
|
|
157
157
|
if parent_mod.is_a?(Foobara::Namespace::IsNamespace)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
# Only domains can have an org as its parent
|
|
159
|
+
# Important that Foobara::GlobalOrganization's parent is Foobara or it breaks categories
|
|
160
|
+
if mod.foobara_organization? || mod.foobara_domain? || !parent_mod.foobara_organization?
|
|
161
|
+
mod.scoped_namespace = parent_mod
|
|
162
|
+
return
|
|
163
|
+
end
|
|
162
164
|
end
|
|
165
|
+
|
|
166
|
+
parent_mod = Util.module_for(parent_mod)
|
|
163
167
|
end
|
|
164
168
|
|
|
165
169
|
mod.scoped_namespace = default_namespace if default_namespace
|
|
@@ -216,6 +220,13 @@ module Foobara
|
|
|
216
220
|
adjusted_scoped_path << path_part unless mod.scoped_namespace&.scoped_ignore_module?(next_mod)
|
|
217
221
|
end
|
|
218
222
|
|
|
223
|
+
if parent&.foobara_organization?
|
|
224
|
+
if !mod.foobara_domain? && !mod.foobara_organization?
|
|
225
|
+
parent = Foobara::GlobalDomain
|
|
226
|
+
adjusted_scoped_path = mod_name.split("::")
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
219
230
|
mod.scoped_path_autoset = true
|
|
220
231
|
mod.scoped_path = adjusted_scoped_path
|
|
221
232
|
|
|
@@ -17,35 +17,56 @@ module Foobara
|
|
|
17
17
|
[
|
|
18
18
|
:@foobara_children,
|
|
19
19
|
:@foobara_registry,
|
|
20
|
-
:@foobara_type_builder
|
|
20
|
+
:@foobara_type_builder,
|
|
21
|
+
:@lru_cache
|
|
21
22
|
].each do |var_name|
|
|
22
|
-
|
|
23
|
-
[
|
|
24
|
-
Namespace.global,
|
|
25
|
-
Foobara::GlobalOrganization,
|
|
26
|
-
Foobara::GlobalDomain,
|
|
27
|
-
Domain,
|
|
28
|
-
Types::Type,
|
|
29
|
-
Value::Processor,
|
|
30
|
-
Error
|
|
31
|
-
].each do |klass|
|
|
23
|
+
namespaces_to_reset.each do |klass|
|
|
32
24
|
if klass.instance_variable_defined?(var_name)
|
|
33
25
|
klass.remove_instance_variable(var_name)
|
|
34
26
|
end
|
|
35
27
|
end
|
|
36
28
|
end
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
Namespace.clear_lru_cache!
|
|
31
|
+
|
|
32
|
+
@original_scoped.each_key do |namespace|
|
|
33
|
+
scoped = @original_scoped[namespace]
|
|
34
|
+
to_remove = []
|
|
35
|
+
|
|
36
|
+
scoped.each do |child|
|
|
37
|
+
if child.scoped_unregistered?
|
|
38
|
+
to_remove << child
|
|
39
|
+
next
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
unless namespace.foobara_registered?(child, mode: Namespace::LookupMode::DIRECT)
|
|
43
|
+
namespace.foobara_register(child)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
children = namespace.foobara_children
|
|
48
|
+
|
|
49
|
+
to_remove.each do |child|
|
|
50
|
+
children.delete(child)
|
|
51
|
+
scoped.delete(child)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
to_remove.clear
|
|
55
|
+
|
|
56
|
+
@original_children[namespace].each do |child|
|
|
57
|
+
if child.scoped_unregistered?
|
|
58
|
+
to_remove << child
|
|
59
|
+
next
|
|
60
|
+
end
|
|
61
|
+
children << child unless children.include?(child)
|
|
62
|
+
end
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
|
|
64
|
+
to_remove.each do |child|
|
|
65
|
+
@original_children[namespace].delete(child)
|
|
66
|
+
end
|
|
46
67
|
end
|
|
47
68
|
|
|
48
|
-
|
|
69
|
+
Namespace.clear_lru_cache!
|
|
49
70
|
|
|
50
71
|
register_type_declaration(Handlers::RegisteredTypeDeclaration.new)
|
|
51
72
|
register_type_declaration(Handlers::ExtendRegisteredTypeDeclaration.new)
|
|
@@ -101,11 +122,15 @@ module Foobara
|
|
|
101
122
|
}
|
|
102
123
|
end
|
|
103
124
|
|
|
104
|
-
Value::DataError.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
::Foobara::Value::DataError.instance_exec do
|
|
126
|
+
class << self
|
|
127
|
+
def context_type_declaration
|
|
128
|
+
{
|
|
129
|
+
attribute_name: :symbol,
|
|
130
|
+
value: :duck
|
|
131
|
+
}.freeze
|
|
132
|
+
end
|
|
133
|
+
end
|
|
109
134
|
end
|
|
110
135
|
end
|
|
111
136
|
|
|
@@ -113,11 +138,33 @@ module Foobara
|
|
|
113
138
|
capture_current_namespaces
|
|
114
139
|
end
|
|
115
140
|
|
|
141
|
+
private
|
|
142
|
+
|
|
116
143
|
def capture_current_namespaces
|
|
117
144
|
# TODO: this feels like the wrong place to do this but doing it here for now to make sure it's done when
|
|
118
145
|
# most important
|
|
119
|
-
@original_scoped =
|
|
120
|
-
@original_children =
|
|
146
|
+
@original_scoped = {}
|
|
147
|
+
@original_children = {}
|
|
148
|
+
|
|
149
|
+
namespaces_to_reset.each do |namespace|
|
|
150
|
+
next unless namespace.is_a?(Namespace::IsNamespace)
|
|
151
|
+
|
|
152
|
+
@original_scoped[namespace] = namespace.foobara_registry.all_scoped.dup
|
|
153
|
+
@original_children[namespace] = namespace.foobara_children.dup
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def namespaces_to_reset
|
|
158
|
+
[
|
|
159
|
+
Foobara::GlobalDomain,
|
|
160
|
+
Foobara::GlobalOrganization,
|
|
161
|
+
Value::Processor,
|
|
162
|
+
Types::Type,
|
|
163
|
+
Domain,
|
|
164
|
+
Error,
|
|
165
|
+
Foobara,
|
|
166
|
+
Namespace.global
|
|
167
|
+
]
|
|
121
168
|
end
|
|
122
169
|
end
|
|
123
170
|
end
|
|
@@ -22,36 +22,20 @@ module Foobara
|
|
|
22
22
|
self.validate_error_context_enabled = true
|
|
23
23
|
|
|
24
24
|
module ErrorExtension
|
|
25
|
-
class NoContextTypeSetError < StandardError
|
|
26
|
-
def initialize
|
|
27
|
-
super("No context type declaration set. Either set it or mark the error as abstract")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
25
|
include Concern
|
|
32
26
|
# TODO: replace this with some kind of Foobara::TypeBuilder version
|
|
33
27
|
include WithRegistries
|
|
34
28
|
|
|
35
29
|
module ClassMethods
|
|
36
30
|
def context_type
|
|
37
|
-
@context_type
|
|
38
|
-
Foobara::Domain.foobara_type_from_declaration(self, context_type_declaration)
|
|
39
|
-
rescue NoContextTypeSetError
|
|
40
|
-
if abstract?
|
|
41
|
-
nil
|
|
42
|
-
else
|
|
43
|
-
# simplecov:disable
|
|
44
|
-
raise
|
|
45
|
-
# simplecov:enable
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
31
|
+
return @context_type if defined?(@context_type)
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# simplecov:enable
|
|
33
|
+
@context_type = unless abstract?
|
|
34
|
+
Foobara::Domain.foobara_type_from_declaration(self, context_type_declaration)
|
|
35
|
+
end
|
|
54
36
|
end
|
|
37
|
+
|
|
38
|
+
def context_type_declaration = {}.freeze
|
|
55
39
|
end
|
|
56
40
|
|
|
57
41
|
def initialize(...)
|
|
@@ -82,7 +82,6 @@ module Foobara
|
|
|
82
82
|
using_mode(Mode::STRINGIFIED, &)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
# TODO: use manifest context instead
|
|
86
85
|
def using_mode(new_mode, &)
|
|
87
86
|
with_manifest_context(mode: new_mode, &)
|
|
88
87
|
end
|
|
@@ -116,8 +115,17 @@ module Foobara
|
|
|
116
115
|
Thread.inheritable_thread_local_var_get("foobara_manifest_context")
|
|
117
116
|
end
|
|
118
117
|
|
|
119
|
-
allowed_context_keys = [
|
|
120
|
-
|
|
118
|
+
allowed_context_keys = [
|
|
119
|
+
:detached,
|
|
120
|
+
:to_include,
|
|
121
|
+
:mode,
|
|
122
|
+
:remove_sensitive,
|
|
123
|
+
:include_processors,
|
|
124
|
+
# This is just a flag to allow the deprecated Foobara.manifest to include
|
|
125
|
+
# everything without risk of breaking something in command connector manifests
|
|
126
|
+
:include_unreachable
|
|
127
|
+
]
|
|
128
|
+
booleans = [:detached, :remove_sensitive, :include_processors, :include_unreachable]
|
|
121
129
|
|
|
122
130
|
booleans.each do |context_item|
|
|
123
131
|
define_method "foobara_manifest_context_#{context_item}?" do
|
|
@@ -5,22 +5,11 @@ module Foobara
|
|
|
5
5
|
if args.size == 1
|
|
6
6
|
context_type.types_depended_on(args[0])
|
|
7
7
|
elsif args.empty?
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
raise Foobara::TypeDeclarations::ErrorExtension::NoContextTypeSetError
|
|
13
|
-
end
|
|
14
|
-
rescue Foobara::TypeDeclarations::ErrorExtension::NoContextTypeSetError
|
|
15
|
-
if abstract?
|
|
16
|
-
[]
|
|
17
|
-
else
|
|
18
|
-
# simplecov:disable
|
|
19
|
-
raise
|
|
20
|
-
# simplecov:enable
|
|
21
|
-
end
|
|
8
|
+
if abstract?
|
|
9
|
+
[]
|
|
10
|
+
else
|
|
11
|
+
context_type.types_depended_on
|
|
22
12
|
end
|
|
23
|
-
|
|
24
13
|
else
|
|
25
14
|
# simplecov:disable
|
|
26
15
|
raise ArgumentError, "Too many arguments #{args}"
|
data/version.rb
CHANGED