foobara 0.0.92 → 0.0.94
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/src/command_pattern_implementation/concerns/reflection.rb +39 -18
- data/projects/command/src/transformed_command.rb +83 -40
- data/projects/command_connectors/src/command_connector/commands/describe.rb +1 -5
- data/projects/command_connectors/src/command_connector/request.rb +7 -1
- data/projects/command_connectors/src/command_connector/response.rb +7 -1
- data/projects/command_connectors/src/command_connector.rb +85 -74
- data/projects/command_connectors/src/command_registry/exposed_command.rb +3 -2
- data/projects/command_connectors/src/command_registry/exposed_domain.rb +10 -3
- data/projects/command_connectors/src/command_registry/exposed_organization.rb +2 -2
- data/projects/command_connectors/src/serializers/atomic_serializer.rb +1 -1
- data/projects/command_connectors/src/serializers/errors_serializer.rb +4 -2
- data/projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb +40 -0
- data/projects/common/src/data_path.rb +16 -0
- data/projects/common/src/error.rb +10 -4
- data/projects/common/src/possible_error.rb +9 -3
- data/projects/detached_entity/src/concerns/associations.rb +26 -20
- data/projects/detached_entity/src/concerns/reflection.rb +3 -3
- data/projects/detached_entity/src/detached_entity_type.rb +8 -3
- data/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/{attributes_declaration.rb → model_instance_is_valid.rb} +1 -1
- data/projects/domain/src/domain_module_extension.rb +12 -4
- data/projects/domain/src/extensions/foobara.rb +31 -28
- data/projects/domain/src/is_manifestable.rb +6 -2
- data/projects/domain/src/organization_module_extension.rb +6 -2
- data/projects/entity/src/concerns/queries.rb +29 -31
- data/projects/entity/src/extensions/builtin_types/entity/validators/{attributes_declaration.rb → model_instance_is_valid.rb} +1 -1
- data/projects/model/src/concerns/reflection.rb +8 -2
- data/projects/model/src/concerns/types.rb +121 -23
- data/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb +1 -2
- data/projects/model/src/extensions/builtin_types/model/validators/{attributes_declaration.rb → model_instance_is_valid.rb} +1 -1
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +29 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +39 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +44 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +48 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +34 -0
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +34 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb +54 -0
- data/projects/model/src/model.rb +9 -0
- data/projects/model_attribute_helpers/src/attribute_helpers.rb +25 -4
- data/projects/namespace/src/is_namespace.rb +34 -15
- data/projects/persistence/src/entity_attributes_crud_driver.rb +25 -1
- data/projects/persistence/src/entity_base/transaction_table.rb +28 -3
- data/projects/type_declarations/src/desugarizer.rb +1 -1
- data/projects/type_declarations/src/type_builder.rb +42 -39
- data/projects/type_declarations/src/type_declaration_handler.rb +1 -1
- data/projects/type_declarations/src/type_declaration_handler_registry.rb +1 -1
- data/projects/type_declarations/src/type_declaration_validator.rb +1 -1
- data/projects/type_declarations/src/type_declarations.rb +39 -10
- data/projects/types/src/extensions/error.rb +3 -3
- data/projects/types/src/type/concerns/reflection.rb +79 -4
- data/projects/types/src/type.rb +42 -17
- data/projects/value/src/caster.rb +1 -1
- data/projects/value/src/mutator.rb +1 -1
- data/projects/value/src/processor/casting.rb +1 -1
- data/projects/value/src/processor/pipeline.rb +1 -1
- data/projects/value/src/processor/selection.rb +1 -1
- data/projects/value/src/processor.rb +13 -5
- data/projects/value/src/transformer.rb +1 -1
- data/projects/value/src/validator.rb +1 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 481928c28115c1b97adee6f5caa284b559ca954ee57f337bbb456ab80972b4eb
|
4
|
+
data.tar.gz: 2d083d6fb702f82dd920e4de4a7ac9bc6e82dd3fa87d874cb89f49d495d4b780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9a25149a21e5d8aa851e4a8776f5f3d8a3e44635598544a4d9da2e8e9709ec61c812e286ecedacd6376e7a928c94993567a5dd00d0c67d829d4f6a4d9848f6
|
7
|
+
data.tar.gz: 9561f972da6f0c94e40adc04d23ef33e7eea856b045248c4e04f057365543eaf82b6810592221e64e1ecb9e3a31530edb2f7beefa2ab3845a117197bd0b6c6af
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [0.0.94] - 2025-04-07
|
2
|
+
|
3
|
+
- Support capture_unknown_errors at the command connector level
|
4
|
+
|
5
|
+
# [0.0.93] - 2025-04-06
|
6
|
+
|
7
|
+
- Add delegated attributes to models
|
8
|
+
- Add private attributes to models
|
9
|
+
- Pass manifest construction context through thread_parent instead of passing it everywhere
|
10
|
+
- Various namespace lookup bugfixes
|
11
|
+
- Various bugfixes for .find_all/many type of methods in both Model and crud drivers
|
12
|
+
|
1
13
|
# [0.0.92] - 2025-04-01
|
2
14
|
|
3
15
|
- Improve error call stacks in calls like #run!
|
@@ -19,36 +19,48 @@ module Foobara
|
|
19
19
|
remove_instance_variable("@all") if instance_variable_defined?("@all")
|
20
20
|
end
|
21
21
|
|
22
|
-
def foobara_manifest
|
22
|
+
def foobara_manifest
|
23
|
+
to_include = TypeDeclarations.foobara_manifest_context_to_include
|
24
|
+
|
23
25
|
depends_on = self.depends_on.map do |command_name|
|
24
26
|
other_command = Foobara::Namespace.global.foobara_lookup!(command_name,
|
25
27
|
mode: Foobara::Namespace::LookupMode::ABSOLUTE)
|
26
|
-
to_include
|
28
|
+
if to_include
|
29
|
+
to_include << other_command
|
30
|
+
end
|
27
31
|
other_command.foobara_manifest_reference
|
28
32
|
end.sort
|
29
33
|
|
30
|
-
types = types_depended_on
|
31
|
-
to_include
|
34
|
+
types = types_depended_on.map do |t|
|
35
|
+
if to_include
|
36
|
+
to_include << t
|
37
|
+
end
|
32
38
|
t.foobara_manifest_reference
|
33
39
|
end.sort
|
34
40
|
|
35
41
|
inputs_types_depended_on = self.inputs_types_depended_on.map do |t|
|
36
|
-
to_include
|
42
|
+
if to_include
|
43
|
+
to_include << t
|
44
|
+
end
|
37
45
|
t.foobara_manifest_reference
|
38
46
|
end.sort
|
39
47
|
|
40
48
|
result_types_depended_on = self.result_types_depended_on.map do |t|
|
41
|
-
to_include
|
49
|
+
if to_include
|
50
|
+
to_include << t
|
51
|
+
end
|
42
52
|
t.foobara_manifest_reference
|
43
53
|
end.sort
|
44
54
|
|
45
55
|
errors_types_depended_on = self.errors_types_depended_on.map do |t|
|
46
|
-
to_include
|
56
|
+
if to_include
|
57
|
+
to_include << t
|
58
|
+
end
|
47
59
|
t.foobara_manifest_reference
|
48
60
|
end.sort
|
49
61
|
|
50
62
|
possible_errors = self.possible_errors.map do |possible_error|
|
51
|
-
[possible_error.key.to_s, possible_error.foobara_manifest
|
63
|
+
[possible_error.key.to_s, possible_error.foobara_manifest]
|
52
64
|
end.sort.to_h
|
53
65
|
|
54
66
|
h = Util.remove_blank(
|
@@ -78,15 +90,18 @@ module Foobara
|
|
78
90
|
Util.non_full_name(self)
|
79
91
|
end
|
80
92
|
|
81
|
-
def types_depended_on
|
93
|
+
def types_depended_on
|
94
|
+
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
95
|
+
|
82
96
|
if defined?(@types_depended_on) && @types_depended_on.key?(remove_sensitive)
|
83
97
|
return @types_depended_on[remove_sensitive]
|
84
98
|
end
|
85
99
|
|
86
100
|
@types_depended_on ||= {}
|
87
101
|
@types_depended_on[remove_sensitive] = begin
|
88
|
-
types = inputs_types_depended_on
|
89
|
-
|
102
|
+
types = inputs_types_depended_on |
|
103
|
+
result_types_depended_on |
|
104
|
+
errors_types_depended_on
|
90
105
|
|
91
106
|
unless depends_on_entities.empty?
|
92
107
|
entity_types = depends_on_entities.map(&:entity_type)
|
@@ -96,14 +111,16 @@ module Foobara
|
|
96
111
|
end
|
97
112
|
|
98
113
|
types |= entity_types
|
99
|
-
types |= entity_types.map
|
114
|
+
types |= entity_types.map(&:types_depended_on).inject(:|)
|
100
115
|
end
|
101
116
|
|
102
117
|
types
|
103
118
|
end
|
104
119
|
end
|
105
120
|
|
106
|
-
def inputs_types_depended_on
|
121
|
+
def inputs_types_depended_on
|
122
|
+
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
123
|
+
|
107
124
|
if defined?(@inputs_types_depended_on) && @inputs_types_depended_on.key?(remove_sensitive)
|
108
125
|
return @inputs_types_depended_on[remove_sensitive]
|
109
126
|
end
|
@@ -121,14 +138,16 @@ module Foobara
|
|
121
138
|
end
|
122
139
|
# :nocov:
|
123
140
|
else
|
124
|
-
inputs_type.types_depended_on
|
141
|
+
inputs_type.types_depended_on
|
125
142
|
end
|
126
143
|
else
|
127
144
|
Set.new
|
128
145
|
end
|
129
146
|
end
|
130
147
|
|
131
|
-
def result_types_depended_on
|
148
|
+
def result_types_depended_on
|
149
|
+
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
150
|
+
|
132
151
|
if defined?(@result_types_depended_on) && @result_types_depended_on.key?(remove_sensitive)
|
133
152
|
return @result_types_depended_on[remove_sensitive]
|
134
153
|
end
|
@@ -138,14 +157,16 @@ module Foobara
|
|
138
157
|
if result_type.registered?
|
139
158
|
Set[result_type]
|
140
159
|
else
|
141
|
-
result_type.types_depended_on
|
160
|
+
result_type.types_depended_on
|
142
161
|
end
|
143
162
|
else
|
144
163
|
Set.new
|
145
164
|
end
|
146
165
|
end
|
147
166
|
|
148
|
-
def errors_types_depended_on
|
167
|
+
def errors_types_depended_on
|
168
|
+
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
169
|
+
|
149
170
|
if defined?(@errors_types_depended_on) && @errors_types_depended_on.key?(remove_sensitive)
|
150
171
|
return @errors_types_depended_on[remove_sensitive]
|
151
172
|
end
|
@@ -153,7 +174,7 @@ module Foobara
|
|
153
174
|
@errors_types_depended_on ||= {}
|
154
175
|
@errors_types_depended_on[remove_sensitive] = begin
|
155
176
|
error_classes = possible_errors.map(&:error_class)
|
156
|
-
error_classes.map
|
177
|
+
error_classes.map(&:types_depended_on).inject(:|) || Set.new
|
157
178
|
end
|
158
179
|
end
|
159
180
|
end
|
@@ -174,28 +174,48 @@ module Foobara
|
|
174
174
|
@possible_errors ||= error_context_type_map.values
|
175
175
|
end
|
176
176
|
|
177
|
-
def possible_errors_manifest
|
178
|
-
|
179
|
-
|
180
|
-
|
177
|
+
def possible_errors_manifest
|
178
|
+
errors_proc = -> do
|
179
|
+
possible_errors.map do |possible_error|
|
180
|
+
[possible_error.key.to_s, possible_error.foobara_manifest]
|
181
|
+
end.sort.to_h
|
182
|
+
end
|
183
|
+
|
184
|
+
if TypeDeclarations.manifest_context_set?(:remove_sensitive)
|
185
|
+
errors_proc.call
|
186
|
+
else
|
187
|
+
TypeDeclarations.with_manifest_context(remove_sensitive: true, &errors_proc)
|
188
|
+
end
|
181
189
|
end
|
182
190
|
|
183
191
|
def inputs_types_depended_on
|
184
|
-
|
192
|
+
TypeDeclarations.with_manifest_context(remove_sensitive: false) do
|
193
|
+
inputs_type_for_manifest&.types_depended_on || []
|
194
|
+
end
|
185
195
|
end
|
186
196
|
|
187
|
-
def result_types_depended_on
|
188
|
-
result_type_for_manifest&.types_depended_on
|
197
|
+
def result_types_depended_on
|
198
|
+
type_proc = -> { result_type_for_manifest&.types_depended_on || [] }
|
199
|
+
|
200
|
+
if TypeDeclarations.manifest_context_set?(:remove_sensitive)
|
201
|
+
type_proc.call
|
202
|
+
else
|
203
|
+
TypeDeclarations.with_manifest_context(remove_sensitive: true, &type_proc)
|
204
|
+
end
|
189
205
|
end
|
190
206
|
|
191
|
-
def types_depended_on
|
207
|
+
def types_depended_on
|
208
|
+
# Seems to be not necessary?
|
209
|
+
# types = command_class.types_depended_on
|
210
|
+
|
211
|
+
types = Set.new
|
212
|
+
|
192
213
|
# TODO: memoize this
|
193
214
|
# TODO: this should not delegate to command since transformers are in play
|
194
|
-
types = command_class.types_depended_on(remove_sensitive:)
|
195
215
|
|
196
216
|
type = inputs_type
|
197
217
|
|
198
|
-
if type
|
218
|
+
if type
|
199
219
|
if type.registered?
|
200
220
|
# TODO: if we ever change from attributes-only inputs type
|
201
221
|
# then this will be handy
|
@@ -207,75 +227,98 @@ module Foobara
|
|
207
227
|
types |= type.types_depended_on
|
208
228
|
end
|
209
229
|
|
210
|
-
|
230
|
+
types_proc = proc do
|
231
|
+
type = result_type
|
211
232
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
233
|
+
if type
|
234
|
+
if type.registered?
|
235
|
+
# TODO: if we ever change from attributes-only inputs type
|
236
|
+
# then this will be handy
|
237
|
+
# :nocov:
|
238
|
+
types |= [type]
|
239
|
+
# :nocov:
|
240
|
+
end
|
241
|
+
|
242
|
+
types |= type.types_depended_on
|
219
243
|
end
|
220
244
|
|
221
|
-
|
222
|
-
|
245
|
+
possible_errors.each do |possible_error|
|
246
|
+
error_class = possible_error.error_class
|
247
|
+
types |= error_class.types_depended_on
|
248
|
+
end
|
223
249
|
|
224
|
-
|
225
|
-
error_class = possible_error.error_class
|
226
|
-
types |= error_class.types_depended_on(remove_sensitive:)
|
250
|
+
types
|
227
251
|
end
|
228
252
|
|
229
|
-
|
253
|
+
if TypeDeclarations.manifest_context_set?(:remove_sensitive)
|
254
|
+
types_proc.call
|
255
|
+
else
|
256
|
+
TypeDeclarations.with_manifest_context(remove_sensitive: true, &types_proc)
|
257
|
+
end
|
230
258
|
end
|
231
259
|
|
232
|
-
def foobara_manifest
|
260
|
+
def foobara_manifest
|
261
|
+
to_include = TypeDeclarations.foobara_manifest_context_to_include
|
262
|
+
|
233
263
|
types = types_depended_on.select(&:registered?).map do |t|
|
234
|
-
to_include
|
264
|
+
if to_include
|
265
|
+
to_include << t
|
266
|
+
end
|
235
267
|
t.foobara_manifest_reference
|
236
268
|
end.sort
|
237
269
|
|
238
|
-
inputs_transformers =
|
239
|
-
|
240
|
-
|
241
|
-
|
270
|
+
inputs_transformers = TypeDeclarations.with_manifest_context(remove_sensitive: false) do
|
271
|
+
self.inputs_transformers.map(&:foobara_manifest)
|
272
|
+
end
|
273
|
+
result_transformers = self.result_transformers.map(&:foobara_manifest)
|
274
|
+
errors_transformers = self.errors_transformers.map(&:foobara_manifest)
|
275
|
+
pre_commit_transformers = self.pre_commit_transformers.map(&:foobara_manifest)
|
242
276
|
serializers = self.serializers.map do |s|
|
243
277
|
if s.respond_to?(:foobara_manifest)
|
244
|
-
to_include
|
278
|
+
if to_include
|
279
|
+
to_include << s
|
280
|
+
end
|
245
281
|
s.foobara_manifest_reference
|
246
282
|
else
|
247
283
|
{ proc: s.to_s }
|
248
284
|
end
|
249
285
|
end
|
250
286
|
|
251
|
-
response_mutators = self.response_mutators.map
|
252
|
-
request_mutators =
|
287
|
+
response_mutators = self.response_mutators.map(&:foobara_manifest)
|
288
|
+
request_mutators = TypeDeclarations.with_manifest_context(remove_sensitive: false) do
|
289
|
+
self.request_mutators.map(&:foobara_manifest)
|
290
|
+
end
|
253
291
|
|
254
292
|
authenticator_manifest = if authenticator
|
255
293
|
if authenticator.respond_to?(:foobara_manifest)
|
256
294
|
# TODO: test this path
|
257
295
|
# :nocov:
|
258
|
-
authenticator.foobara_manifest
|
296
|
+
authenticator.foobara_manifest
|
259
297
|
# :nocov:
|
260
298
|
else
|
261
299
|
true
|
262
300
|
end
|
263
301
|
end
|
264
302
|
|
265
|
-
inputs_types_depended_on =
|
266
|
-
|
303
|
+
inputs_types_depended_on = TypeDeclarations.with_manifest_context(remove_sensitive: false) do
|
304
|
+
self.inputs_types_depended_on.map(&:foobara_manifest_reference).sort
|
305
|
+
end
|
306
|
+
|
307
|
+
result_types_depended_on = self.result_types_depended_on.map(&:foobara_manifest_reference)
|
267
308
|
result_types_depended_on = result_types_depended_on.sort
|
268
309
|
|
269
310
|
# TODO: Do NOT defer to command_class.foobara_manifest because it might process types that
|
270
311
|
# might not have an exposed command and might not need one due to transformers/mutators/remove_sensitive flag
|
271
|
-
command_class.foobara_manifest
|
312
|
+
command_class.foobara_manifest.merge(
|
272
313
|
Util.remove_blank(
|
273
314
|
inputs_types_depended_on:,
|
274
315
|
result_types_depended_on:,
|
275
316
|
types_depended_on: types,
|
276
|
-
inputs_type:
|
277
|
-
|
278
|
-
|
317
|
+
inputs_type: TypeDeclarations.with_manifest_context(remove_sensitive: false) do
|
318
|
+
inputs_type_for_manifest&.reference_or_declaration_data
|
319
|
+
end,
|
320
|
+
result_type: result_type_for_manifest&.reference_or_declaration_data,
|
321
|
+
possible_errors: possible_errors_manifest,
|
279
322
|
capture_unknown_error:,
|
280
323
|
inputs_transformers:,
|
281
324
|
result_transformers:,
|
@@ -16,11 +16,7 @@ module Foobara
|
|
16
16
|
attr_accessor :manifest
|
17
17
|
|
18
18
|
def build_manifest
|
19
|
-
self.manifest =
|
20
|
-
manifestable.foobara_manifest
|
21
|
-
else
|
22
|
-
manifestable.foobara_manifest(to_include: Set.new)
|
23
|
-
end
|
19
|
+
self.manifest = manifestable.foobara_manifest
|
24
20
|
end
|
25
21
|
|
26
22
|
def stamp_request_metadata
|
@@ -86,6 +86,18 @@ module Foobara
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
attr_accessor :command_registry, :authenticator, :capture_unknown_error
|
90
|
+
|
91
|
+
def initialize(authenticator: nil, capture_unknown_error: nil, default_serializers: nil)
|
92
|
+
self.command_registry = CommandRegistry.new(authenticator:)
|
93
|
+
self.authenticator = authenticator
|
94
|
+
self.capture_unknown_error = capture_unknown_error
|
95
|
+
|
96
|
+
Util.array(default_serializers).each do |serializer|
|
97
|
+
add_default_serializer(serializer)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
89
101
|
def find_builtin_command_class(command_class_name)
|
90
102
|
self.class.find_builtin_command_class(command_class_name)
|
91
103
|
end
|
@@ -104,8 +116,6 @@ module Foobara
|
|
104
116
|
:all_transformed_command_classes,
|
105
117
|
to: :command_registry
|
106
118
|
|
107
|
-
attr_accessor :command_registry, :authenticator
|
108
|
-
|
109
119
|
def lookup_command(name)
|
110
120
|
command_registry.foobara_lookup_command(name)
|
111
121
|
end
|
@@ -237,13 +247,11 @@ module Foobara
|
|
237
247
|
end
|
238
248
|
|
239
249
|
def set_response_status(response)
|
240
|
-
|
241
|
-
response.status = outcome.success? ? 0 : 1
|
250
|
+
response.status = response.success? ? 0 : 1
|
242
251
|
end
|
243
252
|
|
244
253
|
def set_response_body(response)
|
245
254
|
outcome = response.request.outcome
|
246
|
-
# response.body = outcome.success? ? outcome.result : outcome.error_collection
|
247
255
|
response.body = outcome.success? ? outcome.result : outcome.error_collection
|
248
256
|
end
|
249
257
|
|
@@ -263,15 +271,6 @@ module Foobara
|
|
263
271
|
end
|
264
272
|
end
|
265
273
|
|
266
|
-
def initialize(authenticator: nil, default_serializers: nil)
|
267
|
-
self.command_registry = CommandRegistry.new(authenticator:)
|
268
|
-
self.authenticator = authenticator
|
269
|
-
|
270
|
-
Util.array(default_serializers).each do |serializer|
|
271
|
-
add_default_serializer(serializer)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
274
|
def connect_delayed(registerable_name, *args, **opts)
|
276
275
|
delayed_connections[registerable_name] = { args:, opts: }
|
277
276
|
end
|
@@ -343,7 +342,7 @@ module Foobara
|
|
343
342
|
end
|
344
343
|
|
345
344
|
if command
|
346
|
-
|
345
|
+
run_command(request)
|
347
346
|
# :nocov:
|
348
347
|
elsif !request.error
|
349
348
|
raise "No command returned from #request_to_command"
|
@@ -353,6 +352,16 @@ module Foobara
|
|
353
352
|
build_response(request)
|
354
353
|
end
|
355
354
|
|
355
|
+
def run_command(request)
|
356
|
+
request.command.run
|
357
|
+
rescue => e
|
358
|
+
if capture_unknown_error
|
359
|
+
request.error = CommandConnector::UnknownError.new(e)
|
360
|
+
else
|
361
|
+
raise
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
356
365
|
def authenticate(request)
|
357
366
|
request_command = request.command
|
358
367
|
|
@@ -396,10 +405,9 @@ module Foobara
|
|
396
405
|
Foobara.foobara_lookup_type(name, mode: Namespace::LookupMode::RELAXED)
|
397
406
|
end
|
398
407
|
|
399
|
-
def foobara_manifest
|
408
|
+
def foobara_manifest
|
400
409
|
process_delayed_connections
|
401
410
|
|
402
|
-
# Drive all of this off of the list of exposed commands...
|
403
411
|
to_include = Set.new
|
404
412
|
|
405
413
|
to_include << command_registry.global_organization
|
@@ -423,81 +431,84 @@ module Foobara
|
|
423
431
|
processor_class: {}
|
424
432
|
}
|
425
433
|
|
426
|
-
|
427
|
-
|
434
|
+
TypeDeclarations.with_manifest_context(to_include: additional_to_include, remove_sensitive: true) do
|
435
|
+
until to_include.empty? && additional_to_include.empty?
|
436
|
+
object = nil
|
428
437
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
438
|
+
if to_include.empty?
|
439
|
+
until additional_to_include.empty?
|
440
|
+
o = additional_to_include.first
|
441
|
+
additional_to_include.delete(o)
|
433
442
|
|
434
|
-
|
435
|
-
|
436
|
-
|
443
|
+
if o.is_a?(::Module)
|
444
|
+
if o.foobara_domain? || o.foobara_organization?
|
445
|
+
unless o.foobara_root_namespace == command_registry
|
446
|
+
next
|
447
|
+
end
|
448
|
+
elsif o.is_a?(::Class) && o < Foobara::Command
|
437
449
|
next
|
438
450
|
end
|
439
|
-
elsif o.is_a?(::
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
451
|
+
elsif o.is_a?(Types::Type)
|
452
|
+
if o.sensitive?
|
453
|
+
# :nocov:
|
454
|
+
raise UnexpectedSensitiveTypeInManifestError,
|
455
|
+
"Unexpected sensitive type in manifest: #{o.scoped_full_path}. " \
|
456
|
+
"Make sure these are not included."
|
444
457
|
# :nocov:
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
unless command_registry.foobara_registered?(domain_name)
|
452
|
-
command_registry.build_and_register_exposed_domain(domain_name)
|
453
|
-
|
454
|
-
# Since we don't know which other domains/orgs creating this domain might have created,
|
455
|
-
# we will just add them all to be included just in case
|
456
|
-
command_registry.foobara_all_domain.each do |exposed_domain|
|
457
|
-
additional_to_include << exposed_domain
|
458
|
-
end
|
458
|
+
else
|
459
|
+
domain_name = o.foobara_domain.scoped_full_name
|
460
|
+
|
461
|
+
unless command_registry.foobara_registered?(domain_name)
|
462
|
+
command_registry.build_and_register_exposed_domain(domain_name)
|
459
463
|
|
460
|
-
|
461
|
-
|
464
|
+
# Since we don't know which other domains/orgs creating this domain might have created,
|
465
|
+
# we will just add them all to be included just in case
|
466
|
+
command_registry.foobara_all_domain.each do |exposed_domain|
|
467
|
+
additional_to_include << exposed_domain
|
468
|
+
end
|
469
|
+
|
470
|
+
command_registry.foobara_all_organization.each do |exposed_organization|
|
471
|
+
additional_to_include << exposed_organization
|
472
|
+
end
|
462
473
|
end
|
463
474
|
end
|
464
475
|
end
|
465
|
-
end
|
466
476
|
|
467
|
-
|
468
|
-
|
477
|
+
object = o
|
478
|
+
break
|
479
|
+
end
|
480
|
+
else
|
481
|
+
object = to_include.first
|
482
|
+
to_include.delete(object)
|
469
483
|
end
|
470
|
-
else
|
471
|
-
object = to_include.first
|
472
|
-
to_include.delete(object)
|
473
|
-
end
|
474
484
|
|
475
|
-
|
476
|
-
|
485
|
+
break unless object
|
486
|
+
next if included.include?(object)
|
477
487
|
|
478
|
-
|
488
|
+
manifest_reference = object.foobara_manifest_reference.to_sym
|
479
489
|
|
480
|
-
|
490
|
+
category_symbol = command_registry.foobara_category_symbol_for(object)
|
481
491
|
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
492
|
+
unless category_symbol
|
493
|
+
# :nocov:
|
494
|
+
raise "no category symbol for #{object}"
|
495
|
+
# :nocov:
|
496
|
+
end
|
487
497
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
498
|
+
namespace = if object.is_a?(Types::Type)
|
499
|
+
object.created_in_namespace
|
500
|
+
else
|
501
|
+
Foobara::Namespace.current
|
502
|
+
end
|
493
503
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
504
|
+
cat = h[category_symbol] ||= {}
|
505
|
+
# TODO: do we really need to enter the namespace here for this?
|
506
|
+
cat[manifest_reference] = Foobara::Namespace.use namespace do
|
507
|
+
object.foobara_manifest
|
508
|
+
end
|
499
509
|
|
500
|
-
|
510
|
+
included << object
|
511
|
+
end
|
501
512
|
end
|
502
513
|
|
503
514
|
h[:domain].each_value do |domain_manifest|
|
@@ -100,8 +100,8 @@ module Foobara
|
|
100
100
|
@full_command_symbol ||= Util.underscore_sym(full_command_name)
|
101
101
|
end
|
102
102
|
|
103
|
-
def foobara_manifest
|
104
|
-
transformed_command_class.foobara_manifest
|
103
|
+
def foobara_manifest
|
104
|
+
transformed_command_class.foobara_manifest.merge(super).merge(
|
105
105
|
Util.remove_blank(
|
106
106
|
scoped_category: :command,
|
107
107
|
domain: command_class.domain.foobara_manifest_reference,
|
@@ -113,6 +113,7 @@ module Foobara
|
|
113
113
|
def transformed_command_class
|
114
114
|
@transformed_command_class ||= if Util.all_blank_or_false?(
|
115
115
|
[
|
116
|
+
capture_unknown_error,
|
116
117
|
inputs_transformers,
|
117
118
|
result_transformers,
|
118
119
|
errors_transformers,
|