Go · 8932 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4
5 package orgsdb
6
7 import (
8 "context"
9
10 "github.com/jackc/pgx/v5/pgtype"
11 )
12
13 type Querier interface {
14 AcceptOrgInvitation(ctx context.Context, db DBTX, id int64) error
15 // SPDX-License-Identifier: AGPL-3.0-or-later
16 // ─── org_members ───────────────────────────────────────────────────
17 // Idempotent on (org_id, user_id): re-adding a member is a no-op
18 // rather than an error. The role is taken from the supplied row when
19 // the member is new; existing rows keep their current role (use
20 // ChangeOrgMemberRole to update).
21 AddOrgMember(ctx context.Context, db DBTX, arg AddOrgMemberParams) error
22 // ─── team_members ─────────────────────────────────────────────────
23 AddTeamMember(ctx context.Context, db DBTX, arg AddTeamMemberParams) error
24 CancelOrgInvitation(ctx context.Context, db DBTX, id int64) error
25 ChangeOrgMemberRole(ctx context.Context, db DBTX, arg ChangeOrgMemberRoleParams) error
26 // Used by the last-owner protection: refuses to remove or demote the
27 // only owner. Caller compares `count = 1` before allowing the change.
28 CountOrgOwners(ctx context.Context, db DBTX, orgID int64) (int64, error)
29 // SPDX-License-Identifier: AGPL-3.0-or-later
30 // ─── orgs ──────────────────────────────────────────────────────────
31 // Inserts a new org. The trigger on `orgs` populates `principals` for
32 // /{slug} resolution; the caller adds the creator as owner in the same
33 // tx (separate query so the orchestrator owns ordering).
34 CreateOrg(ctx context.Context, db DBTX, arg CreateOrgParams) (Org, error)
35 // SPDX-License-Identifier: AGPL-3.0-or-later
36 // ─── org_invitations ───────────────────────────────────────────────
37 CreateOrgInvitation(ctx context.Context, db DBTX, arg CreateOrgInvitationParams) (OrgInvitation, error)
38 // SPDX-License-Identifier: AGPL-3.0-or-later
39 // ─── teams ─────────────────────────────────────────────────────────
40 CreateTeam(ctx context.Context, db DBTX, arg CreateTeamParams) (Team, error)
41 DeclineOrgInvitation(ctx context.Context, db DBTX, id int64) error
42 // Children's parent_team_id flips to NULL via the FK ON DELETE SET NULL,
43 // promoting them to top-level — matches the "deleting parent doesn't
44 // delete children" intent in the spec's pitfalls.
45 DeleteTeam(ctx context.Context, db DBTX, id int64) error
46 // Idempotency check before creating a new invite — so a re-issued
47 // invite to the same target doesn't accumulate stale rows.
48 GetExistingPendingInvitation(ctx context.Context, db DBTX, arg GetExistingPendingInvitationParams) (OrgInvitation, error)
49 GetOrgByID(ctx context.Context, db DBTX, id int64) (Org, error)
50 // Slug is citext so the comparison is case-insensitive. Soft-deleted
51 // orgs are filtered out so a slug freed by deletion is invisible to
52 // normal lookups (the resolver still sees the row via the deleted_at
53 // column for grace-period restore).
54 GetOrgBySlug(ctx context.Context, db DBTX, slug string) (Org, error)
55 GetOrgBySlugIncludingDeleted(ctx context.Context, db DBTX, slug string) (Org, error)
56 GetOrgInvitationByID(ctx context.Context, db DBTX, id int64) (OrgInvitation, error)
57 GetOrgInvitationByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (OrgInvitation, error)
58 GetOrgMember(ctx context.Context, db DBTX, arg GetOrgMemberParams) (OrgMember, error)
59 GetTeamByID(ctx context.Context, db DBTX, id int64) (Team, error)
60 GetTeamByOrgAndSlug(ctx context.Context, db DBTX, arg GetTeamByOrgAndSlugParams) (Team, error)
61 GetTeamRepoAccess(ctx context.Context, db DBTX, arg GetTeamRepoAccessParams) (TeamRepoAccess, error)
62 // ─── team_repo_access ─────────────────────────────────────────────
63 GrantTeamRepoAccess(ctx context.Context, db DBTX, arg GrantTeamRepoAccessParams) error
64 // Final row removal after the cascade finished. The principals
65 // trigger drops the matching principals row in the same tx.
66 HardDeleteOrgRow(ctx context.Context, db DBTX, id int64) error
67 // Replaces the inline EXISTS query in handlers/orgs/teams.go
68 // canSeeTeam + filterSecretTeams (SR2 M2). Used by the visibility
69 // gate for secret teams.
70 IsTeamMember(ctx context.Context, db DBTX, arg IsTeamMemberParams) (bool, error)
71 ListChildTeams(ctx context.Context, db DBTX, parentTeamID pgtype.Int8) ([]Team, error)
72 // Sweep input for the lifecycle worker: every soft-deleted org whose
73 // 14-day grace window has elapsed. The interval is intentionally a
74 // DB literal (not a parameter) so the policy lives next to the data.
75 ListOrgIDsPastSoftDeleteGrace(ctx context.Context, db DBTX) ([]int64, error)
76 // Members of an org with usernames + roles for the people page.
77 ListOrgMembers(ctx context.Context, db DBTX, orgID int64) ([]ListOrgMembersRow, error)
78 // All repo IDs (including soft-deleted) belonging to an org. Used by
79 // the org hard-delete cascade to fan out per-repo destruction.
80 ListOrgRepoIDs(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) ([]int64, error)
81 // Profile-page input: every org a user is a member of, with role.
82 ListOrgsForUser(ctx context.Context, db DBTX, userID int64) ([]ListOrgsForUserRow, error)
83 ListPendingInvitationsForEmail(ctx context.Context, db DBTX, targetEmail pgtype.Text) ([]ListPendingInvitationsForEmailRow, error)
84 ListPendingInvitationsForOrg(ctx context.Context, db DBTX, orgID int64) ([]ListPendingInvitationsForOrgRow, error)
85 // Two flavors: by user_id (already-claimed invites) and by email
86 // (claim-on-signup). Caller unions the two lookups when surfacing
87 // to the user.
88 ListPendingInvitationsForUser(ctx context.Context, db DBTX, targetUserID pgtype.Int8) ([]ListPendingInvitationsForUserRow, error)
89 // All teams with grants on a single repo; for repo settings/access page.
90 ListRepoTeamGrants(ctx context.Context, db DBTX, repoID int64) ([]ListRepoTeamGrantsRow, error)
91 // Policy hot-path: given a repo and a set of team_ids the actor
92 // belongs to (incl. inherited), return the access rows. Caller picks
93 // the highest role.
94 ListTeamAccessForRepoAndTeams(ctx context.Context, db DBTX, arg ListTeamAccessForRepoAndTeamsParams) ([]ListTeamAccessForRepoAndTeamsRow, error)
95 ListTeamMembers(ctx context.Context, db DBTX, teamID int64) ([]ListTeamMembersRow, error)
96 // All repos the team has any grant on; for the team-view page.
97 ListTeamRepoAccess(ctx context.Context, db DBTX, teamID int64) ([]ListTeamRepoAccessRow, error)
98 ListTeamsForOrg(ctx context.Context, db DBTX, orgID int64) ([]Team, error)
99 // Returns the teams a user directly belongs to within an org. The
100 // policy aggregator unions this with each row's parent_team_id to
101 // get the inherited set.
102 ListTeamsForUserInOrg(ctx context.Context, db DBTX, arg ListTeamsForUserInOrgParams) ([]ListTeamsForUserInOrgRow, error)
103 RemoveOrgMember(ctx context.Context, db DBTX, arg RemoveOrgMemberParams) error
104 RemoveTeamMember(ctx context.Context, db DBTX, arg RemoveTeamMemberParams) error
105 // ─── principals (read-only from this domain) ───────────────────────
106 // Single-query /{slug} resolver. Returns the (kind, id) tuple that
107 // /{slug}/* routes use to dispatch to the user-profile or org-profile
108 // handler. Both kinds share the slug PK so collisions are
109 // impossible at the DB layer.
110 ResolvePrincipal(ctx context.Context, db DBTX, slug string) (Principal, error)
111 RestoreOrg(ctx context.Context, db DBTX, id int64) error
112 RevokeTeamRepoAccess(ctx context.Context, db DBTX, arg RevokeTeamRepoAccessParams) error
113 SetOrgAllowMemberRepoCreate(ctx context.Context, db DBTX, arg SetOrgAllowMemberRepoCreateParams) error
114 SetOrgAvatarKey(ctx context.Context, db DBTX, arg SetOrgAvatarKeyParams) error
115 SetOrgSuspended(ctx context.Context, db DBTX, arg SetOrgSuspendedParams) error
116 SetTeamMemberRole(ctx context.Context, db DBTX, arg SetTeamMemberRoleParams) error
117 // The one-level-nesting BEFORE trigger blocks invalid moves; the
118 // caller surfaces the SQLSTATE 23514 as a friendly error.
119 SetTeamParent(ctx context.Context, db DBTX, arg SetTeamParentParams) error
120 SoftDeleteOrg(ctx context.Context, db DBTX, id int64) error
121 UpdateOrgProfile(ctx context.Context, db DBTX, arg UpdateOrgProfileParams) error
122 UpdateTeamProfile(ctx context.Context, db DBTX, arg UpdateTeamProfileParams) error
123 }
124
125 var _ Querier = (*Queries)(nil)
126