post-for-me 0.1.0.pre.alpha.9 → 0.1.0.pre.alpha.11

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +1 -1
  4. data/lib/post_for_me/client.rb +4 -0
  5. data/lib/post_for_me/internal/transport/base_client.rb +7 -1
  6. data/lib/post_for_me/internal/transport/pooled_net_requester.rb +38 -26
  7. data/lib/post_for_me/internal/util.rb +12 -7
  8. data/lib/post_for_me/models/platform_post.rb +843 -0
  9. data/lib/post_for_me/models/social_account.rb +9 -1
  10. data/lib/post_for_me/models/social_account_create_auth_url_params.rb +245 -9
  11. data/lib/post_for_me/models/social_account_disconnect_response.rb +9 -1
  12. data/lib/post_for_me/models/social_account_feed_list_params.rb +81 -0
  13. data/lib/post_for_me/models/social_account_feed_list_response.rb +58 -0
  14. data/lib/post_for_me/models.rb +4 -0
  15. data/lib/post_for_me/resources/social_account_feeds.rb +51 -0
  16. data/lib/post_for_me/resources/social_accounts.rb +8 -1
  17. data/lib/post_for_me/version.rb +1 -1
  18. data/lib/post_for_me.rb +6 -0
  19. data/manifest.yaml +2 -0
  20. data/rbi/post_for_me/client.rbi +3 -0
  21. data/rbi/post_for_me/internal/transport/base_client.rbi +5 -0
  22. data/rbi/post_for_me/internal/transport/pooled_net_requester.rbi +6 -2
  23. data/rbi/post_for_me/internal/type/base_model.rbi +8 -4
  24. data/rbi/post_for_me/models/platform_post.rbi +1287 -0
  25. data/rbi/post_for_me/models/social_account.rbi +8 -0
  26. data/rbi/post_for_me/models/social_account_create_auth_url_params.rbi +545 -15
  27. data/rbi/post_for_me/models/social_account_disconnect_response.rbi +8 -0
  28. data/rbi/post_for_me/models/social_account_feed_list_params.rbi +157 -0
  29. data/rbi/post_for_me/models/social_account_feed_list_response.rbi +110 -0
  30. data/rbi/post_for_me/models.rbi +4 -0
  31. data/rbi/post_for_me/resources/social_account_feeds.rbi +51 -0
  32. data/rbi/post_for_me/resources/social_accounts.rbi +13 -0
  33. data/sig/post_for_me/client.rbs +2 -0
  34. data/sig/post_for_me/internal/transport/base_client.rbs +2 -0
  35. data/sig/post_for_me/internal/transport/pooled_net_requester.rbs +4 -1
  36. data/sig/post_for_me/models/platform_post.rbs +660 -0
  37. data/sig/post_for_me/models/social_account.rbs +5 -0
  38. data/sig/post_for_me/models/social_account_create_auth_url_params.rbs +193 -10
  39. data/sig/post_for_me/models/social_account_disconnect_response.rbs +5 -0
  40. data/sig/post_for_me/models/social_account_feed_list_params.rbs +75 -0
  41. data/sig/post_for_me/models/social_account_feed_list_response.rbs +54 -0
  42. data/sig/post_for_me/models.rbs +4 -0
  43. data/sig/post_for_me/resources/social_account_feeds.rbs +18 -0
  44. data/sig/post_for_me/resources/social_accounts.rbs +2 -0
  45. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01ccb7d44dae77373838e7b5fe9d286727f29d5b0cb28c147c4d5f2db24f8755
4
- data.tar.gz: 80cf5a0f6c198eb315344dfeec272c8987552d5ec63ac8054b10b6c99787d577
3
+ metadata.gz: 50c053e497dbc73d9161d2a2908702e98b892372b9a9c3e69244c78342bcaaa9
4
+ data.tar.gz: 47a5a0e272cb715aa1c182d0a9a9074e5fd2a4311a48806707b7c8a67e8d820d
5
5
  SHA512:
6
- metadata.gz: 3040c94c71317b8e81ec5b45fd1b06ed7214b291b158d9ae292d229ce1ad7404b359c6424294702923d4d2edec71dbe5c14542e4c5ae101f189ef07f2dd730ef
7
- data.tar.gz: a294fa51eff7716dd53392b2defcc295b559c5fddbc3d857f4274d6bcfd52189b105c8d0e247c25820e601670f76ef5c8ab319c423ce777eebf74e1dc69aa14a
6
+ metadata.gz: 4b67f480f3490ae82b4e41034ec76cd05359e8e4ebb247403fe9f32fb3e7c064e1fe06a9770f9c5e34e1eff13f33ce261c057d2667e65146b79bec6fffa7246e
7
+ data.tar.gz: 9333829a49cfacf9c9afcde7ab276185f2698c471dd11b20c1f2f4063e9a32564ca0b990ecf9a323e7d81e848a3193d935fed4684219f50d391ca282281e7765
data/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-alpha.11 (2025-12-30)
4
+
5
+ Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.1.0-alpha.10...v0.1.0-alpha.11)
6
+
7
+ ### Features
8
+
9
+ * **api:** Adding account feed endpoint ([7ce9691](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/7ce9691b9e4e111c934bed1c09d9ccbfbc4b7c9d))
10
+ * **api:** api update ([8a5f7ea](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/8a5f7ea61dc9b9484e9f6c380f375564a9800ead))
11
+ * **api:** api update ([64ca219](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/64ca219193b85a3f605c9bd705d2eb3cc7ac4433))
12
+ * **api:** api update ([6ebb7cc](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/6ebb7cc2b9c3bf0938e7b985a3ff1d5d0f73a092))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * calling `break` out of streams should be instantaneous ([14f7017](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/14f70172ad4f58f195c95315c1634c41cb87c00f))
18
+ * issue where json.parse errors when receiving HTTP 204 with nobody ([fdc1690](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/fdc16902862fec1eb612d9a9f82d9c4f4acd3a6e))
19
+
20
+
21
+ ### Chores
22
+
23
+ * explicitly require "base64" gem ([ca97f9c](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/ca97f9c65134f8532190e9daeaba12db30171971))
24
+
25
+ ## 0.1.0-alpha.10 (2025-11-05)
26
+
27
+ Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.1.0-alpha.9...v0.1.0-alpha.10)
28
+
29
+ ### Features
30
+
31
+ * **api:** api update ([129bf08](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/129bf0849de95a151f9fb756f8ae18feee7ca85b))
32
+ * handle thread interrupts in the core HTTP client ([67a9096](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/67a9096a8cdf6200f708a3f58063405bceb7f7ca))
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * absolutely qualified uris should always override the default ([2f8e594](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/2f8e594d99b3c79d12b6e6dcb50d1928df5af7c0))
38
+ * better thread safety via early initializing SSL store during HTTP client creation ([b9e0151](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/b9e01515a5ff7e201462dded310b312800a0276d))
39
+ * should not reuse buffers for `IO.copy_stream` interop ([4a8bedd](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/4a8bedda953dabf110a699a183b62d338713b44f))
40
+
41
+
42
+ ### Chores
43
+
44
+ * bump dependency version and update sorbet types ([936adc6](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/936adc671f5a30e84245daa790743dd9183b0a17))
45
+ * ignore linter error for tests having large collections ([8b60378](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/8b60378131cc5ff32c7dc2e96aa3d7db84280d6b))
46
+
3
47
  ## 0.1.0-alpha.9 (2025-10-03)
4
48
 
5
49
  Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.1.0-alpha.8...v0.1.0-alpha.9)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "post-for-me", "~> 0.1.0.pre.alpha.9"
20
+ gem "post-for-me", "~> 0.1.0.pre.alpha.11"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -30,6 +30,9 @@ module PostForMe
30
30
  # @return [PostForMe::Resources::SocialAccounts]
31
31
  attr_reader :social_accounts
32
32
 
33
+ # @return [PostForMe::Resources::SocialAccountFeeds]
34
+ attr_reader :social_account_feeds
35
+
33
36
  # @api private
34
37
  #
35
38
  # @return [Hash{String=>String}]
@@ -81,6 +84,7 @@ module PostForMe
81
84
  @social_posts = PostForMe::Resources::SocialPosts.new(client: self)
82
85
  @social_post_results = PostForMe::Resources::SocialPostResults.new(client: self)
83
86
  @social_accounts = PostForMe::Resources::SocialAccounts.new(client: self)
87
+ @social_account_feeds = PostForMe::Resources::SocialAccountFeeds.new(client: self)
84
88
  end
85
89
  end
86
90
  end
@@ -201,7 +201,8 @@ module PostForMe
201
201
  self.class::PLATFORM_HEADERS,
202
202
  {
203
203
  "accept" => "application/json",
204
- "content-type" => "application/json"
204
+ "content-type" => "application/json",
205
+ "user-agent" => user_agent
205
206
  },
206
207
  headers
207
208
  )
@@ -219,6 +220,11 @@ module PostForMe
219
220
  # @return [Hash{String=>String}]
220
221
  private def auth_headers = {}
221
222
 
223
+ # @api private
224
+ #
225
+ # @return [String]
226
+ private def user_agent = "#{self.class.name}/Ruby #{PostForMe::VERSION}"
227
+
222
228
  # @api private
223
229
  #
224
230
  # @return [String]
@@ -16,10 +16,11 @@ module PostForMe
16
16
  class << self
17
17
  # @api private
18
18
  #
19
+ # @param cert_store [OpenSSL::X509::Store]
19
20
  # @param url [URI::Generic]
20
21
  #
21
22
  # @return [Net::HTTP]
22
- def connect(url)
23
+ def connect(cert_store:, url:)
23
24
  port =
24
25
  case [url.port, url.scheme]
25
26
  in [Integer, _]
@@ -33,6 +34,8 @@ module PostForMe
33
34
  Net::HTTP.new(url.host, port).tap do
34
35
  _1.use_ssl = %w[https wss].include?(url.scheme)
35
36
  _1.max_retries = 0
37
+
38
+ (_1.cert_store = cert_store) if _1.use_ssl?
36
39
  end
37
40
  end
38
41
 
@@ -102,7 +105,7 @@ module PostForMe
102
105
  pool =
103
106
  @mutex.synchronize do
104
107
  @pools[origin] ||= ConnectionPool.new(size: @size) do
105
- self.class.connect(url)
108
+ self.class.connect(cert_store: @cert_store, url: url)
106
109
  end
107
110
  end
108
111
 
@@ -128,40 +131,50 @@ module PostForMe
128
131
  url, deadline = request.fetch_values(:url, :deadline)
129
132
 
130
133
  req = nil
131
- eof = false
132
134
  finished = false
133
- closing = nil
134
135
 
135
136
  # rubocop:disable Metrics/BlockLength
136
137
  enum = Enumerator.new do |y|
137
138
  next if finished
138
139
 
139
140
  with_pool(url, deadline: deadline) do |conn|
140
- req, closing = self.class.build_request(request) do
141
- self.class.calibrate_socket_timeout(conn, deadline)
142
- end
143
-
144
- self.class.calibrate_socket_timeout(conn, deadline)
145
- unless conn.started?
146
- conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
147
- conn.start
148
- end
141
+ eof = false
142
+ closing = nil
143
+ ::Thread.handle_interrupt(Object => :never) do
144
+ ::Thread.handle_interrupt(Object => :immediate) do
145
+ req, closing = self.class.build_request(request) do
146
+ self.class.calibrate_socket_timeout(conn, deadline)
147
+ end
149
148
 
150
- self.class.calibrate_socket_timeout(conn, deadline)
151
- conn.request(req) do |rsp|
152
- y << [req, rsp]
153
- break if finished
154
-
155
- rsp.read_body do |bytes|
156
- y << bytes.force_encoding(Encoding::BINARY)
157
- break if finished
149
+ self.class.calibrate_socket_timeout(conn, deadline)
150
+ unless conn.started?
151
+ conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
152
+ conn.start
153
+ end
158
154
 
159
155
  self.class.calibrate_socket_timeout(conn, deadline)
156
+ ::Kernel.catch(:jump) do
157
+ conn.request(req) do |rsp|
158
+ y << [req, rsp]
159
+ ::Kernel.throw(:jump) if finished
160
+
161
+ rsp.read_body do |bytes|
162
+ y << bytes.force_encoding(Encoding::BINARY)
163
+ ::Kernel.throw(:jump) if finished
164
+
165
+ self.class.calibrate_socket_timeout(conn, deadline)
166
+ end
167
+ eof = true
168
+ end
169
+ end
170
+ end
171
+ ensure
172
+ begin
173
+ conn.finish if !eof && conn&.started?
174
+ ensure
175
+ closing&.call
160
176
  end
161
- eof = true
162
177
  end
163
- ensure
164
- conn.finish if !eof && conn&.started?
165
178
  end
166
179
  rescue Timeout::Error
167
180
  raise PostForMe::Errors::APITimeoutError.new(url: url, request: req)
@@ -174,8 +187,6 @@ module PostForMe
174
187
  body = PostForMe::Internal::Util.fused_enum(enum, external: true) do
175
188
  finished = true
176
189
  loop { enum.next }
177
- ensure
178
- closing&.call
179
190
  end
180
191
  [Integer(response.code), response, body]
181
192
  end
@@ -186,6 +197,7 @@ module PostForMe
186
197
  def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
187
198
  @mutex = Mutex.new
188
199
  @size = size
200
+ @cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
189
201
  @pools = {}
190
202
  end
191
203
 
@@ -346,8 +346,9 @@ module PostForMe
346
346
  base_path, base_query = lhs.fetch_values(:path, :query)
347
347
  slashed = base_path.end_with?("/") ? base_path : "#{base_path}/"
348
348
 
349
- parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query)
350
- override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path)
349
+ merged = {**parse_uri(rhs.fetch(:path)), **rhs.except(:path, :query)}
350
+ parsed_path, parsed_query = merged.fetch_values(:path, :query)
351
+ override = URI::Generic.build(**merged.slice(:scheme, :host, :port), path: parsed_path)
351
352
 
352
353
  joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override)
353
354
  query = deep_merge(
@@ -473,10 +474,9 @@ module PostForMe
473
474
  # @return [Enumerable<String>]
474
475
  def writable_enum(&blk)
475
476
  Enumerator.new do |y|
476
- buf = String.new
477
477
  y.define_singleton_method(:write) do
478
- self << buf.replace(_1)
479
- buf.bytesize
478
+ self << _1.dup
479
+ _1.bytesize
480
480
  end
481
481
 
482
482
  blk.call(y)
@@ -657,7 +657,8 @@ module PostForMe
657
657
  def decode_content(headers, stream:, suppress_error: false)
658
658
  case (content_type = headers["content-type"])
659
659
  in PostForMe::Internal::Util::JSON_CONTENT
660
- json = stream.to_a.join
660
+ return nil if (json = stream.to_a.join).empty?
661
+
661
662
  begin
662
663
  JSON.parse(json, symbolize_names: true)
663
664
  rescue JSON::ParserError => e
@@ -667,7 +668,11 @@ module PostForMe
667
668
  in PostForMe::Internal::Util::JSONL_CONTENT
668
669
  lines = decode_lines(stream)
669
670
  chain_fused(lines) do |y|
670
- lines.each { y << JSON.parse(_1, symbolize_names: true) }
671
+ lines.each do
672
+ next if _1.empty?
673
+
674
+ y << JSON.parse(_1, symbolize_names: true)
675
+ end
671
676
  end
672
677
  in %r{^text/event-stream}
673
678
  lines = decode_lines(stream)