mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
perf(javascript): validate the version change graph once (#1370)
compareJavaScriptApplicationVersions built the change graph with createJavaScriptApplicationGraph, which validates it and re-derives every node, observation, edge and graph ID, then parsed the result with a schema that embeds the full graph schema, repeating all of that work. Seal the change graph with the owned immutable factory and accept that exact sealed graph in the result parse, as owned analysis results already do. Items, coverage and the public result schema are unchanged; output is byte-identical.
This commit is contained in:
@@ -2,7 +2,11 @@ import { z } from "zod";
|
||||
|
||||
import { emptyArraySchema } from "../emptyArraySchema.js";
|
||||
import { evidenceSchema } from "../evidence.js";
|
||||
import { javascriptApplicationGraphSchema } from "./javascriptApplicationGraph.js";
|
||||
import {
|
||||
isValidatedImmutableJavaScriptApplicationGraph,
|
||||
javascriptApplicationGraphSchema,
|
||||
type JavaScriptApplicationGraph,
|
||||
} from "./javascriptApplicationGraph.js";
|
||||
import { JAVASCRIPT_APPLICATION_NODE_KINDS } from "./javascriptApplicationGraphSchemas.js";
|
||||
import { prefixedDigestSchema } from "../digests.js";
|
||||
|
||||
@@ -234,6 +238,14 @@ export const applicationVersionComparisonResultSchema = z
|
||||
});
|
||||
});
|
||||
|
||||
/** Reuse the exact owned change graph while validating the rest of the result. */
|
||||
export const ownedApplicationVersionComparisonResultSchema =
|
||||
applicationVersionComparisonResultSchema.safeExtend({
|
||||
graph: z.custom<JavaScriptApplicationGraph>(
|
||||
isValidatedImmutableJavaScriptApplicationGraph,
|
||||
),
|
||||
});
|
||||
|
||||
export type ApplicationVersionComparisonItem = z.infer<
|
||||
typeof comparisonItemSchema
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user