atlas_rb 1.18.0 → 1.19.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfa719c8d880ec4ed326597fe0882537649b69b6e0e52a3df4123353c1019198
4
- data.tar.gz: 1ffae14221914997c13572495b728dbb93cd02c81144cba4eb5ca33f64bb444a
3
+ metadata.gz: 528d764830f8e3a3fdaf376983d4ce3babe6ef0a19f5b1e2fe02fbceb0584bd0
4
+ data.tar.gz: 2d80d25327e3e43f389a0f71e84c2a880f5bc89905989ff22c16aabee90261c4
5
5
  SHA512:
6
- metadata.gz: b4705dd193fec70bb702846a51aa08a902a772a76964873d89a11ef2963823e7b5217525a3fb2efed339596ce213f04d6aad3cd43bb8b9387c92ea246e1d4740
7
- data.tar.gz: 3ab173992d0243e249f51dd385cb6b7507bd8478adac2abcb1077e49c04bc0dfcb2d4fc665b9e843e72b17337dd9cdf8e8709008078dc0909befd87ef5472ac1
6
+ metadata.gz: 881ea22bc257423cbbeb748d26bc011371d5d9112be6e72106a60799215d59ce636ef566210a7b5cb93090d075f450f910f15a1040f321910869f358a01bb8cf
7
+ data.tar.gz: 97203339683115160ec8ef78e375f639d76d38716f2d29f190b2c80b01505f8eda85081e6d487510de0fc65308ae00afba7dbc18e956da16476a2bc3b6bc931b
data/.version CHANGED
@@ -1 +1 @@
1
- 1.18.0
1
+ 1.19.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.19.0
4
+
5
+ ### Added — `Resource.search`, the catalog keyword search
6
+
7
+ ```ruby
8
+ AtlasRb::Resource.search("whaling logbook", type: "Work", page: 1, per_page: 25)
9
+ # => Mash with "results" and "pagination"
10
+ ```
11
+
12
+ Binds `GET /resources/search`, which needs Atlas 0.6.199 or later. It is
13
+ Cerberus's search bar for a caller without Blacklight: the same field weights,
14
+ because both come from the Solr core's search handler, and the same filters for
15
+ the global catalog. It returns the whole envelope, as `descendant_works` does, so
16
+ a caller pages with `pagination.pages`.
17
+
18
+ Each row is a Solr digest, and `klass` is a name `Resource.class_for` accepts, so
19
+ loading the full resource is `class_for(hit.klass).find(hit.noid)`.
20
+
21
+ One difference from Cerberus is deliberate. Atlas gates the rows as its own
22
+ `Ability` reads a resource, so an edit group and the depositor count as well as a
23
+ read group. Cerberus's search still checks read groups only, so for staff and
24
+ depositors this can return items that Cerberus's search does not. Every such item
25
+ is one the user can already open.
26
+
3
27
  ## 1.18.0
4
28
 
5
29
  ### Changed — the write surface is type-agnostic, and the typed writes are gone
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.18.0)
4
+ atlas_rb (1.19.0)
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.14.3)
19
+ faraday (2.14.4)
20
20
  faraday-net_http (>= 2.0, < 3.5)
21
21
  json
22
22
  logger
data/README.md CHANGED
@@ -641,6 +641,31 @@ tombstoned resources come back flagged (`"tombstoned" => true`), so index
641
641
  by `"noid"` rather than assuming positional correspondence. NOIDs only —
642
642
  raw Valkyrie ids are not a supported input.
643
643
 
644
+ ### Searching the catalog (`Resource.search`)
645
+
646
+ A keyword search, as Cerberus's search bar runs it, for a caller that has words
647
+ rather than a NOID:
648
+
649
+ ```ruby
650
+ result = AtlasRb::Resource.search("whaling logbook", type: "Work", per_page: 50)
651
+ result.pagination.total # => 12
652
+ hit = result.results.first
653
+ hit.title # => "Whaling logbook, 1851"
654
+ AtlasRb::Resource.class_for(hit.klass).find(hit.noid)
655
+ ```
656
+
657
+ It searches Works, Collections, Communities and People, most relevant first.
658
+ `type` narrows to one of those four; any other value is a `400`, raised as
659
+ `AtlasRb::ResourceError`. Leave out the text to browse everything the user may
660
+ read, newest first.
661
+
662
+ Each row is a digest read off Solr — `{ "id", "noid", "klass", "title",
663
+ "creators", "year", "thumbnail", "in_progress", "embargoed", "incomplete" }` —
664
+ not the full typed payload. Rows are **gated to the acting user**: public, one of
665
+ their read or edit groups, or a resource they deposited. So the same text can
666
+ return different results for different users. There are no facets and no sort
667
+ option.
668
+
644
669
  ### Missing resources: `nil` on a read, a raise on a write
645
670
 
646
671
  The two halves of the API answer an absent resource differently, on purpose.
@@ -155,6 +155,55 @@ module AtlasRb
155
155
  .get('/resources/' + id + '/descendant_works')) { |body| AtlasRb::Mash.new(body) }
156
156
  end
157
157
 
158
+ # Keyword search over the catalog, as Cerberus's search bar searches it.
159
+ #
160
+ # Searches Works, Collections, Communities and People, most relevant
161
+ # first, and returns one page. Atlas gates every row to what the acting
162
+ # user may read — public, one of their read or edit groups, or a resource
163
+ # they deposited — so two users can get different results for the same
164
+ # text. Tombstoned resources, featured Collections, personal roots and
165
+ # unfinished deposits (except the caller's own) never appear.
166
+ #
167
+ # Each row is a digest read off Solr, not a resource: `{ "id", "noid",
168
+ # "klass", "title", "creators", "year", "thumbnail", "in_progress",
169
+ # "embargoed", "incomplete" }`. `klass` is one of the four type names
170
+ # above, which {class_for} accepts, so a caller loads the full resource
171
+ # with `class_for(hit.klass).find(hit.noid)`.
172
+ #
173
+ # @param query [String, nil] the search text. Omit or pass blank to browse
174
+ # everything the user may read, newest first.
175
+ # @param type [String, nil] one of `"Work"`, `"Collection"`, `"Community"`,
176
+ # `"Person"`, to narrow the search to that type.
177
+ # @param page [Integer, nil] 1-based page (default 1 server-side).
178
+ # @param per_page [Integer, nil] page size (server default 25, capped 100).
179
+ # @param nuid [String, nil] optional acting user's NUID. On the relay-signing
180
+ # path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
181
+ # path it is ignored (identity lives in the token).
182
+ # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
183
+ # header. Falls through to {AtlasRb.config}.default_on_behalf_of when omitted.
184
+ # @return [AtlasRb::Mash] the parsed envelope, with a `"results"` digest
185
+ # array and a `"pagination"` block (`total` / `page` / `per_page` / `pages`).
186
+ #
187
+ # @raise [AtlasRb::ResourceError] on any non-2xx — a `400` for an unknown
188
+ # `type`, an auth envelope, a `5xx` — carrying Atlas's status and body.
189
+ # @example Find a Work by a word in its title, then load it
190
+ # result = AtlasRb::Resource.search("whaling logbook", type: "Work")
191
+ # hit = result.results.first
192
+ # AtlasRb::Resource.class_for(hit.klass).find(hit.noid)
193
+ # @example Page through every match
194
+ # (1..AtlasRb::Resource.search("whaling").pagination.pages).flat_map do |page|
195
+ # AtlasRb::Resource.search("whaling", page: page).results
196
+ # end
197
+ def self.search(query = nil, type: nil, page: nil, per_page: nil, nuid: nil, on_behalf_of: nil)
198
+ params = {}
199
+ params[:q] = query if query
200
+ params[:type] = type if type
201
+ params[:page] = page if page
202
+ params[:per_page] = per_page if per_page
203
+ read_body(connection(params, nuid, on_behalf_of: on_behalf_of)
204
+ .get("/resources/search")) { |body| AtlasRb::Mash.new(body) }
205
+ end
206
+
158
207
  # Validate a MODS XML document against Atlas's schema *without* persisting it.
159
208
  #
160
209
  # Useful for surfacing validation errors in UIs before the user commits.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-17 00:00:00.000000000 Z
11
+ date: 2026-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday