type RuntimeObservationLine = string | false | null | undefined;

export function buildRuntimeObservation<const Code extends string>(input: {
  code: Code;
  lines: readonly RuntimeObservationLine[] | string;
  severity: "error" | "warning";
}): { code: Code; message: string; severity: "error" | "warning" } {
  const message =
    typeof input.lines === "string"
      ? input.lines
      : input.lines
          .filter((line): line is string => line !== false && line !== null && line !== undefined)
          .join("\n");
  return {
    code: input.code,
    severity: input.severity,
    message,
  };
}
