@@ -40,6 +40,7 @@ import { getAuditService } from "@/ee/features/audit/factory";
4040import { addUserToOrganization , orgHasAvailability } from "@/lib/authUtils" ;
4141import { getOrgMetadata } from "@/lib/utils" ;
4242import { getOrgFromDomain } from "./data/org" ;
43+ import { withOptionalAuthV2 } from "./withAuthV2" ;
4344
4445const ajv = new Ajv ( {
4546 validateFormats : false ,
@@ -637,49 +638,47 @@ export const getConnectionInfo = async (connectionId: number, domain: string) =>
637638 }
638639 } ) ) ) ;
639640
640- export const getRepos = async ( domain : string , filter : { status ?: RepoIndexingStatus [ ] , connectionId ?: number } = { } ) => sew ( ( ) =>
641- withAuth ( ( userId ) =>
642- withOrgMembership ( userId , domain , async ( { org } ) => {
643- const repos = await prisma . repo . findMany ( {
644- where : {
645- orgId : org . id ,
646- ...( filter . status ? {
647- repoIndexingStatus : { in : filter . status }
648- } : { } ) ,
649- ...( filter . connectionId ? {
650- connections : {
651- some : {
652- connectionId : filter . connectionId
653- }
654- }
655- } : { } ) ,
656- } ,
657- include : {
641+ export const getRepos = async ( filter : { status ?: RepoIndexingStatus [ ] , connectionId ?: number } = { } ) => sew ( ( ) =>
642+ withOptionalAuthV2 ( async ( { org } ) => {
643+ const repos = await prisma . repo . findMany ( {
644+ where : {
645+ orgId : org . id ,
646+ ...( filter . status ? {
647+ repoIndexingStatus : { in : filter . status }
648+ } : { } ) ,
649+ ...( filter . connectionId ? {
658650 connections : {
659- include : {
660- connection : true ,
651+ some : {
652+ connectionId : filter . connectionId
661653 }
662654 }
655+ } : { } ) ,
656+ } ,
657+ include : {
658+ connections : {
659+ include : {
660+ connection : true ,
661+ }
663662 }
664- } ) ;
663+ }
664+ } ) ;
665665
666- return repos . map ( ( repo ) => repositoryQuerySchema . parse ( {
667- codeHostType : repo . external_codeHostType ,
668- repoId : repo . id ,
669- repoName : repo . name ,
670- repoDisplayName : repo . displayName ?? undefined ,
671- repoCloneUrl : repo . cloneUrl ,
672- webUrl : repo . webUrl ?? undefined ,
673- linkedConnections : repo . connections . map ( ( { connection } ) => ( {
674- id : connection . id ,
675- name : connection . name ,
676- } ) ) ,
677- imageUrl : repo . imageUrl ?? undefined ,
678- indexedAt : repo . indexedAt ?? undefined ,
679- repoIndexingStatus : repo . repoIndexingStatus ,
680- } ) ) ;
681- } , /* minRequiredRole = */ OrgRole . GUEST ) , /* allowAnonymousAccess = */ true
682- ) ) ;
666+ return repos . map ( ( repo ) => repositoryQuerySchema . parse ( {
667+ codeHostType : repo . external_codeHostType ,
668+ repoId : repo . id ,
669+ repoName : repo . name ,
670+ repoDisplayName : repo . displayName ?? undefined ,
671+ repoCloneUrl : repo . cloneUrl ,
672+ webUrl : repo . webUrl ?? undefined ,
673+ linkedConnections : repo . connections . map ( ( { connection } ) => ( {
674+ id : connection . id ,
675+ name : connection . name ,
676+ } ) ) ,
677+ imageUrl : repo . imageUrl ?? undefined ,
678+ indexedAt : repo . indexedAt ?? undefined ,
679+ repoIndexingStatus : repo . repoIndexingStatus ,
680+ } ) )
681+ } ) ) ;
683682
684683export const getRepoInfoByName = async ( repoName : string , domain : string ) => sew ( ( ) =>
685684 withAuth ( ( userId ) =>
0 commit comments