dor-services-client 15.30.1 → 15.32.0

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: 38fe63ab39d1a47f000292637f9cc4ff069fc00f14e5a0f418b10533f045d683
4
- data.tar.gz: 1417b370b51776908eead2717873de190c8056179bc0e1fceabb1fe2f4b979c2
3
+ metadata.gz: '06370387f51516d2a08d643598cc2e885f783014aa3bcb4f353abd131372470e'
4
+ data.tar.gz: 218e00a0664bb35a8ce93677791f6c5d6c52ffb64e3eb23a88da2713a4e79ee6
5
5
  SHA512:
6
- metadata.gz: c37c6ec851c5358ff9e2e3e932eacacf62b8a97152a8efec10e3ebc4f5028e0c7dc7fabe799f625839f39623c5a10f50b69b9c86de1ba7235b440fad4606ea0c
7
- data.tar.gz: 709012201d7f5bf3dc66a3f058484ed00c3e5c72b1a1ebc5b86a988cecfb20a34e2ce79f90734ac072e24e4e135c3f3de41637c996cd26918a1cddee3f47d368
6
+ metadata.gz: 37fc5d5a48b56cfa1bab49622d8c63014776f6493252ca7c69d63605296c8b4a60ea4739f0cb9205989a81a6ff37e800b965ba8cf6e35fb9a9f0211719f96ac3
7
+ data.tar.gz: b25369fb1e80f33db2bfc03fb1135f470d882b0af2017b29a3f1342531d5d0c04c0c59f19a8c685519bd89f123b1a9803471204e42f0ad4dd28f6a5339ec9323
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.30.1)
4
+ dor-services-client (15.32.0)
5
5
  activesupport (>= 7.0.0)
6
- cocina-models (~> 0.112.0)
6
+ cocina-models (~> 0.113.0)
7
7
  deprecation
8
8
  faraday (~> 2.0)
9
9
  faraday-retry
@@ -26,7 +26,7 @@ GEM
26
26
  securerandom (>= 0.3)
27
27
  tzinfo (~> 2.0, >= 2.0.5)
28
28
  uri (>= 0.13.1)
29
- addressable (2.8.8)
29
+ addressable (2.8.9)
30
30
  public_suffix (>= 2.0.2, < 8.0)
31
31
  ast (2.4.3)
32
32
  attr_extras (7.1.0)
@@ -34,7 +34,7 @@ GEM
34
34
  bigdecimal (4.0.1)
35
35
  byebug (13.0.0)
36
36
  reline (>= 0.6.0)
37
- cocina-models (0.112.0)
37
+ cocina-models (0.113.0)
38
38
  activesupport
39
39
  deprecation
40
40
  dry-struct (~> 1.0)
@@ -99,6 +99,9 @@ GEM
99
99
  ice_nine (0.11.2)
100
100
  io-console (0.8.2)
101
101
  json (2.18.1)
102
+ json-schema (6.1.0)
103
+ addressable (~> 2.8)
104
+ bigdecimal (>= 3.1, < 5)
102
105
  json_schemer (2.5.0)
103
106
  bigdecimal
104
107
  hana (~> 1.3)
@@ -109,7 +112,10 @@ GEM
109
112
  language_server-protocol (3.17.0.5)
110
113
  lint_roller (1.1.0)
111
114
  logger (1.7.0)
112
- minitest (6.0.1)
115
+ mcp (0.7.1)
116
+ json-schema (>= 4.1)
117
+ minitest (6.0.2)
118
+ drb (~> 2.0)
113
119
  prism (~> 1.5)
114
120
  multi_json (1.19.1)
115
121
  net-http (0.9.1)
@@ -145,14 +151,15 @@ GEM
145
151
  rspec-expectations (3.13.5)
146
152
  diff-lcs (>= 1.2.0, < 2.0)
147
153
  rspec-support (~> 3.13.0)
148
- rspec-mocks (3.13.7)
154
+ rspec-mocks (3.13.8)
149
155
  diff-lcs (>= 1.2.0, < 2.0)
150
156
  rspec-support (~> 3.13.0)
151
157
  rspec-support (3.13.7)
152
- rubocop (1.84.2)
158
+ rubocop (1.85.0)
153
159
  json (~> 2.3)
154
160
  language_server-protocol (~> 3.17.0.2)
155
161
  lint_roller (~> 1.1.0)
162
+ mcp (~> 0.6)
156
163
  parallel (~> 1.10)
157
164
  parser (>= 3.3.0.2)
158
165
  rainbow (>= 2.2.2, < 4.0)
@@ -214,4 +221,4 @@ DEPENDENCIES
214
221
  webmock
215
222
 
216
223
  BUNDLED WITH
217
- 4.0.6
224
+ 4.0.7
data/README.md CHANGED
@@ -108,6 +108,8 @@ object_client.version.current
108
108
  # Status includes whether the object is open, assembling, accessioning, or closeable.
109
109
  # See also objects_client.statuses for getting statuses in batch.
110
110
  object_client.version.status
111
+ # Returns object version as Cocina instance if valid; returns a Hash<cocina_object:, error_message:> if invalid
112
+ object_client.version.find(3)
111
113
 
112
114
  # see dor-services-app openapi.yml for optional params
113
115
  object_client.version.open(description: 'Changed title')
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 3.0', '< 5'
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 7.0.0'
28
- spec.add_dependency 'cocina-models', '~> 0.112.0'
28
+ spec.add_dependency 'cocina-models', '~> 0.113.0'
29
29
  spec.add_dependency 'deprecation', '>= 0'
30
30
  spec.add_dependency 'faraday', '~> 2.0'
31
31
  spec.add_dependency 'faraday-retry'
@@ -53,15 +53,21 @@ module Dor
53
53
  @object_identifier = object_identifier
54
54
  end
55
55
 
56
- # @return [Cocina::Models::DROWithMetadata] the object metadata
57
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
56
+ # @return [Cocina::Models::DROWithMetadata, Hash] the object metadata or a hash with
57
+ # invalid metadata and a message about the source of the invalidity
58
+ # @raise [Dor::Services::Client::Error] on an unsuccessful response from the server
58
59
  def find(version)
59
60
  resp = connection.get do |req|
60
61
  req.url "#{base_path}/#{version}"
61
62
  end
62
- raise_exception_based_on_response!(resp) unless resp.success?
63
63
 
64
- build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
64
+ if resp.success?
65
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
66
+ elsif resp.status == 409 # Signals the Cocina is present but invalid
67
+ build_invalid_cocina_from_response(resp)
68
+ else
69
+ raise_exception_based_on_response!(resp) unless resp.success?
70
+ end
65
71
  end
66
72
 
67
73
  # Get the current version for a DOR object. This comes from ObjectVersion table in the DSA
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.30.1'
6
+ VERSION = '15.32.0'
7
7
  end
8
8
  end
9
9
  end
@@ -54,6 +54,15 @@ module Dor
54
54
  Cocina::Models.without_metadata(cocina_object).to_json
55
55
  end
56
56
 
57
+ def build_invalid_cocina_from_response(response)
58
+ invalid_cocina_error = JSON.parse(response.body).dig('errors', 0)
59
+
60
+ {
61
+ cocina_object: invalid_cocina_error.dig('meta', 'json'),
62
+ error_message: invalid_cocina_error['message']
63
+ }.with_indifferent_access
64
+ end
65
+
57
66
  def date_from_header(headers, key)
58
67
  headers[key]&.to_datetime
59
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.30.1
4
+ version: 15.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.112.0
33
+ version: 0.113.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.112.0
40
+ version: 0.113.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: deprecation
43
43
  requirement: !ruby/object:Gem::Requirement