atlas_rb 1.27.4 → 1.28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98ed27c0812607ce56681c0dd9b3ab4c17fc1224c7e3c36bf0aa5b4deb7527e9
4
- data.tar.gz: 401ebcc7d93621d999c2b6441f0e470ee6b68c2081e0eb104e5f059330310004
3
+ metadata.gz: 3f7cb74b4e4b3ef68b7aff99b26d2ac253d7834403aab7044a72a007bcf56c3d
4
+ data.tar.gz: 89e00c992776ff2c04876e2ec3e992642b66bc2b2a794e5234a2e62ac1c74aff
5
5
  SHA512:
6
- metadata.gz: 604f5e4183097244b9759cbf0caf188abf45ca936a7f9a07f3a476a4cb05dee0aa23f65357114bbdd9525e85d2c6ae746f0dba330f05cc4f3b978ae077778900
7
- data.tar.gz: e9d53ba6883acc6decc743d4e480a682918c7f6db19e550e97d5455836a31250a29430ba846df03fab075cd410cff11b6c01ffe257522898c47c9f27d708b723
6
+ metadata.gz: e51d08455c2c8e8c1cc57c7f4dc04cc74f016f9e1f85f2975b61608427b4d38f814aaedb9e124e0472a8fa7654f31a6267ce2dd4f968e6ebc1817bf06df9f83d
7
+ data.tar.gz: 8d589063122434a3d1583cf476d1f86fd952e880a467b823b653860233015b807ab2b06f6c2e9472842da135c8be1f5d1b2ce92322d8f08b83be749119504d9a
data/.version CHANGED
@@ -1 +1 @@
1
- 1.27.4
1
+ 1.28.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.28.1
4
+
5
+ Requires an Atlas that serves `GET /works/:id/file_revisions` (0.6.243 or
6
+ later).
7
+
8
+ ### Added — `AtlasRb::Work.file_revisions`
9
+
10
+ Lists the revision dates of a Work's replaced files: one entry per Blob with
11
+ more than one revision, as `blob_id` and `revisions`, newest first. Each
12
+ revision carries only `revision` and `created`. Atlas allows it to anyone who
13
+ can read the Work, so it carries no attribution; `Blob.versions` stays the
14
+ admin-gated, attributed history. `[]` when no file was ever replaced, `nil` on
15
+ a 404.
16
+
17
+ ## 1.28.0
18
+
19
+ Requires an Atlas that stores the preview image's size and placeholder (0.6.234
20
+ or later). An older Atlas ignores the new keys.
21
+
22
+ ### Added — the preview's size and placeholder on `Resource.set_thumbnails`
23
+
24
+ `preview_width:`, `preview_height:` and `preview_placeholder:` ride the PATCH
25
+ body beside `preview:`. Each is optional, and a `nil` is not sent. Atlas writes
26
+ them only with a `preview` URI and clears them when a `preview` arrives without
27
+ them, so pass them on every preview write. A malformed value, or one sent
28
+ without `preview`, raises `ResourceError` with status 422 and an `error` code.
29
+
30
+ `Work.find`, `Collection.find` and `Community.find` return the three keys
31
+ beside `"preview"`, each `nil` when Atlas holds none.
32
+
3
33
  ## 1.27.4
4
34
 
5
35
  Requires an Atlas that serves `GET /works/:id/health_check` (0.6.232 or later).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.27.4)
4
+ atlas_rb (1.28.1)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
@@ -16,7 +16,7 @@ GEM
16
16
  base64 (0.3.0)
17
17
  connection_pool (2.5.5)
18
18
  diff-lcs (1.6.1)
19
- faraday (2.15.0)
19
+ faraday (2.15.1)
20
20
  faraday-net_http (>= 2.0, < 3.6)
21
21
  json
22
22
  logger
@@ -32,6 +32,9 @@ module AtlasRb
32
32
  # omitted.
33
33
  # @return [Hash, nil] the `"collection"` object, already unwrapped from the
34
34
  # JSON response, or `nil` when the Collection does not exist (`404`).
35
+ # The preview image rides beside it: `"preview"` is its URI, and
36
+ # `"preview_width"`, `"preview_height"` and `"preview_placeholder"` (base64
37
+ # of a ~16px-wide JPEG) describe it. Each is `nil` when Atlas holds none.
35
38
  # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
36
39
  # auth/validation error envelope), carrying Atlas's status + body.
37
40
  #
@@ -30,6 +30,9 @@ module AtlasRb
30
30
  # omitted.
31
31
  # @return [Hash, nil] the `"community"` object from the JSON response,
32
32
  # already unwrapped, or `nil` when the Community does not exist (`404`).
33
+ # The preview image rides beside it: `"preview"` is its URI, and
34
+ # `"preview_width"`, `"preview_height"` and `"preview_placeholder"` (base64
35
+ # of a ~16px-wide JPEG) describe it. Each is `nil` when Atlas holds none.
33
36
  # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
34
37
  # auth/validation error envelope), carrying Atlas's status + body.
35
38
  #
@@ -136,19 +136,39 @@ module AtlasRb
136
136
  #
137
137
  # Only the URIs you pass are upserted; an omitted key is left untouched.
138
138
  #
139
+ # The preview's size and placeholder are written only with `preview`, and
140
+ # Atlas answers `422` for one sent without it. A `preview` sent without them
141
+ # clears the stored ones, so pass them on every preview write.
142
+ #
139
143
  # @param id [String] the resource's NOID.
140
144
  # @param thumbnail [String, nil] IIIF URI for the ~85² thumbnail.
141
145
  # @param thumbnail_2x [String, nil] IIIF URI for the ~170² 2x thumbnail.
142
146
  # @param preview [String, nil] IIIF URI for the ~500w preview image.
147
+ # @param preview_width [Integer, nil] pixel width of the image `preview`
148
+ # serves. Send it with `preview_height`.
149
+ # @param preview_height [Integer, nil] pixel height of the image `preview`
150
+ # serves. Send it with `preview_width`.
151
+ # @param preview_placeholder [String, nil] base64 of a ~16px-wide JPEG of
152
+ # that image, at most 2048 characters. The bytes only, not a data URI.
143
153
  # @param nuid [String, nil] optional acting user's NUID.
144
154
  # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
145
155
  # header.
146
156
  # @return [AtlasRb::Mash] the resource, unwrapped from its type key.
147
157
  # @raise [AtlasRb::NotFoundError] on `404` — the write did not happen.
148
158
  # @raise [AtlasRb::StaleResourceError] on an optimistic-lock conflict.
149
- # @raise [AtlasRb::ResourceError] on any other non-2xx.
150
- def self.set_thumbnails(id, thumbnail: nil, thumbnail_2x: nil, preview: nil, nuid: nil, on_behalf_of: nil)
151
- body = { thumbnail: thumbnail, thumbnail_2x: thumbnail_2x, preview: preview }.compact
159
+ # @raise [AtlasRb::ResourceError] on any other non-2xx, including the `422`
160
+ # whose `error` names a malformed size or placeholder.
161
+ #
162
+ # @example A preview with its size and placeholder
163
+ # AtlasRb::Resource.set_thumbnails("w-789", preview: uri,
164
+ # preview_width: 500, preview_height: 375,
165
+ # preview_placeholder: Base64.strict_encode64(tiny_jpeg))
166
+ def self.set_thumbnails(id, thumbnail: nil, thumbnail_2x: nil, preview: nil,
167
+ preview_width: nil, preview_height: nil, preview_placeholder: nil,
168
+ nuid: nil, on_behalf_of: nil)
169
+ body = { thumbnail: thumbnail, thumbnail_2x: thumbnail_2x, preview: preview,
170
+ preview_width: preview_width, preview_height: preview_height,
171
+ preview_placeholder: preview_placeholder }.compact
152
172
  unwrap(write_resource(
153
173
  connection({}, nuid, on_behalf_of: on_behalf_of)
154
174
  .patch('/resources/' + id + '/thumbnails', JSON.dump(body))
data/lib/atlas_rb/work.rb CHANGED
@@ -29,6 +29,9 @@ module AtlasRb
29
29
  # {AtlasRb.config}.default_on_behalf_of when omitted.
30
30
  # @return [Hash, nil] the `"work"` object, already unwrapped from the JSON
31
31
  # response, or `nil` when the Work does not exist (`404`).
32
+ # The preview image rides beside it: `"preview"` is its URI, and
33
+ # `"preview_width"`, `"preview_height"` and `"preview_placeholder"` (base64
34
+ # of a ~16px-wide JPEG) describe it. Each is `nil` when Atlas holds none.
32
35
  # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
33
36
  # auth/validation error envelope), carrying Atlas's status + body.
34
37
  #
@@ -512,6 +515,48 @@ module AtlasRb
512
515
  end
513
516
  end
514
517
 
518
+ # List the revision dates of a Work's replaced files.
519
+ #
520
+ # Wraps `GET /works/<id>/file_revisions` (Atlas 0.6.243 or later). Each
521
+ # entry names one Blob that has been replaced at least once, as
522
+ # `"blob_id"`, and lists its content revisions newest first under
523
+ # `"revisions"`. A revision carries only `"revision"`, the contiguous
524
+ # 1-based ordinal (1 is the first upload), and `"created"`, an ISO-8601
525
+ # timestamp.
526
+ #
527
+ # The Blobs are the ones {.assets} lists, so a file in a withdrawn FileSet
528
+ # stays out, and a Delegate never appears. Atlas allows the call to anyone
529
+ # who can read the Work, so it carries no attribution, digest, size or
530
+ # filename. The attributed history is {Blob.versions}, which is
531
+ # admin-gated.
532
+ #
533
+ # @param id [String] the Work ID.
534
+ # @param nuid [String, nil] optional acting user's NUID. On the relay-signing
535
+ # path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
536
+ # path it is ignored (identity lives in the token).
537
+ # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
538
+ # header. Falls through to {AtlasRb.config}.default_on_behalf_of when
539
+ # omitted.
540
+ # @return [Array<AtlasRb::Mash>, nil] one entry per Blob with more than one
541
+ # revision: `"blob_id"` and `"revisions"` (each `"revision"` and
542
+ # `"created"`), newest first. `[]` when no file was ever replaced.
543
+ #
544
+ # `nil` when Atlas answers `404` — no such Work, or, with a misconfigured
545
+ # `ATLAS_URL`, the route is not Atlas's at all.
546
+ # @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
547
+ # (a `403` for a caller who cannot read the Work, a `5xx`, a proxy's
548
+ # `503`), carrying Atlas's status and body so the failure is attributable
549
+ # at the boundary.
550
+ # @example Show when each file was replaced
551
+ # AtlasRb::Work.file_revisions("w-789", nuid: viewer_nuid).each do |entry|
552
+ # entry.revisions.each { |r| puts "#{entry.blob_id} v#{r.revision} #{r.created}" }
553
+ # end
554
+ def self.file_revisions(id, nuid: nil, on_behalf_of: nil)
555
+ read_body(connection({}, nuid, on_behalf_of: on_behalf_of).get("#{ROUTE}#{id}/file_revisions")) do |body|
556
+ body.map { |entry| AtlasRb::Mash.new(entry) }
557
+ end
558
+ end
559
+
515
560
  # Grade a Work's health green, yellow or red.
516
561
  #
517
562
  # Wraps `GET /works/<id>/health_check` (Atlas 0.6.232 or later). `grade` is
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.4
4
+ version: 1.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff