// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: desktop_account.sql package generated import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const clearDesktopAccountDeleteRequested = `-- name: ClearDesktopAccountDeleteRequested :one UPDATE platform_accounts SET delete_requested_at = NULL, sync_version = sync_version + 1, updated_at = now() WHERE desktop_id = $1 AND workspace_id = $2 AND deleted_at IS NULL RETURNING desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at ` type ClearDesktopAccountDeleteRequestedParams struct { DesktopID pgtype.UUID `json:"desktop_id"` WorkspaceID int64 `json:"workspace_id"` } type ClearDesktopAccountDeleteRequestedRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ClearDesktopAccountDeleteRequested(ctx context.Context, arg ClearDesktopAccountDeleteRequestedParams) (ClearDesktopAccountDeleteRequestedRow, error) { row := q.db.QueryRow(ctx, clearDesktopAccountDeleteRequested, arg.DesktopID, arg.WorkspaceID) var i ClearDesktopAccountDeleteRequestedRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getDesktopAccountByDesktopID = `-- name: GetDesktopAccountByDesktopID :one SELECT desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at FROM platform_accounts WHERE desktop_id = $1 AND workspace_id = $2 LIMIT 1 ` type GetDesktopAccountByDesktopIDParams struct { DesktopID pgtype.UUID `json:"desktop_id"` WorkspaceID int64 `json:"workspace_id"` } type GetDesktopAccountByDesktopIDRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) GetDesktopAccountByDesktopID(ctx context.Context, arg GetDesktopAccountByDesktopIDParams) (GetDesktopAccountByDesktopIDRow, error) { row := q.db.QueryRow(ctx, getDesktopAccountByDesktopID, arg.DesktopID, arg.WorkspaceID) var i GetDesktopAccountByDesktopIDRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getDesktopAccountByIdentity = `-- name: GetDesktopAccountByIdentity :one SELECT desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at FROM platform_accounts WHERE workspace_id = $1 AND platform_id = $2 AND platform_uid = $3 AND deleted_at IS NULL LIMIT 1 ` type GetDesktopAccountByIdentityParams struct { WorkspaceID int64 `json:"workspace_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` } type GetDesktopAccountByIdentityRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) GetDesktopAccountByIdentity(ctx context.Context, arg GetDesktopAccountByIdentityParams) (GetDesktopAccountByIdentityRow, error) { row := q.db.QueryRow(ctx, getDesktopAccountByIdentity, arg.WorkspaceID, arg.PlatformID, arg.PlatformUid) var i GetDesktopAccountByIdentityRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const listDesktopAccountsByUser = `-- name: ListDesktopAccountsByUser :many SELECT desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at FROM platform_accounts WHERE workspace_id = $1 AND user_id = $2 AND deleted_at IS NULL ORDER BY platform_id, display_name, created_at DESC ` type ListDesktopAccountsByUserParams struct { WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` } type ListDesktopAccountsByUserRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ListDesktopAccountsByUser(ctx context.Context, arg ListDesktopAccountsByUserParams) ([]ListDesktopAccountsByUserRow, error) { rows, err := q.db.Query(ctx, listDesktopAccountsByUser, arg.WorkspaceID, arg.UserID) if err != nil { return nil, err } defer rows.Close() var items []ListDesktopAccountsByUserRow for rows.Next() { var i ListDesktopAccountsByUserRow if err := rows.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const markDesktopAccountDeleteRequested = `-- name: MarkDesktopAccountDeleteRequested :one UPDATE platform_accounts SET delete_requested_at = now(), sync_version = sync_version + 1, updated_at = now() WHERE desktop_id = $1 AND workspace_id = $2 AND deleted_at IS NULL RETURNING desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at ` type MarkDesktopAccountDeleteRequestedParams struct { DesktopID pgtype.UUID `json:"desktop_id"` WorkspaceID int64 `json:"workspace_id"` } type MarkDesktopAccountDeleteRequestedRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) MarkDesktopAccountDeleteRequested(ctx context.Context, arg MarkDesktopAccountDeleteRequestedParams) (MarkDesktopAccountDeleteRequestedRow, error) { row := q.db.QueryRow(ctx, markDesktopAccountDeleteRequested, arg.DesktopID, arg.WorkspaceID) var i MarkDesktopAccountDeleteRequestedRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const patchDesktopAccount = `-- name: PatchDesktopAccount :one UPDATE platform_accounts SET display_name = COALESCE($1::text, display_name), nickname = COALESCE($1::text, nickname), health = COALESCE($2, health), status = COALESCE($3, status), verified_at = COALESCE($4, verified_at), last_check_at = COALESCE($4, last_check_at), tags = COALESCE($5, tags), sync_version = sync_version + 1, updated_at = now() WHERE desktop_id = $6 AND workspace_id = $7 AND sync_version = $8 AND deleted_at IS NULL RETURNING desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at ` type PatchDesktopAccountParams struct { DisplayName pgtype.Text `json:"display_name"` Health pgtype.Text `json:"health"` LegacyStatus pgtype.Text `json:"legacy_status"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` DesktopID pgtype.UUID `json:"desktop_id"` WorkspaceID int64 `json:"workspace_id"` IfSyncVersion int64 `json:"if_sync_version"` } type PatchDesktopAccountRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) PatchDesktopAccount(ctx context.Context, arg PatchDesktopAccountParams) (PatchDesktopAccountRow, error) { row := q.db.QueryRow(ctx, patchDesktopAccount, arg.DisplayName, arg.Health, arg.LegacyStatus, arg.VerifiedAt, arg.Tags, arg.DesktopID, arg.WorkspaceID, arg.IfSyncVersion, ) var i PatchDesktopAccountRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const tombstoneDesktopAccount = `-- name: TombstoneDesktopAccount :one UPDATE platform_accounts SET deleted_at = now(), sync_version = sync_version + 1, updated_at = now() WHERE desktop_id = $1 AND workspace_id = $2 AND sync_version = $3 AND deleted_at IS NULL RETURNING desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at ` type TombstoneDesktopAccountParams struct { DesktopID pgtype.UUID `json:"desktop_id"` WorkspaceID int64 `json:"workspace_id"` IfSyncVersion int64 `json:"if_sync_version"` } type TombstoneDesktopAccountRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) TombstoneDesktopAccount(ctx context.Context, arg TombstoneDesktopAccountParams) (TombstoneDesktopAccountRow, error) { row := q.db.QueryRow(ctx, tombstoneDesktopAccount, arg.DesktopID, arg.WorkspaceID, arg.IfSyncVersion) var i TombstoneDesktopAccountRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const upsertDesktopAccount = `-- name: UpsertDesktopAccount :one INSERT INTO platform_accounts ( desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, nickname, avatar_url, status, metadata_json, last_check_at, account_fingerprint, display_name, health, verified_at, tags, sync_version ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8::text, $9, $10, $11, $12, $13, $8::text, $14, $12, $15, 1 ) ON CONFLICT (workspace_id, platform_id, platform_uid) WHERE deleted_at IS NULL DO UPDATE SET client_id = EXCLUDED.client_id, user_id = EXCLUDED.user_id, nickname = EXCLUDED.nickname, avatar_url = COALESCE(EXCLUDED.avatar_url, platform_accounts.avatar_url), status = EXCLUDED.status, metadata_json = COALESCE(EXCLUDED.metadata_json, platform_accounts.metadata_json), last_check_at = COALESCE(EXCLUDED.last_check_at, platform_accounts.last_check_at), account_fingerprint = EXCLUDED.account_fingerprint, display_name = EXCLUDED.display_name, health = EXCLUDED.health, verified_at = COALESCE(EXCLUDED.verified_at, platform_accounts.verified_at), tags = EXCLUDED.tags, sync_version = platform_accounts.sync_version + 1, delete_requested_at = NULL, updated_at = now() WHERE platform_accounts.workspace_id = EXCLUDED.workspace_id AND ( $16::bigint IS NULL OR platform_accounts.sync_version = $16::bigint ) RETURNING desktop_id, tenant_id, workspace_id, user_id, client_id, platform_id, platform_uid, account_fingerprint, display_name, avatar_url, health, verified_at, tags, sync_version, deleted_at, delete_requested_at, created_at, updated_at ` type UpsertDesktopAccountParams struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` LegacyStatus string `json:"legacy_status"` MetadataJson []byte `json:"metadata_json"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` Health string `json:"health"` Tags []byte `json:"tags"` IfSyncVersion pgtype.Int8 `json:"if_sync_version"` } type UpsertDesktopAccountRow struct { DesktopID pgtype.UUID `json:"desktop_id"` TenantID int64 `json:"tenant_id"` WorkspaceID int64 `json:"workspace_id"` UserID int64 `json:"user_id"` ClientID pgtype.UUID `json:"client_id"` PlatformID string `json:"platform_id"` PlatformUid string `json:"platform_uid"` AccountFingerprint pgtype.Text `json:"account_fingerprint"` DisplayName string `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` Health string `json:"health"` VerifiedAt pgtype.Timestamptz `json:"verified_at"` Tags []byte `json:"tags"` SyncVersion int64 `json:"sync_version"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` DeleteRequestedAt pgtype.Timestamptz `json:"delete_requested_at"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) UpsertDesktopAccount(ctx context.Context, arg UpsertDesktopAccountParams) (UpsertDesktopAccountRow, error) { row := q.db.QueryRow(ctx, upsertDesktopAccount, arg.DesktopID, arg.TenantID, arg.WorkspaceID, arg.UserID, arg.ClientID, arg.PlatformID, arg.PlatformUid, arg.DisplayName, arg.AvatarUrl, arg.LegacyStatus, arg.MetadataJson, arg.VerifiedAt, arg.AccountFingerprint, arg.Health, arg.Tags, arg.IfSyncVersion, ) var i UpsertDesktopAccountRow err := row.Scan( &i.DesktopID, &i.TenantID, &i.WorkspaceID, &i.UserID, &i.ClientID, &i.PlatformID, &i.PlatformUid, &i.AccountFingerprint, &i.DisplayName, &i.AvatarUrl, &i.Health, &i.VerifiedAt, &i.Tags, &i.SyncVersion, &i.DeletedAt, &i.DeleteRequestedAt, &i.CreatedAt, &i.UpdatedAt, ) return i, err }