Skip to main content

Function: checkRollback()

checkRollback(artifact, registry): RollbackCheck

Defined in: packages/core/src/checkRollback.ts:37

Asks whether one stored artifact would still render against a registry — the question to settle before pointing a route back at it. Every name in the artifact's blockVersions has to be registered at the version recorded there; a different version, or no entry at all, is drift.

Parameters

artifact

Artifact

The rollback target, as read back from the store. Only blockVersions is read, so an artifact hand-built for a test needs nothing else to be accurate.

registry

Registry

The registry the running code holds now, from createRegistry.

Returns

RollbackCheck

{ compatible: true }, or { compatible: false, drifted } naming every block that moved. Drift is a value, not a throw: whether it stops the rollback is the caller's call.

Example

import { checkRollback, createRegistry, defineBlock } from "@nubbin/core";
import { z } from "zod";

const heroAtV2 = defineBlock({
name: "Hero",
schema: z.object({ title: z.string() }),
component: null,
version: 2,
slots: {},
});

// artifact.blockVersions is { Hero: 1 }
checkRollback(artifact, createRegistry([heroAtV2]));
// { compatible: false, drifted: ["Hero"] }