mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(javascript): share Evidence parameter projection (#16604)
This commit is contained in:
1 parent
13e1ad9568
commit
b2cf8db876
1 file changed
+27
-33
@@ -11,7 +11,10 @@ import { JAVASCRIPT_APPLICATION_PROVIDER } from "../../domain/investigationProvi
|
||||
import { freezeOwnedJsonSnapshotSteps } from "../../domain/immutableJson.js";
|
||||
import { rememberOwnedApplicationGraphEvidence } from "./JavaScriptApplicationEvidenceGraph.js";
|
||||
import { completeJavaScriptAnalysisSteps } from "./JavaScriptAnalysisControl.js";
|
||||
import { jsonValueValidationSteps } from "../../domain/jsonValue.js";
|
||||
import {
|
||||
jsonValueValidationSteps,
|
||||
type JsonValue,
|
||||
} from "../../domain/jsonValue.js";
|
||||
import type { ProgressReporter } from "../../ports/ProgressReporter.js";
|
||||
|
||||
/** Create owned analysis Evidence while allowing request cancellation during sealing and hashing. */
|
||||
@@ -86,37 +89,28 @@ const applicationObservation = (
|
||||
locations: [{ kind: "artifact-path", path: "artifact-root" }],
|
||||
});
|
||||
|
||||
const recordedParameterKeys = [
|
||||
"input_path",
|
||||
"semantic_precision",
|
||||
"semantic_analysis",
|
||||
"format",
|
||||
"integrity_policy",
|
||||
"max_semantic_nodes",
|
||||
"max_semantic_nodes_per_file",
|
||||
"max_semantic_unknowns",
|
||||
"max_semantic_unknowns_per_file",
|
||||
"source_paths",
|
||||
"max_heap_mb",
|
||||
"analysis_timeout_ms",
|
||||
] as const satisfies readonly (keyof AnalyzeJavaScriptApplicationInput)[];
|
||||
|
||||
const parameters = (
|
||||
input: AnalyzeJavaScriptApplicationInput,
|
||||
): EvidenceObservation["parameters"] => ({
|
||||
input_path: input.input_path,
|
||||
...(input.semantic_precision === undefined
|
||||
? {}
|
||||
: { semantic_precision: input.semantic_precision }),
|
||||
...(input.semantic_analysis === undefined
|
||||
? {}
|
||||
: { semantic_analysis: input.semantic_analysis }),
|
||||
format: input.format,
|
||||
integrity_policy: input.integrity_policy,
|
||||
...(input.max_semantic_nodes === undefined
|
||||
? {}
|
||||
: { max_semantic_nodes: input.max_semantic_nodes }),
|
||||
...(input.max_semantic_nodes_per_file === undefined
|
||||
? {}
|
||||
: { max_semantic_nodes_per_file: input.max_semantic_nodes_per_file }),
|
||||
...(input.max_semantic_unknowns === undefined
|
||||
? {}
|
||||
: { max_semantic_unknowns: input.max_semantic_unknowns }),
|
||||
...(input.max_semantic_unknowns_per_file === undefined
|
||||
? {}
|
||||
: { max_semantic_unknowns_per_file: input.max_semantic_unknowns_per_file }),
|
||||
...(input.source_paths === undefined
|
||||
? {}
|
||||
: { source_paths: input.source_paths }),
|
||||
...(input.max_heap_mb === undefined
|
||||
? {}
|
||||
: { max_heap_mb: input.max_heap_mb }),
|
||||
...(input.analysis_timeout_ms === undefined
|
||||
? {}
|
||||
: { analysis_timeout_ms: input.analysis_timeout_ms }),
|
||||
});
|
||||
): EvidenceObservation["parameters"] => {
|
||||
const recorded: Record<string, JsonValue> = {};
|
||||
for (const key of recordedParameterKeys) {
|
||||
const value = input[key];
|
||||
if (value !== undefined) recorded[key] = value;
|
||||
}
|
||||
return recorded;
|
||||
};
|
||||
Reference in new issue
Block a user