@kuriousdesign/machine-sdk
Version:
Shared data types and helpers for machine-related repositories
20 lines (19 loc) • 646 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildFullTopicPath = buildFullTopicPath;
function buildFullTopicPath(device, deviceMap) {
const parts = [];
let current = device;
while (current) {
parts.unshift(current.id);
if (!current.parentId || current.parentId === 0)
break;
const parent = deviceMap.get(current.parentId);
if (!parent) {
console.warn(`Parent device missing for device ${current.id}, parentId: ${current.parentId}`);
break;
}
current = parent;
}
return 'machine/' + parts.join('/');
}