atlas_rb 1.6.2 → 1.6.4

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: d84aa1546173f2a0ad397f7bb8f960be544c79c02187013fadf82301efa8afcf
4
- data.tar.gz: 7873dec712e7bc46d10fd081e2401a96ff980c3c93d97a35799f08edbe701f26
3
+ metadata.gz: 5c1b8b2ec2ef5cadfe63ee85f618f8ef0ce394e9d7cc49637750250594ecd414
4
+ data.tar.gz: d59e9ac145408d33e00ddcc89f92cee6126b32e5c1959467a042080f14f49bb6
5
5
  SHA512:
6
- metadata.gz: 431d703701ca9f01511894590c3680147f96daf702930796acc8bfe6678b7c34eba571087c6ce491daf144797ea2c07bfd345e04d20cf077ff92034ec2c0c886
7
- data.tar.gz: 83dc3bd542faa2ccca914f0f4029f4ef5427fd0971c641edeeacf607927d93d818e71faa45c9b5637f7f6ed9df0df7600a66bfa420a86965d3a59f71726d4b64
6
+ metadata.gz: 42992114ad5685f700294dd0f52d5c55507182d4ae0f907a2077c35a534cb7e8052a5d4a7a266f435ae1964341ca15d28c85688e8ff559ff60eb067c48994a7d
7
+ data.tar.gz: dc7a7df1a1fba8e4766a47c648c37f85a99244d105ebe6f564f09953fcda29837b111f41e730e871ca20afd032ed9db46dfe7dcd64e41badc550816d8c66f56e
data/.version CHANGED
@@ -1 +1 @@
1
- 1.6.2
1
+ 1.6.4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.6.2)
4
+ atlas_rb (1.6.4)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
@@ -44,6 +44,9 @@ module AtlasRb
44
44
  # @param xml_path [String, nil] optional path to a MODS XML file used to
45
45
  # seed metadata. When given, the Collection is created and immediately
46
46
  # patched with the metadata in the file.
47
+ # @param featured [Boolean] mark the Collection as a genre-showcase
48
+ # ("Featured") Collection. Defaults to false. Use when provisioning a
49
+ # Community's showcase set (loop create + featured: true).
47
50
  # @param nuid [String, nil] optional acting user's NUID. On the relay-signing
48
51
  # path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
49
52
  # path it is ignored (identity lives in the token).
@@ -53,11 +56,11 @@ module AtlasRb
53
56
  # @return [Hash] the created Collection payload (post-update if
54
57
  # `xml_path` was supplied).
55
58
  #
56
- # @example
57
- # AtlasRb::Collection.create("c-123", "/tmp/collection-mods.xml")
58
- def self.create(id, xml_path = nil, nuid: nil, on_behalf_of: nil)
59
+ # @example A featured showcase collection
60
+ # AtlasRb::Collection.create("c-123", featured: true)
61
+ def self.create(id, xml_path = nil, featured: false, nuid: nil, on_behalf_of: nil)
59
62
  result = AtlasRb::Mash.new(JSON.parse(
60
- connection({ parent_id: id }, nuid, on_behalf_of: on_behalf_of).post(ROUTE)&.body
63
+ connection({ parent_id: id, featured: featured }, nuid, on_behalf_of: on_behalf_of).post(ROUTE)&.body
61
64
  ))["collection"]
62
65
  return result unless xml_path.present?
63
66
 
@@ -65,6 +68,27 @@ module AtlasRb
65
68
  find(result["id"], nuid: nuid, on_behalf_of: on_behalf_of)
66
69
  end
67
70
 
71
+ # Toggle the showcase "Featured" flag on an existing Collection.
72
+ #
73
+ # A resource-attribute write (not a MODS update), so it does not touch
74
+ # descriptive metadata. Cerberus reads the projected `featured_bsi` to
75
+ # badge the Collection in a community's browse.
76
+ #
77
+ # @param id [String] the Collection ID.
78
+ # @param featured [Boolean] the new flag value.
79
+ # @param nuid [String, nil] optional acting user's NUID.
80
+ # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
81
+ # header. Falls through to {AtlasRb.config}.default_on_behalf_of when omitted.
82
+ # @return [AtlasRb::Mash] the updated `"collection"` object, already unwrapped.
83
+ #
84
+ # @example
85
+ # AtlasRb::Collection.set_featured("col-456", true)
86
+ def self.set_featured(id, featured, nuid: nil, on_behalf_of: nil)
87
+ AtlasRb::Mash.new(JSON.parse(
88
+ connection({ featured: featured }, nuid, on_behalf_of: on_behalf_of).patch(ROUTE + id)&.body
89
+ ))["collection"]
90
+ end
91
+
68
92
  # Move a Collection to a different parent Community.
69
93
  #
70
94
  # Wraps `PATCH /collections/<id>/parent` with a `parent_id` of the new
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AtlasRb
4
+ # A neutral curatorial identity in Atlas, distinct from the auth-side users
5
+ # directory. A Person correlates the several `users` rows that share a NUID
6
+ # and carries the authoritative, librarian-editable `display_name` (the SSO
7
+ # `users.name` is frequently wrong and is clobbered on every login), plus
8
+ # community affiliations.
9
+ #
10
+ # Addressed by NUID, not NOID — the NUID is the correlation key consumers
11
+ # hold. So the positional `id` argument below is the person's **NUID**, and
12
+ # the `nuid:` / `on_behalf_of:` keywords keep their usual gem meaning (the
13
+ # acting principal). The one exception is {.create}, whose `nuid:` keyword is
14
+ # the *new person's* NUID (matching the gap's signature); the acting principal
15
+ # there comes from the ambient `AtlasRb.config.default_nuid`.
16
+ #
17
+ # Create / update / affiliation writes are :system + admin on the server; a
18
+ # non-privileged caller gets a 403.
19
+ class Person < Resource
20
+ ROUTE = "/people/"
21
+
22
+ # Fetch a Person by NUID.
23
+ #
24
+ # @param id [String] the person's NUID.
25
+ # @param nuid [String, nil] acting principal (signed into the assertion sub).
26
+ # @param on_behalf_of [String, nil] acting-as target.
27
+ # @return [AtlasRb::Mash] the unwrapped `"person"` object.
28
+ def self.find(id, nuid: nil, on_behalf_of: nil)
29
+ AtlasRb::Mash.new(JSON.parse(
30
+ connection({}, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id)&.body
31
+ ))["person"]
32
+ end
33
+
34
+ # Batch-resolve people to their authoritative display_name in one call
35
+ # (supersedes the SSO users directory's resolve). Unresolved NUIDs drop.
36
+ #
37
+ # @param nuids [Array<String>] the NUIDs to resolve.
38
+ # @param nuid [String, nil] acting principal.
39
+ # @param on_behalf_of [String, nil] acting-as target.
40
+ # @return [Array<AtlasRb::Mash>] one unwrapped `"person"` per resolved NUID.
41
+ def self.resolve(nuids, nuid: nil, on_behalf_of: nil)
42
+ JSON.parse(
43
+ connection({ nuids: Array(nuids).join(",") }, nuid, on_behalf_of: on_behalf_of).get(ROUTE)&.body
44
+ )["people"].map { |entry| AtlasRb::Mash.new(entry["person"]) }
45
+ end
46
+
47
+ # Create a Person. One Person per NUID — a duplicate NUID is a 409.
48
+ #
49
+ # @param nuid [String] the **new person's** NUID (the subject, not the actor).
50
+ # @param display_name [String] authoritative display name.
51
+ # @param bio [String, nil]
52
+ # @param orcid [String, nil]
53
+ # @param title [String, nil]
54
+ # @param on_behalf_of [String, nil] acting-as target (the acting principal
55
+ # itself comes from the ambient AtlasRb.config.default_nuid).
56
+ # @return [AtlasRb::Mash] the unwrapped `"person"` object.
57
+ def self.create(nuid:, display_name:, bio: nil, orcid: nil, title: nil, on_behalf_of: nil)
58
+ body = { nuid: nuid, display_name: display_name, bio: bio, orcid: orcid, title: title }.compact
59
+ AtlasRb::Mash.new(JSON.parse(
60
+ connection({}, nil, on_behalf_of: on_behalf_of).post(ROUTE, JSON.dump(body))&.body
61
+ ))["person"]
62
+ end
63
+
64
+ # Edit a Person's authority fields. NUID is immutable and not patchable.
65
+ # Only supplied fields are changed.
66
+ #
67
+ # @param id [String] the person's NUID.
68
+ # @param display_name [String, nil]
69
+ # @param bio [String, nil]
70
+ # @param orcid [String, nil]
71
+ # @param title [String, nil]
72
+ # @param nuid [String, nil] acting principal.
73
+ # @param on_behalf_of [String, nil] acting-as target.
74
+ # @return [AtlasRb::Mash] the unwrapped, updated `"person"` object.
75
+ def self.update(id, display_name: nil, bio: nil, orcid: nil, title: nil, nuid: nil, on_behalf_of: nil)
76
+ body = { display_name: display_name, bio: bio, orcid: orcid, title: title }.compact
77
+ AtlasRb::Mash.new(JSON.parse(
78
+ connection({}, nuid, on_behalf_of: on_behalf_of).patch(ROUTE + id, JSON.dump(body))&.body
79
+ ))["person"]
80
+ end
81
+
82
+ # Add a community affiliation (idempotent; audited server-side).
83
+ #
84
+ # @param id [String] the person's NUID.
85
+ # @param community_id [String] the community's NOID.
86
+ # @param nuid [String, nil] acting principal.
87
+ # @param on_behalf_of [String, nil] acting-as target.
88
+ # @return [AtlasRb::Mash] the unwrapped `"person"` object, with the updated
89
+ # `affiliated_community_ids`.
90
+ def self.add_affiliation(id, community_id, nuid: nil, on_behalf_of: nil)
91
+ AtlasRb::Mash.new(JSON.parse(
92
+ connection({}, nuid, on_behalf_of: on_behalf_of)
93
+ .post(ROUTE + id + "/affiliations", JSON.dump(community_id: community_id))&.body
94
+ ))["person"]
95
+ end
96
+
97
+ # Remove a community affiliation (tolerant; audited server-side).
98
+ #
99
+ # @param id [String] the person's NUID.
100
+ # @param community_id [String] the community's NOID.
101
+ # @param nuid [String, nil] acting principal.
102
+ # @param on_behalf_of [String, nil] acting-as target.
103
+ # @return [AtlasRb::Mash] the unwrapped `"person"` object.
104
+ def self.remove_affiliation(id, community_id, nuid: nil, on_behalf_of: nil)
105
+ AtlasRb::Mash.new(JSON.parse(
106
+ connection({}, nuid, on_behalf_of: on_behalf_of)
107
+ .delete(ROUTE + id + "/affiliations/" + community_id)&.body
108
+ ))["person"]
109
+ end
110
+ end
111
+ end
data/lib/atlas_rb.rb CHANGED
@@ -22,6 +22,7 @@ require_relative "atlas_rb/file_set"
22
22
  require_relative "atlas_rb/blob"
23
23
  require_relative "atlas_rb/delegate"
24
24
  require_relative "atlas_rb/compilation"
25
+ require_relative "atlas_rb/person"
25
26
  require_relative "atlas_rb/user"
26
27
  require_relative "atlas_rb/admin"
27
28
  require_relative "atlas_rb/admin/work"
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.6.2
4
+ version: 1.6.4
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-17 00:00:00.000000000 Z
11
+ date: 2026-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -147,6 +147,7 @@ files:
147
147
  - lib/atlas_rb/mash.rb
148
148
  - lib/atlas_rb/middleware/raise_on_resource_error.rb
149
149
  - lib/atlas_rb/middleware/raise_on_stale_resource.rb
150
+ - lib/atlas_rb/person.rb
150
151
  - lib/atlas_rb/resource.rb
151
152
  - lib/atlas_rb/system.rb
152
153
  - lib/atlas_rb/system/user.rb