feat: next

This commit is contained in:
2025-05-12 11:30:33 -04:00
parent cdeaa13d92
commit 07cec78aa5
36 changed files with 1553 additions and 327 deletions

View File

@ -0,0 +1,221 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: credential.sql
package sqlc
import (
"context"
"time"
)
const deleteCredential = `-- name: DeleteCredential :exec
DELETE FROM credential
WHERE
cred_id = ?1
AND
user_id = ?2
`
type DeleteCredentialParams struct {
ID string
UserID int64
}
func (q *Queries) DeleteCredential(ctx context.Context, arg DeleteCredentialParams) error {
_, err := q.db.ExecContext(ctx, deleteCredential, arg.ID, arg.UserID)
return err
}
const getCredential = `-- name: GetCredential :one
SELECT
cred_id,
cred_public_key,
sign_count,
transports,
user_verified,
backup_eligible,
backup_state,
attestation_object,
attestation_client_data,
created_at,
last_used,
user_id
FROM credential
WHERE
cred_id = ?1
AND
user_id = ?2
LIMIT 1
`
type GetCredentialParams struct {
ID string
UserID int64
}
func (q *Queries) GetCredential(ctx context.Context, arg GetCredentialParams) (Credential, error) {
row := q.db.QueryRowContext(ctx, getCredential, arg.ID, arg.UserID)
var i Credential
err := row.Scan(
&i.CredID,
&i.CredPublicKey,
&i.SignCount,
&i.Transports,
&i.UserVerified,
&i.BackupEligible,
&i.BackupState,
&i.AttestationObject,
&i.AttestationClientData,
&i.CreatedAt,
&i.LastUsed,
&i.UserID,
)
return i, err
}
const getCredentials = `-- name: GetCredentials :many
SELECT
cred_id,
cred_public_key,
sign_count,
transports,
user_verified,
backup_eligible,
backup_state,
attestation_object,
attestation_client_data,
created_at,
last_used,
user_id
FROM credential
WHERE user_id = ?1
`
func (q *Queries) GetCredentials(ctx context.Context, userID int64) ([]Credential, error) {
rows, err := q.db.QueryContext(ctx, getCredentials, userID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Credential
for rows.Next() {
var i Credential
if err := rows.Scan(
&i.CredID,
&i.CredPublicKey,
&i.SignCount,
&i.Transports,
&i.UserVerified,
&i.BackupEligible,
&i.BackupState,
&i.AttestationObject,
&i.AttestationClientData,
&i.CreatedAt,
&i.LastUsed,
&i.UserID,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const insertCredential = `-- name: InsertCredential :exec
INSERT INTO credential (
cred_id,
cred_public_key,
sign_count,
transports,
user_verified,
backup_eligible,
backup_state,
attestation_object,
attestation_client_data,
created_at,
last_used,
user_id
) VALUES (
?1,
?2,
?3,
?4,
?5,
?6,
?7,
?8,
?9,
?10,
?11,
?12
)
`
type InsertCredentialParams struct {
CredID string
CredPublicKey []byte
SignCount int64
Transports *string
UserVerified *bool
BackupEligible *bool
BackupState *bool
AttestationObject []byte
AttestationClientData []byte
CreatedAt time.Time
LastUsed time.Time
UserID int64
}
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) error {
_, err := q.db.ExecContext(ctx, insertCredential,
arg.CredID,
arg.CredPublicKey,
arg.SignCount,
arg.Transports,
arg.UserVerified,
arg.BackupEligible,
arg.BackupState,
arg.AttestationObject,
arg.AttestationClientData,
arg.CreatedAt,
arg.LastUsed,
arg.UserID,
)
return err
}
const updateCredential = `-- name: UpdateCredential :exec
UPDATE credential
SET
last_used = COALESCE(?1, last_used),
sign_count = COALESCE(?2, sign_count)
WHERE
cred_id = ?3
AND
user_id = ?4
`
type UpdateCredentialParams struct {
LastUsed *time.Time
SignCount *int64
ID string
UserID int64
}
func (q *Queries) UpdateCredential(ctx context.Context, arg UpdateCredentialParams) error {
_, err := q.db.ExecContext(ctx, updateCredential,
arg.LastUsed,
arg.SignCount,
arg.ID,
arg.UserID,
)
return err
}

View File

@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
package sqlc

View File

@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: file.sql
package sqlc

View File

@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: item.sql
package sqlc
@ -85,6 +85,7 @@ WHERE
AND
(added <= ?4 OR ?4 IS NULL)
)
ORDER BY added DESC
LIMIT
?6
OFFSET

View File

@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
package sqlc
@ -8,6 +8,21 @@ import (
"time"
)
type Credential struct {
CredID string
CredPublicKey []byte
SignCount int64
Transports *string
UserVerified *bool
BackupEligible *bool
BackupState *bool
AttestationObject []byte
AttestationClientData []byte
CreatedAt time.Time
LastUsed time.Time
UserID int64
}
type File struct {
ID int64
Name string
@ -34,4 +49,5 @@ type User struct {
Username string
Password string
ProfilePictureID *int64
WebauthnID string
}

View File

@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: user.sql
package sqlc
@ -24,7 +24,8 @@ SELECT
id,
username,
password,
profile_picture_id
profile_picture_id,
webauthn_id
FROM user
WHERE
id = ?1
@ -39,6 +40,7 @@ func (q *Queries) GetUser(ctx context.Context, id int64) (User, error) {
&i.Username,
&i.Password,
&i.ProfilePictureID,
&i.WebauthnID,
)
return i, err
}
@ -48,7 +50,8 @@ SELECT
id,
username,
password,
profile_picture_id
profile_picture_id,
webauthn_id
FROM user
WHERE
username = ?1
@ -63,6 +66,7 @@ func (q *Queries) GetUserbyUsername(ctx context.Context, username string) (User,
&i.Username,
&i.Password,
&i.ProfilePictureID,
&i.WebauthnID,
)
return i, err
}
@ -70,21 +74,24 @@ func (q *Queries) GetUserbyUsername(ctx context.Context, username string) (User,
const insertUser = `-- name: InsertUser :one
INSERT INTO user (
username,
password
password,
webauthn_id
) VALUES (
?1,
?2
?2,
?3
)
RETURNING id
`
type InsertUserParams struct {
Username string
Password string
Username string
Password string
WebauthnID string
}
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (int64, error) {
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Password)
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Password, arg.WebauthnID)
var id int64
err := row.Scan(&id)
return id, err