@@ -40,6 +40,7 @@ import { getAuditService } from "@/ee/features/audit/factory";
40
40
import { addUserToOrganization , orgHasAvailability } from "@/lib/authUtils" ;
41
41
import { getOrgMetadata } from "@/lib/utils" ;
42
42
import { getOrgFromDomain } from "./data/org" ;
43
+ import { withOptionalAuthV2 } from "./withAuthV2" ;
43
44
44
45
const ajv = new Ajv ( {
45
46
validateFormats : false ,
@@ -637,49 +638,47 @@ export const getConnectionInfo = async (connectionId: number, domain: string) =>
637
638
}
638
639
} ) ) ) ;
639
640
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 ? {
658
650
connections : {
659
- include : {
660
- connection : true ,
651
+ some : {
652
+ connectionId : filter . connectionId
661
653
}
662
654
}
655
+ } : { } ) ,
656
+ } ,
657
+ include : {
658
+ connections : {
659
+ include : {
660
+ connection : true ,
661
+ }
663
662
}
664
- } ) ;
663
+ }
664
+ } ) ;
665
665
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
+ } ) ) ;
683
682
684
683
export const getRepoInfoByName = async ( repoName : string , domain : string ) => sew ( ( ) =>
685
684
withAuth ( ( userId ) =>
0 commit comments