cocina-models 0.64.0 → 0.66.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9539fc314563e23d96f0f90cf2a97eca07ebbc2a63e9678581530a2cd7843396
4
- data.tar.gz: 2a8d73a4d425dd4ad399431108e987590cc9aea97515aeb77edc7c49758fb4d5
3
+ metadata.gz: def07c3b758899fb7dafda2ab26d7376318137895cb1335ab22404ab939e6e15
4
+ data.tar.gz: cb8f57478510d3f40a9241e944484437889dbf4b0b09e992696da7b9d1e595c1
5
5
  SHA512:
6
- metadata.gz: 447c58bbc28217dabd2664a23527eeedfa5588684700316b5507735d9d832e8905fbf9177f1918a1abb30d2cc4ce693e4d111cb47631d0f579a3fe7a780275cf
7
- data.tar.gz: 61d83471e7b68292b2c945bbfb07d47d3bf179b40552b03e190eda1cf5915d7569606e6873275fdd327542e7c1d0767903797cd1c73d2c08241c8aa9ed0af33a
6
+ metadata.gz: 1de2f3d0703139311d8f58f1ec24b5b579b330c0461c645ebe76d153930ab91850d694a2b7a138a8ee6c63ee8ba5562f6c24ff044a7dd0bf40355eb1007afd51
7
+ data.tar.gz: ecdfd2b784a0e42c30e348d08dbe7a6f092c369d7830dd86b11c2ff8185fef4238068fdc4b5e7fe8af90d1d9477e17436d03fde5058855d97819a7270ebc304e
@@ -1,11 +1,12 @@
1
1
  **NOTE: Changes to openapi.yml require updating openapi.yml for sdr-api and dor-services-app and generating models - see README.**
2
2
 
3
- ## Why was this change made?
3
+ ## Why was this change made? 🤔
4
4
 
5
5
 
6
6
 
7
- ## How was this change tested?
7
+ ## How was this change tested? 🤨
8
+
9
+ ⚡ ⚠ If this change has cross service impact, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test)*** and/or test in [stage|qa] environment, in addition to specs. ⚡
8
10
 
9
11
 
10
12
 
11
- ## Which documentation and/or configurations were updated?
@@ -76,6 +76,7 @@ module Cocina
76
76
  run("rubocop -a #{filepath} > /dev/null")
77
77
  end
78
78
 
79
+ # rubocop:disable Metrics/AbcSize
79
80
  def clean_output
80
81
  FileUtils.mkdir_p(options[:output])
81
82
  files = Dir.glob("#{options[:output]}/*.rb")
@@ -83,8 +84,10 @@ module Cocina
83
84
  files.delete("#{options[:output]}/version.rb")
84
85
  files.delete("#{options[:output]}/checkable.rb")
85
86
  files.delete("#{options[:output]}/validator.rb")
87
+ files.delete("#{options[:output]}/validatable.rb")
86
88
  FileUtils.rm_f(files)
87
89
  end
90
+ # rubocop:enable Metrics/AbcSize
88
91
  end
89
92
  end
90
93
  end
@@ -16,11 +16,10 @@ module Cocina
16
16
  module Models
17
17
  class #{name} < Struct
18
18
 
19
+ #{validate}
19
20
  #{types}
20
21
 
21
22
  #{model_attributes}
22
-
23
- #{validate}
24
23
  end
25
24
  end
26
25
  end
@@ -64,10 +63,7 @@ module Cocina
64
63
  return '' unless validatable?
65
64
 
66
65
  <<~RUBY
67
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
68
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
69
- super(attributes, safe, &block)
70
- end
66
+ include Validatable
71
67
  RUBY
72
68
  end
73
69
 
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class AdminPolicy < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
@@ -17,11 +19,6 @@ module Cocina
17
19
  attribute :version, Types::Strict::Integer
18
20
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
19
21
  attribute :description, Description.optional.meta(omittable: true)
20
-
21
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
22
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
23
- super(attributes, safe, &block)
24
- end
25
22
  end
26
23
  end
27
24
  end
@@ -3,8 +3,6 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class AdminPolicyAdministrative < Struct
6
- # This is an XML expression of the default access (see defaultAccess)
7
- attribute :defaultObjectRights, Types::Strict::String.default('<?xml version="1.0" encoding="UTF-8"?><rightsMetadata><access type="discover"><machine><world/></machine></access><access type="read"><machine><world/></machine></access><use><human type="useAndReproduction"/><human type="creativeCommons"/><machine type="creativeCommons" uri=""/><human type="openDataCommons"/><machine type="openDataCommons" uri=""/></use><copyright><human/></copyright></rightsMetadata>').meta(omittable: true)
8
6
  attribute :defaultAccess, AdminPolicyDefaultAccess.optional.meta(omittable: true)
9
7
  attribute :registrationWorkflow, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
10
8
  # An additional workflow to start for objects managed by this admin policy once the end-accession workflow step is complete
@@ -15,8 +13,6 @@ module Cocina
15
13
  attribute :hasAdminPolicy, Types::Strict::String
16
14
  # example: druid:bc123df4567
17
15
  attribute :hasAgreement, Types::Strict::String
18
- # example: druid:bc123df4567
19
- attribute :referencesAgreement, Types::Strict::String.meta(omittable: true)
20
16
  attribute :roles, Types::Strict::Array.of(AccessRole).default([].freeze)
21
17
  end
22
18
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Collection < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/collection.jsonld',
@@ -26,11 +28,6 @@ module Cocina
26
28
  attribute :administrative, Administrative.optional.meta(omittable: true)
27
29
  attribute :description, Description.optional.meta(omittable: true)
28
30
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
29
-
30
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
31
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
32
- super(attributes, safe, &block)
33
- end
34
31
  end
35
32
  end
36
33
  end
@@ -10,9 +10,9 @@ module Cocina
10
10
  attribute :copyright, Types::Strict::String.optional.meta(omittable: true)
11
11
  # The human readable use and reproduction statement that applies
12
12
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
13
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
13
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
14
14
  # The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
15
- attribute :license, Types::Strict::String.meta(omittable: true)
15
+ attribute :license, Types::Strict::String.optional.meta(omittable: true)
16
16
  end
17
17
  end
18
18
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Description < Struct
6
+ include Validatable
7
+
6
8
  attribute :title, Types::Strict::Array.of(Title).default([].freeze)
7
9
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
8
10
  attribute :event, Types::Strict::Array.of(Event).default([].freeze)
@@ -20,11 +22,6 @@ module Cocina
20
22
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
21
23
  # Stanford persistent URL associated with the related resource. Note this is http, not https.
22
24
  attribute :purl, Types::Strict::String
23
-
24
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
25
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
26
- super(attributes, safe, &block)
27
- end
28
25
  end
29
26
  end
30
27
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DRO < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/object.jsonld',
@@ -38,11 +40,6 @@ module Cocina
38
40
  attribute :identification, Identification.optional.meta(omittable: true)
39
41
  attribute :structural, DROStructural.optional.meta(omittable: true)
40
42
  attribute :geographic, Geographic.optional.meta(omittable: true)
41
-
42
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
43
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
44
- super(attributes, safe, &block)
45
- end
46
43
  end
47
44
  end
48
45
  end
@@ -20,9 +20,9 @@ module Cocina
20
20
  attribute :embargo, Embargo.optional.meta(omittable: true)
21
21
  # The human readable use and reproduction statement that applies
22
22
  # example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
23
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
23
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
24
24
  # The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
25
- attribute :license, Types::Strict::String.enum('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', 'http://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
25
+ attribute :license, Types::Strict::String.optional.enum('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', 'http://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
26
26
  end
27
27
  end
28
28
  end
@@ -19,7 +19,7 @@ module Cocina
19
19
  attribute :releaseDate, Types::Params::DateTime
20
20
  # The human readable use and reproduction statement that applies when the embargo expires.
21
21
  # example: These materials are in the public domain.
22
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
22
+ attribute :useAndReproductionStatement, Types::Strict::String.optional.meta(omittable: true)
23
23
  end
24
24
  end
25
25
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestAdminPolicy < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
@@ -15,11 +17,6 @@ module Cocina
15
17
  attribute :version, Types::Strict::Integer
16
18
  attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
17
19
  attribute :description, RequestDescription.optional.meta(omittable: true)
18
-
19
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
20
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
21
- super(attributes, safe, &block)
22
- end
23
20
  end
24
21
  end
25
22
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestCollection < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/collection.jsonld',
@@ -21,11 +23,6 @@ module Cocina
21
23
  attribute(:administrative, Administrative.default { Administrative.new })
22
24
  attribute :description, RequestDescription.optional.meta(omittable: true)
23
25
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
24
-
25
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
26
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
27
- super(attributes, safe, &block)
28
- end
29
26
  end
30
27
  end
31
28
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestDescription < Struct
6
+ include Validatable
7
+
6
8
  attribute :title, Types::Strict::Array.of(Title).default([].freeze)
7
9
  attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
8
10
  attribute :event, Types::Strict::Array.of(Event).default([].freeze)
@@ -18,11 +20,6 @@ module Cocina
18
20
  attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
19
21
  # URL or other pointer to the location of the resource description.
20
22
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
21
-
22
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
23
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
24
- super(attributes, safe, &block)
25
- end
26
23
  end
27
24
  end
28
25
  end
@@ -3,6 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class RequestDRO < Struct
6
+ include Validatable
7
+
6
8
  include Checkable
7
9
 
8
10
  TYPES = ['http://cocina.sul.stanford.edu/models/object.jsonld',
@@ -33,11 +35,6 @@ module Cocina
33
35
  attribute(:identification, RequestIdentification.default { RequestIdentification.new })
34
36
  attribute :structural, RequestDROStructural.optional.meta(omittable: true)
35
37
  attribute :geographic, Geographic.optional.meta(omittable: true)
36
-
37
- def self.new(attributes = default_attributes, safe = false, validate = true, &block)
38
- Validator.validate(self, attributes.with_indifferent_access) if validate && name
39
- super(attributes, safe, &block)
40
- end
41
38
  end
42
39
  end
43
40
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # Validate upon construction
6
+ module Validatable
7
+ extend ActiveSupport::Concern
8
+
9
+ class_methods do
10
+ def new(attributes = default_attributes, safe = false, validate = true, &block)
11
+ Validator.validate(self, attributes.with_indifferent_access) if validate && name
12
+ super(attributes, safe, &block)
13
+ end
14
+ end
15
+
16
+ def new(*args)
17
+ validate = args.first.delete(:validate) if args.present?
18
+ new_model = super(*args)
19
+ Validator.validate(new_model.class, new_model.to_h) if (validate || validate.nil?) && self.class.name
20
+ new_model
21
+ end
22
+ end
23
+ end
24
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.64.0'
5
+ VERSION = '0.66.0'
6
6
  end
7
7
  end
data/openapi.yml CHANGED
@@ -212,11 +212,6 @@ components:
212
212
  type: object
213
213
  additionalProperties: false
214
214
  properties:
215
- defaultObjectRights:
216
- type: string
217
- description: This is an XML expression of the default access (see defaultAccess)
218
- deprecated: true
219
- default: <?xml version="1.0" encoding="UTF-8"?><rightsMetadata><access type="discover"><machine><world/></machine></access><access type="read"><machine><world/></machine></access><use><human type="useAndReproduction"/><human type="creativeCommons"/><machine type="creativeCommons" uri=""/><human type="openDataCommons"/><machine type="openDataCommons" uri=""/></use><copyright><human/></copyright></rightsMetadata>
220
215
  defaultAccess:
221
216
  $ref: '#/components/schemas/AdminPolicyDefaultAccess'
222
217
  registrationWorkflow:
@@ -237,8 +232,6 @@ components:
237
232
  $ref: '#/components/schemas/Druid'
238
233
  hasAgreement:
239
234
  $ref: '#/components/schemas/Druid'
240
- referencesAgreement:
241
- $ref: '#/components/schemas/Druid'
242
235
  roles:
243
236
  description: The access roles conferred by this AdminPolicy (used by Argo)
244
237
  type: array
@@ -443,9 +436,11 @@ components:
443
436
  description: The human readable use and reproduction statement that applies
444
437
  example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
445
438
  type: string
439
+ nullable: true
446
440
  license:
447
441
  description: The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
448
442
  type: string
443
+ nullable: true
449
444
  CollectionIdentification:
450
445
  type: object
451
446
  additionalProperties: false
@@ -917,9 +912,11 @@ components:
917
912
  description: The human readable use and reproduction statement that applies
918
913
  example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
919
914
  type: string
915
+ nullable: true
920
916
  license:
921
917
  description: The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
922
918
  type: string
919
+ nullable: true
923
920
  enum:
924
921
  - 'https://www.gnu.org/licenses/agpl.txt'
925
922
  - 'https://www.apache.org/licenses/LICENSE-2.0'
@@ -991,6 +988,7 @@ components:
991
988
  description: The human readable use and reproduction statement that applies when the embargo expires.
992
989
  example: These materials are in the public domain.
993
990
  type: string
991
+ nullable: true
994
992
  required:
995
993
  - releaseDate
996
994
  Event:
@@ -1845,6 +1843,7 @@ components:
1845
1843
  StandardBarcode:
1846
1844
  description: The standard barcode associated with a DRO object, prefixed with 36105
1847
1845
  type: string
1846
+ nullable: true
1848
1847
  pattern: '^36105[0-9]{9}$'
1849
1848
  example: '36105010362304'
1850
1849
  Title:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-26 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -338,6 +338,7 @@ files:
338
338
  - lib/cocina/models/standard_barcode.rb
339
339
  - lib/cocina/models/stanford_access.rb
340
340
  - lib/cocina/models/title.rb
341
+ - lib/cocina/models/validatable.rb
341
342
  - lib/cocina/models/validator.rb
342
343
  - lib/cocina/models/version.rb
343
344
  - lib/cocina/models/vocab.rb