foobara 0.0.106 → 0.0.107
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/command_pattern_implementation/concerns/entities.rb +1 -1
- data/projects/command/src/transformed_command.rb +2 -2
- data/projects/command_connectors/src/command_connector/command_connector_error.rb +11 -0
- data/projects/command_connectors/src/command_connector/invalid_context_error.rb +5 -0
- data/projects/command_connectors/src/command_connector/no_command_found_error.rb +5 -0
- data/projects/command_connectors/src/command_connector/no_command_or_type_found_error.rb +7 -0
- data/projects/command_connectors/src/command_connector/no_type_found_error.rb +5 -0
- data/projects/command_connectors/src/command_connector/not_allowed_error.rb +24 -0
- data/projects/command_connectors/src/command_connector/not_found_error.rb +13 -0
- data/projects/command_connectors/src/command_connector/unauthenticated_error.rb +9 -0
- data/projects/command_connectors/src/command_connector/unknown_error.rb +15 -0
- data/projects/command_connectors/src/command_connector.rb +8 -84
- data/projects/entity/src/concerns/queries.rb +1 -1
- data/projects/entity/src/not_found_error.rb +22 -23
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a5a11223a3bc2f8aebf691c6bc8f0d0bdb05930286f9c1e16f2f1ac8f82756
|
4
|
+
data.tar.gz: 07f8edc98723f2297413d12065483d0a80f1b641ca0088fab99434c59cba4d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a75a392d55df8390b3d483b8a1d670d0b466783921fe2808961c18d4587644e82f515734cf49fac1ae9d42c8ed19a084d3562131e70ec9259ea5cdfaee945f1
|
7
|
+
data.tar.gz: 939caca7112b46752613e9427471c1c0dc0d422fd24d571d379973bae3a169f71816cbbffb0df2ff939a213c7bc16ae104c6416d3c0f3003ce96be5a748aca52
|
data/CHANGELOG.md
CHANGED
@@ -581,7 +581,7 @@ module Foobara
|
|
581
581
|
explanation = source || "No explanation."
|
582
582
|
end
|
583
583
|
|
584
|
-
error = CommandConnector::NotAllowedError.
|
584
|
+
error = CommandConnector::NotAllowedError.for(rule_symbol: rule.symbol, explanation:)
|
585
585
|
self.outcome = Outcome.error(error)
|
586
586
|
|
587
587
|
command.state_machine.error!
|
@@ -605,7 +605,7 @@ module Foobara
|
|
605
605
|
rescue => e
|
606
606
|
if capture_unknown_error
|
607
607
|
# TODO: move to superclass?
|
608
|
-
self.outcome = Outcome.error(CommandConnector::UnknownError.
|
608
|
+
self.outcome = Outcome.error(CommandConnector::UnknownError.for(e))
|
609
609
|
else
|
610
610
|
# :nocov:
|
611
611
|
raise
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandConnector
|
3
|
+
class NotAllowedError < CommandConnectorError
|
4
|
+
class << self
|
5
|
+
def for(rule_symbol: nil, explanation: nil)
|
6
|
+
rule_symbol ||= :no_symbol_declared
|
7
|
+
message = "Not allowed"
|
8
|
+
if explanation
|
9
|
+
message += ": #{explanation}"
|
10
|
+
end
|
11
|
+
explanation ||= "No explanation"
|
12
|
+
context = { rule_symbol:, explanation: }
|
13
|
+
|
14
|
+
new(message:, context:)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context do
|
19
|
+
rule_symbol :symbol, :required
|
20
|
+
explanation :string, :required
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "command_connector_error"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
class CommandConnector
|
5
|
+
class NotFoundError < CommandConnectorError
|
6
|
+
context not_found: :string
|
7
|
+
|
8
|
+
def initialize(message: "Not found: #{context[:not_found]}", **)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Foobara
|
2
|
+
class CommandConnector
|
3
|
+
class UnknownError < CommandConnectorError
|
4
|
+
class << self
|
5
|
+
def for(error)
|
6
|
+
new(message: error.message).tap do |unknown_error|
|
7
|
+
unknown_error.error = error
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,84 +2,6 @@ module Foobara
|
|
2
2
|
class CommandConnector
|
3
3
|
class UnexpectedSensitiveTypeInManifestError < StandardError; end
|
4
4
|
|
5
|
-
class CommandConnectorError < Foobara::RuntimeError
|
6
|
-
class << self
|
7
|
-
def context_type_declaration
|
8
|
-
{}
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(message, context: {})
|
13
|
-
super(message:, context:)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class UnknownError < CommandConnectorError
|
18
|
-
attr_accessor :error
|
19
|
-
|
20
|
-
def initialize(error)
|
21
|
-
# TODO: can we just use #cause for this?
|
22
|
-
self.error = error
|
23
|
-
|
24
|
-
super(error.message)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class NotFoundError < CommandConnectorError
|
29
|
-
class << self
|
30
|
-
def context_type_declaration
|
31
|
-
{ not_found: :string }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
attr_accessor :not_found
|
36
|
-
|
37
|
-
def initialize(not_found)
|
38
|
-
self.not_found = not_found
|
39
|
-
|
40
|
-
super(message, context: { not_found: })
|
41
|
-
end
|
42
|
-
|
43
|
-
def message
|
44
|
-
"Not found: #{not_found}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class UnauthenticatedError < CommandConnectorError
|
49
|
-
def initialize
|
50
|
-
super("Unauthenticated")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class NotAllowedError < CommandConnectorError
|
55
|
-
class << self
|
56
|
-
def context_type_declaration
|
57
|
-
{
|
58
|
-
rule_symbol: :symbol,
|
59
|
-
explanation: :string
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
attr_accessor :rule_symbol, :explanation
|
65
|
-
|
66
|
-
def initialize(rule_symbol:, explanation:)
|
67
|
-
self.rule_symbol = rule_symbol || :no_symbol_declared
|
68
|
-
self.explanation = explanation || "No explanation"
|
69
|
-
|
70
|
-
super("Not allowed: #{explanation}", context:)
|
71
|
-
end
|
72
|
-
|
73
|
-
def context
|
74
|
-
{ rule_symbol:, explanation: }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class InvalidContextError < CommandConnectorError; end
|
79
|
-
class NoCommandFoundError < NotFoundError; end
|
80
|
-
class NoTypeFoundError < NotFoundError; end
|
81
|
-
class NoCommandOrTypeFoundError < NotFoundError; end
|
82
|
-
|
83
5
|
class << self
|
84
6
|
def find_builtin_command_class(command_class_name)
|
85
7
|
Util.find_constant_through_class_hierarchy(self, "Commands::#{command_class_name}")
|
@@ -231,7 +153,7 @@ module Foobara
|
|
231
153
|
|
232
154
|
unless transformed_command_class
|
233
155
|
# :nocov:
|
234
|
-
raise NoCommandFoundError
|
156
|
+
raise NoCommandFoundError.new(message: "Could not find command registered for #{full_command_name}")
|
235
157
|
# :nocov:
|
236
158
|
end
|
237
159
|
|
@@ -243,7 +165,9 @@ module Foobara
|
|
243
165
|
|
244
166
|
unless manifestable
|
245
167
|
# :nocov:
|
246
|
-
raise NoCommandOrTypeFoundError
|
168
|
+
raise NoCommandOrTypeFoundError.new(
|
169
|
+
message: "Could not find command or type registered for #{full_command_name}"
|
170
|
+
)
|
247
171
|
# :nocov:
|
248
172
|
end
|
249
173
|
|
@@ -259,7 +183,7 @@ module Foobara
|
|
259
183
|
|
260
184
|
unless transformed_command_class
|
261
185
|
# :nocov:
|
262
|
-
raise NoCommandFoundError
|
186
|
+
raise NoCommandFoundError.new(message: "Could not find command registered for #{full_command_name}")
|
263
187
|
# :nocov:
|
264
188
|
end
|
265
189
|
|
@@ -274,7 +198,7 @@ module Foobara
|
|
274
198
|
|
275
199
|
unless type
|
276
200
|
# :nocov:
|
277
|
-
raise NoTypeFoundError
|
201
|
+
raise NoTypeFoundError.new(message: "Could not find type registered for #{full_command_name}")
|
278
202
|
# :nocov:
|
279
203
|
end
|
280
204
|
|
@@ -323,7 +247,7 @@ module Foobara
|
|
323
247
|
transform_command_class(command_class)
|
324
248
|
else
|
325
249
|
# :nocov:
|
326
|
-
raise InvalidContextError
|
250
|
+
raise InvalidContextError.new(message: "Not sure what to do with #{action}")
|
327
251
|
# :nocov:
|
328
252
|
end
|
329
253
|
|
@@ -466,7 +390,7 @@ module Foobara
|
|
466
390
|
request.command.run
|
467
391
|
rescue => e
|
468
392
|
if capture_unknown_error
|
469
|
-
request.error = CommandConnector::UnknownError.
|
393
|
+
request.error = CommandConnector::UnknownError.for(e)
|
470
394
|
else
|
471
395
|
raise
|
472
396
|
end
|
@@ -31,41 +31,40 @@ module Foobara
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def data_path
|
35
|
-
|
34
|
+
def for(criteria, entity_class: self.entity_class, data_path: self.data_path || "")
|
35
|
+
message = "Could not find #{entity_class} for #{criteria}"
|
36
|
+
context = {
|
37
|
+
entity_class: entity_class.full_entity_name,
|
38
|
+
criteria:,
|
39
|
+
data_path: data_path.to_s
|
40
|
+
}
|
41
|
+
|
42
|
+
new(context:, message:)
|
36
43
|
end
|
37
44
|
|
38
|
-
def
|
39
|
-
|
40
|
-
entity_class: :string, # TODO: we don't have a way to specify an exact value for a type
|
41
|
-
criteria: :duck, # TODO: probably should be integer or string but no union types yet
|
42
|
-
data_path: :string # TODO: we don't have a way to specify an exact value for a type
|
43
|
-
}
|
45
|
+
def data_path
|
46
|
+
nil
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
|
50
|
+
context do
|
51
|
+
entity_class :string # TODO: we don't have a way to specify an exact value for a type
|
52
|
+
criteria :duck # TODO: probably should be integer or string but no union types yet
|
53
|
+
data_path :string # TODO: we don't have a way to specify an exact value for a type
|
54
|
+
end
|
48
55
|
|
49
56
|
foobara_delegate :primary_key_attribute, :full_entity_name, to: :entity_class
|
50
57
|
|
51
|
-
def
|
52
|
-
|
53
|
-
self.entity_class = entity_class
|
54
|
-
self.data_path = data_path || ""
|
55
|
-
|
56
|
-
super(context:, message:)
|
58
|
+
def criteria
|
59
|
+
context[:criteria]
|
57
60
|
end
|
58
61
|
|
59
|
-
def
|
60
|
-
|
61
|
-
entity_class: full_entity_name,
|
62
|
-
criteria:,
|
63
|
-
data_path: data_path.to_s
|
64
|
-
}
|
62
|
+
def data_path
|
63
|
+
context[:data_path]
|
65
64
|
end
|
66
65
|
|
67
|
-
def
|
68
|
-
|
66
|
+
def entity_class
|
67
|
+
context[:entity_class]
|
69
68
|
end
|
70
69
|
end
|
71
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.107
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -183,12 +183,21 @@ files:
|
|
183
183
|
- projects/command_connectors/lib/foobara/command_connectors.rb
|
184
184
|
- projects/command_connectors/src/authenticator.rb
|
185
185
|
- projects/command_connectors/src/command_connector.rb
|
186
|
+
- projects/command_connectors/src/command_connector/command_connector_error.rb
|
186
187
|
- projects/command_connectors/src/command_connector/commands/describe.rb
|
187
188
|
- projects/command_connectors/src/command_connector/commands/list_commands.rb
|
188
189
|
- projects/command_connectors/src/command_connector/commands/ping.rb
|
189
190
|
- projects/command_connectors/src/command_connector/commands/query_git_commit_info.rb
|
191
|
+
- projects/command_connectors/src/command_connector/invalid_context_error.rb
|
192
|
+
- projects/command_connectors/src/command_connector/no_command_found_error.rb
|
193
|
+
- projects/command_connectors/src/command_connector/no_command_or_type_found_error.rb
|
194
|
+
- projects/command_connectors/src/command_connector/no_type_found_error.rb
|
195
|
+
- projects/command_connectors/src/command_connector/not_allowed_error.rb
|
196
|
+
- projects/command_connectors/src/command_connector/not_found_error.rb
|
190
197
|
- projects/command_connectors/src/command_connector/request.rb
|
191
198
|
- projects/command_connectors/src/command_connector/response.rb
|
199
|
+
- projects/command_connectors/src/command_connector/unauthenticated_error.rb
|
200
|
+
- projects/command_connectors/src/command_connector/unknown_error.rb
|
192
201
|
- projects/command_connectors/src/command_registry.rb
|
193
202
|
- projects/command_connectors/src/command_registry/allowed_rule.rb
|
194
203
|
- projects/command_connectors/src/command_registry/exposed_command.rb
|