foobara 0.0.89 → 0.0.90
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 +4 -0
- data/projects/command/src/transformed_command.rb +41 -1
- data/projects/command_connectors/src/command_connector/request.rb +12 -2
- data/projects/command_connectors/src/command_registry/exposed_command.rb +5 -0
- data/projects/command_connectors/src/request_mutator.rb +24 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aef9e716ddfe89cbe85867f6bb5a0af642b3af7e1dab9fb502116380eb4e44e
|
4
|
+
data.tar.gz: 80f58463fdbc26ee8bdf90cfe56eeca95ecb56dd2d8fb8c4d4014a12d9f98d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12a9d4519ac42c3b159b35260e768b67cfafe7811a83d3027ec7f7e278306a48ae5e4185b5416f94b915d1ea4b6dc4f65c1056b7a5c12c229f00d807436b3188
|
7
|
+
data.tar.gz: 1cb99a0a5e64de8585e578d50845118ffd817abcceafc37d04aeb9b892aebc74c11737560d8adb3656af4ed912dbc27aa3cc762888673114f6018068da1a43cc
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,7 @@ module Foobara
|
|
17
17
|
# On exposed command? On the command registry? On the command connector?
|
18
18
|
# This is the easiest place to implement them but feels awkward.
|
19
19
|
:response_mutators,
|
20
|
+
:request_mutators,
|
20
21
|
:allowed_rule,
|
21
22
|
:requires_authentication,
|
22
23
|
:authenticator
|
@@ -32,6 +33,7 @@ module Foobara
|
|
32
33
|
pre_commit_transformers:,
|
33
34
|
serializers:,
|
34
35
|
response_mutators:,
|
36
|
+
request_mutators:,
|
35
37
|
allowed_rule:,
|
36
38
|
requires_authentication:,
|
37
39
|
authenticator:,
|
@@ -64,6 +66,7 @@ module Foobara
|
|
64
66
|
klass.pre_commit_transformers = Util.array(pre_commit_transformers)
|
65
67
|
klass.serializers = Util.array(serializers)
|
66
68
|
klass.response_mutators = Util.array(response_mutators)
|
69
|
+
klass.request_mutators = Util.array(request_mutators)
|
67
70
|
klass.allowed_rule = allowed_rule
|
68
71
|
klass.requires_authentication = requires_authentication
|
69
72
|
klass.authenticator = authenticator
|
@@ -126,6 +129,18 @@ module Foobara
|
|
126
129
|
@result_type_for_manifest = mutated_result_type
|
127
130
|
end
|
128
131
|
|
132
|
+
def inputs_type_for_manifest
|
133
|
+
return @inputs_type_for_manifest if defined?(@inputs_type_for_manifest)
|
134
|
+
|
135
|
+
mutated_inputs_type = inputs_type
|
136
|
+
|
137
|
+
request_mutators&.each do |mutator|
|
138
|
+
mutated_inputs_type = mutator.instance.inputs_type_from(mutated_inputs_type)
|
139
|
+
end
|
140
|
+
|
141
|
+
@inputs_type_for_manifest = mutated_inputs_type
|
142
|
+
end
|
143
|
+
|
129
144
|
def error_context_type_map
|
130
145
|
@error_context_type_map ||= begin
|
131
146
|
set = {}
|
@@ -226,11 +241,12 @@ module Foobara
|
|
226
241
|
end
|
227
242
|
|
228
243
|
response_mutators = self.response_mutators.map { |t| t.foobara_manifest(to_include:) }
|
244
|
+
request_mutators = self.request_mutators.map { |t| t.foobara_manifest(to_include:) }
|
229
245
|
|
230
246
|
command_class.foobara_manifest(to_include:, remove_sensitive:).merge(
|
231
247
|
Util.remove_blank(
|
232
248
|
types_depended_on: types,
|
233
|
-
inputs_type:
|
249
|
+
inputs_type: inputs_type_for_manifest&.reference_or_declaration_data,
|
234
250
|
result_type: result_type_for_manifest&.reference_or_declaration_data(remove_sensitive:),
|
235
251
|
possible_errors: possible_errors_manifest(to_include:, remove_sensitive:),
|
236
252
|
capture_unknown_error:,
|
@@ -240,6 +256,7 @@ module Foobara
|
|
240
256
|
pre_commit_transformers:,
|
241
257
|
serializers:,
|
242
258
|
response_mutators:,
|
259
|
+
request_mutators:,
|
243
260
|
requires_authentication:,
|
244
261
|
authenticator: authenticator&.manifest
|
245
262
|
)
|
@@ -285,6 +302,29 @@ module Foobara
|
|
285
302
|
end
|
286
303
|
end
|
287
304
|
|
305
|
+
def request_mutator
|
306
|
+
return @request_mutator if defined?(@request_mutator)
|
307
|
+
|
308
|
+
if request_mutators.empty?
|
309
|
+
@request_mutator = nil
|
310
|
+
return
|
311
|
+
end
|
312
|
+
|
313
|
+
@request_mutator = begin
|
314
|
+
transformers = transformers_to_processors(request_mutators, result_type, direction: :to)
|
315
|
+
|
316
|
+
if transformers.size == 1
|
317
|
+
transformers.first
|
318
|
+
else
|
319
|
+
Value::Processor::Pipeline.new(processors: transformers)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def mutate_request(request)
|
325
|
+
request_mutator&.process_value!(request)
|
326
|
+
end
|
327
|
+
|
288
328
|
def result_transformer
|
289
329
|
return @result_transformer if defined?(@result_transformer)
|
290
330
|
|
@@ -4,8 +4,7 @@ module Foobara
|
|
4
4
|
include TruncatedInspect
|
5
5
|
|
6
6
|
# TODO: this feels like a smell of some sort...
|
7
|
-
attr_accessor :
|
8
|
-
:command,
|
7
|
+
attr_accessor :command,
|
9
8
|
:error,
|
10
9
|
:command_connector,
|
11
10
|
:serializers,
|
@@ -13,6 +12,8 @@ module Foobara
|
|
13
12
|
:full_command_name,
|
14
13
|
:action
|
15
14
|
|
15
|
+
attr_reader :command_class
|
16
|
+
|
16
17
|
def initialize(**opts)
|
17
18
|
valid_keys = %i[inputs full_command_name action]
|
18
19
|
|
@@ -29,6 +30,15 @@ module Foobara
|
|
29
30
|
self.full_command_name = opts[:full_command_name] if opts.key?(:full_command_name)
|
30
31
|
end
|
31
32
|
|
33
|
+
def command_class=(klass)
|
34
|
+
@command_class = klass
|
35
|
+
|
36
|
+
# TODO: we really need to revisit these interfaces. Something is wrong.
|
37
|
+
if command_class.respond_to?(:mutate_request)
|
38
|
+
command_class.mutate_request(self)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
def serializer
|
33
43
|
return @serializer if defined?(@serializer)
|
34
44
|
|
@@ -12,6 +12,7 @@ module Foobara
|
|
12
12
|
:errors_transformers,
|
13
13
|
:pre_commit_transformers,
|
14
14
|
:serializers,
|
15
|
+
:request_mutators,
|
15
16
|
:response_mutators,
|
16
17
|
:allowed_rule,
|
17
18
|
:requires_authentication,
|
@@ -29,6 +30,7 @@ module Foobara
|
|
29
30
|
errors_transformers: nil,
|
30
31
|
pre_commit_transformers: nil,
|
31
32
|
response_mutators: nil,
|
33
|
+
request_mutators: nil,
|
32
34
|
serializers: nil,
|
33
35
|
allowed_rule: nil,
|
34
36
|
requires_authentication: nil,
|
@@ -79,6 +81,7 @@ module Foobara
|
|
79
81
|
self.errors_transformers = errors_transformers
|
80
82
|
self.pre_commit_transformers = pre_commit_transformers
|
81
83
|
self.response_mutators = response_mutators
|
84
|
+
self.request_mutators = request_mutators
|
82
85
|
self.serializers = serializers
|
83
86
|
self.allowed_rule = allowed_rule
|
84
87
|
self.requires_authentication = requires_authentication
|
@@ -115,6 +118,7 @@ module Foobara
|
|
115
118
|
errors_transformers,
|
116
119
|
pre_commit_transformers,
|
117
120
|
response_mutators,
|
121
|
+
request_mutators,
|
118
122
|
serializers,
|
119
123
|
allowed_rule,
|
120
124
|
requires_authentication,
|
@@ -135,6 +139,7 @@ module Foobara
|
|
135
139
|
errors_transformers:,
|
136
140
|
pre_commit_transformers:,
|
137
141
|
response_mutators:,
|
142
|
+
request_mutators:,
|
138
143
|
serializers:,
|
139
144
|
allowed_rule:,
|
140
145
|
requires_authentication:,
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Foobara
|
2
|
+
module CommandConnectors
|
3
|
+
class RequestMutator < Foobara::Value::Mutator
|
4
|
+
def inputs_type_declaration_from(_inputs_type)
|
5
|
+
# :nocov:
|
6
|
+
raise "subclass responsibility"
|
7
|
+
# :nocov:
|
8
|
+
end
|
9
|
+
|
10
|
+
def inputs_type_from(inputs_type)
|
11
|
+
declaration = inputs_type_declaration_from(inputs_type)
|
12
|
+
Foobara::Domain.current.foobara_type_from_declaration(declaration)
|
13
|
+
end
|
14
|
+
|
15
|
+
def mutate
|
16
|
+
# :nocov:
|
17
|
+
raise "subclass responsibility"
|
18
|
+
# :nocov:
|
19
|
+
end
|
20
|
+
|
21
|
+
alias request declaration_data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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.90
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- projects/command_connectors/src/command_registry/exposed_command.rb
|
180
180
|
- projects/command_connectors/src/command_registry/exposed_domain.rb
|
181
181
|
- projects/command_connectors/src/command_registry/exposed_organization.rb
|
182
|
+
- projects/command_connectors/src/request_mutator.rb
|
182
183
|
- projects/command_connectors/src/response_mutator.rb
|
183
184
|
- projects/command_connectors/src/serializer.rb
|
184
185
|
- projects/command_connectors/src/serializers/aggregate_serializer.rb
|