/**
 * Cypher fragment that UNWINDs the caller's `$revisions` array and
 * creates one `:CompiledTruthRevision` row per element, linked from
 * the entity bound as `n` in the caller's MATCH. The caller is
 * responsible for binding `n` (the entity) and providing
 * `$accountId` and `$revisions` parameters.
 *
 * Designed to be concatenated after a `compiledTruth` /
 * `compiledTruthPublic` SET so both mutations sit in the same
 * `session.run` call (single TX).
 */
export const REVISION_CYPHER_FRAGMENT_UNWIND = `
UNWIND $revisions AS rev
CREATE (r:CompiledTruthRevision {
  revisionId: randomUUID(),
  accountId: $accountId,
  truth: rev.truth,
  twin: rev.twin,
  writtenAt: datetime(),
  source: rev.source
})
CREATE (n)-[:HAS_REVISION]->(r)
`;
/**
 * Convenience runner for tests and ad-hoc callers that want to write
 * revisions in isolation (no concurrent `compiledTruth` SET).
 * Production writers compose `REVISION_CYPHER_FRAGMENT_UNWIND` into
 * their own statement; this helper exists so test code does not have
 * to duplicate the fragment.
 */
export async function writeRevisionsStandalone(args) {
    const { session, nodeId, accountId, revisions } = args;
    if (revisions.length === 0)
        return;
    await session.run(`MATCH (n) WHERE elementId(n) = $nodeId AND n.accountId = $accountId
     WITH n
     ${REVISION_CYPHER_FRAGMENT_UNWIND}`, { nodeId, accountId, revisions });
}
//# sourceMappingURL=compiled-truth-revision.js.map