atlas_rb 1.13.2 → 1.14.0
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/.version +1 -1
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/blob.rb +42 -0
- 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: 683f9aa507f7cfa025781f231f839bdb39bb44f566e074e8ca304200da86e426
|
|
4
|
+
data.tar.gz: e12684f3de4d03e69e1024ab43765a4912f2f550c2ff01e72bc5953da5d55089
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b34332d51540262c758c6e40e1c8eab538b3601e22fdde3639e60897e75b6c0cc9483b8a79eed1165f179f07bc2012ee9fd96d218e5dcf589f1d8c0734bd8ab
|
|
7
|
+
data.tar.gz: b56c2e3c5cadff71fb0ec53765c3160c27d6d695a0458d0e0e8cb09b65aaf7da483d3d436735cda2d41f82b8dc6227a0a3c262c4a2fc9696d39c9247f5c1e139
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.14.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
### Added — `Blob.find_many_versions`, the batch version-history read
|
|
6
|
+
|
|
7
|
+
`AtlasRb::Blob.versions` takes one id, so a caller holding a set of Blob noids
|
|
8
|
+
had to fan out a request per noid. The admin file-manage listing does exactly
|
|
9
|
+
that: it reads every replaceable Blob on a Work, which on a multipage Work is
|
|
10
|
+
one request per page binary, all before the page returns a byte.
|
|
11
|
+
|
|
12
|
+
`Blob.find_many_versions` wraps Atlas's `POST /files/find_many_versions` and
|
|
13
|
+
answers one `versions`-shaped envelope per Blob in a single call.
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
assets = AtlasRb::Work.assets(work_noid).reject { |a| a[:uri].present? }
|
|
17
|
+
history = AtlasRb::Blob.find_many_versions(assets.map(&:noid))
|
|
18
|
+
.index_by { |h| h["blob_id"] }
|
|
19
|
+
history[assets.first.noid]["versions"].first["revision"] # => 3
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The result is **unordered** and **may be shorter than the input** — an id that
|
|
23
|
+
resolves to nothing, or to a resource that is not a Blob, is dropped silently.
|
|
24
|
+
Index by `"blob_id"`.
|
|
25
|
+
|
|
26
|
+
Requires Atlas >= 0.6.161. Admin-gated exactly like `.versions`. `.versions`
|
|
27
|
+
itself is unchanged.
|
|
28
|
+
|
|
3
29
|
## 1.13.2
|
|
4
30
|
|
|
5
31
|
### Documentation — point `children` callers at the batch resolver
|
data/Gemfile.lock
CHANGED
data/lib/atlas_rb/blob.rb
CHANGED
|
@@ -290,6 +290,48 @@ module AtlasRb
|
|
|
290
290
|
))
|
|
291
291
|
end
|
|
292
292
|
|
|
293
|
+
# Read binary version history for many Blobs in one round-trip.
|
|
294
|
+
#
|
|
295
|
+
# Wraps Atlas's `POST /files/find_many_versions` — the batch counterpart to
|
|
296
|
+
# {.versions}, returning one envelope of exactly that shape per Blob. Use it
|
|
297
|
+
# anywhere a set of Blob noids would otherwise be resolved with a
|
|
298
|
+
# `versions`-per-noid fan-out (the admin file-manage listing, which reads
|
|
299
|
+
# every replaceable Blob on a Work): one HTTP call instead of N.
|
|
300
|
+
#
|
|
301
|
+
# The ids travel in the request **body**, so the list is not bounded by URL
|
|
302
|
+
# length. The result is **unordered** and **may be shorter than the input** —
|
|
303
|
+
# an id that resolves to nothing, or to a resource that is not a Blob, is
|
|
304
|
+
# dropped silently. Index by `"blob_id"`; do not assume positional
|
|
305
|
+
# correspondence with `ids`.
|
|
306
|
+
#
|
|
307
|
+
# Server admin-gates this exactly like {.versions} (the descriptors expose
|
|
308
|
+
# the same edit attribution), so `401` / `403` surface as raw Faraday
|
|
309
|
+
# responses. The grant is class-wide, so nothing is dropped for
|
|
310
|
+
# authorization — a dropped id is an unresolvable one.
|
|
311
|
+
#
|
|
312
|
+
# @param ids [Array<String>] Blob NOIDs.
|
|
313
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
314
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
315
|
+
# path it is ignored (identity lives in the token).
|
|
316
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
317
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
318
|
+
# omitted.
|
|
319
|
+
# @return [Array<AtlasRb::Mash>] one {.versions}-shaped envelope per resolved
|
|
320
|
+
# Blob (`"blob_id"` plus a reverse-chronological `"versions"` array); empty
|
|
321
|
+
# when none resolved.
|
|
322
|
+
#
|
|
323
|
+
# @example Render a Work's files with their histories in two calls
|
|
324
|
+
# assets = AtlasRb::Work.assets(work_noid).reject { |a| a[:uri].present? }
|
|
325
|
+
# history = AtlasRb::Blob.find_many_versions(assets.map(&:noid))
|
|
326
|
+
# .index_by { |h| h["blob_id"] }
|
|
327
|
+
# history[assets.first.noid]["versions"].first["revision"] # => 3
|
|
328
|
+
def self.find_many_versions(ids, nuid: nil, on_behalf_of: nil)
|
|
329
|
+
JSON.parse(
|
|
330
|
+
connection({}, nuid, on_behalf_of: on_behalf_of)
|
|
331
|
+
.post("#{ROUTE}find_many_versions", JSON.dump(ids: Array(ids)))&.body
|
|
332
|
+
).map { |envelope| AtlasRb::Mash.new(envelope) }
|
|
333
|
+
end
|
|
334
|
+
|
|
293
335
|
# Stream the bytes of a *prior* version of a Blob through a block.
|
|
294
336
|
#
|
|
295
337
|
# Wraps `GET /files/<id>/versions/<version_id>/content` — the version-pinned
|