mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 23:36:41 +00:00
refactor(domain): consolidate canonical ordering and digest helpers (#624)
* refactor(domain): consolidate canonical ordering and digest helpers Single owner for code-point ordering (domain/canonicalOrdering.ts) and canonical JSON digests (domain/comparisonSemantics.ts). Delete all local compareCodePoints/compareText/digestCanonical duplicates and migrate every importer. No re-export shims. * fix(ci): allow slower real browser startup
This commit is contained in:
1 parent
38b293329c
commit
ba3869c597
74 files changed
+438
-530
No files matched your search
@@ -1,7 +1,5 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import canonicalize from "canonicalize";
|
||||
|
||||
import { canonicalDigest } from "./comparisonSemantics.js";
|
||||
import { uniqueSorted } from "./canonicalOrdering.js";
|
||||
import type { Evidence } from "./evidence.js";
|
||||
import { buildJavaScriptApplicationChangeGraph } from "./javascriptApplicationChangeGraph.js";
|
||||
import {
|
||||
@@ -9,7 +7,6 @@ import {
|
||||
type ApplicationVersionComparisonResult,
|
||||
} from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
import type { JavaScriptApplicationGraph } from "./javascriptApplicationGraph.js";
|
||||
import { compareCodePoints } from "./javascriptApplicationGraph.js";
|
||||
import { classifyJavaScriptApplicationVersions } from "./javascriptApplicationVersionItems.js";
|
||||
import { matchJavaScriptApplicationVersions } from "./javascriptApplicationVersionKeys.js";
|
||||
|
||||
@@ -81,7 +78,7 @@ export const compareJavaScriptApplicationVersions = (
|
||||
};
|
||||
return applicationVersionComparisonResultSchema.parse({
|
||||
...semantic,
|
||||
comparison_id: `javc_${digestCanonical(semantic)}`,
|
||||
comparison_id: `javc_${canonicalDigest(semantic, "Application version comparison")}`,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -164,16 +161,3 @@ const comparisonLimitations = (
|
||||
"At least one source graph is incomplete; unmatched entities on the opposite side remain unknown rather than added or removed.",
|
||||
]),
|
||||
]);
|
||||
|
||||
const digestCanonical = (value: unknown): string => {
|
||||
const encoded = canonicalize(value);
|
||||
if (encoded === undefined)
|
||||
throw new TypeError(
|
||||
"Application version comparison could not canonicalize data",
|
||||
);
|
||||
return createHash("sha256").update(encoded).digest("hex");
|
||||
};
|
||||
|
||||
const uniqueSorted = <Value extends string>(
|
||||
values: readonly Value[],
|
||||
): Value[] => [...new Set(values)].sort(compareCodePoints);
|
||||
Reference in new issue
Block a user