cocina-models 0.58.2 → 0.59.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: 373c87def65c96c5e54fca772ded4c486a26ed1ed2ec5679e4d1f4483241d950
4
- data.tar.gz: 58fd159bc6341d831d42ffd59cb7c42ff8fb0643c87c724753e69c100ec271f4
3
+ metadata.gz: d472f28820d79530461986e33333e5992ccb186f49b87a8a1cb72c3ffb86aa3b
4
+ data.tar.gz: 19bb67df011f97b52ec3bdbbe847a2fdebabbacc1dd3a322279eedb1c73aec50
5
5
  SHA512:
6
- metadata.gz: 1ef5aec119f9230e8a274d2c97130c1c1fa421acf227f856613e7c2fb93542ef6f2af64b22e87b44448b6f428b37ba9e091bc1ed01acd16058f30329156e0d31
7
- data.tar.gz: 759e9eee67dc7fc016727e0a4954c07c9d5d1a7a36b5f0eda210b26a12550112210bd7b0b8e59f0ab45e5a57b8e685fb377abb8a78ff74777ebbdc64c474c38a
6
+ metadata.gz: ac7b48e7ea013bd36fe1dc15f1c1a6826bade90358b7c2c43697af4945d1b5e9fac44acaa08f87233609fcb5e8c53598a85b656157ad33aa96ff8baea20400fe
7
+ data.tar.gz: b260daadd1e73062df358ef214a6d0417d3b0d5f0c493ad22fe0025019822c4386f5e23bedaec6517d4678c3b766050816def14f329ca3b78f6dbca597ac3cbc
data/.rubocop.yml CHANGED
@@ -79,6 +79,8 @@ Metrics/BlockLength:
79
79
 
80
80
  Metrics/MethodLength:
81
81
  Max: 14
82
+ Exclude:
83
+ - 'spec/cocina/models/file_access_spec.rb'
82
84
 
83
85
  # ----- RSpec ------
84
86
 
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-09-08 19:05:09 UTC using RuboCop version 0.89.1.
3
+ # on 2021-04-16 17:25:55 UTC using RuboCop version 0.93.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -8,15 +8,15 @@
8
8
 
9
9
  # Offense count: 1
10
10
  # Configuration parameters: AllowedMethods.
11
- # AllowedMethods: present?, blank?, presence, try, try!
11
+ # AllowedMethods: present?, blank?, presence, try, try!, in?
12
12
  Lint/SafeNavigationChain:
13
13
  Exclude:
14
14
  - 'lib/cocina/generator/schema_base.rb'
15
15
 
16
16
  # Offense count: 1
17
- # Configuration parameters: IgnoredMethods.
18
- Metrics/CyclomaticComplexity:
19
- Max: 8
17
+ # Configuration parameters: CountKeywordArgs.
18
+ Metrics/ParameterLists:
19
+ Max: 6
20
20
 
21
21
  # Offense count: 1
22
22
  # Configuration parameters: MinBodyLength.
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  This is a Ruby implementation of the SDR data model (named "COCINA"). The data being modeled includes digital repository objects.
10
10
 
11
- Validation is performed by openapi (using OpenAPIParser). Modeling is provided by dry-struct and dry-types. Together, these provide a way for consumers to validate objects against models and to manipulate thos objects.
11
+ Validation is performed by openapi (using OpenAPIParser). Modeling is provided by dry-struct and dry-types. Together, these provide a way for consumers to validate objects against models and to manipulate those objects.
12
12
 
13
13
  This is a work in progress that will ultimately implement the full [COCINA data model](http://sul-dlss.github.io/cocina-models/). See also [architecture documentation](https://sul-dlss.github.io/taco-truck/COCINA.html#cocina-data-models--shapes).
14
14
 
@@ -34,44 +34,53 @@ Beyond what is necessary to test the generator, the Cocina model classes are not
34
34
 
35
35
  ## Releasing
36
36
 
37
+ ### Step 0: Share intent to change the models
38
+
39
+ Send a note to `#dlss-infra-chg-mgmt` on Slack to let people know what is changing and when.
40
+
41
+ ### Step 1: Cut the release
42
+
37
43
  The release process is much like any other gem. First bump the version in `lib/cocina/models/version.rb`, and commit the result. Then run:
38
44
  ```
39
45
  bundle exec rake release
40
46
  ```
41
47
  which pushes the gem to rubygems.org. Next write up the release notes: https://github.com/sul-dlss/cocina-models/releases .
42
48
 
43
- Finally, you must release versions of [sdr-client](https://github.com/sul-dlss/sdr-client) and [dor-services-client](https://github.com/sul-dlss/dor-services-client/) pinned to this version because [Argo](https://github.com/sul-dlss/argo) depends on both of those. When [dor-services-app](https://github.com/sul-dlss/dor-services-app) is updated to use the new models (via the auto-update script), the clients must be updated at the same time or there is risk of models produced by dor-services-app not being acceptable to the clients.
49
+ ### Step 2: Update client gems coupled to the models
44
50
 
45
- ### Communicate
51
+ Next, you should release versions of [sdr-client](https://github.com/sul-dlss/sdr-client) and [dor-services-client](https://github.com/sul-dlss/dor-services-client/) pinned to this version because applications such as [Argo](https://github.com/sul-dlss/argo) depend on both of these gems using the same models.
46
52
 
47
- Send a note to `#dlss-infra-chg-mgmt` on Slack to let people know what is changing and when.
53
+ ### Step 3: Update service API specifications and gems
54
+
55
+ The cocina-models gem is used in applications that have an API specification that accepts Cocina models. Next, make sure that the `openapi.yml` for these applications include the `openapi.yml` schema changes made in cocina-models. This list of services is known to include:
56
+
57
+ * [sul-dlss/sdr-api](https://github.com/sul-dlss/sdr-api)
58
+ * [sul-dlss/dor-services-app](https://github.com/sul-dlss/dor-services-app/)
48
59
 
49
- ### Dependent Services
60
+ This can be accomplished by copying and pasting these schemas. By convention, these schemas are listed first in the `openapi.yml` of the associated projects, followed by the application-specific schemas.
50
61
 
51
- Once the above listed gems are updated all the following services that use cocina-models should be updated and released at the same time:
62
+ #### Step 3b: Bump gems
52
63
 
53
- * sul-dlss/sdr-api
54
- * sul-dlss/dor-services-app
55
- * sul-dlss/google-books
56
- * sul-dlss/common-accessioning
57
- * sul-dlss/argo
58
- * sul-dlss/pre-assembly
59
- * sul-dlss/hydrus
60
- * sul-dlss/happy-heron
61
- * sul-dlss/infrastructure-integration-test
62
- * sul-dlss/dor_indexing_app
64
+ At the same, we have found it convenient to use these PRs to also bump the versions of cocina-models, sdr-client, and dor-services-client in these applications/services. Why? When [dor-services-app](https://github.com/sul-dlss/dor-services-app), for example, is updated to use the new models (via the auto-update script), these clients should be updated at the same time or there is risk of models produced by dor-services-app not being acceptable to the clients.
63
65
 
64
- ## Using this gem
66
+ ### Step 4: Update other dependent applications
65
67
 
66
- If you are using this gem in an application that has an API that accepts Cocina models (e.g., SDR API, Dor-Services-App), make sure that the `openapi.yml` for the application includes the schemas that match the schemas in this `openapi.yml`.
68
+ Once the above listed steps have been completed, all the following applications that use cocina-models should be updated and released at the same time:
67
69
 
68
- This can be accomplished by cutting and pasting these schemas. By convention, these schemas are listed first in the `openapi.yml` of the associated projects, followed by the application-specific schemas.
70
+ * [sul-dlss/dor_indexing_app](https://github.com/sul-dlss/dor_indexing_app/)
71
+ * [sul-dlss/common-accessioning](https://github.com/sul-dlss/common-accessioning/)
72
+ * [sul-dlss/google-books](https://github.com/sul-dlss/google-books/)
73
+ * [sul-dlss/argo](https://github.com/sul-dlss/argo/)
74
+ * [sul-dlss/pre-assembly](https://github.com/sul-dlss/pre-assembly/)
75
+ * [sul-dlss/hydrus](https://github.com/sul-dlss/hydrus/)
76
+ * [sul-dlss/happy-heron](https://github.com/sul-dlss/happy-heron/)
77
+ * [sul-dlss/infrastructure-integration-test](https://github.com/sul-dlss/infrastructure-integration-test/)
69
78
 
70
- ### Usage conventions
79
+ ## Usage conventions
71
80
 
72
81
  The following are the recommended naming conventions for code using Cocina models:
73
82
 
74
- * cocina_item: Cocina::Models::DRO instance
75
- * cocina_admin_policy: Cocina::Models::AdminPolicy instance
76
- * cocina_collection: Cocina::Models::Collection instance
77
- * cocina_object: Cocina::Models::DRO or Cocina::Models::AdminPolicy or Cocina::Models::Collection instance
83
+ * `cocina_item`: `Cocina::Models::DRO` instance
84
+ * `cocina_admin_policy`: `Cocina::Models::AdminPolicy` instance
85
+ * `cocina_collection`: `Cocina::Models::Collection` instance
86
+ * `cocina_object`: `Cocina::Models::DRO` or `Cocina::Models::AdminPolicy` or `Cocina::Models::Collection` instance
@@ -5,7 +5,7 @@ module Cocina
5
5
  # Class for generating from an openapi schema
6
6
  class Schema < SchemaBase
7
7
  def schema_properties
8
- @schema_properties ||= (properties + all_of_properties).uniq(&:key)
8
+ @schema_properties ||= (properties + all_of_properties + one_of_properties).uniq(&:key)
9
9
  end
10
10
 
11
11
  def generate
@@ -83,15 +83,42 @@ module Cocina
83
83
  all_of_properties_for(schema_doc)
84
84
  end
85
85
 
86
+ def one_of_properties
87
+ one_of_properties_for(schema_doc)
88
+ end
89
+
86
90
  def all_of_properties_for(doc)
87
91
  return [] if doc.all_of.nil?
88
92
 
89
93
  doc.all_of.map do |all_of_schema|
90
94
  # All of for this + recurse
91
- schema_properties_for(all_of_schema) + all_of_properties_for(all_of_schema)
95
+ schema_properties_for(all_of_schema) +
96
+ all_of_properties_for(all_of_schema) +
97
+ one_of_properties_for(all_of_schema)
92
98
  end.flatten
93
99
  end
94
100
 
101
+ def one_of_properties_for(doc)
102
+ return [] if doc.one_of.nil?
103
+
104
+ # All properties must be objects.
105
+ unless doc.one_of.all? { |schema| schema.type == 'object' }
106
+ raise 'All properties for oneOf must be objects'
107
+ end
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 openAPI.
116
+ relaxed: true,
117
+ parent: self)
118
+ end
119
+ end
120
+ end
121
+
95
122
  def schema_properties_for(doc)
96
123
  doc.properties.map do |key, properties_doc|
97
124
  property_class_for(properties_doc).new(properties_doc,
@@ -9,7 +9,7 @@ module Cocina
9
9
  end
10
10
 
11
11
  def omittable
12
- if required
12
+ if required && !relaxed
13
13
  '.default([].freeze)'
14
14
  else
15
15
  '.meta(omittable: true)'
@@ -4,14 +4,15 @@ module Cocina
4
4
  module Generator
5
5
  # Base class for generating from openapi
6
6
  class SchemaBase
7
- attr_reader :schema_doc, :key, :required, :nullable, :parent
7
+ attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed
8
8
 
9
- def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil)
9
+ def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false)
10
10
  @schema_doc = schema_doc
11
11
  @key = key
12
12
  @required = required
13
13
  @nullable = nullable
14
14
  @parent = parent
15
+ @relaxed = relaxed
15
16
  end
16
17
 
17
18
  def filename
@@ -25,7 +26,7 @@ module Cocina
25
26
  # Allows non-required values to not be provided. This allows smaller
26
27
  # requests as not every field needs to be present.
27
28
  def omittable
28
- return '' if required
29
+ return '' if required && !relaxed
29
30
 
30
31
  '.meta(omittable: true)'
31
32
  end
@@ -33,7 +34,7 @@ module Cocina
33
34
  # Allows nillable values to be set to nil. This is useful when doing
34
35
  # an update and you want to clear out a value.
35
36
  def optional
36
- nullable ? '.optional' : ''
37
+ nullable || relaxed ? '.optional' : ''
37
38
  end
38
39
 
39
40
  def quote(item)
@@ -54,6 +55,12 @@ module Cocina
54
55
  "# example: #{schema_doc.example}\n"
55
56
  end
56
57
 
58
+ def relaxed_comment
59
+ return '' unless relaxed
60
+
61
+ "# Validation of this property is relaxed. See the openapi for full validation.\n"
62
+ end
63
+
57
64
  def dry_datatype(doc)
58
65
  case doc.type
59
66
  when 'integer'
@@ -63,7 +70,7 @@ module Cocina
63
70
  when 'boolean'
64
71
  'Strict::Bool'
65
72
  else
66
- if doc.one_of&.map(&:type).all? { |o| %w[integer string].include?(o) }
73
+ if any_datatype?(doc)
67
74
  'Nominal::Any'
68
75
  else
69
76
  raise "#{schema_doc.type} not supported"
@@ -71,6 +78,10 @@ module Cocina
71
78
  end
72
79
  end
73
80
 
81
+ def any_datatype?(doc)
82
+ relaxed || doc.one_of&.map(&:type).all? { |o| %w[integer string].include?(o) }
83
+ end
84
+
74
85
  def string_dry_datatype(doc)
75
86
  case doc.format
76
87
  when 'date-time'
@@ -5,7 +5,7 @@ module Cocina
5
5
  # Class for generating from an openapi reference
6
6
  class SchemaRef < SchemaBase
7
7
  def generate
8
- if required
8
+ if required && !relaxed
9
9
  "attribute(:#{name.camelize(:lower)}, #{schema_doc.name}.default { #{schema_doc.name}.new })"
10
10
  else
11
11
  "attribute :#{name.camelize(:lower)}, #{schema_doc.name}.optional.meta(omittable: true)"
@@ -7,14 +7,14 @@ module Cocina
7
7
  # rubocop:disable Layout/LineLength
8
8
  def generate
9
9
  # optional has to come before default or the default value that gets set will be nil.
10
- "#{description}#{example}attribute :#{name.camelize(:lower)}, Types::#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}#{omittable}"
10
+ "#{description}#{example}#{relaxed_comment}attribute :#{name.camelize(:lower)}, Types::#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}#{omittable}"
11
11
  end
12
12
  # rubocop:enable Layout/LineLength
13
13
 
14
14
  private
15
15
 
16
16
  def enum
17
- return '' unless schema_doc.enum
17
+ return '' if !schema_doc.enum || relaxed
18
18
 
19
19
  items = use_types? ? "*#{parent.name}::TYPES" : schema_doc.enum.map { |item| quote(item) }.join(', ')
20
20
 
@@ -3,18 +3,17 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Access < Struct
6
- # Access level
7
- attribute :access, Types::Strict::String.default('dark').enum('world', 'stanford', 'location-based', 'citation-only', 'dark').meta(omittable: true)
8
- # The human readable copyright statement that applies
9
- # example: Copyright World Trade Organization
10
- attribute :copyright, Types::Strict::String.meta(omittable: true)
6
+ # Access level.
7
+ # Validation of this property is relaxed. See the openapi for full validation.
8
+ attribute :access, Types::Strict::String.optional.default('dark').meta(omittable: true)
9
+ # Download access level.
10
+ # Validation of this property is relaxed. See the openapi for full validation.
11
+ attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
11
12
  # If access is "location-based", which location should have access.
12
- attribute :readLocation, Types::Strict::String.enum('spec', 'music', 'ars', 'art', 'hoover', 'm&m').meta(omittable: true)
13
- # The human readable use and reproduction statement that applies
14
- # 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).
15
- attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
16
- # The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
17
- attribute :license, Types::Strict::String.meta(omittable: true)
13
+ # Validation of this property is relaxed. See the openapi for full validation.
14
+ attribute :readLocation, Types::Strict::String.optional.meta(omittable: true)
15
+ # Validation of this property is relaxed. See the openapi for full validation.
16
+ attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
18
17
  end
19
18
  end
20
19
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class CitationOnlyAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('citation-only')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('none')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.optional.enum('').meta(omittable: true)
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
@@ -20,7 +20,7 @@ module Cocina
20
20
  attribute :label, Types::Strict::String
21
21
  # Version for the Collection within SDR.
22
22
  attribute :version, Types::Strict::Integer
23
- attribute(:access, Access.default { Access.new })
23
+ attribute(:access, CollectionAccess.default { CollectionAccess.new })
24
24
  attribute :administrative, Administrative.optional.meta(omittable: true)
25
25
  attribute :description, Description.optional.meta(omittable: true)
26
26
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class CollectionAccess < Struct
6
+ # Access level
7
+ attribute :access, Types::Strict::String.default('dark').enum('world', 'dark').meta(omittable: true)
8
+ # The human readable copyright statement that applies
9
+ # example: Copyright World Trade Organization
10
+ attribute :copyright, Types::Strict::String.meta(omittable: true)
11
+ # The human readable use and reproduction statement that applies
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)
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)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class ControlledDigitalLendingAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('stanford')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('none')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.optional.enum('').meta(omittable: true)
12
+ # Available for controlled digital lending.
13
+ attribute :controlledDigitalLending, Types::Strict::Bool.default(false)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class DarkAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.default('dark').enum('dark').meta(omittable: true)
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.default('none').enum('none').meta(omittable: true)
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.optional.enum('').meta(omittable: true)
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
@@ -3,19 +3,21 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DROAccess < Struct
6
- attribute :access, Types::Strict::String.default('dark').enum('world', 'stanford', 'location-based', 'citation-only', 'dark').meta(omittable: true)
7
- # Available for controlled digital lending.
8
- attribute :controlledDigitalLending, Types::Strict::Bool.meta(omittable: true)
6
+ # Access level.
7
+ # Validation of this property is relaxed. See the openapi for full validation.
8
+ attribute :access, Types::Strict::String.optional.default('dark').meta(omittable: true)
9
+ # Download access level.
10
+ # Validation of this property is relaxed. See the openapi for full validation.
11
+ attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
12
+ # If access is "location-based", which location should have access.
13
+ # Validation of this property is relaxed. See the openapi for full validation.
14
+ attribute :readLocation, Types::Strict::String.optional.meta(omittable: true)
15
+ # Validation of this property is relaxed. See the openapi for full validation.
16
+ attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
9
17
  # The human readable copyright statement that applies
10
18
  # example: Copyright World Trade Organization
11
19
  attribute :copyright, Types::Strict::String.meta(omittable: true)
12
20
  attribute :embargo, Embargo.optional.meta(omittable: true)
13
- # Download access level. This is used in the transition from Fedora as a way to set a default download level at registration that is copied down to all the files.
14
-
15
- attribute :download, Types::Strict::String.default('none').enum('world', 'stanford', 'location-based', 'none').meta(omittable: true)
16
- # If access is "location-based", which location should have access. This is used in the transition from Fedora as a way to set a default readLocation at registration that is copied down to all the files.
17
-
18
- attribute :readLocation, Types::Strict::String.enum('spec', 'music', 'ars', 'art', 'hoover', 'm&m').meta(omittable: true)
19
21
  # The human readable use and reproduction statement that applies
20
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).
21
23
  attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
@@ -3,11 +3,20 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Embargo < Struct
6
+ # Access level.
7
+ # Validation of this property is relaxed. See the openapi for full validation.
8
+ attribute :access, Types::Strict::String.optional.default('dark').meta(omittable: true)
9
+ # Download access level.
10
+ # Validation of this property is relaxed. See the openapi for full validation.
11
+ attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
12
+ # If access is "location-based", which location should have access.
13
+ # Validation of this property is relaxed. See the openapi for full validation.
14
+ attribute :readLocation, Types::Strict::String.optional.meta(omittable: true)
15
+ # Validation of this property is relaxed. See the openapi for full validation.
16
+ attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
6
17
  # Date when the Collection is released from an embargo.
7
18
  # example: 2029-06-22T07:00:00.000+00:00
8
19
  attribute :releaseDate, Types::Params::DateTime
9
- # Access level that applies when embargo expires.
10
- attribute :access, Types::Strict::String.enum('world', 'stanford', 'location-based', 'citation-only', 'dark')
11
20
  # The human readable use and reproduction statement that applies when the embargo expires.
12
21
  # example: These materials are in the public domain.
13
22
  attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
@@ -3,14 +3,17 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class FileAccess < Struct
6
- # Access level
7
- attribute :access, Types::Strict::String.default('dark').enum('world', 'stanford', 'location-based', 'citation-only', 'dark').meta(omittable: true)
8
- # Available for controlled digital lending.
9
- attribute :controlledDigitalLending, Types::Strict::Bool.meta(omittable: true)
10
- # Download access level for a file
11
- attribute :download, Types::Strict::String.default('none').enum('world', 'stanford', 'location-based', 'none').meta(omittable: true)
6
+ # Access level.
7
+ # Validation of this property is relaxed. See the openapi for full validation.
8
+ attribute :access, Types::Strict::String.optional.default('dark').meta(omittable: true)
9
+ # Download access level.
10
+ # Validation of this property is relaxed. See the openapi for full validation.
11
+ attribute :download, Types::Strict::String.optional.default('none').meta(omittable: true)
12
12
  # If access is "location-based", which location should have access.
13
- attribute :readLocation, Types::Strict::String.enum('spec', 'music', 'ars', 'art', 'hoover', 'm&m').meta(omittable: true)
13
+ # Validation of this property is relaxed. See the openapi for full validation.
14
+ attribute :readLocation, Types::Strict::String.optional.meta(omittable: true)
15
+ # Validation of this property is relaxed. See the openapi for full validation.
16
+ attribute :controlledDigitalLending, Types::Strict::Bool.optional.meta(omittable: true)
14
17
  end
15
18
  end
16
19
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class LocationBasedAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('location-based')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('location-based', 'none')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.enum('spec', 'music', 'ars', 'art', 'hoover', 'm&m')
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class LocationBasedDownloadAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('stanford', 'world')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('location-based')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.enum('spec', 'music', 'ars', 'art', 'hoover', 'm&m')
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
@@ -15,7 +15,7 @@ module Cocina
15
15
  attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
16
16
  attribute :label, Types::Strict::String
17
17
  attribute :version, Types::Strict::Integer
18
- attribute(:access, Access.default { Access.new })
18
+ attribute(:access, CollectionAccess.default { CollectionAccess.new })
19
19
  attribute(:administrative, Administrative.default { Administrative.new })
20
20
  attribute :description, Description.optional.meta(omittable: true)
21
21
  attribute :identification, CollectionIdentification.optional.meta(omittable: true)
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class StanfordAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('stanford')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('stanford')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.optional.enum('').meta(omittable: true)
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.58.2'
5
+ VERSION = '0.59.0'
6
6
  end
7
7
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ class WorldAccess < Struct
6
+ # Access level.
7
+ attribute :access, Types::Strict::String.enum('world')
8
+ # Download access level.
9
+ attribute :download, Types::Strict::String.enum('none', 'stanford', 'world')
10
+ # If access is "location-based", which location should have access.
11
+ attribute :readLocation, Types::Strict::String.optional.enum('').meta(omittable: true)
12
+ attribute :controlledDigitalLending, Types::Strict::Bool.enum(false).meta(omittable: true)
13
+ end
14
+ end
15
+ end
data/openapi.yml CHANGED
@@ -94,41 +94,16 @@ paths:
94
94
  components:
95
95
  schemas:
96
96
  Access:
97
- description: Access metadata for collections
98
97
  type: object
99
- additionalProperties: false
100
- properties:
101
- access:
102
- description: Access level
103
- type: string
104
- enum:
105
- - 'world'
106
- - 'stanford'
107
- - 'location-based'
108
- - 'citation-only'
109
- - 'dark'
110
- default: 'dark'
111
- copyright:
112
- description: The human readable copyright statement that applies
113
- example: Copyright World Trade Organization
114
- type: string
115
- readLocation:
116
- description: If access is "location-based", which location should have access.
117
- type: string
118
- enum:
119
- - 'spec'
120
- - 'music'
121
- - 'ars'
122
- - 'art'
123
- - 'hoover'
124
- - 'm&m'
125
- useAndReproductionStatement:
126
- description: The human readable use and reproduction statement that applies
127
- 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).
128
- type: string
129
- license:
130
- description: The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
131
- type: string
98
+ oneOf:
99
+ # Being first, makes DarkAccess the default.
100
+ - $ref: '#/components/schemas/DarkAccess'
101
+ - $ref: '#/components/schemas/CitationOnlyAccess'
102
+ - $ref: '#/components/schemas/ControlledDigitalLendingAccess'
103
+ - $ref: '#/components/schemas/LocationBasedAccess'
104
+ - $ref: '#/components/schemas/LocationBasedDownloadAccess'
105
+ - $ref: '#/components/schemas/StanfordAccess'
106
+ - $ref: '#/components/schemas/WorldAccess'
132
107
  AccessRole:
133
108
  description: Access role conferred by an AdminPolicy to objects within it. (used by Argo)
134
109
  type: object
@@ -353,6 +328,33 @@ components:
353
328
  type: string
354
329
  pattern: '^[0-9]+-[0-9]+$'
355
330
  example: 6772719-1001
331
+ CitationOnlyAccess:
332
+ type: object
333
+ properties:
334
+ access:
335
+ description: Access level.
336
+ type: string
337
+ enum:
338
+ - citation-only
339
+ download:
340
+ description: Download access level.
341
+ type: string
342
+ enum:
343
+ - 'none'
344
+ readLocation:
345
+ description: If access is "location-based", which location should have access.
346
+ type: string
347
+ nullable: true
348
+ enum:
349
+ - null
350
+ controlledDigitalLending:
351
+ type: boolean
352
+ default: false
353
+ enum:
354
+ - false
355
+ required:
356
+ - access
357
+ - download
356
358
  Collection:
357
359
  description: A group of Digital Repository Objects that indicate some type of conceptual grouping within the domain that is worth reusing across the system.
358
360
  type: object
@@ -377,7 +379,7 @@ components:
377
379
  description: Version for the Collection within SDR.
378
380
  type: integer
379
381
  access:
380
- $ref: '#/components/schemas/Access'
382
+ $ref: '#/components/schemas/CollectionAccess'
381
383
  administrative:
382
384
  $ref: '#/components/schemas/Administrative'
383
385
  description:
@@ -390,6 +392,29 @@ components:
390
392
  - type
391
393
  - version
392
394
  - access
395
+ CollectionAccess:
396
+ description: Access metadata for collections
397
+ type: object
398
+ additionalProperties: false
399
+ properties:
400
+ access:
401
+ description: Access level
402
+ type: string
403
+ enum:
404
+ - 'world'
405
+ - 'dark'
406
+ default: 'dark'
407
+ copyright:
408
+ description: The human readable copyright statement that applies
409
+ example: Copyright World Trade Organization
410
+ type: string
411
+ useAndReproductionStatement:
412
+ description: The human readable use and reproduction statement that applies
413
+ 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).
414
+ type: string
415
+ license:
416
+ description: The license governing reuse of the Collection. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
417
+ type: string
393
418
  CollectionIdentification:
394
419
  type: object
395
420
  additionalProperties: false
@@ -442,6 +467,60 @@ components:
442
467
  type: array
443
468
  items:
444
469
  $ref: "#/components/schemas/DescriptiveParallelContributor"
470
+ ControlledDigitalLendingAccess:
471
+ type: object
472
+ properties:
473
+ access:
474
+ description: Access level.
475
+ type: string
476
+ enum:
477
+ - stanford
478
+ download:
479
+ description: Download access level.
480
+ type: string
481
+ enum:
482
+ - none
483
+ readLocation:
484
+ description: If access is "location-based", which location should have access.
485
+ type: string
486
+ nullable: true
487
+ enum:
488
+ - null
489
+ controlledDigitalLending:
490
+ description: Available for controlled digital lending.
491
+ type: boolean
492
+ default: false
493
+ required:
494
+ - access
495
+ - download
496
+ - controlledDigitalLending
497
+ DarkAccess:
498
+ type: object
499
+ properties:
500
+ access:
501
+ description: Access level.
502
+ type: string
503
+ default: 'dark'
504
+ enum:
505
+ - dark
506
+ download:
507
+ description: Download access level.
508
+ type: string
509
+ default: 'none'
510
+ enum:
511
+ - 'none'
512
+ readLocation:
513
+ description: If access is "location-based", which location should have access.
514
+ type: string
515
+ nullable: true
516
+ default: null
517
+ enum:
518
+ - null
519
+ controlledDigitalLending:
520
+ type: boolean
521
+ default: false
522
+ enum:
523
+ - false
445
524
  Description:
446
525
  type: object
447
526
  additionalProperties: false
@@ -848,60 +927,23 @@ components:
848
927
  DROAccess:
849
928
  type: object
850
929
  additionalProperties: false
851
- properties:
852
- access:
853
- type: string
854
- enum:
855
- - 'world'
856
- - 'stanford'
857
- - 'location-based'
858
- - 'citation-only'
859
- - 'dark'
860
- default: 'dark'
861
- controlledDigitalLending:
862
- description: Available for controlled digital lending.
863
- type: boolean
864
- default: false
865
- copyright:
866
- description: The human readable copyright statement that applies
867
- example: Copyright World Trade Organization
868
- type: string
869
- embargo:
870
- $ref: '#/components/schemas/Embargo'
871
- download:
872
- description: >
873
- Download access level. This is used in the transition from Fedora as
874
- a way to set a default download level at registration that is copied
875
- down to all the files.
876
-
877
- type: string
878
- enum:
879
- - 'world'
880
- - 'stanford'
881
- - 'location-based'
882
- - 'none'
883
- default: 'none'
884
- readLocation:
885
- description: >
886
- If access is "location-based", which location should have access.
887
- This is used in the transition from Fedora as a way to set a default
888
- readLocation at registration that is copied down to all the files.
889
-
890
- type: string
891
- enum:
892
- - 'spec'
893
- - 'music'
894
- - 'ars'
895
- - 'art'
896
- - 'hoover'
897
- - 'm&m'
898
- useAndReproductionStatement:
899
- description: The human readable use and reproduction statement that applies
900
- 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).
901
- type: string
902
- license:
903
- description: The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
904
- type: string
930
+ allOf:
931
+ - $ref: "#/components/schemas/Access"
932
+ - type: object
933
+ properties:
934
+ copyright:
935
+ description: The human readable copyright statement that applies
936
+ example: Copyright World Trade Organization
937
+ type: string
938
+ embargo:
939
+ $ref: '#/components/schemas/Embargo'
940
+ useAndReproductionStatement:
941
+ description: The human readable use and reproduction statement that applies
942
+ 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).
943
+ type: string
944
+ license:
945
+ description: The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
946
+ type: string
905
947
  DROStructural:
906
948
  description: Structural metadata
907
949
  type: object
@@ -932,28 +974,21 @@ components:
932
974
  Embargo:
933
975
  type: object
934
976
  additionalProperties: false
935
- properties:
936
- releaseDate:
937
- description: Date when the Collection is released from an embargo.
938
- type: string
939
- format: date-time
940
- example: '2029-06-22T07:00:00.000+00:00'
941
- access:
942
- description: Access level that applies when embargo expires.
943
- type: string
944
- enum:
945
- - world
946
- - stanford
947
- - location-based
948
- - citation-only
949
- - dark
950
- useAndReproductionStatement:
951
- description: The human readable use and reproduction statement that applies when the embargo expires.
952
- example: These materials are in the public domain.
953
- type: string
954
- required:
955
- - releaseDate
956
- - access
977
+ allOf:
978
+ - $ref: "#/components/schemas/Access"
979
+ - type: object
980
+ properties:
981
+ releaseDate:
982
+ description: Date when the Collection is released from an embargo.
983
+ type: string
984
+ format: date-time
985
+ example: '2029-06-22T07:00:00.000+00:00'
986
+ useAndReproductionStatement:
987
+ description: The human readable use and reproduction statement that applies when the embargo expires.
988
+ example: These materials are in the public domain.
989
+ type: string
990
+ required:
991
+ - releaseDate
957
992
  Event:
958
993
  description: Property model for describing events in the history of the resource.
959
994
  type: object
@@ -1056,40 +1091,14 @@ components:
1056
1091
  description: Access metadata for files
1057
1092
  type: object
1058
1093
  additionalProperties: false
1059
- properties:
1060
- access:
1061
- description: Access level
1062
- type: string
1063
- enum:
1064
- - 'world'
1065
- - 'stanford'
1066
- - 'location-based'
1067
- - 'citation-only'
1068
- - 'dark'
1069
- default: 'dark'
1070
- controlledDigitalLending:
1071
- description: Available for controlled digital lending.
1072
- type: boolean
1073
- default: false
1074
- download:
1075
- description: Download access level for a file
1076
- type: string
1077
- enum:
1078
- - 'world'
1079
- - 'stanford'
1080
- - 'location-based'
1081
- - 'none'
1082
- default: 'none'
1083
- readLocation:
1084
- description: If access is "location-based", which location should have access.
1085
- type: string
1086
- enum:
1087
- - 'spec'
1088
- - 'music'
1089
- - 'ars'
1090
- - 'art'
1091
- - 'hoover'
1092
- - 'm&m'
1094
+ oneOf:
1095
+ # Being first, makes DarkAccess the default.
1096
+ - $ref: '#/components/schemas/DarkAccess'
1097
+ - $ref: '#/components/schemas/ControlledDigitalLendingAccess'
1098
+ - $ref: '#/components/schemas/LocationBasedAccess'
1099
+ - $ref: '#/components/schemas/LocationBasedDownloadAccess'
1100
+ - $ref: '#/components/schemas/StanfordAccess'
1101
+ - $ref: '#/components/schemas/WorldAccess'
1093
1102
  FileAdministrative:
1094
1103
  type: object
1095
1104
  additionalProperties: false
@@ -1247,6 +1256,72 @@ components:
1247
1256
  valueLanguage:
1248
1257
  # description: present for mapping to additional schemas in the future and for consistency but not otherwise used
1249
1258
  $ref: "#/components/schemas/DescriptiveValueLanguage"
1259
+ LocationBasedAccess:
1260
+ type: object
1261
+ properties:
1262
+ access:
1263
+ description: Access level.
1264
+ type: string
1265
+ enum:
1266
+ - location-based
1267
+ download:
1268
+ description: Download access level.
1269
+ type: string
1270
+ enum:
1271
+ - location-based
1272
+ - none
1273
+ readLocation:
1274
+ description: If access is "location-based", which location should have access.
1275
+ type: string
1276
+ enum:
1277
+ - 'spec'
1278
+ - 'music'
1279
+ - 'ars'
1280
+ - 'art'
1281
+ - 'hoover'
1282
+ - 'm&m'
1283
+ controlledDigitalLending:
1284
+ type: boolean
1285
+ default: false
1286
+ enum:
1287
+ - false
1288
+ required:
1289
+ - access
1290
+ - download
1291
+ - readLocation
1292
+ LocationBasedDownloadAccess:
1293
+ type: object
1294
+ properties:
1295
+ access:
1296
+ description: Access level.
1297
+ type: string
1298
+ enum:
1299
+ - stanford
1300
+ - world
1301
+ download:
1302
+ description: Download access level.
1303
+ type: string
1304
+ enum:
1305
+ - location-based
1306
+ readLocation:
1307
+ description: If access is "location-based", which location should have access.
1308
+ type: string
1309
+ enum:
1310
+ - 'spec'
1311
+ - 'music'
1312
+ - 'ars'
1313
+ - 'art'
1314
+ - 'hoover'
1315
+ - 'm&m'
1316
+ controlledDigitalLending:
1317
+ type: boolean
1318
+ default: false
1319
+ enum:
1320
+ - false
1321
+ required:
1322
+ - access
1323
+ - download
1324
+ - readLocation
1250
1325
  MessageDigest:
1251
1326
  description: The output of the message digest algorithm.
1252
1327
  type: object
@@ -1424,7 +1499,7 @@ components:
1424
1499
  version:
1425
1500
  type: integer
1426
1501
  access:
1427
- $ref: '#/components/schemas/Access'
1502
+ $ref: '#/components/schemas/CollectionAccess'
1428
1503
  administrative:
1429
1504
  $ref: '#/components/schemas/Administrative'
1430
1505
  description:
@@ -1704,3 +1779,59 @@ components:
1704
1779
  - type: object
1705
1780
  required:
1706
1781
  - valueAt
1782
+ StanfordAccess:
1783
+ type: object
1784
+ properties:
1785
+ access:
1786
+ description: Access level.
1787
+ type: string
1788
+ enum:
1789
+ - stanford
1790
+ download:
1791
+ description: Download access level.
1792
+ type: string
1793
+ enum:
1794
+ - stanford
1795
+ readLocation:
1796
+ description: If access is "location-based", which location should have access.
1797
+ type: string
1798
+ nullable: true
1799
+ enum:
1800
+ - null
1801
+ controlledDigitalLending:
1802
+ type: boolean
1803
+ default: false
1804
+ enum:
1805
+ - false
1806
+ required:
1807
+ - access
1808
+ - download
1809
+ WorldAccess:
1810
+ type: object
1811
+ properties:
1812
+ access:
1813
+ description: Access level.
1814
+ type: string
1815
+ enum:
1816
+ - world
1817
+ download:
1818
+ description: Download access level.
1819
+ type: string
1820
+ enum:
1821
+ - none
1822
+ - stanford
1823
+ - world
1824
+ readLocation:
1825
+ description: If access is "location-based", which location should have access.
1826
+ type: string
1827
+ nullable: true
1828
+ enum:
1829
+ - null
1830
+ controlledDigitalLending:
1831
+ type: boolean
1832
+ default: false
1833
+ enum:
1834
+ - false
1835
+ required:
1836
+ - access
1837
+ - download
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.58.2
4
+ version: 0.59.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: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -265,9 +265,13 @@ files:
265
265
  - lib/cocina/models/catalog_link.rb
266
266
  - lib/cocina/models/catkey_barcode.rb
267
267
  - lib/cocina/models/checkable.rb
268
+ - lib/cocina/models/citation_only_access.rb
268
269
  - lib/cocina/models/collection.rb
270
+ - lib/cocina/models/collection_access.rb
269
271
  - lib/cocina/models/collection_identification.rb
270
272
  - lib/cocina/models/contributor.rb
273
+ - lib/cocina/models/controlled_digital_lending_access.rb
274
+ - lib/cocina/models/dark_access.rb
271
275
  - lib/cocina/models/description.rb
272
276
  - lib/cocina/models/descriptive_access_metadata.rb
273
277
  - lib/cocina/models/descriptive_admin_metadata.rb
@@ -294,6 +298,8 @@ files:
294
298
  - lib/cocina/models/geographic.rb
295
299
  - lib/cocina/models/identification.rb
296
300
  - lib/cocina/models/language.rb
301
+ - lib/cocina/models/location_based_access.rb
302
+ - lib/cocina/models/location_based_download_access.rb
297
303
  - lib/cocina/models/message_digest.rb
298
304
  - lib/cocina/models/presentation.rb
299
305
  - lib/cocina/models/related_resource.rb
@@ -311,10 +317,12 @@ files:
311
317
  - lib/cocina/models/source_id.rb
312
318
  - lib/cocina/models/standard.rb
313
319
  - lib/cocina/models/standard_barcode.rb
320
+ - lib/cocina/models/stanford_access.rb
314
321
  - lib/cocina/models/title.rb
315
322
  - lib/cocina/models/validator.rb
316
323
  - lib/cocina/models/version.rb
317
324
  - lib/cocina/models/vocab.rb
325
+ - lib/cocina/models/world_access.rb
318
326
  - openapi.yml
319
327
  homepage: https://github.com/sul-dlss/cocina-models
320
328
  licenses: []
@@ -334,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
342
  - !ruby/object:Gem::Version
335
343
  version: '0'
336
344
  requirements: []
337
- rubygems_version: 3.1.4
345
+ rubygems_version: 3.0.3
338
346
  signing_key:
339
347
  specification_version: 4
340
348
  summary: Data models for the SDR