export type Part = { type: | "CustomType" | "Widget" | "SharedSlice" | "Slice" | "LegacySlice" | "GroupItem" | "primary" | "items" | "RepeatableItem" key: string } export type Path = ReadonlyArray const PATH_SEPARATOR = "::" export function serialize(path: Path): string { return path.map((part) => part.key).join(PATH_SEPARATOR) } export function current(path: Path): Part | undefined { return path[path.length - 1] } export function append(path: string, strElement: string): string { return path + PATH_SEPARATOR + strElement } export function make(...entries: (Pick & Partial>)[]): Path { return entries.reduce((acc, { key, type }) => { return key ? acc.concat({ key, type }) : acc }, []) }