({
namespace,
type,
entityId,
chunkId,
field,
variant
} = {})
| 11 | } |
| 12 | |
| 13 | export function encodeVectorId({ |
| 14 | namespace, |
| 15 | type, |
| 16 | entityId, |
| 17 | chunkId, |
| 18 | field, |
| 19 | variant |
| 20 | } = {}) { |
| 21 | if (entityId === null || entityId === undefined) { |
| 22 | throw new Error('encodeVectorId requires entityId.'); |
| 23 | } |
| 24 | |
| 25 | const parts = [ |
| 26 | ID_VERSION, |
| 27 | encodePart(namespace), |
| 28 | encodePart(type), |
| 29 | encodePart(entityId), |
| 30 | encodePart(chunkId), |
| 31 | encodePart(field), |
| 32 | encodePart(variant) |
| 33 | ]; |
| 34 | |
| 35 | while (parts.length > 0 && parts[parts.length - 1] === '') { |
| 36 | parts.pop(); |
| 37 | } |
| 38 | |
| 39 | return parts.join('::'); |
| 40 | } |
| 41 | |
| 42 | export function decodeVectorId(id) { |
| 43 | if (!id || typeof id !== 'string') return null; |
no test coverage detected