prusalink 0.1.0 → 0.1.1
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 +9 -0
- data/lib/prusalink/client.rb +5 -1
- data/lib/prusalink/exceptions.rb +2 -0
- data/lib/prusalink/files/file.rb +2 -1
- data/lib/prusalink/files/folder.rb +2 -1
- data/lib/prusalink/files.rb +6 -2
- data/lib/prusalink/server_version.rb +14 -0
- data/lib/prusalink/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e56eee0dc3ba4c8a6a4ef23d4ee876a74108a4b9cf6105cbd3227749cbba406d
|
|
4
|
+
data.tar.gz: 625b138bcc66f1a54b1efa22f27fc2e5e686a4ec5b43d63e5feba73adb4b4e2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d003b0cacdc0af494f10b8448f187277760bb9277cae92a083c02a250559a02641985f799732d94f4dd1c2a17541cce02147f425b22a30267b600e54bdbcdaab
|
|
7
|
+
data.tar.gz: 2db605cca6bb2c9c24b6272a01e2b8292b14ce14e93d5087739b1903f050504abe7951f92213e0b5eace8f28ffb73c7414e8ba4e4892702dce33002009d08d3b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-11-15
|
|
4
|
+
|
|
5
|
+
- Fix `Files::File#read_only` and `Files::Folder#read_only`, which were always `nil` on MK4, XL and MINI firmware. It sends `ro` instead of `read_only`
|
|
6
|
+
- Fix `Files.info` reporting `currently_printed: false` on MK4, XL and MINI firmware, which sends a `Currently-Printing` header instead of `Currently-Printed`
|
|
7
|
+
- Fix `Files.upload` raising a Sorbet `TypeError` on MK4, XL and MINI firmware, which answers with the uploaded file's JSON. It returns `true` again
|
|
8
|
+
- Raise `Prusalink::Exceptions::InvalidResponseError` instead of `JSON::ParserError` when the printer answers with invalid JSON, like XL firmware does for a job whose file was deleted
|
|
9
|
+
- Add `ServerVersion#server`, `#nozzle_diameter` and `#hostname`, which MK4, XL and MINI firmware send
|
|
10
|
+
- Add VCR cassettes recorded against a Prusa XL for every read-only endpoint
|
|
11
|
+
|
|
3
12
|
## [0.1.0] - 2026-11-15
|
|
4
13
|
|
|
5
14
|
- Initial release: client with HTTP Digest auth, version, info, status, job, storage, transfer and files resources
|
data/lib/prusalink/client.rb
CHANGED
|
@@ -86,6 +86,7 @@ module Prusalink
|
|
|
86
86
|
# @raise [Exceptions::Error] a subclass matching the HTTP status when the request fails
|
|
87
87
|
# @raise [Exceptions::TimeoutError] if the printer doesn't respond within the configured timeouts
|
|
88
88
|
# @raise [Exceptions::ConnectionError] if the printer can't be reached
|
|
89
|
+
# @raise [Exceptions::InvalidResponseError] if the printer answers with invalid JSON
|
|
89
90
|
sig do
|
|
90
91
|
params(
|
|
91
92
|
path: String,
|
|
@@ -158,12 +159,15 @@ module Prusalink
|
|
|
158
159
|
return response.body.to_s unless parsed.is_a?(Hash)
|
|
159
160
|
|
|
160
161
|
[parsed[:title], parsed[:text]].compact.join(": ").presence || response.body.to_s
|
|
161
|
-
rescue
|
|
162
|
+
rescue Exceptions::InvalidResponseError
|
|
162
163
|
response.body.to_s
|
|
163
164
|
end
|
|
164
165
|
|
|
165
166
|
def parse_json(body)
|
|
166
167
|
transform_keys(JSON.parse(body))
|
|
168
|
+
rescue JSON::ParserError => e
|
|
169
|
+
# Seen on XL firmware: the job's JSON ends with a trailing comma when its file was deleted
|
|
170
|
+
raise Exceptions::InvalidResponseError, "The printer answered with invalid JSON (#{e.message}): #{body}"
|
|
167
171
|
end
|
|
168
172
|
|
|
169
173
|
def transform_keys(obj)
|
data/lib/prusalink/exceptions.rb
CHANGED
|
@@ -28,6 +28,8 @@ module Prusalink
|
|
|
28
28
|
class ServiceUnavailableError < Error; end
|
|
29
29
|
# Any other unexpected HTTP status
|
|
30
30
|
class UnknownError < Error; end
|
|
31
|
+
# The printer answered with a body that isn't valid JSON
|
|
32
|
+
class InvalidResponseError < Error; end
|
|
31
33
|
# The printer could not be reached (connection refused, host unreachable, DNS failure, ...)
|
|
32
34
|
class ConnectionError < Error; end
|
|
33
35
|
# The printer did not open the connection or respond within the configured timeouts
|
data/lib/prusalink/files/file.rb
CHANGED
|
@@ -56,7 +56,8 @@ module Prusalink
|
|
|
56
56
|
|
|
57
57
|
deserialize_config do
|
|
58
58
|
nested :refs, Files::Refs
|
|
59
|
-
|
|
59
|
+
# MK4, XL and MINI firmware send `ro` instead of the OpenAPI spec's `read_only`
|
|
60
|
+
rename type: :file_type, ro: :read_only
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
# Whether the file can be printed (G-code, binary G-code or SL1)
|
|
@@ -50,7 +50,8 @@ module Prusalink
|
|
|
50
50
|
auto_initialize!
|
|
51
51
|
|
|
52
52
|
deserialize_config do
|
|
53
|
-
|
|
53
|
+
# MK4, XL and MINI firmware send `ro` instead of the OpenAPI spec's `read_only`
|
|
54
|
+
rename type: :file_type, ro: :read_only
|
|
54
55
|
transform do |data|
|
|
55
56
|
data[:children] = data[:children].map { |child| Files.build_entry(child) } if data[:children].is_a?(Array)
|
|
56
57
|
end
|
data/lib/prusalink/files.rb
CHANGED
|
@@ -134,7 +134,9 @@ module Prusalink
|
|
|
134
134
|
|
|
135
135
|
{
|
|
136
136
|
read_only: header_true?(headers["read-only"]),
|
|
137
|
-
|
|
137
|
+
# The OpenAPI spec and PrusaLink on a Raspberry Pi send Currently-Printed.
|
|
138
|
+
# MK4, XL and MINI firmware send Currently-Printing.
|
|
139
|
+
currently_printed: header_true?(headers["currently-printed"] || headers["currently-printing"])
|
|
138
140
|
}
|
|
139
141
|
end
|
|
140
142
|
|
|
@@ -166,7 +168,9 @@ module Prusalink
|
|
|
166
168
|
raise ArgumentError, "Can't upload a #{io.class} without a known size. Pass a path, a File or a StringIO"
|
|
167
169
|
end
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
# MK4, XL and MINI firmware answer 201 with the uploaded file's JSON, others answer without a body (true).
|
|
172
|
+
# Either way the upload succeeded, so this returns true rather than the JSON.
|
|
173
|
+
put(path: path, params: io, headers: headers.merge("Content-Length" => T.unsafe(io).size.to_s)).then { true }
|
|
170
174
|
end
|
|
171
175
|
|
|
172
176
|
# RFC 8941 boolean, the format PrusaLink expects in its headers
|
|
@@ -44,6 +44,20 @@ module Prusalink
|
|
|
44
44
|
# @return [Hash] Optional capabilities, e.g. { upload_by_put: true }
|
|
45
45
|
auto_attr :capabilities, type: Hash
|
|
46
46
|
|
|
47
|
+
# The next three fields are sent by MK4, XL and MINI firmware, but aren't in the OpenAPI spec.
|
|
48
|
+
|
|
49
|
+
# @!attribute [r] server
|
|
50
|
+
# @return [String] The PrusaLink server version, e.g. "2.1.2"
|
|
51
|
+
auto_attr :server, type: String
|
|
52
|
+
|
|
53
|
+
# @!attribute [r] nozzle_diameter
|
|
54
|
+
# @return [Float] The nozzle's diameter, in millimeters
|
|
55
|
+
auto_attr :nozzle_diameter, type: Float
|
|
56
|
+
|
|
57
|
+
# @!attribute [r] hostname
|
|
58
|
+
# @return [String] The printer's hostname on the network, e.g. "prusa-xl"
|
|
59
|
+
auto_attr :hostname, type: String
|
|
60
|
+
|
|
47
61
|
# @!attribute [r] extra
|
|
48
62
|
# @return [Hash] Any additional fields returned by the API
|
|
49
63
|
auto_attr :extra, type: Hash
|
data/lib/prusalink/version.rb
CHANGED