sql

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Text

func Text[T ~string](value T) pgtype.Text

func TimestampTz

func TimestampTz(t time.Time) pgtype.Timestamptz

func ToPointerString added in v0.36.0

func ToPointerString(value pgtype.Text) *string

Types

type AuthProvider

type AuthProvider struct {
	ID string
}

List of available Oauth providers. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthProviderRequest

type AuthProviderRequest struct {
	ID      uuid.UUID
	Options []byte
}

Oauth requests, inserted before redirecting to the provider's site. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthRefreshToken

type AuthRefreshToken struct {
	ID               uuid.UUID
	CreatedAt        pgtype.Timestamptz
	ExpiresAt        pgtype.Timestamptz
	UserID           uuid.UUID
	Metadata         []byte
	Type             RefreshTokenType
	RefreshTokenHash pgtype.Text
}

User refresh tokens. Hasura auth uses them to rotate new access tokens as long as the refresh token is not expired. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthRefreshTokenType

type AuthRefreshTokenType struct {
	Value   string
	Comment pgtype.Text
}

type AuthRole

type AuthRole struct {
	Role string
}

Persistent Hasura roles for users. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthSchemaMigration added in v0.40.0

type AuthSchemaMigration struct {
	Version int64
	Dirty   bool
}

Internal table for tracking migrations. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthUser

type AuthUser struct {
	ID                       uuid.UUID
	CreatedAt                pgtype.Timestamptz
	UpdatedAt                pgtype.Timestamptz
	LastSeen                 pgtype.Timestamptz
	Disabled                 bool
	DisplayName              string
	AvatarUrl                string
	Locale                   string
	Email                    pgtype.Text
	PhoneNumber              pgtype.Text
	PasswordHash             pgtype.Text
	EmailVerified            bool
	PhoneNumberVerified      bool
	NewEmail                 pgtype.Text
	OtpMethodLastUsed        pgtype.Text
	OtpHash                  pgtype.Text
	OtpHashExpiresAt         pgtype.Timestamptz
	DefaultRole              string
	IsAnonymous              bool
	TotpSecret               pgtype.Text
	ActiveMfaType            pgtype.Text
	Ticket                   pgtype.Text
	TicketExpiresAt          pgtype.Timestamptz
	Metadata                 []byte
	WebauthnCurrentChallenge pgtype.Text
}

User account information. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthUserProvider

type AuthUserProvider struct {
	ID             uuid.UUID
	CreatedAt      pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
	UserID         uuid.UUID
	AccessToken    string
	RefreshToken   pgtype.Text
	ProviderID     string
	ProviderUserID string
}

Active providers for a given user. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthUserRole

type AuthUserRole struct {
	ID        uuid.UUID
	CreatedAt pgtype.Timestamptz
	UserID    uuid.UUID
	Role      string
}

Roles of users. Don't modify its structure as Hasura Auth relies on it to function properly.

type AuthUserSecurityKey

type AuthUserSecurityKey struct {
	ID                  uuid.UUID
	UserID              uuid.UUID
	CredentialID        string
	CredentialPublicKey []byte
	Counter             int64
	Transports          string
	Nickname            pgtype.Text
}

User webauthn security keys. Don't modify its structure as Hasura Auth relies on it to function properly.

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type FindUserProviderByProviderIdParams added in v0.35.0

type FindUserProviderByProviderIdParams struct {
	ProviderUserID string
	ProviderID     string
}

type GetUserByEmailAndTicketParams added in v0.35.0

type GetUserByEmailAndTicketParams struct {
	Email  pgtype.Text
	Ticket pgtype.Text
}

type GetUserByPhoneNumberAndOTPParams added in v0.39.1

type GetUserByPhoneNumberAndOTPParams struct {
	PhoneNumber pgtype.Text
	Otp         string
}

type GetUserByProviderIDParams added in v0.35.0

type GetUserByProviderIDParams struct {
	ProviderUserID string
	ProviderID     string
}

type GetUserByRefreshTokenHashParams added in v0.28.0

type GetUserByRefreshTokenHashParams struct {
	RefreshTokenHash pgtype.Text
	Type             RefreshTokenType
}

type InsertRefreshtokenParams added in v0.28.0

type InsertRefreshtokenParams struct {
	UserID           uuid.UUID
	RefreshTokenHash pgtype.Text
	ExpiresAt        pgtype.Timestamptz
	Type             RefreshTokenType
	Metadata         []byte
}

type InsertSecurityKeyParams added in v0.39.0

type InsertSecurityKeyParams struct {
	UserID              uuid.UUID
	CredentialID        string
	CredentialPublicKey []byte
	Nickname            pgtype.Text
}

type InsertUserParams

type InsertUserParams struct {
	ID                uuid.UUID
	Disabled          bool
	DisplayName       string
	AvatarUrl         string
	PhoneNumber       pgtype.Text
	Roles             []string
	Otp               string
	OtpMethodLastUsed pgtype.Text
	Email             pgtype.Text
	PasswordHash      pgtype.Text
	Ticket            pgtype.Text
	TicketExpiresAt   pgtype.Timestamptz
	EmailVerified     bool
	Locale            string
	DefaultRole       string
	Metadata          []byte
	OtpHashExpiresAt  pgtype.Timestamptz
}

type InsertUserProviderParams added in v0.35.0

type InsertUserProviderParams struct {
	UserID         uuid.UUID
	ProviderID     string
	ProviderUserID string
}

type InsertUserRow

type InsertUserRow struct {
	UserID    uuid.UUID
	CreatedAt pgtype.Timestamptz
}

type InsertUserWithRefreshTokenParams

type InsertUserWithRefreshTokenParams struct {
	Disabled              bool
	DisplayName           string
	AvatarUrl             string
	Email                 pgtype.Text
	PasswordHash          pgtype.Text
	Ticket                pgtype.Text
	TicketExpiresAt       pgtype.Timestamptz
	EmailVerified         bool
	Locale                string
	DefaultRole           string
	IsAnonymous           bool
	Metadata              []byte
	RefreshTokenHash      pgtype.Text
	RefreshTokenExpiresAt pgtype.Timestamptz
	Roles                 []string
}

type InsertUserWithRefreshTokenRow

type InsertUserWithRefreshTokenRow struct {
	ID             uuid.UUID
	RefreshTokenID uuid.UUID
}

type InsertUserWithSecurityKeyAndRefreshTokenParams added in v0.28.0

type InsertUserWithSecurityKeyAndRefreshTokenParams struct {
	ID                    uuid.UUID
	Disabled              bool
	DisplayName           string
	AvatarUrl             string
	Email                 pgtype.Text
	Ticket                pgtype.Text
	TicketExpiresAt       pgtype.Timestamptz
	EmailVerified         bool
	Locale                string
	DefaultRole           string
	Metadata              []byte
	RefreshTokenHash      pgtype.Text
	RefreshTokenExpiresAt pgtype.Timestamptz
	CredentialID          string
	CredentialPublicKey   []byte
	Nickname              pgtype.Text
	Roles                 []string
}

type InsertUserWithSecurityKeyAndRefreshTokenRow added in v0.28.1

type InsertUserWithSecurityKeyAndRefreshTokenRow struct {
	ID             uuid.UUID
	RefreshTokenID uuid.UUID
}

type InsertUserWithSecurityKeyParams added in v0.28.0

type InsertUserWithSecurityKeyParams struct {
	ID                  uuid.UUID
	Disabled            bool
	DisplayName         string
	AvatarUrl           string
	Email               pgtype.Text
	Ticket              pgtype.Text
	TicketExpiresAt     pgtype.Timestamptz
	EmailVerified       bool
	Locale              string
	DefaultRole         string
	Metadata            []byte
	Roles               []string
	CredentialID        string
	CredentialPublicKey []byte
	Nickname            pgtype.Text
}

type InsertUserWithUserProviderAndRefreshTokenParams added in v0.35.0

type InsertUserWithUserProviderAndRefreshTokenParams struct {
	ID                    uuid.UUID
	Disabled              bool
	DisplayName           string
	AvatarUrl             string
	Email                 pgtype.Text
	Ticket                pgtype.Text
	TicketExpiresAt       pgtype.Timestamptz
	EmailVerified         bool
	Locale                string
	DefaultRole           string
	Metadata              []byte
	RefreshTokenHash      pgtype.Text
	RefreshTokenExpiresAt pgtype.Timestamptz
	ProviderID            string
	ProviderUserID        string
	Roles                 []string
}

type InsertUserWithUserProviderAndRefreshTokenRow added in v0.35.0

type InsertUserWithUserProviderAndRefreshTokenRow struct {
	ID             uuid.UUID
	RefreshTokenID uuid.UUID
}

type InsertUserWithUserProviderParams added in v0.35.0

type InsertUserWithUserProviderParams struct {
	ID              uuid.UUID
	Disabled        bool
	DisplayName     string
	AvatarUrl       string
	Email           pgtype.Text
	Ticket          pgtype.Text
	TicketExpiresAt pgtype.Timestamptz
	EmailVerified   bool
	Locale          string
	DefaultRole     string
	Metadata        []byte
	Roles           []string
	ProviderID      string
	ProviderUserID  string
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CountSecurityKeysUser added in v0.28.0

func (q *Queries) CountSecurityKeysUser(ctx context.Context, userID uuid.UUID) (int64, error)

func (*Queries) DeleteRefreshToken added in v0.40.0

func (q *Queries) DeleteRefreshToken(ctx context.Context, refreshTokenHash pgtype.Text) error

func (*Queries) DeleteRefreshTokens added in v0.28.0

func (q *Queries) DeleteRefreshTokens(ctx context.Context, userID uuid.UUID) error

func (*Queries) DeleteUserRoles added in v0.28.0

func (q *Queries) DeleteUserRoles(ctx context.Context, userID uuid.UUID) error

func (*Queries) FindUserProviderByProviderId added in v0.35.0

func (q *Queries) FindUserProviderByProviderId(ctx context.Context, arg FindUserProviderByProviderIdParams) (AuthUserProvider, error)

func (*Queries) GetSecurityKeys added in v0.36.0

func (q *Queries) GetSecurityKeys(ctx context.Context, userID uuid.UUID) ([]AuthUserSecurityKey, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (AuthUser, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email pgtype.Text) (AuthUser, error)

func (*Queries) GetUserByEmailAndTicket added in v0.35.0

func (q *Queries) GetUserByEmailAndTicket(ctx context.Context, arg GetUserByEmailAndTicketParams) (AuthUser, error)

func (*Queries) GetUserByPhoneNumber added in v0.39.1

func (q *Queries) GetUserByPhoneNumber(ctx context.Context, phoneNumber pgtype.Text) (AuthUser, error)

func (*Queries) GetUserByPhoneNumberAndOTP added in v0.39.1

func (q *Queries) GetUserByPhoneNumberAndOTP(ctx context.Context, arg GetUserByPhoneNumberAndOTPParams) (AuthUser, error)

func (*Queries) GetUserByProviderID added in v0.35.0

func (q *Queries) GetUserByProviderID(ctx context.Context, arg GetUserByProviderIDParams) (AuthUser, error)

func (*Queries) GetUserByRefreshTokenHash added in v0.28.0

func (q *Queries) GetUserByRefreshTokenHash(ctx context.Context, arg GetUserByRefreshTokenHashParams) (AuthUser, error)

func (*Queries) GetUserByTicket added in v0.34.0

func (q *Queries) GetUserByTicket(ctx context.Context, dollar_1 pgtype.Text) (AuthUser, error)

func (*Queries) GetUserRoles added in v0.28.0

func (q *Queries) GetUserRoles(ctx context.Context, userID uuid.UUID) ([]AuthUserRole, error)

func (*Queries) InsertRefreshtoken added in v0.28.0

func (q *Queries) InsertRefreshtoken(ctx context.Context, arg InsertRefreshtokenParams) (uuid.UUID, error)

func (*Queries) InsertSecurityKey added in v0.39.0

func (q *Queries) InsertSecurityKey(ctx context.Context, arg InsertSecurityKeyParams) (uuid.UUID, error)

func (*Queries) InsertUser

func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (InsertUserRow, error)

func (*Queries) InsertUserProvider added in v0.35.0

func (q *Queries) InsertUserProvider(ctx context.Context, arg InsertUserProviderParams) (AuthUserProvider, error)

func (*Queries) InsertUserWithSecurityKey added in v0.28.0

func (q *Queries) InsertUserWithSecurityKey(ctx context.Context, arg InsertUserWithSecurityKeyParams) (uuid.UUID, error)

func (*Queries) InsertUserWithSecurityKeyAndRefreshToken added in v0.28.0

func (*Queries) InsertUserWithUserProvider added in v0.35.0

func (q *Queries) InsertUserWithUserProvider(ctx context.Context, arg InsertUserWithUserProviderParams) (uuid.UUID, error)

func (*Queries) InsertUserWithUserProviderAndRefreshToken added in v0.35.0

func (*Queries) RefreshTokenAndGetUserRoles added in v0.29.0

func (q *Queries) RefreshTokenAndGetUserRoles(ctx context.Context, arg RefreshTokenAndGetUserRolesParams) ([]RefreshTokenAndGetUserRolesRow, error)

func (*Queries) UpdateUserActiveMFAType added in v0.38.1

func (q *Queries) UpdateUserActiveMFAType(ctx context.Context, arg UpdateUserActiveMFATypeParams) error

func (*Queries) UpdateUserChangeEmail added in v0.28.0

func (q *Queries) UpdateUserChangeEmail(ctx context.Context, arg UpdateUserChangeEmailParams) (AuthUser, error)

func (*Queries) UpdateUserChangePassword added in v0.34.0

func (q *Queries) UpdateUserChangePassword(ctx context.Context, arg UpdateUserChangePasswordParams) (uuid.UUID, error)

func (*Queries) UpdateUserConfirmChangeEmail added in v0.35.0

func (q *Queries) UpdateUserConfirmChangeEmail(ctx context.Context, id uuid.UUID) (AuthUser, error)

func (*Queries) UpdateUserDeanonymize added in v0.28.0

func (q *Queries) UpdateUserDeanonymize(ctx context.Context, arg UpdateUserDeanonymizeParams) error

func (*Queries) UpdateUserLastSeen added in v0.28.0

func (q *Queries) UpdateUserLastSeen(ctx context.Context, id uuid.UUID) (pgtype.Timestamptz, error)

func (*Queries) UpdateUserOTPHash added in v0.39.1

func (q *Queries) UpdateUserOTPHash(ctx context.Context, arg UpdateUserOTPHashParams) (uuid.UUID, error)

func (*Queries) UpdateUserTicket added in v0.28.0

func (q *Queries) UpdateUserTicket(ctx context.Context, arg UpdateUserTicketParams) (uuid.UUID, error)

func (*Queries) UpdateUserTotpSecret added in v0.38.1

func (q *Queries) UpdateUserTotpSecret(ctx context.Context, arg UpdateUserTotpSecretParams) error

func (*Queries) UpdateUserVerifyEmail added in v0.35.0

func (q *Queries) UpdateUserVerifyEmail(ctx context.Context, id uuid.UUID) (AuthUser, error)

func (*Queries) UpsertRoles added in v0.40.0

func (q *Queries) UpsertRoles(ctx context.Context, roles []string) ([]string, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RefreshTokenAndGetUserRolesParams added in v0.29.0

type RefreshTokenAndGetUserRolesParams struct {
	NewRefreshTokenHash pgtype.Text
	ExpiresAt           pgtype.Timestamptz
	OldRefreshTokenHash pgtype.Text
}

type RefreshTokenAndGetUserRolesRow added in v0.29.0

type RefreshTokenAndGetUserRolesRow struct {
	RefreshTokenID uuid.UUID
	Role           pgtype.Text
}

type RefreshTokenType added in v0.28.0

type RefreshTokenType string
const (
	RefreshTokenTypeRegular RefreshTokenType = "regular"
	RefreshTokenTypePAT     RefreshTokenType = "pat"
)

type UpdateUserActiveMFATypeParams added in v0.38.1

type UpdateUserActiveMFATypeParams struct {
	ID            uuid.UUID
	ActiveMfaType pgtype.Text
}

type UpdateUserChangeEmailParams added in v0.28.0

type UpdateUserChangeEmailParams struct {
	ID              uuid.UUID
	Ticket          pgtype.Text
	TicketExpiresAt pgtype.Timestamptz
	NewEmail        pgtype.Text
}

type UpdateUserChangePasswordParams added in v0.34.0

type UpdateUserChangePasswordParams struct {
	ID           uuid.UUID
	PasswordHash pgtype.Text
}

type UpdateUserDeanonymizeParams added in v0.28.0

type UpdateUserDeanonymizeParams struct {
	Roles           []string
	Email           interface{}
	DefaultRole     pgtype.Text
	DisplayName     pgtype.Text
	Locale          pgtype.Text
	Metadata        []byte
	PasswordHash    pgtype.Text
	Ticket          pgtype.Text
	TicketExpiresAt pgtype.Timestamptz
	ID              pgtype.UUID
}

type UpdateUserOTPHashParams added in v0.39.1

type UpdateUserOTPHashParams struct {
	ID                uuid.UUID
	Otp               string
	OtpHashExpiresAt  pgtype.Timestamptz
	OtpMethodLastUsed pgtype.Text
}

type UpdateUserTicketParams added in v0.28.0

type UpdateUserTicketParams struct {
	ID              uuid.UUID
	Ticket          pgtype.Text
	TicketExpiresAt pgtype.Timestamptz
}

type UpdateUserTotpSecretParams added in v0.38.1

type UpdateUserTotpSecretParams struct {
	ID         uuid.UUID
	TotpSecret pgtype.Text
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL