Add explicit noninteractive CLI transfer modes with full event validation, idempotent duplicate handling, collision refusal, atomic import backups, and no-overwrite export creation. Cover pure merge semantics and end-to-end rollback paths for unsupported content, invalid identities, conflicts, option combinations, and existing destinations.
29 lines
860 B
C++
29 lines
860 B
C++
#pragma once
|
|
|
|
#include "nocal/domain/event.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <span>
|
|
#include <vector>
|
|
|
|
namespace nocal {
|
|
|
|
struct ImportMergeResult {
|
|
std::vector<Event> events;
|
|
std::size_t imported{};
|
|
std::size_t duplicates_skipped{};
|
|
};
|
|
|
|
// Transfer inputs must contain valid intervals and one non-empty, unique UID
|
|
// per event. Invalid input throws std::invalid_argument before any persistence
|
|
// boundary is crossed.
|
|
void validate_events_for_export(std::span<const Event> events);
|
|
|
|
// Preserves target order and appends new source events in source order. An
|
|
// exactly equivalent source/target UID is skipped; a differing UID collision
|
|
// throws std::invalid_argument and returns no partial result.
|
|
[[nodiscard]] ImportMergeResult merge_events_for_import(
|
|
std::span<const Event> target, std::span<const Event> source);
|
|
|
|
} // namespace nocal
|