diff --git a/packages/state/api/api.json b/packages/state/api/api.json index fc6d8c913..6b0f0291a 100644 --- a/packages/state/api/api.json +++ b/packages/state/api/api.json @@ -2387,7 +2387,7 @@ }, { "kind": "Content", - "text": "Value | (() => Value)" + "text": "(() => Value) | Value" }, { "kind": "Content", @@ -2813,7 +2813,7 @@ }, { "kind": "Content", - "text": "undefined | any[]" + "text": "any[] | undefined" }, { "kind": "Content", diff --git a/packages/tlschema/src/migrations.test.ts b/packages/tlschema/src/migrations.test.ts index 377920f2d..f9a6d9548 100644 --- a/packages/tlschema/src/migrations.test.ts +++ b/packages/tlschema/src/migrations.test.ts @@ -2030,6 +2030,34 @@ describe('Fractional indexing for line points', () => { }) }) +describe('add white', () => { + const { up, down } = rootShapeMigrations.migrators[rootShapeVersions.AddWhite] + + test('up works as expected', () => { + expect( + up({ + props: {}, + }) + ).toEqual({ + props: {}, + }) + }) + + test('down works as expected', () => { + expect( + down({ + props: { + color: 'white', + }, + }) + ).toEqual({ + props: { + color: 'black', + }, + }) + }) +}) + /* --- PUT YOUR MIGRATIONS TESTS ABOVE HERE --- */ for (const migrator of allMigrators) { diff --git a/packages/tlschema/src/records/TLShape.ts b/packages/tlschema/src/records/TLShape.ts index 5821ae09e..300c5fad4 100644 --- a/packages/tlschema/src/records/TLShape.ts +++ b/packages/tlschema/src/records/TLShape.ts @@ -87,11 +87,12 @@ export const rootShapeVersions = { AddIsLocked: 1, HoistOpacity: 2, AddMeta: 3, + AddWhite: 4, } as const /** @internal */ export const rootShapeMigrations = defineMigrations({ - currentVersion: rootShapeVersions.AddMeta, + currentVersion: rootShapeVersions.AddWhite, migrators: { [rootShapeVersions.AddIsLocked]: { up: (record) => { @@ -147,6 +148,22 @@ export const rootShapeMigrations = defineMigrations({ } }, }, + [rootShapeVersions.AddWhite]: { + up: (record) => { + return { + ...record, + } + }, + down: (record) => { + return { + ...record, + props: { + ...record.props, + color: record.props.color === 'white' ? 'black' : record.props.color, + }, + } + }, + }, }, })