Skip to content

Commit 3687cde

Browse files
fix: shifted 2 functions to use the @sentry/api package
1 parent 80b809d commit 3687cde

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/lib/api-client.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010

1111
import {
12+
createANewProject,
1213
listAnOrganization_sIssues,
14+
listAnOrganization_sRepositories,
1315
listAnOrganization_sTeams,
1416
listAProject_sClientKeys,
1517
listAProject_sTeams,
@@ -682,13 +684,13 @@ export type ProjectWithOrg = SentryProject & {
682684
export async function listRepositories(
683685
orgSlug: string
684686
): Promise<SentryRepository[]> {
685-
const regionUrl = await resolveOrgRegion(orgSlug);
686-
687-
const { data } = await apiRequestToRegion<SentryRepository[]>(
688-
regionUrl,
689-
`/organizations/${orgSlug}/repos/`
690-
);
691-
return data;
687+
const config = await getOrgSdkConfig(orgSlug);
688+
const result = await listAnOrganization_sRepositories({
689+
...config,
690+
path: { organization_id_or_slug: orgSlug },
691+
});
692+
const data = unwrapResult(result, "Failed to list repositories");
693+
return data as unknown as SentryRepository[];
692694
}
693695

694696
/**
@@ -719,7 +721,6 @@ type CreateProjectBody = {
719721

720722
/**
721723
* Create a new project in an organization under a team.
722-
* Uses region-aware routing via the /teams/ endpoint regex.
723724
*
724725
* @param orgSlug - The organization slug
725726
* @param teamSlug - The team slug to create the project under
@@ -732,13 +733,17 @@ export async function createProject(
732733
teamSlug: string,
733734
body: CreateProjectBody
734735
): Promise<SentryProject> {
735-
const regionUrl = await resolveOrgRegion(orgSlug);
736-
const { data } = await apiRequestToRegion<SentryProject>(
737-
regionUrl,
738-
`/teams/${orgSlug}/${teamSlug}/projects/`,
739-
{ method: "POST", body }
740-
);
741-
return data;
736+
const config = await getOrgSdkConfig(orgSlug);
737+
const result = await createANewProject({
738+
...config,
739+
path: {
740+
organization_id_or_slug: orgSlug,
741+
team_id_or_slug: teamSlug,
742+
},
743+
body,
744+
});
745+
const data = unwrapResult(result, "Failed to create project");
746+
return data as unknown as SentryProject;
742747
}
743748

744749
/**

0 commit comments

Comments
 (0)