createBindingPropsMigrationIds

See source code

Creates properly formatted migration IDs for binding property migrations. Follows the convention: 'com.tldraw.binding.{bindingType}/{version}'

function createBindingPropsMigrationIds<
  S extends string,
  T extends Record<string, number>,
>(
  bindingType: S,
  ids: T
): {
  [k in keyof T]: `com.tldraw.binding.${S}/${T[k]}`
}

Example

// Create migration IDs for custom binding
const myBindingVersions = createBindingPropsMigrationIds('myCustomBinding', {
  AddNewProperty: 1,
  UpdateProperty: 2,
})

// Result:
// {
//   AddNewProperty: 'com.tldraw.binding.myCustomBinding/1',
//   UpdateProperty: 'com.tldraw.binding.myCustomBinding/2'
// }

Parameters

NameDescription

bindingType

S

The type of binding these migrations apply to

ids

T

Object mapping migration names to version numbers

Returns

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

Object with formatted migration IDs

Prev
createBindingId
Next
createBindingPropsMigrationSequence