basecradle 0.14.0 → 0.14.2
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 +66 -0
- data/README.md +2 -2
- data/lib/basecradle/api_object.rb +12 -2
- data/lib/basecradle/client.rb +5 -5
- data/lib/basecradle/items.rb +3 -1
- data/lib/basecradle/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: e2f24c012adffce3eb5bf812fd4fe41244e33a255f63a7b6c4c751e919d77740
|
|
4
|
+
data.tar.gz: ba6c3c758aa25b0d744c8dcf5362cfa754de9e32f7a6fcdbdad5ed749afe643d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53023dc5e3c3c2cfca97302f7c158859945e526649f986e90b598f73a83ed87ad6d3c5851c014c8302a01c4dbe56be90940f746a931b2103633deaf4595e0f58
|
|
7
|
+
data.tar.gz: 3013c477c9c3e10c0a3a5a7accf7a462f45c006e1d2b204344cd8727201f6cae2056451595cce61509c33b7efdd4f5c78ebfc683990ed53013d631e679d3fe02
|
data/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,70 @@ section**. The newest heading is always the version `lib/basecradle/version.rb`
|
|
|
9
9
|
a release writes its entry and its version in the same PR — and `test/changelog_test.rb`
|
|
10
10
|
fails CI if the two ever disagree.
|
|
11
11
|
|
|
12
|
+
## [0.14.2] - 2026-11-16
|
|
13
|
+
|
|
14
|
+
A patch release with one behavior fix. No verb is added or removed, and no signature
|
|
15
|
+
changes. The one caller it affects passes an `idempotency_key` made only of whitespace:
|
|
16
|
+
that create is now sent without a key and is no longer auto-retried.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **A whitespace-only `idempotency_key` is no key**
|
|
21
|
+
([#292](https://github.com/basecradle/basecradle-ruby/pull/292),
|
|
22
|
+
[#288](https://github.com/basecradle/basecradle-ruby/issues/288)). A key made only of
|
|
23
|
+
whitespace (`" "`, `"\t"`) used to go out as an `Idempotency-Key` header. A client built
|
|
24
|
+
with `max_retries:` would also re-send that create after a lost connection. The platform
|
|
25
|
+
reads a blank header as no key, so it could not deduplicate that create, and a retry
|
|
26
|
+
could post a duplicate. A key that is `nil`, empty, or only spaces, tabs and line breaks
|
|
27
|
+
now counts as no key on `timeline.messages.create`, `timeline.assets.create`,
|
|
28
|
+
`timeline.tasks.create` and `timeline.webhook_endpoints.create`: no header is sent, and
|
|
29
|
+
the create is never auto-retried. Use a fresh UUID per logical create. The Python SDK
|
|
30
|
+
is making the same change
|
|
31
|
+
([basecradle-python#349](https://github.com/basecradle/basecradle-python/issues/349)).
|
|
32
|
+
|
|
33
|
+
## [0.14.1] - 2026-11-16
|
|
34
|
+
|
|
35
|
+
A patch release. It carries one behavior fix brought over from the Python SDK and a
|
|
36
|
+
corrected description of an asset's download link. No method is added or removed, and no
|
|
37
|
+
calling code needs to change.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- **An empty `idempotency_key` sends no header**
|
|
42
|
+
([#260](https://github.com/basecradle/basecradle-ruby/pull/260), mirroring Python
|
|
43
|
+
0.16.0). Passing `idempotency_key: ""` to `timeline.messages.create`,
|
|
44
|
+
`timeline.assets.create`, `timeline.tasks.create` or `timeline.webhook_endpoints.create`
|
|
45
|
+
used to send an empty `Idempotency-Key` header. An empty string now counts as no key,
|
|
46
|
+
the same as `nil`: no header is sent. Retries are unchanged: a create without a key was
|
|
47
|
+
never auto-retried, and an empty key was already treated that way.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **An asset's `file.url` is described as a one-hour link**
|
|
52
|
+
([#266](https://github.com/basecradle/basecradle-ruby/pull/266)). Since 2026-11-06 the
|
|
53
|
+
platform's download link is valid for one hour from the response that carried it, and
|
|
54
|
+
needs no credentials while it is valid. The README's example called it an
|
|
55
|
+
authenticated download URL, and the `BaseCradle::AssetFile` documentation called it a
|
|
56
|
+
dereferenceable one. Both now say what it is: treat the link like a secret, do not store
|
|
57
|
+
it, and read the asset again for a fresh one. The SDK's behavior is unchanged; it returns `url` as the platform sends
|
|
58
|
+
it.
|
|
59
|
+
- **Ruby 4.0 is tested in CI**
|
|
60
|
+
([#280](https://github.com/basecradle/basecradle-ruby/pull/280)). The gemspec already
|
|
61
|
+
allowed it (`>= 3.2`). Every change is now tested on Ruby 3.2, 3.3, 3.4 and 4.0. The
|
|
62
|
+
floor stays at 3.2.
|
|
63
|
+
|
|
64
|
+
### Security
|
|
65
|
+
|
|
66
|
+
- **The release workflow's publish job runs actions pinned to commit SHAs**
|
|
67
|
+
([#285](https://github.com/basecradle/basecradle-ruby/pull/285)). The publish job is
|
|
68
|
+
the one that can push this gem to RubyGems. It used `actions/checkout`,
|
|
69
|
+
`ruby/setup-ruby` and `rubygems/release-gem` by tag or branch, so a change to one of
|
|
70
|
+
those references upstream would have run in it. Each is now pinned to a full commit
|
|
71
|
+
SHA, and 0.14.1 is the first release published that way. The rehearsal job before it
|
|
72
|
+
and the CI jobs still use version tags; that is tracked in
|
|
73
|
+
[#286](https://github.com/basecradle/basecradle-ruby/issues/286). Nothing in the gem
|
|
74
|
+
itself changes.
|
|
75
|
+
|
|
12
76
|
## [0.14.0] - 2026-10-23
|
|
13
77
|
|
|
14
78
|
A parity release. The first full SDK parity audit (basecradle#715) checked every issue
|
|
@@ -730,6 +794,8 @@ the Python SDK's behavior in idiomatic Ruby. Zero runtime dependencies.
|
|
|
730
794
|
- **Quality bars** — a README-as-tested-doc harness (every example runs against a mocked
|
|
731
795
|
API) and a spec drift-guard (CI fails if the live API grows beyond the SDK).
|
|
732
796
|
|
|
797
|
+
[0.14.2]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.2
|
|
798
|
+
[0.14.1]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.1
|
|
733
799
|
[0.14.0]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.0
|
|
734
800
|
[0.13.0]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.13.0
|
|
735
801
|
[0.12.0]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.12.0
|
data/README.md
CHANGED
|
@@ -120,7 +120,7 @@ message = timeline.messages.create(body: "Hello from a peer.")
|
|
|
120
120
|
puts message.content.body
|
|
121
121
|
|
|
122
122
|
asset = timeline.assets.create(file: "./report.pdf", description: "Quarterly report")
|
|
123
|
-
puts asset.content.file.url #
|
|
123
|
+
puts asset.content.file.url # download link: valid for one hour, no credentials needed
|
|
124
124
|
|
|
125
125
|
task = timeline.tasks.create(instructions: "Review the report.", activate_at: Time.utc(2026, 7, 1, 15))
|
|
126
126
|
puts task.content.status # "pending"
|
|
@@ -254,7 +254,7 @@ the same way. What gives the folding up is converting away from the type: both
|
|
|
254
254
|
|
|
255
255
|
## Idempotent creates & safe retries
|
|
256
256
|
|
|
257
|
-
A create can succeed on the server while its response is lost on the wire — retrying it blind would duplicate the record. Pass an `idempotency_key:` (a UUID is ideal; any string works) and the platform stores **at most one record per key**: a resend returns the *original* record — no duplicate message, asset, task activation, or webhook endpoint. All four create methods accept it.
|
|
257
|
+
A create can succeed on the server while its response is lost on the wire — retrying it blind would duplicate the record. Pass an `idempotency_key:` (a UUID is ideal; any non-blank string works — an empty or whitespace-only key counts as no key) and the platform stores **at most one record per key**: a resend returns the *original* record — no duplicate message, asset, task activation, or webhook endpoint. All four create methods accept it.
|
|
258
258
|
|
|
259
259
|
Keys are scoped **per timeline and per author** for all four resources — yours never collide with another peer's, and the same key on two timelines creates two records.
|
|
260
260
|
|
|
@@ -16,11 +16,21 @@ module BaseCradle
|
|
|
16
16
|
data["uuid"] || data.fetch("content")["uuid"]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# A key the platform cannot deduplicate on is no key at all: +nil+, an empty string, or
|
|
20
|
+
# a string of only whitespace — the platform reads the header with Rails' +presence+,
|
|
21
|
+
# which takes a blank value for none. Both places that read a key (the header a create
|
|
22
|
+
# sends, and whether a request may be retried) ask this one question (#288). +scrub+
|
|
23
|
+
# keeps a key with invalid bytes a key, rather than raising out of +strip+.
|
|
24
|
+
def self.blank_idempotency_key?(key)
|
|
25
|
+
key.to_s.scrub.strip.empty?
|
|
26
|
+
end
|
|
27
|
+
|
|
19
28
|
# The per-request headers carrying an optional idempotency key — +nil+ when no key was
|
|
20
29
|
# given (so a create without a key sends no +Idempotency-Key+ header, and is never
|
|
21
|
-
# auto-retried). Shared by the four
|
|
30
|
+
# auto-retried). A blank key is no key, the same as +nil+. Shared by the four
|
|
31
|
+
# content-create methods.
|
|
22
32
|
def self.idempotency_headers(key)
|
|
23
|
-
key
|
|
33
|
+
blank_idempotency_key?(key) ? nil : { "Idempotency-Key" => key }
|
|
24
34
|
end
|
|
25
35
|
|
|
26
36
|
# A read-only, wire-exact view of one API JSON object.
|
data/lib/basecradle/client.rb
CHANGED
|
@@ -76,8 +76,8 @@ module BaseCradle
|
|
|
76
76
|
# off. When set above 0, only requests that are safe to re-send are retried: any +GET+
|
|
77
77
|
# (reads change nothing) and any create carrying an +idempotency_key+ (the platform
|
|
78
78
|
# dedupes keyed creates, so a resend can't duplicate the record). An unkeyed +POST+ is
|
|
79
|
-
# never retried, whatever this is set to
|
|
80
|
-
# RETRY_MAX_DELAY seconds.
|
|
79
|
+
# never retried, whatever this is set to — and a blank key (empty, or only whitespace)
|
|
80
|
+
# is no key. Retries back off exponentially, capped at RETRY_MAX_DELAY seconds.
|
|
81
81
|
def initialize(token = nil, base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT,
|
|
82
82
|
max_retries: DEFAULT_MAX_RETRIES)
|
|
83
83
|
resolved = token || ENV.fetch("BASECRADLE_TOKEN", nil)
|
|
@@ -323,12 +323,12 @@ module BaseCradle
|
|
|
323
323
|
|
|
324
324
|
# A request is safe to auto-retry only when re-sending it can't create a duplicate: a
|
|
325
325
|
# +GET+ (reads change nothing), or any request carrying an +Idempotency-Key+ (the
|
|
326
|
-
# platform dedupes keyed creates). An unkeyed write is never retried
|
|
326
|
+
# platform dedupes keyed creates). An unkeyed write is never retried, and a blank key
|
|
327
|
+
# (empty or only whitespace) is no key: the platform cannot dedupe on it.
|
|
327
328
|
def retryable?(method, http_request)
|
|
328
329
|
return true if method.to_s.upcase == "GET"
|
|
329
330
|
|
|
330
|
-
|
|
331
|
-
!(key.nil? || key.empty?)
|
|
331
|
+
!BaseCradle.blank_idempotency_key?(http_request["Idempotency-Key"])
|
|
332
332
|
end
|
|
333
333
|
|
|
334
334
|
# Build and send an authenticated request; returns the raw Net::HTTPResponse, whatever
|
data/lib/basecradle/items.rb
CHANGED
|
@@ -36,7 +36,9 @@ module BaseCradle
|
|
|
36
36
|
attribute :content, wrap: MessageContent
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
# An asset's attached file: metadata plus a
|
|
39
|
+
# An asset's attached file: metadata plus a download link. The link (+url+) is valid for
|
|
40
|
+
# one hour from the response that carried it and needs no credentials while it is valid,
|
|
41
|
+
# so treat it like a secret, do not store it, and read the asset again for a fresh one.
|
|
40
42
|
class AssetFile < ApiObject
|
|
41
43
|
attribute :filename
|
|
42
44
|
attribute :byte_size
|
data/lib/basecradle/version.rb
CHANGED