mirror of
https://github.com/morluto/rea
synced 2026-10-29 07:17:42 -04:00
18 lines
605 B
TypeScript
18 lines
605 B
TypeScript
import { canonicalJson } from "../comparisonSemantics.js";
|
|
import {
|
|
javaScriptSemanticGraphSchema,
|
|
type JavaScriptSemanticGraph,
|
|
} from "./javascriptSemanticGraph.js";
|
|
|
|
/** Parse a stored semantic graph and reject stale IDs. */
|
|
export const parseJavaScriptSemanticGraph = (
|
|
input: unknown,
|
|
): JavaScriptSemanticGraph => javaScriptSemanticGraphSchema.parse(input);
|
|
|
|
/** Serialize a verified semantic graph as canonical JSON. */
|
|
export const serializeJavaScriptSemanticGraph = (input: unknown): string =>
|
|
canonicalJson(
|
|
parseJavaScriptSemanticGraph(input),
|
|
"JavaScript semantic graph",
|
|
);
|