Strata · API

compareSnapshot

compareSnapshot, from @niscorp/strata/check, compares a recorded snapshot with the current one. It returns the status same, missing when nothing was recorded, or changed with one diff line per difference; changed at the recorded version means a migration is required. Descriptions are not compared, so a reworded .describe() is not a change.

Recorded schema
z.object({
  label: z.string(),
  tone: z.enum(['primary', 'quiet']).optional(),
}).strict()
Current schema: reworded
z.object({
  label: z.string().describe('What it says.'),
  tone: z.enum(['primary', 'quiet']).optional(),
}).strict()
Current schema: renamed
z.object({
  text: z.string(),
  tone: z.enum(['primary', 'quiet']).optional(),
}).strict()
Comparison
{
  reworded: { status: 'same' },
  renamed: {
    status: 'changed',
    changes: [
      {
        kind: 'theatre.buttons/button',
        lines: [
          '- properties.label',
          '+ properties.text',
          '- required["label"]',
          '+ required["text"]',
        ],
      },
    ],
  },
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.