import { v4 } from "uuid";
import { getDurableEventStore } from "./store.js";
import { ok } from "../../is.js";
export async function addDurableEvent(event) {
    return setDurableEvent(event);
}
export async function setDurableEvent(event) {
    const createdAt = event.createdAt || new Date().toISOString();
    const eventId = event.durableEventId || v4();
    const durable = {
        timeStamp: Date.now(),
        createdAt,
        updatedAt: createdAt,
        durableEventId: eventId,
        ...event
    };
    ok(!durable.virtual, "Cannot store virtual event");
    const store = getDurableEventStore(durable);
    await store.set(eventId, durable);
    return durable;
}
//# sourceMappingURL=add-durable-event.js.map