atlas_rb 1.29.5 → 1.29.6
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 +21 -0
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/collection.rb +51 -0
- data/lib/atlas_rb/community.rb +51 -0
- data/lib/atlas_rb/compilation.rb +48 -0
- data/lib/atlas_rb/resource.rb +25 -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: f25cd02a3fdd7a916ead4b71c784798f2a8eea61c58690f1caba0b841b46681e
|
|
4
|
+
data.tar.gz: c4707259a5cdce5d8861031ea7347b38a2dd0544f891acc582ddc64314e81651
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9cb8668bd08869e86278deae33e14c0822bc4ce628fd7fe6ada78d797726767b845f4386311056375121348b456e4dcafef2279ee95febbad94d0e98e4290faa
|
|
7
|
+
data.tar.gz: d52af1dadb11eb38eb7fabc55ea859457d9644cefcf10c9051ce87dbb7cb882943d50625d5476070749d156036dd26f985b98e4b632a376ae82d3bb5812238b4
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.29.
|
|
1
|
+
1.29.6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.29.6
|
|
4
|
+
|
|
5
|
+
Needs an Atlas with the scoped search routes. An older Atlas answers `404`,
|
|
6
|
+
and each method returns `nil`.
|
|
7
|
+
|
|
8
|
+
### Added — `Compilation.search`, `Collection.search` and `Community.search`
|
|
9
|
+
|
|
10
|
+
Wrap `GET /compilations/<id>/search`, `GET /collections/<id>/search` and
|
|
11
|
+
`GET /communities/<id>/search`: a keyword, filters and facet counts over the
|
|
12
|
+
Works of one Set or one container's subtree. Each returns a `Mash` with
|
|
13
|
+
`works`, `pagination` and `facets`, or `nil` on a `404`. `filters:` is sent
|
|
14
|
+
as `f[field][]=value` and `facets:` as `facet[]=field`.
|
|
15
|
+
|
|
16
|
+
Embargoed, in-progress and incomplete Works never appear, even for an admin
|
|
17
|
+
token. A facet or filter field that Atlas does not allow, or an unknown
|
|
18
|
+
`sort`, raises `ResourceError` with status `400` and Atlas's message.
|
|
19
|
+
|
|
20
|
+
`Collection.search` and `Community.search` shadow the catalog-wide
|
|
21
|
+
`Resource.search` on those two classes. Call `Resource.search` for the
|
|
22
|
+
catalog.
|
|
23
|
+
|
|
3
24
|
## 1.29.5
|
|
4
25
|
|
|
5
26
|
Needs an Atlas that records a v1 pid (0.6.279 or later). An older Atlas ignores
|
data/Gemfile.lock
CHANGED
data/lib/atlas_rb/collection.rb
CHANGED
|
@@ -195,5 +195,56 @@ module AtlasRb
|
|
|
195
195
|
ROUTE + id + '/mods' + (kind.to_s.empty? ? '' : ".#{kind}")
|
|
196
196
|
))
|
|
197
197
|
end
|
|
198
|
+
|
|
199
|
+
# Search the Works beneath a Collection, at any depth, with filters and facet
|
|
200
|
+
# counts.
|
|
201
|
+
#
|
|
202
|
+
# Wraps `GET /collections/<id>/search`. The rows are the same Work digests
|
|
203
|
+
# {Resource.descendant_works} returns, gated to what the caller may read.
|
|
204
|
+
#
|
|
205
|
+
# **Embargoed, in-progress and incomplete Works never appear, for any
|
|
206
|
+
# caller.** That includes an admin token: the route is a public feed. Use
|
|
207
|
+
# {Resource.descendant_works} or {Compilation.contents} to see them.
|
|
208
|
+
#
|
|
209
|
+
# @param id [String] the Collection ID.
|
|
210
|
+
# @param q [String, nil] keyword query; `nil` lists the whole scope.
|
|
211
|
+
# @param filters [Hash{String => String, Array<String>}] field to values,
|
|
212
|
+
# e.g. `{ "genre_ssim" => ["Photographs"] }`. Values in one field match
|
|
213
|
+
# any; every field must match. Sent as `f[field][]=value`.
|
|
214
|
+
# @param facets [Array<String>] the fields to count values for. Sent as
|
|
215
|
+
# `facet[]=field`.
|
|
216
|
+
# @param facet_limit [Integer, nil] values per facet (Atlas: default 20, at
|
|
217
|
+
# most 100).
|
|
218
|
+
# @param sort [String, nil] `"relevance"`, `"title"` or `"date"` (newest
|
|
219
|
+
# first). Atlas sorts by relevance when `q` is given, and by a stable
|
|
220
|
+
# order otherwise.
|
|
221
|
+
# @param page [Integer, nil] 1-based page (default 1).
|
|
222
|
+
# @param per_page [Integer, nil] page size (default 25, at most 100).
|
|
223
|
+
# @param include_linked [Boolean, nil] also search Works linked into the
|
|
224
|
+
# subtree from elsewhere when truthy; structural members only by default.
|
|
225
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
226
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
227
|
+
# path it is ignored (identity lives in the token).
|
|
228
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
229
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
230
|
+
# omitted.
|
|
231
|
+
# @return [AtlasRb::Mash, nil] `{ "works" => [...], "pagination" => {...},
|
|
232
|
+
# "facets" => { "genre_ssim" => [{ "value", "count" }] } }`. The counts
|
|
233
|
+
# cover the whole result, not just the page. `nil` when Atlas answers `404`.
|
|
234
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
|
|
235
|
+
# A `400` means a facet or filter field Atlas does not allow, or an
|
|
236
|
+
# unknown sort; the error's message carries Atlas's explanation.
|
|
237
|
+
# @example
|
|
238
|
+
# page = AtlasRb::Collection.search("x-123", filters: { "genre_ssim" => ["Maps"] }, sort: "title")
|
|
239
|
+
# page.works.map(&:noid)
|
|
240
|
+
def self.search(id, q: nil, filters: {}, facets: [], facet_limit: nil, sort: nil,
|
|
241
|
+
page: nil, per_page: nil, include_linked: nil, nuid: nil, on_behalf_of: nil)
|
|
242
|
+
params = scoped_search_params(q: q, filters: filters, facets: facets, facet_limit: facet_limit,
|
|
243
|
+
sort: sort, page: page, per_page: per_page)
|
|
244
|
+
params[:include_linked] = include_linked unless include_linked.nil?
|
|
245
|
+
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/search')) do |body|
|
|
246
|
+
AtlasRb::Mash.new(body)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
198
249
|
end
|
|
199
250
|
end
|
data/lib/atlas_rb/community.rb
CHANGED
|
@@ -169,5 +169,56 @@ module AtlasRb
|
|
|
169
169
|
ROUTE + id + '/mods' + (kind.to_s.empty? ? '' : ".#{kind}")
|
|
170
170
|
))
|
|
171
171
|
end
|
|
172
|
+
|
|
173
|
+
# Search the Works beneath a Community, at any depth, with filters and facet
|
|
174
|
+
# counts.
|
|
175
|
+
#
|
|
176
|
+
# Wraps `GET /communities/<id>/search`. The rows are the same Work digests
|
|
177
|
+
# {Resource.descendant_works} returns, gated to what the caller may read.
|
|
178
|
+
#
|
|
179
|
+
# **Embargoed, in-progress and incomplete Works never appear, for any
|
|
180
|
+
# caller.** That includes an admin token: the route is a public feed. Use
|
|
181
|
+
# {Resource.descendant_works} or {Compilation.contents} to see them.
|
|
182
|
+
#
|
|
183
|
+
# @param id [String] the Community ID.
|
|
184
|
+
# @param q [String, nil] keyword query; `nil` lists the whole scope.
|
|
185
|
+
# @param filters [Hash{String => String, Array<String>}] field to values,
|
|
186
|
+
# e.g. `{ "genre_ssim" => ["Photographs"] }`. Values in one field match
|
|
187
|
+
# any; every field must match. Sent as `f[field][]=value`.
|
|
188
|
+
# @param facets [Array<String>] the fields to count values for. Sent as
|
|
189
|
+
# `facet[]=field`.
|
|
190
|
+
# @param facet_limit [Integer, nil] values per facet (Atlas: default 20, at
|
|
191
|
+
# most 100).
|
|
192
|
+
# @param sort [String, nil] `"relevance"`, `"title"` or `"date"` (newest
|
|
193
|
+
# first). Atlas sorts by relevance when `q` is given, and by a stable
|
|
194
|
+
# order otherwise.
|
|
195
|
+
# @param page [Integer, nil] 1-based page (default 1).
|
|
196
|
+
# @param per_page [Integer, nil] page size (default 25, at most 100).
|
|
197
|
+
# @param include_linked [Boolean, nil] also search Works linked into the
|
|
198
|
+
# subtree from elsewhere when truthy; structural members only by default.
|
|
199
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
200
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
201
|
+
# path it is ignored (identity lives in the token).
|
|
202
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
203
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
204
|
+
# omitted.
|
|
205
|
+
# @return [AtlasRb::Mash, nil] `{ "works" => [...], "pagination" => {...},
|
|
206
|
+
# "facets" => { "genre_ssim" => [{ "value", "count" }] } }`. The counts
|
|
207
|
+
# cover the whole result, not just the page. `nil` when Atlas answers `404`.
|
|
208
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
|
|
209
|
+
# A `400` means a facet or filter field Atlas does not allow, or an
|
|
210
|
+
# unknown sort; the error's message carries Atlas's explanation.
|
|
211
|
+
# @example
|
|
212
|
+
# page = AtlasRb::Community.search("x-123", filters: { "genre_ssim" => ["Maps"] }, sort: "title")
|
|
213
|
+
# page.works.map(&:noid)
|
|
214
|
+
def self.search(id, q: nil, filters: {}, facets: [], facet_limit: nil, sort: nil,
|
|
215
|
+
page: nil, per_page: nil, include_linked: nil, nuid: nil, on_behalf_of: nil)
|
|
216
|
+
params = scoped_search_params(q: q, filters: filters, facets: facets, facet_limit: facet_limit,
|
|
217
|
+
sort: sort, page: page, per_page: per_page)
|
|
218
|
+
params[:include_linked] = include_linked unless include_linked.nil?
|
|
219
|
+
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/search')) do |body|
|
|
220
|
+
AtlasRb::Mash.new(body)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
172
223
|
end
|
|
173
224
|
end
|
data/lib/atlas_rb/compilation.rb
CHANGED
|
@@ -445,5 +445,53 @@ module AtlasRb
|
|
|
445
445
|
AtlasRb::Mash.new(body)
|
|
446
446
|
end
|
|
447
447
|
end
|
|
448
|
+
|
|
449
|
+
# Search the Works in a Set (its resolved recipe), with filters and facet counts.
|
|
450
|
+
#
|
|
451
|
+
# Wraps `GET /compilations/<id>/search`. The rows are the same Work digests
|
|
452
|
+
# {Resource.descendant_works} returns, gated to what the caller may read.
|
|
453
|
+
#
|
|
454
|
+
# **Embargoed, in-progress and incomplete Works never appear, for any
|
|
455
|
+
# caller.** That includes an admin token: the route is a public feed. Use
|
|
456
|
+
# {Resource.descendant_works} or {Compilation.contents} to see them.
|
|
457
|
+
#
|
|
458
|
+
# @param id [String] the Compilation ID.
|
|
459
|
+
# @param q [String, nil] keyword query; `nil` lists the whole scope.
|
|
460
|
+
# @param filters [Hash{String => String, Array<String>}] field to values,
|
|
461
|
+
# e.g. `{ "genre_ssim" => ["Photographs"] }`. Values in one field match
|
|
462
|
+
# any; every field must match. Sent as `f[field][]=value`.
|
|
463
|
+
# @param facets [Array<String>] the fields to count values for. Sent as
|
|
464
|
+
# `facet[]=field`.
|
|
465
|
+
# @param facet_limit [Integer, nil] values per facet (Atlas: default 20, at
|
|
466
|
+
# most 100).
|
|
467
|
+
# @param sort [String, nil] `"relevance"`, `"title"` or `"date"` (newest
|
|
468
|
+
# first). Atlas sorts by relevance when `q` is given, and by a stable
|
|
469
|
+
# order otherwise.
|
|
470
|
+
# @param page [Integer, nil] 1-based page (default 1).
|
|
471
|
+
# @param per_page [Integer, nil] page size (default 25, at most 100).
|
|
472
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
473
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
474
|
+
# path it is ignored (identity lives in the token).
|
|
475
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
476
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
477
|
+
# omitted.
|
|
478
|
+
# @return [AtlasRb::Mash, nil] `{ "works" => [...], "pagination" => {...},
|
|
479
|
+
# "facets" => { "genre_ssim" => [{ "value", "count" }] } }`. The counts
|
|
480
|
+
# cover the whole result, not just the page. `nil` when Atlas answers `404`.
|
|
481
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
|
|
482
|
+
# A `400` means a facet or filter field Atlas does not allow, or an
|
|
483
|
+
# unknown sort; the error's message carries Atlas's explanation.
|
|
484
|
+
# @example
|
|
485
|
+
# page = AtlasRb::Compilation.search("c-123", q: "harbor", facets: ["genre_ssim"])
|
|
486
|
+
# page.works.map(&:noid)
|
|
487
|
+
# page.facets.genre_ssim.map { |row| [row.value, row.count] }
|
|
488
|
+
def self.search(id, q: nil, filters: {}, facets: [], facet_limit: nil, sort: nil,
|
|
489
|
+
page: nil, per_page: nil, nuid: nil, on_behalf_of: nil)
|
|
490
|
+
params = scoped_search_params(q: q, filters: filters, facets: facets, facet_limit: facet_limit,
|
|
491
|
+
sort: sort, page: page, per_page: per_page)
|
|
492
|
+
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/search')) do |body|
|
|
493
|
+
AtlasRb::Mash.new(body)
|
|
494
|
+
end
|
|
495
|
+
end
|
|
448
496
|
end
|
|
449
497
|
end
|
data/lib/atlas_rb/resource.rb
CHANGED
|
@@ -668,5 +668,30 @@ module AtlasRb
|
|
|
668
668
|
payload
|
|
669
669
|
end
|
|
670
670
|
private_class_method :xml_upload_payload
|
|
671
|
+
|
|
672
|
+
# The query parameters of a scoped search: {Compilation.search},
|
|
673
|
+
# {Collection.search} and {Community.search}.
|
|
674
|
+
#
|
|
675
|
+
# Ruby-friendly names in, Atlas's wire names out: `filters:` becomes `f`
|
|
676
|
+
# and `facets:` becomes `facet`. Faraday's nested encoder then sends
|
|
677
|
+
# `f[genre_ssim][]=Photographs` and `facet[]=genre_ssim`, which is the
|
|
678
|
+
# shape Atlas reads. A parameter the caller left `nil` or empty is not
|
|
679
|
+
# sent at all, so Atlas applies its own default.
|
|
680
|
+
#
|
|
681
|
+
# @param q [String, nil] the keyword.
|
|
682
|
+
# @param filters [Hash{String => String, Array<String>}, nil] field to values.
|
|
683
|
+
# @param facets [Array<String>, String, nil] the fields to count.
|
|
684
|
+
# @param options [Hash] `facet_limit`, `sort`, `page`, `per_page`, sent when
|
|
685
|
+
# not `nil`.
|
|
686
|
+
# @return [Hash] the query parameters.
|
|
687
|
+
# @api private
|
|
688
|
+
def self.scoped_search_params(q:, filters:, facets:, **options)
|
|
689
|
+
params = options.compact
|
|
690
|
+
params[:q] = q unless q.nil?
|
|
691
|
+
params[:f] = filters.to_h { |field, values| [field.to_s, Array(values)] } unless filters.nil? || filters.empty?
|
|
692
|
+
params[:facet] = Array(facets) unless facets.nil? || Array(facets).empty?
|
|
693
|
+
params
|
|
694
|
+
end
|
|
695
|
+
private_class_method :scoped_search_params
|
|
671
696
|
end
|
|
672
697
|
end
|