hephaestus 0.6.1 → 0.6.3

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: b58de861c02e9f029be16c4ffc63a7d328569e00d17b620fe192cbc9c4788579
4
- data.tar.gz: 634c07e912d979106ff8eefc6eaed83c4331321652754edd95f6ee87af2e6706
3
+ metadata.gz: 44ea48d1eb2074031506e9029eb3650657c2af45a4a0dc69d64297bcb3d1ce46
4
+ data.tar.gz: 83098f6cc522540642f8607ddfc98816d47a1f68981a5414572800a3151ecaff
5
5
  SHA512:
6
- metadata.gz: f1517fe22cb5f81eca885f702051a9546aa3088e3cad6d3159190f9673368a601b59cd243505380bd6129cbdcc3ba9e1ddb8e771c90722efabfe51d534793277
7
- data.tar.gz: a3d9dffb9397754e98696bb1c1ca10718026aeb5580a36342298da0e61476e0c78dbf16429a03823cd673fba8bdbdd56121d1b184098dd93195e174eb6a4ba1a
6
+ metadata.gz: 7ff481188d3525a3b232099cd902db74cf2fa29bb368dc4e62fc6b4525bdbe9b978e08666a490fca443bbc76e7cbe73af65894e50d85e51f3ef9d4d3c144c66d
7
+ data.tar.gz: 4fdc8e71109d913965923239ff10b00b185ee1289b34f503c196f25308b7aef8a5bf385b064c6931403b7bbcb1144057a297c0f4573c184fe7dcd200118bef34
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [v0.6.3] - 05-07-2024
2
+ ## What's Changed
3
+ * Changes to support Rack 3 param parsing by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/21
4
+
5
+
6
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.6.2...v0.6.3
7
+ # [v0.6.2] - 19-06-2024
8
+ ## What's Changed
9
+ * Use Ruby test suite by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/18
10
+ * Catch up with plug updates by @balevine in https://github.com/yettoapp/hephaestus/pull/17
11
+
12
+
13
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.6.1...v0.6.2
14
+ ## [v0.6.1] - 12-02-2024
15
+ ## What's Changed
16
+ * Port recent Ruby, TOML, and OpenAPI changes by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/16
17
+
18
+
19
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.6.0...v0.6.1
1
20
  ## [v0.6.0] - 19-12-2023
2
21
  ## What's Changed
3
22
  * Remove switch logic from plugs by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/15
@@ -196,7 +196,7 @@ module Hephaestus
196
196
  strip_blank_lines_between_setter_calls(node.children)
197
197
 
198
198
  node.children.each do |child_node|
199
- send("on_#{child_node.type}", child_node)
199
+ send(:"on_#{child_node.type}", child_node)
200
200
  end
201
201
  end
202
202
 
@@ -164,7 +164,7 @@ module Hephaestus
164
164
 
165
165
  replace_in_files(destination_root, "PlugApp", app_name.underscore.camelcase)
166
166
  replace_in_files(destination_root, "plug-app", app_name.dasherize)
167
- replace_in_files("destination_root}/.github/workflows/test.yml", "plug-app", app_name.dasherize)
167
+ replace_in_files("#{destination_root}/.github/workflows", "plug-app", app_name.dasherize)
168
168
  replace_in_files(destination_root, "PLUG_APP", app_name.underscore.upcase)
169
169
  replace_in_files(destination_root, "plug_app", app_name.underscore)
170
170
 
@@ -29,7 +29,7 @@ module Hephaestus
29
29
  raltie_overload = <<~CONFIG
30
30
 
31
31
  # Load dotenv only in development environment
32
- Dotenv::Railtie.overload if Rails.env.development?
32
+ Dotenv::Rails.overwrite = true if Rails.env.development?
33
33
  CONFIG
34
34
  inject_into_file(
35
35
  "config/application.rb",
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Hephaestus
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.3"
6
6
  RAILS_VERSION = "~> 7.0"
7
7
  RUBY_VERSION = File
8
8
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
@@ -6,9 +6,11 @@ on:
6
6
 
7
7
  jobs:
8
8
  ruby:
9
- uses: yettoapp/actions/.github/workflows/ruby_test_suite.yml@main
9
+ uses: yettoapp/actions/.github/workflows/rails_test_suite.yml@main
10
10
  secrets:
11
11
  gh_token: ${{ secrets.GH_SISYPHUS_YETTO_REPO_TOKEN }}
12
+ with:
13
+ system_tests: false
12
14
 
13
15
  docker:
14
16
  uses: yettoapp/actions/.github/workflows/test_dockerbuild.yml@main
@@ -7,116 +7,123 @@ module BodyParameter
7
7
 
8
8
  sig { returns(String) }
9
9
  def bparam_organization_id
10
- plug_installation_params[:organization][:id]
10
+ plug_installation_params[:yetto][:organization][:id]
11
11
  end
12
12
 
13
13
  sig { returns(String) }
14
14
  def bparam_inbox_id
15
- plug_installation_params[:inbox][:id]
15
+ plug_installation_params[:yetto][:inbox][:id]
16
16
  end
17
17
 
18
18
  sig { returns(String) }
19
19
  def bparam_plug_installation_id
20
- plug_installation_params[:plug_installation][:id]
20
+ plug_installation_params[:yetto][:plug_installation][:id]
21
21
  end
22
22
 
23
23
  sig { returns(String) }
24
24
  def bparam_plug_id
25
- plug_installation_params[:plug][:id]
25
+ plug_installation_params[:yetto][:plug][:id]
26
26
  end
27
27
 
28
28
  sig { returns(T::Hash[Symbol, String]) }
29
29
  def bparam_plug_installation_settings
30
- plug_installation_params[:plug_installation][:settings]
30
+ plug_installation_params[:yetto][:plug_installation][:settings]
31
31
  end
32
32
 
33
33
  sig { returns(T::Hash[Symbol, String]) }
34
34
  def plug_installation_params
35
35
  return {} if params.blank?
36
36
 
37
- plug_installation = params.fetch(:plug_installation, {})
37
+ yetto_params = params.fetch(:yetto, {})
38
+ plug_installation = yetto_params.fetch(:plug_installation, {})
39
+
38
40
  plug_installation_id = plug_installation.fetch(:id, "")
39
41
  settings = plug_installation.fetch(:settings, {}).to_unsafe_hash
40
42
 
41
- organization_id = params.fetch(:organization, {}).fetch(:id, "")
42
- plug_id = params.fetch(:plug, {}).fetch(:id, "")
43
- inbox_id = params.fetch(:inbox, {}).fetch(:id, "")
43
+ organization_id = yetto_params.fetch(:organization, {}).fetch(:id, "")
44
+ plug_id = yetto_params.fetch(:plug, {}).fetch(:id, "")
45
+ inbox_id = yetto_params.fetch(:inbox, {}).fetch(:id, "")
44
46
 
45
47
  {
46
- plug_installation: {
47
- id: plug_installation_id,
48
- settings: settings,
49
- },
50
- organization: {
51
- id: organization_id,
52
- },
53
- plug: {
54
- id: plug_id,
55
- },
56
- inbox: {
57
- id: inbox_id,
48
+ yetto: {
49
+ plug_installation: {
50
+ id: plug_installation_id,
51
+ settings: settings,
52
+ },
53
+ organization: {
54
+ id: organization_id,
55
+ },
56
+ plug: {
57
+ id: plug_id,
58
+ },
59
+ inbox: {
60
+ id: inbox_id,
61
+ },
58
62
  },
59
63
  }
60
64
  end
61
65
 
62
66
  sig { returns(String) }
63
67
  def bparam_message_id
64
- message_params[:message][:id]
68
+ message_params[:yetto][:message][:id]
65
69
  end
66
70
 
67
71
  sig { returns(String) }
68
72
  def bparam_message_text_content
69
- message_params[:message][:text_content]
73
+ message_params[:yetto][:message][:text_content]
70
74
  end
71
75
 
72
76
  sig { returns(String) }
73
77
  def bparam_message_conversation_id
74
- message_params[:message][:conversation][:id]
78
+ message_params[:yetto][:message][:conversation][:id]
75
79
  end
76
80
 
77
81
  sig { returns(String) }
78
82
  def bparam_message_conversation_title
79
- message_params[:message][:conversation][:title]
83
+ message_params[:yetto][:message][:conversation][:title]
80
84
  end
81
85
 
82
86
  sig { returns(String) }
83
87
  def bparam_message_author_name
84
- message_params[:message].fetch(:author, {}).fetch(:name, "Noone")
88
+ message_params[:yetto][:message].fetch(:author, {}).fetch(:name, "Noone")
85
89
  end
86
90
 
87
91
  sig { returns(T::Hash[Symbol, String]) }
88
92
  def bparam_message_metadata
89
- message_params[:message][:metadata]
93
+ message_params[:yetto][:message][:metadata]
90
94
  end
91
95
 
92
96
  sig { returns(T::Hash[Symbol, String]) }
93
97
  def message_params
94
98
  return {} if params.blank?
95
99
 
96
- message = params.fetch(:message, {})
100
+ yetto_params = params.fetch(:yetto, {})
101
+ message = yetto_params.fetch(:message, {})
97
102
  message_id = message.fetch(:id, "")
98
103
  text_content = message.fetch(:text_content, "")
99
104
  conversation = message.fetch(:conversation, {})
100
105
  conversation_id = conversation.fetch(:id, "")
101
106
  title = conversation.fetch(:title, "")
102
- created_by_user = message.fetch(:created_by_user, {})
107
+ created_by_membership = message.fetch(:created_by_membership, {})
103
108
  created_by_plug = message.fetch(:created_by_plug, {})
104
- author = created_by_user.presence || created_by_plug
109
+ author = created_by_membership.fetch(:user) || created_by_plug
105
110
  name = author.fetch(:name, "")
106
111
  metadata = message.fetch(:metadata, {}).to_unsafe_hash
107
112
 
108
113
  {
109
- message: {
110
- id: message_id,
111
- text_content: text_content,
112
- conversation: {
113
- id: conversation_id,
114
- title: title,
115
- },
116
- author: {
117
- name: name,
114
+ yetto: {
115
+ message: {
116
+ id: message_id,
117
+ text_content: text_content,
118
+ conversation: {
119
+ id: conversation_id,
120
+ title: title,
121
+ },
122
+ author: {
123
+ name: name,
124
+ },
125
+ metadata: metadata,
118
126
  },
119
- metadata: metadata,
120
127
  },
121
128
  }
122
129
  end
@@ -14,6 +14,7 @@ module PlugApp
14
14
 
15
15
  HTTP_REQUEST_BODY = "http.request.body"
16
16
  PLUG_APP_PATH_PREFIX = "/app/"
17
+ RACK_REQUEST_BODY = "rack.input"
17
18
 
18
19
  sig { params(app: T.untyped).void }
19
20
  def initialize(app)
@@ -23,24 +24,22 @@ module PlugApp
23
24
 
24
25
  sig { params(env: T.untyped).returns(T.untyped) }
25
26
  def call(env)
26
- request = ActionDispatch::Request.new(env.dup)
27
-
28
27
  OpenTelemetry::Trace.current_span.add_attributes({
29
28
  OpenTelemetry::VERSION => PlugApp::Application::GIT_SHA,
30
29
  OpenTelemetry::SemanticConventions::Trace::HTTP_REQUEST_CONTENT_LENGTH => env["CONTENT_LENGTH"].to_i,
31
- HTTP_REQUEST_BODY => filtered_params(request),
30
+ HTTP_REQUEST_BODY => filtered_params(env),
32
31
  })
33
32
 
34
33
  app.call(env)
35
34
  end
36
35
 
37
- def filtered_params(request)
38
- params = request.params
39
- if request.path.starts_with?(PLUG_APP_PATH_PREFIX)
40
- {}
41
- else
42
- @filterer.filter(params)
43
- end.to_json
36
+ def filtered_params(env)
37
+ body = env[RACK_REQUEST_BODY]&.read
38
+ return "{}" if body.blank? || body == "{}"
39
+
40
+ @filterer.filter(JSON.parse(body)).to_json
41
+ ensure
42
+ env[RACK_REQUEST_BODY]&.try(:rewind)
44
43
  end
45
44
  end
46
45
  end
@@ -1,5 +1,3 @@
1
- version: "3.8"
2
-
3
1
  services:
4
2
  redis-db:
5
3
  image: redis:7-bookworm
@@ -1,5 +1,6 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
+
3
4
  # Be sure to restart your server when you modify this file.
4
5
 
5
6
  # Avoid CORS issues when API is called from the frontend app.
@@ -2,98 +2,77 @@
2
2
  "CreateAppMessage": {
3
3
  "type": "object",
4
4
  "required": [
5
- "plug_installation",
6
- "message",
7
- "inbox"
5
+ "yetto"
8
6
  ],
9
7
  "properties": {
10
- "plug_installation": {
8
+ "yetto": {
11
9
  "type": "object",
12
10
  "required": [
13
- "id",
14
- "settings"
11
+ "plug_installation",
12
+ "message"
15
13
  ],
16
14
  "properties": {
17
- "id": {
18
- "type": "string",
19
- "pattern": "^(?:pli)_[A-Z0-9]{26}$"
20
- },
21
- "settings": {
22
- "type": "object",
23
- "required": [],
24
- "properties": {}
25
- }
26
- }
27
- },
28
- "inbox": {
29
- "type": "object",
30
- "required": [
31
- "id",
32
- "organization"
33
- ],
34
- "properties": {
35
- "id": {
36
- "type": "string",
37
- "pattern": "^(?:ibx)_[A-Z0-9]{26}$"
38
- },
39
- "organization": {
15
+ "plug_installation": {
40
16
  "type": "object",
41
17
  "required": [
42
18
  "id",
43
- "status"
19
+ "settings"
44
20
  ],
45
21
  "properties": {
46
22
  "id": {
47
23
  "type": "string",
48
- "pattern": "^(?:org)_[A-Z0-9]{26}$"
24
+ "pattern": "^(?:pli)_[A-Z0-9]{26}$"
49
25
  },
50
- "status": {
51
- "type": "string"
26
+ "settings": {
27
+ "type": "object",
28
+ "required": [],
29
+ "properties": {}
52
30
  }
53
31
  }
54
- }
55
- }
56
- },
57
- "message": {
58
- "type": "object",
59
- "required": [
60
- "id",
61
- "conversation",
62
- "text_content",
63
- "metadata"
64
- ],
65
- "properties": {
66
- "id": {
67
- "type": "string",
68
- "pattern": "^(?:msg)_[A-Z0-9]{26}$"
69
- },
70
- "text_content": {
71
- "type": "string"
72
- },
73
- "metadata": {
74
- "type": "object"
75
32
  },
76
- "conversation": {
33
+ "message": {
77
34
  "type": "object",
78
35
  "required": [
79
36
  "id",
80
- "title",
37
+ "conversation",
38
+ "text_content",
81
39
  "metadata"
82
40
  ],
83
41
  "properties": {
84
42
  "id": {
85
43
  "type": "string",
86
- "pattern": "^(?:cnv)_[A-Z0-9]{26}$"
44
+ "pattern": "^(?:msg)_[A-Z0-9]{26}$"
87
45
  },
88
- "title": {
46
+ "text_content": {
89
47
  "type": "string"
90
48
  },
91
49
  "metadata": {
92
50
  "type": "object"
51
+ },
52
+ "conversation": {
53
+ "type": "object",
54
+ "required": [
55
+ "id",
56
+ "title",
57
+ "metadata"
58
+ ],
59
+ "properties": {
60
+ "id": {
61
+ "type": "string",
62
+ "pattern": "^(?:cnv)_[A-Z0-9]{26}$"
63
+ },
64
+ "title": {
65
+ "type": "string"
66
+ },
67
+ "metadata": {
68
+ "type": "object"
69
+ }
70
+ }
93
71
  }
94
72
  }
95
73
  }
96
- }
74
+ },
75
+ "additionalProperties": false
97
76
  }
98
77
  },
99
78
  "additionalProperties": false
@@ -101,65 +80,35 @@
101
80
  "ConfigureApp": {
102
81
  "type": "object",
103
82
  "required": [
104
- "plug_installation",
105
- "organization",
106
- "plug",
107
- "inbox"
83
+ "yetto"
108
84
  ],
109
85
  "properties": {
110
- "plug_installation": {
86
+ "yetto": {
111
87
  "type": "object",
112
88
  "required": [
113
- "id",
114
- "settings"
89
+ "plug_installation",
115
90
  ],
116
91
  "properties": {
117
- "id": {
118
- "type": "string",
119
- "pattern": "^(?:pli)_[A-Z0-9]{26}$"
120
- },
121
- "settings": {
92
+ "plug_installation": {
122
93
  "type": "object",
123
- "required": [],
124
- "properties": {}
125
- }
126
- }
127
- },
128
- "organization": {
129
- "type": "object",
130
- "required": [
131
- "id"
132
- ],
133
- "properties": {
134
- "id": {
135
- "type": "string",
136
- "pattern": "^(?:org)_[A-Z0-9]{26}$"
137
- }
138
- }
139
- },
140
- "plug": {
141
- "type": "object",
142
- "required": [
143
- "id"
144
- ],
145
- "properties": {
146
- "id": {
147
- "type": "string",
148
- "pattern": "^(?:plg)_[A-Z0-9]{26}$"
149
- }
150
- }
151
- },
152
- "inbox": {
153
- "type": "object",
154
- "required": [
155
- "id"
156
- ],
157
- "properties": {
158
- "id": {
159
- "type": "string",
160
- "pattern": "^(?:ibx)_[A-Z0-9]{26}$"
94
+ "required": [
95
+ "id",
96
+ "settings"
97
+ ],
98
+ "properties": {
99
+ "id": {
100
+ "type": "string",
101
+ "pattern": "^(?:pli)_[A-Z0-9]{26}$"
102
+ },
103
+ "settings": {
104
+ "type": "object",
105
+ "required": [],
106
+ "properties": {}
107
+ }
108
+ }
161
109
  }
162
- }
110
+ },
111
+ "additionalProperties": false
163
112
  }
164
113
  },
165
114
  "additionalProperties": false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hephaestus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
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-02-12 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  - !ruby/object:Gem::Version
250
250
  version: 3.4.7
251
251
  requirements: []
252
- rubygems_version: 3.5.6
252
+ rubygems_version: 3.5.3
253
253
  signing_key:
254
254
  specification_version: 4
255
255
  summary: Generate a Rails app that can be used to create plugs for Yetto.