(
session: &Service,
target: &str,
person_did: &str,
)
| 5085 | } |
| 5086 | |
| 5087 | fn provenance_export_with_session( |
| 5088 | session: &Service, |
| 5089 | target: &str, |
| 5090 | person_did: &str, |
| 5091 | ) -> CliResult<(Merkle, Vec<ProvenanceWireGraph>)> { |
| 5092 | let request = pb::ExportProvenanceRequest { |
| 5093 | repository: Some(session.reference.clone()), |
| 5094 | change: None, |
| 5095 | view: None, |
| 5096 | person_did: Some(person_did.to_string()), |
| 5097 | target: Some(target.to_string()), |
| 5098 | }; |
| 5099 | let response = session.export_provenance(request)?; |
| 5100 | let resolved = response |
| 5101 | .resolved_change |
| 5102 | .as_ref() |
| 5103 | .and_then(|hash| hash.value.clone().try_into().ok()) |
| 5104 | .map(Merkle) |
| 5105 | .ok_or_else(|| CliError::Internal(anyhow::anyhow!("no resolved change")))?; |
| 5106 | let mut graphs = Vec::with_capacity(response.graphs.len()); |
| 5107 | for bundle in &response.graphs { |
| 5108 | let graph_payload = bundle |
| 5109 | .graph |
| 5110 | .as_ref() |
| 5111 | .filter(|bytes| bytes.schema == "atomic.prov.graph.v1") |
| 5112 | .ok_or_else(|| { |
| 5113 | CliError::Internal(anyhow::anyhow!("missing provenance graph bundle")) |
| 5114 | })?; |
| 5115 | let graph: atomic_core::change::ProvenanceGraph = |
| 5116 | serde_json::from_slice(&graph_payload.payload) |
| 5117 | .map_err(|error| CliError::Internal(anyhow::anyhow!("graph bundle: {error}")))?; |
| 5118 | let input_payload = bundle |
| 5119 | .input |
| 5120 | .as_ref() |
| 5121 | .filter(|bytes| bytes.schema == "atomic.prov.input.v1") |
| 5122 | .ok_or_else(|| CliError::Internal(anyhow::anyhow!("missing prov input bundle")))?; |
| 5123 | graphs.push(ProvenanceWireGraph { |
| 5124 | graph, |
| 5125 | input: prov_input_domain(&input_payload.payload)?, |
| 5126 | prior_activities: bundle.prior_activities.clone(), |
| 5127 | chain_truncated: bundle.chain_truncated, |
| 5128 | }); |
| 5129 | } |
| 5130 | Ok((resolved, graphs)) |
| 5131 | } |
| 5132 | |
| 5133 | // --------------------------------------------------------------------------- |
| 5134 | // remote registry (SyncService) |
no test coverage detected