atlas_rb 1.8.8 → 1.8.10
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/Gemfile.lock +1 -1
- data/lib/atlas_rb/faraday_helper.rb +36 -0
- data/lib/atlas_rb/resource.rb +46 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a1ca62f7d0e0d49e63754618a22967d8a89a4496c05c894bbbff7f13903e94d
|
|
4
|
+
data.tar.gz: 5645596297711e7cc464645d249b91b4b62108eaf71978f9d07ffed9590043cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acd99d449e3dd94bb23cfdeabfc1190d2a074e5bfe07a2a4a8e54723fad47680f525d52e761f5ccee50ac1b464a39b889331e6468fe63bb9a0b06f8d17526262
|
|
7
|
+
data.tar.gz: c2d0db210a2a66cb41bc68baec3b6158916a86866c9a20182efc1bc2240f26e0c00357e340d08b4313312e239fabc9338bbca3f6face3c9d0576ef13d9f1f74d
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.10
|
data/Gemfile.lock
CHANGED
|
@@ -36,9 +36,28 @@ module AtlasRb
|
|
|
36
36
|
# If neither a signing key nor `ATLAS_JWT` is configured there is no relay
|
|
37
37
|
# credential, so the transport raises {AtlasRb::ConfigurationError}.
|
|
38
38
|
#
|
|
39
|
+
# ## Instrumentation
|
|
40
|
+
#
|
|
41
|
+
# Every builder brackets its request in an `ActiveSupport::Notifications`
|
|
42
|
+
# event named **`request.atlas_rb`** (Faraday's `:instrumentation`
|
|
43
|
+
# middleware, wired as the *outermost* handler so a redirect hop — e.g. the
|
|
44
|
+
# `/resources/:noid` NOID resolver — folds into one event per logical call
|
|
45
|
+
# rather than being double-counted). The payload is the Faraday `env`, so a
|
|
46
|
+
# subscriber reads `payload.method` / `payload.url` and the event's duration.
|
|
47
|
+
# This lets a host count/time Atlas round-trips (an N+1-over-HTTP detector)
|
|
48
|
+
# without reaching into gem internals. It is guarded on
|
|
49
|
+
# `defined?(ActiveSupport::Notifications)`: Rails hosts get the events; the
|
|
50
|
+
# headless BYO-JWT path (no AS loaded) is unaffected. With no subscriber
|
|
51
|
+
# attached the emit degrades to a listener lookup + `yield`, so it is safe to
|
|
52
|
+
# leave in the stack permanently — opt-in lives entirely on the consumer side.
|
|
53
|
+
#
|
|
39
54
|
# The module is mixed in via `extend`, so its methods become class methods on
|
|
40
55
|
# the host (e.g. `AtlasRb::Work.connection({})`).
|
|
41
56
|
module FaradayHelper
|
|
57
|
+
# ActiveSupport::Notifications event name emitted per outbound Atlas request.
|
|
58
|
+
# A dedicated name (not Faraday's default `request.faraday`) so a host that
|
|
59
|
+
# also uses Faraday for other clients can subscribe to Atlas traffic alone.
|
|
60
|
+
INSTRUMENTATION_EVENT = "request.atlas_rb"
|
|
42
61
|
# Wire contract Atlas enforces for relay-signing assertions (see Atlas
|
|
43
62
|
# ApplicationController#verify_cerberus_assertion). iss/aud are fixed; the
|
|
44
63
|
# short TTL bounds replay (Atlas allows 30s leeway on exp).
|
|
@@ -83,6 +102,7 @@ module AtlasRb
|
|
|
83
102
|
params: params,
|
|
84
103
|
headers: headers
|
|
85
104
|
) do |f|
|
|
105
|
+
instrument(f)
|
|
86
106
|
f.use AtlasRb::Middleware::RaiseOnStaleResource
|
|
87
107
|
f.use AtlasRb::Middleware::RaiseOnResourceError
|
|
88
108
|
f.response :follow_redirects
|
|
@@ -123,6 +143,7 @@ module AtlasRb
|
|
|
123
143
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
124
144
|
headers: headers
|
|
125
145
|
) do |f|
|
|
146
|
+
instrument(f)
|
|
126
147
|
f.use AtlasRb::Middleware::RaiseOnStaleResource
|
|
127
148
|
# Translate Atlas's verify-on-ingest 422 (fixity_mismatch /
|
|
128
149
|
# unsupported_digest_algorithm) into a typed FixityMismatchError —
|
|
@@ -190,6 +211,7 @@ module AtlasRb
|
|
|
190
211
|
params: params,
|
|
191
212
|
headers: headers
|
|
192
213
|
) do |f|
|
|
214
|
+
instrument(f)
|
|
193
215
|
f.response :follow_redirects
|
|
194
216
|
f.adapter Faraday.default_adapter
|
|
195
217
|
end
|
|
@@ -197,6 +219,20 @@ module AtlasRb
|
|
|
197
219
|
|
|
198
220
|
private
|
|
199
221
|
|
|
222
|
+
# Register Faraday's instrumentation middleware as the OUTERMOST handler so
|
|
223
|
+
# each logical call emits exactly one {INSTRUMENTATION_EVENT} — a redirect
|
|
224
|
+
# hop (e.g. the `/resources/:noid` resolver) is bracketed with the request
|
|
225
|
+
# it redirects to, not counted twice. Guarded on
|
|
226
|
+
# `defined?(ActiveSupport::Notifications)` because Faraday defaults its
|
|
227
|
+
# instrumenter to that constant and would `NameError` at build time on the
|
|
228
|
+
# headless path where ActiveSupport isn't loaded; there, the emit is simply
|
|
229
|
+
# never wired and the transport is unaffected.
|
|
230
|
+
def instrument(builder)
|
|
231
|
+
return unless defined?(ActiveSupport::Notifications)
|
|
232
|
+
|
|
233
|
+
builder.request :instrumentation, name: INSTRUMENTATION_EVENT
|
|
234
|
+
end
|
|
235
|
+
|
|
200
236
|
# Build the auth + identity headers shared by {#connection} and {#multipart}.
|
|
201
237
|
# Precedence: ATLAS_JWT (BYO-JWT) > relay-signing. The acting nuid /
|
|
202
238
|
# on_behalf_of fall through to the configured `default_nuid` /
|
data/lib/atlas_rb/resource.rb
CHANGED
|
@@ -88,6 +88,52 @@ module AtlasRb
|
|
|
88
88
|
).map { |node| AtlasRb::Mash.new(node) }
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
# Every Work beneath a resource, at any depth — the structural counterpart
|
|
92
|
+
# to {Compilation.contents}. Wraps `GET /resources/<id>/descendant_works`,
|
|
93
|
+
# which flattens the resource's full descendant subtree to the Works it
|
|
94
|
+
# contains, gated to what the caller may read and paginated Solr-side. Gives
|
|
95
|
+
# a Collection the flatten-to-Works capability a Set already has, so a bulk
|
|
96
|
+
# export (e.g. hyperion) pages one gated, fast call family instead of the
|
|
97
|
+
# client-side `children → find_many → recurse` walk.
|
|
98
|
+
#
|
|
99
|
+
# Returns the same digest shape as {find_many} / {Compilation.contents}
|
|
100
|
+
# (`{ "id", "noid", "klass", "title", "thumbnail" }`) under a `"works"` key,
|
|
101
|
+
# plus a `"pagination"` envelope (`total` / `page` / `per_page` / `pages`).
|
|
102
|
+
# Membership is **structural** (`a_member_of`) only; pass
|
|
103
|
+
# `include_linked: true` to also surface linked members
|
|
104
|
+
# (`a_linked_member_of`). Restricted Works never appear for a caller who may
|
|
105
|
+
# not read them; tombstoned Works are dropped.
|
|
106
|
+
#
|
|
107
|
+
# @param id [String] an Atlas resource ID (subtree root; any type).
|
|
108
|
+
# @param page [Integer, nil] 1-based page (default 1 server-side).
|
|
109
|
+
# @param per_page [Integer, nil] page size (server default 25, capped 100).
|
|
110
|
+
# @param include_linked [Boolean, nil] also include linked members when
|
|
111
|
+
# truthy; structural-only by default.
|
|
112
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
113
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
114
|
+
# path it is ignored (identity lives in the token).
|
|
115
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
116
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when omitted.
|
|
117
|
+
# @return [AtlasRb::Mash, nil] the parsed envelope, with a `"works"` digest
|
|
118
|
+
# array and a `"pagination"` block; `nil` when the id resolves to nothing
|
|
119
|
+
# (`404`).
|
|
120
|
+
#
|
|
121
|
+
# @example Page a Collection's whole subtree of Works
|
|
122
|
+
# result = AtlasRb::Resource.descendant_works("col-456", per_page: 100)
|
|
123
|
+
# result["works"].map { |w| w["noid"] }
|
|
124
|
+
# result.dig("pagination", "pages")
|
|
125
|
+
def self.descendant_works(id, page: nil, per_page: nil, include_linked: nil, nuid: nil, on_behalf_of: nil)
|
|
126
|
+
params = {}
|
|
127
|
+
params[:page] = page if page
|
|
128
|
+
params[:per_page] = per_page if per_page
|
|
129
|
+
params[:include_linked] = include_linked unless include_linked.nil?
|
|
130
|
+
resp = connection(params, nuid, on_behalf_of: on_behalf_of)
|
|
131
|
+
.get('/resources/' + id + '/descendant_works')
|
|
132
|
+
return nil if resp.status == 404
|
|
133
|
+
|
|
134
|
+
AtlasRb::Mash.new(JSON.parse(resp.body))
|
|
135
|
+
end
|
|
136
|
+
|
|
91
137
|
# Validate a MODS XML document against Atlas's schema *without* persisting it.
|
|
92
138
|
#
|
|
93
139
|
# 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.8.
|
|
4
|
+
version: 1.8.10
|
|
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-07-
|
|
11
|
+
date: 2026-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|