hephaestus 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,8 @@
4
4
  class ApplicationController < ActionController::Base
5
5
  include ActionController::MimeResponds
6
6
 
7
+ include Hephaestus::Responses
8
+
7
9
  rescue_from ActionController::UnknownFormat, with: :not_acceptable
8
10
 
9
11
  before_action :set_request_span_context
@@ -16,105 +18,4 @@ class ApplicationController < ActionController::Base
16
18
  OpenTelemetry::SemanticConventions::Trace::HTTP_RESPONSE_CONTENT_LENGTH => response.headers["content-length"] || 0,
17
19
  })
18
20
  end
19
-
20
- def no_content
21
- head(:no_content)
22
- end
23
-
24
- def okay
25
- render(
26
- json: {
27
- message: "OK",
28
- }.to_json,
29
- status: :ok,
30
- )
31
- end
32
-
33
- def created
34
- render(
35
- json: {
36
- message: "Created",
37
- }.to_json,
38
- status: :created,
39
- )
40
- end
41
-
42
- def bad_request
43
- render(
44
- json: {
45
- errors: [
46
- {
47
- message: "Bad Request",
48
- },
49
- ],
50
- }.to_json,
51
- status: :bad_request,
52
- )
53
- end
54
-
55
- def forbidden
56
- render(
57
- json: {
58
- errors: [
59
- {
60
- message: "Forbidden",
61
- },
62
- ],
63
- }.to_json,
64
- status: :forbidden,
65
- )
66
- end
67
-
68
- def not_acceptable
69
- render(
70
- json: ::ErrorSerializer.format("Not Acceptable").to_json,
71
- status: :not_acceptable,
72
- )
73
- end
74
-
75
- def not_found
76
- render(
77
- json: ::ErrorSerializer.format("Not Found").to_json,
78
- status: :not_found,
79
- )
80
- end
81
-
82
- def service_unavailable(msg)
83
- render(
84
- json: {
85
- errors: [
86
- {
87
- message: "Service Unavailable: #{msg}",
88
- },
89
- ],
90
- }.to_json,
91
- status: :service_unavailable,
92
- )
93
- end
94
-
95
- def bad_gateway
96
- render(
97
- json: {
98
- errors: [
99
- {
100
- message: "Bad Gateway",
101
- },
102
- ],
103
- }.to_json,
104
- status: :bad_gateway,
105
- )
106
- end
107
-
108
- def internal_server_error
109
- render(
110
- json: {
111
- errors: [
112
- {
113
- message: "Internal Server Error",
114
- },
115
- ],
116
- }.to_json,
117
- status: :internal_server_error,
118
- )
119
- end
120
21
  end
@@ -16,7 +16,7 @@ class UpdateYettoJob < ApplicationJob
16
16
 
17
17
  case type
18
18
  when "update_plug_installation"
19
- YettoService.update_installation(plug_installation_id, params)
19
+ YettoService.update_plug_installation(plug_installation_id, params)
20
20
  when "create_message_reply"
21
21
  YettoService.create_message_reply(message_id, plug_installation_id, params)
22
22
  when "add_message_metadata"
@@ -29,16 +29,16 @@ module PlugApp
29
29
 
30
30
  case validated_request.error
31
31
  when OpenapiFirst::Schema::ValidationError
32
- error_arr = format_arr(validated_request.error.errors.map(&:error))
32
+ error_arr = format_arr(validated_request.error.errors.map(&:message))
33
33
  Rails.logger.error(error_arr) if print_user_api_errors?
34
34
  [PlugApp::HTTP::BAD_REQUEST_I, { "Content-Type" => "application/json" }, [error_arr]]
35
35
  else
36
- case validated_request.error.error_type
36
+ case validated_request.error.type
37
37
  when :not_found
38
38
  [PlugApp::HTTP::NOT_FOUND_I, { "Content-Type" => "application/json" }, [format_str("Not Found")]]
39
39
  else
40
40
  error_message = if validated_request.error.errors.present?
41
- format_arr(validated_request.error.errors.map(&:error))
41
+ format_arr(validated_request.error.errors.map(&:message))
42
42
  else
43
43
  format_str(validated_request.error.message)
44
44
  end
@@ -25,7 +25,7 @@ class YettoService
25
25
  yetto_client.with_headers("Authorization" => "Bearer #{token}").get("#{YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
26
26
  end
27
27
 
28
- def update_installation(plug_installation_id, params)
28
+ def update_plug_installation(plug_installation_id, params)
29
29
  plug_installation = {}
30
30
  plug_installation[:settings] = params.fetch(:settings, {})
31
31
  plug_installation[:credentials] = params.fetch(:credentials, {})
@@ -34,7 +34,7 @@ class YettoService
34
34
  yetto_client.with_headers("Authorization" => "Bearer #{token}").patch("#{YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}", json: plug_installation)
35
35
  end
36
36
 
37
- def update_message(message_id, plug_installation_id, params)
37
+ def update_message(plug_installation_id, message_id, params)
38
38
  payload = params[:payload]
39
39
  token = perform_token_exchange(plug_installation_id)
40
40
 
@@ -19,4 +19,4 @@ elsif options[:parse_string].present?
19
19
  end
20
20
 
21
21
  puts "Parsing `#{body}` into HMAC"
22
- puts OpenSSL::HMAC.hexdigest(Authable::SHA256_DIGEST, SIGNING_SECRET, body)
22
+ puts OpenSSL::HMAC.hexdigest(Hephaestus::ValidatesFromYetto::SHA256_DIGEST, SIGNING_SECRET, body)
@@ -9,7 +9,7 @@ class UpdateYettoJobTest < ActiveJob::TestCase
9
9
  def setup
10
10
  super
11
11
 
12
- @update_installation_body = {
12
+ @update_plug_installation_body = {
13
13
  credentials: {},
14
14
  settings: {},
15
15
  }
@@ -4,7 +4,7 @@
4
4
  module Webmocks
5
5
  module YettoWebmock
6
6
  def yetto_auth_header(payload, signing_secret = "super-secret")
7
- "sha256=#{OpenSSL::HMAC.hexdigest(Authable::SHA256_DIGEST, signing_secret, payload.to_json)}"
7
+ "sha256=#{OpenSSL::HMAC.hexdigest(Hephaestus::ValidatesFromYetto::SHA256_DIGEST, signing_secret, payload.to_json)}"
8
8
  end
9
9
 
10
10
  def assert_requested_post_access_token(plug_installation_id)
@@ -58,13 +58,13 @@ module Webmocks
58
58
  )
59
59
  end
60
60
 
61
- def assert_requested_update_installation(plug_installation_id)
61
+ def assert_requested_update_plug_installation(plug_installation_id)
62
62
  assert_requested_post_access_token(plug_installation_id)
63
63
 
64
64
  assert_requested(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
65
65
  end
66
66
 
67
- def stub_update_installation(plug_installation_id, params, response: {}, status: 200)
67
+ def stub_update_plug_installation(plug_installation_id, params, response: {}, status: 200)
68
68
  stub_post_access_token(plug_installation_id)
69
69
 
70
70
  stub_request(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
@@ -98,12 +98,12 @@ module Webmocks
98
98
  # )
99
99
  end
100
100
 
101
- def assert_requested_update_message_metadata(plug_installation_id, message_id)
101
+ def assert_requested_update_message(plug_installation_id, message_id)
102
102
  assert_requested_post_access_token(plug_installation_id)
103
103
  assert_requested(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}")
104
104
  end
105
105
 
106
- def stub_update_message_metadata(plug_installation_id, message_id, payload)
106
+ def stub_update_message(plug_installation_id, message_id, payload)
107
107
  stub_post_access_token(plug_installation_id)
108
108
  stub_request(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}")
109
109
  .with(
metadata CHANGED
@@ -1,15 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hephaestus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-05 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bootsnap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ force_ruby_platform: false
13
28
  - !ruby/object:Gem::Dependency
14
29
  name: bundler
15
30
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +39,141 @@ dependencies:
24
39
  - - "~>"
25
40
  - !ruby/object:Gem::Version
26
41
  version: '2.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: ferrum
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.15'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.15'
56
+ force_ruby_platform: false
57
+ - !ruby/object:Gem::Dependency
58
+ name: hiredis
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.6'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.6'
71
+ force_ruby_platform: false
72
+ - !ruby/object:Gem::Dependency
73
+ name: httpsensible
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '0.3'
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '0.3'
86
+ force_ruby_platform: false
87
+ - !ruby/object:Gem::Dependency
88
+ name: jbuilder
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '2.12'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '2.12'
101
+ force_ruby_platform: false
102
+ - !ruby/object:Gem::Dependency
103
+ name: jwt
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '2.8'
109
+ type: :runtime
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '2.8'
116
+ force_ruby_platform: false
117
+ - !ruby/object:Gem::Dependency
118
+ name: litestream
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '0.12'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.12'
131
+ force_ruby_platform: false
132
+ - !ruby/object:Gem::Dependency
133
+ name: lograge
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.14'
139
+ type: :runtime
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.14'
146
+ force_ruby_platform: false
147
+ - !ruby/object:Gem::Dependency
148
+ name: mission_control-jobs
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.5'
154
+ type: :runtime
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '0.5'
161
+ force_ruby_platform: false
162
+ - !ruby/object:Gem::Dependency
163
+ name: openapi_first
164
+ requirement: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - "~>"
167
+ - !ruby/object:Gem::Version
168
+ version: '2.0'
169
+ type: :runtime
170
+ prerelease: false
171
+ version_requirements: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: '2.0'
176
+ force_ruby_platform: false
27
177
  - !ruby/object:Gem::Dependency
28
178
  name: parser
29
179
  requirement: !ruby/object:Gem::Requirement
@@ -43,16 +193,16 @@ dependencies:
43
193
  name: rails
44
194
  requirement: !ruby/object:Gem::Requirement
45
195
  requirements:
46
- - - "~>"
196
+ - - ">="
47
197
  - !ruby/object:Gem::Version
48
- version: '7.0'
198
+ version: '8.0'
49
199
  type: :runtime
50
200
  prerelease: false
51
201
  version_requirements: !ruby/object:Gem::Requirement
52
202
  requirements:
53
- - - "~>"
203
+ - - ">="
54
204
  - !ruby/object:Gem::Version
55
- version: '7.0'
205
+ version: '8.0'
56
206
  force_ruby_platform: false
57
207
  - !ruby/object:Gem::Dependency
58
208
  name: rainbow
@@ -70,33 +220,184 @@ dependencies:
70
220
  version: '3.0'
71
221
  force_ruby_platform: false
72
222
  - !ruby/object:Gem::Dependency
73
- name: minitest
223
+ name: redis
74
224
  requirement: !ruby/object:Gem::Requirement
75
225
  requirements:
76
226
  - - "~>"
77
227
  - !ruby/object:Gem::Version
78
- version: '5.6'
79
- type: :development
228
+ version: '5.2'
229
+ type: :runtime
80
230
  prerelease: false
81
231
  version_requirements: !ruby/object:Gem::Requirement
82
232
  requirements:
83
233
  - - "~>"
84
234
  - !ruby/object:Gem::Version
85
- version: '5.6'
235
+ version: '5.2'
236
+ force_ruby_platform: false
237
+ - !ruby/object:Gem::Dependency
238
+ name: retriable
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '3.1'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '3.1'
251
+ force_ruby_platform: false
252
+ - !ruby/object:Gem::Dependency
253
+ name: sidekiq
254
+ requirement: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - "~>"
257
+ - !ruby/object:Gem::Version
258
+ version: '7.2'
259
+ type: :runtime
260
+ prerelease: false
261
+ version_requirements: !ruby/object:Gem::Requirement
262
+ requirements:
263
+ - - "~>"
264
+ - !ruby/object:Gem::Version
265
+ version: '7.2'
266
+ force_ruby_platform: false
267
+ - !ruby/object:Gem::Dependency
268
+ name: slack_webhook_logger
269
+ requirement: !ruby/object:Gem::Requirement
270
+ requirements:
271
+ - - "~>"
272
+ - !ruby/object:Gem::Version
273
+ version: '0.6'
274
+ type: :runtime
275
+ prerelease: false
276
+ version_requirements: !ruby/object:Gem::Requirement
277
+ requirements:
278
+ - - "~>"
279
+ - !ruby/object:Gem::Version
280
+ version: '0.6'
281
+ force_ruby_platform: false
282
+ - !ruby/object:Gem::Dependency
283
+ name: solid_queue
284
+ requirement: !ruby/object:Gem::Requirement
285
+ requirements:
286
+ - - "~>"
287
+ - !ruby/object:Gem::Version
288
+ version: '1.0'
289
+ type: :runtime
290
+ prerelease: false
291
+ version_requirements: !ruby/object:Gem::Requirement
292
+ requirements:
293
+ - - "~>"
294
+ - !ruby/object:Gem::Version
295
+ version: '1.0'
296
+ force_ruby_platform: false
297
+ - !ruby/object:Gem::Dependency
298
+ name: sqlite3
299
+ requirement: !ruby/object:Gem::Requirement
300
+ requirements:
301
+ - - "~>"
302
+ - !ruby/object:Gem::Version
303
+ version: '2.0'
304
+ type: :runtime
305
+ prerelease: false
306
+ version_requirements: !ruby/object:Gem::Requirement
307
+ requirements:
308
+ - - "~>"
309
+ - !ruby/object:Gem::Version
310
+ version: '2.0'
311
+ force_ruby_platform: false
86
312
  - !ruby/object:Gem::Dependency
87
- name: minitest-focus
313
+ name: opentelemetry-exporter-otlp
314
+ requirement: !ruby/object:Gem::Requirement
315
+ requirements:
316
+ - - "~>"
317
+ - !ruby/object:Gem::Version
318
+ version: '0.26'
319
+ type: :runtime
320
+ prerelease: false
321
+ version_requirements: !ruby/object:Gem::Requirement
322
+ requirements:
323
+ - - "~>"
324
+ - !ruby/object:Gem::Version
325
+ version: '0.26'
326
+ force_ruby_platform: false
327
+ - !ruby/object:Gem::Dependency
328
+ name: opentelemetry-instrumentation-all
329
+ requirement: !ruby/object:Gem::Requirement
330
+ requirements:
331
+ - - "~>"
332
+ - !ruby/object:Gem::Version
333
+ version: '0.63'
334
+ type: :runtime
335
+ prerelease: false
336
+ version_requirements: !ruby/object:Gem::Requirement
337
+ requirements:
338
+ - - "~>"
339
+ - !ruby/object:Gem::Version
340
+ version: '0.63'
341
+ force_ruby_platform: false
342
+ - !ruby/object:Gem::Dependency
343
+ name: opentelemetry-sdk
344
+ requirement: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '1.4'
349
+ type: :runtime
350
+ prerelease: false
351
+ version_requirements: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '1.4'
356
+ force_ruby_platform: false
357
+ - !ruby/object:Gem::Dependency
358
+ name: opentelemetry-semantic_conventions
359
+ requirement: !ruby/object:Gem::Requirement
360
+ requirements:
361
+ - - "~>"
362
+ - !ruby/object:Gem::Version
363
+ version: '1.10'
364
+ type: :runtime
365
+ prerelease: false
366
+ version_requirements: !ruby/object:Gem::Requirement
367
+ requirements:
368
+ - - "~>"
369
+ - !ruby/object:Gem::Version
370
+ version: '1.10'
371
+ force_ruby_platform: false
372
+ - !ruby/object:Gem::Dependency
373
+ name: propshaft
88
374
  requirement: !ruby/object:Gem::Requirement
89
375
  requirements:
90
376
  - - "~>"
91
377
  - !ruby/object:Gem::Version
92
378
  version: '1.1'
93
- type: :development
379
+ type: :runtime
94
380
  prerelease: false
95
381
  version_requirements: !ruby/object:Gem::Requirement
96
382
  requirements:
97
383
  - - "~>"
98
384
  - !ruby/object:Gem::Version
99
385
  version: '1.1'
386
+ force_ruby_platform: false
387
+ - !ruby/object:Gem::Dependency
388
+ name: dotenv-rails
389
+ requirement: !ruby/object:Gem::Requirement
390
+ requirements:
391
+ - - ">="
392
+ - !ruby/object:Gem::Version
393
+ version: '0'
394
+ type: :development
395
+ prerelease: false
396
+ version_requirements: !ruby/object:Gem::Requirement
397
+ requirements:
398
+ - - ">="
399
+ - !ruby/object:Gem::Version
400
+ version: '0'
100
401
  description: 'Hephaestus is a Rails generator to create plugs for Yetto.
101
402
 
102
403
  '
@@ -113,10 +414,12 @@ files:
113
414
  - LICENSE.txt
114
415
  - README.md
115
416
  - bin/hephaestus
417
+ - lib/Rakefile
116
418
  - lib/hephaestus.rb
117
419
  - lib/hephaestus/actions.rb
118
420
  - lib/hephaestus/actions/strip_comments_action.rb
119
421
  - lib/hephaestus/app_builder.rb
422
+ - lib/hephaestus/engine.rb
120
423
  - lib/hephaestus/exit_on_failure.rb
121
424
  - lib/hephaestus/generators/app_generator.rb
122
425
  - lib/hephaestus/generators/base.rb
@@ -127,7 +430,22 @@ files:
127
430
  - lib/hephaestus/generators/license_generator.rb
128
431
  - lib/hephaestus/generators/rubocop_generator.rb
129
432
  - lib/hephaestus/generators/sorbet_generator.rb
433
+ - lib/hephaestus/http.rb
434
+ - lib/hephaestus/middleware.rb
435
+ - lib/hephaestus/middleware/malformed_request.rb
436
+ - lib/hephaestus/middleware/openapi_validation.rb
437
+ - lib/hephaestus/middleware/tracing_attributes.rb
438
+ - lib/hephaestus/support/hephaestus/api.rb
439
+ - lib/hephaestus/support/hephaestus/webmocks/browser_webmock.rb
440
+ - lib/hephaestus/support/hephaestus/webmocks/slack_webmock.rb
441
+ - lib/hephaestus/support/hephaestus/webmocks/yetto_webmock.rb
442
+ - lib/hephaestus/support/rails.rb
443
+ - lib/hephaestus/test_helper.rb
130
444
  - lib/hephaestus/version.rb
445
+ - lib/tasks/hephaestus_tasks.rake
446
+ - lib/tasks/package.rake
447
+ - lib/tasks/rubocop.rake
448
+ - lib/version.rb
131
449
  - templates/.dockerignore
132
450
  - templates/.env.sample
133
451
  - templates/.github/dependabot.yml