cocina-models 0.116.0 → 0.118.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: cfe265fcb4aa056742a278f0f49cdaec73de7cab666ef011217c98918441d2d7
4
- data.tar.gz: 407191578301b2dabb6db984f3e039a76a3a81e6d8bc305df705526154bcd5ca
3
+ metadata.gz: ee0ad9dfc1b1845db07b8d94510214d98be20b7d732e0909dfe1935c046e9a34
4
+ data.tar.gz: 60f04cbd3e7531c45357c546d490851b8b781f0224468c2d2c81d9e3e550575f
5
5
  SHA512:
6
- metadata.gz: 3517ded3340511228c488a66a19885bce82c20dfbddcea85ab43dcceb8a92b17accb2124bb87381f671bbbaa3955089d6e8e47f499677b77021acf33108fc2a6
7
- data.tar.gz: 28598c41ae1c8ffef3e698c462983e05438ef6bc0f8f1f7ed27da03c5f09a8c10a99896e51568793f8578f553ee5907052737144769226097384dc2439fb14da
6
+ metadata.gz: 70072f8f40350f2341e230f2cee198c72872b418eda5e1682e7ab1cdb7fac5c5121386a6e53d3d0c3995139b80797ec51783f0630a9844d948cc8fd79afa7f19
7
+ data.tar.gz: c56237be3e22069ade32d6ad81d9a989c78759dc9d3ff8a99150709958da55f942707670aa2b7aad05f35d9dcbc9e9d073a01f47079f8deefbb7d42902725a77
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@4.6.0
3
+ ruby-rails: sul-dlss/ruby-rails@4.8.0
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.116.0)
4
+ cocina-models (0.118.0)
5
5
  activesupport
6
6
  deprecation
7
7
  dry-struct (~> 1.0)
@@ -19,7 +19,7 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- activesupport (8.1.2)
22
+ activesupport (8.1.3)
23
23
  base64
24
24
  bigdecimal
25
25
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -32,12 +32,10 @@ GEM
32
32
  securerandom (>= 0.3)
33
33
  tzinfo (~> 2.0, >= 2.0.5)
34
34
  uri (>= 0.13.1)
35
- addressable (2.8.9)
36
- public_suffix (>= 2.0.2, < 8.0)
37
35
  ast (2.4.3)
38
36
  attr_extras (7.1.0)
39
37
  base64 (0.3.0)
40
- bigdecimal (4.0.1)
38
+ bigdecimal (4.1.2)
41
39
  concurrent-ruby (1.3.6)
42
40
  connection_pool (3.0.2)
43
41
  date (3.5.1)
@@ -75,21 +73,18 @@ GEM
75
73
  activesupport (>= 3.0, < 9.0)
76
74
  equivalent-xml (0.6.0)
77
75
  nokogiri (>= 1.4.3)
78
- erb (6.0.2)
76
+ erb (6.0.4)
79
77
  hana (1.3.7)
80
78
  i18n (1.14.8)
81
79
  concurrent-ruby (~> 1.0)
82
80
  ice_nine (0.11.2)
83
81
  io-console (0.8.2)
84
- irb (1.17.0)
82
+ irb (1.18.0)
85
83
  pp (>= 0.6.0)
86
84
  prism (>= 1.3.0)
87
85
  rdoc (>= 4.0.0)
88
86
  reline (>= 0.4.2)
89
- json (2.19.2)
90
- json-schema (6.2.0)
91
- addressable (~> 2.8)
92
- bigdecimal (>= 3.1, < 5)
87
+ json (2.19.5)
93
88
  json_schemer (2.5.0)
94
89
  bigdecimal
95
90
  hana (~> 1.3)
@@ -100,19 +95,17 @@ GEM
100
95
  language_server-protocol (3.17.0.5)
101
96
  lint_roller (1.1.0)
102
97
  logger (1.7.0)
103
- mcp (0.8.0)
104
- json-schema (>= 4.1)
105
- minitest (6.0.2)
98
+ minitest (6.0.6)
106
99
  drb (~> 2.0)
107
100
  prism (~> 1.5)
108
- multi_json (1.19.1)
109
- nokogiri (1.19.1-arm64-darwin)
101
+ multi_json (1.21.1)
102
+ nokogiri (1.19.3-arm64-darwin)
110
103
  racc (~> 1.4)
111
- nokogiri (1.19.1-x86_64-linux-gnu)
104
+ nokogiri (1.19.3-x86_64-linux-gnu)
112
105
  racc (~> 1.4)
113
106
  optimist (3.2.1)
114
- parallel (1.27.0)
115
- parser (3.3.10.2)
107
+ parallel (2.1.0)
108
+ parser (3.3.11.1)
116
109
  ast (~> 2.4.1)
117
110
  racc
118
111
  patience_diff (1.2.0)
@@ -124,15 +117,14 @@ GEM
124
117
  psych (5.3.1)
125
118
  date
126
119
  stringio
127
- public_suffix (7.0.5)
128
120
  racc (1.8.1)
129
121
  rainbow (3.1.1)
130
- rake (13.3.1)
122
+ rake (13.4.2)
131
123
  rdoc (7.2.0)
132
124
  erb
133
125
  psych (>= 4.0.0)
134
126
  tsort
135
- regexp_parser (2.11.3)
127
+ regexp_parser (2.12.0)
136
128
  reline (0.6.3)
137
129
  io-console (~> 0.5)
138
130
  rspec (3.13.2)
@@ -150,12 +142,11 @@ GEM
150
142
  rspec-support (3.13.7)
151
143
  rspec_junit_formatter (0.6.0)
152
144
  rspec-core (>= 2, < 4, != 2.12.0)
153
- rubocop (1.85.1)
145
+ rubocop (1.86.2)
154
146
  json (~> 2.3)
155
147
  language_server-protocol (~> 3.17.0.2)
156
148
  lint_roller (~> 1.1.0)
157
- mcp (~> 0.6)
158
- parallel (~> 1.10)
149
+ parallel (>= 1.10)
159
150
  parser (>= 3.3.0.2)
160
151
  rainbow (>= 2.2.2, < 4.0)
161
152
  regexp_parser (>= 2.9.3, < 3.0)
@@ -181,10 +172,10 @@ GEM
181
172
  simplecov_json_formatter (0.1.4)
182
173
  simpleidn (0.2.3)
183
174
  stringio (3.2.0)
184
- super_diff (0.18.0)
185
- attr_extras (>= 6.2.4)
186
- diff-lcs
187
- patience_diff
175
+ super_diff (0.19.0)
176
+ attr_extras (>= 6.2.4, < 8)
177
+ diff-lcs (~> 1.5)
178
+ patience_diff (~> 1.2)
188
179
  thor (1.5.0)
189
180
  tsort (0.2.0)
190
181
  tzinfo (2.0.6)
@@ -193,7 +184,7 @@ GEM
193
184
  unicode-emoji (~> 4.1)
194
185
  unicode-emoji (4.2.0)
195
186
  uri (1.1.1)
196
- zeitwerk (2.7.5)
187
+ zeitwerk (2.8.2)
197
188
 
198
189
  PLATFORMS
199
190
  arm64-darwin
@@ -213,13 +204,13 @@ DEPENDENCIES
213
204
  simplecov
214
205
 
215
206
  CHECKSUMS
216
- activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
217
- addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
207
+ activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
218
208
  ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
219
209
  attr_extras (7.1.0) sha256=d96fc9a9dd5d85ba2d37762440a816f840093959ae26bb90da994c2d9f1fc827
220
210
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
221
- bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
222
- cocina-models (0.116.0)
211
+ bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
212
+ bundler (4.0.12) sha256=7f8b757d28dfb636e7b24fba2344ac6dd13b5b24f4b46d62573d483f211825ac
213
+ cocina-models (0.118.0)
223
214
  concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
224
215
  connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
225
216
  date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
@@ -235,38 +226,35 @@ CHECKSUMS
235
226
  dry-types (1.9.1) sha256=baebeecdb9f8395d6c9d227b62011279440943e3ef2468fe8ccc1ba11467f178
236
227
  edtf (3.2.0) sha256=a15a0ee274e49c8047a3ebb5d61d793ba44f7f8ffbf0595392c467e3ea8d2447
237
228
  equivalent-xml (0.6.0) sha256=8919761efa848ad0846369ff8be1f646b17e5061698c4867b09829000cc3f487
238
- erb (6.0.2) sha256=9fe6264d44f79422c87490a1558479bd0e7dad4dd0e317656e67ea3077b5242b
229
+ erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
239
230
  hana (1.3.7) sha256=5425db42d651fea08859811c29d20446f16af196308162894db208cac5ce9b0d
240
231
  i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
241
232
  ice_nine (0.11.2) sha256=5d506a7d2723d5592dc121b9928e4931742730131f22a1a37649df1c1e2e63db
242
233
  io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
243
- irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae
244
- json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
245
- json-schema (6.2.0) sha256=e8bff46ed845a22c1ab2bd0d7eccf831c01fe23bb3920caa4c74db4306813666
234
+ irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
235
+ json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59
246
236
  json_schemer (2.5.0) sha256=2f01fb4cce721a4e08dd068fc2030cffd0702a7f333f1ea2be6e8991f00ae396
247
237
  jsonpath (1.1.5) sha256=29f70467193a2dc93ab864ec3d3326d54267961acc623f487340eb9c34931dbe
248
238
  language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
249
239
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
250
240
  logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
251
- mcp (0.8.0) sha256=ae8bd146bb8e168852866fd26f805f52744f6326afb3211e073f78a95e0c34fb
252
- minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
253
- multi_json (1.19.1) sha256=7aefeff8f2c854bf739931a238e4aea64592845e0c0395c8a7d2eea7fdd631b7
254
- nokogiri (1.19.1-arm64-darwin) sha256=dfe2d337e6700eac47290407c289d56bcf85805d128c1b5a6434ddb79731cb9e
255
- nokogiri (1.19.1-x86_64-linux-gnu) sha256=1a4902842a186b4f901078e692d12257678e6133858d0566152fe29cdb98456a
241
+ minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
242
+ multi_json (1.21.1) sha256=e6126a31808e3b4d19f483c775ceac34df190dffa62adfb63a165ee14ba68080
243
+ nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42
244
+ nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976
256
245
  optimist (3.2.1) sha256=8cf8a0fd69f3aa24ab48885d3a666717c27bc3d9edd6e976e18b9d771e72e34e
257
- parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
258
- parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
246
+ parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
247
+ parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
259
248
  patience_diff (1.2.0) sha256=f492094486af02fff4a80070fa6b4d0ebbcf4d42fb38bba29d095eef43f6822c
260
249
  pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6
261
250
  prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
262
251
  prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
263
252
  psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974
264
- public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
265
253
  racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
266
254
  rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
267
- rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
255
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
268
256
  rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
269
- regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
257
+ regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
270
258
  reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
271
259
  rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
272
260
  rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
@@ -274,7 +262,7 @@ CHECKSUMS
274
262
  rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
275
263
  rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
276
264
  rspec_junit_formatter (0.6.0) sha256=40dde674e6ae4e6cc0ff560da25497677e34fefd2338cc467a8972f602b62b15
277
- rubocop (1.85.1) sha256=3dbcf9e961baa4c376eeeb2a03913dca5e3987033b04d38fa538aa1e7406cc77
265
+ rubocop (1.86.2) sha256=bb2e97f635eda42c448f2588f4a6ff78f221b8bdfdf65b1e9b07fbd57521b45d
278
266
  rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
279
267
  rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
280
268
  rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
@@ -285,14 +273,14 @@ CHECKSUMS
285
273
  simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
286
274
  simpleidn (0.2.3) sha256=08ce96f03fa1605286be22651ba0fc9c0b2d6272c9b27a260bc88be05b0d2c29
287
275
  stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
288
- super_diff (0.18.0) sha256=9f5e77464fa75150619f7783174fbbe1bbac50a1eaf157cd39ad5584b0eac142
276
+ super_diff (0.19.0) sha256=c35fc1c0daa223d67b203fe3fb49a6cfd67850a53920319565c3c654e03ec902
289
277
  thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
290
278
  tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
291
279
  tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
292
280
  unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
293
281
  unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
294
282
  uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
295
- zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd
283
+ zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12
296
284
 
297
285
  BUNDLED WITH
298
- 4.0.8
286
+ 4.0.12
data/README.md CHANGED
@@ -16,6 +16,10 @@ For more about the model for description see https://consul.stanford.edu/display
16
16
 
17
17
  The [schema.json](schema.json) can also be viewed via JSON HERO: https://jsonhero.io/j/rynNH3NLBhcf and DOR Services App's openapi.yml: https://sul-dlss.github.io/dor-services-app/
18
18
 
19
+ ### Schema Design
20
+
21
+ Our JSON Schema uses *terminal & mixin* composition strategy so we can enforce deep validation without running into **allOf** composition pitfalls. Terminal schemas (e.g., **DRO**, **Collection**, **AdminPolicy**, their **WithMetadata** variants, and **Request** variants) are the validation boundaries and generally set the `unevaluatedProperties: false` property. Reusable mixins (e.g., **DROMixin**, **CollectionMixin**, **AdminPolicyMixin**, and **AccessMixin**) are intentionally open and are composed into terminal schemas via **allOf** or **oneOf**, so these schemas **may not** take advantage of `unevaluatedProperties` to prevent unexpected properties.
22
+
19
23
  ## Configuration
20
24
 
21
25
  Set the PURL url base:
@@ -121,9 +125,7 @@ Before you release a major or minor change, think about if this release will inc
121
125
  If unsure, ask the team or ask for help to just run the validation report anyway (as described above).
122
126
 
123
127
  ### Partial release process
124
- NOTE: If dependency updates are about to be released, you have the option of shortening the process and stopping after Step 3. This is because Steps 4 onwards will be taken care of by the regular dependency updates process (basically the updating of cocina-models, dor-services-client and sdr-client as needed in the rest of the associated apps). You still do need to manually bump some gems and the pinned version of cocina-models in the directly coupled apps and get those PRs approved and merged, as described in Steps 1-3 below.
125
-
126
- IMPORTANT: If you do opt to skip steps 4 onward, you should NOT merge the dor-services-app and sdr-api PRs you created in step 3 until you are ready to finish the dependency updates process. You can have them reviewed and approved, but if you merge, you will greatly increase the risk of issues if the main branch of DSA or sdr-api are deployed after steps 1-3 are complete but before the rest of the apps are updated to use the new cocina-models via regular dependency updates. The fix for this is to either roll back DSA and sdr-api to the previous release tag, or proceed forwards with step 4-5.
128
+ NOTE: If dependency updates are about to be released, you have the option of shortening the process and stopping after Step 2. This is because Steps 3 onwards will be taken care of by the regular dependency updates process (basically the updating of cocina-models, dor-services-client and sdr-client as needed in the rest of the associated apps). You still do need to manually bump some gems and get those PRs approved and merged, as described in Steps 1-2 below.
127
129
 
128
130
  ### Step 0: Share intent to change the models
129
131
 
@@ -160,8 +162,6 @@ Perform `bundle update --conservative cocina-models dor-services-client` in the
160
162
 
161
163
  Get the directly coupled services PRs merged before the deploy in step 5.
162
164
 
163
- See the IMPORTANT note above about the timing of merging these PRs if you are waiting for dependency updates to make the updates to other dependent applications.
164
-
165
165
  ### Step 4: Update other dependent applications
166
166
 
167
167
  All applications that use cocina-models should be updated and released at the same time. "Cocina Level 2" describes this set of updates. The applications that use cocina-models are those in [this list](https://github.com/sul-dlss/access-update-scripts/blob/master/infrastructure/projects.yml) that are NOT marked with `cocina_level2: false`.
@@ -102,8 +102,10 @@ module Cocina
102
102
  end
103
103
 
104
104
  def schema_for(schema_name, lite: false)
105
+ return if schema_name.ends_with?('Mixin')
106
+
105
107
  schema_doc = schemas[schema_name]
106
- return nil if schema_doc.nil?
108
+ return if schema_doc.nil?
107
109
 
108
110
  case schema_doc.type
109
111
  when 'object'
@@ -5,21 +5,25 @@ module Cocina
5
5
  # Class for generating from a JSON schema
6
6
  class Schema < SchemaBase
7
7
  def schema_properties
8
- @schema_properties ||= (properties + all_of_properties + one_of_properties).uniq(&:key)
8
+ @schema_properties ||= (
9
+ schema_properties_for(schema_doc) +
10
+ all_of_properties_for(schema_doc) +
11
+ one_of_properties_for(schema_doc)
12
+ ).uniq(&:key)
9
13
  end
10
14
 
11
- VALIDATE_TYPES = %w[DRO RequestDRO DROWithMetadata Collection RequestCollection CollectionWithMetadata AdminPolicy
12
- RequestAdminPolicy AdminPolicyWithMetadata Description RequestDescription].freeze
15
+ VALIDATABLE_TYPES = %w[DRO RequestDRO DROWithMetadata Collection RequestCollection CollectionWithMetadata AdminPolicy
16
+ RequestAdminPolicy AdminPolicyWithMetadata Description RequestDescription].freeze
13
17
 
14
18
  def generate
15
19
  <<~RUBY
16
20
  # frozen_string_literal: true
17
21
 
18
22
  module Cocina
19
- module Models#{' '}
23
+ module Models
20
24
  #{preamble}class #{name} < Struct
21
25
 
22
- #{validate}
26
+ #{validatable}
23
27
  #{types}
24
28
 
25
29
  #{model_attributes}
@@ -65,68 +69,41 @@ module Cocina
65
69
  RUBY
66
70
  end
67
71
 
68
- def validate
69
- return '' unless validatable?
72
+ def validatable
73
+ return '' if VALIDATABLE_TYPES.exclude?(name)
70
74
 
71
75
  <<~RUBY
72
76
  include Validatable
73
77
  RUBY
74
78
  end
75
79
 
76
- def validatable?
77
- VALIDATE_TYPES.include?(name) && !lite
78
- end
79
-
80
- def properties
81
- schema_properties_for(schema_doc)
82
- end
83
-
84
- def all_of_properties
85
- all_of_properties_for(schema_doc)
86
- end
87
-
88
- def one_of_properties
89
- one_of_properties_for(schema_doc)
90
- end
91
-
92
80
  def all_of_properties_for(doc)
93
- return [] if doc.all_of.nil?
94
-
95
- doc.all_of.map do |all_of_schema|
96
- # All of for this + recurse
81
+ Array(doc.all_of).flat_map do |all_of_schema|
97
82
  schema_properties_for(all_of_schema) +
98
83
  all_of_properties_for(all_of_schema) +
99
84
  one_of_properties_for(all_of_schema)
100
- end.flatten
85
+ end
101
86
  end
102
87
 
103
88
  def one_of_properties_for(doc)
104
- return [] if doc.one_of.nil?
105
-
106
- # All properties must be objects.
107
- raise 'All properties for oneOf must be objects' unless doc.one_of.all? { |schema| schema.type == 'object' }
108
-
109
- doc.one_of.flat_map do |one_of_doc|
110
- one_of_doc.properties.map do |key, properties_doc|
111
- property_class_for(properties_doc).new(properties_doc,
112
- key: key,
113
- # The property does less validation because may vary between
114
- # different oneOf schemas. Validation is still performed
115
- # by JSON Schema.
116
- relaxed: true,
117
- parent: self,
118
- schemas: schemas)
119
- end
89
+ Array(doc.one_of).flat_map do |one_of_schema|
90
+ schema_properties_for(one_of_schema, relaxed: true) +
91
+ all_of_properties_for(one_of_schema) +
92
+ one_of_properties_for(one_of_schema)
120
93
  end
121
94
  end
122
95
 
123
- def schema_properties_for(doc)
96
+ def schema_properties_for(doc, relaxed: nil)
97
+ relax_all_properties = relaxed
98
+
124
99
  Array(doc.properties).map do |key, properties_doc|
125
100
  clazz = property_class_for(properties_doc)
101
+ relaxed = relax_all_properties.nil? ? lite && clazz != SchemaValue : relax_all_properties
102
+
126
103
  clazz.new(properties_doc,
127
104
  key: key,
128
105
  required: doc.required&.include?(key),
129
- relaxed: lite && clazz != SchemaValue,
106
+ relaxed: relaxed,
130
107
  nullable: Array(properties_doc.type).include?('null'),
131
108
  parent: self,
132
109
  schemas: schemas)
@@ -3,6 +3,6 @@
3
3
  module Cocina
4
4
  module Models
5
5
  # A barcode
6
- Barcode = BusinessBarcode | LaneMedicalBarcode | CatkeyBarcode | StandardBarcode
6
+ Barcode = BusinessBarcode | LaneMedicalBarcode | CatkeyBarcode | StandardBarcode | CaliforniaHistoricalSocietyBarcode
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # The barcode associated with a business library DRO object, prefixed with 2050
5
+ # The barcode associated with a business library DRO, prefixed with 2050
6
6
  # example: 20503740296
7
7
  BusinessBarcode = Types::String.constrained(format: /^2050[0-9]{7}$/)
8
8
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # The barcode associated with a CHS DRO, prefixed with 405
6
+ # example: 405000111956
7
+ CaliforniaHistoricalSocietyBarcode = Types::String.constrained(format: /^405[0-9]+$/)
8
+ end
9
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # The barcode associated with a DRO object based on catkey, prefixed with a catkey
6
- # followed by a hyphen
5
+ # The barcode associated with a DRO based on catkey, prefixed with a catkey followed
6
+ # by a hyphen
7
7
  # example: 6772719-1001
8
8
  CatkeyBarcode = Types::String.constrained(format: /^[0-9]+-[0-9]+$/)
9
9
  end
@@ -4,6 +4,7 @@ module Cocina
4
4
  module Models
5
5
  # Default value model for descriptive elements.
6
6
  class DescriptiveValue < Struct
7
+ attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
7
8
  attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
9
  attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
10
  attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
@@ -40,7 +41,6 @@ module Cocina
40
41
  attribute? :valueLanguage, DescriptiveValueLanguage.optional
41
42
  # URL or other pointer to the location of the value of the descriptive element.
42
43
  attribute? :valueAt, Types::Strict::String
43
- attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
44
44
  end
45
45
  end
46
46
  end
@@ -3,17 +3,6 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DROAccess < Struct
6
- # Access level.
7
- # Validation of this property is relaxed. See the schema.json for full validation.
8
- attribute? :view, Types::Strict::String.optional.default('dark')
9
- # Download access level.
10
- # Validation of this property is relaxed. See the schema.json for full validation.
11
- attribute? :download, Types::Strict::String.optional.default('none')
12
- # Not used for this access type, must be null.
13
- # Validation of this property is relaxed. See the schema.json for full validation.
14
- attribute? :location, Types::Strict::String.optional
15
- # Validation of this property is relaxed. See the schema.json for full validation.
16
- attribute? :controlledDigitalLending, Types::Strict::Bool.optional.default(false)
17
6
  # The human readable copyright statement that applies
18
7
  # example: Copyright World Trade Organization
19
8
  attribute? :copyright, Copyright.optional
@@ -27,6 +16,17 @@ module Cocina
27
16
  # The license governing reuse of the DRO. Should be an IRI for known licenses (i.e.
28
17
  # CC, RightsStatement.org URI, etc.).
29
18
  attribute? :license, License.optional.enum(nil, 'https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'https://cocina.sul.stanford.edu/licenses/none')
19
+ # Access level.
20
+ # Validation of this property is relaxed. See the schema.json for full validation.
21
+ attribute? :view, Types::Strict::String.optional.default('dark')
22
+ # Download access level.
23
+ # Validation of this property is relaxed. See the schema.json for full validation.
24
+ attribute? :download, Types::Strict::String.optional.default('none')
25
+ # Not used for this access type, must be null.
26
+ # Validation of this property is relaxed. See the schema.json for full validation.
27
+ attribute? :location, Types::Strict::String.optional
28
+ # Validation of this property is relaxed. See the schema.json for full validation.
29
+ attribute? :controlledDigitalLending, Types::Strict::Bool.optional.default(false)
30
30
  end
31
31
  end
32
32
  end
@@ -3,6 +3,15 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Embargo < Struct
6
+ # Date when the Collection is released from an embargo.
7
+ # example: 2029-06-22T07:00:00.000+00:00
8
+ attribute :releaseDate, Types::Params::DateTime
9
+ # The human readable use and reproduction statement that applies
10
+ # example: Property rights reside with the repository. Literary rights reside with
11
+ # the creators of the documents or their heirs. To obtain permission to publish or
12
+ # reproduce, please contact the Public Services Librarian of the Dept. of Special Collections
13
+ # (http://library.stanford.edu/spc).
14
+ attribute? :useAndReproductionStatement, UseAndReproductionStatement.optional
6
15
  # Access level.
7
16
  # Validation of this property is relaxed. See the schema.json for full validation.
8
17
  attribute? :view, Types::Strict::String.optional.default('dark')
@@ -14,15 +23,6 @@ module Cocina
14
23
  attribute? :location, Types::Strict::String.optional
15
24
  # Validation of this property is relaxed. See the schema.json for full validation.
16
25
  attribute? :controlledDigitalLending, Types::Strict::Bool.optional.default(false)
17
- # Date when the Collection is released from an embargo.
18
- # example: 2029-06-22T07:00:00.000+00:00
19
- attribute :releaseDate, Types::Params::DateTime
20
- # The human readable use and reproduction statement that applies
21
- # example: Property rights reside with the repository. Literary rights reside with
22
- # the creators of the documents or their heirs. To obtain permission to publish or
23
- # reproduce, please contact the Public Services Librarian of the Dept. of Special Collections
24
- # (http://library.stanford.edu/spc).
25
- attribute? :useAndReproductionStatement, UseAndReproductionStatement.optional
26
26
  end
27
27
  end
28
28
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # The barcode associated with a Lane Medical Library DRO object, prefixed with 245
5
+ # The barcode associated with a Lane Medical Library DRO, prefixed with 245
6
6
  # example: 24503259768
7
7
  LaneMedicalBarcode = Types::String.constrained(format: /^245[0-9]{8}$/)
8
8
  end
@@ -394,13 +394,14 @@ module Cocina
394
394
  end
395
395
 
396
396
  def blank_ng_xml
397
- Nokogiri::XML(<<~XML
398
- <mods xmlns="http://www.loc.gov/mods/v3"#{' '}
399
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"#{' '}
400
- version="3.6"#{' '}
401
- xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd" />
402
- XML
403
- )
397
+ Nokogiri::XML(
398
+ <<~XML
399
+ <mods xmlns="http://www.loc.gov/mods/v3"
400
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
401
+ version="3.6"
402
+ xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd" />
403
+ XML
404
+ )
404
405
  end
405
406
  end
406
407
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- # The standard barcode associated with a DRO object, prefixed with 36105
5
+ # The standard barcode associated with a DRO, prefixed with 36105
6
6
  # example: 36105010362304
7
7
  StandardBarcode = Types::String.constrained(format: /^36105[0-9]{9}$/)
8
8
  end
@@ -3,6 +3,7 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Title < Struct
6
+ attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
6
7
  attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
8
  attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
9
  attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
@@ -39,7 +40,6 @@ module Cocina
39
40
  attribute? :valueLanguage, DescriptiveValueLanguage.optional
40
41
  # URL or other pointer to the location of the value of the descriptive element.
41
42
  attribute? :valueAt, Types::Strict::String
42
- attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
43
43
  end
44
44
  end
45
45
  end