mirror of
https://github.com/morluto/rea.git
synced 2026-10-31 03:45:39 +00:00
refactor(artifacts): consolidate inventory into inspection
This commit is contained in:
1 parent
a66e43a99d
commit
0fe96d92df
28 files changed
+375
-280
No files matched your search
@@ -126,19 +126,23 @@ export const resolveCompareApplicationVersionsRequestValidated = (
|
||||
input: CompareApplicationVersionsRequest,
|
||||
lookup?: EvidenceLookup,
|
||||
): Result<ComparisonInput, AnalysisError> => {
|
||||
const left = graphEvidence(
|
||||
"left" in input
|
||||
? { application: input.left }
|
||||
: { application_evidence_id: input.left_evidence_id },
|
||||
lookup,
|
||||
);
|
||||
const leftReference = input.left ?? input.left_evidence_id;
|
||||
if (leftReference === undefined)
|
||||
return err(
|
||||
new AnalysisInputError("compare_application_versions", undefined, [
|
||||
{ path: ["left"], reason: "missing_argument" },
|
||||
]),
|
||||
);
|
||||
const left = resolveApplicationGraphReference(leftReference, lookup);
|
||||
if (!left.ok) return left;
|
||||
const right = graphEvidence(
|
||||
"right" in input
|
||||
? { application: input.right }
|
||||
: { application_evidence_id: input.right_evidence_id },
|
||||
lookup,
|
||||
);
|
||||
const rightReference = input.right ?? input.right_evidence_id;
|
||||
if (rightReference === undefined)
|
||||
return err(
|
||||
new AnalysisInputError("compare_application_versions", undefined, [
|
||||
{ path: ["right"], reason: "missing_argument" },
|
||||
]),
|
||||
);
|
||||
const right = resolveApplicationGraphReference(rightReference, lookup);
|
||||
if (!right.ok) return right;
|
||||
const leftNative = resolveEvidenceReferences(
|
||||
lookup,
|
||||
@@ -265,6 +269,14 @@ const graphEvidence = (
|
||||
return resolved.ok ? ok(resolved.value[0]) : resolved;
|
||||
};
|
||||
|
||||
const resolveApplicationGraphReference = (
|
||||
reference: Evidence | string,
|
||||
lookup: EvidenceLookup | undefined,
|
||||
) =>
|
||||
typeof reference === "string"
|
||||
? graphEvidence({ application_evidence_id: reference }, lookup)
|
||||
: graphEvidence({ application: reference }, lookup);
|
||||
|
||||
const invalid = <Value>(
|
||||
operation: string,
|
||||
cause: z.ZodError,
|
||||
|
||||
Reference in new issue
Block a user