atlas_rb 1.0.0 → 1.1.1

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: 7f8b62042df9f4d715469ba7cf23dcf352485552aa9d73c55290312c3055800c
4
- data.tar.gz: d435ed7a4fb953f2d82dd6f304232731802b2e8fe68a5e055fecd51e972c560a
3
+ metadata.gz: 9660fb0f48db5601e75f8fb0579794cd398d42fbdbe1c2e849b67bb32569d9c1
4
+ data.tar.gz: fa8f43e4f7577027c3368e30f4ebf5c231202edbcaa1004ef0711582925680ee
5
5
  SHA512:
6
- metadata.gz: 3dffc895e6bee5bce6dbe907488a72a240c55b7d5ae5a506bff61d81a451a97490090d576c575fa07cf82ffbaf023109a9938aa66adf872e892b3a2fc37f3e13
7
- data.tar.gz: 7076d8304048de5f20b8560875fbaddcac8ab29a4c3cf3d37ac54b95c3bac4cb6aff56bc503967ec3a5e41289bf4173055b9d8ced278ac9b63849231e0e09ea2
6
+ metadata.gz: b98eab79df77eda36139468d6701ea8e56f5ae16ee85e3ef22635bc11f42aed762654bd9dbf02b87a4f8521bb4de335724b249c3700397d748572bd734bf62b4
7
+ data.tar.gz: c8f565644a54f99e6110131e6d1b361c21f51e068c565837c5226d21eb700b488fa13e1be9e59d591b587b4303196c785abf0c1fc8bb5eec000840b1515f2961
data/.version CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Added
6
+
7
+ - **`depositor:` kwarg on `AtlasRb::Work.create`** — optional NUID
8
+ forwarded as the `depositor` query param on `POST /works`. When
9
+ omitted, behaviour is unchanged: Atlas defaults the depositor to the
10
+ acting user. When provided, Atlas stamps the named NUID as the Work's
11
+ `depositor` and records the acting user as the `proxy_uploader`.
12
+
13
+ Motivation: proxy deposit. Librarians and bulk-deposit jobs frequently
14
+ upload Works on behalf of a researcher who is the rightful credited
15
+ depositor. Until now there was no way to express that split through
16
+ the gem — callers had to choose between misattributing the deposit to
17
+ the librarian or dropping to a raw Faraday call. The depositor is
18
+ immutable post-create; there is no corresponding setter on the update
19
+ surface.
20
+
21
+ ## 1.1.0
22
+
23
+ ### Added
24
+
25
+ - **`AtlasRb::Resource.history(id, nuid: nil, on_behalf_of: nil)`** —
26
+ wraps Atlas's `GET /resources/:id/history` endpoint. Returns the full
27
+ envelope (`resource_id` + reverse-chronological `events` array) as an
28
+ `AtlasRb::Mash`, matching the gem's convention for cross-resource
29
+ bindings. Authorization errors (`401` / `403`) surface as raw Faraday
30
+ responses for the caller's rescue layer. Pagination is not yet
31
+ supported by the server; a TODO is in place for when it lands.
32
+
33
+ Cerberus consumes this binding for the "History" tab on resource show
34
+ pages.
35
+
3
36
  ## 1.0.0 — major restructure: namespace gradient + ambient identity
4
37
 
5
38
  This release reshapes the gem's API surface. Downstream consumers
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.0.0)
4
+ atlas_rb (1.1.1)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
data/README.md CHANGED
@@ -112,7 +112,7 @@ Community → Collection → Work
112
112
  | `AtlasRb::FileSet` | Classified slot under a Work (e.g. `"primary"`, `"supplemental"`). |
113
113
  | `AtlasRb::Blob` | The binary bytes; supports streaming downloads. |
114
114
  | `AtlasRb::Authentication` | NUID → user record / group lookup. |
115
- | `AtlasRb::Resource` | Generic resolver and permissions lookup. |
115
+ | `AtlasRb::Resource` | Generic resolver, permissions lookup, and audit-event history. |
116
116
  | `AtlasRb::Reset` | Test-only — wipes Atlas state via `GET /reset`. |
117
117
 
118
118
  ## Namespace gradient: regular / Admin / System
@@ -187,6 +187,24 @@ AtlasRb::Work.list(in_progress: false, page: 2) # completed deposits, page 2
187
187
  AtlasRb::Work.complete("w-789") # mark w-789 done
188
188
  ```
189
189
 
190
+ ### Audit-event history
191
+
192
+ `Resource.history` wraps Atlas's `GET /resources/<id>/history` endpoint
193
+ and returns the full envelope — `resource_id` plus a reverse-chronological
194
+ `events` array — as an `AtlasRb::Mash`. It is type-agnostic: pass any
195
+ Community, Collection, Work, FileSet, or Blob ID. Pagination is not yet
196
+ supported on the server side; the endpoint returns the full history in
197
+ one shot.
198
+
199
+ ```ruby
200
+ result = AtlasRb::Resource.history("w-789")
201
+ result["resource_id"] # => "w-789"
202
+ result["events"].first["action"] # => "update"
203
+ ```
204
+
205
+ Authorization errors (`401` / `403`) are not caught here — they surface as
206
+ raw Faraday responses for the calling application's rescue layer.
207
+
190
208
  ## End-to-end example
191
209
 
192
210
  JSON responses come back as `AtlasRb::Mash` (a `Hashie::Mash` subclass), so
@@ -5,9 +5,9 @@ module AtlasRb
5
5
  #
6
6
  # Subclasses define a `ROUTE` constant (e.g. `"/communities/"`) and override
7
7
  # whichever of `find / create / destroy / update / metadata / mods` apply.
8
- # The {Resource} class itself ships three endpoints that are not
9
- # type-specific: a generic resolver, an XML preview helper, and a
10
- # permissions lookup.
8
+ # The {Resource} class itself ships four endpoints that are not
9
+ # type-specific: a generic resolver, an XML preview helper, a permissions
10
+ # lookup, and an audit-event history fetch.
11
11
  #
12
12
  # The Atlas resource hierarchy is:
13
13
  #
@@ -91,5 +91,42 @@ module AtlasRb
91
91
  .get('/resources/' + id + '/permissions')&.body
92
92
  ))["resource"]
93
93
  end
94
+
95
+ # Fetch the audit-event history for a resource.
96
+ #
97
+ # Wraps Atlas's `GET /resources/<id>/history` endpoint, which returns the
98
+ # full envelope (`resource_id` + reverse-chronological `events` array).
99
+ # The whole envelope is preserved so callers can confirm the events
100
+ # belong to the requested resource; access events as `result["events"]`.
101
+ #
102
+ # Authorization errors (`401` / `403`) are intentionally **not** caught
103
+ # here — they surface as raw Faraday responses for the calling
104
+ # application's rescue layer to translate.
105
+ #
106
+ # @todo Add pagination support once Atlas's history endpoint exposes
107
+ # page / per_page query params. Today the endpoint returns the full
108
+ # history in one shot.
109
+ #
110
+ # @param id [String] an Atlas resource ID.
111
+ # @param nuid [String, nil] optional acting user's NUID, forwarded as the
112
+ # `User:` header. Required for cerberus-token requests; legacy bearer
113
+ # tokens still resolve without it.
114
+ # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
115
+ # header. Falls through to {AtlasRb.config}.default_on_behalf_of when
116
+ # omitted.
117
+ # @return [AtlasRb::Mash] the parsed envelope from
118
+ # `GET /resources/<id>/history`, with `"resource_id"` and an `"events"`
119
+ # array (reverse chronological; possibly empty).
120
+ #
121
+ # @example
122
+ # result = AtlasRb::Resource.history("abc12345")
123
+ # result["resource_id"] # => "abc12345"
124
+ # result["events"].first["action"] # => "create"
125
+ def self.history(id, nuid: nil, on_behalf_of: nil)
126
+ AtlasRb::Mash.new(JSON.parse(
127
+ connection({}, nuid, on_behalf_of: on_behalf_of)
128
+ .get('/resources/' + id + '/history')&.body
129
+ ))
130
+ end
94
131
  end
95
132
  end
data/lib/atlas_rb/work.rb CHANGED
@@ -93,6 +93,13 @@ module AtlasRb
93
93
  # @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
94
94
  # header. Falls through to {AtlasRb.config}.default_on_behalf_of when
95
95
  # omitted.
96
+ # @param depositor [String, nil] optional NUID to stamp on the new Work's
97
+ # `depositor` field. When omitted, Atlas defaults the depositor to the
98
+ # acting user (`nuid:`); this kwarg is the proxy / batch escape hatch
99
+ # where the librarian who uploaded the Work is distinct from the person
100
+ # it should be attributed to. The acting user becomes the Work's
101
+ # `proxy_uploader`. The depositor is immutable post-create; there is no
102
+ # setter on the update surface.
96
103
  # @return [Hash] the created Work payload (post-update if `xml_path` was
97
104
  # supplied).
98
105
  #
@@ -105,9 +112,15 @@ module AtlasRb
105
112
  # @example Retry-safe bulk-deposit create
106
113
  # key = SecureRandom.uuid
107
114
  # AtlasRb::Work.create("col-456", idempotency_key: key)
108
- def self.create(id, xml_path = nil, idempotency_key: nil, nuid: nil, on_behalf_of: nil)
115
+ #
116
+ # @example Proxy deposit — librarian uploads on behalf of a researcher
117
+ # AtlasRb::Work.create("col-456", depositor: "000000123")
118
+ def self.create(id, xml_path = nil, idempotency_key: nil, nuid: nil,
119
+ on_behalf_of: nil, depositor: nil)
120
+ params = { collection_id: id }
121
+ params[:depositor] = depositor if depositor
109
122
  result = AtlasRb::Mash.new(JSON.parse(
110
- connection({ collection_id: id }, nuid,
123
+ connection(params, nuid,
111
124
  on_behalf_of: on_behalf_of, idempotency_key: idempotency_key).post(ROUTE)&.body
112
125
  ))["work"]
113
126
  return result unless xml_path.present?
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.0.0
4
+ version: 1.1.1
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-05-23 00:00:00.000000000 Z
11
+ date: 2026-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday