createShapePropsMigrationIds

See source code

Creates properly formatted migration IDs for shape properties.

Generates standardized migration IDs following the convention: com.tldraw.shape.{shapeType}/{version}

function createShapePropsMigrationIds<
  const S extends string,
  const T extends Record<string, number>,
>(
  shapeType: S,
  ids: T
): {
  [k in keyof T]: `com.tldraw.shape.${S}/${T[k]}`
}

Example

const myShapeVersions = createShapePropsMigrationIds('custom', {
  AddColor: 1,
  AddSize: 2,
  RefactorProps: 3,
})
// Result: {
//   AddColor: 'com.tldraw.shape.custom/1',
//   AddSize: 'com.tldraw.shape.custom/2',
//   RefactorProps: 'com.tldraw.shape.custom/3'
// }

Parameters

NameDescription

shapeType

S

The type of shape these migrations apply to

ids

T

Record mapping migration names to version numbers

Returns

{
  [k in keyof T]: `com.tldraw.shape.${S}/${T[k]}`
}

Record with the same keys but formatted migration ID values

Prev
createShapeId
Next
createShapePropsMigrationSequence