forked from mtusi2026/mtusi2026lab7
18 lines
574 B
TypeScript
18 lines
574 B
TypeScript
export type RuntimeMode = "canonical" | "checked-cache";
|
|
export function createRuntimePreparation(ports: {
|
|
build: () => Promise<void>;
|
|
verifyCache: () => Promise<void>;
|
|
}) {
|
|
if (
|
|
typeof ports?.build !== "function" ||
|
|
typeof ports?.verifyCache !== "function"
|
|
)
|
|
throw new Error("RUNTIME_PREPARATION_PORTS_REQUIRED");
|
|
return async (mode: RuntimeMode) => {
|
|
if (mode !== "canonical" && mode !== "checked-cache")
|
|
throw new Error("INVALID_RUNTIME_MODE");
|
|
if (mode === "canonical") await ports.build();
|
|
else await ports.verifyCache();
|
|
};
|
|
}
|