Repository navigation
Expand file tree
/
Copy pathlib.rs
More file actions
7209 lines (6873 loc) · 240 KB
/
Copy pathlib.rs
File metadata and controls
7209 lines (6873 loc) · 240 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: Apache-2.0
//! Portable metadata model and pure renderers for registry catalogs.
use std::collections::{BTreeMap, BTreeSet};
use std::sync::Arc;
use oxiri::Iri;
use serde::{de, Deserialize, Deserializer, Serialize};
use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use thiserror::Error;
pub const ODRL_ENFORCEMENT_PROFILE: &str = "registry-evidence-gateway-pdp/v1";
pub const SUPPORTED_ODRL_ENFORCEMENT_TERMS: &[&str] = &["odrl:purpose", "odrl:spatial"];
#[allow(dead_code)]
const DATASETS_COLLECTION_ID: &str = "datasets";
const JSON_SCHEMA_DRAFT_2020_12: &str = "https://json-schema.org/draft/2020-12/schema";
const EU_DATA_THEME_SCHEME: &str = "http://publications.europa.eu/resource/authority/data-theme";
const EUROVOC_THEME_SCHEME: &str = "http://eurovoc.europa.eu/100141";
const EU_LOCATION_IRI: &str = "http://publications.europa.eu/resource/authority/country/EUR";
/// The single evidence-offering access kind this layer validates in depth.
pub const REGISTRY_EVIDENCE_ACCESS_KIND: &str = "registry-evidence";
const CATALOG_SCHEMA_VERSION: &str = "registry-manifest-catalog/v1";
const EVIDENCE_OFFERINGS_SCHEMA_VERSION: &str = "registry-manifest-evidence-offerings/v1";
const EVIDENCE_OFFERING_SCHEMA_VERSION: &str = "registry-manifest-evidence-offering/v1";
const POLICY_COLLECTION_SCHEMA_VERSION: &str = "registry-manifest-policy-collection/v1";
const POLICY_SCHEMA_VERSION: &str = "registry-manifest-policy/v1";
const SHACL_SCHEMA_VERSION: &str = "registry-manifest-shacl/v1";
const CODELIST_SCHEMA_VERSION: &str = "registry-manifest-codelist/v1";
const ENTITY_JSON_SCHEMA_VERSION: &str = "registry-manifest-entity-json-schema/v1";
const FORM_JSON_SCHEMA_VERSION: &str = "registry-manifest-form-json-schema/v1";
const OGC_RECORDS_SCHEMA_VERSION: &str = "registry-manifest-ogc-records/v1";
const MAX_PROFILES: usize = 64;
const MAX_CATALOG_CONFORMS_TO: usize = 64;
const MAX_CATALOG_APPLICATION_PROFILES: usize = 32;
const MAX_TOP_LEVEL_COLLECTION_ITEMS: usize = 256;
const MAX_DATASET_ENTITIES: usize = 256;
const MAX_ENTITY_FIELDS: usize = 512;
const MAX_ENTITY_RELATIONSHIPS: usize = 512;
const MAX_CODELIST_CONCEPTS: usize = 1024;
const MAX_URI_LIST_ITEMS: usize = 128;
const ECOSYSTEM_BINDING_TYPE_GOVERNED_EVIDENCE: &str = "governed-evidence";
pub const REQUIRED_EVIDENCE_PACK_GATES: &[&str] = &[
"purpose",
"jurisdiction",
"legal_basis",
"consent",
"authority_basis",
"requester_identity",
"subject_identity",
"subject_relationship",
"assurance",
"source_binding",
"source_freshness",
"requested_disclosure",
"credential_format",
"route_scope",
];
pub const SUPPORTED_EVIDENCE_PACK_OUTPUTS: &[&str] = &["minimized_json"];
const BUILTIN_VOCABULARIES: &[(&str, &str)] = &[
("adms", "http://www.w3.org/ns/adms#"),
("cccev", "http://data.europa.eu/m8g/"),
("cpsv", "http://purl.org/vocab/cpsv#"),
("cv", "http://data.europa.eu/m8g/"),
("dcat", "http://www.w3.org/ns/dcat#"),
("dcatap", "http://data.europa.eu/r5r/"),
("dcterms", "http://purl.org/dc/terms/"),
("eli", "http://data.europa.eu/eli/ontology#"),
("foaf", "http://xmlns.com/foaf/0.1/"),
("odrl", "http://www.w3.org/ns/odrl/2/"),
("rdfs", "http://www.w3.org/2000/01/rdf-schema#"),
(
"registry_manifest",
"https://id.registrystack.org/ns/registry-manifest/v1#",
),
("sh", "http://www.w3.org/ns/shacl#"),
("skos", "http://www.w3.org/2004/02/skos/core#"),
("xsd", "http://www.w3.org/2001/XMLSchema#"),
];
pub const RUNTIME_ONLY_KEYS: &[&str] = &[
"admin_bind",
"admin_listener",
"audit",
"auth",
"bind",
"bindings",
"capabilities",
"column",
"config_trust",
"file_path",
"listener",
"listeners",
"peer_allowlist",
"peers",
"private_jwk",
"private_jwk_env",
"query",
"replay",
"required_filters",
"rows_scope",
"scope",
"secret_provider",
"secret_providers",
"signing_keys",
"source",
"source_connections",
"source_id",
"table",
"token_url",
"url",
"url_env",
"visibility",
];
const SECRET_BEARING_KEYS: &[&str] = &[
"api_key",
"client_secret",
"credentials",
"password",
"private_key",
"secret",
"token",
];
const SECRET_COMPACT_SUFFIXES: &[&str] = &[
"credential",
"credentials",
"env",
"key",
"keys",
"password",
"passwords",
"secret",
"secrets",
"token",
"tokens",
"value",
"values",
];
const CREDENTIAL_SECRET_SUFFIXES: &[&str] = &[
"env",
"key",
"keys",
"password",
"passwords",
"secret",
"secrets",
"token",
"tokens",
"value",
"values",
];
#[must_use]
pub fn is_runtime_only_key(key: &str) -> bool {
RUNTIME_ONLY_KEYS.contains(&key)
}
fn is_secret_bearing_key(key: &str) -> bool {
let normalized = normalize_manifest_key(key);
let segments = normalized
.split('_')
.filter(|segment| !segment.is_empty())
.collect::<Vec<_>>();
let compact = normalized.replace('_', "");
if credential_secret_key(&compact) {
return true;
}
SECRET_BEARING_KEYS.iter().any(|secret| {
secret_matches_segments(&segments, secret) || secret_matches_compact(&compact, secret)
})
}
fn credential_secret_key(compact: &str) -> bool {
if compact == "credential" || compact == "credentials" {
return true;
}
if compact
.strip_prefix("credential")
.is_some_and(secret_numeric_suffix)
|| compact
.strip_prefix("credentials")
.is_some_and(secret_numeric_suffix)
{
return true;
}
if credential_secret_occurrence(compact, "credential")
|| credential_secret_occurrence(compact, "credentials")
{
return true;
}
if compact.len() > "credential".len() && compact.ends_with("credential") {
return true;
}
if compact.len() > "credentials".len() && compact.ends_with("credentials") {
return true;
}
for prefix in ["credential", "credentials"] {
let Some(suffix) = compact.strip_prefix(prefix) else {
continue;
};
if !suffix.is_empty()
&& CREDENTIAL_SECRET_SUFFIXES
.iter()
.any(|secret_suffix| suffix.starts_with(secret_suffix))
{
return true;
}
}
false
}
fn credential_secret_occurrence(compact: &str, secret: &str) -> bool {
compact.match_indices(secret).any(|(index, _)| {
let suffix_start = index + secret.len();
let prefix = &compact[..index];
let suffix = &compact[suffix_start..];
!prefix.is_empty()
&& !suffix.is_empty()
&& (secret_numeric_suffix(suffix)
|| CREDENTIAL_SECRET_SUFFIXES
.iter()
.any(|secret_suffix| suffix.starts_with(secret_suffix)))
})
}
fn secret_matches_segments(segments: &[&str], secret: &str) -> bool {
let secret_segments = secret.split('_').collect::<Vec<_>>();
if secret_segments.len() == 1 {
return segments.contains(&secret_segments[0]);
}
segments
.windows(secret_segments.len())
.any(|window| window == secret_segments.as_slice())
}
fn secret_matches_compact(compact: &str, secret: &str) -> bool {
let compact_secret = secret.replace('_', "");
if compact == compact_secret || compact.ends_with(&compact_secret) {
return true;
}
if compact
.strip_prefix(&compact_secret)
.is_some_and(secret_numeric_suffix)
|| compact
.strip_suffix(&compact_secret)
.is_some_and(secret_numeric_prefix)
{
return true;
}
if secret.contains('_') && compact.contains(&compact_secret) {
return true;
}
for suffix in secret_compact_suffixes(compact, &compact_secret) {
if !suffix.is_empty()
&& SECRET_COMPACT_SUFFIXES
.iter()
.any(|credential_suffix| suffix.starts_with(credential_suffix))
{
return true;
}
}
false
}
fn secret_compact_suffixes<'a>(
compact: &'a str,
compact_secret: &'a str,
) -> impl Iterator<Item = &'a str> {
compact.match_indices(compact_secret).map(|(index, _)| {
let suffix_start = index + compact_secret.len();
&compact[suffix_start..]
})
}
fn secret_numeric_suffix(value: &str) -> bool {
!value.is_empty() && value.chars().all(|ch| ch.is_ascii_digit())
}
fn secret_numeric_prefix(value: &str) -> bool {
!value.is_empty() && value.chars().next().is_some_and(|ch| ch.is_ascii_digit())
}
fn normalize_manifest_key(key: &str) -> String {
key.chars()
.map(|ch| {
if ch.is_ascii_alphanumeric() {
ch.to_ascii_lowercase()
} else {
'_'
}
})
.collect()
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ManifestDigestError {
#[error("metadata manifest serialization failed: {0}")]
Json(#[from] serde_json::Error),
#[error("metadata manifest canonicalization failed: {0}")]
CanonicalJson(#[from] registry_platform_canonical_json::JcsError),
}
pub fn canonicalize_json(value: &Value) -> Result<Vec<u8>, ManifestDigestError> {
Ok(registry_platform_canonical_json::canonicalize_json(value)?)
}
pub fn source_manifest_digest(manifest: &MetadataManifest) -> Result<String, ManifestDigestError> {
let value = serde_json::to_value(manifest)?;
let canonical = canonicalize_json(&value)?;
Ok(sha256_uri(&canonical))
}
pub fn compute_policy_hash(policy: &Value) -> Result<String, ManifestDigestError> {
let canonical = canonicalize_json(policy)?;
Ok(sha256_uri(&canonical))
}
pub fn compute_evidence_pack_policy_hash(
evidence_pack: &EvidencePackMetadata,
) -> Result<Option<String>, ManifestDigestError> {
evidence_pack
.policy
.as_ref()
.map(compute_policy_hash)
.transpose()
}
pub fn verify_evidence_pack_policy_hash(
evidence_pack: &EvidencePackMetadata,
) -> Result<Option<bool>, ManifestDigestError> {
let Some(declared) = evidence_pack.policy_hash.as_deref() else {
return Ok(None);
};
let Some(computed) = compute_evidence_pack_policy_hash(evidence_pack)? else {
return Ok(None);
};
Ok(Some(declared == computed))
}
#[must_use]
pub fn sha256_uri(bytes: &[u8]) -> String {
let digest = Sha256::digest(bytes);
let mut output = String::with_capacity("sha256:".len() + 64);
output.push_str("sha256:");
for byte in digest {
use std::fmt::Write as _;
let _ = write!(output, "{byte:02x}");
}
output
}
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
pub struct MetadataManifest {
pub schema_version: String,
pub catalog: CatalogManifest,
#[serde(default)]
pub vocabularies: BTreeMap<String, String>,
#[serde(default)]
pub profiles: Vec<ProfileClaim>,
#[serde(default)]
pub evaluation_profiles: Vec<EvaluationProfileManifest>,
#[serde(default)]
pub ecosystem_bindings: Vec<EcosystemBindingManifest>,
#[serde(default)]
pub requirements: Vec<RequirementManifest>,
#[serde(default)]
pub evidence_types: Vec<EvidenceTypeManifest>,
#[serde(default)]
pub authorities: Vec<AuthorityManifest>,
#[serde(default)]
pub public_services: Vec<ServiceManifest>,
#[serde(default)]
pub data_services: Vec<DataServiceManifest>,
#[serde(default)]
pub forms: Vec<FormManifest>,
#[serde(default)]
pub datasets: Vec<DatasetManifest>,
#[serde(default)]
pub codelists: Vec<CodelistManifest>,
}
impl<'de> Deserialize<'de> for MetadataManifest {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = Value::deserialize(deserializer)?;
let mut runtime_keys = Vec::new();
let mut secret_keys = Vec::new();
collect_disallowed_json_keys(&value, &mut runtime_keys, &mut secret_keys);
if !runtime_keys.is_empty() {
runtime_keys.sort();
runtime_keys.dedup();
return Err(de::Error::custom(format!(
"runtime-only keys are not allowed in metadata manifests: {}",
runtime_keys.join(", ")
)));
}
if !secret_keys.is_empty() {
secret_keys.sort();
secret_keys.dedup();
return Err(de::Error::custom(format!(
"secret-bearing keys are not allowed in metadata manifests: {}",
secret_keys.join(", ")
)));
}
let fields: MetadataManifestFields =
serde_path_to_error::deserialize(value).map_err(de::Error::custom)?;
Ok(fields.into())
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
struct MetadataManifestFields {
schema_version: String,
catalog: CatalogManifest,
#[serde(default)]
vocabularies: BTreeMap<String, String>,
#[serde(default)]
profiles: Vec<ProfileClaim>,
#[serde(default)]
evaluation_profiles: Vec<EvaluationProfileManifest>,
#[serde(default)]
ecosystem_bindings: Vec<EcosystemBindingManifest>,
#[serde(default)]
requirements: Vec<RequirementManifest>,
#[serde(default)]
evidence_types: Vec<EvidenceTypeManifest>,
#[serde(default)]
authorities: Vec<AuthorityManifest>,
#[serde(default)]
public_services: Vec<ServiceManifest>,
#[serde(default)]
data_services: Vec<DataServiceManifest>,
#[serde(default)]
forms: Vec<FormManifest>,
#[serde(default)]
datasets: Vec<DatasetManifest>,
#[serde(default)]
codelists: Vec<CodelistManifest>,
}
impl From<MetadataManifestFields> for MetadataManifest {
fn from(fields: MetadataManifestFields) -> Self {
Self {
schema_version: fields.schema_version,
catalog: fields.catalog,
vocabularies: fields.vocabularies,
profiles: fields.profiles,
evaluation_profiles: fields.evaluation_profiles,
ecosystem_bindings: fields.ecosystem_bindings,
requirements: fields.requirements,
evidence_types: fields.evidence_types,
authorities: fields.authorities,
public_services: fields.public_services,
data_services: fields.data_services,
forms: fields.forms,
datasets: fields.datasets,
codelists: fields.codelists,
}
}
}
fn collect_disallowed_json_keys(
value: &Value,
runtime_keys: &mut Vec<String>,
secret_keys: &mut Vec<String>,
) {
match value {
Value::Object(map) => {
for (key, child) in map {
if is_runtime_only_key(key) {
runtime_keys.push(key.clone());
}
if is_secret_bearing_key(key) {
secret_keys.push(key.clone());
}
collect_disallowed_json_keys(child, runtime_keys, secret_keys);
}
}
Value::Array(values) => {
for child in values {
collect_disallowed_json_keys(child, runtime_keys, secret_keys);
}
}
Value::Null | Value::Bool(_) | Value::Number(_) | Value::String(_) => {}
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct CatalogManifest {
pub id: String,
pub base_url: String,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
pub publisher: PublisherManifest,
#[serde(default)]
pub participant_id: Option<String>,
#[serde(default)]
pub conforms_to: Vec<String>,
#[serde(default)]
pub standards: StandardsManifest,
#[serde(default)]
pub application_profiles: Vec<ApplicationProfile>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct StandardsManifest {
#[serde(default)]
pub dcat: Option<String>,
#[serde(default)]
pub shacl: Option<String>,
#[serde(default)]
pub json_schema: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ApplicationProfile {
pub id: String,
pub version: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ProfileClaim {
pub id: String,
pub version: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EvaluationProfileManifest {
pub id: String,
pub ruleset: String,
pub claim_id: String,
pub subject_id_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_source_observed_age_seconds: Option<u64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evidence_pack: Option<EvidencePackMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EvidencePackMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pack_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pack_version: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_basis: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub semantic_profile: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evidence_envelope: Option<Value>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub required_gates: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub allowed_outputs: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub policy_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub policy_version: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub policy_hash: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_mapping: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub policy: Option<Value>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fixtures: Vec<Value>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub synthetic_data: Vec<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub odrl_policy_url: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub odrl_enforcement: Option<OdrlEnforcementProfile>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct OdrlEnforcementProfile {
pub profile: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub constraint_terms: Vec<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EcosystemBindingManifest {
pub id: String,
pub version: String,
pub profile: String,
#[serde(rename = "type")]
pub binding_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub title: Option<LocalizedText>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<LocalizedText>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vocabulary: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub request_envelope: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub response_envelope: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transport: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub trust_framework: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub credential_format: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub assurance_model: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub conformance: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evidence_pack: Option<EvidencePackMetadata>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub profiles: Vec<ProfileClaim>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum LocalizedText {
Plain(String),
Localized(BTreeMap<String, String>),
}
impl LocalizedText {
pub fn text(&self) -> String {
match self {
Self::Plain(value) => value.clone(),
Self::Localized(values) => values
.get("en")
.or_else(|| values.values().next())
.cloned()
.unwrap_or_default(),
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PublisherManifest {
pub name: String,
#[serde(default)]
pub iri: Option<String>,
#[serde(default)]
pub authority_type: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct AuthorityManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub name: String,
#[serde(default)]
pub authority_type: Option<String>,
#[serde(default)]
pub spatial: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ServiceManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub competent_authority: Option<String>,
#[serde(default)]
pub jurisdiction: Option<String>,
#[serde(default)]
pub channels: Vec<ChannelManifest>,
#[serde(default)]
pub holds_requirements: Vec<String>,
#[serde(default)]
pub produces: Vec<String>,
#[serde(default)]
pub data_services: Vec<String>,
#[serde(default)]
pub forms: Vec<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ChannelManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
#[serde(default)]
pub title: Option<LocalizedText>,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub kind: Option<String>,
#[serde(default)]
pub access_url: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct DataServiceManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub endpoint_url: Option<String>,
#[serde(default)]
pub endpoint_description: Option<String>,
#[serde(default)]
pub serves_datasets: Vec<String>,
#[serde(default)]
pub conforms_to: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
pub service: String,
#[serde(default)]
pub channel: Option<String>,
#[serde(default)]
pub validates_with: Option<FormValidationManifest>,
#[serde(default)]
pub sections: Vec<FormSectionManifest>,
#[serde(default)]
pub fields: Vec<FormFieldManifest>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormValidationManifest {
#[serde(default)]
pub json_schema: Option<String>,
#[serde(default)]
pub shacl: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormSectionManifest {
pub id: String,
#[serde(default)]
pub title: Option<LocalizedText>,
#[serde(default)]
pub repeatable: bool,
#[serde(default)]
pub min_occurs: Option<u32>,
#[serde(default)]
pub max_occurs: Option<u32>,
#[serde(default)]
pub visible_when: Option<FormVisibilityManifest>,
#[serde(default)]
pub fields: Vec<FormFieldManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormFieldManifest {
pub id: String,
#[serde(default)]
pub name: Option<String>,
pub label: LocalizedText,
#[serde(default)]
pub widget_type: Option<String>,
#[serde(default)]
pub data_type: Option<String>,
#[serde(default)]
pub concept: Option<String>,
#[serde(default)]
pub supports_requirement: Option<String>,
#[serde(default)]
pub required: bool,
#[serde(default)]
pub min_occurs: Option<u32>,
#[serde(default)]
pub max_occurs: Option<u32>,
#[serde(default)]
pub visible_when: Option<FormVisibilityManifest>,
#[serde(default)]
pub fulfillment: Option<FormFulfillmentManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormVisibilityManifest {
pub field: String,
pub equals: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct FormFulfillmentManifest {
#[serde(default)]
pub modes: Vec<String>,
#[serde(default)]
pub preferred_mode: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct DatasetManifest {
pub id: String,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub owner: Option<String>,
#[serde(default)]
pub sensitivity: Sensitivity,
#[serde(default)]
pub access_rights: AccessRights,
#[serde(default)]
pub update_frequency: UpdateFrequency,
#[serde(default)]
pub conforms_to: Vec<String>,
/// DCAT-AP `dcatap:applicableLegislation` IRIs. These are standard
/// evidence links only; downstream systems may use them to infer legal
/// readiness, but Registry Relay does not publish an authority verdict.
#[serde(default)]
pub applicable_legislation: Vec<String>,
#[serde(default)]
pub spatial_coverage: Option<String>,
#[serde(default)]
pub status: Option<AdmsStatus>,
/// Related CPSV public services that produce this dataset. Published as
/// JSON-LD `cpsv:PublicService` nodes with `cpsv:produces`; consumers can
/// interpret that evidence, but the manifest does not declare
/// source-of-truth status.
#[serde(default)]
pub public_services: Vec<PublicServiceManifest>,
#[serde(default)]
pub policy: Option<DatasetPolicyManifest>,
#[serde(default)]
pub evidence_offerings: Vec<EvidenceOfferingManifest>,
#[serde(default)]
pub entities: Vec<EntityManifest>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct DatasetPolicyManifest {
#[serde(default)]
pub uid: Option<String>,
#[serde(default)]
pub assigner: Option<String>,
#[serde(default)]
pub profile: Vec<String>,
#[serde(default)]
pub permissions: Vec<PolicyRuleManifest>,
#[serde(default)]
pub prohibitions: Vec<PolicyRuleManifest>,
#[serde(default)]
pub obligations: Vec<PolicyDutyManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PolicyRuleManifest {
pub action: String,
#[serde(default)]
pub target: Option<String>,
#[serde(default)]
pub assignee: Option<String>,
#[serde(default)]
pub constraints: Vec<PolicyConstraintManifest>,
#[serde(default)]
pub duties: Vec<PolicyDutyManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PolicyDutyManifest {
pub action: String,
#[serde(default)]
pub target: Option<String>,
#[serde(default)]
pub assignee: Option<String>,
#[serde(default)]
pub constraints: Vec<PolicyConstraintManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PolicyConstraintManifest {
pub left_operand: String,
pub operator: String,
pub right_operand: PolicyOperandValue,
#[serde(default)]
pub unit: Option<String>,
#[serde(default)]
pub datatype: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PolicyOperandValue {
#[serde(default)]
pub iri: Option<String>,
#[serde(default)]
pub value: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct PublicServiceManifest {
#[serde(default)]
pub id: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct RequirementManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub rdf_type: Option<String>,
#[serde(default)]
pub procedure_contexts: Vec<String>,
#[serde(default)]
pub reference_frameworks: Vec<ReferenceFrameworkManifest>,
#[serde(default)]
pub evidence_type_lists: Vec<EvidenceTypeListManifest>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EvidenceTypeListManifest {
#[serde(default)]
pub id: Option<String>,
#[serde(default)]
pub title: Option<LocalizedText>,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub evidence_types: Vec<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ReferenceFrameworkManifest {
pub iri: String,
pub identifier: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EvidenceTypeManifest {
pub id: String,
#[serde(default)]
pub iri: Option<String>,
pub title: LocalizedText,
#[serde(default)]
pub description: Option<LocalizedText>,
#[serde(default)]
pub proves: Vec<String>,
#[serde(default)]
pub information_concepts: Vec<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct EvidenceOfferingManifest {
pub id: String,
#[serde(default)]