feat: add safe calendar import and export
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.
This commit is contained in:
28
include/nocal/domain/calendar_transfer.hpp
Normal file
28
include/nocal/domain/calendar_transfer.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#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
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "nocal/domain/calendar_transfer.hpp"
|
||||
#include "nocal/domain/date.hpp"
|
||||
#include "nocal/domain/event.hpp"
|
||||
#include "nocal/domain/event_query.hpp"
|
||||
|
||||
Reference in New Issue
Block a user