feat(store): store legal notices and privacy policies
Refs #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
44537a1c11
commit
4134af4aef
5 files changed
+132
No files matched your search
@@ -0,0 +1,82 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: legal.sql
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const deleteLegalDocument = `-- name: DeleteLegalDocument :exec
|
||||
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2
|
||||
`
|
||||
|
||||
type DeleteLegalDocumentParams struct {
|
||||
OrgID *uuid.UUID
|
||||
Kind string
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteLegalDocument(ctx context.Context, arg DeleteLegalDocumentParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteLegalDocument, arg.OrgID, arg.Kind)
|
||||
return err
|
||||
}
|
||||
|
||||
const legalDocuments = `-- name: LegalDocuments :many
|
||||
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
||||
WHERE org_id IS NULL OR org_id = $1
|
||||
ORDER BY org_id NULLS LAST, kind
|
||||
`
|
||||
|
||||
// The organization's documents and the platform's, organization first.
|
||||
func (q *Queries) LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error) {
|
||||
rows, err := q.db.Query(ctx, legalDocuments, orgID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []LegalDocument{}
|
||||
for rows.Next() {
|
||||
var i LegalDocument
|
||||
if err := rows.Scan(
|
||||
&i.OrgID,
|
||||
&i.Kind,
|
||||
&i.Url,
|
||||
&i.Markdown,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertLegalDocument = `-- name: UpsertLegalDocument :exec
|
||||
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertLegalDocumentParams struct {
|
||||
OrgID *uuid.UUID
|
||||
Kind string
|
||||
Url string
|
||||
Markdown string
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertLegalDocument,
|
||||
arg.OrgID,
|
||||
arg.Kind,
|
||||
arg.Url,
|
||||
arg.Markdown,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -115,6 +115,14 @@ type Invitation struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type LegalDocument struct {
|
||||
OrgID *uuid.UUID
|
||||
Kind string
|
||||
Url string
|
||||
Markdown string
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Membership struct {
|
||||
OrgID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
|
||||
@@ -51,6 +51,7 @@ type Querier interface {
|
||||
DeleteGroup(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteInvitationsForEmail(ctx context.Context, email string) error
|
||||
DeleteLegalDocument(ctx context.Context, arg DeleteLegalDocumentParams) error
|
||||
DeleteMonitor(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID) error
|
||||
DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
@@ -112,6 +113,8 @@ type Querier interface {
|
||||
// Newest result per monitor and region in the org.
|
||||
LatestResults(ctx context.Context, orgID uuid.UUID) ([]LatestResultsRow, error)
|
||||
LatestResultsForMonitor(ctx context.Context, arg LatestResultsForMonitorParams) ([]LatestResultsForMonitorRow, error)
|
||||
// The organization's documents and the platform's, organization first.
|
||||
LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error)
|
||||
ListAPITokens(ctx context.Context, arg ListAPITokensParams) ([]ListAPITokensRow, error)
|
||||
// Agents owned by org, or platform agents when org is NULL.
|
||||
ListAgents(ctx context.Context, orgID *uuid.UUID) ([]ListAgentsRow, error)
|
||||
@@ -214,6 +217,7 @@ type Querier interface {
|
||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||
UpdateSSOProvider(ctx context.Context, arg UpdateSSOProviderParams) (SsoProvider, error)
|
||||
UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error)
|
||||
UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error
|
||||
// Uptime per monitor from the hourly aggregate, including the not yet
|
||||
// materialized most recent hours (real-time aggregation).
|
||||
UptimeSince(ctx context.Context, arg UptimeSinceParams) ([]UptimeSinceRow, error)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
-- name: UpsertLegalDocument :exec
|
||||
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now();
|
||||
|
||||
-- name: DeleteLegalDocument :exec
|
||||
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2;
|
||||
|
||||
-- name: LegalDocuments :many
|
||||
-- The organization's documents and the platform's, organization first.
|
||||
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
||||
WHERE org_id IS NULL OR org_id = sqlc.narg(org_id)
|
||||
ORDER BY org_id NULLS LAST, kind;
|
||||
Reference in new issue
Block a user