Rename tlstore to store (#1507)
This PR renames the `@tldraw/tlstore` package to `@tldraw/store`, mainly to avoid confusion between `TLStore`. Will be doing the same with other packages. ### Change Type - [x] `major` — Breaking Change ### Release Notes - Replace @tldraw/tlstore with @tldraw/store
This commit is contained in:
parent
7307282f1f
commit
c1b84bf246
92 changed files with 99 additions and 99 deletions
24
packages/store/src/lib/BaseRecord.ts
Normal file
24
packages/store/src/lib/BaseRecord.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
/** @public */
|
||||
export type ID<R extends UnknownRecord> = string & { __type__: R }
|
||||
|
||||
/** @public */
|
||||
export type IdOf<R extends UnknownRecord> = R['id']
|
||||
|
||||
/**
|
||||
* The base record that all records must extend.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface BaseRecord<TypeName extends string, Id extends ID<UnknownRecord>> {
|
||||
readonly id: Id
|
||||
readonly typeName: TypeName
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export type UnknownRecord = BaseRecord<string, ID<UnknownRecord>>
|
||||
|
||||
export type OmitMeta<R extends UnknownRecord> = R extends R ? Omit<R, 'id' | 'typeName'> : R
|
||||
|
||||
export function isRecord(record: unknown): record is UnknownRecord {
|
||||
return typeof record === 'object' && record !== null && 'id' in record && 'typeName' in record
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue