cocina-models 0.126.0 → 0.127.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 +4 -4
- data/AGENTS.md +2 -2
- data/Gemfile.lock +12 -12
- data/bin/validate-data +4 -4
- data/lib/cocina/models/request_admin_policy.rb +1 -1
- data/lib/cocina/models/request_collection.rb +1 -1
- data/lib/cocina/models/request_dro.rb +1 -1
- data/lib/cocina/models/validators/composite_description_validator.rb +2 -2
- data/lib/cocina/models/validators/description_location_visitor_validator.rb +59 -0
- data/lib/cocina/models/version.rb +1 -1
- data/schema.json +1 -4
- metadata +2 -2
- data/lib/cocina/models/validators/description_location_source_code_visitor_validator.rb +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9beced1e40bb48b8cb1b833da51b9205b5f454554c0385ad982c3f8bed648f8
|
|
4
|
+
data.tar.gz: b94cfd3960e8bdd7ff896a3749b12c95ed1827bcf05cdf7a62d37c0e9f88d817
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3accd9261f9215632a273525b0459e004db3cc0410bda7d455018e5042e1de908f87d7a13d1faa75c605c67c26b6437e0cc1c8dc6a8abda67fe5a6927bd71283
|
|
7
|
+
data.tar.gz: 26c9d0be0086a3567d640760432dca23a4355e088b7368bc48db87023c4e6d915880c33b3ab4588be22b2ce84b49eed69eb30cf357f8dab1921ec9eece3cea1e
|
data/AGENTS.md
CHANGED
|
@@ -167,7 +167,7 @@ Generate a short kebab-case slug summarizing the query (e.g., `invalid-encoding`
|
|
|
167
167
|
|
|
168
168
|
The comment lines must use `#` so the file remains valid jq syntax. When resuming (Step 2 resume path), parse these comment sections by their labels to reconstruct the inputs.
|
|
169
169
|
|
|
170
|
-
Find the most recent `.jsonl.
|
|
170
|
+
Find the most recent `.jsonl.zst` file in the project root by listing `*.jsonl.zst` files sorted by name descending and taking the first result.
|
|
171
171
|
|
|
172
172
|
### Step 8 — Output
|
|
173
173
|
|
|
@@ -178,7 +178,7 @@ Present:
|
|
|
178
178
|
4. A ready-to-run shell snippet:
|
|
179
179
|
|
|
180
180
|
```
|
|
181
|
-
|
|
181
|
+
zstdcat <most-recent .jsonl.zst filename> \
|
|
182
182
|
| pv -l -s 5500000 \
|
|
183
183
|
| parallel -j$(sysctl -n hw.logicalcpu) --pipe --block 50M --recend '\n' \
|
|
184
184
|
jq -rcf <slug>.jq.txt \
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cocina-models (0.
|
|
4
|
+
cocina-models (0.127.0)
|
|
5
5
|
activesupport
|
|
6
6
|
cocina_display
|
|
7
7
|
deprecation
|
|
@@ -102,11 +102,11 @@ GEM
|
|
|
102
102
|
iso8601 (0.13.0)
|
|
103
103
|
janeway-jsonpath (1.0.0)
|
|
104
104
|
json (2.20.0)
|
|
105
|
-
jsonschema_rs (0.46.
|
|
105
|
+
jsonschema_rs (0.46.10-arm64-darwin)
|
|
106
106
|
bigdecimal (>= 3.1, < 5)
|
|
107
|
-
jsonschema_rs (0.46.
|
|
107
|
+
jsonschema_rs (0.46.10-x86_64-linux)
|
|
108
108
|
bigdecimal (>= 3.1, < 5)
|
|
109
|
-
language_server-protocol (3.17.0.
|
|
109
|
+
language_server-protocol (3.17.0.6)
|
|
110
110
|
lint_roller (1.1.0)
|
|
111
111
|
logger (1.7.0)
|
|
112
112
|
minitest (6.0.6)
|
|
@@ -162,7 +162,7 @@ GEM
|
|
|
162
162
|
rspec-support (3.13.7)
|
|
163
163
|
rspec_junit_formatter (0.6.0)
|
|
164
164
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
165
|
-
rubocop (1.88.
|
|
165
|
+
rubocop (1.88.1)
|
|
166
166
|
json (~> 2.3)
|
|
167
167
|
language_server-protocol (~> 3.17.0.2)
|
|
168
168
|
lint_roller (~> 1.1.0)
|
|
@@ -173,7 +173,7 @@ GEM
|
|
|
173
173
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
174
174
|
ruby-progressbar (~> 1.7)
|
|
175
175
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
176
|
-
rubocop-ast (1.
|
|
176
|
+
rubocop-ast (1.50.0)
|
|
177
177
|
parser (>= 3.3.7.2)
|
|
178
178
|
prism (~> 1.7)
|
|
179
179
|
rubocop-rake (0.7.1)
|
|
@@ -232,7 +232,7 @@ CHECKSUMS
|
|
|
232
232
|
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
|
|
233
233
|
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
|
|
234
234
|
bundler (4.0.15) sha256=a4ceb882fe94a0e0ac63cd0813932bbfd631a14e5ac0b7975189b19a4d28d9e7
|
|
235
|
-
cocina-models (0.
|
|
235
|
+
cocina-models (0.127.0)
|
|
236
236
|
cocina_display (2.8.0) sha256=89722e8e204c07cfa38f3deacbd66d42f3db9c7b29fdc034973d847cf93c4995
|
|
237
237
|
concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
|
|
238
238
|
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
@@ -260,9 +260,9 @@ CHECKSUMS
|
|
|
260
260
|
iso8601 (0.13.0) sha256=298c2b15b7be5fa95a1372813d36a2257656cd8e906dfbc1f5cb409851425aa2
|
|
261
261
|
janeway-jsonpath (1.0.0) sha256=c8293f009f2aea9487ddee3067ca735a1f758eb1c8834ff4fab3ffd06c56d0a3
|
|
262
262
|
json (2.20.0) sha256=9362bc6e55a952b056abf9167cf053358181c904cb70cd6eee0808ea830fc32b
|
|
263
|
-
jsonschema_rs (0.46.
|
|
264
|
-
jsonschema_rs (0.46.
|
|
265
|
-
language_server-protocol (3.17.0.
|
|
263
|
+
jsonschema_rs (0.46.10-arm64-darwin) sha256=1bece46823184a8cbec55d7585f09de68cc2bc03772d8aa9c29deba23b490609
|
|
264
|
+
jsonschema_rs (0.46.10-x86_64-linux) sha256=ef1f8a244e8e5b4a9e35ccd0b7f7aa9912a7e15b00f1170ba3f3cade0bdc627b
|
|
265
|
+
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
|
|
266
266
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
267
267
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
268
268
|
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
|
|
@@ -290,8 +290,8 @@ CHECKSUMS
|
|
|
290
290
|
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
291
291
|
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
292
292
|
rspec_junit_formatter (0.6.0) sha256=40dde674e6ae4e6cc0ff560da25497677e34fefd2338cc467a8972f602b62b15
|
|
293
|
-
rubocop (1.88.
|
|
294
|
-
rubocop-ast (1.
|
|
293
|
+
rubocop (1.88.1) sha256=726af773d6bc169ed3ff852f3ca020b7c58d39c34e7a8d879a8e0147cc994f26
|
|
294
|
+
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
|
|
295
295
|
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
|
|
296
296
|
rubocop-rspec (3.10.2) sha256=0b3e2ecc592cd10ecbf0095bb58d1e357905276e069643523cc19eb7495f65e2
|
|
297
297
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
data/bin/validate-data
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
# Validate JSONL (
|
|
4
|
+
# Validate JSONL (zstd compressed) files against the schema
|
|
5
5
|
|
|
6
6
|
# Trap Ctrl+C to exit gracefully
|
|
7
7
|
Signal.trap('INT') do
|
|
@@ -65,7 +65,7 @@ end
|
|
|
65
65
|
# Count lines in the file
|
|
66
66
|
def count_lines(filename)
|
|
67
67
|
count = 0
|
|
68
|
-
IO.popen(['
|
|
68
|
+
IO.popen(['zstdcat', filename]) do |io|
|
|
69
69
|
io.each_line { count += 1 }
|
|
70
70
|
end
|
|
71
71
|
count
|
|
@@ -73,7 +73,7 @@ end
|
|
|
73
73
|
|
|
74
74
|
# Get total line count (either from option or by counting)
|
|
75
75
|
def get_total_lines(filename, provided_count)
|
|
76
|
-
count_filename = filename.sub(/\.
|
|
76
|
+
count_filename = filename.sub(/\.zst$/, '.count.txt')
|
|
77
77
|
if provided_count
|
|
78
78
|
puts "Using provided line count: #{provided_count}"
|
|
79
79
|
provided_count
|
|
@@ -183,7 +183,7 @@ def distribute_work(filename, workers, batch_size, total_lines) # rubocop:disabl
|
|
|
183
183
|
throttle_rate: 0.1
|
|
184
184
|
)
|
|
185
185
|
|
|
186
|
-
IO.popen(['
|
|
186
|
+
IO.popen(['zstdcat', filename]) do |io|
|
|
187
187
|
io.each_line do |line|
|
|
188
188
|
line_number += 1
|
|
189
189
|
batch << [line_number, line]
|
|
@@ -14,7 +14,7 @@ module Cocina
|
|
|
14
14
|
# example: 1.2.3
|
|
15
15
|
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
|
16
16
|
attribute :type, Types::Strict::String.enum(*RequestAdminPolicy::TYPES)
|
|
17
|
-
attribute :label, Types::Strict::String
|
|
17
|
+
attribute? :label, Types::Strict::String.default('')
|
|
18
18
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
|
19
19
|
# Administrative properties for an AdminPolicy
|
|
20
20
|
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
|
|
@@ -18,7 +18,7 @@ module Cocina
|
|
|
18
18
|
# example: 1.2.3
|
|
19
19
|
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
|
20
20
|
attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
|
|
21
|
-
attribute :label, Types::Strict::String
|
|
21
|
+
attribute? :label, Types::Strict::String.default('')
|
|
22
22
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
|
23
23
|
# Access metadata for collections
|
|
24
24
|
attribute(:access, CollectionAccess.default { CollectionAccess.new })
|
|
@@ -30,7 +30,7 @@ module Cocina
|
|
|
30
30
|
# example: 1.2.3
|
|
31
31
|
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
|
32
32
|
attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
|
|
33
|
-
attribute :label, Types::Strict::String
|
|
33
|
+
attribute? :label, Types::Strict::String.default('')
|
|
34
34
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
|
35
35
|
attribute? :access, DROAccess.optional
|
|
36
36
|
attribute(:administrative, RequestAdministrative.default { RequestAdministrative.new })
|
|
@@ -17,10 +17,10 @@ module Cocina
|
|
|
17
17
|
DescriptionDateTimeVisitorValidator,
|
|
18
18
|
DescriptionEventDateVisitorValidator,
|
|
19
19
|
DescriptionSubjectTemporalEncodingVisitorValidator,
|
|
20
|
-
DescriptionLocationSourceCodeVisitorValidator,
|
|
21
20
|
DescriptionTitleSourceCodeVisitorValidator,
|
|
22
21
|
DescriptionLanguageUriVisitorValidator,
|
|
23
|
-
DescriptionScriptVisitorValidator
|
|
22
|
+
DescriptionScriptVisitorValidator,
|
|
23
|
+
DescriptionLocationVisitorValidator
|
|
24
24
|
].freeze
|
|
25
25
|
|
|
26
26
|
def self.validate(clazz, attributes)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cocina_display'
|
|
4
|
+
|
|
5
|
+
module Cocina
|
|
6
|
+
module Models
|
|
7
|
+
module Validators
|
|
8
|
+
# Validates location.source.code against location_source_codes.yml and
|
|
9
|
+
# validates location.code against marc_country_codes.yml when source.code is marccountry.
|
|
10
|
+
class DescriptionLocationVisitorValidator < BaseDescriptionVisitorValidator
|
|
11
|
+
def validate!
|
|
12
|
+
errors = []
|
|
13
|
+
errors << "Unrecognized location source codes in description: #{error_paths.join(', ')}" if error_paths.any?
|
|
14
|
+
errors << "Invalid MARC country codes in description: #{marc_country_error_paths.join(', ')}" if marc_country_error_paths.any?
|
|
15
|
+
raise ValidationError, errors.join('; ') if errors.any?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def visit_hash(hash:, path:)
|
|
19
|
+
return unless location_path?(path)
|
|
20
|
+
|
|
21
|
+
source_code = hash.dig(:source, :code)
|
|
22
|
+
return unless source_code
|
|
23
|
+
|
|
24
|
+
error_paths << "#{path_to_s(path)}.source.code (#{source_code})" unless valid_codes.include?(source_code.downcase)
|
|
25
|
+
|
|
26
|
+
return unless source_code.downcase == 'marccountry'
|
|
27
|
+
|
|
28
|
+
code = hash[:code]
|
|
29
|
+
marc_country_error_paths << "#{path_to_s(path)}.code (#{code})" if code && !valid_marc_country_codes.include?(code.downcase)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def error_paths
|
|
35
|
+
@error_paths ||= []
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def marc_country_error_paths
|
|
39
|
+
@marc_country_error_paths ||= []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def location_path?(path)
|
|
43
|
+
# Match entries in a location array (e.g., [:location, 0] or [:relatedResource, 0, :location, 0]).
|
|
44
|
+
path.length >= 2 && path[-1].is_a?(Integer) && path[-2].to_s == 'location'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# rubocop:disable Style/ClassVars
|
|
48
|
+
def valid_codes
|
|
49
|
+
@@valid_codes ||= YAML.load_file(::File.expand_path('../../../../location_source_codes.yml', __dir__)).to_set(&:downcase)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def valid_marc_country_codes
|
|
53
|
+
@@valid_marc_country_codes ||= YAML.load_file(CocinaDisplay.root.join('config/marc_countries.yml')).keys.to_set(&:to_s)
|
|
54
|
+
end
|
|
55
|
+
# rubocop:enable Style/ClassVars
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
data/schema.json
CHANGED
|
@@ -1720,7 +1720,7 @@
|
|
|
1720
1720
|
"minItems": 1
|
|
1721
1721
|
}
|
|
1722
1722
|
}
|
|
1723
|
-
}
|
|
1723
|
+
}
|
|
1724
1724
|
]
|
|
1725
1725
|
},
|
|
1726
1726
|
"File": {
|
|
@@ -2676,7 +2676,6 @@
|
|
|
2676
2676
|
"required": [
|
|
2677
2677
|
"cocinaVersion",
|
|
2678
2678
|
"administrative",
|
|
2679
|
-
"label",
|
|
2680
2679
|
"type",
|
|
2681
2680
|
"version"
|
|
2682
2681
|
],
|
|
@@ -2744,7 +2743,6 @@
|
|
|
2744
2743
|
"cocinaVersion",
|
|
2745
2744
|
"access",
|
|
2746
2745
|
"administrative",
|
|
2747
|
-
"label",
|
|
2748
2746
|
"type",
|
|
2749
2747
|
"version"
|
|
2750
2748
|
],
|
|
@@ -2811,7 +2809,6 @@
|
|
|
2811
2809
|
"cocinaVersion",
|
|
2812
2810
|
"administrative",
|
|
2813
2811
|
"identification",
|
|
2814
|
-
"label",
|
|
2815
2812
|
"type",
|
|
2816
2813
|
"version"
|
|
2817
2814
|
],
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocina-models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.127.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Coyne
|
|
@@ -488,7 +488,7 @@ files:
|
|
|
488
488
|
- lib/cocina/models/validators/description_identifier_source_code_visitor_validator.rb
|
|
489
489
|
- lib/cocina/models/validators/description_language_code_visitor_validator.rb
|
|
490
490
|
- lib/cocina/models/validators/description_language_uri_visitor_validator.rb
|
|
491
|
-
- lib/cocina/models/validators/
|
|
491
|
+
- lib/cocina/models/validators/description_location_visitor_validator.rb
|
|
492
492
|
- lib/cocina/models/validators/description_name_source_code_visitor_validator.rb
|
|
493
493
|
- lib/cocina/models/validators/description_role_source_code_visitor_validator.rb
|
|
494
494
|
- lib/cocina/models/validators/description_script_visitor_validator.rb
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cocina
|
|
4
|
-
module Models
|
|
5
|
-
module Validators
|
|
6
|
-
# Validates location.source.code values against location_source_codes.yml.
|
|
7
|
-
class DescriptionLocationSourceCodeVisitorValidator < BaseDescriptionVisitorValidator
|
|
8
|
-
def validate!
|
|
9
|
-
return if error_paths.empty?
|
|
10
|
-
|
|
11
|
-
raise ValidationError, "Unrecognized location source codes in description: #{error_paths.join(', ')}"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def visit_hash(hash:, path:)
|
|
15
|
-
return unless location_path?(path)
|
|
16
|
-
|
|
17
|
-
source_code = hash.dig(:source, :code)
|
|
18
|
-
return unless source_code
|
|
19
|
-
return if valid_codes.include?(source_code.downcase)
|
|
20
|
-
|
|
21
|
-
error_paths << "#{path_to_s(path)}.source.code (#{source_code})"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def error_paths
|
|
27
|
-
@error_paths ||= []
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def location_path?(path)
|
|
31
|
-
# Match entries in a location array (e.g., [:location, 0] or [:relatedResource, 0, :location, 0]).
|
|
32
|
-
path.length >= 2 && path[-1].is_a?(Integer) && path[-2].to_s == 'location'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# rubocop:disable Style/ClassVars
|
|
36
|
-
def valid_codes
|
|
37
|
-
@@valid_codes ||= YAML.load_file(::File.expand_path('../../../../location_source_codes.yml', __dir__)).to_set(&:downcase)
|
|
38
|
-
end
|
|
39
|
-
# rubocop:enable Style/ClassVars
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|