import { getSession } from "../lib/neo4j.js";
export async function scheduleGet(eventId, accountId) {
    const neo4jSession = getSession();
    try {
        const result = await neo4jSession.run(`MATCH (e:Event {eventId: $eventId, accountId: $accountId})
       OPTIONAL MATCH (e)-[r]->(target)
       RETURN e, collect({type: type(r), targetLabel: labels(target)[0], targetName: target.name, targetId: elementId(target)}) AS rels`, { eventId, accountId });
        if (result.records.length === 0)
            return null;
        const record = result.records[0];
        const e = record.get("e").properties;
        const rels = record.get("rels");
        const detail = {
            eventId: e.eventId,
            name: e.name,
            startDate: e.startDate,
            eventStatus: e.eventStatus,
            createdAt: e.createdAt,
            updatedAt: e.updatedAt,
            relationships: rels
                .filter((r) => r.type !== null)
                .map((r) => ({
                type: r.type,
                targetLabel: r.targetLabel ?? "Unknown",
                targetName: r.targetName ?? undefined,
                targetId: r.targetId,
            })),
        };
        if (e.description)
            detail.description = e.description;
        if (e.endDate)
            detail.endDate = e.endDate;
        if (e.location)
            detail.location = e.location;
        if (e.recurrence)
            detail.recurrence = e.recurrence;
        if (e.timezone)
            detail.timezone = e.timezone;
        if (e.nextRun)
            detail.nextRun = e.nextRun;
        if (e.lastTriggered)
            detail.lastTriggered = e.lastTriggered;
        if (e.skipNext)
            detail.skipNext = e.skipNext;
        if (e.notes)
            detail.notes = e.notes;
        return detail;
    }
    finally {
        await neo4jSession.close();
    }
}
//# sourceMappingURL=schedule-get.js.map