gen

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	And = runtime.And
	Or  = runtime.Or
)

And / Or combine @filter-tree predicates built with the generated per-query constructors.

View Source
var ShapeSpace = map[string]runtime.ShapeSpaceInfo{
	"AllAuditActions":   {Enumerable: 1, Exact: true, Unbounded: false},
	"CountAuditLogs":    {Enumerable: 1, Exact: true, Unbounded: false},
	"FilterUsers":       {Enumerable: 1, Exact: true, Unbounded: true},
	"FindUserByEmail":   {Enumerable: 1, Exact: true, Unbounded: false},
	"GetUserProfile":    {Enumerable: 2, Exact: true, Unbounded: false},
	"ListAuditLogs":     {Enumerable: 2, Exact: true, Unbounded: false},
	"ListUsersSorted":   {Enumerable: 26, Exact: true, Unbounded: false},
	"SearchUsers":       {Enumerable: 64, Exact: true, Unbounded: false},
	"UpdateUserProfile": {Enumerable: 4, Exact: true, Unbounded: false},
	"UserAuditActions":  {Enumerable: 1, Exact: true, Unbounded: false},
}

ShapeSpace describes each query's reachable shape space, computed at generate time (design doc 18): the enumerable dimensions' shape count, whether that count is exact (large @order-by permutation spaces saturate at MaxUint64), and whether unbounded dimensions exist (@filter-tree structure; @in arity on expanding dialects) — under which used-vs-reachable coverage is a floor, never a ratio.

Functions

func FilterUsersEmailPrefix

func FilterUsersEmailPrefix(scopePrefix string) runtime.Tree

FilterUsersEmailPrefix builds the "email_prefix" predicate of @filter-tree(scope).

func FilterUsersStatusEq

func FilterUsersStatusEq(scopeStatus string) runtime.Tree

FilterUsersStatusEq builds the "status_eq" predicate of @filter-tree(scope).

func FilterUsersTenant

func FilterUsersTenant(scopeTenantID int64) runtime.Tree

FilterUsersTenant builds the "tenant" predicate of @filter-tree(scope).

func FilterUsersUnscoped

func FilterUsersUnscoped() runtime.Tree

FilterUsersUnscoped is the explicit, greppable opt-out: it renders TRUE.

Types

type AllAuditActionsParams

type AllAuditActionsParams struct {
}

type AllAuditActionsRow

type AllAuditActionsRow struct {
	Action      string
	Occurrences int64
}

type CountAuditLogsParams

type CountAuditLogsParams struct {
}

type CountAuditLogsRow

type CountAuditLogsRow struct {
	Total int64
}

type DBTX

type DBTX interface {
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

DBTX matches sqlc's pgx flavor: a pgx.Conn, pgxpool.Pool, or pgx.Tx satisfies it, so sqlc- and sqletch-generated code share transactions.

type FilterUsersParams

type FilterUsersParams struct {
	Limit int64
}

type FilterUsersRow

type FilterUsersRow struct {
	ID    int64
	Email string
}

type FindUserByEmailParams

type FindUserByEmailParams struct {
	Email string
}

type FindUserByEmailRow

type FindUserByEmailRow struct {
	ID       int64
	Email    string
	Nickname optional.Option[string]
}

type GetUserProfileParams

type GetUserProfileParams struct {
	ID     int64
	Status optional.Option[string] // None omits the guarded fragment(s)
}

type GetUserProfileRow

type GetUserProfileRow struct {
	ID       int64
	Email    string
	Nickname optional.Option[string]
	OrgID    optional.Option[int64]
}

type ListAuditLogsParams

type ListAuditLogsParams struct {
	TenantID int64
	AfterID  optional.Option[int64] // None omits the guarded fragment(s)
	Limit    int64
}

type ListAuditLogsRow

type ListAuditLogsRow struct {
	ID        int64
	ActorID   optional.Option[int64]
	Action    string
	CreatedAt time.Time
}

type ListUsersSortedParams

type ListUsersSortedParams struct {
	Limit         int64
	IncludeBanned bool                     // @when control parameter
	Sort          []ListUsersSortedSortKey // key sequence; empty = @default
}

type ListUsersSortedRow

type ListUsersSortedRow struct {
	ID        int64
	Email     string
	CreatedAt time.Time
}

type ListUsersSortedSortKey

type ListUsersSortedSortKey int
const (
	ListUsersSortedSortCreatedAtAsc  ListUsersSortedSortKey = 0
	ListUsersSortedSortCreatedAtDesc ListUsersSortedSortKey = 1
	ListUsersSortedSortEmailAsc      ListUsersSortedSortKey = 2
	ListUsersSortedSortEmailDesc     ListUsersSortedSortKey = 3
)

type Querier

type Querier interface {
	AllAuditActions(ctx context.Context, arg AllAuditActionsParams) ([]AllAuditActionsRow, error)
	CountAuditLogs(ctx context.Context, tenantID TenantID, arg CountAuditLogsParams) (CountAuditLogsRow, error)
	FilterUsers(ctx context.Context, scope runtime.Tree, arg FilterUsersParams) ([]FilterUsersRow, error)
	FindUserByEmail(ctx context.Context, arg FindUserByEmailParams) (optional.Option[FindUserByEmailRow], error)
	GetUserProfile(ctx context.Context, arg GetUserProfileParams) (GetUserProfileRow, error)
	ListAuditLogs(ctx context.Context, arg ListAuditLogsParams) ([]ListAuditLogsRow, error)
	ListUsersSorted(ctx context.Context, arg ListUsersSortedParams) ([]ListUsersSortedRow, error)
	SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)
	UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (UpdateUserProfileRow, error)
	UserAuditActions(ctx context.Context, tenantID TenantID, arg UserAuditActionsParams) ([]UserAuditActionsRow, error)
}

Querier lets user code mock the generated queries.

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AllAuditActions

func (q *Queries) AllAuditActions(ctx context.Context, arg AllAuditActionsParams) ([]AllAuditActionsRow, error)

func (*Queries) Cache

func (q *Queries) Cache() *runtime.ComposedCache

Cache exposes the composed-SQL cache for scrape-time inspection (Stats, TopShapes). Mutating it is the generated code's business, not the caller's.

func (*Queries) CountAuditLogs

func (q *Queries) CountAuditLogs(ctx context.Context, tenantID TenantID, arg CountAuditLogsParams) (CountAuditLogsRow, error)

tenantID is required (policy tenant_scope).

func (*Queries) FilterUsers

func (q *Queries) FilterUsers(ctx context.Context, scope runtime.Tree, arg FilterUsersParams) ([]FilterUsersRow, error)

scope is required (@filter-tree!; FilterUsersUnscoped() opts out).

func (*Queries) FindUserByEmail

func (*Queries) GetUserProfile

func (q *Queries) GetUserProfile(ctx context.Context, arg GetUserProfileParams) (GetUserProfileRow, error)

func (*Queries) ListAuditLogs

func (q *Queries) ListAuditLogs(ctx context.Context, arg ListAuditLogsParams) ([]ListAuditLogsRow, error)

func (*Queries) ListUsersSorted

func (q *Queries) ListUsersSorted(ctx context.Context, arg ListUsersSortedParams) ([]ListUsersSortedRow, error)

func (*Queries) OnQuery

func (q *Queries) OnQuery(fn func(shapeKey, sql string))

OnQuery installs an observability hook receiving the shape key and the composed SQL of every call.

func (*Queries) SearchUsers

func (q *Queries) SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)

func (*Queries) SetObserver

func (q *Queries) SetObserver(o runtime.Observer)

SetObserver installs a runtime observer receiving compose, exec, and reject events for every query on this Queries value and any WithTx derivative (design doc 18). Install it before serving traffic; Cache() exposes the same cache for scrape-time Stats and TopShapes.

func (*Queries) UpdateUserProfile

func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (UpdateUserProfileRow, error)

func (*Queries) UserAuditActions

func (q *Queries) UserAuditActions(ctx context.Context, tenantID TenantID, arg UserAuditActionsParams) ([]UserAuditActionsRow, error)

tenantID is required (policy tenant_scope).

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SearchUsersParams

type SearchUsersParams struct {
	OrganizationID optional.Option[int64]     // None omits the guarded fragment(s)
	Status         optional.Option[string]    // None omits the guarded fragment(s)
	EmailPrefix    optional.Option[string]    // None omits the guarded fragment(s)
	CreatedAfter   optional.Option[time.Time] // None omits the guarded fragment(s)
	Limit          int64
	Sort           SearchUsersSort // zero value selects @default
}

type SearchUsersRow

type SearchUsersRow struct {
	ID        int64
	Email     string
	Status    string
	CreatedAt time.Time
}

type SearchUsersSort

type SearchUsersSort int
const (
	SearchUsersSortDefault SearchUsersSort = iota
	SearchUsersSortCreatedAtDesc
	SearchUsersSortCreatedAtAsc
	SearchUsersSortEmailAsc
)

type TenantID

type TenantID int64

TenantID is the "tenant_id" argument woven by policy tenant_scope. A distinct type keeps same-typed policy arguments from being swapped at a call site; construct it explicitly: TenantID(v).

type UpdateUserProfileParams

type UpdateUserProfileParams struct {
	Email    optional.Option[string] // None omits the guarded fragment(s)
	Nickname optional.Option[string] // None omits the guarded fragment(s)
	ID       int64
}

type UpdateUserProfileRow

type UpdateUserProfileRow struct {
	ID        int64
	Email     string
	Nickname  optional.Option[string]
	UpdatedAt time.Time
}

type UserAuditActionsParams

type UserAuditActionsParams struct {
}

type UserAuditActionsRow

type UserAuditActionsRow struct {
	ID     int64
	Action optional.Option[string]
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL