atlas_rb 1.3.1 → 1.3.2

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: '0947add262eb2b9b4ab993f16c2c379877455e9ece3bca04f41a61bfddf79ee3'
4
- data.tar.gz: d239887dfaac21e78a7118503d4ed8ab79b12b3aa174ee18f5a8f31f253ca866
3
+ metadata.gz: 54691ff87af06d611d63a27333682abfd284c67d6990d0c8400ea2b9b80adb92
4
+ data.tar.gz: 7d3119d56763694dad36c69ded4cbf975af62d6eb070baf36c0df02f422259f1
5
5
  SHA512:
6
- metadata.gz: b4d59334c7730d11f9f7779b1cbef5c7cef49ce4b1726257a9c8590f258ab4c8aac80ffffa10c1111a38b4d98b95c7b36e824eab925aff4aae1ff87336f7e37e
7
- data.tar.gz: a5c0484e6d4204758dc1eee8e2ca6086a289e19e250a404fbdffc4af65eaa7864f2da7f93a9586d4d84776c76b33dbdebb5147ae4d728baed51110864c347e30
6
+ metadata.gz: 86dc095d2be7db4fdefe997cc6b33fabd0d3c1826804b0521fda48b06d17ec4cd3fde492a3926114965d4354823f55043ea7559d4ce82dcc06a288b7fa8afecd
7
+ data.tar.gz: c31c2bea0442ec082ede4a2328c6f7471eb02151021c6e08620b4fef5b254996ad424816493e8d955e202f5c5444e800393b85064dc9feb58a61cbaf126a9e08
data/.version CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.2
4
+
5
+ ### Added — `AtlasRb::User` (read-only user directory)
6
+
7
+ A user-context binding for Atlas's user directory endpoints — recipient
8
+ typeahead and NUID → name resolution for any surface that today renders a
9
+ bare NUID (User Inbox sender display, Audit History chips, Rights history).
10
+
11
+ ```ruby
12
+ AtlasRb::User.search("jan", nuid: "000000002")
13
+ # => [{ "nuid" => "001234567", "name" => "Doe, Jane" }, ...]
14
+
15
+ AtlasRb::User.find_by_nuid("001234567")
16
+ # => { "nuid" => "001234567", "name" => "Doe, Jane" }
17
+
18
+ AtlasRb::User.resolve(["001234567", "007654321"])
19
+ # => one entry per resolvable NUID, ordered by name
20
+ ```
21
+
22
+ - `search` is the typeahead: case-insensitive match on name, prefix match
23
+ on NUID. Atlas caps the list at 10 and orders by name.
24
+ - `resolve` batch-resolves up to 100 NUIDs in one round-trip (an inbox
25
+ page of senders in one call). Unresolvable NUIDs are dropped — callers
26
+ index by `nuid`.
27
+ - `find_by_nuid` resolves a single NUID; returns `nil` on Atlas's 404
28
+ (unknown NUID, or one held by an excluded role — indistinguishable on
29
+ the wire by design).
30
+ - Minimal disclosure is enforced server-side: entries carry `nuid` +
31
+ `name` only, and `anonymous` / `guest` / `system` rows never appear.
32
+ - Deliberately **not** under `AtlasRb::System` — this is an acting-user
33
+ capability on the ordinary `ATLAS_TOKEN` + `User:` header pairing; the
34
+ `System` namespace stays reserved for system-token calls.
35
+
3
36
  ## 1.3.1
4
37
 
5
38
  ### Added — `AtlasRb::Resource.mods_versions` / `mods_version` (MODS version history)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.3.1)
4
+ atlas_rb (1.3.2)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AtlasRb
4
+ # Read-only user directory lookups — typeahead search and NUID → name
5
+ # resolution.
6
+ #
7
+ # This is a **user-context** binding: calls authenticate as the acting
8
+ # user via the standard `ATLAS_TOKEN` + `User:` header pairing, like every
9
+ # other top-level class. It is deliberately *not* part of
10
+ # {AtlasRb::System} — that namespace is structurally reserved for
11
+ # system-token calls ({System::User.find_or_create}), and directory
12
+ # lookups are an ordinary logged-in-user capability.
13
+ #
14
+ # Atlas enforces minimal disclosure: every entry carries `nuid` + `name`
15
+ # only (no email, role, or groups), and rows with role `anonymous`,
16
+ # `guest`, or `system` are never returned. Per the layering principle the
17
+ # gem adds nothing on top — no caching, no name parsing, no result
18
+ # shaping; presentation belongs to the host application.
19
+ class User
20
+ extend AtlasRb::FaradayHelper
21
+
22
+ # Atlas REST endpoint prefix for the user directory.
23
+ # @api private
24
+ ROUTE = "/users"
25
+
26
+ # Typeahead search of the user directory.
27
+ #
28
+ # Case-insensitive match on name, prefix match on NUID (so typing a
29
+ # known NUID works too). Atlas caps the result (10 entries) and orders
30
+ # it by name; a blank query resolves to an empty list.
31
+ #
32
+ # @param query [String] name fragment or NUID prefix to match.
33
+ # @param nuid [String, nil] optional acting user's NUID, forwarded as the
34
+ # `User:` header. Required for cerberus-token requests; legacy bearer
35
+ # tokens still resolve without it.
36
+ # @return [Array<AtlasRb::Mash>] matching directory entries, each
37
+ # carrying `nuid` and `name`.
38
+ #
39
+ # @example Recipient typeahead
40
+ # AtlasRb::User.search("jan", nuid: "000000002")
41
+ # # => [{ "nuid" => "001234567", "name" => "Doe, Jane" }, ...]
42
+ def self.search(query, nuid: nil)
43
+ JSON.parse(
44
+ connection({ q: query }, nuid).get(ROUTE)&.body
45
+ ).map { |entry| AtlasRb::Mash.new(entry) }
46
+ end
47
+
48
+ # Resolve a single NUID to a directory entry.
49
+ #
50
+ # @param target_nuid [String] the NUID being looked up — the *subject*
51
+ # of the call, distinct from the acting `nuid:` kwarg.
52
+ # @param nuid [String, nil] optional acting user's NUID, forwarded as the
53
+ # `User:` header. Required for cerberus-token requests; legacy bearer
54
+ # tokens still resolve without it.
55
+ # @return [AtlasRb::Mash, nil] the `nuid` + `name` entry, or `nil` when
56
+ # Atlas reports the NUID as absent (unknown, or held by an excluded
57
+ # role — the two are indistinguishable on the wire by design).
58
+ #
59
+ # @example Sender-name display
60
+ # AtlasRb::User.find_by_nuid("001234567")
61
+ # # => { "nuid" => "001234567", "name" => "Doe, Jane" }
62
+ def self.find_by_nuid(target_nuid, nuid: nil)
63
+ response = connection({}, nuid).get("#{ROUTE}/by_nuid/#{target_nuid}")
64
+ return nil if response.status == 404
65
+
66
+ AtlasRb::Mash.new(JSON.parse(response.body))
67
+ end
68
+
69
+ # Batch-resolve a set of NUIDs to directory entries in one call.
70
+ #
71
+ # Same response shape as {.search}. Unresolvable NUIDs (unknown or
72
+ # excluded-role) are dropped, so the result may be shorter than the
73
+ # input — callers index by `nuid`. Atlas caps the batch at 100.
74
+ #
75
+ # @param nuids [Array<String>, String] the NUIDs to resolve.
76
+ # @param nuid [String, nil] optional acting user's NUID, forwarded as the
77
+ # `User:` header. Required for cerberus-token requests; legacy bearer
78
+ # tokens still resolve without it.
79
+ # @return [Array<AtlasRb::Mash>] resolved entries, each carrying `nuid`
80
+ # and `name`, ordered by name.
81
+ #
82
+ # @example Resolve an inbox page of senders in one round-trip
83
+ # senders = AtlasRb::User.resolve(["001234567", "007654321"])
84
+ # by_nuid = senders.index_by { |entry| entry["nuid"] }
85
+ def self.resolve(nuids, nuid: nil)
86
+ JSON.parse(
87
+ connection({ nuids: Array(nuids).join(",") }, nuid).get(ROUTE)&.body
88
+ ).map { |entry| AtlasRb::Mash.new(entry) }
89
+ end
90
+ end
91
+ end
data/lib/atlas_rb.rb CHANGED
@@ -18,6 +18,7 @@ require_relative "atlas_rb/work"
18
18
  require_relative "atlas_rb/file_set"
19
19
  require_relative "atlas_rb/blob"
20
20
  require_relative "atlas_rb/delegate"
21
+ require_relative "atlas_rb/user"
21
22
  require_relative "atlas_rb/admin"
22
23
  require_relative "atlas_rb/admin/work"
23
24
  require_relative "atlas_rb/admin/collection"
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.3.1
4
+ version: 1.3.2
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-06-07 00:00:00.000000000 Z
11
+ date: 2026-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -134,6 +134,7 @@ files:
134
134
  - lib/atlas_rb/middleware/raise_on_stale_resource.rb
135
135
  - lib/atlas_rb/resource.rb
136
136
  - lib/atlas_rb/system/user.rb
137
+ - lib/atlas_rb/user.rb
137
138
  - lib/atlas_rb/version.rb
138
139
  - lib/atlas_rb/work.rb
139
140
  - sig/atlas_rb.rbs