foobara-http-command-connector 0.0.25 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88dbdfc89d4069572fddd99686602ba6397997f6c783436dfd95b105a615034b
4
- data.tar.gz: 0cadfc7c58c3d52c7a8fdecd1e2f6bc7ba8fb6f513dd835ed1e93786090aafaf
3
+ metadata.gz: 36ab57af0c0d65f450500790ed68ba268c1bd5862fbaec71cfb83f4a00fc514a
4
+ data.tar.gz: 93cbb5d98e08155a605be8481a3dd9a092d051e4b7d642b0df13af65d9c5f489
5
5
  SHA512:
6
- metadata.gz: a38d412897c87218f0941b0df609f98481766557fa8182766d8ba704b93c2fc15d79bf71104a90e5a2ffcae99c4c845cc4171af19645ffdbdad38bf44bf05232
7
- data.tar.gz: 72c53f3b1fa770643c09a8755818e8b54619ebea9b6a2b2172790d73228f6bb33009b3b19aaafbe4ebcd3f819b944ca7aa82dcbee7d11393f06922991f7c2240
6
+ metadata.gz: '09d292eba68a1d214d65035c8df665b69aadfdfaf9aeb4964d9d9941e4b3aedc35bacf8a86b28ee5691b9578a853e65b7ee32fcfd1937a37063d976c3b87e541'
7
+ data.tar.gz: 8ad52d666aefd12f21bc71f52f7a1639c4d7c63700e18f8c1a9f015f93d42bf1ebf73948f603d90f10afdca204e7f686a92bf99afb19a9368ddde5bec7b06e97
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.1.0] - 2025-08-22
2
+
3
+ - Handle new Foobara 0.1.0 type declarations
4
+
5
+ ## [0.0.26] - 2025-05-03
6
+
7
+ - Deal with CommandConnector interface changes
8
+
1
9
  ## [0.0.25] - 2025-05-01
2
10
 
3
11
  - Add SetInputToProcResult request transformer
@@ -125,18 +125,24 @@ module Foobara
125
125
  html << render_html_list({ element_type: data.element_type }, skip_wrapper: true)
126
126
  html << "</ul>" unless skip_wrapper
127
127
  when Manifest::TypeDeclaration
128
- html << "<ul>" unless skip_wrapper
129
- data.relevant_manifest.each_pair do |key, value|
130
- if key.to_s == "type"
131
- value = root_manifest.lookup_path(key, value)
128
+ manifest = data.relevant_manifest
129
+
130
+ if manifest.is_a?(::Symbol)
131
+ html << foobara_reference_link(data.to_type)
132
+ else
133
+ html << "<ul>" unless skip_wrapper
134
+ data.relevant_manifest.each_pair do |key, value|
135
+ if key.to_s == "type"
136
+ value = root_manifest.lookup_path(key, value)
137
+ end
138
+ html << "<li>#{key}"
139
+ html << "<ul>"
140
+ html << render_html_list(value, skip_wrapper: true)
141
+ html << "</ul>"
142
+ html << "</li>"
132
143
  end
133
- html << "<li>#{key}"
134
- html << "<ul>"
135
- html << render_html_list(value, skip_wrapper: true)
136
- html << "</ul>"
137
- html << "</li>"
144
+ html << "</ul>" unless skip_wrapper
138
145
  end
139
- html << "</ul>" unless skip_wrapper
140
146
  when Manifest::Type, Manifest::Command, Manifest::Error
141
147
  html << foobara_reference_link(data)
142
148
  when Manifest::PossibleError
@@ -31,21 +31,13 @@ module Foobara
31
31
 
32
32
  if result
33
33
  self.object_to_help_with = result
34
+ elsif mode == Namespace::LookupMode::ABSOLUTE
35
+ determine_object_to_help_with(mode: Namespace::LookupMode::GENERAL)
36
+ elsif mode == Namespace::LookupMode::GENERAL
37
+ determine_object_to_help_with(mode: Namespace::LookupMode::RELAXED)
34
38
  else
35
- # TODO: we should look up from the command connector's namespace instead, right?
36
- result = GlobalOrganization.foobara_lookup(arg, mode:)
37
-
38
- if result && root_manifest.contains?(result.foobara_manifest_reference,
39
- result.scoped_category)
40
- self.object_to_help_with = result
41
- elsif mode == Namespace::LookupMode::ABSOLUTE
42
- determine_object_to_help_with(mode: Namespace::LookupMode::GENERAL)
43
- elsif mode == Namespace::LookupMode::GENERAL
44
- determine_object_to_help_with(mode: Namespace::LookupMode::RELAXED)
45
- else
46
- # TODO: add an input error instead for missing record to trigger 404
47
- add_runtime_error(CommandConnector::NotFoundError.for(arg))
48
- end
39
+ # TODO: add an input error instead for missing record to trigger 404
40
+ add_runtime_error(CommandConnector::NotFoundError.for(arg))
49
41
  end
50
42
  else
51
43
  self.object_to_help_with = root_manifest
data/src/http/cookie.rb CHANGED
@@ -4,7 +4,7 @@ module Foobara
4
4
  class Cookie
5
5
  attr_accessor :name, :value, :opts
6
6
 
7
- ALLOWED_OPTIONS = %i[path httponly secure same_site domain expires max_age].freeze
7
+ ALLOWED_OPTIONS = [:path, :httponly, :secure, :same_site, :domain, :expires, :max_age].freeze
8
8
 
9
9
  def initialize(name, value, **opts)
10
10
  invalid_options = opts.keys - ALLOWED_OPTIONS
data/src/http/request.rb CHANGED
@@ -113,14 +113,6 @@ module Foobara
113
113
  path
114
114
  end
115
115
  end
116
-
117
- def set_response_header(name, value)
118
- name = name.to_s
119
- name = name.downcase
120
-
121
- self.response_headers ||= {}
122
- self.response_headers = response_headers.merge(name => value)
123
- end
124
116
  end
125
117
  end
126
118
  end
@@ -24,6 +24,10 @@ module Foobara
24
24
  Domain.current.foobara_type_from_declaration(new_declaration)
25
25
  end
26
26
 
27
+ def applicable?(_request)
28
+ true
29
+ end
30
+
27
31
  def mutate(request)
28
32
  request.inputs[attribute_name] = request.instance_exec(&input_value_proc)
29
33
  end
data/src/http.rb CHANGED
@@ -58,24 +58,28 @@ module Foobara
58
58
  super(*, prefix:, **)
59
59
  end
60
60
 
61
- def request_to_command(request)
61
+ def request_to_command_class(request)
62
62
  if request.method == "OPTIONS"
63
- return Foobara::CommandConnectors::Http::Commands::GetOptions.new(request:)
63
+ Foobara::CommandConnectors::Http::Commands::GetOptions
64
+ else
65
+ super.tap do |command_class|
66
+ if request.action == "help"
67
+ command_class.serializers = [Commands::Help::ResultSerializer]
68
+ end
69
+ end
64
70
  end
71
+ end
65
72
 
66
- command = super
67
-
68
- if request.action == "help"
69
- request.set_response_header("content-type", "text/html")
70
- command.class.serializers = [Commands::Help::ResultSerializer]
73
+ def request_to_command_inputs(request)
74
+ if request.method == "OPTIONS"
75
+ { request: }
76
+ else
77
+ super
71
78
  end
72
-
73
- command
74
79
  end
75
80
 
76
81
  def set_response_status(response)
77
- command = response.command
78
- outcome = command.outcome
82
+ outcome = response.outcome
79
83
 
80
84
  response.status = if outcome.success?
81
85
  200
@@ -124,6 +128,10 @@ module Foobara
124
128
  end
125
129
  end
126
130
 
131
+ if request.action == "help"
132
+ response_headers = (response_headers || {}).merge("content-type" => "text/html")
133
+ end
134
+
127
135
  if response_headers
128
136
  static_headers.merge(response_headers)
129
137
  else
@@ -135,10 +143,10 @@ module Foobara
135
143
 
136
144
  def static_headers
137
145
  @static_headers ||= ENV.each_with_object({}) do |(key, value), headers|
138
- next if %w[
139
- FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
140
- FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS
141
- FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE
146
+ next if [
147
+ "FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS",
148
+ "FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS",
149
+ "FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE"
142
150
  ].include?(key)
143
151
 
144
152
  match = key.match(/\AFOOBARA_HTTP_RESPONSE_HEADER_(.*)\z/)
metadata CHANGED
@@ -1,28 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-http-command-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.88
18
+ version: 0.1.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
- - - "~>"
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.1.1
29
+ - - "<"
24
30
  - !ruby/object:Gem::Version
25
- version: 0.0.88
31
+ version: 2.0.0
26
32
  email:
27
33
  - azimux@gmail.com
28
34
  executables: []
@@ -95,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
97
103
  requirements: []
98
- rubygems_version: 3.6.2
104
+ rubygems_version: 3.6.9
99
105
  specification_version: 4
100
106
  summary: No description. Add one.
101
107
  test_files: []