(
session: &Service,
target: &str,
person_did: &str,
)
| 5045 | } |
| 5046 | |
| 5047 | fn provenance_export_with_session( |
| 5048 | session: &Service, |
| 5049 | target: &str, |
| 5050 | person_did: &str, |
| 5051 | ) -> CliResult<(Merkle, Vec<ProvenanceWireGraph>)> { |
| 5052 | let request = pb::ExportProvenanceRequest { |
| 5053 | repository: Some(session.reference.clone()), |
| 5054 | change: None, |
| 5055 | view: None, |
| 5056 | person_did: Some(person_did.to_string()), |
| 5057 | target: Some(target.to_string()), |
| 5058 | }; |
| 5059 | let response = session.export_provenance(request)?; |
| 5060 | let resolved = response |
| 5061 | .resolved_change |
| 5062 | .as_ref() |
| 5063 | .and_then(|hash| hash.value.clone().try_into().ok()) |
| 5064 | .map(Merkle) |
| 5065 | .ok_or_else(|| CliError::Internal(anyhow::anyhow!("no resolved change")))?; |
| 5066 | let mut graphs = Vec::with_capacity(response.graphs.len()); |
| 5067 | for bundle in &response.graphs { |
| 5068 | let graph_payload = bundle |
| 5069 | .graph |
| 5070 | .as_ref() |
| 5071 | .filter(|bytes| bytes.schema == "atomic.prov.graph.v1") |
| 5072 | .ok_or_else(|| { |
| 5073 | CliError::Internal(anyhow::anyhow!("missing provenance graph bundle")) |
| 5074 | })?; |
| 5075 | let graph: atomic_core::change::ProvenanceGraph = |
| 5076 | serde_json::from_slice(&graph_payload.payload) |
| 5077 | .map_err(|error| CliError::Internal(anyhow::anyhow!("graph bundle: {error}")))?; |
| 5078 | let input_payload = bundle |
| 5079 | .input |
| 5080 | .as_ref() |
| 5081 | .filter(|bytes| bytes.schema == "atomic.prov.input.v1") |
| 5082 | .ok_or_else(|| CliError::Internal(anyhow::anyhow!("missing prov input bundle")))?; |
| 5083 | graphs.push(ProvenanceWireGraph { |
| 5084 | graph, |
| 5085 | input: prov_input_domain(&input_payload.payload)?, |
| 5086 | prior_activities: bundle.prior_activities.clone(), |
| 5087 | chain_truncated: bundle.chain_truncated, |
| 5088 | }); |
| 5089 | } |
| 5090 | Ok((resolved, graphs)) |
| 5091 | } |
| 5092 | |
| 5093 | // --------------------------------------------------------------------------- |
| 5094 | // remote registry (SyncService) |
no test coverage detected