foobara 0.0.90 → 0.0.92
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 -2
- data/projects/builtin_types/src/email/validator_base.rb +1 -1
- data/projects/command/src/transformed_command.rb +46 -33
- data/projects/command_connectors/src/command_connector.rb +32 -3
- data/projects/command_connectors/src/command_registry.rb +9 -0
- data/projects/common/src/error.rb +25 -1
- data/projects/common/src/outcome.rb +11 -5
- data/projects/manifest/src/foobara/manifest/command.rb +4 -0
- data/projects/type_declarations/src/remove_sensitive_values_transformer.rb +6 -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: ad04851e6936963ef7ad60f1d6e7ab34241993abb2107b14a26d8cbc8d73663e
|
4
|
+
data.tar.gz: 178614a7f7b288a13ca290a14f702348e47d43e4d675611c7953bcdd033bdf5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13112e8c68e48a51e442ce485c5fbcc89ab5974df3f1349012e2e646cecdf1742096bc5d42a9edb4c5dd825b06adabca6302f8a4c9ec44857c98338c8cc4b210
|
7
|
+
data.tar.gz: a48dcd6f4ec1f36feba216fab63711ea37a2378f819cc450a8e08bb15ea62a4f4463970f666b7d61fabd7aee871e01112abe2afceb915fbd0bc2cade4994b4b3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# [0.0.92] - 2025-04-01
|
2
|
+
|
3
|
+
- Improve error call stacks in calls like #run!
|
4
|
+
- Fix bug preventing first call to CommandConnector#foobara_manifest from returning all its domains
|
5
|
+
|
6
|
+
# [0.0.91] - 2025-03-31
|
7
|
+
|
8
|
+
- Fix bug that was including removed types in command manifest's inputs_types_depended_on
|
9
|
+
- Hoist authentication check up into command connector further from transformed command
|
10
|
+
|
1
11
|
# [0.0.90] - 2025-03-29
|
2
12
|
|
3
13
|
- Implement request mutator concept
|
@@ -11,7 +21,7 @@
|
|
11
21
|
- Implement response mutator concept
|
12
22
|
- Break up #request_to_response for easier overriding/extension
|
13
23
|
- Add AttributesTransformers::Reject
|
14
|
-
- Fix problem causing downcase/regex processors to explode on
|
24
|
+
- Fix problem causing downcase/regex processors to explode on allow_nil types
|
15
25
|
|
16
26
|
# [0.0.87] - 2025-03-26
|
17
27
|
|
@@ -266,7 +276,7 @@
|
|
266
276
|
|
267
277
|
## [0.0.13] - 2024-11-13
|
268
278
|
|
269
|
-
- Do not fail :one_of if it is nil and :
|
279
|
+
- Do not fail :one_of if it is nil and :allow_nil
|
270
280
|
|
271
281
|
## [0.0.12] - 2024-10-30
|
272
282
|
|
@@ -73,7 +73,7 @@ module Foobara
|
|
73
73
|
|
74
74
|
Util.make_class(class_name, ValidatorBase) do
|
75
75
|
define_method :applicable? do |value|
|
76
|
-
# TODO: hmmm, I wonder how we can short-circuit these checks if :
|
76
|
+
# TODO: hmmm, I wonder how we can short-circuit these checks if :allow_nil matches??
|
77
77
|
value.is_a?(::String)
|
78
78
|
end
|
79
79
|
|
@@ -180,6 +180,14 @@ module Foobara
|
|
180
180
|
end.sort.to_h
|
181
181
|
end
|
182
182
|
|
183
|
+
def inputs_types_depended_on
|
184
|
+
inputs_type_for_manifest&.types_depended_on || []
|
185
|
+
end
|
186
|
+
|
187
|
+
def result_types_depended_on(remove_sensitive: true)
|
188
|
+
result_type_for_manifest&.types_depended_on(remove_sensitive:) || []
|
189
|
+
end
|
190
|
+
|
183
191
|
def types_depended_on(remove_sensitive: true)
|
184
192
|
# TODO: memoize this
|
185
193
|
# TODO: this should not delegate to command since transformers are in play
|
@@ -188,29 +196,29 @@ module Foobara
|
|
188
196
|
type = inputs_type
|
189
197
|
|
190
198
|
if type != command_class.inputs_type
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
199
|
+
if type.registered?
|
200
|
+
# TODO: if we ever change from attributes-only inputs type
|
201
|
+
# then this will be handy
|
202
|
+
# :nocov:
|
203
|
+
types |= [type]
|
204
|
+
# :nocov:
|
205
|
+
end
|
206
|
+
|
207
|
+
types |= type.types_depended_on
|
200
208
|
end
|
201
209
|
|
202
210
|
type = result_type
|
203
211
|
|
204
212
|
if type != command_class.result_type
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
213
|
+
if type.registered?
|
214
|
+
# TODO: if we ever change from attributes-only inputs type
|
215
|
+
# then this will be handy
|
216
|
+
# :nocov:
|
217
|
+
types |= [type]
|
218
|
+
# :nocov:
|
219
|
+
end
|
220
|
+
|
221
|
+
types |= type.types_depended_on(remove_sensitive:)
|
214
222
|
end
|
215
223
|
|
216
224
|
possible_errors.each do |possible_error|
|
@@ -243,8 +251,27 @@ module Foobara
|
|
243
251
|
response_mutators = self.response_mutators.map { |t| t.foobara_manifest(to_include:) }
|
244
252
|
request_mutators = self.request_mutators.map { |t| t.foobara_manifest(to_include:) }
|
245
253
|
|
254
|
+
authenticator_manifest = if authenticator
|
255
|
+
if authenticator.respond_to?(:foobara_manifest)
|
256
|
+
# TODO: test this path
|
257
|
+
# :nocov:
|
258
|
+
authenticator.foobara_manifest(to_include:)
|
259
|
+
# :nocov:
|
260
|
+
else
|
261
|
+
true
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
inputs_types_depended_on = self.inputs_types_depended_on.map(&:foobara_manifest_reference).sort
|
266
|
+
result_types_depended_on = self.result_types_depended_on(remove_sensitive:).map(&:foobara_manifest_reference)
|
267
|
+
result_types_depended_on = result_types_depended_on.sort
|
268
|
+
|
269
|
+
# TODO: Do NOT defer to command_class.foobara_manifest because it might process types that
|
270
|
+
# might not have an exposed command and might not need one due to transformers/mutators/remove_sensitive flag
|
246
271
|
command_class.foobara_manifest(to_include:, remove_sensitive:).merge(
|
247
272
|
Util.remove_blank(
|
273
|
+
inputs_types_depended_on:,
|
274
|
+
result_types_depended_on:,
|
248
275
|
types_depended_on: types,
|
249
276
|
inputs_type: inputs_type_for_manifest&.reference_or_declaration_data,
|
250
277
|
result_type: result_type_for_manifest&.reference_or_declaration_data(remove_sensitive:),
|
@@ -258,7 +285,7 @@ module Foobara
|
|
258
285
|
response_mutators:,
|
259
286
|
request_mutators:,
|
260
287
|
requires_authentication:,
|
261
|
-
authenticator:
|
288
|
+
authenticator: authenticator_manifest
|
262
289
|
)
|
263
290
|
)
|
264
291
|
end
|
@@ -394,7 +421,6 @@ module Foobara
|
|
394
421
|
to: :class
|
395
422
|
|
396
423
|
def run
|
397
|
-
authenticate if requires_authentication?
|
398
424
|
apply_allowed_rule
|
399
425
|
apply_pre_commit_transformers
|
400
426
|
run_command
|
@@ -482,19 +508,6 @@ module Foobara
|
|
482
508
|
self.command = command_class.new(transformed_inputs)
|
483
509
|
end
|
484
510
|
|
485
|
-
def authenticate
|
486
|
-
command.after_load_records do |command:, **|
|
487
|
-
self.authenticated_user = instance_eval(&:authenticator)
|
488
|
-
|
489
|
-
unless authenticated_user
|
490
|
-
self.outcome = Outcome.error(CommandConnector::UnauthenticatedError.new)
|
491
|
-
|
492
|
-
command.state_machine.error!
|
493
|
-
command.halt!
|
494
|
-
end
|
495
|
-
end
|
496
|
-
end
|
497
|
-
|
498
511
|
def apply_allowed_rule
|
499
512
|
rule = allowed_rule
|
500
513
|
|
@@ -338,6 +338,10 @@ module Foobara
|
|
338
338
|
# TODO: feels like a smell
|
339
339
|
request.command_connector = self
|
340
340
|
|
341
|
+
if command.respond_to?(:requires_authentication?) && command.requires_authentication?
|
342
|
+
authenticate(request)
|
343
|
+
end
|
344
|
+
|
341
345
|
if command
|
342
346
|
command.run
|
343
347
|
# :nocov:
|
@@ -349,6 +353,23 @@ module Foobara
|
|
349
353
|
build_response(request)
|
350
354
|
end
|
351
355
|
|
356
|
+
def authenticate(request)
|
357
|
+
request_command = request.command
|
358
|
+
|
359
|
+
request_command.after_load_records do |command:, **|
|
360
|
+
authenticated_user = request.instance_eval(&authenticator)
|
361
|
+
|
362
|
+
request_command.authenticated_user = authenticated_user
|
363
|
+
|
364
|
+
unless authenticated_user
|
365
|
+
request_command.outcome = Outcome.error(CommandConnector::UnauthenticatedError.new)
|
366
|
+
|
367
|
+
command.state_machine.error!
|
368
|
+
command.halt!
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
352
373
|
def build_request_and_command(...)
|
353
374
|
request = build_request(...)
|
354
375
|
|
@@ -428,9 +449,17 @@ module Foobara
|
|
428
449
|
domain_name = o.foobara_domain.scoped_full_name
|
429
450
|
|
430
451
|
unless command_registry.foobara_registered?(domain_name)
|
431
|
-
|
432
|
-
|
433
|
-
|
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
|
459
|
+
|
460
|
+
command_registry.foobara_all_organization.each do |exposed_organization|
|
461
|
+
additional_to_include << exposed_organization
|
462
|
+
end
|
434
463
|
end
|
435
464
|
end
|
436
465
|
end
|
@@ -86,6 +86,15 @@ module Foobara
|
|
86
86
|
exposed_organization.foobara_register(exposed_domain)
|
87
87
|
exposed_domain.foobara_parent_namespace = exposed_organization
|
88
88
|
|
89
|
+
domain_module.foobara_depends_on.each do |domain_name|
|
90
|
+
# TODO: test this code path!!
|
91
|
+
# :nocov:
|
92
|
+
unless foobara_organization_registered?(domain_name)
|
93
|
+
build_and_register_exposed_domain(domain_name)
|
94
|
+
end
|
95
|
+
# :nocov:
|
96
|
+
end
|
97
|
+
|
89
98
|
exposed_domain
|
90
99
|
end
|
91
100
|
|
@@ -5,7 +5,7 @@ module Foobara
|
|
5
5
|
include Manifestable
|
6
6
|
|
7
7
|
# TODO: rename :path to data_path
|
8
|
-
attr_accessor :error_key, :message, :context, :is_fatal
|
8
|
+
attr_accessor :error_key, :message, :context, :is_fatal, :backtrace_when_initialized, :backtrace_when_raised
|
9
9
|
|
10
10
|
# Need to do this early so doing it here... not sure if this is OK as it couples namespaces and errors
|
11
11
|
|
@@ -219,6 +219,30 @@ module Foobara
|
|
219
219
|
# :nocov:
|
220
220
|
end
|
221
221
|
|
222
|
+
backtrace_when_initialized = caller[1..]
|
223
|
+
index = 1
|
224
|
+
|
225
|
+
has_build_error = false
|
226
|
+
|
227
|
+
1.upto(10) do |i|
|
228
|
+
if backtrace_when_initialized[i].end_with?("#build_error'")
|
229
|
+
index = i + 1
|
230
|
+
has_build_error = true
|
231
|
+
break
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
if has_build_error
|
236
|
+
index.upto(10) do |i|
|
237
|
+
unless backtrace_when_initialized[i].end_with?("#build_error'")
|
238
|
+
index = i
|
239
|
+
break
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
self.backtrace_when_initialized = backtrace_when_initialized[index..]
|
245
|
+
|
222
246
|
super(message)
|
223
247
|
end
|
224
248
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Foobara
|
2
2
|
class Outcome
|
3
3
|
class UnsuccessfulOutcomeError < StandardError
|
4
|
-
attr_accessor :errors
|
4
|
+
attr_accessor :errors, :backtrace_when_raised
|
5
5
|
|
6
6
|
def initialize(errors)
|
7
7
|
self.errors = errors
|
@@ -74,11 +74,17 @@ module Foobara
|
|
74
74
|
def raise!
|
75
75
|
return if success?
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
error = errors.first
|
78
|
+
original_backtrace = error.backtrace_when_initialized
|
79
|
+
|
80
|
+
if errors.size > 1
|
81
|
+
error = UnsuccessfulOutcomeError.new(errors)
|
81
82
|
end
|
83
|
+
|
84
|
+
error.set_backtrace(original_backtrace)
|
85
|
+
error.backtrace_when_raised = caller
|
86
|
+
|
87
|
+
raise error
|
82
88
|
end
|
83
89
|
|
84
90
|
def result!
|
@@ -8,9 +8,15 @@ module Foobara
|
|
8
8
|
associations = Foobara::DetachedEntity.construct_deep_associations(from_type)
|
9
9
|
|
10
10
|
associations&.values&.reverse&.each do |entity_type|
|
11
|
+
next if entity_type.sensitive?
|
12
|
+
next unless entity_type.has_sensitive_types?
|
13
|
+
|
11
14
|
declaration = entity_type.declaration_data
|
12
15
|
sanitized_type_declaration = TypeDeclarations.remove_sensitive_types(declaration)
|
13
16
|
|
17
|
+
# We want to make sure that any types that change due to having sensitive types
|
18
|
+
# has a corresponding registered type in the command registry domain if needed
|
19
|
+
# TODO: this all feels so messy and brittle.
|
14
20
|
Domain.current.foobara_type_from_declaration(sanitized_type_declaration)
|
15
21
|
end
|
16
22
|
end
|
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.92
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|