MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / encodeVectorId

Function encodeVectorId

vector/idCodec.js:13–40  ·  view source on GitHub ↗
({
    namespace,
    type,
    entityId,
    chunkId,
    field,
    variant
} = {})

Source from the content-addressed store, hash-verified

11}
12
13export 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
42export function decodeVectorId(id) {
43 if (!id || typeof id !== 'string') return null;

Callers 1

Calls 1

encodePartFunction · 0.85

Tested by

no test coverage detected