mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
feature/1214 session fetch refactor (#1215)
* chore(docs): remove token economy guide * refactor(context): update GatewayContext to use Querier interface * chore(database): update schema path * docs: Update READMEs for x/did, x/dwn, and x/svc with UCAN integration * chore(pkg): update database scope name * refactor(did): optimize GenesisState proto methods * refactor(svc): update Service proto to use repeated fields * refactor(api): rename MsgSpawn to MsgInitialize
This commit is contained in:
@@ -8,92 +8,61 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
Number int64
|
||||
Sequence int32
|
||||
Address string
|
||||
PublicKey string
|
||||
ChainID string
|
||||
Controller string
|
||||
IsSubsidiary bool
|
||||
IsValidator bool
|
||||
IsDelegator bool
|
||||
IsAccountable bool
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
ID string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
Name string
|
||||
Symbol string
|
||||
Decimals int32
|
||||
ChainID string
|
||||
Channel string
|
||||
AssetType string
|
||||
CoingeckoID pgtype.Text
|
||||
}
|
||||
|
||||
type Credential struct {
|
||||
ID string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
Handle string
|
||||
CredentialID string
|
||||
AuthenticatorAttachment string
|
||||
Origin string
|
||||
Type string
|
||||
Transports string
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
AuthenticatorAttachment string `json:"authenticator_attachment"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
ID string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
Address string
|
||||
Handle string
|
||||
Origin string
|
||||
Name string
|
||||
Status string
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
BrowserName string
|
||||
BrowserVersion string
|
||||
ClientIpaddr string
|
||||
Platform string
|
||||
IsDesktop bool
|
||||
IsMobile bool
|
||||
IsTablet bool
|
||||
IsTv bool
|
||||
IsBot bool
|
||||
Challenge string
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ProfileID string
|
||||
ID string `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
}
|
||||
|
||||
type Vault struct {
|
||||
ID int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DeletedAt pgtype.Timestamptz
|
||||
Handle string
|
||||
Origin string
|
||||
Address string
|
||||
Cid string
|
||||
Config []byte
|
||||
SessionID int64
|
||||
RedirectUri string
|
||||
ID int64 `json:"id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Address string `json:"address"`
|
||||
Cid string `json:"cid"`
|
||||
Config []byte `json:"config"`
|
||||
SessionID int64 `json:"session_id"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package hwayorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CheckHandleExists(ctx context.Context, handle string) (bool, error)
|
||||
CreateSession(ctx context.Context, arg CreateSessionParams) (*Session, error)
|
||||
GetChallengeBySessionID(ctx context.Context, id string) (string, error)
|
||||
GetCredentialByID(ctx context.Context, credentialID string) (*Credential, error)
|
||||
GetCredentialsByHandle(ctx context.Context, handle string) ([]*Credential, error)
|
||||
GetHumanVerificationNumbers(ctx context.Context, id string) (*GetHumanVerificationNumbersRow, error)
|
||||
GetProfileByAddress(ctx context.Context, address string) (*Profile, error)
|
||||
GetProfileByHandle(ctx context.Context, handle string) (*Profile, error)
|
||||
GetProfileByID(ctx context.Context, id string) (*Profile, error)
|
||||
GetSessionByClientIP(ctx context.Context, clientIpaddr string) (*Session, error)
|
||||
GetSessionByID(ctx context.Context, id string) (*Session, error)
|
||||
GetVaultConfigByCID(ctx context.Context, cid string) (*Vault, error)
|
||||
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID int64) (string, error)
|
||||
InsertCredential(ctx context.Context, arg InsertCredentialParams) (*Credential, error)
|
||||
InsertProfile(ctx context.Context, arg InsertProfileParams) (*Profile, error)
|
||||
SoftDeleteCredential(ctx context.Context, credentialID string) error
|
||||
SoftDeleteProfile(ctx context.Context, address string) error
|
||||
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (*Profile, error)
|
||||
UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (*Session, error)
|
||||
UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (*Session, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
+65
-65
@@ -1,7 +1,7 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: query_highway.sql
|
||||
// source: query.sql
|
||||
|
||||
package hwayorm
|
||||
|
||||
@@ -43,23 +43,23 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type CreateSessionParams struct {
|
||||
ID string
|
||||
BrowserName string
|
||||
BrowserVersion string
|
||||
ClientIpaddr string
|
||||
Platform string
|
||||
IsDesktop bool
|
||||
IsMobile bool
|
||||
IsTablet bool
|
||||
IsTv bool
|
||||
IsBot bool
|
||||
Challenge string
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ProfileID string
|
||||
ID string `json:"id"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) {
|
||||
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, createSession,
|
||||
arg.ID,
|
||||
arg.BrowserName,
|
||||
@@ -96,7 +96,7 @@ func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (S
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getChallengeBySessionID = `-- name: GetChallengeBySessionID :one
|
||||
@@ -119,7 +119,7 @@ AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (Credential, error) {
|
||||
func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (*Credential, error) {
|
||||
row := q.db.QueryRow(ctx, getCredentialByID, credentialID)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
@@ -134,7 +134,7 @@ func (q *Queries) GetCredentialByID(ctx context.Context, credentialID string) (C
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getCredentialsByHandle = `-- name: GetCredentialsByHandle :many
|
||||
@@ -143,13 +143,13 @@ WHERE handle = $1
|
||||
AND deleted_at IS NULL
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error) {
|
||||
func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]*Credential, error) {
|
||||
rows, err := q.db.Query(ctx, getCredentialsByHandle, handle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Credential
|
||||
var items []*Credential
|
||||
for rows.Next() {
|
||||
var i Credential
|
||||
if err := rows.Scan(
|
||||
@@ -166,7 +166,7 @@ func (q *Queries) GetCredentialsByHandle(ctx context.Context, handle string) ([]
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
@@ -181,15 +181,15 @@ LIMIT 1
|
||||
`
|
||||
|
||||
type GetHumanVerificationNumbersRow struct {
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (GetHumanVerificationNumbersRow, error) {
|
||||
func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (*GetHumanVerificationNumbersRow, error) {
|
||||
row := q.db.QueryRow(ctx, getHumanVerificationNumbers, id)
|
||||
var i GetHumanVerificationNumbersRow
|
||||
err := row.Scan(&i.IsHumanFirst, &i.IsHumanLast)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByAddress = `-- name: GetProfileByAddress :one
|
||||
@@ -198,7 +198,7 @@ WHERE address = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (Profile, error) {
|
||||
func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByAddress, address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
@@ -212,7 +212,7 @@ func (q *Queries) GetProfileByAddress(ctx context.Context, address string) (Prof
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByHandle = `-- name: GetProfileByHandle :one
|
||||
@@ -222,7 +222,7 @@ AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (Profile, error) {
|
||||
func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByHandle, handle)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
@@ -236,7 +236,7 @@ func (q *Queries) GetProfileByHandle(ctx context.Context, handle string) (Profil
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getProfileByID = `-- name: GetProfileByID :one
|
||||
@@ -245,7 +245,7 @@ WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProfileByID(ctx context.Context, id string) (Profile, error) {
|
||||
func (q *Queries) GetProfileByID(ctx context.Context, id string) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, getProfileByID, id)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
@@ -259,7 +259,7 @@ func (q *Queries) GetProfileByID(ctx context.Context, id string) (Profile, error
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getSessionByClientIP = `-- name: GetSessionByClientIP :one
|
||||
@@ -268,7 +268,7 @@ WHERE client_ipaddr = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByClientIP(ctx context.Context, clientIpaddr string) (Session, error) {
|
||||
func (q *Queries) GetSessionByClientIP(ctx context.Context, clientIpaddr string) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, getSessionByClientIP, clientIpaddr)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
@@ -290,7 +290,7 @@ func (q *Queries) GetSessionByClientIP(ctx context.Context, clientIpaddr string)
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getSessionByID = `-- name: GetSessionByID :one
|
||||
@@ -299,7 +299,7 @@ WHERE id = $1 AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetSessionByID(ctx context.Context, id string) (Session, error) {
|
||||
func (q *Queries) GetSessionByID(ctx context.Context, id string) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, getSessionByID, id)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
@@ -321,7 +321,7 @@ func (q *Queries) GetSessionByID(ctx context.Context, id string) (Session, error
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getVaultConfigByCID = `-- name: GetVaultConfigByCID :one
|
||||
@@ -331,7 +331,7 @@ AND deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error) {
|
||||
func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (*Vault, error) {
|
||||
row := q.db.QueryRow(ctx, getVaultConfigByCID, cid)
|
||||
var i Vault
|
||||
err := row.Scan(
|
||||
@@ -347,7 +347,7 @@ func (q *Queries) GetVaultConfigByCID(ctx context.Context, cid string) (Vault, e
|
||||
&i.SessionID,
|
||||
&i.RedirectUri,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getVaultRedirectURIBySessionID = `-- name: GetVaultRedirectURIBySessionID :one
|
||||
@@ -376,14 +376,14 @@ RETURNING id, created_at, updated_at, deleted_at, handle, credential_id, authent
|
||||
`
|
||||
|
||||
type InsertCredentialParams struct {
|
||||
Handle string
|
||||
CredentialID string
|
||||
Origin string
|
||||
Type string
|
||||
Transports string
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error) {
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (*Credential, error) {
|
||||
row := q.db.QueryRow(ctx, insertCredential,
|
||||
arg.Handle,
|
||||
arg.CredentialID,
|
||||
@@ -404,7 +404,7 @@ func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialPara
|
||||
&i.Type,
|
||||
&i.Transports,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const insertProfile = `-- name: InsertProfile :one
|
||||
@@ -418,13 +418,13 @@ RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name,
|
||||
`
|
||||
|
||||
type InsertProfileParams struct {
|
||||
Address string
|
||||
Handle string
|
||||
Origin string
|
||||
Name string
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error) {
|
||||
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, insertProfile,
|
||||
arg.Address,
|
||||
arg.Handle,
|
||||
@@ -443,7 +443,7 @@ func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (P
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const softDeleteCredential = `-- name: SoftDeleteCredential :exec
|
||||
@@ -480,12 +480,12 @@ RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name,
|
||||
`
|
||||
|
||||
type UpdateProfileParams struct {
|
||||
Name string
|
||||
Handle string
|
||||
Address string
|
||||
Name string `json:"name"`
|
||||
Handle string `json:"handle"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error) {
|
||||
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (*Profile, error) {
|
||||
row := q.db.QueryRow(ctx, updateProfile, arg.Name, arg.Handle, arg.Address)
|
||||
var i Profile
|
||||
err := row.Scan(
|
||||
@@ -499,7 +499,7 @@ func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (P
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const updateSessionHumanVerification = `-- name: UpdateSessionHumanVerification :one
|
||||
@@ -513,12 +513,12 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type UpdateSessionHumanVerificationParams struct {
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ID string
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (Session, error) {
|
||||
func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, updateSessionHumanVerification, arg.IsHumanFirst, arg.IsHumanLast, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
@@ -540,7 +540,7 @@ func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg Update
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const updateSessionWithProfileID = `-- name: UpdateSessionWithProfileID :one
|
||||
@@ -553,11 +553,11 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type UpdateSessionWithProfileIDParams struct {
|
||||
ProfileID string
|
||||
ID string
|
||||
ProfileID string `json:"profile_id"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (Session, error) {
|
||||
func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (*Session, error) {
|
||||
row := q.db.QueryRow(ctx, updateSessionWithProfileID, arg.ProfileID, arg.ID)
|
||||
var i Session
|
||||
err := row.Scan(
|
||||
@@ -579,5 +579,5 @@ func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSess
|
||||
&i.IsHumanLast,
|
||||
&i.ProfileID,
|
||||
)
|
||||
return i, err
|
||||
return &i, err
|
||||
}
|
||||
@@ -10,90 +10,90 @@ import (
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
Number int64
|
||||
Sequence int64
|
||||
Address string
|
||||
PublicKey string
|
||||
ChainID string
|
||||
Controller string
|
||||
IsSubsidiary bool
|
||||
IsValidator bool
|
||||
IsDelegator bool
|
||||
IsAccountable bool
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Number int64 `json:"number"`
|
||||
Sequence int64 `json:"sequence"`
|
||||
Address string `json:"address"`
|
||||
PublicKey string `json:"public_key"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Controller string `json:"controller"`
|
||||
IsSubsidiary bool `json:"is_subsidiary"`
|
||||
IsValidator bool `json:"is_validator"`
|
||||
IsDelegator bool `json:"is_delegator"`
|
||||
IsAccountable bool `json:"is_accountable"`
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
Name string
|
||||
Symbol string
|
||||
Decimals int64
|
||||
ChainID string
|
||||
Channel string
|
||||
AssetType string
|
||||
CoingeckoID sql.NullString
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Name string `json:"name"`
|
||||
Symbol string `json:"symbol"`
|
||||
Decimals int64 `json:"decimals"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Channel string `json:"channel"`
|
||||
AssetType string `json:"asset_type"`
|
||||
CoingeckoID sql.NullString `json:"coingecko_id"`
|
||||
}
|
||||
|
||||
type Credential struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
Handle string
|
||||
CredentialID string
|
||||
AuthenticatorAttachment string
|
||||
Origin string
|
||||
Type string
|
||||
Transports string
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
AuthenticatorAttachment string `json:"authenticator_attachment"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
Address string
|
||||
Handle string
|
||||
Origin string
|
||||
Name string
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
BrowserName string
|
||||
BrowserVersion string
|
||||
ClientIpaddr string
|
||||
Platform string
|
||||
IsDesktop bool
|
||||
IsMobile bool
|
||||
IsTablet bool
|
||||
IsTv bool
|
||||
IsBot bool
|
||||
Challenge string
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ProfileID int64
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
}
|
||||
|
||||
type Vault struct {
|
||||
ID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt sql.NullTime
|
||||
Handle string
|
||||
Origin string
|
||||
Address string
|
||||
Cid string
|
||||
Config string
|
||||
SessionID string
|
||||
RedirectUri string
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt sql.NullTime `json:"deleted_at"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Address string `json:"address"`
|
||||
Cid string `json:"cid"`
|
||||
Config string `json:"config"`
|
||||
SessionID string `json:"session_id"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
|
||||
package motrorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CheckHandleExists(ctx context.Context, handle string) (bool, error)
|
||||
CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
|
||||
GetChallengeBySessionID(ctx context.Context, id string) (string, error)
|
||||
GetCredentialByID(ctx context.Context, credentialID string) (Credential, error)
|
||||
GetCredentialsByHandle(ctx context.Context, handle string) ([]Credential, error)
|
||||
GetHumanVerificationNumbers(ctx context.Context, id string) (GetHumanVerificationNumbersRow, error)
|
||||
GetProfileByAddress(ctx context.Context, address string) (Profile, error)
|
||||
GetProfileByHandle(ctx context.Context, handle string) (Profile, error)
|
||||
GetProfileByID(ctx context.Context, id string) (Profile, error)
|
||||
GetSessionByClientIP(ctx context.Context, clientIpaddr string) (Session, error)
|
||||
GetSessionByID(ctx context.Context, id string) (Session, error)
|
||||
GetVaultConfigByCID(ctx context.Context, cid string) (Vault, error)
|
||||
GetVaultRedirectURIBySessionID(ctx context.Context, sessionID string) (string, error)
|
||||
InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error)
|
||||
InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error)
|
||||
SoftDeleteCredential(ctx context.Context, credentialID string) error
|
||||
SoftDeleteProfile(ctx context.Context, address string) error
|
||||
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
|
||||
UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (Session, error)
|
||||
UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (Session, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
+34
-34
@@ -1,7 +1,7 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: query_vault.sql
|
||||
// source: query.sql
|
||||
|
||||
package motrorm
|
||||
|
||||
@@ -43,20 +43,20 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type CreateSessionParams struct {
|
||||
ID string
|
||||
BrowserName string
|
||||
BrowserVersion string
|
||||
ClientIpaddr string
|
||||
Platform string
|
||||
IsDesktop bool
|
||||
IsMobile bool
|
||||
IsTablet bool
|
||||
IsTv bool
|
||||
IsBot bool
|
||||
Challenge string
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ProfileID int64
|
||||
ID string `json:"id"`
|
||||
BrowserName string `json:"browser_name"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
ClientIpaddr string `json:"client_ipaddr"`
|
||||
Platform string `json:"platform"`
|
||||
IsDesktop bool `json:"is_desktop"`
|
||||
IsMobile bool `json:"is_mobile"`
|
||||
IsTablet bool `json:"is_tablet"`
|
||||
IsTv bool `json:"is_tv"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
Challenge string `json:"challenge"`
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error) {
|
||||
@@ -184,8 +184,8 @@ LIMIT 1
|
||||
`
|
||||
|
||||
type GetHumanVerificationNumbersRow struct {
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetHumanVerificationNumbers(ctx context.Context, id string) (GetHumanVerificationNumbersRow, error) {
|
||||
@@ -376,11 +376,11 @@ RETURNING id, created_at, updated_at, deleted_at, handle, credential_id, authent
|
||||
`
|
||||
|
||||
type InsertCredentialParams struct {
|
||||
Handle string
|
||||
CredentialID string
|
||||
Origin string
|
||||
Type string
|
||||
Transports string
|
||||
Handle string `json:"handle"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
Origin string `json:"origin"`
|
||||
Type string `json:"type"`
|
||||
Transports string `json:"transports"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) (Credential, error) {
|
||||
@@ -418,10 +418,10 @@ RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
|
||||
`
|
||||
|
||||
type InsertProfileParams struct {
|
||||
Address string
|
||||
Handle string
|
||||
Origin string
|
||||
Name string
|
||||
Address string `json:"address"`
|
||||
Handle string `json:"handle"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProfile(ctx context.Context, arg InsertProfileParams) (Profile, error) {
|
||||
@@ -479,9 +479,9 @@ RETURNING id, created_at, updated_at, deleted_at, address, handle, origin, name
|
||||
`
|
||||
|
||||
type UpdateProfileParams struct {
|
||||
Name string
|
||||
Handle string
|
||||
Address string
|
||||
Name string `json:"name"`
|
||||
Handle string `json:"handle"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error) {
|
||||
@@ -511,9 +511,9 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type UpdateSessionHumanVerificationParams struct {
|
||||
IsHumanFirst bool
|
||||
IsHumanLast bool
|
||||
ID string
|
||||
IsHumanFirst bool `json:"is_human_first"`
|
||||
IsHumanLast bool `json:"is_human_last"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionHumanVerification(ctx context.Context, arg UpdateSessionHumanVerificationParams) (Session, error) {
|
||||
@@ -551,8 +551,8 @@ RETURNING id, created_at, updated_at, deleted_at, browser_name, browser_version,
|
||||
`
|
||||
|
||||
type UpdateSessionWithProfileIDParams struct {
|
||||
ProfileID int64
|
||||
ID string
|
||||
ProfileID int64 `json:"profile_id"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateSessionWithProfileID(ctx context.Context, arg UpdateSessionWithProfileIDParams) (Session, error) {
|
||||
@@ -98,8 +98,6 @@ CREATE TABLE vaults (
|
||||
FOREIGN KEY (session_id) REFERENCES sessions(id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
-- Indexes for common queries
|
||||
CREATE INDEX idx_profiles_handle ON profiles(handle);
|
||||
CREATE INDEX idx_profiles_address ON profiles(address);
|
||||
@@ -4,5 +4,5 @@ import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed schema_vault.sql
|
||||
//go:embed vault/schema.sql
|
||||
var SchemaVaultSQL string
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "sqlite"
|
||||
queries: "./sink/query_vault.sql"
|
||||
schema: "./sink/schema_vault.sql"
|
||||
queries: "./sink/vault/query.sql"
|
||||
schema: "./sink/vault/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_interface: true
|
||||
emit_json_tags: true
|
||||
package: "motrorm"
|
||||
out: "motrorm"
|
||||
|
||||
- engine: "postgresql"
|
||||
queries: "./sink/query_highway.sql"
|
||||
schema: "./sink/schema_highway.sql"
|
||||
queries: "./sink/highway/query.sql"
|
||||
schema: "./sink/highway/schema.sql"
|
||||
gen:
|
||||
go:
|
||||
emit_all_enum_values: true
|
||||
emit_enum_valid_method: true
|
||||
emit_json_tags: true
|
||||
emit_interface: true
|
||||
emit_result_struct_pointers: true
|
||||
omit_unused_structs: true
|
||||
package: "hwayorm"
|
||||
out: "hwayorm"
|
||||
sql_package: "pgx/v5"
|
||||
|
||||
sql_package: "pgx/v5"
|
||||
|
||||
Reference in New Issue
Block a user