import { v4 } from "uuid";
import { getHappeningStore } from "./store.js";
import { getMaybePartner, getMaybeUser } from "../../authentication/index.js";
export async function setHappening(data) {
    const createdAt = data.createdAt || new Date().toISOString();
    const happeningId = data.happeningId || v4();
    const type = data.type || "event";
    const partnerId = getMaybePartner()?.partnerId;
    const userId = getMaybeUser()?.userId;
    const happening = {
        ...data,
        type,
        createdAt,
        happeningId,
        partnerId,
        userId
    };
    const store = getHappeningStore();
    await store.set(happeningId, happening);
    return happening;
}
//# sourceMappingURL=set-happening.js.map