core/repo-integrations-core/internal/db/query.sql.go
Tiago Yamamoto a52bd4519d refactor: optimize Dockerfiles and documentation for core services
- Use Google Distroless images for all services (Go & Node.js).
- Standardize documentation with [PROJECT-NAME].md.
- Add .dockerignore and .gitignore to all projects.
- Remove docker-compose.yml in favor of docker run instructions.
- Fix Go version and dependency issues in observability, repo-integrations, and security-governance.
- Add Podman support (fully qualified image names).
- Update Dashboard to use Node.js static server for Distroless compatibility.
2025-12-30 13:22:34 -03:00

446 lines
11 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: query.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createRepoAccount = `-- name: CreateRepoAccount :one
INSERT INTO repo_accounts (
tenant_id,
provider,
account_id,
username,
encrypted_access_token,
encrypted_refresh_token
) VALUES (
$1, $2, $3, $4, $5, $6
) RETURNING id, tenant_id, provider, account_id, username, encrypted_access_token, encrypted_refresh_token, created_at, updated_at
`
type CreateRepoAccountParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
Provider string `json:"provider"`
AccountID string `json:"account_id"`
Username string `json:"username"`
EncryptedAccessToken []byte `json:"encrypted_access_token"`
EncryptedRefreshToken []byte `json:"encrypted_refresh_token"`
}
func (q *Queries) CreateRepoAccount(ctx context.Context, arg CreateRepoAccountParams) (RepoAccount, error) {
row := q.db.QueryRow(ctx, createRepoAccount,
arg.TenantID,
arg.Provider,
arg.AccountID,
arg.Username,
arg.EncryptedAccessToken,
arg.EncryptedRefreshToken,
)
var i RepoAccount
err := row.Scan(
&i.ID,
&i.TenantID,
&i.Provider,
&i.AccountID,
&i.Username,
&i.EncryptedAccessToken,
&i.EncryptedRefreshToken,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const createRepoEvent = `-- name: CreateRepoEvent :one
INSERT INTO repo_events (
tenant_id,
repository_id,
event_type,
payload
) VALUES (
$1, $2, $3, $4
) RETURNING id, tenant_id, repository_id, event_type, payload, processed_at, created_at
`
type CreateRepoEventParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
RepositoryID pgtype.UUID `json:"repository_id"`
EventType string `json:"event_type"`
Payload []byte `json:"payload"`
}
func (q *Queries) CreateRepoEvent(ctx context.Context, arg CreateRepoEventParams) (RepoEvent, error) {
row := q.db.QueryRow(ctx, createRepoEvent,
arg.TenantID,
arg.RepositoryID,
arg.EventType,
arg.Payload,
)
var i RepoEvent
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepositoryID,
&i.EventType,
&i.Payload,
&i.ProcessedAt,
&i.CreatedAt,
)
return i, err
}
const createRepository = `-- name: CreateRepository :one
INSERT INTO repositories (
tenant_id,
repo_account_id,
external_id,
name,
url
) VALUES (
$1, $2, $3, $4, $5
) RETURNING id, tenant_id, repo_account_id, external_id, name, url, is_active, created_at, updated_at
`
type CreateRepositoryParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
RepoAccountID pgtype.UUID `json:"repo_account_id"`
ExternalID string `json:"external_id"`
Name string `json:"name"`
Url string `json:"url"`
}
func (q *Queries) CreateRepository(ctx context.Context, arg CreateRepositoryParams) (Repository, error) {
row := q.db.QueryRow(ctx, createRepository,
arg.TenantID,
arg.RepoAccountID,
arg.ExternalID,
arg.Name,
arg.Url,
)
var i Repository
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepoAccountID,
&i.ExternalID,
&i.Name,
&i.Url,
&i.IsActive,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const createWebhook = `-- name: CreateWebhook :one
INSERT INTO webhooks (
tenant_id,
repository_id,
external_id,
secret
) VALUES (
$1, $2, $3, $4
) RETURNING id, tenant_id, repository_id, external_id, secret, is_active, created_at
`
type CreateWebhookParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
RepositoryID pgtype.UUID `json:"repository_id"`
ExternalID string `json:"external_id"`
Secret string `json:"secret"`
}
func (q *Queries) CreateWebhook(ctx context.Context, arg CreateWebhookParams) (Webhook, error) {
row := q.db.QueryRow(ctx, createWebhook,
arg.TenantID,
arg.RepositoryID,
arg.ExternalID,
arg.Secret,
)
var i Webhook
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepositoryID,
&i.ExternalID,
&i.Secret,
&i.IsActive,
&i.CreatedAt,
)
return i, err
}
const getRepoAccount = `-- name: GetRepoAccount :one
SELECT id, tenant_id, provider, account_id, username, encrypted_access_token, encrypted_refresh_token, created_at, updated_at FROM repo_accounts
WHERE tenant_id = $1 AND provider = $2 AND account_id = $3
`
type GetRepoAccountParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
Provider string `json:"provider"`
AccountID string `json:"account_id"`
}
func (q *Queries) GetRepoAccount(ctx context.Context, arg GetRepoAccountParams) (RepoAccount, error) {
row := q.db.QueryRow(ctx, getRepoAccount, arg.TenantID, arg.Provider, arg.AccountID)
var i RepoAccount
err := row.Scan(
&i.ID,
&i.TenantID,
&i.Provider,
&i.AccountID,
&i.Username,
&i.EncryptedAccessToken,
&i.EncryptedRefreshToken,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getRepoAccountByID = `-- name: GetRepoAccountByID :one
SELECT id, tenant_id, provider, account_id, username, encrypted_access_token, encrypted_refresh_token, created_at, updated_at FROM repo_accounts
WHERE tenant_id = $1 AND id = $2
`
type GetRepoAccountByIDParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
ID pgtype.UUID `json:"id"`
}
func (q *Queries) GetRepoAccountByID(ctx context.Context, arg GetRepoAccountByIDParams) (RepoAccount, error) {
row := q.db.QueryRow(ctx, getRepoAccountByID, arg.TenantID, arg.ID)
var i RepoAccount
err := row.Scan(
&i.ID,
&i.TenantID,
&i.Provider,
&i.AccountID,
&i.Username,
&i.EncryptedAccessToken,
&i.EncryptedRefreshToken,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getRepository = `-- name: GetRepository :one
SELECT id, tenant_id, repo_account_id, external_id, name, url, is_active, created_at, updated_at FROM repositories
WHERE tenant_id = $1 AND id = $2
`
type GetRepositoryParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
ID pgtype.UUID `json:"id"`
}
func (q *Queries) GetRepository(ctx context.Context, arg GetRepositoryParams) (Repository, error) {
row := q.db.QueryRow(ctx, getRepository, arg.TenantID, arg.ID)
var i Repository
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepoAccountID,
&i.ExternalID,
&i.Name,
&i.Url,
&i.IsActive,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getRepositoryByExternalID = `-- name: GetRepositoryByExternalID :one
SELECT id, tenant_id, repo_account_id, external_id, name, url, is_active, created_at, updated_at FROM repositories
WHERE tenant_id = $1 AND external_id = $2
`
type GetRepositoryByExternalIDParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
ExternalID string `json:"external_id"`
}
func (q *Queries) GetRepositoryByExternalID(ctx context.Context, arg GetRepositoryByExternalIDParams) (Repository, error) {
row := q.db.QueryRow(ctx, getRepositoryByExternalID, arg.TenantID, arg.ExternalID)
var i Repository
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepoAccountID,
&i.ExternalID,
&i.Name,
&i.Url,
&i.IsActive,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getWebhookByRepoExternalID = `-- name: GetWebhookByRepoExternalID :one
SELECT w.id, w.tenant_id, w.repository_id, w.external_id, w.secret, w.is_active, w.created_at FROM webhooks w
JOIN repositories r ON w.repository_id = r.id
WHERE r.tenant_id = $1 AND r.external_id = $2
`
type GetWebhookByRepoExternalIDParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
ExternalID string `json:"external_id"`
}
func (q *Queries) GetWebhookByRepoExternalID(ctx context.Context, arg GetWebhookByRepoExternalIDParams) (Webhook, error) {
row := q.db.QueryRow(ctx, getWebhookByRepoExternalID, arg.TenantID, arg.ExternalID)
var i Webhook
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepositoryID,
&i.ExternalID,
&i.Secret,
&i.IsActive,
&i.CreatedAt,
)
return i, err
}
const getWebhookByRepoID = `-- name: GetWebhookByRepoID :one
SELECT id, tenant_id, repository_id, external_id, secret, is_active, created_at FROM webhooks
WHERE tenant_id = $1 AND repository_id = $2
`
type GetWebhookByRepoIDParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
RepositoryID pgtype.UUID `json:"repository_id"`
}
func (q *Queries) GetWebhookByRepoID(ctx context.Context, arg GetWebhookByRepoIDParams) (Webhook, error) {
row := q.db.QueryRow(ctx, getWebhookByRepoID, arg.TenantID, arg.RepositoryID)
var i Webhook
err := row.Scan(
&i.ID,
&i.TenantID,
&i.RepositoryID,
&i.ExternalID,
&i.Secret,
&i.IsActive,
&i.CreatedAt,
)
return i, err
}
const listRepoAccountsByTenant = `-- name: ListRepoAccountsByTenant :many
SELECT id, tenant_id, provider, account_id, username, encrypted_access_token, encrypted_refresh_token, created_at, updated_at FROM repo_accounts
WHERE tenant_id = $1
`
func (q *Queries) ListRepoAccountsByTenant(ctx context.Context, tenantID pgtype.UUID) ([]RepoAccount, error) {
rows, err := q.db.Query(ctx, listRepoAccountsByTenant, tenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []RepoAccount
for rows.Next() {
var i RepoAccount
if err := rows.Scan(
&i.ID,
&i.TenantID,
&i.Provider,
&i.AccountID,
&i.Username,
&i.EncryptedAccessToken,
&i.EncryptedRefreshToken,
&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 listRepositoriesByTenant = `-- name: ListRepositoriesByTenant :many
SELECT id, tenant_id, repo_account_id, external_id, name, url, is_active, created_at, updated_at FROM repositories
WHERE tenant_id = $1 AND is_active = TRUE
`
func (q *Queries) ListRepositoriesByTenant(ctx context.Context, tenantID pgtype.UUID) ([]Repository, error) {
rows, err := q.db.Query(ctx, listRepositoriesByTenant, tenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Repository
for rows.Next() {
var i Repository
if err := rows.Scan(
&i.ID,
&i.TenantID,
&i.RepoAccountID,
&i.ExternalID,
&i.Name,
&i.Url,
&i.IsActive,
&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 updateRepoAccountTokens = `-- name: UpdateRepoAccountTokens :one
UPDATE repo_accounts
SET
encrypted_access_token = $3,
encrypted_refresh_token = $4,
updated_at = NOW()
WHERE tenant_id = $1 AND id = $2
RETURNING id, tenant_id, provider, account_id, username, encrypted_access_token, encrypted_refresh_token, created_at, updated_at
`
type UpdateRepoAccountTokensParams struct {
TenantID pgtype.UUID `json:"tenant_id"`
ID pgtype.UUID `json:"id"`
EncryptedAccessToken []byte `json:"encrypted_access_token"`
EncryptedRefreshToken []byte `json:"encrypted_refresh_token"`
}
func (q *Queries) UpdateRepoAccountTokens(ctx context.Context, arg UpdateRepoAccountTokensParams) (RepoAccount, error) {
row := q.db.QueryRow(ctx, updateRepoAccountTokens,
arg.TenantID,
arg.ID,
arg.EncryptedAccessToken,
arg.EncryptedRefreshToken,
)
var i RepoAccount
err := row.Scan(
&i.ID,
&i.TenantID,
&i.Provider,
&i.AccountID,
&i.Username,
&i.EncryptedAccessToken,
&i.EncryptedRefreshToken,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}