| 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 | CreateOrgGithubImport(ctx context.Context, db DBTX, arg CreateOrgGithubImportParams) (OrgGithubImport, error) |
| 37 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 38 | // ─── org_invitations ─────────────────────────────────────────────── |
| 39 | CreateOrgInvitation(ctx context.Context, db DBTX, arg CreateOrgInvitationParams) (OrgInvitation, error) |
| 40 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 41 | // ─── teams ───────────────────────────────────────────────────────── |
| 42 | CreateTeam(ctx context.Context, db DBTX, arg CreateTeamParams) (Team, error) |
| 43 | DeclineOrgInvitation(ctx context.Context, db DBTX, id int64) error |
| 44 | // Children's parent_team_id flips to NULL via the FK ON DELETE SET NULL, |
| 45 | // promoting them to top-level — matches the "deleting parent doesn't |
| 46 | // delete children" intent in the spec's pitfalls. |
| 47 | DeleteTeam(ctx context.Context, db DBTX, id int64) error |
| 48 | // Idempotency check before creating a new invite — so a re-issued |
| 49 | // invite to the same target doesn't accumulate stale rows. |
| 50 | GetExistingPendingInvitation(ctx context.Context, db DBTX, arg GetExistingPendingInvitationParams) (OrgInvitation, error) |
| 51 | GetOrgByID(ctx context.Context, db DBTX, id int64) (Org, error) |
| 52 | // Slug is citext so the comparison is case-insensitive. Soft-deleted |
| 53 | // orgs are filtered out so a slug freed by deletion is invisible to |
| 54 | // normal lookups (the resolver still sees the row via the deleted_at |
| 55 | // column for grace-period restore). |
| 56 | GetOrgBySlug(ctx context.Context, db DBTX, slug string) (Org, error) |
| 57 | GetOrgBySlugIncludingDeleted(ctx context.Context, db DBTX, slug string) (Org, error) |
| 58 | GetOrgGithubImport(ctx context.Context, db DBTX, id int64) (OrgGithubImport, error) |
| 59 | GetOrgGithubImportForOrg(ctx context.Context, db DBTX, arg GetOrgGithubImportForOrgParams) (OrgGithubImport, error) |
| 60 | GetOrgGithubImportProgress(ctx context.Context, db DBTX, arg GetOrgGithubImportProgressParams) (GetOrgGithubImportProgressRow, error) |
| 61 | GetOrgGithubImportRepo(ctx context.Context, db DBTX, id int64) (OrgGithubImportRepo, error) |
| 62 | GetOrgInvitationByID(ctx context.Context, db DBTX, id int64) (OrgInvitation, error) |
| 63 | GetOrgInvitationByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (OrgInvitation, error) |
| 64 | GetOrgMember(ctx context.Context, db DBTX, arg GetOrgMemberParams) (OrgMember, error) |
| 65 | GetTeamByID(ctx context.Context, db DBTX, id int64) (Team, error) |
| 66 | GetTeamByOrgAndSlug(ctx context.Context, db DBTX, arg GetTeamByOrgAndSlugParams) (Team, error) |
| 67 | GetTeamRepoAccess(ctx context.Context, db DBTX, arg GetTeamRepoAccessParams) (TeamRepoAccess, error) |
| 68 | // ─── team_repo_access ───────────────────────────────────────────── |
| 69 | GrantTeamRepoAccess(ctx context.Context, db DBTX, arg GrantTeamRepoAccessParams) error |
| 70 | // Final row removal after the cascade finished. The principals |
| 71 | // trigger drops the matching principals row in the same tx. |
| 72 | HardDeleteOrgRow(ctx context.Context, db DBTX, id int64) error |
| 73 | InsertOrgGithubImportRepo(ctx context.Context, db DBTX, arg InsertOrgGithubImportRepoParams) (OrgGithubImportRepo, error) |
| 74 | // Replaces the inline EXISTS query in handlers/orgs/teams.go |
| 75 | // canSeeTeam + filterSecretTeams (SR2 M2). Used by the visibility |
| 76 | // gate for secret teams. |
| 77 | IsTeamMember(ctx context.Context, db DBTX, arg IsTeamMemberParams) (bool, error) |
| 78 | ListChildTeams(ctx context.Context, db DBTX, parentTeamID pgtype.Int8) ([]Team, error) |
| 79 | ListOrgGithubImportRepos(ctx context.Context, db DBTX, importID int64) ([]OrgGithubImportRepo, error) |
| 80 | ListOrgGithubImportsForOrg(ctx context.Context, db DBTX, arg ListOrgGithubImportsForOrgParams) ([]OrgGithubImport, error) |
| 81 | // Sweep input for the lifecycle worker: every soft-deleted org whose |
| 82 | // 14-day grace window has elapsed. The interval is intentionally a |
| 83 | // DB literal (not a parameter) so the policy lives next to the data. |
| 84 | ListOrgIDsPastSoftDeleteGrace(ctx context.Context, db DBTX) ([]int64, error) |
| 85 | // Members of an org with usernames + roles for the people page. |
| 86 | ListOrgMembers(ctx context.Context, db DBTX, orgID int64) ([]ListOrgMembersRow, error) |
| 87 | // All repo IDs (including soft-deleted) belonging to an org. Used by |
| 88 | // the org hard-delete cascade to fan out per-repo destruction. |
| 89 | ListOrgRepoIDs(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) ([]int64, error) |
| 90 | // Profile-page input: every org a user is a member of, with role. |
| 91 | ListOrgsForUser(ctx context.Context, db DBTX, userID int64) ([]ListOrgsForUserRow, error) |
| 92 | ListPendingInvitationsForEmail(ctx context.Context, db DBTX, targetEmail pgtype.Text) ([]ListPendingInvitationsForEmailRow, error) |
| 93 | ListPendingInvitationsForOrg(ctx context.Context, db DBTX, orgID int64) ([]ListPendingInvitationsForOrgRow, error) |
| 94 | // Two flavors: by user_id (already-claimed invites) and by email |
| 95 | // (claim-on-signup). Caller unions the two lookups when surfacing |
| 96 | // to the user. |
| 97 | ListPendingInvitationsForUser(ctx context.Context, db DBTX, targetUserID pgtype.Int8) ([]ListPendingInvitationsForUserRow, error) |
| 98 | // All teams with grants on a single repo; for repo settings/access page. |
| 99 | ListRepoTeamGrants(ctx context.Context, db DBTX, repoID int64) ([]ListRepoTeamGrantsRow, error) |
| 100 | // Policy hot-path: given a repo and a set of team_ids the actor |
| 101 | // belongs to (incl. inherited), return the access rows. Caller picks |
| 102 | // the highest role. |
| 103 | ListTeamAccessForRepoAndTeams(ctx context.Context, db DBTX, arg ListTeamAccessForRepoAndTeamsParams) ([]ListTeamAccessForRepoAndTeamsRow, error) |
| 104 | ListTeamMembers(ctx context.Context, db DBTX, teamID int64) ([]ListTeamMembersRow, error) |
| 105 | // All repos the team has any grant on; for the team-view page. |
| 106 | ListTeamRepoAccess(ctx context.Context, db DBTX, teamID int64) ([]ListTeamRepoAccessRow, error) |
| 107 | ListTeamsForOrg(ctx context.Context, db DBTX, orgID int64) ([]Team, error) |
| 108 | // Returns the teams a user directly belongs to within an org. The |
| 109 | // policy aggregator unions this with each row's parent_team_id to |
| 110 | // get the inherited set. |
| 111 | ListTeamsForUserInOrg(ctx context.Context, db DBTX, arg ListTeamsForUserInOrgParams) ([]ListTeamsForUserInOrgRow, error) |
| 112 | MarkOrgGithubImportCompleted(ctx context.Context, db DBTX, id int64) error |
| 113 | MarkOrgGithubImportCompletedIfDone(ctx context.Context, db DBTX, id int64) (OrgGithubImport, error) |
| 114 | MarkOrgGithubImportDiscovering(ctx context.Context, db DBTX, id int64) error |
| 115 | MarkOrgGithubImportFailed(ctx context.Context, db DBTX, arg MarkOrgGithubImportFailedParams) error |
| 116 | MarkOrgGithubImportImporting(ctx context.Context, db DBTX, arg MarkOrgGithubImportImportingParams) error |
| 117 | MarkOrgGithubImportRepoFailed(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoFailedParams) error |
| 118 | MarkOrgGithubImportRepoImported(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoImportedParams) error |
| 119 | MarkOrgGithubImportRepoImporting(ctx context.Context, db DBTX, id int64) error |
| 120 | MarkOrgGithubImportRepoSkipped(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoSkippedParams) error |
| 121 | RemoveOrgMember(ctx context.Context, db DBTX, arg RemoveOrgMemberParams) error |
| 122 | RemoveTeamMember(ctx context.Context, db DBTX, arg RemoveTeamMemberParams) error |
| 123 | // ─── principals (read-only from this domain) ─────────────────────── |
| 124 | // Single-query /{slug} resolver. Returns the (kind, id) tuple that |
| 125 | // /{slug}/* routes use to dispatch to the user-profile or org-profile |
| 126 | // handler. Both kinds share the slug PK so collisions are |
| 127 | // impossible at the DB layer. |
| 128 | ResolvePrincipal(ctx context.Context, db DBTX, slug string) (Principal, error) |
| 129 | RestoreOrg(ctx context.Context, db DBTX, id int64) error |
| 130 | RevokeTeamRepoAccess(ctx context.Context, db DBTX, arg RevokeTeamRepoAccessParams) error |
| 131 | SetOrgAllowMemberRepoCreate(ctx context.Context, db DBTX, arg SetOrgAllowMemberRepoCreateParams) error |
| 132 | SetOrgAvatarKey(ctx context.Context, db DBTX, arg SetOrgAvatarKeyParams) error |
| 133 | SetOrgSuspended(ctx context.Context, db DBTX, arg SetOrgSuspendedParams) error |
| 134 | SetTeamMemberRole(ctx context.Context, db DBTX, arg SetTeamMemberRoleParams) error |
| 135 | // The one-level-nesting BEFORE trigger blocks invalid moves; the |
| 136 | // caller surfaces the SQLSTATE 23514 as a friendly error. |
| 137 | SetTeamParent(ctx context.Context, db DBTX, arg SetTeamParentParams) error |
| 138 | SoftDeleteOrg(ctx context.Context, db DBTX, id int64) error |
| 139 | UpdateOrgProfile(ctx context.Context, db DBTX, arg UpdateOrgProfileParams) error |
| 140 | UpdateTeamProfile(ctx context.Context, db DBTX, arg UpdateTeamProfileParams) error |
| 141 | } |
| 142 | |
| 143 | var _ Querier = (*Queries)(nil) |
| 144 |