atlas_rb 1.29.5 → 1.29.7
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 +38 -0
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/collection.rb +55 -0
- data/lib/atlas_rb/community.rb +55 -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: 966b7b990c4e511a304cc00ff85d927c2480912b19cc242ea83bb9d0cf153a00
|
|
4
|
+
data.tar.gz: e1842a0db3d17034b5c9520e9ffc86a5aa1a22c446b233a8e3cb90cce054394e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d7768219f0487961b9516f0d7b892ee8fb977c8fc84e704163237534a8e1b3324f1379000e9bfc5d0203d0a9bae1c0d512875d1404e5dff41625506224a29f7
|
|
7
|
+
data.tar.gz: 9c69d4d9423397750596333cf8d990fae3e2b5ea895a799d79b94e23878c2a01ac77d58c12a24ead1d621b5caeee3a1aed7e6491d8c2586389cd339539aee18a
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.29.
|
|
1
|
+
1.29.7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.29.7
|
|
4
|
+
|
|
5
|
+
Needs Atlas 0.6.282 or later. An older Atlas still puts the rows under
|
|
6
|
+
`works`, so `results` is `nil` there.
|
|
7
|
+
|
|
8
|
+
### Changed — scoped search rows are under `results`
|
|
9
|
+
|
|
10
|
+
`Compilation.search`, `Collection.search` and `Community.search` return their
|
|
11
|
+
rows under `results`, not `works`. No code in the gem changed: it passes
|
|
12
|
+
Atlas's body through as a `Mash`, so only the documented shape moves.
|
|
13
|
+
|
|
14
|
+
`Collection.search` and `Community.search` also return the Collections
|
|
15
|
+
beneath the scope, as v1's `/api/v1/search/:id` did. Each Collection row has
|
|
16
|
+
the same shape as a Work row, and `resource_class` is `AtlasRb::Collection`.
|
|
17
|
+
The scope itself is never a row, and any `filters:` drops every Collection.
|
|
18
|
+
`Compilation.search` still returns Works only.
|
|
19
|
+
|
|
20
|
+
## 1.29.6
|
|
21
|
+
|
|
22
|
+
Needs an Atlas with the scoped search routes. An older Atlas answers `404`,
|
|
23
|
+
and each method returns `nil`.
|
|
24
|
+
|
|
25
|
+
### Added — `Compilation.search`, `Collection.search` and `Community.search`
|
|
26
|
+
|
|
27
|
+
Wrap `GET /compilations/<id>/search`, `GET /collections/<id>/search` and
|
|
28
|
+
`GET /communities/<id>/search`: a keyword, filters and facet counts over the
|
|
29
|
+
Works of one Set or one container's subtree. Each returns a `Mash` with
|
|
30
|
+
`works`, `pagination` and `facets`, or `nil` on a `404`. `filters:` is sent
|
|
31
|
+
as `f[field][]=value` and `facets:` as `facet[]=field`.
|
|
32
|
+
|
|
33
|
+
Embargoed, in-progress and incomplete Works never appear, even for an admin
|
|
34
|
+
token. A facet or filter field that Atlas does not allow, or an unknown
|
|
35
|
+
`sort`, raises `ResourceError` with status `400` and Atlas's message.
|
|
36
|
+
|
|
37
|
+
`Collection.search` and `Community.search` shadow the catalog-wide
|
|
38
|
+
`Resource.search` on those two classes. Call `Resource.search` for the
|
|
39
|
+
catalog.
|
|
40
|
+
|
|
3
41
|
## 1.29.5
|
|
4
42
|
|
|
5
43
|
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,60 @@ module AtlasRb
|
|
|
195
195
|
ROUTE + id + '/mods' + (kind.to_s.empty? ? '' : ".#{kind}")
|
|
196
196
|
))
|
|
197
197
|
end
|
|
198
|
+
|
|
199
|
+
# Search the Works and Collections beneath a Collection, at any depth, with
|
|
200
|
+
# filters and facet counts.
|
|
201
|
+
#
|
|
202
|
+
# Wraps `GET /collections/<id>/search`. The rows are the Work digests
|
|
203
|
+
# {Resource.descendant_works} returns, plus one row in the same shape for
|
|
204
|
+
# each Collection beneath the Collection, gated to what the caller may read.
|
|
205
|
+
# Each row's `resource_class` tells the two apart. The Collection itself is
|
|
206
|
+
# never a row. Any `filters:` drops every Collection, because a Collection
|
|
207
|
+
# carries none of the Work values the filters match.
|
|
208
|
+
#
|
|
209
|
+
# **Embargoed, in-progress and incomplete Works never appear, for any
|
|
210
|
+
# caller.** That includes an admin token: the route is a public feed. Use
|
|
211
|
+
# {Resource.descendant_works} or {Compilation.contents} to see them.
|
|
212
|
+
#
|
|
213
|
+
# @param id [String] the Collection ID.
|
|
214
|
+
# @param q [String, nil] keyword query; `nil` lists the whole scope.
|
|
215
|
+
# @param filters [Hash{String => String, Array<String>}] field to values,
|
|
216
|
+
# e.g. `{ "genre_ssim" => ["Photographs"] }`. Values in one field match
|
|
217
|
+
# any; every field must match. Sent as `f[field][]=value`.
|
|
218
|
+
# @param facets [Array<String>] the fields to count values for. Sent as
|
|
219
|
+
# `facet[]=field`.
|
|
220
|
+
# @param facet_limit [Integer, nil] values per facet (Atlas: default 20, at
|
|
221
|
+
# most 100).
|
|
222
|
+
# @param sort [String, nil] `"relevance"`, `"title"` or `"date"` (newest
|
|
223
|
+
# first). Atlas sorts by relevance when `q` is given, and by a stable
|
|
224
|
+
# order otherwise.
|
|
225
|
+
# @param page [Integer, nil] 1-based page (default 1).
|
|
226
|
+
# @param per_page [Integer, nil] page size (default 25, at most 100).
|
|
227
|
+
# @param include_linked [Boolean, nil] also search Works linked into the
|
|
228
|
+
# subtree from elsewhere when truthy; structural members only by default.
|
|
229
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
230
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
231
|
+
# path it is ignored (identity lives in the token).
|
|
232
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
233
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
234
|
+
# omitted.
|
|
235
|
+
# @return [AtlasRb::Mash, nil] `{ "results" => [...], "pagination" => {...},
|
|
236
|
+
# "facets" => { "genre_ssim" => [{ "value", "count" }] } }`. The counts
|
|
237
|
+
# cover the whole result, not just the page. `nil` when Atlas answers `404`.
|
|
238
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
|
|
239
|
+
# A `400` means a facet or filter field Atlas does not allow, or an
|
|
240
|
+
# unknown sort; the error's message carries Atlas's explanation.
|
|
241
|
+
# @example
|
|
242
|
+
# page = AtlasRb::Collection.search("x-123", filters: { "genre_ssim" => ["Maps"] }, sort: "title")
|
|
243
|
+
# page.results.map(&:noid)
|
|
244
|
+
def self.search(id, q: nil, filters: {}, facets: [], facet_limit: nil, sort: nil,
|
|
245
|
+
page: nil, per_page: nil, include_linked: nil, nuid: nil, on_behalf_of: nil)
|
|
246
|
+
params = scoped_search_params(q: q, filters: filters, facets: facets, facet_limit: facet_limit,
|
|
247
|
+
sort: sort, page: page, per_page: per_page)
|
|
248
|
+
params[:include_linked] = include_linked unless include_linked.nil?
|
|
249
|
+
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/search')) do |body|
|
|
250
|
+
AtlasRb::Mash.new(body)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
198
253
|
end
|
|
199
254
|
end
|
data/lib/atlas_rb/community.rb
CHANGED
|
@@ -169,5 +169,60 @@ module AtlasRb
|
|
|
169
169
|
ROUTE + id + '/mods' + (kind.to_s.empty? ? '' : ".#{kind}")
|
|
170
170
|
))
|
|
171
171
|
end
|
|
172
|
+
|
|
173
|
+
# Search the Works and Collections beneath a Community, at any depth, with
|
|
174
|
+
# filters and facet counts.
|
|
175
|
+
#
|
|
176
|
+
# Wraps `GET /communities/<id>/search`. The rows are the Work digests
|
|
177
|
+
# {Resource.descendant_works} returns, plus one row in the same shape for
|
|
178
|
+
# each Collection beneath the Community, gated to what the caller may read.
|
|
179
|
+
# Each row's `resource_class` tells the two apart. The Community itself is
|
|
180
|
+
# never a row. Any `filters:` drops every Collection, because a Collection
|
|
181
|
+
# carries none of the Work values the filters match.
|
|
182
|
+
#
|
|
183
|
+
# **Embargoed, in-progress and incomplete Works never appear, for any
|
|
184
|
+
# caller.** That includes an admin token: the route is a public feed. Use
|
|
185
|
+
# {Resource.descendant_works} or {Compilation.contents} to see them.
|
|
186
|
+
#
|
|
187
|
+
# @param id [String] the Community ID.
|
|
188
|
+
# @param q [String, nil] keyword query; `nil` lists the whole scope.
|
|
189
|
+
# @param filters [Hash{String => String, Array<String>}] field to values,
|
|
190
|
+
# e.g. `{ "genre_ssim" => ["Photographs"] }`. Values in one field match
|
|
191
|
+
# any; every field must match. Sent as `f[field][]=value`.
|
|
192
|
+
# @param facets [Array<String>] the fields to count values for. Sent as
|
|
193
|
+
# `facet[]=field`.
|
|
194
|
+
# @param facet_limit [Integer, nil] values per facet (Atlas: default 20, at
|
|
195
|
+
# most 100).
|
|
196
|
+
# @param sort [String, nil] `"relevance"`, `"title"` or `"date"` (newest
|
|
197
|
+
# first). Atlas sorts by relevance when `q` is given, and by a stable
|
|
198
|
+
# order otherwise.
|
|
199
|
+
# @param page [Integer, nil] 1-based page (default 1).
|
|
200
|
+
# @param per_page [Integer, nil] page size (default 25, at most 100).
|
|
201
|
+
# @param include_linked [Boolean, nil] also search Works linked into the
|
|
202
|
+
# subtree from elsewhere when truthy; structural members only by default.
|
|
203
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
204
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
205
|
+
# path it is ignored (identity lives in the token).
|
|
206
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
207
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
208
|
+
# omitted.
|
|
209
|
+
# @return [AtlasRb::Mash, nil] `{ "results" => [...], "pagination" => {...},
|
|
210
|
+
# "facets" => { "genre_ssim" => [{ "value", "count" }] } }`. The counts
|
|
211
|
+
# cover the whole result, not just the page. `nil` when Atlas answers `404`.
|
|
212
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`.
|
|
213
|
+
# A `400` means a facet or filter field Atlas does not allow, or an
|
|
214
|
+
# unknown sort; the error's message carries Atlas's explanation.
|
|
215
|
+
# @example
|
|
216
|
+
# page = AtlasRb::Community.search("x-123", filters: { "genre_ssim" => ["Maps"] }, sort: "title")
|
|
217
|
+
# page.results.map(&:noid)
|
|
218
|
+
def self.search(id, q: nil, filters: {}, facets: [], facet_limit: nil, sort: nil,
|
|
219
|
+
page: nil, per_page: nil, include_linked: nil, nuid: nil, on_behalf_of: nil)
|
|
220
|
+
params = scoped_search_params(q: q, filters: filters, facets: facets, facet_limit: facet_limit,
|
|
221
|
+
sort: sort, page: page, per_page: per_page)
|
|
222
|
+
params[:include_linked] = include_linked unless include_linked.nil?
|
|
223
|
+
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/search')) do |body|
|
|
224
|
+
AtlasRb::Mash.new(body)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
172
227
|
end
|
|
173
228
|
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] `{ "results" => [...], "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.results.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
|