import { BaseRecord } from '../BaseRecord' import { defineMigrations } from '../migrate' import { createRecordType } from '../RecordType' import { StoreSchema } from '../StoreSchema' const UserVersion = { Initial: 0, } as const /** * A user of tldraw */ interface User extends BaseRecord<'user'> { name: string } const userMigrations = defineMigrations({ currentVersion: UserVersion.Initial, firstVersion: UserVersion.Initial, migrators: {}, }) const User = createRecordType('user', { migrations: userMigrations, }) const ShapeVersion = { Initial: 0, } as const const RectangleVersion = { Initial: 0, } as const interface Shape extends BaseRecord<'shape'> { type: string x: number y: number props: Props } interface RectangleProps { width: number height: number opactiy: number } interface OvalProps { radius: number borderStyle: 'solid' | 'dashed' } const shapeMigrations = defineMigrations({ currentVersion: ShapeVersion.Initial, firstVersion: ShapeVersion.Initial, migrators: {}, subTypeKey: 'type', subTypeMigrations: { rectangle: defineMigrations({ currentVersion: RectangleVersion.Initial, firstVersion: RectangleVersion.Initial, migrators: {}, }), }, }) const Shape = createRecordType>('shape', { migrations: shapeMigrations, }) // this interface only exists to be removed interface Org extends BaseRecord<'org'> { name: string } const Org = createRecordType('org', { migrations: defineMigrations({ currentVersion: 0, firstVersion: 0, migrators: {} }), }) export const testSchemaV0 = new StoreSchema>( [User, Shape, Org] as any, defineMigrations({ firstVersion: 0, currentVersion: 0, migrators: {} }) )