- Add HTTP handlers for issues, comments, agents, workspaces, inbox, members, and activity - Implement JWT authentication middleware with Bearer token validation - Add sqlc queries for all entities (CRUD operations) - Extract router into reusable NewRouter() for testability - Expand SDK with full API client methods (CRUD for all resources) - Add updateWorkspace to SDK, add Member type to shared types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
2.1 KiB
Go
93 lines
2.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: activity.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createActivity = `-- name: CreateActivity :one
|
|
INSERT INTO activity_log (
|
|
workspace_id, issue_id, actor_type, actor_id, action, details
|
|
) VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING id, workspace_id, issue_id, actor_type, actor_id, action, details, created_at
|
|
`
|
|
|
|
type CreateActivityParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
IssueID pgtype.UUID `json:"issue_id"`
|
|
ActorType pgtype.Text `json:"actor_type"`
|
|
ActorID pgtype.UUID `json:"actor_id"`
|
|
Action string `json:"action"`
|
|
Details []byte `json:"details"`
|
|
}
|
|
|
|
func (q *Queries) CreateActivity(ctx context.Context, arg CreateActivityParams) (ActivityLog, error) {
|
|
row := q.db.QueryRow(ctx, createActivity,
|
|
arg.WorkspaceID,
|
|
arg.IssueID,
|
|
arg.ActorType,
|
|
arg.ActorID,
|
|
arg.Action,
|
|
arg.Details,
|
|
)
|
|
var i ActivityLog
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.IssueID,
|
|
&i.ActorType,
|
|
&i.ActorID,
|
|
&i.Action,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listActivities = `-- name: ListActivities :many
|
|
SELECT id, workspace_id, issue_id, actor_type, actor_id, action, details, created_at FROM activity_log
|
|
WHERE issue_id = $1
|
|
ORDER BY created_at DESC
|
|
LIMIT $2 OFFSET $3
|
|
`
|
|
|
|
type ListActivitiesParams struct {
|
|
IssueID pgtype.UUID `json:"issue_id"`
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListActivities(ctx context.Context, arg ListActivitiesParams) ([]ActivityLog, error) {
|
|
rows, err := q.db.Query(ctx, listActivities, arg.IssueID, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ActivityLog{}
|
|
for rows.Next() {
|
|
var i ActivityLog
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.WorkspaceID,
|
|
&i.IssueID,
|
|
&i.ActorType,
|
|
&i.ActorID,
|
|
&i.Action,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|