Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

43.8 KB
Raw Blame
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0
// source: room_document_comments.sql

package store

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const countRoomDocumentCommentsForThread = `-- name: CountRoomDocumentCommentsForThread :one
SELECT count(*)
FROM room_document_comments
WHERE thread_id=$1::text
`

func (q *Queries) CountRoomDocumentCommentsForThread(ctx context.Context, threadID string) (int64, error) {
	row := q.db.QueryRow(ctx, countRoomDocumentCommentsForThread, threadID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const createRoomDocumentComment = `-- name: CreateRoomDocumentComment :one
INSERT INTO room_document_comments(
    id,tenant_id,room_id,document_id,thread_id,parent_comment_id,
    author_actor_id,body,segments
) VALUES(
    $1::text,$2::text,NULLIF($3::text,''),
    $4::text,$5::text,
    $6::text,$7::text,
    $8::text,$9::jsonb
)
RETURNING id, tenant_id, room_id, document_id, thread_id, parent_comment_id, author_actor_id, version_number, deleted_at, created_at, updated_at, body, segments
`

type CreateRoomDocumentCommentParams struct {
	ID              string      `json:"id"`
	TenantID        string      `json:"tenant_id"`
	RoomID          string      `json:"room_id"`
	DocumentID      string      `json:"document_id"`
	ThreadID        string      `json:"thread_id"`
	ParentCommentID pgtype.Text `json:"parent_comment_id"`
	AuthorActorID   string      `json:"author_actor_id"`
	Body            string      `json:"body"`
	Segments        []byte      `json:"segments"`
}

func (q *Queries) CreateRoomDocumentComment(ctx context.Context, arg CreateRoomDocumentCommentParams) (RoomDocumentComment, error) {
	row := q.db.QueryRow(ctx, createRoomDocumentComment,
		arg.ID,
		arg.TenantID,
		arg.RoomID,
		arg.DocumentID,
		arg.ThreadID,
		arg.ParentCommentID,
		arg.AuthorActorID,
		arg.Body,
		arg.Segments,
	)
	var i RoomDocumentComment
	err := row.Scan(
		&i.ID,
		&i.TenantID,
		&i.RoomID,
		&i.DocumentID,
		&i.ThreadID,
		&i.ParentCommentID,
		&i.AuthorActorID,
		&i.VersionNumber,
		&i.DeletedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.Body,
		&i.Segments,
	)
	return i, err
}

const createRoomDocumentCommentThread = `-- name: CreateRoomDocumentCommentThread :one
INSERT INTO room_document_comment_threads(
    id,tenant_id,room_id,document_id,current_anchor_id,anchor_status,created_by_actor_id,
    anchor_kind,anchor_document_version_id,anchor_quoted_text,anchor_block_id,
    anchor_context_before,anchor_context_after,anchor_version_number,anchor_created_by_actor_id
) VALUES(
    $1::text,$2::text,NULLIF($3::text,''),
    $4::text,$5::text,
    $6::text,
    $7::text,$8::text,
    NULLIF($9::text,''),$10::text,
    $11::text,$12::text,
    $13::text,1,$7::text
)
RETURNING id, tenant_id, room_id, document_id, current_anchor_id, anchor_status, created_by_actor_id, resolved_by_actor_id, resolved_at, created_at, updated_at, anchor_kind, anchor_document_version_id, anchor_quoted_text, anchor_block_id, anchor_context_before, anchor_context_after, anchor_version_number, anchor_created_by_actor_id, anchor_created_at
`

type CreateRoomDocumentCommentThreadParams struct {
	ID                      string `json:"id"`
	TenantID                string `json:"tenant_id"`
	RoomID                  string `json:"room_id"`
	DocumentID              string `json:"document_id"`
	CurrentAnchorID         string `json:"current_anchor_id"`
	AnchorStatus            string `json:"anchor_status"`
	CreatedByActorID        string `json:"created_by_actor_id"`
	AnchorKind              string `json:"anchor_kind"`
	AnchorDocumentVersionID string `json:"anchor_document_version_id"`
	AnchorQuotedText        string `json:"anchor_quoted_text"`
	AnchorBlockID           string `json:"anchor_block_id"`
	AnchorContextBefore     string `json:"anchor_context_before"`
	AnchorContextAfter      string `json:"anchor_context_after"`
}

func (q *Queries) CreateRoomDocumentCommentThread(ctx context.Context, arg CreateRoomDocumentCommentThreadParams) (RoomDocumentCommentThread, error) {
	row := q.db.QueryRow(ctx, createRoomDocumentCommentThread,
		arg.ID,
		arg.TenantID,
		arg.RoomID,
		arg.DocumentID,
		arg.CurrentAnchorID,
		arg.AnchorStatus,
		arg.CreatedByActorID,
		arg.AnchorKind,
		arg.AnchorDocumentVersionID,
		arg.AnchorQuotedText,
		arg.AnchorBlockID,
		arg.AnchorContextBefore,
		arg.AnchorContextAfter,
	)
	var i RoomDocumentCommentThread
	err := row.Scan(
		&i.ID,
		&i.TenantID,
		&i.RoomID,
		&i.DocumentID,
		&i.CurrentAnchorID,
		&i.AnchorStatus,
		&i.CreatedByActorID,
		&i.ResolvedByActorID,
		&i.ResolvedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.AnchorKind,
		&i.AnchorDocumentVersionID,
		&i.AnchorQuotedText,
		&i.AnchorBlockID,
		&i.AnchorContextBefore,
		&i.AnchorContextAfter,
		&i.AnchorVersionNumber,
		&i.AnchorCreatedByActorID,
		&i.AnchorCreatedAt,
	)
	return i, err
}

const getDocumentCommentVersionAnchor = `-- name: GetDocumentCommentVersionAnchor :one
SELECT version.id,version.filename
FROM document_versions version
JOIN documents document ON document.id=version.document_id
 AND document.tenant_id=version.tenant_id AND document.status='active'
WHERE version.id=$1::text
  AND version.document_id=$2::text
FOR SHARE OF version,document
`

type GetDocumentCommentVersionAnchorParams struct {
	DocumentVersionID string `json:"document_version_id"`
	DocumentID        string `json:"document_id"`
}

type GetDocumentCommentVersionAnchorRow struct {
	ID       string `json:"id"`
	Filename string `json:"filename"`
}

func (q *Queries) GetDocumentCommentVersionAnchor(ctx context.Context, arg GetDocumentCommentVersionAnchorParams) (GetDocumentCommentVersionAnchorRow, error) {
	row := q.db.QueryRow(ctx, getDocumentCommentVersionAnchor, arg.DocumentVersionID, arg.DocumentID)
	var i GetDocumentCommentVersionAnchorRow
	err := row.Scan(&i.ID, &i.Filename)
	return i, err
}

const getRoomDocumentCommentCreateAuthority = `-- name: GetRoomDocumentCommentCreateAuthority :one
SELECT document.id AS document_id,document.tenant_id,
       ''::text AS room_id,
       caller.id AS actor_id,caller.kind AS actor_kind,
       caller.display_name AS actor_display_name
FROM documents document
JOIN actors caller ON caller.tenant_id=document.tenant_id
  AND caller.account_id=$1::text AND caller.kind='human'
WHERE document.id=$2::text
  AND document.status='active'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $1::text,$2::text
  ) access
  WHERE access.tenant_id=document.tenant_id AND access.can_read)
`

type GetRoomDocumentCommentCreateAuthorityParams struct {
	AccountID  string `json:"account_id"`
	DocumentID string `json:"document_id"`
}

type GetRoomDocumentCommentCreateAuthorityRow struct {
	DocumentID       string `json:"document_id"`
	TenantID         string `json:"tenant_id"`
	RoomID           string `json:"room_id"`
	ActorID          string `json:"actor_id"`
	ActorKind        string `json:"actor_kind"`
	ActorDisplayName string `json:"actor_display_name"`
}

func (q *Queries) GetRoomDocumentCommentCreateAuthority(ctx context.Context, arg GetRoomDocumentCommentCreateAuthorityParams) (GetRoomDocumentCommentCreateAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentCreateAuthority, arg.AccountID, arg.DocumentID)
	var i GetRoomDocumentCommentCreateAuthorityRow
	err := row.Scan(
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
		&i.ActorID,
		&i.ActorKind,
		&i.ActorDisplayName,
	)
	return i, err
}

const getRoomDocumentCommentMutationAuthority = `-- name: GetRoomDocumentCommentMutationAuthority :one
SELECT comment.id,comment.thread_id,comment.parent_comment_id,
       comment.document_id,comment.tenant_id,comment.room_id,
       thread.current_anchor_id,
       comment.author_actor_id,comment.version_number,comment.deleted_at,
       comment.created_at,comment.updated_at,
       comment.body,comment.segments,
       author.kind AS author_kind,author.display_name AS author_display_name,
       caller.id AS caller_actor_id
FROM room_document_comments comment
JOIN room_document_comment_threads thread ON thread.id=comment.thread_id
JOIN documents document
  ON document.id=comment.document_id AND document.tenant_id=comment.tenant_id
 AND document.status='active'
JOIN actors author
  ON author.id=comment.author_actor_id AND author.tenant_id=comment.tenant_id
JOIN actors caller
  ON caller.tenant_id=comment.tenant_id
 AND caller.account_id=$1::text
 AND caller.kind='human'
WHERE comment.id=$2::text
  AND thread.anchor_status<>'orphaned'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $1::text,comment.document_id
  ) access
  WHERE access.tenant_id=comment.tenant_id AND access.can_read)
FOR UPDATE OF thread,comment
`

type GetRoomDocumentCommentMutationAuthorityParams struct {
	AccountID string `json:"account_id"`
	CommentID string `json:"comment_id"`
}

type GetRoomDocumentCommentMutationAuthorityRow struct {
	ID                string             `json:"id"`
	ThreadID          string             `json:"thread_id"`
	ParentCommentID   pgtype.Text        `json:"parent_comment_id"`
	DocumentID        string             `json:"document_id"`
	TenantID          string             `json:"tenant_id"`
	RoomID            pgtype.Text        `json:"room_id"`
	CurrentAnchorID   string             `json:"current_anchor_id"`
	AuthorActorID     string             `json:"author_actor_id"`
	VersionNumber     int64              `json:"version_number"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	Body              string             `json:"body"`
	Segments          []byte             `json:"segments"`
	AuthorKind        string             `json:"author_kind"`
	AuthorDisplayName string             `json:"author_display_name"`
	CallerActorID     string             `json:"caller_actor_id"`
}

func (q *Queries) GetRoomDocumentCommentMutationAuthority(ctx context.Context, arg GetRoomDocumentCommentMutationAuthorityParams) (GetRoomDocumentCommentMutationAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentMutationAuthority, arg.AccountID, arg.CommentID)
	var i GetRoomDocumentCommentMutationAuthorityRow
	err := row.Scan(
		&i.ID,
		&i.ThreadID,
		&i.ParentCommentID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
		&i.CurrentAnchorID,
		&i.AuthorActorID,
		&i.VersionNumber,
		&i.DeletedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.Body,
		&i.Segments,
		&i.AuthorKind,
		&i.AuthorDisplayName,
		&i.CallerActorID,
	)
	return i, err
}

const getRoomDocumentCommentMutationScope = `-- name: GetRoomDocumentCommentMutationScope :one
SELECT comment.id AS comment_id,comment.document_id,comment.tenant_id,comment.room_id
FROM room_document_comments comment
JOIN documents document
  ON document.id=comment.document_id AND document.tenant_id=comment.tenant_id
 AND document.status='active'
WHERE comment.id=$1::text
`

type GetRoomDocumentCommentMutationScopeRow struct {
	CommentID  string      `json:"comment_id"`
	DocumentID string      `json:"document_id"`
	TenantID   string      `json:"tenant_id"`
	RoomID     pgtype.Text `json:"room_id"`
}

func (q *Queries) GetRoomDocumentCommentMutationScope(ctx context.Context, commentID string) (GetRoomDocumentCommentMutationScopeRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentMutationScope, commentID)
	var i GetRoomDocumentCommentMutationScopeRow
	err := row.Scan(
		&i.CommentID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
	)
	return i, err
}

const getRoomDocumentCommentParent = `-- name: GetRoomDocumentCommentParent :one
SELECT id
FROM room_document_comments
WHERE id=$1::text
  AND thread_id=$2::text
`

type GetRoomDocumentCommentParentParams struct {
	CommentID string `json:"comment_id"`
	ThreadID  string `json:"thread_id"`
}

func (q *Queries) GetRoomDocumentCommentParent(ctx context.Context, arg GetRoomDocumentCommentParentParams) (string, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentParent, arg.CommentID, arg.ThreadID)
	var id string
	err := row.Scan(&id)
	return id, err
}

const getRoomDocumentCommentReadAuthority = `-- name: GetRoomDocumentCommentReadAuthority :one
SELECT document.id AS document_id,document.tenant_id,
       ''::text AS room_id
FROM documents document
WHERE document.id=$1::text
  AND document.status='active'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $2::text,$1::text
  ) access
  WHERE access.tenant_id=document.tenant_id AND access.can_read)
`

type GetRoomDocumentCommentReadAuthorityParams struct {
	DocumentID string `json:"document_id"`
	AccountID  string `json:"account_id"`
}

type GetRoomDocumentCommentReadAuthorityRow struct {
	DocumentID string `json:"document_id"`
	TenantID   string `json:"tenant_id"`
	RoomID     string `json:"room_id"`
}

func (q *Queries) GetRoomDocumentCommentReadAuthority(ctx context.Context, arg GetRoomDocumentCommentReadAuthorityParams) (GetRoomDocumentCommentReadAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentReadAuthority, arg.DocumentID, arg.AccountID)
	var i GetRoomDocumentCommentReadAuthorityRow
	err := row.Scan(&i.DocumentID, &i.TenantID, &i.RoomID)
	return i, err
}

const getRoomDocumentCommentReplyAuthority = `-- name: GetRoomDocumentCommentReplyAuthority :one
SELECT thread.id AS thread_id,thread.document_id,thread.tenant_id,thread.room_id,
       thread.current_anchor_id,
       caller.id AS actor_id,caller.kind AS actor_kind,
       caller.display_name AS actor_display_name
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
JOIN actors caller
  ON caller.tenant_id=thread.tenant_id
 AND caller.account_id=$1::text
 AND caller.kind='human'
WHERE thread.id=$2::text
  AND thread.anchor_status<>'orphaned'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $1::text,thread.document_id
  ) access
  WHERE access.tenant_id=thread.tenant_id AND access.can_read)
FOR UPDATE OF thread
`

type GetRoomDocumentCommentReplyAuthorityParams struct {
	AccountID string `json:"account_id"`
	ThreadID  string `json:"thread_id"`
}

type GetRoomDocumentCommentReplyAuthorityRow struct {
	ThreadID         string      `json:"thread_id"`
	DocumentID       string      `json:"document_id"`
	TenantID         string      `json:"tenant_id"`
	RoomID           pgtype.Text `json:"room_id"`
	CurrentAnchorID  string      `json:"current_anchor_id"`
	ActorID          string      `json:"actor_id"`
	ActorKind        string      `json:"actor_kind"`
	ActorDisplayName string      `json:"actor_display_name"`
}

func (q *Queries) GetRoomDocumentCommentReplyAuthority(ctx context.Context, arg GetRoomDocumentCommentReplyAuthorityParams) (GetRoomDocumentCommentReplyAuthorityRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentReplyAuthority, arg.AccountID, arg.ThreadID)
	var i GetRoomDocumentCommentReplyAuthorityRow
	err := row.Scan(
		&i.ThreadID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
		&i.CurrentAnchorID,
		&i.ActorID,
		&i.ActorKind,
		&i.ActorDisplayName,
	)
	return i, err
}

const getRoomDocumentCommentReplyAuthorityForAgent = `-- name: GetRoomDocumentCommentReplyAuthorityForAgent :one
SELECT thread.id AS thread_id,thread.document_id,thread.tenant_id,thread.room_id,
       thread.current_anchor_id,
       caller.id AS actor_id,caller.kind AS actor_kind,
       caller.display_name AS actor_display_name
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
JOIN agent_registrations registration
  ON registration.tenant_id=thread.tenant_id
 AND registration.agent_management_id=$1::text
 AND registration.status='active'
JOIN actors caller
  ON caller.id=registration.actor_id AND caller.tenant_id=registration.tenant_id
 AND caller.kind='agent'
WHERE thread.id=$2::text
  AND thread.anchor_status<>'orphaned'
  AND (
    document_comment_agent_readable(thread.tenant_id,thread.document_id,registration.actor_id)
  )
FOR UPDATE OF thread
`

type GetRoomDocumentCommentReplyAuthorityForAgentParams struct {
	AgentManagementID string `json:"agent_management_id"`
	ThreadID          string `json:"thread_id"`
}

type GetRoomDocumentCommentReplyAuthorityForAgentRow struct {
	ThreadID         string      `json:"thread_id"`
	DocumentID       string      `json:"document_id"`
	TenantID         string      `json:"tenant_id"`
	RoomID           pgtype.Text `json:"room_id"`
	CurrentAnchorID  string      `json:"current_anchor_id"`
	ActorID          string      `json:"actor_id"`
	ActorKind        string      `json:"actor_kind"`
	ActorDisplayName string      `json:"actor_display_name"`
}

func (q *Queries) GetRoomDocumentCommentReplyAuthorityForAgent(ctx context.Context, arg GetRoomDocumentCommentReplyAuthorityForAgentParams) (GetRoomDocumentCommentReplyAuthorityForAgentRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentReplyAuthorityForAgent, arg.AgentManagementID, arg.ThreadID)
	var i GetRoomDocumentCommentReplyAuthorityForAgentRow
	err := row.Scan(
		&i.ThreadID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
		&i.CurrentAnchorID,
		&i.ActorID,
		&i.ActorKind,
		&i.ActorDisplayName,
	)
	return i, err
}

const getRoomDocumentCommentReplyScope = `-- name: GetRoomDocumentCommentReplyScope :one
SELECT thread.id AS thread_id,thread.document_id,thread.tenant_id,thread.room_id
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
WHERE thread.id=$1::text
  AND thread.anchor_status<>'orphaned'
`

type GetRoomDocumentCommentReplyScopeRow struct {
	ThreadID   string      `json:"thread_id"`
	DocumentID string      `json:"document_id"`
	TenantID   string      `json:"tenant_id"`
	RoomID     pgtype.Text `json:"room_id"`
}

func (q *Queries) GetRoomDocumentCommentReplyScope(ctx context.Context, threadID string) (GetRoomDocumentCommentReplyScopeRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentReplyScope, threadID)
	var i GetRoomDocumentCommentReplyScopeRow
	err := row.Scan(
		&i.ThreadID,
		&i.DocumentID,
		&i.TenantID,
		&i.RoomID,
	)
	return i, err
}

const getRoomDocumentCommentThreadForAccount = `-- name: GetRoomDocumentCommentThreadForAccount :one
SELECT thread.id,thread.document_id,thread.anchor_status,thread.resolved_at,
       thread.created_at,thread.updated_at,
       creator.id AS creator_id,creator.tenant_id AS creator_tenant_id,
       creator.kind AS creator_kind,creator.display_name AS creator_display_name,
       resolver.id AS resolver_id,resolver.kind AS resolver_kind,
       resolver.display_name AS resolver_display_name,
       thread.current_anchor_id AS anchor_id,thread.anchor_kind,
       thread.anchor_document_version_id AS document_version_id,
       thread.anchor_quoted_text AS quoted_text,thread.anchor_block_id AS block_id,
       thread.anchor_context_before AS context_before,thread.anchor_context_after AS context_after,
       thread.anchor_created_at,
       anchor_creator.id AS anchor_creator_id,
       anchor_creator.kind AS anchor_creator_kind,
       anchor_creator.display_name AS anchor_creator_display_name
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
JOIN actors creator
  ON creator.id=thread.created_by_actor_id AND creator.tenant_id=thread.tenant_id
LEFT JOIN actors resolver
  ON resolver.id=thread.resolved_by_actor_id AND resolver.tenant_id=thread.tenant_id
JOIN actors anchor_creator
  ON anchor_creator.id=thread.anchor_created_by_actor_id AND anchor_creator.tenant_id=thread.tenant_id
WHERE thread.id=$1::text
  AND thread.anchor_status<>'orphaned'
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_v2(
      $2::text,thread.document_id
  ) access
  WHERE access.tenant_id=thread.tenant_id AND access.can_read)
`

type GetRoomDocumentCommentThreadForAccountParams struct {
	ThreadID  string `json:"thread_id"`
	AccountID string `json:"account_id"`
}

type GetRoomDocumentCommentThreadForAccountRow struct {
	ID                       string             `json:"id"`
	DocumentID               string             `json:"document_id"`
	AnchorStatus             string             `json:"anchor_status"`
	ResolvedAt               pgtype.Timestamptz `json:"resolved_at"`
	CreatedAt                pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                pgtype.Timestamptz `json:"updated_at"`
	CreatorID                string             `json:"creator_id"`
	CreatorTenantID          string             `json:"creator_tenant_id"`
	CreatorKind              string             `json:"creator_kind"`
	CreatorDisplayName       string             `json:"creator_display_name"`
	ResolverID               pgtype.Text        `json:"resolver_id"`
	ResolverKind             pgtype.Text        `json:"resolver_kind"`
	ResolverDisplayName      pgtype.Text        `json:"resolver_display_name"`
	AnchorID                 string             `json:"anchor_id"`
	AnchorKind               string             `json:"anchor_kind"`
	DocumentVersionID        pgtype.Text        `json:"document_version_id"`
	QuotedText               string             `json:"quoted_text"`
	BlockID                  string             `json:"block_id"`
	ContextBefore            string             `json:"context_before"`
	ContextAfter             string             `json:"context_after"`
	AnchorCreatedAt          pgtype.Timestamptz `json:"anchor_created_at"`
	AnchorCreatorID          string             `json:"anchor_creator_id"`
	AnchorCreatorKind        string             `json:"anchor_creator_kind"`
	AnchorCreatorDisplayName string             `json:"anchor_creator_display_name"`
}

func (q *Queries) GetRoomDocumentCommentThreadForAccount(ctx context.Context, arg GetRoomDocumentCommentThreadForAccountParams) (GetRoomDocumentCommentThreadForAccountRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentThreadForAccount, arg.ThreadID, arg.AccountID)
	var i GetRoomDocumentCommentThreadForAccountRow
	err := row.Scan(
		&i.ID,
		&i.DocumentID,
		&i.AnchorStatus,
		&i.ResolvedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.CreatorID,
		&i.CreatorTenantID,
		&i.CreatorKind,
		&i.CreatorDisplayName,
		&i.ResolverID,
		&i.ResolverKind,
		&i.ResolverDisplayName,
		&i.AnchorID,
		&i.AnchorKind,
		&i.DocumentVersionID,
		&i.QuotedText,
		&i.BlockID,
		&i.ContextBefore,
		&i.ContextAfter,
		&i.AnchorCreatedAt,
		&i.AnchorCreatorID,
		&i.AnchorCreatorKind,
		&i.AnchorCreatorDisplayName,
	)
	return i, err
}

const getRoomDocumentCommentThreadForAgent = `-- name: GetRoomDocumentCommentThreadForAgent :one
SELECT thread.id,thread.document_id,thread.anchor_status,thread.resolved_at,
       thread.created_at,thread.updated_at,
       creator.id AS creator_id,creator.tenant_id AS creator_tenant_id,
       creator.kind AS creator_kind,creator.display_name AS creator_display_name,
       resolver.id AS resolver_id,resolver.kind AS resolver_kind,
       resolver.display_name AS resolver_display_name,
       thread.current_anchor_id AS anchor_id,thread.anchor_kind,
       thread.anchor_document_version_id AS document_version_id,
       thread.anchor_quoted_text AS quoted_text,thread.anchor_block_id AS block_id,
       thread.anchor_context_before AS context_before,thread.anchor_context_after AS context_after,
       thread.anchor_created_at,
       anchor_creator.id AS anchor_creator_id,
       anchor_creator.kind AS anchor_creator_kind,
       anchor_creator.display_name AS anchor_creator_display_name
FROM room_document_comment_threads thread
JOIN documents document
  ON document.id=thread.document_id AND document.tenant_id=thread.tenant_id
 AND document.status='active'
JOIN agent_registrations registration
  ON registration.tenant_id=thread.tenant_id
 AND registration.agent_management_id=$1::text
 AND registration.status='active'
JOIN actors creator
  ON creator.id=thread.created_by_actor_id AND creator.tenant_id=thread.tenant_id
LEFT JOIN actors resolver
  ON resolver.id=thread.resolved_by_actor_id AND resolver.tenant_id=thread.tenant_id
JOIN actors anchor_creator
  ON anchor_creator.id=thread.anchor_created_by_actor_id AND anchor_creator.tenant_id=thread.tenant_id
WHERE thread.id=$2::text
  AND thread.anchor_status<>'orphaned'
  AND (
    document_comment_agent_readable(thread.tenant_id,thread.document_id,registration.actor_id)
  )
`

type GetRoomDocumentCommentThreadForAgentParams struct {
	AgentManagementID string `json:"agent_management_id"`
	ThreadID          string `json:"thread_id"`
}

type GetRoomDocumentCommentThreadForAgentRow struct {
	ID                       string             `json:"id"`
	DocumentID               string             `json:"document_id"`
	AnchorStatus             string             `json:"anchor_status"`
	ResolvedAt               pgtype.Timestamptz `json:"resolved_at"`
	CreatedAt                pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                pgtype.Timestamptz `json:"updated_at"`
	CreatorID                string             `json:"creator_id"`
	CreatorTenantID          string             `json:"creator_tenant_id"`
	CreatorKind              string             `json:"creator_kind"`
	CreatorDisplayName       string             `json:"creator_display_name"`
	ResolverID               pgtype.Text        `json:"resolver_id"`
	ResolverKind             pgtype.Text        `json:"resolver_kind"`
	ResolverDisplayName      pgtype.Text        `json:"resolver_display_name"`
	AnchorID                 string             `json:"anchor_id"`
	AnchorKind               string             `json:"anchor_kind"`
	DocumentVersionID        pgtype.Text        `json:"document_version_id"`
	QuotedText               string             `json:"quoted_text"`
	BlockID                  string             `json:"block_id"`
	ContextBefore            string             `json:"context_before"`
	ContextAfter             string             `json:"context_after"`
	AnchorCreatedAt          pgtype.Timestamptz `json:"anchor_created_at"`
	AnchorCreatorID          string             `json:"anchor_creator_id"`
	AnchorCreatorKind        string             `json:"anchor_creator_kind"`
	AnchorCreatorDisplayName string             `json:"anchor_creator_display_name"`
}

func (q *Queries) GetRoomDocumentCommentThreadForAgent(ctx context.Context, arg GetRoomDocumentCommentThreadForAgentParams) (GetRoomDocumentCommentThreadForAgentRow, error) {
	row := q.db.QueryRow(ctx, getRoomDocumentCommentThreadForAgent, arg.AgentManagementID, arg.ThreadID)
	var i GetRoomDocumentCommentThreadForAgentRow
	err := row.Scan(
		&i.ID,
		&i.DocumentID,
		&i.AnchorStatus,
		&i.ResolvedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.CreatorID,
		&i.CreatorTenantID,
		&i.CreatorKind,
		&i.CreatorDisplayName,
		&i.ResolverID,
		&i.ResolverKind,
		&i.ResolverDisplayName,
		&i.AnchorID,
		&i.AnchorKind,
		&i.DocumentVersionID,
		&i.QuotedText,
		&i.BlockID,
		&i.ContextBefore,
		&i.ContextAfter,
		&i.AnchorCreatedAt,
		&i.AnchorCreatorID,
		&i.AnchorCreatorKind,
		&i.AnchorCreatorDisplayName,
	)
	return i, err
}

const listCurrentDocumentCommentAgentReferenceActorsForHuman = `-- name: ListCurrentDocumentCommentAgentReferenceActorsForHuman :many
SELECT target.id,target.tenant_id,target.kind,target.display_name,target.account_id
FROM resolve_human_document_access_v2($1::text,$2::text) access
JOIN agent_registrations registration ON registration.tenant_id=access.tenant_id AND registration.status='active'
  AND (registration.created_by_actor_id=access.actor_id OR registration.visibility_scope='workspace')
JOIN actors target ON target.id=registration.actor_id AND target.tenant_id=registration.tenant_id
WHERE access.can_read AND target.id=ANY($3::text[])
  AND EXISTS(SELECT 1 FROM resolve_agent_document_access_v2(registration.agent_management_id,$2::text) ordinary WHERE ordinary.can_read)
ORDER BY target.id
`

type ListCurrentDocumentCommentAgentReferenceActorsForHumanParams struct {
	AccountID  string   `json:"account_id"`
	DocumentID string   `json:"document_id"`
	ActorIds   []string `json:"actor_ids"`
}

type ListCurrentDocumentCommentAgentReferenceActorsForHumanRow struct {
	ID          string      `json:"id"`
	TenantID    string      `json:"tenant_id"`
	Kind        string      `json:"kind"`
	DisplayName string      `json:"display_name"`
	AccountID   pgtype.Text `json:"account_id"`
}

func (q *Queries) ListCurrentDocumentCommentAgentReferenceActorsForHuman(ctx context.Context, arg ListCurrentDocumentCommentAgentReferenceActorsForHumanParams) ([]ListCurrentDocumentCommentAgentReferenceActorsForHumanRow, error) {
	rows, err := q.db.Query(ctx, listCurrentDocumentCommentAgentReferenceActorsForHuman, arg.AccountID, arg.DocumentID, arg.ActorIds)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListCurrentDocumentCommentAgentReferenceActorsForHumanRow{}
	for rows.Next() {
		var i ListCurrentDocumentCommentAgentReferenceActorsForHumanRow
		if err := rows.Scan(
			&i.ID,
			&i.TenantID,
			&i.Kind,
			&i.DisplayName,
			&i.AccountID,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listCurrentDocumentCommentHumanReferenceActorsForAgent = `-- name: ListCurrentDocumentCommentHumanReferenceActorsForAgent :many
SELECT target.id,target.tenant_id,target.kind,target.display_name,target.account_id
FROM agent_registrations registration
JOIN actors target ON target.tenant_id=registration.tenant_id AND target.kind='human'
WHERE registration.agent_management_id=$1::text
  AND registration.status='active' AND target.id=ANY($2::text[])
  AND EXISTS(SELECT 1 FROM resolve_human_document_access_expiry(
    target.account_id,$3::text,'read') access WHERE access.has_access)
  AND (document_comment_agent_readable(registration.tenant_id,$3::text,registration.actor_id))
ORDER BY target.id
`

type ListCurrentDocumentCommentHumanReferenceActorsForAgentParams struct {
	AgentManagementID string   `json:"agent_management_id"`
	ActorIds          []string `json:"actor_ids"`
	DocumentID        string   `json:"document_id"`
}

type ListCurrentDocumentCommentHumanReferenceActorsForAgentRow struct {
	ID          string      `json:"id"`
	TenantID    string      `json:"tenant_id"`
	Kind        string      `json:"kind"`
	DisplayName string      `json:"display_name"`
	AccountID   pgtype.Text `json:"account_id"`
}

func (q *Queries) ListCurrentDocumentCommentHumanReferenceActorsForAgent(ctx context.Context, arg ListCurrentDocumentCommentHumanReferenceActorsForAgentParams) ([]ListCurrentDocumentCommentHumanReferenceActorsForAgentRow, error) {
	rows, err := q.db.Query(ctx, listCurrentDocumentCommentHumanReferenceActorsForAgent, arg.AgentManagementID, arg.ActorIds, arg.DocumentID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListCurrentDocumentCommentHumanReferenceActorsForAgentRow{}
	for rows.Next() {
		var i ListCurrentDocumentCommentHumanReferenceActorsForAgentRow
		if err := rows.Scan(
			&i.ID,
			&i.TenantID,
			&i.Kind,
			&i.DisplayName,
			&i.AccountID,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listCurrentDocumentCommentRoomReferenceActorsForHuman = `-- name: ListCurrentDocumentCommentRoomReferenceActorsForHuman :many
SELECT target.id,target.tenant_id,target.kind,target.display_name,target.account_id
FROM document_context_bindings binding
JOIN rooms room ON room.id=binding.room_id AND room.tenant_id=binding.tenant_id
  AND room.deletion_started_at IS NULL
JOIN actors caller ON caller.tenant_id=binding.tenant_id
  AND caller.account_id=$1::text AND caller.kind='human'
JOIN active_room_members caller_membership
  ON caller_membership.room_id=binding.room_id
 AND caller_membership.tenant_id=binding.tenant_id
 AND caller_membership.actor_id=caller.id
JOIN active_room_members target_membership
  ON target_membership.room_id=binding.room_id
 AND target_membership.tenant_id=binding.tenant_id
JOIN actors target ON target.id=target_membership.actor_id
 AND target.tenant_id=target_membership.tenant_id
WHERE binding.document_id=$2::text
  AND binding.binding_kind='room' AND binding.status='active'
  AND binding.room_id=$3::text
  AND target.id=ANY($4::text[])
ORDER BY target.id
`

type ListCurrentDocumentCommentRoomReferenceActorsForHumanParams struct {
	AccountID  string   `json:"account_id"`
	DocumentID string   `json:"document_id"`
	RoomID     string   `json:"room_id"`
	ActorIds   []string `json:"actor_ids"`
}

type ListCurrentDocumentCommentRoomReferenceActorsForHumanRow struct {
	ID          string      `json:"id"`
	TenantID    string      `json:"tenant_id"`
	Kind        string      `json:"kind"`
	DisplayName string      `json:"display_name"`
	AccountID   pgtype.Text `json:"account_id"`
}

func (q *Queries) ListCurrentDocumentCommentRoomReferenceActorsForHuman(ctx context.Context, arg ListCurrentDocumentCommentRoomReferenceActorsForHumanParams) ([]ListCurrentDocumentCommentRoomReferenceActorsForHumanRow, error) {
	rows, err := q.db.Query(ctx, listCurrentDocumentCommentRoomReferenceActorsForHuman,
		arg.AccountID,
		arg.DocumentID,
		arg.RoomID,
		arg.ActorIds,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListCurrentDocumentCommentRoomReferenceActorsForHumanRow{}
	for rows.Next() {
		var i ListCurrentDocumentCommentRoomReferenceActorsForHumanRow
		if err := rows.Scan(
			&i.ID,
			&i.TenantID,
			&i.Kind,
			&i.DisplayName,
			&i.AccountID,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listCurrentRoomDocumentCommentReferenceActors = `-- name: ListCurrentRoomDocumentCommentReferenceActors :many
SELECT actor.id,actor.tenant_id,actor.kind,actor.display_name,actor.account_id
FROM actors actor
JOIN active_room_members membership
  ON membership.tenant_id=actor.tenant_id
 AND membership.room_id=$1::text
 AND membership.actor_id=actor.id
WHERE actor.tenant_id=$2::text
  AND actor.id=ANY($3::text[])
ORDER BY actor.id
`

type ListCurrentRoomDocumentCommentReferenceActorsParams struct {
	RoomID   string   `json:"room_id"`
	TenantID string   `json:"tenant_id"`
	ActorIds []string `json:"actor_ids"`
}

type ListCurrentRoomDocumentCommentReferenceActorsRow struct {
	ID          string      `json:"id"`
	TenantID    string      `json:"tenant_id"`
	Kind        string      `json:"kind"`
	DisplayName string      `json:"display_name"`
	AccountID   pgtype.Text `json:"account_id"`
}

func (q *Queries) ListCurrentRoomDocumentCommentReferenceActors(ctx context.Context, arg ListCurrentRoomDocumentCommentReferenceActorsParams) ([]ListCurrentRoomDocumentCommentReferenceActorsRow, error) {
	rows, err := q.db.Query(ctx, listCurrentRoomDocumentCommentReferenceActors, arg.RoomID, arg.TenantID, arg.ActorIds)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListCurrentRoomDocumentCommentReferenceActorsRow{}
	for rows.Next() {
		var i ListCurrentRoomDocumentCommentReferenceActorsRow
		if err := rows.Scan(
			&i.ID,
			&i.TenantID,
			&i.Kind,
			&i.DisplayName,
			&i.AccountID,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listRoomDocumentCommentThreads = `-- name: ListRoomDocumentCommentThreads :many
SELECT thread.id,thread.document_id,thread.anchor_status,thread.resolved_at,
       thread.created_at,thread.updated_at,
       creator.id AS creator_id,creator.tenant_id AS creator_tenant_id,
       creator.kind AS creator_kind,creator.display_name AS creator_display_name,
       resolver.id AS resolver_id,resolver.kind AS resolver_kind,
       resolver.display_name AS resolver_display_name,
       thread.current_anchor_id AS anchor_id,thread.anchor_kind,
       thread.anchor_document_version_id AS document_version_id,
       thread.anchor_quoted_text AS quoted_text,thread.anchor_block_id AS block_id,
       thread.anchor_context_before AS context_before,thread.anchor_context_after AS context_after,
       thread.anchor_created_at,
       anchor_creator.id AS anchor_creator_id,
       anchor_creator.kind AS anchor_creator_kind,
       anchor_creator.display_name AS anchor_creator_display_name
FROM room_document_comment_threads thread
JOIN actors creator
  ON creator.id=thread.created_by_actor_id AND creator.tenant_id=thread.tenant_id
LEFT JOIN actors resolver
  ON resolver.id=thread.resolved_by_actor_id AND resolver.tenant_id=thread.tenant_id
JOIN actors anchor_creator
  ON anchor_creator.id=thread.anchor_created_by_actor_id AND anchor_creator.tenant_id=thread.tenant_id
WHERE thread.document_id=$1::text
  AND thread.anchor_status<>'orphaned'
  AND (
    $2::text='' OR (thread.created_at,thread.id)>(
      SELECT cursor_thread.created_at,cursor_thread.id
      FROM room_document_comment_threads cursor_thread
      WHERE cursor_thread.id=$2::text
        AND cursor_thread.document_id=$1::text
    )
  )
ORDER BY thread.created_at,thread.id
LIMIT $3::integer
`

type ListRoomDocumentCommentThreadsParams struct {
	DocumentID string `json:"document_id"`
	Cursor     string `json:"cursor"`
	PageLimit  int32  `json:"page_limit"`
}

type ListRoomDocumentCommentThreadsRow struct {
	ID                       string             `json:"id"`
	DocumentID               string             `json:"document_id"`
	AnchorStatus             string             `json:"anchor_status"`
	ResolvedAt               pgtype.Timestamptz `json:"resolved_at"`
	CreatedAt                pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                pgtype.Timestamptz `json:"updated_at"`
	CreatorID                string             `json:"creator_id"`
	CreatorTenantID          string             `json:"creator_tenant_id"`
	CreatorKind              string             `json:"creator_kind"`
	CreatorDisplayName       string             `json:"creator_display_name"`
	ResolverID               pgtype.Text        `json:"resolver_id"`
	ResolverKind             pgtype.Text        `json:"resolver_kind"`
	ResolverDisplayName      pgtype.Text        `json:"resolver_display_name"`
	AnchorID                 string             `json:"anchor_id"`
	AnchorKind               string             `json:"anchor_kind"`
	DocumentVersionID        pgtype.Text        `json:"document_version_id"`
	QuotedText               string             `json:"quoted_text"`
	BlockID                  string             `json:"block_id"`
	ContextBefore            string             `json:"context_before"`
	ContextAfter             string             `json:"context_after"`
	AnchorCreatedAt          pgtype.Timestamptz `json:"anchor_created_at"`
	AnchorCreatorID          string             `json:"anchor_creator_id"`
	AnchorCreatorKind        string             `json:"anchor_creator_kind"`
	AnchorCreatorDisplayName string             `json:"anchor_creator_display_name"`
}

func (q *Queries) ListRoomDocumentCommentThreads(ctx context.Context, arg ListRoomDocumentCommentThreadsParams) ([]ListRoomDocumentCommentThreadsRow, error) {
	rows, err := q.db.Query(ctx, listRoomDocumentCommentThreads, arg.DocumentID, arg.Cursor, arg.PageLimit)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListRoomDocumentCommentThreadsRow{}
	for rows.Next() {
		var i ListRoomDocumentCommentThreadsRow
		if err := rows.Scan(
			&i.ID,
			&i.DocumentID,
			&i.AnchorStatus,
			&i.ResolvedAt,
			&i.CreatedAt,
			&i.UpdatedAt,
			&i.CreatorID,
			&i.CreatorTenantID,
			&i.CreatorKind,
			&i.CreatorDisplayName,
			&i.ResolverID,
			&i.ResolverKind,
			&i.ResolverDisplayName,
			&i.AnchorID,
			&i.AnchorKind,
			&i.DocumentVersionID,
			&i.QuotedText,
			&i.BlockID,
			&i.ContextBefore,
			&i.ContextAfter,
			&i.AnchorCreatedAt,
			&i.AnchorCreatorID,
			&i.AnchorCreatorKind,
			&i.AnchorCreatorDisplayName,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listRoomDocumentCommentsForThreads = `-- name: ListRoomDocumentCommentsForThreads :many
SELECT comment.id,comment.thread_id,comment.parent_comment_id,comment.deleted_at,
       comment.created_at,comment.updated_at,
       comment.version_number,comment.body,comment.segments,
       author.id AS author_id,author.tenant_id AS author_tenant_id,
       author.kind AS author_kind,author.display_name AS author_display_name
FROM room_document_comments comment
JOIN actors author
  ON author.id=comment.author_actor_id AND author.tenant_id=comment.tenant_id
WHERE comment.thread_id=ANY($1::text[])
ORDER BY comment.thread_id,comment.created_at,comment.id
`

type ListRoomDocumentCommentsForThreadsRow struct {
	ID                string             `json:"id"`
	ThreadID          string             `json:"thread_id"`
	ParentCommentID   pgtype.Text        `json:"parent_comment_id"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	VersionNumber     int64              `json:"version_number"`
	Body              string             `json:"body"`
	Segments          []byte             `json:"segments"`
	AuthorID          string             `json:"author_id"`
	AuthorTenantID    string             `json:"author_tenant_id"`
	AuthorKind        string             `json:"author_kind"`
	AuthorDisplayName string             `json:"author_display_name"`
}

func (q *Queries) ListRoomDocumentCommentsForThreads(ctx context.Context, threadIds []string) ([]ListRoomDocumentCommentsForThreadsRow, error) {
	rows, err := q.db.Query(ctx, listRoomDocumentCommentsForThreads, threadIds)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListRoomDocumentCommentsForThreadsRow{}
	for rows.Next() {
		var i ListRoomDocumentCommentsForThreadsRow
		if err := rows.Scan(
			&i.ID,
			&i.ThreadID,
			&i.ParentCommentID,
			&i.DeletedAt,
			&i.CreatedAt,
			&i.UpdatedAt,
			&i.VersionNumber,
			&i.Body,
			&i.Segments,
			&i.AuthorID,
			&i.AuthorTenantID,
			&i.AuthorKind,
			&i.AuthorDisplayName,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const softDeleteRoomDocumentComment = `-- name: SoftDeleteRoomDocumentComment :one
UPDATE room_document_comments
SET version_number=version_number+1,deleted_at=now(),updated_at=now()
WHERE id=$1::text
RETURNING version_number,deleted_at,updated_at
`

type SoftDeleteRoomDocumentCommentRow struct {
	VersionNumber int64              `json:"version_number"`
	DeletedAt     pgtype.Timestamptz `json:"deleted_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) SoftDeleteRoomDocumentComment(ctx context.Context, commentID string) (SoftDeleteRoomDocumentCommentRow, error) {
	row := q.db.QueryRow(ctx, softDeleteRoomDocumentComment, commentID)
	var i SoftDeleteRoomDocumentCommentRow
	err := row.Scan(&i.VersionNumber, &i.DeletedAt, &i.UpdatedAt)
	return i, err
}

const touchRoomDocumentCommentThread = `-- name: TouchRoomDocumentCommentThread :one
UPDATE room_document_comment_threads
SET updated_at=now()
WHERE id=$1::text
RETURNING updated_at
`

func (q *Queries) TouchRoomDocumentCommentThread(ctx context.Context, threadID string) (pgtype.Timestamptz, error) {
	row := q.db.QueryRow(ctx, touchRoomDocumentCommentThread, threadID)
	var updated_at pgtype.Timestamptz
	err := row.Scan(&updated_at)
	return updated_at, err
}

const updateRoomDocumentCommentBody = `-- name: UpdateRoomDocumentCommentBody :one
UPDATE room_document_comments
SET body=$1::text,segments=$2::jsonb,
    version_number=version_number+1,updated_at=now()
WHERE id=$3::text
RETURNING version_number,updated_at
`

type UpdateRoomDocumentCommentBodyParams struct {
	Body      string `json:"body"`
	Segments  []byte `json:"segments"`
	CommentID string `json:"comment_id"`
}

type UpdateRoomDocumentCommentBodyRow struct {
	VersionNumber int64              `json:"version_number"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

func (q *Queries) UpdateRoomDocumentCommentBody(ctx context.Context, arg UpdateRoomDocumentCommentBodyParams) (UpdateRoomDocumentCommentBodyRow, error) {
	row := q.db.QueryRow(ctx, updateRoomDocumentCommentBody, arg.Body, arg.Segments, arg.CommentID)
	var i UpdateRoomDocumentCommentBodyRow
	err := row.Scan(&i.VersionNumber, &i.UpdatedAt)
	return i, err
}