evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that migrates API schema definitions between different versions, handling type modifications and backward compatibility.
Create a schema migration system that transforms API schema objects between versions while maintaining type safety. The system should handle property modifications, additions, and removals.
Your system should support migrating schema definitions that evolve over time. Schemas may have properties that need to be:
The migration utility must provide compile-time type safety, ensuring that:
Implement the following functions:
migrateToV2 that accepts a V1 schema object and returns a V2 schema objectmigrateToV3 that accepts a V2 schema object and returns a V3 schema objectVersion 1 Schema has:
name: stringtype: stringrequired: booleandeprecated: booleanVersion 2 Schema removes deprecated and adds:
nullable: booleandescription: stringVersion 3 Schema removes nullable and adds:
allowNull: boolean (replaces nullable)metadata: object with source (string) and version (number) properties/**
* Migrates a V1 schema to V2
*/
export function migrateToV2(schema: SchemaV1): SchemaV2;
/**
* Migrates a V2 schema to V3
*/
export function migrateToV3(schema: SchemaV2): SchemaV3;Given a V1 schema {name: "user", type: "object", required: true, deprecated: false}, migrateToV2 returns a V2 schema without the deprecated property and with nullable: false and description: "" @test
Given a V2 schema {name: "user", type: "object", nullable: true, description: "User schema"}, migrateToV3 returns a V3 schema without nullable property, with allowNull: true and metadata: {source: "migration", version: 3} @test
The migrated V2 schema should not allow accessing the deprecated property (compile-time check) @test
The migrated V3 schema should not allow accessing the nullable property (compile-time check) @test
Provides TypeScript type utilities for API schema definitions and migrations.