/**
 * FROST handoff formatter
 * -----------------------
 * Keeps the same structured envelope as the InfluxDB formatter so a shared
 * CoreSync collector can accept existing EVOLV dbase messages without coupling
 * producing nodes to FROST HTTP details.
 */
function format(measurement, metadata) {
  const { fields, tags, config } = metadata;
  return {
    measurement,
    fields,
    tags: tags || {},
    timestamp: new Date().toISOString(),
    source: {
      nodeId: config?.general?.id,
      softwareType: config?.functionality?.softwareType,
      unit: config?.general?.unit || config?.asset?.unit,
    },
  };
}

module.exports = { format };
