pgrepo

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

func New

func New(pool *pgxpool.Pool) *Repo

func (*Repo) AcceptInvitation

func (r *Repo) AcceptInvitation(ctx context.Context, invitationID, userID, email string, now time.Time) (app.Workspace, error)

func (*Repo) AcceptInvitationTx

func (r *Repo) AcceptInvitationTx(ctx context.Context, tx pgx.Tx, invitationID, userID, email string, now time.Time) (app.Workspace, error)

func (*Repo) CountActiveOwners

func (r *Repo) CountActiveOwners(ctx context.Context, workspaceID string) (int, error)

func (*Repo) CountWorkspacesByUser

func (r *Repo) CountWorkspacesByUser(ctx context.Context, userID string) (int, error)

func (*Repo) CountWorkspacesByUserForCreateTx

func (r *Repo) CountWorkspacesByUserForCreateTx(ctx context.Context, tx pgx.Tx, userID string) (int, error)

func (*Repo) CreateInvitation

func (r *Repo) CreateInvitation(ctx context.Context, workspaceID, email, role, createdBy string, expiresAt time.Time) (app.Invitation, error)

func (*Repo) CreatePersonalWorkspaceTx added in v0.9.0

func (r *Repo) CreatePersonalWorkspaceTx(ctx context.Context, tx pgx.Tx, slug, ownerUserID string, now time.Time) (app.Workspace, error)

CreatePersonalWorkspaceTx is the ADR 0016 personal-workspace insert: name and kind are fixed ('Personal' / 'personal'), plan_code takes the column default ('free'). Mirrors CreateWorkspaceWithOwnerTx — workspace row plus the owner membership row in the same transaction — so a 23505 on either insert (uq_workspace_personal, workspace_slug_key, uq_member_active) rolls the whole thing back and surfaces as app.ErrDuplicate.

func (r *Repo) CreateShareLink(ctx context.Context, workspaceID, codeHash, codePrefix, role, createdBy string, maxUses int, expiresAt time.Time) (app.ShareLink, error)

func (*Repo) CreateWorkspaceWithOwner

func (r *Repo) CreateWorkspaceWithOwner(ctx context.Context, slug, name, ownerUserID string, now time.Time) (app.Workspace, error)

func (*Repo) CreateWorkspaceWithOwnerTx

func (r *Repo) CreateWorkspaceWithOwnerTx(ctx context.Context, tx pgx.Tx, slug, name, ownerUserID string, now time.Time) (app.Workspace, error)

func (*Repo) DeclineInvitation

func (r *Repo) DeclineInvitation(ctx context.Context, invitationID, email string, now time.Time) error

func (*Repo) DeleteRolePerms added in v0.4.0

func (r *Repo) DeleteRolePerms(ctx context.Context, workspaceID, role string) error

func (*Repo) DeleteWorkspaceCascade

func (r *Repo) DeleteWorkspaceCascade(ctx context.Context, tx pgx.Tx, workspaceID string) error

func (*Repo) FindWorkspaceIDBySlug

func (r *Repo) FindWorkspaceIDBySlug(ctx context.Context, slug string) (string, bool, error)

func (*Repo) GetMember

func (r *Repo) GetMember(ctx context.Context, workspaceID, userID string) (app.Member, bool, error)

func (*Repo) GetMemberUserStatus

func (r *Repo) GetMemberUserStatus(ctx context.Context, workspaceID, userID string) (app.Member, string, bool, error)

func (*Repo) GetWorkspace

func (r *Repo) GetWorkspace(ctx context.Context, id string) (app.Workspace, bool, error)

func (*Repo) HasPendingInvitation

func (r *Repo) HasPendingInvitation(ctx context.Context, workspaceID, email string) (bool, error)

func (*Repo) IsMemberByEmail

func (r *Repo) IsMemberByEmail(ctx context.Context, workspaceID, email string) (bool, error)

func (*Repo) ListInvitations

func (r *Repo) ListInvitations(ctx context.Context, workspaceID string, page, pageSize int) (app.Page[app.Invitation], error)

func (*Repo) ListMembers

func (r *Repo) ListMembers(ctx context.Context, workspaceID string, page, pageSize int) (app.Page[app.Member], error)

func (*Repo) ListRoleOverrides added in v0.4.0

func (r *Repo) ListRoleOverrides(ctx context.Context, workspaceID string) (map[string][]authz.Permission, error)
func (r *Repo) ListShareLinks(ctx context.Context, workspaceID string, page, pageSize int) (app.Page[app.ShareLink], error)

func (*Repo) ListWorkspacesByUser

func (r *Repo) ListWorkspacesByUser(ctx context.Context, userID string) ([]app.WorkspaceMembership, error)

func (*Repo) OldestActiveOwner

func (r *Repo) OldestActiveOwner(ctx context.Context, workspaceID string) (app.Member, bool, error)

func (*Repo) PendingInvitationsByEmail

func (r *Repo) PendingInvitationsByEmail(ctx context.Context, email string) ([]app.InvitationWithWorkspace, error)
func (r *Repo) RedeemShareLink(ctx context.Context, codeHash, userID string, now time.Time) (app.Workspace, error)

func (*Repo) RedeemShareLinkTx

func (r *Repo) RedeemShareLinkTx(ctx context.Context, tx pgx.Tx, codeHash, userID string, now time.Time) (app.Workspace, error)

func (*Repo) RevokeInvitation

func (r *Repo) RevokeInvitation(ctx context.Context, workspaceID, invitationID string, now time.Time) error
func (r *Repo) RevokeShareLink(ctx context.Context, workspaceID, linkID string, now time.Time) error

func (*Repo) RunInTx

func (r *Repo) RunInTx(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error

func (*Repo) SoftRemoveMember

func (r *Repo) SoftRemoveMember(ctx context.Context, workspaceID, userID, removedBy string, now time.Time) error

func (*Repo) TransferOwnershipTx

func (r *Repo) TransferOwnershipTx(ctx context.Context, tx pgx.Tx, workspaceID, fromUserID, toUserID string) error

func (*Repo) UpdateMemberRole

func (r *Repo) UpdateMemberRole(ctx context.Context, workspaceID, userID, newRole string, now time.Time) error

func (*Repo) UpdateWorkspaceName

func (r *Repo) UpdateWorkspaceName(ctx context.Context, id, name string, now time.Time) error

func (*Repo) UpsertRolePerms added in v0.4.0

func (r *Repo) UpsertRolePerms(ctx context.Context, workspaceID, role string, perms []authz.Permission, now time.Time) error

Jump to

Keyboard shortcuts

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